From 39c5f43ffab73479e181649f45a9cffadd9b233a Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 25 Oct 2023 09:07:06 +0200 Subject: [PATCH] fix(replay): ensure `replay_id` is not added to DSC if session expired --- packages/replay/src/util/addGlobalListeners.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/replay/src/util/addGlobalListeners.ts b/packages/replay/src/util/addGlobalListeners.ts index 0948561f7852..1f7945565524 100644 --- a/packages/replay/src/util/addGlobalListeners.ts +++ b/packages/replay/src/util/addGlobalListeners.ts @@ -40,7 +40,11 @@ export function addGlobalListeners(replay: ReplayContainer): void { const replayId = replay.getSessionId(); // We do not want to set the DSC when in buffer mode, as that means the replay has not been sent (yet) if (replayId && replay.isEnabled() && replay.recordingMode === 'session') { - dsc.replay_id = replayId; + // Ensure to check that the session is still active - it could have expired in the meanwhile + const isSessionActive = replay.checkAndHandleExpiredSession(); + if (isSessionActive) { + dsc.replay_id = replayId; + } } });