-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(browser): Add mode option for the browser session integration #18997
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
base: develop
Are you sure you want to change the base?
Conversation
6dae52a to
85aa5da
Compare
size-limit report 📦
|
c45eae4 to
452d0c4
Compare
| * | ||
| * @default 'navigation' | ||
| */ | ||
| mode?: 'single' | 'navigation'; |
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.
I am not 100% sure about the naming here, as it's only clear when reading the JS doc. A suggestion:
sessionMode: 'navigation' | 'only-pageload'Hm, now that I think more about it, it's probably fine because this is an option in the browserSessionIntegration and it should be clear that this is about the session. So the naming would actually work already (just leaving this to share my thoughts).
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.
uuuuuuh, I actually like only-pageload. However, it seems too technical correct - it could be that "only-pageload" implies that it doesn't track the session further 🤔
@Lms24 wdyt? To get a third opinion here :)
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.
hmm yeah, "only-pageload" to me also implies something like "we only track sessions for the pageload and stop afterwards".
Let's think about this, also from a perspective of potentially adding a third mode for persisting the id in sessionStorage in the future. So mentally, it should correlate to "short -> medium -> long".
How about:
lifecycle: 'route' | 'page' | 'tab'lifecycle: 'navigation' | 'pageload' | 'tab'
1 has the advantage that it's very descriptive, but confusion could come from "page". I think this is minimal and also kinda works anyway because it's primarily relevant for Single Page applications".
2 is a bit more technical but correlates well with established Sentry terms.
I think with the proper JSDoc (which is already there xD), both would work well. Especially if we pair these with lifecycle since this more directly implies session life time than "mode" IMHO. Fully realizing I said other things offline, so sorry for throwing yet more options into the ring. Thoughts?
fwiw, Gemini clearly prefers 1 😅
| await page.locator('#navigate').click(); | ||
|
|
||
| const sessions = (await sessionsPromise).filter(session => session.init); | ||
|
|
||
| expect(sessions.length).toBe(1); |
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.
l: What I like to do when I test that something is not sent, is to await an event after navigating so that we have some time before ending the tests. I guess in this case, we could wait for an error or a transaction event. There's still an assumption here that the session would have been sent before that event but I think that's reasonable and better than not waiting at all or waiting for a a specific time.
We could even make it more deterministic by:
- going to the page
- awaiting for the init session
- registering the request listener for additional sessions
- navigating
- waiting for the unrelated event
- asserting that no more session envelopes have been sent
| * | ||
| * @default 'navigation' | ||
| */ | ||
| mode?: 'single' | 'navigation'; |
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.
hmm yeah, "only-pageload" to me also implies something like "we only track sessions for the pageload and stop afterwards".
Let's think about this, also from a perspective of potentially adding a third mode for persisting the id in sessionStorage in the future. So mentally, it should correlate to "short -> medium -> long".
How about:
lifecycle: 'route' | 'page' | 'tab'lifecycle: 'navigation' | 'pageload' | 'tab'
1 has the advantage that it's very descriptive, but confusion could come from "page". I think this is minimal and also kinda works anyway because it's primarily relevant for Single Page applications".
2 is a bit more technical but correlates well with established Sentry terms.
I think with the proper JSDoc (which is already there xD), both would work well. Especially if we pair these with lifecycle since this more directly implies session life time than "mode" IMHO. Fully realizing I said other things offline, so sorry for throwing yet more options into the ring. Thoughts?
fwiw, Gemini clearly prefers 1 😅
closes #18921
closes JS-1526
This adds a new
modeoption to theBrowserSessionIntegration.New explained:
The default is to
navigationto not introduce any breaking changeMerge checklist