From 3b5aa4d5c07249b35c5b5da38546a995181ab2d4 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Sun, 8 Dec 2024 12:08:26 +0000 Subject: [PATCH 1/3] feat: send snapshot library --- .../extensions/replay/sessionrecording.test.ts | 14 ++++++++++++++ src/extensions/replay/sessionrecording.ts | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/__tests__/extensions/replay/sessionrecording.test.ts b/src/__tests__/extensions/replay/sessionrecording.test.ts index a0c676588..f3dda12cb 100644 --- a/src/__tests__/extensions/replay/sessionrecording.test.ts +++ b/src/__tests__/extensions/replay/sessionrecording.test.ts @@ -858,6 +858,7 @@ describe('SessionRecording', () => { ], $session_id: sessionId, $window_id: 'windowId', + $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', }, { _url: 'https://test.com/s/', @@ -893,6 +894,7 @@ describe('SessionRecording', () => { { type: 3, data: { source: 1 } }, { type: 3, data: { source: 2 } }, ], + $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', }, { _url: 'https://test.com/s/', @@ -973,6 +975,7 @@ describe('SessionRecording', () => { $window_id: 'windowId', $snapshot_data: [{ data: { source: 1 }, emit: 1, type: 3 }], $snapshot_bytes: 39, + $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', }, { _url: 'https://test.com/s/', @@ -1580,6 +1583,7 @@ describe('SessionRecording', () => { $session_id: firstSessionId, $snapshot_bytes: 186, $window_id: expect.any(String), + $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', }, { _batchKey: 'recordings', @@ -1670,6 +1674,7 @@ describe('SessionRecording', () => { $session_id: firstSessionId, $snapshot_bytes: 186, $window_id: expect.any(String), + $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', }, { _batchKey: 'recordings', @@ -1696,6 +1701,7 @@ describe('SessionRecording', () => { $session_id: firstSessionId, $snapshot_bytes: 186, $window_id: expect.any(String), + $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', }, { _batchKey: 'recordings', @@ -2116,6 +2122,7 @@ describe('SessionRecording', () => { $session_id: sessionId, $snapshot_bytes: expect.any(Number), $window_id: 'windowId', + $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', }, captureOptions ) @@ -2137,6 +2144,7 @@ describe('SessionRecording', () => { $session_id: sessionId, $snapshot_bytes: expect.any(Number), $window_id: 'windowId', + $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', }, captureOptions ) @@ -2166,6 +2174,7 @@ describe('SessionRecording', () => { $session_id: sessionId, $snapshot_bytes: expect.any(Number), $window_id: 'windowId', + $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', }, captureOptions ) @@ -2196,6 +2205,7 @@ describe('SessionRecording', () => { $session_id: sessionId, $snapshot_bytes: expect.any(Number), $window_id: 'windowId', + $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', }, captureOptions ) @@ -2215,6 +2225,7 @@ describe('SessionRecording', () => { $session_id: sessionId, $snapshot_bytes: 86, $window_id: 'windowId', + $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', }, captureOptions ) @@ -2239,6 +2250,7 @@ describe('SessionRecording', () => { $session_id: sessionId, $snapshot_bytes: 58, $window_id: 'windowId', + $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', }, captureOptions ) @@ -2262,6 +2274,7 @@ describe('SessionRecording', () => { $session_id: sessionId, $snapshot_bytes: 69, $window_id: 'windowId', + $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', }, captureOptions ) @@ -2308,6 +2321,7 @@ describe('SessionRecording', () => { { type: 3, data: { source: 1 } }, { type: 3, data: { source: 2 } }, ], + $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', }, expect.any(Object) ) diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index 030501aab..fba1e060a 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -46,6 +46,7 @@ import { MutationRateLimiter } from './mutation-rate-limiter' import { gzipSync, strFromU8, strToU8 } from 'fflate' import { clampToRange } from '../../utils/number-utils' import { includes } from '../../utils' +import Config from '../../config' const LOGGER_PREFIX = '[SessionRecording]' const logger = createLogger(LOGGER_PREFIX) @@ -1185,6 +1186,7 @@ export class SessionRecording { $snapshot_data: snapshotBuffer.data, $session_id: snapshotBuffer.sessionId, $window_id: snapshotBuffer.windowId, + $snapshot_library: `web/ver/${Config.LIB_VERSION}/script_name/${this.scriptName}`, }) }) } From 26e531aca5178c9ed3d2ca8f48a59b9d7538e418 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Mon, 9 Dec 2024 22:31:33 +0000 Subject: [PATCH 2/3] like the mobile SDKs --- .../replay/sessionrecording.test.ts | 42 ++++++++++++------- src/extensions/replay/sessionrecording.ts | 3 +- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/__tests__/extensions/replay/sessionrecording.test.ts b/src/__tests__/extensions/replay/sessionrecording.test.ts index f3dda12cb..a7be8f322 100644 --- a/src/__tests__/extensions/replay/sessionrecording.test.ts +++ b/src/__tests__/extensions/replay/sessionrecording.test.ts @@ -858,7 +858,8 @@ describe('SessionRecording', () => { ], $session_id: sessionId, $window_id: 'windowId', - $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', + $lib: 'web', + $lib_version: 'v0.0.1', }, { _url: 'https://test.com/s/', @@ -894,7 +895,8 @@ describe('SessionRecording', () => { { type: 3, data: { source: 1 } }, { type: 3, data: { source: 2 } }, ], - $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', + $lib: 'web', + $lib_version: 'v0.0.1', }, { _url: 'https://test.com/s/', @@ -975,7 +977,8 @@ describe('SessionRecording', () => { $window_id: 'windowId', $snapshot_data: [{ data: { source: 1 }, emit: 1, type: 3 }], $snapshot_bytes: 39, - $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', + $lib: 'web', + $lib_version: 'v0.0.1', }, { _url: 'https://test.com/s/', @@ -1583,7 +1586,8 @@ describe('SessionRecording', () => { $session_id: firstSessionId, $snapshot_bytes: 186, $window_id: expect.any(String), - $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', + $lib: 'web', + $lib_version: 'v0.0.1', }, { _batchKey: 'recordings', @@ -1674,7 +1678,8 @@ describe('SessionRecording', () => { $session_id: firstSessionId, $snapshot_bytes: 186, $window_id: expect.any(String), - $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', + $lib: 'web', + $lib_version: 'v0.0.1', }, { _batchKey: 'recordings', @@ -1701,7 +1706,8 @@ describe('SessionRecording', () => { $session_id: firstSessionId, $snapshot_bytes: 186, $window_id: expect.any(String), - $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', + $lib: 'web', + $lib_version: 'v0.0.1', }, { _batchKey: 'recordings', @@ -2122,7 +2128,8 @@ describe('SessionRecording', () => { $session_id: sessionId, $snapshot_bytes: expect.any(Number), $window_id: 'windowId', - $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', + $lib: 'web', + $lib_version: 'v0.0.1', }, captureOptions ) @@ -2144,7 +2151,8 @@ describe('SessionRecording', () => { $session_id: sessionId, $snapshot_bytes: expect.any(Number), $window_id: 'windowId', - $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', + $lib: 'web', + $lib_version: 'v0.0.1', }, captureOptions ) @@ -2174,7 +2182,8 @@ describe('SessionRecording', () => { $session_id: sessionId, $snapshot_bytes: expect.any(Number), $window_id: 'windowId', - $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', + $lib: 'web', + $lib_version: 'v0.0.1', }, captureOptions ) @@ -2205,7 +2214,8 @@ describe('SessionRecording', () => { $session_id: sessionId, $snapshot_bytes: expect.any(Number), $window_id: 'windowId', - $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', + $lib: 'web', + $lib_version: 'v0.0.1', }, captureOptions ) @@ -2225,7 +2235,8 @@ describe('SessionRecording', () => { $session_id: sessionId, $snapshot_bytes: 86, $window_id: 'windowId', - $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', + $lib: 'web', + $lib_version: 'v0.0.1', }, captureOptions ) @@ -2250,7 +2261,8 @@ describe('SessionRecording', () => { $session_id: sessionId, $snapshot_bytes: 58, $window_id: 'windowId', - $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', + $lib: 'web', + $lib_version: 'v0.0.1', }, captureOptions ) @@ -2274,7 +2286,8 @@ describe('SessionRecording', () => { $session_id: sessionId, $snapshot_bytes: 69, $window_id: 'windowId', - $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', + $lib: 'web', + $lib_version: 'v0.0.1', }, captureOptions ) @@ -2321,7 +2334,8 @@ describe('SessionRecording', () => { { type: 3, data: { source: 1 } }, { type: 3, data: { source: 2 } }, ], - $snapshot_library: 'web/ver/v0.0.1/script_name/recorder', + $lib: 'web', + $lib_version: 'v0.0.1', }, expect.any(Object) ) diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index fba1e060a..36d95dad7 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -1186,7 +1186,8 @@ export class SessionRecording { $snapshot_data: snapshotBuffer.data, $session_id: snapshotBuffer.sessionId, $window_id: snapshotBuffer.windowId, - $snapshot_library: `web/ver/${Config.LIB_VERSION}/script_name/${this.scriptName}`, + $lib: 'web', + $lib_version: Config.LIB_VERSION, }) }) } From f34777c9295a5413070632ece73322e3ee220369 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Tue, 10 Dec 2024 09:57:53 +0000 Subject: [PATCH 3/3] fix moxk --- .../replay/sessionrecording.test.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/__tests__/extensions/replay/sessionrecording.test.ts b/src/__tests__/extensions/replay/sessionrecording.test.ts index a7be8f322..232022864 100644 --- a/src/__tests__/extensions/replay/sessionrecording.test.ts +++ b/src/__tests__/extensions/replay/sessionrecording.test.ts @@ -52,7 +52,7 @@ import { SimpleEventEmitter } from '../../../utils/simple-event-emitter' // Type and source defined here designate a non-user-generated recording event -jest.mock('../../../config', () => ({ LIB_VERSION: 'v0.0.1' })) +jest.mock('../../../config', () => ({ LIB_VERSION: '0.0.1' })) const EMPTY_BUFFER = { data: [], @@ -859,7 +859,7 @@ describe('SessionRecording', () => { $session_id: sessionId, $window_id: 'windowId', $lib: 'web', - $lib_version: 'v0.0.1', + $lib_version: '0.0.1', }, { _url: 'https://test.com/s/', @@ -896,7 +896,7 @@ describe('SessionRecording', () => { { type: 3, data: { source: 2 } }, ], $lib: 'web', - $lib_version: 'v0.0.1', + $lib_version: '0.0.1', }, { _url: 'https://test.com/s/', @@ -978,7 +978,7 @@ describe('SessionRecording', () => { $snapshot_data: [{ data: { source: 1 }, emit: 1, type: 3 }], $snapshot_bytes: 39, $lib: 'web', - $lib_version: 'v0.0.1', + $lib_version: '0.0.1', }, { _url: 'https://test.com/s/', @@ -1587,7 +1587,7 @@ describe('SessionRecording', () => { $snapshot_bytes: 186, $window_id: expect.any(String), $lib: 'web', - $lib_version: 'v0.0.1', + $lib_version: '0.0.1', }, { _batchKey: 'recordings', @@ -1679,7 +1679,7 @@ describe('SessionRecording', () => { $snapshot_bytes: 186, $window_id: expect.any(String), $lib: 'web', - $lib_version: 'v0.0.1', + $lib_version: '0.0.1', }, { _batchKey: 'recordings', @@ -1707,7 +1707,7 @@ describe('SessionRecording', () => { $snapshot_bytes: 186, $window_id: expect.any(String), $lib: 'web', - $lib_version: 'v0.0.1', + $lib_version: '0.0.1', }, { _batchKey: 'recordings', @@ -2129,7 +2129,7 @@ describe('SessionRecording', () => { $snapshot_bytes: expect.any(Number), $window_id: 'windowId', $lib: 'web', - $lib_version: 'v0.0.1', + $lib_version: '0.0.1', }, captureOptions ) @@ -2152,7 +2152,7 @@ describe('SessionRecording', () => { $snapshot_bytes: expect.any(Number), $window_id: 'windowId', $lib: 'web', - $lib_version: 'v0.0.1', + $lib_version: '0.0.1', }, captureOptions ) @@ -2183,7 +2183,7 @@ describe('SessionRecording', () => { $snapshot_bytes: expect.any(Number), $window_id: 'windowId', $lib: 'web', - $lib_version: 'v0.0.1', + $lib_version: '0.0.1', }, captureOptions ) @@ -2215,7 +2215,7 @@ describe('SessionRecording', () => { $snapshot_bytes: expect.any(Number), $window_id: 'windowId', $lib: 'web', - $lib_version: 'v0.0.1', + $lib_version: '0.0.1', }, captureOptions ) @@ -2236,7 +2236,7 @@ describe('SessionRecording', () => { $snapshot_bytes: 86, $window_id: 'windowId', $lib: 'web', - $lib_version: 'v0.0.1', + $lib_version: '0.0.1', }, captureOptions ) @@ -2262,7 +2262,7 @@ describe('SessionRecording', () => { $snapshot_bytes: 58, $window_id: 'windowId', $lib: 'web', - $lib_version: 'v0.0.1', + $lib_version: '0.0.1', }, captureOptions ) @@ -2287,7 +2287,7 @@ describe('SessionRecording', () => { $snapshot_bytes: 69, $window_id: 'windowId', $lib: 'web', - $lib_version: 'v0.0.1', + $lib_version: '0.0.1', }, captureOptions ) @@ -2335,7 +2335,7 @@ describe('SessionRecording', () => { { type: 3, data: { source: 2 } }, ], $lib: 'web', - $lib_version: 'v0.0.1', + $lib_version: '0.0.1', }, expect.any(Object) )