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): play back recording files exported with window UUIDs (#107033)

Tue Haulundbd7a47f235ce
diff --git a/frontend/src/scenes/session-recordings/file-playback/sessionRecordingFilePlaybackSceneLogic.test.ts b/frontend/src/scenes/session-recordings/file-playback/sessionRecordingFilePlaybackSceneLogic.test.ts
index 141169440267..e68e8e74230f 100644
--- a/frontend/src/scenes/session-recordings/file-playback/sessionRecordingFilePlaybackSceneLogic.test.ts
+++ b/frontend/src/scenes/session-recordings/file-playback/sessionRecordingFilePlaybackSceneLogic.test.ts
@@ -2,7 +2,10 @@ import { expectLogic } from 'kea-test-utils'
import { initKeaTests } from '~/test/init'
-import { sessionRecordingFilePlaybackSceneLogic } from './sessionRecordingFilePlaybackSceneLogic'
+import {
+ parseExportedSessionRecording,
+ sessionRecordingFilePlaybackSceneLogic,
+} from './sessionRecordingFilePlaybackSceneLogic'
describe('sessionRecordingFilePlaybackLogic', () => {
let logic: ReturnType<typeof sessionRecordingFilePlaybackSceneLogic.build>
@@ -33,4 +36,40 @@ describe('sessionRecordingFilePlaybackLogic', () => {
expect(playerProps.playerKey).not.toEqual(logic.values.playerProps.playerKey)
})
})
+
+ describe('parseExportedSessionRecording', () => {
+ it.each([
+ [
+ '2022-12-02',
+ {
+ snapshotsByWindowId: {
+ 'window-a': [
+ { type: 2, data: {}, timestamp: 1000 },
+ { type: 3, data: {}, timestamp: 3000 },
+ ],
+ 'window-b': [{ type: 2, data: {}, timestamp: 2000 }],
+ },
+ },
+ ],
+ [
+ '2023-04-28',
+ {
+ id: '',
+ snapshots: [
+ { type: 2, data: {}, timestamp: 1000, windowId: 'window-a' },
+ { type: 2, data: {}, timestamp: 2000, windowId: 'window-b' },
+ { type: 3, data: {}, timestamp: 3000, windowId: 'window-a' },
+ ],
+ },
+ ],
+ ])('maps window UUIDs in a %s export to integer window ids', (version, data) => {
+ const parsed = parseExportedSessionRecording(JSON.stringify({ version, data }))
+
+ expect(parsed.data.snapshots.map((s) => [s.timestamp, s.windowId])).toEqual([
+ [1000, 1],
+ [2000, 2],
+ [3000, 1],
+ ])
+ })
+ })
})
diff --git a/frontend/src/scenes/session-recordings/file-playback/sessionRecordingFilePlaybackSceneLogic.ts b/frontend/src/scenes/session-recordings/file-playback/sessionRecordingFilePlaybackSceneLogic.ts
index 93659619a06e..ba9eea5d6282 100644
--- a/frontend/src/scenes/session-recordings/file-playback/sessionRecordingFilePlaybackSceneLogic.ts
+++ b/frontend/src/scenes/session-recordings/file-playback/sessionRecordingFilePlaybackSceneLogic.ts
@@ -31,6 +31,14 @@ export const parseExportedSessionRecording = (fileData: string): ExportedSession
}
if (data.version === '2023-04-28') {
+ // Files exported before window ids became integers carry the window UUID, and the segmenter indexes windows by number
+ const registerWindowId = createWindowIdRegistry()
+ for (const snapshot of data.data.snapshots) {
+ const windowId: number | string = snapshot.windowId
+ if (typeof windowId === 'string') {
+ snapshot.windowId = registerWindowId(windowId)
+ }
+ }
return data
} else if (data.version === '2022-12-02') {
const registerWindowId = createWindowIdRegistry()