Skip to content
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

Allow use of sessionStorage in browserSessionIntegration to more accurately count sessions for MPAs #14478

Open
lforst opened this issue Nov 26, 2024 · 4 comments
Labels
Feature: Sessions Migrated Package: browser Issues related to the Sentry Browser SDK

Comments

@lforst
Copy link
Member

lforst commented Nov 26, 2024

Description

Session updates we send from the Browser SDK are currently per pageview, leading to more sessions than is commonly understood for MPAs. We find that Sessions likely should have the same lifetime as a Session Replay session. For this we should introduce an option in the browserSessionIntegration that allows a user to configure a persistence model using sessionStorage to more accurately collect number of sessions.

@AbhiPrasad AbhiPrasad added Package: browser Issues related to the Sentry Browser SDK Feature: Sessions labels Nov 28, 2024
@lforst lforst changed the title [v9] Update how sessions work in the browser [v9] Use session storage for sessions Dec 2, 2024
@lforst
Copy link
Member Author

lforst commented Dec 2, 2024

Strawman proposal: We add a sessioIntegration() with the following options:

interface SessionIntegrationOptions {
  /**
   * The storage type that the SDK uses to store a Session ID that is used for Sessions and Release Health in Sentry.
   * 
   * Possible values:
   * 
   * - `"sessionStorage"` (default) The Session ID is persisted to the browser's `sessionStorage`. Sessions will persist across hard-navigations on the same origin.
   * - `"memory"` The Session ID is stored in memory. Hard-navigations will produce new sessions.
   * 
   * Defaults to `"sessionStorage"`.
   */
  persistence?: 'sessionStorage' | 'memory'
}

The persistence name coincides with a similar/same option and behavior in Posthog. It's just a great name for this option: https://posthog.com/docs/libraries/js#persistence

@bruno-garcia
Copy link
Member

Just wanted to mention I think this is a solid plan. Defaulting to sessionStorage with a clear opt-out.

Session Replay relies on sessionStorage and not once we heard this being the reason why someone wouldn't want to use it.

A bigger question would be relying on localStorage. Although that could be an option for users who'd like to have traces connect across tabs, and surviving restarts. But sessionStorage seems like a great improvement to the product without compromising privacy.

@HazAT
Copy link
Member

HazAT commented Jan 7, 2025

+1 on making it opt-out in other words, makeing sessionStorage default
We are doing this with the intention to provide a better service, it is communicated in a major and we are not storing any sensitive data in there so a very clear case for me

@lforst
Copy link
Member Author

lforst commented Jan 9, 2025

This has made another round among stakeholders, we will have to make the usage of sessionStorage opt-in. Which will make this a non-breaking change and not part of v9.

@lforst lforst changed the title [v9] Use session storage for sessions Allow use session storage in browserSessionIntegration to more accurately count sessions for MPAs Jan 9, 2025
@lforst lforst changed the title Allow use session storage in browserSessionIntegration to more accurately count sessions for MPAs Allow use of sessionStorage in browserSessionIntegration to more accurately count sessions for MPAs Jan 9, 2025
@linear linear bot added the Migrated label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Sessions Migrated Package: browser Issues related to the Sentry Browser SDK
Projects
None yet
Development

No branches or pull requests

4 participants