Skip to content

Commit 1c16467

Browse files
committed
fix: Rename useConsentModel to browserConsentMode
1 parent 7e51428 commit 1c16467

File tree

9 files changed

+31
-16
lines changed

9 files changed

+31
-16
lines changed

src/common/config/init-types.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@
8484
* @property {boolean} [spa.enabled] - Turn on/off the single page application feature (on by default). NOTE: the SPA feature is deprecated and under removal procedure.
8585
* @property {boolean} [spa.autoStart] - If true, the agent will automatically start the single page application feature. Otherwise, it will be in a deferred state until the `start` API method is called.
8686
* @property {boolean} [ssl] - If explicitly false, the agent will use HTTP instead of HTTPS. This setting should NOT be used.
87-
* @property {boolean} [useConsentModel] - If true, the agent will use the consent model for whether to allow or disallow data harvest.
87+
* @property {Object} [browserConsentMode]
88+
* @property {boolean} [enabled] - If true, the agent will use consent mode for whether to allow or disallow data harvest.
8889
* @property {Object} [user_actions]
8990
* @property {boolean} [user_actions.enabled] - Must be true to allow UserAction events to be captured.
9091
* @property {Array<string>} [user_actions.elementAttributes] - List of HTML Element properties to be captured with UserAction events' target elements. This may help to identify the source element being interacted with in the UI.

src/common/config/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const InitModelFn = () => {
134134
soft_navigations: { enabled: true, autoStart: true },
135135
spa: { enabled: true, autoStart: true },
136136
ssl: undefined,
137-
useConsentModel: false,
137+
browserConsentMode: { enabled: false },
138138
user_actions: { enabled: true, elementAttributes: ['id', 'className', 'tagName', 'type'] }
139139
}
140140
}

src/common/harvest/harvester.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class Harvester {
5656
*/
5757
triggerHarvestFor (aggregateInst, localOpts = {}) {
5858
if (aggregateInst.blocked) return false
59-
if (this.agentRef.init.useConsentModel && !this.agentRef.runtime?.session?.state?.consent) return false
59+
if (this.agentRef.init?.browserConsentMode?.enabled && !this.agentRef.runtime?.session?.state?.consent) return false
6060

6161
const submitMethod = getSubmitMethod(localOpts)
6262
if (!submitMethod) return false

tests/assets/consent-model-accept.html renamed to tests/assets/consent-mode-accept.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
-->
66
<html>
77
<head>
8-
<title>Consent Model Test</title>
8+
<title>Consent Mode Test</title>
99
{init} {config} {loader}
1010
<script>
1111
newrelic.consent(true)

tests/assets/consent-model-reject.html renamed to tests/assets/consent-mode-reject.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
-->
66
<html>
77
<head>
8-
<title>Consent Model Test</title>
8+
<title>Consent Mode Test</title>
99
{init} {config} {loader}
1010
<script>
1111
newrelic.consent(false)

tests/assets/instrumented2.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<!--
3+
Copyright 2020 New Relic Corporation.
4+
PDX-License-Identifier: Apache-2.0
5+
-->
6+
<html>
7+
<head>
8+
<title>RUM Unit Test</title>
9+
<script>
10+
window.NREUM||(NREUM={});
11+
NREUM.init = {
12+
browserConsentMode: { enabled: true }
13+
}
14+
</script>
15+
{config} {loader}
16+
</head>
17+
<body>Instrumented!</body>
18+
</html>

tests/dts/agentoptions.test-d.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const validOptions: AgentOptions = {
117117
autoStart: false
118118
},
119119
ssl: true,
120-
useConsentModel: false,
120+
browserConsentMode: { enabled: false },
121121
user_actions: {
122122
enabled: true,
123123
elementAttributes: ['id', 'className', 'tagName', 'type']
@@ -198,8 +198,4 @@ expectError<AgentOptions>({
198198

199199
expectError<AgentOptions>({
200200
loaderType: 123 // should be a string
201-
})
202-
203-
expectError<AgentOptions>({
204-
useConsentModel: 'false' // should be a boolean
205201
})

tests/specs/consent-model.e2e.js renamed to tests/specs/consent-mode.e2e.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { testRumRequest, testTimingEventsRequest } from '../../tools/testing-server/utils/expect-tests'
22
import { FEATURE_NAMES } from '../../src/loaders/features/features'
33

4-
describe('consent model', () => {
4+
describe('consent mode', () => {
55
let rumCapture, pvtCapture
66

77
const HARVEST_TIMEOUT = 10000
88

99
const consentModeConfig = {
1010
init: {
11-
useConsentModel: true
11+
browserConsentMode: { enabled: true }
1212
}
1313
}
1414
const manualStartConfig = {
1515
init: {
16-
useConsentModel: true,
16+
browserConsentMode: { enabled: true },
1717
[FEATURE_NAMES.pageViewTiming]: { autoStart: false }
1818
}
1919
}
@@ -32,7 +32,7 @@ describe('consent model', () => {
3232
it('should harvest data for PVE feature if consent is given', async () => {
3333
const [rumHarvests] = await Promise.all([
3434
rumCapture.waitForResult({ totalCount: 1 }),
35-
browser.url(await browser.testHandle.assetURL('consent-model-accept.html', consentModeConfig))
35+
browser.url(await browser.testHandle.assetURL('consent-mode-accept.html', consentModeConfig))
3636
])
3737

3838
expect(rumHarvests.length).toBeGreaterThan(0)
@@ -41,7 +41,7 @@ describe('consent model', () => {
4141
it('should not harvest data if consent is not given', async () => {
4242
const [rumHarvests] = await Promise.all([
4343
rumCapture.waitForResult({ timeout: HARVEST_TIMEOUT }),
44-
browser.url(await browser.testHandle.assetURL('consent-model-reject.html', consentModeConfig))
44+
browser.url(await browser.testHandle.assetURL('consent-mode-reject.html', consentModeConfig))
4545
])
4646

4747
expect(rumHarvests.length).toEqual(0)

tests/unit/common/config/init.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ test('init props exist and return expected defaults', () => {
131131
enabled: true,
132132
elementAttributes: ['id', 'className', 'tagName', 'type']
133133
})
134-
expect(config.useConsentModel).toEqual(false)
134+
expect(config.browserConsentMode.enabled).toEqual(false)
135135
})
136136

137137
describe('property getters/setters used for validation', () => {

0 commit comments

Comments
 (0)