-
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: Fix the referrer changing mid-session #1314
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
posthog.capture(eventName, eventProperties) | ||
} | ||
expect(onCapture).toHaveBeenCalledTimes(1) | ||
expect(onCapture.mock.calls[0][0]).toBe('$$client_ingestion_warning') |
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.
This test was broken before, it relied on state from the previous test and failed when run in isolation.
expect(properties['$referring_domain']).toBe('referrer.example.com') | ||
}) | ||
|
||
it('should not update the referrer within the same session', () => { |
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.
This test fails without the fix in this PR
@@ -227,7 +227,7 @@ export class PostHogPersistence { | |||
} | |||
|
|||
update_referrer_info(): void { | |||
this.register(Info.referrerInfo()) | |||
this.register_once(Info.referrerInfo(), undefined) |
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.
The one-line actual fix
Size Change: +48 B (0%) Total Size: 1.19 MB
ℹ️ View Unchanged
|
Changes
As part of the personless event changes, we accidentally introduced a bug where the referrer could change mid-session. This shouldn't happen, and led to some annoying situation where e.g. if a payments workflow navigated people to checkout.stripe.com and then back to the original site, the referrer would switch to stripe, which meant that any events after that couldn't be attributed to the original referrer.
This fixes that bug, and adds some tests.
(P.S. I realised how this was broken when working on #1313, IMO with this fix merged that PR becomes a lot less useful)
Checklist