From 4bbf0cfafb466147dde8d045c454e5c343153d7b Mon Sep 17 00:00:00 2001 From: Robbie Date: Wed, 3 Apr 2024 12:00:54 +0100 Subject: [PATCH] feat: Add __posthog_debug query string (#1108) * Add __posthog_debug query string * Add more defensiveness --- 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..d289efcd8 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 && _isString(location?.search) && location.search.indexOf('__posthog_debug=true') !== -1) || false, verbose: false, cookie_expiration: 365, upgrade: false,