Skip to main content

How can I delay replay recording until a user consents?

Updated over a month ago

Issue

I would like to use replays, but I need to make sure a user consents before recording has started.

Applies To

  • Frontend JavaScript SDK users

Resolution

For the NPM package -

You can initialize the Replay integration after the user has provided consent. This means removing the replayIntegration() from your initial Sentry.init() and adding it back later. Once it has been added, recording will begin based on your sampling rates. Please refer to our docs here for a code example.

For the loader script -

You must delay loading the entire loader script until after the user consents. The loader script does not support initializing Sentry first with only error monitoring and then enabling replays later.

Note: Please review our Privacy docs here for options on how to configure replays to maintain data privacy. Privacy options apply to both the NPM package, as well as the loader script.

Did this answer your question?