Skip to content

Commit 57220f4

Browse files
authored
feat(replay): Do not restart replays on "keydown" (#8226)
This is causing some low-value replays. If you search sentry for replays with duration < 5 seconds, you will see that most of them are re-newed sessions from idle that only have a "keydown" breadcrumb. I suspect users are alt-tabbing out of an idle Sentry page. Removing for now until we have a better way to detect when a session is truly resumed via keydown event.
1 parent 8c6ad15 commit 57220f4

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

packages/replay/src/coreHandlers/handleKeyboardEvent.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ export function handleKeyboardEvent(replay: ReplayContainer, event: KeyboardEven
1212
return;
1313
}
1414

15-
replay.triggerUserActivity();
15+
// Update user activity, but do not restart recording as it can create
16+
// noisy/low-value replays (e.g. user comes back from idle, hits alt-tab, new
17+
// session with a single "keydown" breadcrumb is created)
18+
replay.updateUserActivity();
1619

1720
const breadcrumb = getKeyboardBreadcrumb(event);
1821

packages/replay/src/replay.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,18 @@ export class ReplayContainer implements ReplayContainerInterface {
486486
this._updateSessionActivity();
487487
}
488488

489+
/**
490+
* Updates the user activity timestamp *without* resuming
491+
* recording. Some user events (e.g. keydown) can be create
492+
* low-value replays that only contain the keypress as a
493+
* breadcrumb. Instead this would require other events to
494+
* create a new replay after a session has expired.
495+
*/
496+
public updateUserActivity(): void {
497+
this._updateUserActivity();
498+
this._updateSessionActivity();
499+
}
500+
489501
/**
490502
* Only flush if `this.recordingMode === 'session'`
491503
*/

packages/replay/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ export interface ReplayContainer {
556556
flushImmediate(): Promise<void>;
557557
cancelFlush(): void;
558558
triggerUserActivity(): void;
559+
updateUserActivity(): void;
559560
addUpdate(cb: AddUpdateCallback): void;
560561
getOptions(): ReplayPluginOptions;
561562
getSessionId(): string | undefined;

0 commit comments

Comments
 (0)