-
Notifications
You must be signed in to change notification settings - Fork 140
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
fix: capture a $pageview event on opting in #1372
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size Change: +1.06 kB (+0.09%) Total Size: 1.17 MB
ℹ️ View Unchanged
|
…-pageview-on-opt-in
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.
Generally looks good. Just a change to make it easier to maintain in the future
src/posthog-core.ts
Outdated
if (this.config.capture_pageview && !this._initialPageviewCaptured && document) { | ||
this._initialPageviewCaptured = true | ||
this.capture('$pageview', { title: document.title }, { send_instantly: true }) | ||
} |
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.
Could we move this block into a private method like captureInitialPageview
instead. that way it isn't likely to get forgotten about later in one place or the other
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.
Thanks @benjackwhite! I added a private method.
Approved - dont forget to bump the label |
Changes
The initial
$pageview
is not captured when customers use the opt in/out flow. It creates a discrepancy in event count like this one. The PR changes the behavior to capture the initial$pageview
event after a user opts in if the event hasn't yet been sent.Before
After
Checklist