Skip to content

Commit

Permalink
feat: send snapshot library (#1587)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra authored Dec 12, 2024
1 parent 0ea603b commit 25c0da2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/__tests__/extensions/replay/sessionrecording.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down Expand Up @@ -858,6 +858,8 @@ describe('SessionRecording', () => {
],
$session_id: sessionId,
$window_id: 'windowId',
$lib: 'web',
$lib_version: '0.0.1',
},
{
_url: 'https://test.com/s/',
Expand Down Expand Up @@ -893,6 +895,8 @@ describe('SessionRecording', () => {
{ type: 3, data: { source: 1 } },
{ type: 3, data: { source: 2 } },
],
$lib: 'web',
$lib_version: '0.0.1',
},
{
_url: 'https://test.com/s/',
Expand Down Expand Up @@ -973,6 +977,8 @@ describe('SessionRecording', () => {
$window_id: 'windowId',
$snapshot_data: [{ data: { source: 1 }, emit: 1, type: 3 }],
$snapshot_bytes: 39,
$lib: 'web',
$lib_version: '0.0.1',
},
{
_url: 'https://test.com/s/',
Expand Down Expand Up @@ -1580,6 +1586,8 @@ describe('SessionRecording', () => {
$session_id: firstSessionId,
$snapshot_bytes: 186,
$window_id: expect.any(String),
$lib: 'web',
$lib_version: '0.0.1',
},
{
_batchKey: 'recordings',
Expand Down Expand Up @@ -1670,6 +1678,8 @@ describe('SessionRecording', () => {
$session_id: firstSessionId,
$snapshot_bytes: 186,
$window_id: expect.any(String),
$lib: 'web',
$lib_version: '0.0.1',
},
{
_batchKey: 'recordings',
Expand All @@ -1696,6 +1706,8 @@ describe('SessionRecording', () => {
$session_id: firstSessionId,
$snapshot_bytes: 186,
$window_id: expect.any(String),
$lib: 'web',
$lib_version: '0.0.1',
},
{
_batchKey: 'recordings',
Expand Down Expand Up @@ -2116,6 +2128,8 @@ describe('SessionRecording', () => {
$session_id: sessionId,
$snapshot_bytes: expect.any(Number),
$window_id: 'windowId',
$lib: 'web',
$lib_version: '0.0.1',
},
captureOptions
)
Expand All @@ -2137,6 +2151,8 @@ describe('SessionRecording', () => {
$session_id: sessionId,
$snapshot_bytes: expect.any(Number),
$window_id: 'windowId',
$lib: 'web',
$lib_version: '0.0.1',
},
captureOptions
)
Expand Down Expand Up @@ -2166,6 +2182,8 @@ describe('SessionRecording', () => {
$session_id: sessionId,
$snapshot_bytes: expect.any(Number),
$window_id: 'windowId',
$lib: 'web',
$lib_version: '0.0.1',
},
captureOptions
)
Expand Down Expand Up @@ -2196,6 +2214,8 @@ describe('SessionRecording', () => {
$session_id: sessionId,
$snapshot_bytes: expect.any(Number),
$window_id: 'windowId',
$lib: 'web',
$lib_version: '0.0.1',
},
captureOptions
)
Expand All @@ -2215,6 +2235,8 @@ describe('SessionRecording', () => {
$session_id: sessionId,
$snapshot_bytes: 86,
$window_id: 'windowId',
$lib: 'web',
$lib_version: '0.0.1',
},
captureOptions
)
Expand All @@ -2239,6 +2261,8 @@ describe('SessionRecording', () => {
$session_id: sessionId,
$snapshot_bytes: 58,
$window_id: 'windowId',
$lib: 'web',
$lib_version: '0.0.1',
},
captureOptions
)
Expand All @@ -2262,6 +2286,8 @@ describe('SessionRecording', () => {
$session_id: sessionId,
$snapshot_bytes: 69,
$window_id: 'windowId',
$lib: 'web',
$lib_version: '0.0.1',
},
captureOptions
)
Expand Down Expand Up @@ -2308,6 +2334,8 @@ describe('SessionRecording', () => {
{ type: 3, data: { source: 1 } },
{ type: 3, data: { source: 2 } },
],
$lib: 'web',
$lib_version: '0.0.1',
},
expect.any(Object)
)
Expand Down
3 changes: 3 additions & 0 deletions src/extensions/replay/sessionrecording.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -1185,6 +1186,8 @@ export class SessionRecording {
$snapshot_data: snapshotBuffer.data,
$session_id: snapshotBuffer.sessionId,
$window_id: snapshotBuffer.windowId,
$lib: 'web',
$lib_version: Config.LIB_VERSION,
})
})
}
Expand Down

0 comments on commit 25c0da2

Please sign in to comment.