From 52e2c3762d676506a6276a1f50ecc92b2e14afb7 Mon Sep 17 00:00:00 2001 From: Robbie Coomber Date: Tue, 30 Jul 2024 16:48:04 +0100 Subject: [PATCH 1/3] Add debug logic for set_config --- src/posthog-core.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/posthog-core.ts b/src/posthog-core.ts index 0a999e62a..728f00bed 100644 --- a/src/posthog-core.ts +++ b/src/posthog-core.ts @@ -1733,6 +1733,11 @@ export class PostHog { } if (this.config.debug) { Config.DEBUG = true + logger.info('set_config', { + config, + oldConfig, + newConfig: { ...this.config }, + }) } this.sessionRecording?.startIfEnabledOrStop() From 64cea46082ed41c469cef9edcc8a03f58178a174 Mon Sep 17 00:00:00 2001 From: Robbie Coomber Date: Wed, 31 Jul 2024 13:56:36 +0100 Subject: [PATCH 2/3] Improve startup debug log --- src/posthog-core.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/posthog-core.ts b/src/posthog-core.ts index 728f00bed..56d4a2f67 100644 --- a/src/posthog-core.ts +++ b/src/posthog-core.ts @@ -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() From 89ac701bbb5b337995dff2f99f7a64da6fb2b705 Mon Sep 17 00:00:00 2001 From: Robbie Coomber Date: Wed, 31 Jul 2024 14:13:15 +0100 Subject: [PATCH 3/3] Add logging to persistence --- src/posthog-persistence.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/posthog-persistence.ts b/src/posthog-persistence.ts index 9524f8682..f24d31a1f 100644 --- a/src/posthog-persistence.ts +++ b/src/posthog-persistence.ts @@ -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() }