-
Notifications
You must be signed in to change notification settings - Fork 128
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 __posthog_debug query string #1108
Conversation
src/posthog-core.ts
Outdated
@@ -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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugly because we have to support IE11, so no URLSearchParams or even string.includes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
surprised we don't already have a convenience function for is blah in the URL but let's not overcomplicate by adding one if we don't already 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have _isString
so you could really belt and braces by replacing location?.search
with _isString(location?.search)
but that's very nit picky and I don't think it adds enough safety to the check to care
Size Change: +589 B (0%) Total Size: 943 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't run it so nitpicky comment worrying about type-safety but other than that this seems a great idea 🚀 🚢
src/posthog-core.ts
Outdated
@@ -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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
surprised we don't already have a convenience function for is blah in the URL but let's not overcomplicate by adding one if we don't already 😊
src/posthog-core.ts
Outdated
@@ -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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have _isString
so you could really belt and braces by replacing location?.search
with _isString(location?.search)
but that's very nit picky and I don't think it adds enough safety to the check to care
Changes
Add a query string to help with debugging the first visit to a site.
We already have the local storage version of this, but the query string method allows testing the order of operations when first visiting a site in a private browser tab, where local storage doesn't exist
Checklist