Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💥 [RUMF-1588] Update default session replay behaviour #2257

Merged
merged 3 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/rum-core/src/boot/rumPublicApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,17 +842,17 @@ describe('rum public api', () => {

it('recording is started with the default defaultPrivacyLevel', () => {
rumPublicApi.init(DEFAULT_INIT_CONFIGURATION)
expect(recorderApiOnRumStartSpy.calls.mostRecent().args[1].defaultPrivacyLevel).toBe(
DefaultPrivacyLevel.MASK_USER_INPUT
)
expect(recorderApiOnRumStartSpy.calls.mostRecent().args[1].defaultPrivacyLevel).toBe(DefaultPrivacyLevel.MASK)
})

it('recording is started with the configured defaultPrivacyLevel', () => {
rumPublicApi.init({
...DEFAULT_INIT_CONFIGURATION,
defaultPrivacyLevel: DefaultPrivacyLevel.MASK,
defaultPrivacyLevel: DefaultPrivacyLevel.MASK_USER_INPUT,
})
expect(recorderApiOnRumStartSpy.calls.mostRecent().args[1].defaultPrivacyLevel).toBe(DefaultPrivacyLevel.MASK)
expect(recorderApiOnRumStartSpy.calls.mostRecent().args[1].defaultPrivacyLevel).toBe(
DefaultPrivacyLevel.MASK_USER_INPUT
)
})
})

Expand Down
10 changes: 5 additions & 5 deletions packages/rum-core/src/domain/configuration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe('validateAndBuildRumConfiguration', () => {
})

describe('sessionReplaySampleRate', () => {
it('defaults to 100 if the option is not provided', () => {
expect(validateAndBuildRumConfiguration(DEFAULT_INIT_CONFIGURATION)!.sessionReplaySampleRate).toBe(100)
it('defaults to 0 if the option is not provided', () => {
expect(validateAndBuildRumConfiguration(DEFAULT_INIT_CONFIGURATION)!.sessionReplaySampleRate).toBe(0)
})

it('is set to `sessionReplaySampleRate` provided value', () => {
Expand Down Expand Up @@ -254,9 +254,9 @@ describe('validateAndBuildRumConfiguration', () => {
})

describe('defaultPrivacyLevel', () => {
it('defaults to MASK_USER_INPUT', () => {
it('defaults to MASK', () => {
expect(validateAndBuildRumConfiguration(DEFAULT_INIT_CONFIGURATION)!.defaultPrivacyLevel).toBe(
DefaultPrivacyLevel.MASK_USER_INPUT
DefaultPrivacyLevel.MASK
)
})

Expand All @@ -273,7 +273,7 @@ describe('validateAndBuildRumConfiguration', () => {
expect(
validateAndBuildRumConfiguration({ ...DEFAULT_INIT_CONFIGURATION, defaultPrivacyLevel: 'foo' as any })!
.defaultPrivacyLevel
).toBe(DefaultPrivacyLevel.MASK_USER_INPUT)
).toBe(DefaultPrivacyLevel.MASK)
})
})

Expand Down
4 changes: 2 additions & 2 deletions packages/rum-core/src/domain/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function validateAndBuildRumConfiguration(
applicationId: initConfiguration.applicationId,
version: initConfiguration.version,
actionNameAttribute: initConfiguration.actionNameAttribute,
sessionReplaySampleRate: initConfiguration.sessionReplaySampleRate ?? 100,
sessionReplaySampleRate: initConfiguration.sessionReplaySampleRate ?? 0,
traceSampleRate: initConfiguration.traceSampleRate,
allowedTracingUrls,
excludedActivityUrls: initConfiguration.excludedActivityUrls ?? [],
Expand All @@ -114,7 +114,7 @@ export function validateAndBuildRumConfiguration(
subdomain: initConfiguration.subdomain,
defaultPrivacyLevel: objectHasValue(DefaultPrivacyLevel, initConfiguration.defaultPrivacyLevel)
? initConfiguration.defaultPrivacyLevel
: DefaultPrivacyLevel.MASK_USER_INPUT,
: DefaultPrivacyLevel.MASK,
customerDataTelemetrySampleRate: 1,
},
baseConfiguration
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/lib/framework/createTest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { LogsInitConfiguration } from '@datadog/browser-logs'
import type { RumInitConfiguration } from '@datadog/browser-rum-core'
import { DefaultPrivacyLevel } from '@datadog/browser-rum'
import { getRunId } from '../../../envUtils'
import { deleteAllCookies, getBrowserName, withBrowserLogs } from '../helpers/browser'
import { APPLICATION_ID, CLIENT_TOKEN } from '../helpers/constants'
Expand All @@ -18,6 +19,7 @@ const DEFAULT_RUM_CONFIGURATION = {
applicationId: APPLICATION_ID,
clientToken: CLIENT_TOKEN,
sessionReplaySampleRate: 100,
defaultPrivacyLevel: DefaultPrivacyLevel.ALLOW,
trackResources: true,
trackLongTasks: true,
telemetrySampleRate: 100,
Expand Down
21 changes: 10 additions & 11 deletions test/e2e/scenario/recorder/recorder.scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ describe('recorder', () => {
.withSetup(bundleSetup)
.withBody(
html`
<div id="not-obfuscated">foo</div>
<p id="hidden-by-attribute" data-dd-privacy="hidden">bar</p>
<span id="hidden-by-classname" class="dd-privacy-hidden baz">baz</span>
<input id="input-ignored" data-dd-privacy="input-ignored" value="toto" />
<input id="input-masked" data-dd-privacy="input-masked" value="toto" />
<div id="not-obfuscated">displayed</div>
<p id="hidden-by-attribute" data-dd-privacy="hidden">hidden</p>
<span id="hidden-by-classname" class="dd-privacy-hidden">hidden</span>
<input id="input-not-obfuscated" value="displayed" />
<input id="input-masked" data-dd-privacy="mask" value="masked" />
`
)
.run(async ({ serverEvents }) => {
Expand All @@ -99,23 +99,22 @@ describe('recorder', () => {

const node = findElementWithIdAttribute(fullSnapshot.data.node, 'not-obfuscated')
expect(node).toBeTruthy()
expect(findTextContent(node!)).toBe('foo')
expect(findTextContent(node!)).toBe('displayed')

const hiddenNodeByAttribute = findElement(fullSnapshot.data.node, (node) => node.tagName === 'p')
expect(hiddenNodeByAttribute).toBeTruthy()
expect(hiddenNodeByAttribute!.attributes['data-dd-privacy']).toBe('hidden')
expect(hiddenNodeByAttribute!.childNodes.length).toBe(0)

const hiddenNodeByClassName = findElement(fullSnapshot.data.node, (node) => node.tagName === 'span')

expect(hiddenNodeByClassName).toBeTruthy()
expect(hiddenNodeByClassName!.attributes.class).toBeUndefined()
expect(hiddenNodeByClassName!.attributes['data-dd-privacy']).toBe('hidden')
expect(hiddenNodeByClassName!.childNodes.length).toBe(0)

const inputIgnored = findElementWithIdAttribute(fullSnapshot.data.node, 'input-ignored')
const inputIgnored = findElementWithIdAttribute(fullSnapshot.data.node, 'input-not-obfuscated')
expect(inputIgnored).toBeTruthy()
expect(inputIgnored!.attributes.value).toBe('***')
expect(inputIgnored!.attributes.value).toBe('displayed')

const inputMasked = findElementWithIdAttribute(fullSnapshot.data.node, 'input-masked')
expect(inputMasked).toBeTruthy()
Expand Down Expand Up @@ -579,8 +578,8 @@ describe('recorder', () => {
.withSetup(bundleSetup)
.withBody(
html`
<input type="text" id="by-data-attribute" data-dd-privacy="input-masked" />
<input type="text" id="by-classname" class="dd-privacy-input-masked" />
<input type="text" id="by-data-attribute" data-dd-privacy="mask" />
<input type="text" id="by-classname" class="dd-privacy-mask" />
`
)
.run(async ({ serverEvents }) => {
Expand Down