Skip to content

Commit a686688

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 d9d8429 commit a686688

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
@@ -534,21 +534,11 @@ export class ReplayContainer {
534534
this._maybeSaveSession();
535535
}
536536

537-
// If the full snapshot is due to an initial load, we will not have
538-
// a previous session ID. In this case, we want to buffer events
539-
// for a set amount of time before flushing. This can help avoid
540-
// capturing replays of users that immediately close the window.
541-
setTimeout(() => this.conditionalFlush(), this.options.initialFlushDelay);
542-
543-
// Cancel any previously debounced flushes to ensure there are no [near]
544-
// simultaneous flushes happening. The latter request should be
545-
// insignificant in this case, so wait for additional user interaction to
546-
// trigger a new flush.
547-
//
548-
// This can happen because there's no guarantee that a recording event
549-
// happens first. e.g. a mouse click can happen and trigger a debounced
550-
// flush before the checkout.
551-
this._debouncedFlush?.cancel();
537+
// Flush immediately so that we do not miss the first segment, otherwise
538+
// it can prevent loading on the UI. This will cause an increase in short
539+
// replays (e.g. opening and closing a tab quickly), but these can be
540+
// filtered on the UI.
541+
this.flushImmediate();
552542

553543
return true;
554544
});

0 commit comments

Comments
 (0)