Skip to content

[Session Replay]Why "Multiple Sentry Session Replay instances are not supported"? #8414

Answered by AbhiPrasad
NiiyaDaiki asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @NiiyaDaiki - there are two issues here. First, you don't need to call replay.start(), this is already done by calling client.addIntegration(replay). Second, By putting the replay init in a component, you run the risk of re-running replay integration creation

I would recommend doing something like this:

let hasReplayInit = false;

function initReplay() {
   if (hasReplayInit) {
     return;
   }

    const client = Sentry.getCurrentHub().getClient()
    const replay = new Sentry.Replay()
    // only reason client doesn't exist is that `Sentry.init` was not called.
    if (client && client.addIntegration) {
      client.addIntegration(replay)
      hasReplayInit = true;
    }
}

const S…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@NiiyaDaiki
Comment options

Answer selected by NiiyaDaiki
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants