Skip to content

Commit

Permalink
feat: Add debug logic for set_config (#1330)
Browse files Browse the repository at this point in the history
* Add debug logic for set_config

* Improve startup debug log

* Add logging to persistence
  • Loading branch information
robbie-c authored and Phanatic committed Jul 31, 2024
1 parent f5243ff commit e7ff20b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/posthog-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,10 @@ export class PostHog {
// global debug to be true
Config.DEBUG = Config.DEBUG || this.config.debug
if (Config.DEBUG) {
// eslint-disable-next-line no-console
console.log('[PostHog.js] Starting in debug mode', this)
logger.info('Starting in debug mode', {
this: this,
config: { ...this.config },
})
}

this._sync_opt_out_with_persistence()
Expand Down Expand Up @@ -1743,6 +1745,11 @@ export class PostHog {
}
if (this.config.debug) {
Config.DEBUG = true
logger.info('set_config', {
config,
oldConfig,
newConfig: { ...this.config },
})
}

this.sessionRecording?.startIfEnabledOrStop()
Expand Down
3 changes: 3 additions & 0 deletions src/posthog-persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export class PostHogPersistence {
this.name = parseName(config)
this.storage = this.buildStorage(config)
this.load()
if (config.debug) {
logger.info('Persistence loaded', this.props)
}
this.update_config(config, config)
this.save()
}
Expand Down

0 comments on commit e7ff20b

Please sign in to comment.