@guardian/commercial-core 4.1.1 → 4.3.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/dist/cjs/ad-sizes.d.ts +1 -1
- package/dist/cjs/ad-sizes.js +53 -0
- package/dist/cjs/create-ad-slot.js +11 -79
- package/dist/cjs/send-commercial-metrics.js +2 -2
- package/dist/cjs/targeting/personalised.js +11 -19
- package/dist/esm/ad-sizes.d.ts +1 -1
- package/dist/esm/ad-sizes.js +53 -0
- package/dist/esm/create-ad-slot.js +12 -80
- package/dist/esm/send-commercial-metrics.js +2 -2
- package/dist/esm/targeting/personalised.js +11 -19
- package/package.json +1 -1
package/dist/cjs/ad-sizes.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ declare class AdSize extends Array<number> {
|
|
|
25
25
|
get height(): number;
|
|
26
26
|
}
|
|
27
27
|
declare type SizeKeys = '160x600' | '300x1050' | '300x250' | '300x600' | '728x90' | '970x250' | 'billboard' | 'empty' | 'fabric' | 'fluid' | 'googleCard' | 'halfPage' | 'inlineMerchandising' | 'leaderboard' | 'merchandising' | 'merchandisingHigh' | 'merchandisingHighAdFeature' | 'mobilesticky' | 'mpu' | 'outOfPage' | 'outstreamDesktop' | 'outstreamGoogleDesktop' | 'outstreamMobile' | 'portrait' | 'skyscraper';
|
|
28
|
-
declare type SlotName = 'right' | 'comments' | 'top-above-nav' | 'mostpop' | 'merchandising' | 'merchandising-high' | 'survey';
|
|
28
|
+
declare type SlotName = 'right' | 'comments' | 'top-above-nav' | 'mostpop' | 'merchandising' | 'merchandising-high' | 'merchandising-high-lucky' | 'survey' | 'im' | 'inline' | 'mostpop' | 'comments' | 'top-above-nav' | 'carrot' | 'epic' | 'mobile-sticky';
|
|
29
29
|
declare type Breakpoint = 'mobile' | 'desktop' | 'phablet' | 'tablet';
|
|
30
30
|
declare type SizeMapping = Partial<Record<Breakpoint, AdSize[]>>;
|
|
31
31
|
declare type SlotSizeMappings = Record<SlotName, SizeMapping>;
|
package/dist/cjs/ad-sizes.js
CHANGED
|
@@ -79,6 +79,31 @@ exports.adSizes = adSizes;
|
|
|
79
79
|
* these were originally from DCR, create-ad-slot.ts ones were in frontend.
|
|
80
80
|
**/
|
|
81
81
|
const slotSizeMappings = {
|
|
82
|
+
inline: {
|
|
83
|
+
mobile: [
|
|
84
|
+
adSizes.outOfPage,
|
|
85
|
+
adSizes.empty,
|
|
86
|
+
adSizes.outstreamMobile,
|
|
87
|
+
adSizes.mpu,
|
|
88
|
+
adSizes.googleCard,
|
|
89
|
+
adSizes.fluid,
|
|
90
|
+
],
|
|
91
|
+
phablet: [
|
|
92
|
+
adSizes.outOfPage,
|
|
93
|
+
adSizes.empty,
|
|
94
|
+
adSizes.outstreamMobile,
|
|
95
|
+
adSizes.mpu,
|
|
96
|
+
adSizes.googleCard,
|
|
97
|
+
adSizes.fluid,
|
|
98
|
+
],
|
|
99
|
+
desktop: [
|
|
100
|
+
adSizes.outOfPage,
|
|
101
|
+
adSizes.empty,
|
|
102
|
+
adSizes.mpu,
|
|
103
|
+
adSizes.googleCard,
|
|
104
|
+
adSizes.fluid,
|
|
105
|
+
],
|
|
106
|
+
},
|
|
82
107
|
right: {
|
|
83
108
|
mobile: [
|
|
84
109
|
adSizes.outOfPage,
|
|
@@ -118,6 +143,14 @@ const slotSizeMappings = {
|
|
|
118
143
|
],
|
|
119
144
|
},
|
|
120
145
|
'top-above-nav': {
|
|
146
|
+
mobile: [
|
|
147
|
+
adSizes.outOfPage,
|
|
148
|
+
adSizes.empty,
|
|
149
|
+
adSizes.fabric,
|
|
150
|
+
adSizes.outstreamMobile,
|
|
151
|
+
adSizes.mpu,
|
|
152
|
+
adSizes.fluid,
|
|
153
|
+
],
|
|
121
154
|
tablet: [
|
|
122
155
|
adSizes.outOfPage,
|
|
123
156
|
adSizes.empty,
|
|
@@ -171,6 +204,14 @@ const slotSizeMappings = {
|
|
|
171
204
|
adSizes.fluid,
|
|
172
205
|
],
|
|
173
206
|
},
|
|
207
|
+
im: {
|
|
208
|
+
mobile: [
|
|
209
|
+
adSizes.outOfPage,
|
|
210
|
+
adSizes.empty,
|
|
211
|
+
adSizes.inlineMerchandising,
|
|
212
|
+
adSizes.fluid,
|
|
213
|
+
],
|
|
214
|
+
},
|
|
174
215
|
'merchandising-high': {
|
|
175
216
|
mobile: [
|
|
176
217
|
adSizes.outOfPage,
|
|
@@ -179,6 +220,9 @@ const slotSizeMappings = {
|
|
|
179
220
|
adSizes.fluid,
|
|
180
221
|
],
|
|
181
222
|
},
|
|
223
|
+
'merchandising-high-lucky': {
|
|
224
|
+
mobile: [adSizes.outOfPage, adSizes.empty, adSizes.fluid],
|
|
225
|
+
},
|
|
182
226
|
merchandising: {
|
|
183
227
|
mobile: [
|
|
184
228
|
adSizes.outOfPage,
|
|
@@ -190,6 +234,15 @@ const slotSizeMappings = {
|
|
|
190
234
|
survey: {
|
|
191
235
|
desktop: [adSizes.outOfPage],
|
|
192
236
|
},
|
|
237
|
+
carrot: {
|
|
238
|
+
mobile: [adSizes.fluid],
|
|
239
|
+
},
|
|
240
|
+
epic: {
|
|
241
|
+
mobile: [adSizes.fluid],
|
|
242
|
+
},
|
|
243
|
+
'mobile-sticky': {
|
|
244
|
+
mobile: [adSizes.mobilesticky],
|
|
245
|
+
},
|
|
193
246
|
};
|
|
194
247
|
exports.slotSizeMappings = slotSizeMappings;
|
|
195
248
|
const getAdSize = (size) => adSizes[size];
|
|
@@ -3,127 +3,59 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createAdSlot = void 0;
|
|
4
4
|
const ad_sizes_1 = require("./ad-sizes");
|
|
5
5
|
const adSlotIdPrefix = 'dfp-ad--';
|
|
6
|
-
const commonSizeMappings = {
|
|
7
|
-
mobile: [
|
|
8
|
-
ad_sizes_1.adSizes.outOfPage,
|
|
9
|
-
ad_sizes_1.adSizes.empty,
|
|
10
|
-
ad_sizes_1.adSizes.outstreamMobile,
|
|
11
|
-
ad_sizes_1.adSizes.mpu,
|
|
12
|
-
ad_sizes_1.adSizes.googleCard,
|
|
13
|
-
ad_sizes_1.adSizes.fluid,
|
|
14
|
-
],
|
|
15
|
-
phablet: [
|
|
16
|
-
ad_sizes_1.adSizes.outOfPage,
|
|
17
|
-
ad_sizes_1.adSizes.empty,
|
|
18
|
-
ad_sizes_1.adSizes.outstreamMobile,
|
|
19
|
-
ad_sizes_1.adSizes.mpu,
|
|
20
|
-
ad_sizes_1.adSizes.googleCard,
|
|
21
|
-
ad_sizes_1.adSizes.fluid,
|
|
22
|
-
],
|
|
23
|
-
desktop: [
|
|
24
|
-
ad_sizes_1.adSizes.outOfPage,
|
|
25
|
-
ad_sizes_1.adSizes.empty,
|
|
26
|
-
ad_sizes_1.adSizes.mpu,
|
|
27
|
-
ad_sizes_1.adSizes.googleCard,
|
|
28
|
-
ad_sizes_1.adSizes.fluid,
|
|
29
|
-
],
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* mark: 432b3a46-90c1-4573-90d3-2400b51af8d0
|
|
33
|
-
* Some of these may or may not need to be synced for with the sizes in ./ad-sizes.ts
|
|
34
|
-
* these were originally from frontend, ad-sizes.ts ones were in DCR.
|
|
35
|
-
**/
|
|
36
6
|
const adSlotConfigs = {
|
|
37
7
|
im: {
|
|
38
8
|
label: false,
|
|
39
9
|
refresh: false,
|
|
40
|
-
sizeMappings:
|
|
41
|
-
mobile: [
|
|
42
|
-
ad_sizes_1.adSizes.outOfPage,
|
|
43
|
-
ad_sizes_1.adSizes.empty,
|
|
44
|
-
ad_sizes_1.adSizes.inlineMerchandising,
|
|
45
|
-
ad_sizes_1.adSizes.fluid,
|
|
46
|
-
],
|
|
47
|
-
},
|
|
10
|
+
sizeMappings: ad_sizes_1.slotSizeMappings['im'],
|
|
48
11
|
},
|
|
49
12
|
'high-merch': {
|
|
50
13
|
label: false,
|
|
51
14
|
refresh: false,
|
|
52
15
|
name: 'merchandising-high',
|
|
53
|
-
sizeMappings:
|
|
54
|
-
mobile: [
|
|
55
|
-
ad_sizes_1.adSizes.outOfPage,
|
|
56
|
-
ad_sizes_1.adSizes.empty,
|
|
57
|
-
ad_sizes_1.adSizes.merchandisingHigh,
|
|
58
|
-
ad_sizes_1.adSizes.fluid,
|
|
59
|
-
],
|
|
60
|
-
},
|
|
16
|
+
sizeMappings: ad_sizes_1.slotSizeMappings['merchandising-high'],
|
|
61
17
|
},
|
|
62
18
|
'high-merch-lucky': {
|
|
63
19
|
label: false,
|
|
64
20
|
refresh: false,
|
|
65
21
|
name: 'merchandising-high-lucky',
|
|
66
|
-
sizeMappings:
|
|
67
|
-
mobile: [ad_sizes_1.adSizes.outOfPage, ad_sizes_1.adSizes.empty, ad_sizes_1.adSizes.fluid],
|
|
68
|
-
},
|
|
22
|
+
sizeMappings: ad_sizes_1.slotSizeMappings['merchandising-high-lucky'],
|
|
69
23
|
},
|
|
70
24
|
'high-merch-paid': {
|
|
71
25
|
label: false,
|
|
72
26
|
refresh: false,
|
|
73
27
|
name: 'merchandising-high',
|
|
74
|
-
sizeMappings:
|
|
75
|
-
mobile: [
|
|
76
|
-
ad_sizes_1.adSizes.outOfPage,
|
|
77
|
-
ad_sizes_1.adSizes.empty,
|
|
78
|
-
ad_sizes_1.adSizes.merchandisingHighAdFeature,
|
|
79
|
-
ad_sizes_1.adSizes.fluid,
|
|
80
|
-
],
|
|
81
|
-
},
|
|
28
|
+
sizeMappings: ad_sizes_1.slotSizeMappings['merchandising-high'],
|
|
82
29
|
},
|
|
83
30
|
inline: {
|
|
84
|
-
sizeMappings:
|
|
31
|
+
sizeMappings: ad_sizes_1.slotSizeMappings['inline'],
|
|
85
32
|
},
|
|
86
33
|
mostpop: {
|
|
87
|
-
sizeMappings:
|
|
34
|
+
sizeMappings: ad_sizes_1.slotSizeMappings['mostpop'],
|
|
88
35
|
},
|
|
89
36
|
comments: {
|
|
90
|
-
sizeMappings:
|
|
37
|
+
sizeMappings: ad_sizes_1.slotSizeMappings['comments'],
|
|
91
38
|
},
|
|
92
39
|
'top-above-nav': {
|
|
93
|
-
sizeMappings:
|
|
94
|
-
mobile: [
|
|
95
|
-
ad_sizes_1.adSizes.outOfPage,
|
|
96
|
-
ad_sizes_1.adSizes.empty,
|
|
97
|
-
ad_sizes_1.adSizes.fabric,
|
|
98
|
-
ad_sizes_1.adSizes.outstreamMobile,
|
|
99
|
-
ad_sizes_1.adSizes.mpu,
|
|
100
|
-
ad_sizes_1.adSizes.fluid,
|
|
101
|
-
],
|
|
102
|
-
},
|
|
40
|
+
sizeMappings: ad_sizes_1.slotSizeMappings['top-above-nav'],
|
|
103
41
|
},
|
|
104
42
|
carrot: {
|
|
105
43
|
label: false,
|
|
106
44
|
refresh: false,
|
|
107
45
|
name: 'carrot',
|
|
108
|
-
sizeMappings:
|
|
109
|
-
mobile: [ad_sizes_1.adSizes.fluid],
|
|
110
|
-
},
|
|
46
|
+
sizeMappings: ad_sizes_1.slotSizeMappings['merchandising-high'],
|
|
111
47
|
},
|
|
112
48
|
epic: {
|
|
113
49
|
label: false,
|
|
114
50
|
refresh: false,
|
|
115
51
|
name: 'epic',
|
|
116
|
-
sizeMappings:
|
|
117
|
-
mobile: [ad_sizes_1.adSizes.fluid],
|
|
118
|
-
},
|
|
52
|
+
sizeMappings: ad_sizes_1.slotSizeMappings['epic'],
|
|
119
53
|
},
|
|
120
54
|
'mobile-sticky': {
|
|
121
55
|
label: true,
|
|
122
56
|
refresh: true,
|
|
123
57
|
name: 'mobile-sticky',
|
|
124
|
-
sizeMappings:
|
|
125
|
-
mobile: [ad_sizes_1.adSizes.mobilesticky],
|
|
126
|
-
},
|
|
58
|
+
sizeMappings: ad_sizes_1.slotSizeMappings['mobile-sticky'],
|
|
127
59
|
},
|
|
128
60
|
};
|
|
129
61
|
/**
|
|
@@ -83,9 +83,9 @@ const listener = (e) => {
|
|
|
83
83
|
};
|
|
84
84
|
const addVisibilityListeners = () => {
|
|
85
85
|
// Report all available metrics when the page is unloaded or in background.
|
|
86
|
-
window.addEventListener('visibilitychange', listener);
|
|
86
|
+
window.addEventListener('visibilitychange', listener, { once: true });
|
|
87
87
|
// Safari does not reliably fire the `visibilitychange` on page unload.
|
|
88
|
-
window.addEventListener('pagehide', listener);
|
|
88
|
+
window.addEventListener('pagehide', listener, { once: true });
|
|
89
89
|
};
|
|
90
90
|
const checkConsent = async () => {
|
|
91
91
|
const consentState = await (0, consent_management_platform_1.onConsent)();
|
|
@@ -73,39 +73,27 @@ const getFrequencyValue = (state) => {
|
|
|
73
73
|
}
|
|
74
74
|
return '0';
|
|
75
75
|
};
|
|
76
|
-
const tcfv2AllPurposesConsented = (consents) => Object.keys(consents).length > 0 && Object.values(consents).every(Boolean);
|
|
77
|
-
const personalisedAdvertising = (state) => {
|
|
78
|
-
if (state.tcfv2)
|
|
79
|
-
return tcfv2AllPurposesConsented(state.tcfv2.consents);
|
|
80
|
-
if (state.ccpa)
|
|
81
|
-
return !state.ccpa.doNotSell;
|
|
82
|
-
if (state.aus)
|
|
83
|
-
return state.aus.personalisedAdvertising;
|
|
84
|
-
return false;
|
|
85
|
-
};
|
|
86
76
|
const getCMPTargeting = (state) => {
|
|
87
77
|
if (state.tcfv2) {
|
|
88
78
|
return {
|
|
89
79
|
cmp_interaction: state.tcfv2.eventStatus,
|
|
90
|
-
pa:
|
|
91
|
-
consent_tcfv2:
|
|
92
|
-
? 't'
|
|
93
|
-
: 'f',
|
|
80
|
+
pa: state.canTarget ? 't' : 'f',
|
|
81
|
+
consent_tcfv2: state.canTarget ? 't' : 'f',
|
|
94
82
|
rdp: 'na',
|
|
95
83
|
};
|
|
96
84
|
}
|
|
97
85
|
if (state.ccpa) {
|
|
98
86
|
return {
|
|
99
87
|
consent_tcfv2: 'na',
|
|
100
|
-
rdp: state.
|
|
101
|
-
pa: state.
|
|
88
|
+
rdp: !state.canTarget ? 't' : 'f',
|
|
89
|
+
pa: state.canTarget ? 't' : 'f',
|
|
102
90
|
};
|
|
103
91
|
}
|
|
104
92
|
if (state.aus) {
|
|
105
93
|
return {
|
|
106
94
|
consent_tcfv2: 'na',
|
|
107
95
|
rdp: 'na',
|
|
108
|
-
pa: state.
|
|
96
|
+
pa: state.canTarget ? 't' : 'f',
|
|
109
97
|
};
|
|
110
98
|
}
|
|
111
99
|
return {
|
|
@@ -123,7 +111,11 @@ const createAdManagerGroup = () => {
|
|
|
123
111
|
return group;
|
|
124
112
|
};
|
|
125
113
|
const getAdManagerGroup = (state) => {
|
|
126
|
-
if (!
|
|
114
|
+
if (!state.framework) {
|
|
115
|
+
libs_1.storage.local.remove(AMTGRP_STORAGE_KEY);
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
if (state.tcfv2 && !state.canTarget) {
|
|
127
119
|
libs_1.storage.local.remove(AMTGRP_STORAGE_KEY);
|
|
128
120
|
return null;
|
|
129
121
|
}
|
|
@@ -133,7 +125,7 @@ const getAdManagerGroup = (state) => {
|
|
|
133
125
|
: createAdManagerGroup();
|
|
134
126
|
};
|
|
135
127
|
const getPermutiveWithState = (state) => {
|
|
136
|
-
if (
|
|
128
|
+
if (state.canTarget)
|
|
137
129
|
return (0, permutive_1.getPermutiveSegments)();
|
|
138
130
|
(0, permutive_1.clearPermutiveSegments)();
|
|
139
131
|
return [];
|
package/dist/esm/ad-sizes.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ declare class AdSize extends Array<number> {
|
|
|
25
25
|
get height(): number;
|
|
26
26
|
}
|
|
27
27
|
declare type SizeKeys = '160x600' | '300x1050' | '300x250' | '300x600' | '728x90' | '970x250' | 'billboard' | 'empty' | 'fabric' | 'fluid' | 'googleCard' | 'halfPage' | 'inlineMerchandising' | 'leaderboard' | 'merchandising' | 'merchandisingHigh' | 'merchandisingHighAdFeature' | 'mobilesticky' | 'mpu' | 'outOfPage' | 'outstreamDesktop' | 'outstreamGoogleDesktop' | 'outstreamMobile' | 'portrait' | 'skyscraper';
|
|
28
|
-
declare type SlotName = 'right' | 'comments' | 'top-above-nav' | 'mostpop' | 'merchandising' | 'merchandising-high' | 'survey';
|
|
28
|
+
declare type SlotName = 'right' | 'comments' | 'top-above-nav' | 'mostpop' | 'merchandising' | 'merchandising-high' | 'merchandising-high-lucky' | 'survey' | 'im' | 'inline' | 'mostpop' | 'comments' | 'top-above-nav' | 'carrot' | 'epic' | 'mobile-sticky';
|
|
29
29
|
declare type Breakpoint = 'mobile' | 'desktop' | 'phablet' | 'tablet';
|
|
30
30
|
declare type SizeMapping = Partial<Record<Breakpoint, AdSize[]>>;
|
|
31
31
|
declare type SlotSizeMappings = Record<SlotName, SizeMapping>;
|
package/dist/esm/ad-sizes.js
CHANGED
|
@@ -74,6 +74,31 @@ const adSizes = {
|
|
|
74
74
|
* these were originally from DCR, create-ad-slot.ts ones were in frontend.
|
|
75
75
|
**/
|
|
76
76
|
const slotSizeMappings = {
|
|
77
|
+
inline: {
|
|
78
|
+
mobile: [
|
|
79
|
+
adSizes.outOfPage,
|
|
80
|
+
adSizes.empty,
|
|
81
|
+
adSizes.outstreamMobile,
|
|
82
|
+
adSizes.mpu,
|
|
83
|
+
adSizes.googleCard,
|
|
84
|
+
adSizes.fluid,
|
|
85
|
+
],
|
|
86
|
+
phablet: [
|
|
87
|
+
adSizes.outOfPage,
|
|
88
|
+
adSizes.empty,
|
|
89
|
+
adSizes.outstreamMobile,
|
|
90
|
+
adSizes.mpu,
|
|
91
|
+
adSizes.googleCard,
|
|
92
|
+
adSizes.fluid,
|
|
93
|
+
],
|
|
94
|
+
desktop: [
|
|
95
|
+
adSizes.outOfPage,
|
|
96
|
+
adSizes.empty,
|
|
97
|
+
adSizes.mpu,
|
|
98
|
+
adSizes.googleCard,
|
|
99
|
+
adSizes.fluid,
|
|
100
|
+
],
|
|
101
|
+
},
|
|
77
102
|
right: {
|
|
78
103
|
mobile: [
|
|
79
104
|
adSizes.outOfPage,
|
|
@@ -113,6 +138,14 @@ const slotSizeMappings = {
|
|
|
113
138
|
],
|
|
114
139
|
},
|
|
115
140
|
'top-above-nav': {
|
|
141
|
+
mobile: [
|
|
142
|
+
adSizes.outOfPage,
|
|
143
|
+
adSizes.empty,
|
|
144
|
+
adSizes.fabric,
|
|
145
|
+
adSizes.outstreamMobile,
|
|
146
|
+
adSizes.mpu,
|
|
147
|
+
adSizes.fluid,
|
|
148
|
+
],
|
|
116
149
|
tablet: [
|
|
117
150
|
adSizes.outOfPage,
|
|
118
151
|
adSizes.empty,
|
|
@@ -166,6 +199,14 @@ const slotSizeMappings = {
|
|
|
166
199
|
adSizes.fluid,
|
|
167
200
|
],
|
|
168
201
|
},
|
|
202
|
+
im: {
|
|
203
|
+
mobile: [
|
|
204
|
+
adSizes.outOfPage,
|
|
205
|
+
adSizes.empty,
|
|
206
|
+
adSizes.inlineMerchandising,
|
|
207
|
+
adSizes.fluid,
|
|
208
|
+
],
|
|
209
|
+
},
|
|
169
210
|
'merchandising-high': {
|
|
170
211
|
mobile: [
|
|
171
212
|
adSizes.outOfPage,
|
|
@@ -174,6 +215,9 @@ const slotSizeMappings = {
|
|
|
174
215
|
adSizes.fluid,
|
|
175
216
|
],
|
|
176
217
|
},
|
|
218
|
+
'merchandising-high-lucky': {
|
|
219
|
+
mobile: [adSizes.outOfPage, adSizes.empty, adSizes.fluid],
|
|
220
|
+
},
|
|
177
221
|
merchandising: {
|
|
178
222
|
mobile: [
|
|
179
223
|
adSizes.outOfPage,
|
|
@@ -185,6 +229,15 @@ const slotSizeMappings = {
|
|
|
185
229
|
survey: {
|
|
186
230
|
desktop: [adSizes.outOfPage],
|
|
187
231
|
},
|
|
232
|
+
carrot: {
|
|
233
|
+
mobile: [adSizes.fluid],
|
|
234
|
+
},
|
|
235
|
+
epic: {
|
|
236
|
+
mobile: [adSizes.fluid],
|
|
237
|
+
},
|
|
238
|
+
'mobile-sticky': {
|
|
239
|
+
mobile: [adSizes.mobilesticky],
|
|
240
|
+
},
|
|
188
241
|
};
|
|
189
242
|
const getAdSize = (size) => adSizes[size];
|
|
190
243
|
// Export for testing
|
|
@@ -1,126 +1,58 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { slotSizeMappings } from './ad-sizes';
|
|
2
2
|
const adSlotIdPrefix = 'dfp-ad--';
|
|
3
|
-
const commonSizeMappings = {
|
|
4
|
-
mobile: [
|
|
5
|
-
adSizes.outOfPage,
|
|
6
|
-
adSizes.empty,
|
|
7
|
-
adSizes.outstreamMobile,
|
|
8
|
-
adSizes.mpu,
|
|
9
|
-
adSizes.googleCard,
|
|
10
|
-
adSizes.fluid,
|
|
11
|
-
],
|
|
12
|
-
phablet: [
|
|
13
|
-
adSizes.outOfPage,
|
|
14
|
-
adSizes.empty,
|
|
15
|
-
adSizes.outstreamMobile,
|
|
16
|
-
adSizes.mpu,
|
|
17
|
-
adSizes.googleCard,
|
|
18
|
-
adSizes.fluid,
|
|
19
|
-
],
|
|
20
|
-
desktop: [
|
|
21
|
-
adSizes.outOfPage,
|
|
22
|
-
adSizes.empty,
|
|
23
|
-
adSizes.mpu,
|
|
24
|
-
adSizes.googleCard,
|
|
25
|
-
adSizes.fluid,
|
|
26
|
-
],
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* mark: 432b3a46-90c1-4573-90d3-2400b51af8d0
|
|
30
|
-
* Some of these may or may not need to be synced for with the sizes in ./ad-sizes.ts
|
|
31
|
-
* these were originally from frontend, ad-sizes.ts ones were in DCR.
|
|
32
|
-
**/
|
|
33
3
|
const adSlotConfigs = {
|
|
34
4
|
im: {
|
|
35
5
|
label: false,
|
|
36
6
|
refresh: false,
|
|
37
|
-
sizeMappings:
|
|
38
|
-
mobile: [
|
|
39
|
-
adSizes.outOfPage,
|
|
40
|
-
adSizes.empty,
|
|
41
|
-
adSizes.inlineMerchandising,
|
|
42
|
-
adSizes.fluid,
|
|
43
|
-
],
|
|
44
|
-
},
|
|
7
|
+
sizeMappings: slotSizeMappings['im'],
|
|
45
8
|
},
|
|
46
9
|
'high-merch': {
|
|
47
10
|
label: false,
|
|
48
11
|
refresh: false,
|
|
49
12
|
name: 'merchandising-high',
|
|
50
|
-
sizeMappings:
|
|
51
|
-
mobile: [
|
|
52
|
-
adSizes.outOfPage,
|
|
53
|
-
adSizes.empty,
|
|
54
|
-
adSizes.merchandisingHigh,
|
|
55
|
-
adSizes.fluid,
|
|
56
|
-
],
|
|
57
|
-
},
|
|
13
|
+
sizeMappings: slotSizeMappings['merchandising-high'],
|
|
58
14
|
},
|
|
59
15
|
'high-merch-lucky': {
|
|
60
16
|
label: false,
|
|
61
17
|
refresh: false,
|
|
62
18
|
name: 'merchandising-high-lucky',
|
|
63
|
-
sizeMappings:
|
|
64
|
-
mobile: [adSizes.outOfPage, adSizes.empty, adSizes.fluid],
|
|
65
|
-
},
|
|
19
|
+
sizeMappings: slotSizeMappings['merchandising-high-lucky'],
|
|
66
20
|
},
|
|
67
21
|
'high-merch-paid': {
|
|
68
22
|
label: false,
|
|
69
23
|
refresh: false,
|
|
70
24
|
name: 'merchandising-high',
|
|
71
|
-
sizeMappings:
|
|
72
|
-
mobile: [
|
|
73
|
-
adSizes.outOfPage,
|
|
74
|
-
adSizes.empty,
|
|
75
|
-
adSizes.merchandisingHighAdFeature,
|
|
76
|
-
adSizes.fluid,
|
|
77
|
-
],
|
|
78
|
-
},
|
|
25
|
+
sizeMappings: slotSizeMappings['merchandising-high'],
|
|
79
26
|
},
|
|
80
27
|
inline: {
|
|
81
|
-
sizeMappings:
|
|
28
|
+
sizeMappings: slotSizeMappings['inline'],
|
|
82
29
|
},
|
|
83
30
|
mostpop: {
|
|
84
|
-
sizeMappings:
|
|
31
|
+
sizeMappings: slotSizeMappings['mostpop'],
|
|
85
32
|
},
|
|
86
33
|
comments: {
|
|
87
|
-
sizeMappings:
|
|
34
|
+
sizeMappings: slotSizeMappings['comments'],
|
|
88
35
|
},
|
|
89
36
|
'top-above-nav': {
|
|
90
|
-
sizeMappings:
|
|
91
|
-
mobile: [
|
|
92
|
-
adSizes.outOfPage,
|
|
93
|
-
adSizes.empty,
|
|
94
|
-
adSizes.fabric,
|
|
95
|
-
adSizes.outstreamMobile,
|
|
96
|
-
adSizes.mpu,
|
|
97
|
-
adSizes.fluid,
|
|
98
|
-
],
|
|
99
|
-
},
|
|
37
|
+
sizeMappings: slotSizeMappings['top-above-nav'],
|
|
100
38
|
},
|
|
101
39
|
carrot: {
|
|
102
40
|
label: false,
|
|
103
41
|
refresh: false,
|
|
104
42
|
name: 'carrot',
|
|
105
|
-
sizeMappings:
|
|
106
|
-
mobile: [adSizes.fluid],
|
|
107
|
-
},
|
|
43
|
+
sizeMappings: slotSizeMappings['merchandising-high'],
|
|
108
44
|
},
|
|
109
45
|
epic: {
|
|
110
46
|
label: false,
|
|
111
47
|
refresh: false,
|
|
112
48
|
name: 'epic',
|
|
113
|
-
sizeMappings:
|
|
114
|
-
mobile: [adSizes.fluid],
|
|
115
|
-
},
|
|
49
|
+
sizeMappings: slotSizeMappings['epic'],
|
|
116
50
|
},
|
|
117
51
|
'mobile-sticky': {
|
|
118
52
|
label: true,
|
|
119
53
|
refresh: true,
|
|
120
54
|
name: 'mobile-sticky',
|
|
121
|
-
sizeMappings:
|
|
122
|
-
mobile: [adSizes.mobilesticky],
|
|
123
|
-
},
|
|
55
|
+
sizeMappings: slotSizeMappings['mobile-sticky'],
|
|
124
56
|
},
|
|
125
57
|
};
|
|
126
58
|
/**
|
|
@@ -80,9 +80,9 @@ const listener = (e) => {
|
|
|
80
80
|
};
|
|
81
81
|
const addVisibilityListeners = () => {
|
|
82
82
|
// Report all available metrics when the page is unloaded or in background.
|
|
83
|
-
window.addEventListener('visibilitychange', listener);
|
|
83
|
+
window.addEventListener('visibilitychange', listener, { once: true });
|
|
84
84
|
// Safari does not reliably fire the `visibilitychange` on page unload.
|
|
85
|
-
window.addEventListener('pagehide', listener);
|
|
85
|
+
window.addEventListener('pagehide', listener, { once: true });
|
|
86
86
|
};
|
|
87
87
|
const checkConsent = async () => {
|
|
88
88
|
const consentState = await onConsent();
|
|
@@ -70,39 +70,27 @@ const getFrequencyValue = (state) => {
|
|
|
70
70
|
}
|
|
71
71
|
return '0';
|
|
72
72
|
};
|
|
73
|
-
const tcfv2AllPurposesConsented = (consents) => Object.keys(consents).length > 0 && Object.values(consents).every(Boolean);
|
|
74
|
-
const personalisedAdvertising = (state) => {
|
|
75
|
-
if (state.tcfv2)
|
|
76
|
-
return tcfv2AllPurposesConsented(state.tcfv2.consents);
|
|
77
|
-
if (state.ccpa)
|
|
78
|
-
return !state.ccpa.doNotSell;
|
|
79
|
-
if (state.aus)
|
|
80
|
-
return state.aus.personalisedAdvertising;
|
|
81
|
-
return false;
|
|
82
|
-
};
|
|
83
73
|
const getCMPTargeting = (state) => {
|
|
84
74
|
if (state.tcfv2) {
|
|
85
75
|
return {
|
|
86
76
|
cmp_interaction: state.tcfv2.eventStatus,
|
|
87
|
-
pa:
|
|
88
|
-
consent_tcfv2:
|
|
89
|
-
? 't'
|
|
90
|
-
: 'f',
|
|
77
|
+
pa: state.canTarget ? 't' : 'f',
|
|
78
|
+
consent_tcfv2: state.canTarget ? 't' : 'f',
|
|
91
79
|
rdp: 'na',
|
|
92
80
|
};
|
|
93
81
|
}
|
|
94
82
|
if (state.ccpa) {
|
|
95
83
|
return {
|
|
96
84
|
consent_tcfv2: 'na',
|
|
97
|
-
rdp: state.
|
|
98
|
-
pa: state.
|
|
85
|
+
rdp: !state.canTarget ? 't' : 'f',
|
|
86
|
+
pa: state.canTarget ? 't' : 'f',
|
|
99
87
|
};
|
|
100
88
|
}
|
|
101
89
|
if (state.aus) {
|
|
102
90
|
return {
|
|
103
91
|
consent_tcfv2: 'na',
|
|
104
92
|
rdp: 'na',
|
|
105
|
-
pa: state.
|
|
93
|
+
pa: state.canTarget ? 't' : 'f',
|
|
106
94
|
};
|
|
107
95
|
}
|
|
108
96
|
return {
|
|
@@ -120,7 +108,11 @@ const createAdManagerGroup = () => {
|
|
|
120
108
|
return group;
|
|
121
109
|
};
|
|
122
110
|
const getAdManagerGroup = (state) => {
|
|
123
|
-
if (!
|
|
111
|
+
if (!state.framework) {
|
|
112
|
+
storage.local.remove(AMTGRP_STORAGE_KEY);
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
if (state.tcfv2 && !state.canTarget) {
|
|
124
116
|
storage.local.remove(AMTGRP_STORAGE_KEY);
|
|
125
117
|
return null;
|
|
126
118
|
}
|
|
@@ -130,7 +122,7 @@ const getAdManagerGroup = (state) => {
|
|
|
130
122
|
: createAdManagerGroup();
|
|
131
123
|
};
|
|
132
124
|
const getPermutiveWithState = (state) => {
|
|
133
|
-
if (
|
|
125
|
+
if (state.canTarget)
|
|
134
126
|
return getPermutiveSegments();
|
|
135
127
|
clearPermutiveSegments();
|
|
136
128
|
return [];
|