From 410482d1b1ec2e9f5b131894222946609337586c Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Wed, 25 Oct 2023 11:46:40 +0200 Subject: [PATCH 1/2] update rum-events-format --- packages/rum-core/src/rumEvent.types.ts | 10 ++++++++++ packages/rum/src/types/sessionReplay.ts | 23 ++++++++++++++++------- rum-events-format | 2 +- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/packages/rum-core/src/rumEvent.types.ts b/packages/rum-core/src/rumEvent.types.ts index d10019bfce..67701bd75d 100644 --- a/packages/rum-core/src/rumEvent.types.ts +++ b/packages/rum-core/src/rumEvent.types.ts @@ -856,6 +856,16 @@ export type RumViewEvent = CommonProperties & { segments_total_raw_size?: number [k: string]: unknown } + /** + * Subset of the SDK configuration options in use during its execution + */ + readonly configuration?: { + /** + * Whether session replay recording configured to start manually + */ + readonly start_session_replay_recording_manually?: boolean + [k: string]: unknown + } [k: string]: unknown } /** diff --git a/packages/rum/src/types/sessionReplay.ts b/packages/rum/src/types/sessionReplay.ts index f0ed7c1ed8..cc3060ac41 100644 --- a/packages/rum/src/types/sessionReplay.ts +++ b/packages/rum/src/types/sessionReplay.ts @@ -48,13 +48,22 @@ export type BrowserRecord = /** * Browser-specific. Schema of a Record type which contains the full snapshot of a screen. */ -export type BrowserFullSnapshotRecord = CommonRecordSchema & { +export type BrowserFullSnapshotRecord = WebviewSupportedCommonRecordSchema & { /** * The type of this Record. */ readonly type: 2 data: BrowserNode } +/** + * Schema of common properties for a Record event type that is supported by webviews. + */ +export type WebviewSupportedCommonRecordSchema = CommonRecordSchema & { + /** + * Defines the unique ID of the nested replay environment that generated this record. + */ + readonly nestedEnvId?: number +} /** * Serialized node contained by this Record. */ @@ -68,7 +77,7 @@ export type SerializedNode = DocumentNode | DocumentFragmentNode | DocumentTypeN /** * Browser-specific. Schema of a Record type which contains mutations of a screen. */ -export type BrowserIncrementalSnapshotRecord = CommonRecordSchema & { +export type BrowserIncrementalSnapshotRecord = WebviewSupportedCommonRecordSchema & { /** * The type of this Record. */ @@ -237,7 +246,7 @@ export type PointerInteractionData = { /** * Schema of a Record which contains the screen properties. */ -export type MetaRecord = CommonRecordSchema & { +export type MetaRecord = WebviewSupportedCommonRecordSchema & { /** * The type of this Record. */ @@ -263,7 +272,7 @@ export type MetaRecord = CommonRecordSchema & { /** * Schema of a Record type which contains focus information. */ -export type FocusRecord = CommonRecordSchema & { +export type FocusRecord = WebviewSupportedCommonRecordSchema & { /** * The type of this Record. */ @@ -278,7 +287,7 @@ export type FocusRecord = CommonRecordSchema & { /** * Schema of a Record which signifies that view lifecycle ended. */ -export type ViewEndRecord = CommonRecordSchema & { +export type ViewEndRecord = WebviewSupportedCommonRecordSchema & { /** * The type of this Record. */ @@ -287,7 +296,7 @@ export type ViewEndRecord = CommonRecordSchema & { /** * Schema of a Record which signifies that the viewport properties have changed. */ -export type VisualViewportRecord = CommonRecordSchema & { +export type VisualViewportRecord = WebviewSupportedCommonRecordSchema & { data: { height: number offsetLeft: number @@ -305,7 +314,7 @@ export type VisualViewportRecord = CommonRecordSchema & { /** * Schema of a Record which signifies a collection of frustration signals. */ -export type FrustrationRecord = CommonRecordSchema & { +export type FrustrationRecord = WebviewSupportedCommonRecordSchema & { /** * The type of this Record. */ diff --git a/rum-events-format b/rum-events-format index f69ca4664e..e29a828faf 160000 --- a/rum-events-format +++ b/rum-events-format @@ -1 +1 @@ -Subproject commit f69ca4664ed6e69c929855d02c4ce3d4b85d0bb4 +Subproject commit e29a828fafdab77525429198b731f176e16957f7 From bb31a9d661d06126410072b3712bd0f9c549c512 Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Wed, 25 Oct 2023 12:04:03 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=89=20Add=20extra=20field=20to=20i?= =?UTF-8?q?dentify=20sessions=20recorded=20manually?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/rum-core/src/domain/assembly.spec.ts | 4 ++-- .../src/domain/view/viewCollection.spec.ts | 22 +++++++++++++++++++ .../src/domain/view/viewCollection.ts | 3 +++ packages/rum-core/src/rawRumEvent.types.ts | 3 +++ packages/rum-core/test/fixtures.ts | 3 +++ 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/packages/rum-core/src/domain/assembly.spec.ts b/packages/rum-core/src/domain/assembly.spec.ts index d3f8960d18..ffbc02b6cc 100644 --- a/packages/rum-core/src/domain/assembly.spec.ts +++ b/packages/rum-core/src/domain/assembly.spec.ts @@ -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, @@ -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, diff --git a/packages/rum-core/src/domain/view/viewCollection.spec.ts b/packages/rum-core/src/domain/view/viewCollection.spec.ts index 44e917236c..bcd85ec41c 100644 --- a/packages/rum-core/src/domain/view/viewCollection.spec.ts +++ b/packages/rum-core/src/domain/view/viewCollection.spec.ts @@ -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, @@ -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) + }) }) diff --git a/packages/rum-core/src/domain/view/viewCollection.ts b/packages/rum-core/src/domain/view/viewCollection.ts index cf4eff404a..192600c399 100644 --- a/packages/rum-core/src/domain/view/viewCollection.ts +++ b/packages/rum-core/src/domain/view/viewCollection.ts @@ -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, diff --git a/packages/rum-core/src/rawRumEvent.types.ts b/packages/rum-core/src/rawRumEvent.types.ts index 8b94d968b9..8290e99a43 100644 --- a/packages/rum-core/src/rawRumEvent.types.ts +++ b/packages/rum-core/src/rawRumEvent.types.ts @@ -119,6 +119,9 @@ export interface RawRumViewEvent { document_version: number replay_stats?: ReplayStats page_states?: PageStateServerEntry[] + configuration: { + start_session_replay_recording_manually: boolean + } } } diff --git a/packages/rum-core/test/fixtures.ts b/packages/rum-core/test/fixtures.ts index 864995618a..76a26db043 100644 --- a/packages/rum-core/test/fixtures.ts +++ b/packages/rum-core/test/fixtures.ts @@ -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: {