Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add debug logic for set_config #1330

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1733,6 +1735,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
Loading