Skip to content

Commit d9b7db8

Browse files
committed
feat(replay): Flush immediately on DOM checkouts
We originally added this delay to flushing to prevent recording short (low value) recordings. However, this causes some issues if the user were to refresh/leave the page before the first recording segment is sent as the backend will consider the replay invalid if it does not have segment id 0 present. Change to flush immediately to try to reduce the number of replays with missing first segments. Our UI has a default duration filter to hide replays < 5 seconds.
1 parent aafa7cb commit d9b7db8

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

packages/replay/src/replay.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -485,21 +485,11 @@ export class ReplayContainer implements ReplayContainerInterface {
485485
this._maybeSaveSession();
486486
}
487487

488-
// If the full snapshot is due to an initial load, we will not have
489-
// a previous session ID. In this case, we want to buffer events
490-
// for a set amount of time before flushing. This can help avoid
491-
// capturing replays of users that immediately close the window.
492-
setTimeout(() => this.conditionalFlush(), this._options.initialFlushDelay);
493-
494-
// Cancel any previously debounced flushes to ensure there are no [near]
495-
// simultaneous flushes happening. The latter request should be
496-
// insignificant in this case, so wait for additional user interaction to
497-
// trigger a new flush.
498-
//
499-
// This can happen because there's no guarantee that a recording event
500-
// happens first. e.g. a mouse click can happen and trigger a debounced
501-
// flush before the checkout.
502-
this._debouncedFlush?.cancel();
488+
// Flush immediately so that we do not miss the first segment, otherwise
489+
// it can prevent loading on the UI. This will cause an increase in short
490+
// replays (e.g. opening and closing a tab quickly), but these can be
491+
// filtered on the UI.
492+
this.flushImmediate();
503493

504494
return true;
505495
});

0 commit comments

Comments
 (0)