Skip to content

Commit

Permalink
✨ Collect replay privacy level in views (#2299)
Browse files Browse the repository at this point in the history
  • Loading branch information
amortemousque authored Jun 23, 2023
1 parent 3138f41 commit 629ebbf
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ describe('viewCollection', () => {
is_active: undefined,
},
feature_flags: undefined,
privacy: { replay_level: 'mask-user-input' },
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function startViewCollection(
lifeCycle.subscribe(LifeCycleEventType.VIEW_UPDATED, (view) =>
lifeCycle.notify(
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED,
processViewUpdate(view, foregroundContexts, featureFlagContexts, recorderApi, pageStateHistory)
processViewUpdate(view, configuration, foregroundContexts, featureFlagContexts, recorderApi, pageStateHistory)
)
)
const trackViewResult = trackViews(
Expand All @@ -53,6 +53,7 @@ export function startViewCollection(

function processViewUpdate(
view: ViewEvent,
configuration: RumConfiguration,
foregroundContexts: ForegroundContexts,
featureFlagContexts: FeatureFlagContexts,
recorderApi: RecorderApi,
Expand Down Expand Up @@ -109,6 +110,9 @@ function processViewUpdate(
has_replay: replayStats ? true : undefined,
is_active: view.sessionIsActive ? undefined : false,
},
privacy: {
replay_level: configuration.defaultPrivacyLevel,
},
}
if (!isEmptyObject(view.customTimings)) {
viewEvent.view.custom_timings = mapValues(
Expand Down
4 changes: 4 additions & 0 deletions packages/rum-core/src/rawRumEvent.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
ServerDuration,
TimeStamp,
RawErrorCause,
DefaultPrivacyLevel,
} from '@datadog/browser-core'
import type { PageState } from './domain/contexts/pageStateHistory'
import type { RumSessionPlan } from './domain/rumSessionManager'
Expand Down Expand Up @@ -107,6 +108,9 @@ export interface RawRumViewEvent {
is_active: false | undefined
}
feature_flags?: Context
privacy?: {
replay_level: DefaultPrivacyLevel
}
_dd: {
document_version: number
replay_stats?: ReplayStats
Expand Down
28 changes: 28 additions & 0 deletions packages/rum-core/src/rumEvent.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,16 @@ export type RumViewEvent = CommonProperties & {
readonly feature_flags?: {
[k: string]: unknown
}
/**
* Privacy properties
*/
readonly privacy?: {
/**
* The replay privacy level
*/
readonly replay_level: 'allow' | 'mask' | 'mask-user-input'
[k: string]: unknown
}
/**
* Internal properties
*/
Expand All @@ -786,6 +796,24 @@ export type RumViewEvent = CommonProperties & {
readonly start: number
[k: string]: unknown
}[]
/**
* Debug metadata for Replay Sessions
*/
replay_stats?: {
/**
* The number of records produced during this view lifetime
*/
records_count?: number
/**
* The number of segments sent during this view lifetime
*/
segments_count?: number
/**
* The total size in bytes of the segments sent during this view lifetime
*/
segments_total_raw_size?: number
[k: string]: unknown
}
[k: string]: unknown
}
[k: string]: unknown
Expand Down

0 comments on commit 629ebbf

Please sign in to comment.