Skip to content

Commit

Permalink
🔉 Add extra field to identify sessions recorded manually
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan committed Oct 25, 2023
1 parent 410482d commit bb31a9d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/rum-core/src/domain/assembly.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ describe('rum assembly', () => {
it('should include the configured sample rates', () => {
const { lifeCycle } = setupBuilder.build()
notifyRawRumEvent(lifeCycle, {
rawRumEvent: createRawRumEvent(RumEventType.VIEW),
rawRumEvent: createRawRumEvent(RumEventType.ACTION),
})
expect(serverRumEvents[0]._dd.configuration).toEqual({
session_replay_sample_rate: 0,
Expand All @@ -728,7 +728,7 @@ describe('rum assembly', () => {
})
.build()
notifyRawRumEvent(lifeCycle, {
rawRumEvent: createRawRumEvent(RumEventType.VIEW),
rawRumEvent: createRawRumEvent(RumEventType.ACTION),
})
expect(serverRumEvents[0]._dd.configuration).toEqual({
session_sample_rate: 1.234,
Expand Down
22 changes: 22 additions & 0 deletions packages/rum-core/src/domain/view/viewCollection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ describe('viewCollection', () => {
{ start: 0 as ServerDuration, state: PageState.ACTIVE },
{ start: 10 as ServerDuration, state: PageState.PASSIVE },
],
configuration: {
start_session_replay_recording_manually: jasmine.any(Boolean),
},
},
date: jasmine.any(Number),
type: RumEventType.VIEW,
Expand Down Expand Up @@ -228,4 +231,23 @@ describe('viewCollection', () => {

expect(rawRumViewEvent.display?.scroll).toBeUndefined()
})

it('should include configuration.start_session_replay_recording_manually value', () => {
let { lifeCycle, rawRumEvents } = setupBuilder
.withConfiguration({ startSessionReplayRecordingManually: false })
.build()
lifeCycle.notify(LifeCycleEventType.VIEW_UPDATED, VIEW)
expect(
(rawRumEvents[rawRumEvents.length - 1].rawRumEvent as RawRumViewEvent)._dd.configuration
.start_session_replay_recording_manually
).toBe(false)
;({ lifeCycle, rawRumEvents } = setupBuilder
.withConfiguration({ startSessionReplayRecordingManually: true })
.build())
lifeCycle.notify(LifeCycleEventType.VIEW_UPDATED, VIEW)
expect(
(rawRumEvents[rawRumEvents.length - 1].rawRumEvent as RawRumViewEvent)._dd.configuration
.start_session_replay_recording_manually
).toBe(true)
})
})
3 changes: 3 additions & 0 deletions packages/rum-core/src/domain/view/viewCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ function processViewUpdate(
document_version: view.documentVersion,
replay_stats: replayStats,
page_states: pageStates,
configuration: {
start_session_replay_recording_manually: configuration.startSessionReplayRecordingManually,
},
},
date: view.startClocks.timeStamp,
type: RumEventType.VIEW,
Expand Down
3 changes: 3 additions & 0 deletions packages/rum-core/src/rawRumEvent.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ export interface RawRumViewEvent {
document_version: number
replay_stats?: ReplayStats
page_states?: PageStateServerEntry[]
configuration: {
start_session_replay_recording_manually: boolean
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions packages/rum-core/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export function createRawRumEvent(type: RumEventType, overrides?: Context): RawR
type,
_dd: {
document_version: 0,
configuration: {
start_session_replay_recording_manually: false,
},
},
date: 0 as TimeStamp,
view: {
Expand Down

0 comments on commit bb31a9d

Please sign in to comment.