@ht-sdks/consent-manager 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -19
- package/commonjs/__tests__/consent-manager/dialog.test.js +33 -0
- package/commonjs/__tests__/consent-manager-builder/analytics.test.js +53 -46
- package/commonjs/__tests__/consent-manager-builder/index.todo.js +52 -88
- package/commonjs/__tests__/consent-manager-builder/preferences.test.js +59 -71
- package/commonjs/__tests__/index.test.js +12 -12
- package/commonjs/consent-manager/banner.js +35 -19
- package/commonjs/consent-manager/buttons.js +5 -5
- package/commonjs/consent-manager/cancel-dialog.js +26 -10
- package/commonjs/consent-manager/categories.js +2 -2
- package/commonjs/consent-manager/container.js +2 -3
- package/commonjs/consent-manager/dialog.js +39 -23
- package/commonjs/consent-manager/font-styles.js +2 -2
- package/commonjs/consent-manager/index.js +41 -25
- package/commonjs/consent-manager/preference-dialog.js +36 -20
- package/commonjs/consent-manager-builder/analytics.js +3 -7
- package/commonjs/consent-manager-builder/index.js +30 -30
- package/commonjs/consent-manager-builder/preferences.js +28 -21
- package/commonjs/index.js +5 -4
- package/commonjs/standalone.js +25 -11
- package/esm/__tests__/consent-manager/dialog.test.js +28 -0
- package/esm/__tests__/consent-manager-builder/analytics.test.js +41 -34
- package/esm/__tests__/consent-manager-builder/index.todo.js +38 -74
- package/esm/__tests__/consent-manager-builder/preferences.test.js +55 -67
- package/esm/consent-manager/banner.js +5 -3
- package/esm/consent-manager/buttons.js +4 -4
- package/esm/consent-manager/cancel-dialog.js +4 -2
- package/esm/consent-manager/categories.js +2 -2
- package/esm/consent-manager/container.js +1 -1
- package/esm/consent-manager/dialog.js +7 -5
- package/esm/consent-manager/font-styles.js +2 -2
- package/esm/consent-manager/index.js +19 -17
- package/esm/consent-manager/preference-dialog.js +7 -5
- package/esm/consent-manager-builder/analytics.js +2 -6
- package/esm/consent-manager-builder/index.js +26 -26
- package/esm/consent-manager-builder/preferences.js +23 -16
- package/esm/index.js +4 -3
- package/esm/standalone.js +3 -3
- package/esm/types.js +1 -0
- package/package.json +62 -68
- package/src/__tests__/consent-manager/dialog.test.tsx +42 -0
- package/src/__tests__/consent-manager-builder/analytics.test.ts +40 -33
- package/src/__tests__/consent-manager-builder/index.todo.js +56 -96
- package/src/__tests__/consent-manager-builder/preferences.test.ts +64 -75
- package/src/consent-manager/banner.tsx +11 -11
- package/src/consent-manager/buttons.tsx +26 -10
- package/src/consent-manager/cancel-dialog.tsx +1 -1
- package/src/consent-manager/categories.ts +2 -2
- package/src/consent-manager/container.tsx +14 -17
- package/src/consent-manager/dialog.tsx +4 -4
- package/src/consent-manager/font-styles.tsx +12 -2
- package/src/consent-manager/index.tsx +27 -29
- package/src/consent-manager/preference-dialog.tsx +13 -11
- package/src/consent-manager-builder/analytics.ts +8 -5
- package/src/consent-manager-builder/index.tsx +28 -28
- package/src/consent-manager-builder/preferences.ts +31 -21
- package/src/index.ts +8 -4
- package/src/standalone.tsx +1 -1
- package/src/types.ts +8 -3
- package/standalone/consent-manager.js +5 -10
- package/standalone/consent-manager.js.map +1 -1
- package/types/consent-manager/banner.d.ts +1 -1
- package/types/consent-manager/buttons.d.ts +6 -7
- package/types/consent-manager/cancel-dialog.d.ts +1 -1
- package/types/consent-manager/index.d.ts +3 -3
- package/types/consent-manager/preference-dialog.d.ts +1 -1
- package/types/consent-manager-builder/analytics.d.ts +1 -1
- package/types/consent-manager-builder/index.d.ts +7 -8
- package/types/consent-manager-builder/preferences.d.ts +4 -6
- package/types/index.d.ts +1 -1
- package/types/types.d.ts +14 -11
- package/commonjs/__tests__/consent-manager-builder/fetch-destinations.test.js +0 -155
- package/commonjs/consent-manager-builder/fetch-destinations.js +0 -104
- package/esm/__tests__/consent-manager-builder/fetch-destinations.test.js +0 -150
- package/esm/consent-manager-builder/fetch-destinations.js +0 -98
- package/src/__tests__/consent-manager-builder/fetch-destinations.test.ts +0 -89
- package/src/consent-manager-builder/fetch-destinations.ts +0 -50
- package/types/consent-manager-builder/fetch-destinations.d.ts +0 -2
- package/types/src/__tests__/consent-manager-builder/analytics.test.d.ts +0 -1
- package/types/src/__tests__/consent-manager-builder/fetch-destinations.test.d.ts +0 -1
- package/types/src/__tests__/consent-manager-builder/preferences.test.d.ts +0 -1
- package/types/src/__tests__/index.test.d.ts +0 -1
- package/types/src/consent-manager/banner.d.ts +0 -21
- package/types/src/consent-manager/buttons.d.ts +0 -13
- package/types/src/consent-manager/cancel-dialog.d.ts +0 -19
- package/types/src/consent-manager/categories.d.ts +0 -3
- package/types/src/consent-manager/container.d.ts +0 -35
- package/types/src/consent-manager/dialog.d.ts +0 -29
- package/types/src/consent-manager/font-styles.d.ts +0 -2
- package/types/src/consent-manager/index.d.ts +0 -35
- package/types/src/consent-manager/preference-dialog.d.ts +0 -32
- package/types/src/consent-manager-builder/analytics.d.ts +0 -14
- package/types/src/consent-manager-builder/fetch-destinations.d.ts +0 -2
- package/types/src/consent-manager-builder/index.d.ts +0 -126
- package/types/src/consent-manager-builder/preferences.d.ts +0 -26
- package/types/src/index.d.ts +0 -7
- package/types/src/standalone.d.ts +0 -5
- package/types/src/types.d.ts +0 -131
- /package/types/__tests__/{consent-manager-builder/fetch-destinations.test.d.ts → consent-manager/dialog.test.d.ts} +0 -0
|
@@ -20,19 +20,25 @@ export const DefaultButton = styled('button')`
|
|
|
20
20
|
margin-right: 8px;
|
|
21
21
|
background-color: #fff;
|
|
22
22
|
background-image: linear-gradient(to top, rgba(67, 90, 111, 0.041), rgba(255, 255, 255, 0.041));
|
|
23
|
-
box-shadow:
|
|
23
|
+
box-shadow:
|
|
24
|
+
inset 0 0 0 1px rgba(67, 90, 111, 0.146),
|
|
25
|
+
inset 0 -1px 1px 0 rgba(67, 90, 111, 0.079);
|
|
24
26
|
&:hover {
|
|
25
27
|
background-image: linear-gradient(to top, rgba(67, 90, 111, 0.057), rgba(67, 90, 111, 0.025));
|
|
26
|
-
box-shadow:
|
|
28
|
+
box-shadow:
|
|
29
|
+
inset 0 0 0 1px rgba(67, 90, 111, 0.255),
|
|
27
30
|
inset 0 -1px 1px 0 rgba(67, 90, 111, 0.114);
|
|
28
31
|
}
|
|
29
32
|
&:focus {
|
|
30
|
-
box-shadow:
|
|
33
|
+
box-shadow:
|
|
34
|
+
0 0 0 3px rgba(1, 108, 209, 0.146),
|
|
35
|
+
inset 0 0 0 1px rgba(67, 90, 111, 0.38),
|
|
31
36
|
inset 0 -1px 1px 0 rgba(67, 90, 111, 0.079);
|
|
32
37
|
}
|
|
33
38
|
&:active {
|
|
34
39
|
background: rgba(1, 108, 209, 0.079);
|
|
35
|
-
box-shadow:
|
|
40
|
+
box-shadow:
|
|
41
|
+
inset 0 0 0 1px rgba(67, 90, 111, 0.146),
|
|
36
42
|
inset 0 -1px 1px 0 rgba(67, 90, 111, 0.079);
|
|
37
43
|
}
|
|
38
44
|
`
|
|
@@ -41,18 +47,23 @@ export const GreenButton = styled('button')`
|
|
|
41
47
|
${baseStyles};
|
|
42
48
|
background-color: #47b881;
|
|
43
49
|
background-image: linear-gradient(to top, #3faf77, #47b881);
|
|
44
|
-
box-shadow:
|
|
50
|
+
box-shadow:
|
|
51
|
+
inset 0 0 0 1px rgba(67, 90, 111, 0.204),
|
|
52
|
+
inset 0 -1px 1px 0 rgba(67, 90, 111, 0.204);
|
|
45
53
|
color: #fff;
|
|
46
54
|
&:hover {
|
|
47
55
|
background-image: linear-gradient(to top, #37a56d, #3faf77);
|
|
48
56
|
}
|
|
49
57
|
&:focus {
|
|
50
|
-
box-shadow:
|
|
58
|
+
box-shadow:
|
|
59
|
+
0 0 0 3px rgba(71, 184, 129, 0.477),
|
|
60
|
+
inset 0 0 0 1px rgba(71, 184, 129, 0.204),
|
|
51
61
|
inset 0 -1px 1px 0 rgba(71, 184, 129, 0.204);
|
|
52
62
|
}
|
|
53
63
|
&:active {
|
|
54
64
|
background-image: linear-gradient(to top, #2d9760, #248953);
|
|
55
|
-
box-shadow:
|
|
65
|
+
box-shadow:
|
|
66
|
+
inset 0 0 0 1px rgba(71, 184, 129, 0.204),
|
|
56
67
|
inset 0 -1px 1px 0 rgba(71, 184, 129, 0.204);
|
|
57
68
|
}
|
|
58
69
|
`
|
|
@@ -61,18 +72,23 @@ export const RedButton = styled('button')`
|
|
|
61
72
|
${baseStyles};
|
|
62
73
|
background-color: #f36331;
|
|
63
74
|
background-image: linear-gradient(to top, #f4541d, #f36331);
|
|
64
|
-
box-shadow:
|
|
75
|
+
box-shadow:
|
|
76
|
+
inset 0 0 0 1px rgba(67, 90, 111, 0.204),
|
|
77
|
+
inset 0 -1px 1px 0 rgba(67, 90, 111, 0.204);
|
|
65
78
|
color: #fff;
|
|
66
79
|
&:hover {
|
|
67
80
|
background-image: linear-gradient(to top, #f4450a, #f4541d);
|
|
68
81
|
}
|
|
69
82
|
&:focus {
|
|
70
|
-
box-shadow:
|
|
83
|
+
box-shadow:
|
|
84
|
+
0 0 0 3px rgba(243, 99, 49, 0.477),
|
|
85
|
+
inset 0 0 0 1px rgba(243, 99, 49, 0.204),
|
|
71
86
|
inset 0 -1px 1px 0 rgba(243, 99, 49, 0.204);
|
|
72
87
|
}
|
|
73
88
|
&:active {
|
|
74
89
|
background-image: linear-gradient(to top, #dd3c06, #c63403);
|
|
75
|
-
box-shadow:
|
|
90
|
+
box-shadow:
|
|
91
|
+
inset 0 0 0 1px rgba(67, 90, 111, 0.204),
|
|
76
92
|
inset 0 -1px 1px 0 rgba(67, 90, 111, 0.204);
|
|
77
93
|
}
|
|
78
94
|
`
|
|
@@ -9,7 +9,7 @@ export const MARKETING_AND_ANALYTICS_CATEGORIES = [
|
|
|
9
9
|
'Realtime Dashboards',
|
|
10
10
|
'Referrals',
|
|
11
11
|
'Surveys',
|
|
12
|
-
'Video'
|
|
12
|
+
'Video',
|
|
13
13
|
]
|
|
14
14
|
|
|
15
15
|
export const ADVERTISING_CATEGORIES = ['Advertising', 'Tag Managers']
|
|
@@ -23,5 +23,5 @@ export const FUNCTIONAL_CATEGORIES = [
|
|
|
23
23
|
'Performance Monitoring',
|
|
24
24
|
'Personalization',
|
|
25
25
|
'SMS & Push Notifications',
|
|
26
|
-
'Security & Fraud'
|
|
26
|
+
'Security & Fraud',
|
|
27
27
|
]
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
DefaultDestinationBehavior,
|
|
12
12
|
ActionsBlockProps,
|
|
13
13
|
PreferenceDialogTemplate,
|
|
14
|
-
CloseBehavior
|
|
14
|
+
CloseBehavior,
|
|
15
15
|
} from '../types'
|
|
16
16
|
|
|
17
17
|
const emitter = new EventEmitter()
|
|
@@ -28,7 +28,7 @@ interface ContainerProps {
|
|
|
28
28
|
saveConsent: (
|
|
29
29
|
newPreferences?: CategoryPreferences,
|
|
30
30
|
shouldReload?: boolean,
|
|
31
|
-
devMode?: boolean
|
|
31
|
+
devMode?: boolean,
|
|
32
32
|
) => void
|
|
33
33
|
resetPreferences: () => void
|
|
34
34
|
closeBehavior?: CloseBehavior | CloseBehaviorFunction
|
|
@@ -61,9 +61,9 @@ function normalizeDestinations(destinations: Destination[]) {
|
|
|
61
61
|
const functionalDestinations: Destination[] = []
|
|
62
62
|
|
|
63
63
|
for (const destination of destinations) {
|
|
64
|
-
if (ADVERTISING_CATEGORIES.find(c => c === destination.category)) {
|
|
64
|
+
if (ADVERTISING_CATEGORIES.find((c) => c === destination.category)) {
|
|
65
65
|
advertisingDestinations.push(destination)
|
|
66
|
-
} else if (FUNCTIONAL_CATEGORIES.find(c => c === destination.category)) {
|
|
66
|
+
} else if (FUNCTIONAL_CATEGORIES.find((c) => c === destination.category)) {
|
|
67
67
|
functionalDestinations.push(destination)
|
|
68
68
|
} else {
|
|
69
69
|
// Fallback to marketing
|
|
@@ -74,25 +74,22 @@ function normalizeDestinations(destinations: Destination[]) {
|
|
|
74
74
|
return { marketingDestinations, advertisingDestinations, functionalDestinations }
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
const Container: React.FC<ContainerProps> = props => {
|
|
77
|
+
const Container: React.FC<ContainerProps> = (props) => {
|
|
78
78
|
const [isDialogOpen, toggleDialog] = React.useState(
|
|
79
|
-
false || (props.workspaceAddedNewDestinations && props.defaultDestinationBehavior === 'ask')
|
|
79
|
+
false || (props.workspaceAddedNewDestinations && props.defaultDestinationBehavior === 'ask'),
|
|
80
80
|
)
|
|
81
81
|
const [showBanner, toggleBanner] = React.useState(true)
|
|
82
82
|
const [isCancelling, toggleCancel] = React.useState(false)
|
|
83
83
|
|
|
84
84
|
// check if all preferences are empty, in which case we should show the banner
|
|
85
|
-
const emptyPreferences = Object.values(props.preferences || {}).every(v => v == null)
|
|
85
|
+
const emptyPreferences = Object.values(props.preferences || {}).every((v) => v == null)
|
|
86
86
|
|
|
87
87
|
let banner = React.useRef<HTMLElement>(null)
|
|
88
88
|
let preferenceDialog = React.useRef<HTMLElement>(null)
|
|
89
89
|
let cancelDialog = React.useRef<HTMLElement>(null)
|
|
90
90
|
|
|
91
|
-
const {
|
|
92
|
-
|
|
93
|
-
advertisingDestinations,
|
|
94
|
-
functionalDestinations
|
|
95
|
-
} = normalizeDestinations(props.destinations)
|
|
91
|
+
const { marketingDestinations, advertisingDestinations, functionalDestinations } =
|
|
92
|
+
normalizeDestinations(props.destinations)
|
|
96
93
|
|
|
97
94
|
const onAcceptAll = () => {
|
|
98
95
|
const truePreferences: CategoryPreferences = props.preferences
|
|
@@ -148,7 +145,7 @@ const Container: React.FC<ContainerProps> = props => {
|
|
|
148
145
|
|
|
149
146
|
const showDialog = () => toggleDialog(true)
|
|
150
147
|
|
|
151
|
-
const handleBodyClick = e => {
|
|
148
|
+
const handleBodyClick = (e) => {
|
|
152
149
|
// Do nothing if no new implicit consent needs to be saved
|
|
153
150
|
if (
|
|
154
151
|
!props.isConsentRequired ||
|
|
@@ -194,7 +191,7 @@ const Container: React.FC<ContainerProps> = props => {
|
|
|
194
191
|
|
|
195
192
|
const handleCategoryChange = (category: string, value: boolean) => {
|
|
196
193
|
props.setPreferences({
|
|
197
|
-
[category]: value
|
|
194
|
+
[category]: value,
|
|
198
195
|
})
|
|
199
196
|
}
|
|
200
197
|
|
|
@@ -229,7 +226,7 @@ const Container: React.FC<ContainerProps> = props => {
|
|
|
229
226
|
props.isConsentRequired &&
|
|
230
227
|
(props.newDestinations.length > 0 || emptyPreferences) && (
|
|
231
228
|
<Banner
|
|
232
|
-
innerRef={current => (banner = { current })}
|
|
229
|
+
innerRef={(current) => (banner = { current })}
|
|
233
230
|
onClose={onClose}
|
|
234
231
|
onChangePreferences={() => toggleDialog(true)}
|
|
235
232
|
content={props.bannerContent}
|
|
@@ -249,7 +246,7 @@ const Container: React.FC<ContainerProps> = props => {
|
|
|
249
246
|
customCategories={props.customCategories}
|
|
250
247
|
destinations={props.destinations}
|
|
251
248
|
preferences={props.preferences}
|
|
252
|
-
innerRef={current => (preferenceDialog = { current })}
|
|
249
|
+
innerRef={(current) => (preferenceDialog = { current })}
|
|
253
250
|
onCancel={handleCancel}
|
|
254
251
|
onSave={handleSave}
|
|
255
252
|
onChange={handleCategoryChange}
|
|
@@ -267,7 +264,7 @@ const Container: React.FC<ContainerProps> = props => {
|
|
|
267
264
|
|
|
268
265
|
{isCancelling && (
|
|
269
266
|
<CancelDialog
|
|
270
|
-
innerRef={current => (cancelDialog = { current })}
|
|
267
|
+
innerRef={(current) => (cancelDialog = { current })}
|
|
271
268
|
onBack={handleCancelBack}
|
|
272
269
|
onConfirm={handleCancelConfirm}
|
|
273
270
|
title={props.cancelDialogTitle}
|
|
@@ -3,7 +3,7 @@ import ReactDOM from 'react-dom'
|
|
|
3
3
|
import styled from '@emotion/styled'
|
|
4
4
|
import { keyframes } from '@emotion/react'
|
|
5
5
|
|
|
6
|
-
import nanoid from 'nanoid'
|
|
6
|
+
import { nanoid } from 'nanoid'
|
|
7
7
|
import fontStyles from './font-styles'
|
|
8
8
|
|
|
9
9
|
const ANIMATION_DURATION = '200ms'
|
|
@@ -43,7 +43,7 @@ const Root = styled('section')<RootProps>`
|
|
|
43
43
|
flex-direction: column;
|
|
44
44
|
max-width: calc(100vw - 16px);
|
|
45
45
|
max-height: calc(100% - 16px);
|
|
46
|
-
width: ${props => props.width};
|
|
46
|
+
width: ${(props) => props.width};
|
|
47
47
|
margin: 8px;
|
|
48
48
|
background: #fff;
|
|
49
49
|
border-radius: 8px;
|
|
@@ -133,7 +133,7 @@ export default class Dialog extends PureComponent<DialogProps, {}> {
|
|
|
133
133
|
|
|
134
134
|
static defaultProps = {
|
|
135
135
|
onCancel: undefined,
|
|
136
|
-
width: '750px'
|
|
136
|
+
width: '750px',
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
constructor(props: DialogProps) {
|
|
@@ -218,7 +218,7 @@ export default class Dialog extends PureComponent<DialogProps, {}> {
|
|
|
218
218
|
this.form = node
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
handleOverlayClick = e => {
|
|
221
|
+
handleOverlayClick = (e) => {
|
|
222
222
|
const { onCancel } = this.props
|
|
223
223
|
// Ignore propogated clicks from inside the dialog
|
|
224
224
|
if (onCancel && this.root && !this.root.contains(e.target)) {
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { css } from '@emotion/react'
|
|
2
2
|
|
|
3
3
|
export default css`
|
|
4
|
-
font-family:
|
|
5
|
-
|
|
4
|
+
font-family:
|
|
5
|
+
system-ui,
|
|
6
|
+
-apple-system,
|
|
7
|
+
BlinkMacSystemFont,
|
|
8
|
+
'Segoe UI',
|
|
9
|
+
Roboto,
|
|
10
|
+
Helvetica,
|
|
11
|
+
Arial,
|
|
12
|
+
sans-serif,
|
|
13
|
+
'Apple Color Emoji',
|
|
14
|
+
'Segoe UI Emoji',
|
|
15
|
+
'Segoe UI Symbol';
|
|
6
16
|
-moz-osx-font-smoothing: grayscale;
|
|
7
17
|
-webkit-font-smoothing: antialiased;
|
|
8
18
|
font-smoothing: antialiased;
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
CategoryPreferences,
|
|
7
7
|
Destination,
|
|
8
8
|
ConsentManagerProps,
|
|
9
|
-
PreferenceDialogTemplate
|
|
9
|
+
PreferenceDialogTemplate,
|
|
10
10
|
} from '../types'
|
|
11
11
|
|
|
12
12
|
const zeroValuePreferences: CategoryPreferences = {
|
|
13
13
|
marketingAndAnalytics: null,
|
|
14
14
|
advertising: null,
|
|
15
|
-
functional: null
|
|
15
|
+
functional: null,
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const defaultPreferencesDialogTemplate: PreferenceDialogTemplate = {
|
|
@@ -20,19 +20,19 @@ const defaultPreferencesDialogTemplate: PreferenceDialogTemplate = {
|
|
|
20
20
|
allowValue: 'Allow',
|
|
21
21
|
categoryValue: 'Category',
|
|
22
22
|
purposeValue: 'Purpose',
|
|
23
|
-
toolsValue: 'Tools'
|
|
23
|
+
toolsValue: 'Tools',
|
|
24
24
|
},
|
|
25
25
|
checkboxes: {
|
|
26
26
|
noValue: 'No',
|
|
27
|
-
yesValue: 'Yes'
|
|
27
|
+
yesValue: 'Yes',
|
|
28
28
|
},
|
|
29
29
|
actionButtons: {
|
|
30
30
|
cancelValue: 'Cancel',
|
|
31
|
-
saveValue: 'Save'
|
|
31
|
+
saveValue: 'Save',
|
|
32
32
|
},
|
|
33
33
|
cancelDialogButtons: {
|
|
34
34
|
cancelValue: 'Yes, Cancel',
|
|
35
|
-
backValue: 'Go Back'
|
|
35
|
+
backValue: 'Go Back',
|
|
36
36
|
},
|
|
37
37
|
categories: [
|
|
38
38
|
{
|
|
@@ -40,7 +40,7 @@ const defaultPreferencesDialogTemplate: PreferenceDialogTemplate = {
|
|
|
40
40
|
name: 'Functional',
|
|
41
41
|
description:
|
|
42
42
|
'To monitor the performance of our site and to enhance your browsing experience.',
|
|
43
|
-
example: 'For example, these tools enable you to communicate with us via live chat.'
|
|
43
|
+
example: 'For example, these tools enable you to communicate with us via live chat.',
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
key: 'marketing',
|
|
@@ -48,7 +48,7 @@ const defaultPreferencesDialogTemplate: PreferenceDialogTemplate = {
|
|
|
48
48
|
description:
|
|
49
49
|
'To understand user behavior in order to provide you with a more relevant browsing experience or personalize the content on our site.',
|
|
50
50
|
example:
|
|
51
|
-
'For example, we collect information about which pages you visit to help us present more relevant information.'
|
|
51
|
+
'For example, we collect information about which pages you visit to help us present more relevant information.',
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
key: 'advertising',
|
|
@@ -56,16 +56,16 @@ const defaultPreferencesDialogTemplate: PreferenceDialogTemplate = {
|
|
|
56
56
|
description:
|
|
57
57
|
'To personalize and measure the effectiveness of advertising on our site and other websites.',
|
|
58
58
|
example:
|
|
59
|
-
'For example, we may serve you a personalized ad based on the pages you visit on our site.'
|
|
59
|
+
'For example, we may serve you a personalized ad based on the pages you visit on our site.',
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
key: 'essential',
|
|
63
63
|
name: 'Essential',
|
|
64
64
|
description: 'We use browser cookies that are necessary for the site to work as intended.',
|
|
65
65
|
example:
|
|
66
|
-
'For example, we store your website data collection preferences so we can honor them if you return to our site. You can disable these cookies in your browser settings but if you do the site may not work as intended.'
|
|
67
|
-
}
|
|
68
|
-
]
|
|
66
|
+
'For example, we store your website data collection preferences so we can honor them if you return to our site. You can disable these cookies in your browser settings but if you do the site may not work as intended.',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
69
|
}
|
|
70
70
|
export default class ConsentManager extends PureComponent<ConsentManagerProps, {}> {
|
|
71
71
|
static displayName = 'ConsentManager'
|
|
@@ -106,7 +106,7 @@ export default class ConsentManager extends PureComponent<ConsentManagerProps, {
|
|
|
106
106
|
cancelDialogContent:
|
|
107
107
|
'Your preferences have not been saved. By continuing to use our website, you’re agreeing to our Privacy Policy.',
|
|
108
108
|
defaultDestinationBehavior: 'disable',
|
|
109
|
-
preferencesDialogTemplate: defaultPreferencesDialogTemplate
|
|
109
|
+
preferencesDialogTemplate: defaultPreferencesDialogTemplate,
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
render() {
|
|
@@ -132,9 +132,8 @@ export default class ConsentManager extends PureComponent<ConsentManagerProps, {
|
|
|
132
132
|
cancelDialogContent,
|
|
133
133
|
customCategories,
|
|
134
134
|
defaultDestinationBehavior,
|
|
135
|
-
cdnHost,
|
|
136
135
|
preferencesDialogTemplate,
|
|
137
|
-
onError
|
|
136
|
+
onError,
|
|
138
137
|
} = this.props
|
|
139
138
|
|
|
140
139
|
return (
|
|
@@ -151,7 +150,6 @@ export default class ConsentManager extends PureComponent<ConsentManagerProps, {
|
|
|
151
150
|
mapCustomPreferences={this.handleMapCustomPreferences}
|
|
152
151
|
customCategories={customCategories}
|
|
153
152
|
defaultDestinationBehavior={defaultDestinationBehavior}
|
|
154
|
-
cdnHost={cdnHost}
|
|
155
153
|
>
|
|
156
154
|
{({
|
|
157
155
|
destinations,
|
|
@@ -163,7 +161,7 @@ export default class ConsentManager extends PureComponent<ConsentManagerProps, {
|
|
|
163
161
|
resetPreferences,
|
|
164
162
|
saveConsent,
|
|
165
163
|
havePreferencesChanged,
|
|
166
|
-
workspaceAddedNewDestinations
|
|
164
|
+
workspaceAddedNewDestinations,
|
|
167
165
|
}) => {
|
|
168
166
|
return (
|
|
169
167
|
<Container
|
|
@@ -209,34 +207,34 @@ export default class ConsentManager extends PureComponent<ConsentManagerProps, {
|
|
|
209
207
|
|
|
210
208
|
mergeTemplates = (
|
|
211
209
|
newProps: PreferenceDialogTemplate,
|
|
212
|
-
defaultPreferencesDialogTemplate: PreferenceDialogTemplate
|
|
210
|
+
defaultPreferencesDialogTemplate: PreferenceDialogTemplate,
|
|
213
211
|
): PreferenceDialogTemplate => {
|
|
214
212
|
const headingsMerge = {
|
|
215
213
|
...defaultPreferencesDialogTemplate.headings,
|
|
216
|
-
...newProps.headings
|
|
214
|
+
...newProps.headings,
|
|
217
215
|
}
|
|
218
216
|
const checkboxesMerge = {
|
|
219
217
|
...defaultPreferencesDialogTemplate.checkboxes,
|
|
220
|
-
...newProps.checkboxes
|
|
218
|
+
...newProps.checkboxes,
|
|
221
219
|
}
|
|
222
220
|
const actionButtonsMerge = {
|
|
223
221
|
...defaultPreferencesDialogTemplate.actionButtons,
|
|
224
|
-
...newProps.actionButtons
|
|
222
|
+
...newProps.actionButtons,
|
|
225
223
|
}
|
|
226
224
|
const cancelDialogButtonsMerge = {
|
|
227
225
|
...defaultPreferencesDialogTemplate.cancelDialogButtons,
|
|
228
|
-
...newProps.cancelDialogButtons
|
|
226
|
+
...newProps.cancelDialogButtons,
|
|
229
227
|
}
|
|
230
|
-
const categoriesMerge = defaultPreferencesDialogTemplate?.categories!.map(category => ({
|
|
228
|
+
const categoriesMerge = defaultPreferencesDialogTemplate?.categories!.map((category) => ({
|
|
231
229
|
...category,
|
|
232
|
-
...newProps?.categories?.find(c => c.key === category.key)
|
|
230
|
+
...newProps?.categories?.find((c) => c.key === category.key),
|
|
233
231
|
}))
|
|
234
232
|
return {
|
|
235
233
|
headings: headingsMerge,
|
|
236
234
|
checkboxes: checkboxesMerge,
|
|
237
235
|
actionButtons: actionButtonsMerge,
|
|
238
236
|
cancelDialogButtons: cancelDialogButtonsMerge,
|
|
239
|
-
categories: categoriesMerge
|
|
237
|
+
categories: categoriesMerge,
|
|
240
238
|
}
|
|
241
239
|
}
|
|
242
240
|
|
|
@@ -251,7 +249,7 @@ export default class ConsentManager extends PureComponent<ConsentManagerProps, {
|
|
|
251
249
|
}
|
|
252
250
|
|
|
253
251
|
const initialCustomPreferences = {}
|
|
254
|
-
Object.keys(customCategories).forEach(category => {
|
|
252
|
+
Object.keys(customCategories).forEach((category) => {
|
|
255
253
|
initialCustomPreferences[category] = null
|
|
256
254
|
})
|
|
257
255
|
|
|
@@ -273,7 +271,7 @@ export default class ConsentManager extends PureComponent<ConsentManagerProps, {
|
|
|
273
271
|
}
|
|
274
272
|
}
|
|
275
273
|
|
|
276
|
-
destinations.forEach(destination => {
|
|
274
|
+
destinations.forEach((destination) => {
|
|
277
275
|
// Mark custom categories
|
|
278
276
|
Object.entries(customCategories).forEach(([categoryName, { integrations }]) => {
|
|
279
277
|
const consentAlreadySetToFalse = destinationPreferences[destination.id] === false
|
|
@@ -302,7 +300,7 @@ export default class ConsentManager extends PureComponent<ConsentManagerProps, {
|
|
|
302
300
|
for (const destination of destinations) {
|
|
303
301
|
// Mark advertising destinations
|
|
304
302
|
if (
|
|
305
|
-
ADVERTISING_CATEGORIES.find(c => c === destination.category) &&
|
|
303
|
+
ADVERTISING_CATEGORIES.find((c) => c === destination.category) &&
|
|
306
304
|
destinationPreferences[destination.id] !== false
|
|
307
305
|
) {
|
|
308
306
|
destinationPreferences[destination.id] = customPrefs.advertising
|
|
@@ -310,7 +308,7 @@ export default class ConsentManager extends PureComponent<ConsentManagerProps, {
|
|
|
310
308
|
|
|
311
309
|
// Mark function destinations
|
|
312
310
|
if (
|
|
313
|
-
FUNCTIONAL_CATEGORIES.find(c => c === destination.category) &&
|
|
311
|
+
FUNCTIONAL_CATEGORIES.find((c) => c === destination.category) &&
|
|
314
312
|
destinationPreferences[destination.id] !== false
|
|
315
313
|
) {
|
|
316
314
|
destinationPreferences[destination.id] = customPrefs.functional
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Destination,
|
|
8
8
|
CustomCategories,
|
|
9
9
|
CategoryPreferences,
|
|
10
|
-
PreferenceDialogTemplate
|
|
10
|
+
PreferenceDialogTemplate,
|
|
11
11
|
} from '../types'
|
|
12
12
|
|
|
13
13
|
const hideOnMobile = css`
|
|
@@ -93,7 +93,7 @@ export default class PreferenceDialog extends PureComponent<PreferenceDialogProp
|
|
|
93
93
|
static defaultProps = {
|
|
94
94
|
marketingAndAnalytics: null,
|
|
95
95
|
advertising: null,
|
|
96
|
-
functional: null
|
|
96
|
+
functional: null,
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
render() {
|
|
@@ -111,17 +111,19 @@ export default class PreferenceDialog extends PureComponent<PreferenceDialogProp
|
|
|
111
111
|
title,
|
|
112
112
|
content,
|
|
113
113
|
preferences,
|
|
114
|
-
preferencesDialogTemplate
|
|
114
|
+
preferencesDialogTemplate,
|
|
115
115
|
} = this.props
|
|
116
116
|
|
|
117
117
|
const { headings, checkboxes, actionButtons } = preferencesDialogTemplate!
|
|
118
118
|
|
|
119
|
-
const functionalInfo = preferencesDialogTemplate?.categories!.find(
|
|
120
|
-
|
|
119
|
+
const functionalInfo = preferencesDialogTemplate?.categories!.find(
|
|
120
|
+
(c) => c.key === 'functional',
|
|
121
|
+
)
|
|
122
|
+
const marketingInfo = preferencesDialogTemplate?.categories!.find((c) => c.key === 'marketing')
|
|
121
123
|
const advertisingInfo = preferencesDialogTemplate?.categories!.find(
|
|
122
|
-
c => c.key === 'advertising'
|
|
124
|
+
(c) => c.key === 'advertising',
|
|
123
125
|
)
|
|
124
|
-
const essentialInfo = preferencesDialogTemplate?.categories!.find(c => c.key === 'essential')
|
|
126
|
+
const essentialInfo = preferencesDialogTemplate?.categories!.find((c) => c.key === 'essential')
|
|
125
127
|
|
|
126
128
|
const buttons = (
|
|
127
129
|
<div>
|
|
@@ -326,7 +328,7 @@ export default class PreferenceDialog extends PureComponent<PreferenceDialogProp
|
|
|
326
328
|
.join(', ')}
|
|
327
329
|
</td> */}
|
|
328
330
|
</Row>
|
|
329
|
-
)
|
|
331
|
+
),
|
|
330
332
|
)}
|
|
331
333
|
</tbody>
|
|
332
334
|
</Table>
|
|
@@ -335,7 +337,7 @@ export default class PreferenceDialog extends PureComponent<PreferenceDialogProp
|
|
|
335
337
|
)
|
|
336
338
|
}
|
|
337
339
|
|
|
338
|
-
handleChange = e => {
|
|
340
|
+
handleChange = (e) => {
|
|
339
341
|
const { onChange } = this.props
|
|
340
342
|
onChange(e.target.name, e.target.value === 'true')
|
|
341
343
|
}
|
|
@@ -347,7 +349,7 @@ export default class PreferenceDialog extends PureComponent<PreferenceDialogProp
|
|
|
347
349
|
marketingAndAnalytics,
|
|
348
350
|
advertising,
|
|
349
351
|
functional,
|
|
350
|
-
customCategories
|
|
352
|
+
customCategories,
|
|
351
353
|
} = this.props
|
|
352
354
|
e.preventDefault()
|
|
353
355
|
// Safe guard against browsers that don't prevent the
|
|
@@ -362,7 +364,7 @@ export default class PreferenceDialog extends PureComponent<PreferenceDialogProp
|
|
|
362
364
|
// Safe guard against custom categories being null
|
|
363
365
|
if (
|
|
364
366
|
customCategories &&
|
|
365
|
-
Object.keys(customCategories).some(category => preferences[category] === null)
|
|
367
|
+
Object.keys(customCategories).some((category) => preferences[category] === null)
|
|
366
368
|
) {
|
|
367
369
|
return
|
|
368
370
|
}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
DefaultDestinationBehavior,
|
|
5
5
|
CategoryPreferences,
|
|
6
6
|
Middleware,
|
|
7
|
-
HtEventsBrowserOptions
|
|
7
|
+
HtEventsBrowserOptions,
|
|
8
8
|
} from '../types'
|
|
9
9
|
|
|
10
10
|
interface AnalyticsParams {
|
|
@@ -22,13 +22,16 @@ interface AnalyticsParams {
|
|
|
22
22
|
function getConsentMiddleware(
|
|
23
23
|
destinationPreferences,
|
|
24
24
|
categoryPreferences,
|
|
25
|
-
defaultDestinationBehavior
|
|
25
|
+
defaultDestinationBehavior,
|
|
26
26
|
): Middleware {
|
|
27
27
|
return ({ payload, next }) => {
|
|
28
28
|
payload.obj.context.consent = {
|
|
29
29
|
defaultDestinationBehavior,
|
|
30
30
|
categoryPreferences,
|
|
31
|
-
destinationPreferences
|
|
31
|
+
destinationPreferences,
|
|
32
|
+
// give precedence to `context.consent` values set explicitly for the event
|
|
33
|
+
// this allows us to immediately reflect changes made to consent
|
|
34
|
+
...payload.obj.context.consent,
|
|
32
35
|
}
|
|
33
36
|
next(payload)
|
|
34
37
|
}
|
|
@@ -43,7 +46,7 @@ export default function conditionallyLoadAnalytics({
|
|
|
43
46
|
shouldReload = true,
|
|
44
47
|
devMode = false,
|
|
45
48
|
defaultDestinationBehavior,
|
|
46
|
-
categoryPreferences
|
|
49
|
+
categoryPreferences,
|
|
47
50
|
}: AnalyticsParams) {
|
|
48
51
|
const wd = window as WindowWithHtEvents
|
|
49
52
|
if (!wd.htevents) return
|
|
@@ -95,7 +98,7 @@ export default function conditionallyLoadAnalytics({
|
|
|
95
98
|
const middleware = getConsentMiddleware(
|
|
96
99
|
destinationPreferences,
|
|
97
100
|
categoryPreferences,
|
|
98
|
-
defaultDestinationBehavior
|
|
101
|
+
defaultDestinationBehavior,
|
|
99
102
|
)
|
|
100
103
|
wd.htevents.addSourceMiddleware(middleware)
|
|
101
104
|
|