Issue
I would like to set a different sampling rate for replays based on my own conditions.
Applies To
- All SaaS Customers and Self-Hosted Users
- Session Replay
Resolution
You can set up something like the following:
const enableSessionReplay = {set your conditions here and return 1 or 0}
Sentry.init({ // ... integrations: [ Sentry.replayIntegration({ // ... }), ], replaysOnErrorSampleRate: enableSessionReplay ? 1.0 : 0, replaysSessionSampleRate: {similar to above if needed}, // ... });
Please keep in mind that once Sentry has been initialized, it is not possible to change any of the Sentry.init
options during runtime. You would have to shut down the SDK and initialize it again with different options based on your custom conditions, which we generally do not recommend.