Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(replay): stop warning about idle gaps as unplayable recording (#91209)

posthog[bot]e3a0e8472b67
diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.test.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.test.ts
index 3ed7a5a7b431..115c9c69fc0e 100644
--- a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.test.ts
+++ b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.test.ts
@@ -555,6 +555,9 @@ describe('sessionRecordingPlayerLogic', () => {
const inc = (timestamp: number): RecordingSnapshot => makeSnapshot(timestamp, EventType.IncrementalSnapshot)
const fs = (timestamp: number): RecordingSnapshot => makeSnapshot(timestamp, EventType.FullSnapshot)
+ const meta = (timestamp: number): RecordingSnapshot => makeSnapshot(timestamp, EventType.Meta)
+ const idle = (timestamp: number): RecordingSnapshot =>
+ makeSnapshot(timestamp, EventType.Custom, 1, { tag: 'sessionIdle', payload: {} })
// second-window events for the multi-window cases
const w2inc = (timestamp: number): RecordingSnapshot =>
makeSnapshot(timestamp, EventType.IncrementalSnapshot, 2)
@@ -943,6 +946,34 @@ describe('sessionRecordingPlayerLogic', () => {
expectedLeadingUnplayableMs: 0,
expectedHasLate: false,
},
+ {
+ description:
+ 'does not flag an idle gap where only a backdated sessionIdle event precedes the full snapshot',
+ firstSourceSnapshots: [idle(START)],
+ secondSourceSnapshots: [fs(LATE_FS_TS), inc(LATE_FS_TS + 1000)],
+ expectedLeadingUnplayableMs: 0,
+ expectedHasLate: false,
+ },
+ {
+ // rrweb emits Meta and FullSnapshot together, so Meta alone means the FullSnapshot was dropped
+ description: 'flags a lost leading snapshot when only its Meta event survives',
+ firstSourceSnapshots: [meta(START)],
+ secondSourceSnapshots: [fs(LATE_FS_TS), inc(LATE_FS_TS + 1000)],
+ expectedLeadingUnplayableMs: LATE_FS_TS - START,
+ expectedHasLate: true,
+ },
+ {
+ description: 'flags a lost leading snapshot when the missing content is in a later window',
+ firstSourceSnapshots: [idle(START)],
+ secondSourceSnapshots: [
+ w2inc(START + 61000),
+ w2inc(START + 62000),
+ w2fs(LATE_FS_TS),
+ w2inc(LATE_FS_TS + 1000),
+ ],
+ expectedLeadingUnplayableMs: LATE_FS_TS - START,
+ expectedHasLate: true,
+ },
])(
'$description',
({ firstSourceSnapshots, secondSourceSnapshots, expectedLeadingUnplayableMs, expectedHasLate }) => {
diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
index a7ca8bdf69b3..850d1025c19e 100644
--- a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
+++ b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
@@ -1875,7 +1875,24 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
return 0
}
const renderability = seekRenderability(firstWindowSegment.startTimestamp)
- return renderability.kind === 'clampToFullSnapshot' ? Math.max(0, renderability.timestamp - start) : 0
+ if (renderability.kind !== 'clampToFullSnapshot') {
+ return 0
+ }
+ // A backdated `sessionIdle` Custom event pulls `start` back over the idle span, and the SDK
+ // drops everything else while idle, so a Custom-only span is empty rather than lost.
+ // Anything else before the recovery point means the FullSnapshot was dropped.
+ const recoveryTimestamp = renderability.timestamp
+ for (const events of Object.values(sessionPlayerData.snapshotsByWindowId)) {
+ for (const event of events) {
+ if (event.timestamp >= recoveryTimestamp) {
+ break
+ }
+ if (event.type !== EventType.Custom) {
+ return recoveryTimestamp - start
+ }
+ }
+ }
+ return 0
},
],