Skip to content

Commit 207b0bc

Browse files
authored
fix(replay): ensure replay_id is not added to DSC if session expired (#9359)
We noticed we still sometimes see "too long sessions", and it seems this is because of errors being tagged with a replay long after the session expired. After some digging, this may be because we do not check session expiration when adding the `replay_id` to the DSC. This PR fixes this.
1 parent f0b0281 commit 207b0bc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/replay/src/util/addGlobalListeners.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ export function addGlobalListeners(replay: ReplayContainer): void {
4040
const replayId = replay.getSessionId();
4141
// We do not want to set the DSC when in buffer mode, as that means the replay has not been sent (yet)
4242
if (replayId && replay.isEnabled() && replay.recordingMode === 'session') {
43-
dsc.replay_id = replayId;
43+
// Ensure to check that the session is still active - it could have expired in the meanwhile
44+
const isSessionActive = replay.checkAndHandleExpiredSession();
45+
if (isSessionActive) {
46+
dsc.replay_id = replayId;
47+
}
4448
}
4549
});
4650

0 commit comments

Comments
 (0)