From 85b4b30ffac084e8b4a0e1ab664d6c78941926b3 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Tue, 24 Oct 2023 09:05:07 +0100 Subject: [PATCH] feat: posthog event on unparseable line (#18144) --- .../player/sessionRecordingDataLogic.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingDataLogic.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingDataLogic.ts index 2a28edac17964..5f3593279cef5 100644 --- a/frontend/src/scenes/session-recordings/player/sessionRecordingDataLogic.ts +++ b/frontend/src/scenes/session-recordings/player/sessionRecordingDataLogic.ts @@ -28,7 +28,7 @@ import posthog from 'posthog-js' const IS_TEST_MODE = process.env.NODE_ENV === 'test' const BUFFER_MS = 60000 // +- before and after start and end of a recording to query for. -const parseEncodedSnapshots = (items: (EncodedRecordingSnapshot | string)[]): RecordingSnapshot[] => +const parseEncodedSnapshots = (items: (EncodedRecordingSnapshot | string)[], sessionId: string): RecordingSnapshot[] => items.flatMap((l) => { try { const snapshotLine = typeof l === 'string' ? (JSON.parse(l) as EncodedRecordingSnapshot) : l @@ -39,6 +39,10 @@ const parseEncodedSnapshots = (items: (EncodedRecordingSnapshot | string)[]): Re ...d, })) } catch (e) { + posthog.capture('session recording had unparseable line', { + sessionId, + line: l, + }) captureException(e) return [] } @@ -307,7 +311,7 @@ export const sessionRecordingDataLogic = kea([ source.blob_key ) data.snapshots = prepareRecordingSnapshots( - parseEncodedSnapshots(encodedResponse), + parseEncodedSnapshots(encodedResponse, props.sessionRecordingId), values.sessionPlayerSnapshotData?.snapshots ?? [] ) } else { @@ -319,7 +323,7 @@ export const sessionRecordingDataLogic = kea([ const response = await api.recordings.listSnapshots(props.sessionRecordingId, params) if (response.snapshots) { data.snapshots = prepareRecordingSnapshots( - parseEncodedSnapshots(response.snapshots), + parseEncodedSnapshots(response.snapshots, props.sessionRecordingId), values.sessionPlayerSnapshotData?.snapshots ?? [] ) }