From a1619cc8b428bd17189cd451353fd43580b47979 Mon Sep 17 00:00:00 2001 From: Robbie Coomber Date: Tue, 2 Apr 2024 13:47:26 +0100 Subject: [PATCH 1/2] Add __posthog_debug query string --- src/posthog-core.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/posthog-core.ts b/src/posthog-core.ts index 357fdca1a..6efb90719 100644 --- a/src/posthog-core.ts +++ b/src/posthog-core.ts @@ -10,7 +10,7 @@ import { isCrossDomainCookie, isDistinctIdStringLike, } from './utils' -import { window, assignableWindow } from './utils/globals' +import { window, assignableWindow, location } from './utils/globals' import { autocapture } from './autocapture' import { PostHogFeatureFlags } from './posthog-featureflags' import { PostHogPersistence } from './posthog-persistence' @@ -124,7 +124,7 @@ export const defaultConfig = (): PostHogConfig => ({ save_referrer: true, capture_pageview: true, capture_pageleave: true, // We'll only capture pageleave events if capture_pageview is also true - debug: false, + debug: (location?.search && location.search.indexOf('__posthog_debug=true') !== -1) || false, verbose: false, cookie_expiration: 365, upgrade: false, From 4ce09167d6f29d62ee244b0a0209e2851edc7117 Mon Sep 17 00:00:00 2001 From: Robbie Date: Wed, 3 Apr 2024 11:38:47 +0100 Subject: [PATCH 2/2] Add more defensiveness --- src/posthog-core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/posthog-core.ts b/src/posthog-core.ts index 6efb90719..d289efcd8 100644 --- a/src/posthog-core.ts +++ b/src/posthog-core.ts @@ -124,7 +124,7 @@ export const defaultConfig = (): PostHogConfig => ({ save_referrer: true, capture_pageview: true, capture_pageleave: true, // We'll only capture pageleave events if capture_pageview is also true - debug: (location?.search && location.search.indexOf('__posthog_debug=true') !== -1) || false, + debug: (location && _isString(location?.search) && location.search.indexOf('__posthog_debug=true') !== -1) || false, verbose: false, cookie_expiration: 365, upgrade: false,