Sessions & tracing in MV3 extensions / SPAs #6297
Replies: 1 comment
-
Hi, your post is touching a lot of topics and I will try to answer as well as possible but I recommend you compile a list of concrete questions if you need more information.
I don't know if there is a best practice. Admittedly, sessions are a bit of a broken feature in the browser. Sessions were originally designed for monitoring on mobile apps, since on that platform you can track app health when the user opens and closes a page. On the browser, we can't do that because we do not want to track people across pages.
Is it still not working for you in the newest version of the SDK? We might have fixed this.
Sessions are created automatically by the You can find the code for this here: sentry-javascript/packages/browser/src/sdk.ts Line 258 in ed183d4 Also: Sessions are completely unrelated to
Yes. If you manually want to track sessions, I recommend you set
You will have to implement that logic yourself.
Browser extensions are not a priority for us at the moment. PRs are welcome if you want to contribute to improve support!
The |
Beta Was this translation helpful? Give feedback.
-
Hey there,
I’m trying to understand whether there's a best practice to track sessions (and thus release health), as well as transactions for single page applications, and more specifically for browser extensions targeting MV3.
I've ran across #5289 (
BrowserTracing
isn't working in ServiceWorkers atm)Our browser extension gets be mounted upon user interaction, on top of whatever tab the user is on. There’s currently no navigation within that app that the SDK could rely on to manage sessions.
We’ve been using
BrowserTracing
in the past (in MV2 background pages), but removed that about 6 months ago. Since then, the JS SDK v6 and 7 still automatically sent session data, when built against manifest version 2. It's not clear to me where exactly sessions were created after we removed theBrowserTracing
and basically hadintegrations: []
set inSentry.init
.Since we switched to MV3, our app doesn’t report any session data any longer.
Now I wonder:
BrowserTracing
sequel that makes sense in the context of MV3?For our MV3 app in particular, my expectation would be that a session is started when the service worker wakes up. Since there’s no pre-termination event from the browser, there is no clear point at which a session could be closed; our app can continue to work in the background even if the user closes the UI, or switches to another tab.
On a related note, I wonder whether there's any integration or approach for transactions in SPAs that don't produce any browser history. I guess we'll just need to implement our own logic around transactions?
I’d be fine implementing any of this, but I’m not sure whether I’ve found enough documentation on how to approach this.
Resources I've read through so far:
Is there anything I'm missing, or any suggested way forward?
I know this may be a lot of context, so thanks for reading until here 🙌
– Matthias
Beta Was this translation helpful? Give feedback.
All reactions