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-1028] enable privacy by default #1049

Merged
merged 6 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 2 additions & 5 deletions packages/core/src/domain/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const DEFAULT_CONFIGURATION = {
silentMultipleInit: false,
trackInteractions: false,
trackViewsManually: false,
initialPrivacyLevel: InitialPrivacyLevel.ALLOW as InitialPrivacyLevel,
initialPrivacyLevel: InitialPrivacyLevel.MASK_FORMS_ONLY as InitialPrivacyLevel,

/**
* arbitrary value, byte precision not needed
Expand Down Expand Up @@ -142,10 +142,7 @@ export function buildConfiguration(initConfiguration: InitConfiguration, buildEn
configuration.actionNameAttribute = initConfiguration.actionNameAttribute
}

if (
configuration.isEnabled('initial-privacy-level-option') &&
objectHasValue(InitialPrivacyLevel, initConfiguration.initialPrivacyLevel)
) {
if (objectHasValue(InitialPrivacyLevel, initConfiguration.initialPrivacyLevel)) {
configuration.initialPrivacyLevel = initConfiguration.initialPrivacyLevel
}

Expand Down
27 changes: 8 additions & 19 deletions packages/rum-core/src/boot/rumPublicApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,28 +670,17 @@ describe('rum public api', () => {

it('recording is started with the default initialPrivacyLevel', () => {
rumPublicApi.init(DEFAULT_INIT_CONFIGURATION)
expect(recorderApiOnRumStartSpy.calls.mostRecent().args[2].initialPrivacyLevel).toBe(InitialPrivacyLevel.ALLOW)
})

describe('initial-privacy-level-option feature enabled', () => {
it('recording is started with the configured initialPrivacyLevel', () => {
rumPublicApi.init({
...DEFAULT_INIT_CONFIGURATION,
initialPrivacyLevel: InitialPrivacyLevel.MASK,
enableExperimentalFeatures: ['initial-privacy-level-option'],
})
expect(recorderApiOnRumStartSpy.calls.mostRecent().args[2].initialPrivacyLevel).toBe(InitialPrivacyLevel.MASK)
})
expect(recorderApiOnRumStartSpy.calls.mostRecent().args[2].initialPrivacyLevel).toBe(
InitialPrivacyLevel.MASK_FORMS_ONLY
)
})

describe('initial-privacy-level-option feature disabled', () => {
it('recording ignores the configured initialPrivacyLevel', () => {
rumPublicApi.init({
...DEFAULT_INIT_CONFIGURATION,
initialPrivacyLevel: InitialPrivacyLevel.MASK,
})
expect(recorderApiOnRumStartSpy.calls.mostRecent().args[2].initialPrivacyLevel).toBe(InitialPrivacyLevel.ALLOW)
it('recording is started with the configured initialPrivacyLevel', () => {
rumPublicApi.init({
...DEFAULT_INIT_CONFIGURATION,
initialPrivacyLevel: InitialPrivacyLevel.MASK,
})
expect(recorderApiOnRumStartSpy.calls.mostRecent().args[2].initialPrivacyLevel).toBe(InitialPrivacyLevel.MASK)
})
})
})
5 changes: 4 additions & 1 deletion packages/rum/src/boot/startRecording.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpRequest } from '@datadog/browser-core'
import { HttpRequest, InitialPrivacyLevel } from '@datadog/browser-core'
import { LifeCycle, LifeCycleEventType } from '@datadog/browser-rum-core'
import { inflate } from 'pako'
import { createRumSessionMock, RumSessionMock } from '../../../rum-core/test/mockRumSession'
Expand Down Expand Up @@ -52,6 +52,9 @@ describe('startRecording', () => {
},
})
.withSession(session)
.withConfiguration({
initialPrivacyLevel: InitialPrivacyLevel.ALLOW,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the default privacy level (mask forms only) data compression is too efficient (🎉), so segments are not reaching the compressed size limit.

})
.beforeBuild(({ lifeCycle, applicationId, configuration, parentContexts, session }) => {
;({ stop: stopRecording } = startRecording(lifeCycle, applicationId, configuration, session, parentContexts))
return { stop: stopRecording }
Expand Down