@guardian/commercial-core 4.1.0 → 4.2.1

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.
@@ -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>;
@@ -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: commonSizeMappings,
31
+ sizeMappings: ad_sizes_1.slotSizeMappings['inline'],
85
32
  },
86
33
  mostpop: {
87
- sizeMappings: commonSizeMappings,
34
+ sizeMappings: ad_sizes_1.slotSizeMappings['mostpop'],
88
35
  },
89
36
  comments: {
90
- sizeMappings: commonSizeMappings,
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
  /**
@@ -14,6 +14,7 @@ export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments,
14
14
  export { initTrackScrollDepth } from './track-scroll-depth';
15
15
  export { initTrackGpcSignal } from './track-gpc-signal';
16
16
  export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
17
+ export { createAdSlot } from './create-ad-slot';
17
18
  export type { AdsConfig, AdsConfigBasic, AdsConfigDisabled, AdTargetingBuilder, CustomParams, } from './types';
18
19
  export * as constants from './constants';
19
20
  export type { ContentTargeting } from './targeting/content';
package/dist/cjs/index.js CHANGED
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  return result;
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.pickTargetingValues = exports.getViewportTargeting = exports.getSharedTargeting = exports.getSessionTargeting = exports.getPersonalisedTargeting = exports.getContentTargeting = exports.constants = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.initTrackGpcSignal = exports.initTrackScrollDepth = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.createAdSize = exports.slotSizeMappings = exports.getAdSize = exports.adSizes = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports.EventTimer = exports.remarketing = exports.inizio = exports.twitter = exports.fbPixel = exports.permutive = exports.ias = void 0;
27
+ exports.pickTargetingValues = exports.getViewportTargeting = exports.getSharedTargeting = exports.getSessionTargeting = exports.getPersonalisedTargeting = exports.getContentTargeting = exports.constants = exports.createAdSlot = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.initTrackGpcSignal = exports.initTrackScrollDepth = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.createAdSize = exports.slotSizeMappings = exports.getAdSize = exports.adSizes = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports.EventTimer = exports.remarketing = exports.inizio = exports.twitter = exports.fbPixel = exports.permutive = exports.ias = void 0;
28
28
  var ias_1 = require("./third-party-tags/ias");
29
29
  Object.defineProperty(exports, "ias", { enumerable: true, get: function () { return ias_1.ias; } });
30
30
  var permutive_1 = require("./third-party-tags/permutive");
@@ -60,6 +60,8 @@ Object.defineProperty(exports, "initTrackGpcSignal", { enumerable: true, get: fu
60
60
  var ad_targeting_youtube_1 = require("./ad-targeting-youtube");
61
61
  Object.defineProperty(exports, "buildAdsConfigWithConsent", { enumerable: true, get: function () { return ad_targeting_youtube_1.buildAdsConfigWithConsent; } });
62
62
  Object.defineProperty(exports, "disabledAds", { enumerable: true, get: function () { return ad_targeting_youtube_1.disabledAds; } });
63
+ var create_ad_slot_1 = require("./create-ad-slot");
64
+ Object.defineProperty(exports, "createAdSlot", { enumerable: true, get: function () { return create_ad_slot_1.createAdSlot; } });
63
65
  exports.constants = __importStar(require("./constants"));
64
66
  var content_1 = require("./targeting/content");
65
67
  Object.defineProperty(exports, "getContentTargeting", { enumerable: true, get: function () { return content_1.getContentTargeting; } });
@@ -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)();
@@ -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>;
@@ -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 { adSizes } from './ad-sizes';
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: commonSizeMappings,
28
+ sizeMappings: slotSizeMappings['inline'],
82
29
  },
83
30
  mostpop: {
84
- sizeMappings: commonSizeMappings,
31
+ sizeMappings: slotSizeMappings['mostpop'],
85
32
  },
86
33
  comments: {
87
- sizeMappings: commonSizeMappings,
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
  /**
@@ -14,6 +14,7 @@ export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments,
14
14
  export { initTrackScrollDepth } from './track-scroll-depth';
15
15
  export { initTrackGpcSignal } from './track-gpc-signal';
16
16
  export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
17
+ export { createAdSlot } from './create-ad-slot';
17
18
  export type { AdsConfig, AdsConfigBasic, AdsConfigDisabled, AdTargetingBuilder, CustomParams, } from './types';
18
19
  export * as constants from './constants';
19
20
  export type { ContentTargeting } from './targeting/content';
package/dist/esm/index.js CHANGED
@@ -13,6 +13,7 @@ export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments,
13
13
  export { initTrackScrollDepth } from './track-scroll-depth';
14
14
  export { initTrackGpcSignal } from './track-gpc-signal';
15
15
  export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
16
+ export { createAdSlot } from './create-ad-slot';
16
17
  import * as constants_1 from './constants';
17
18
  export { constants_1 as constants };
18
19
  export { getContentTargeting } from './targeting/content';
@@ -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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/commercial-core",
3
- "version": "4.1.0",
3
+ "version": "4.2.1",
4
4
  "description": "Guardian advertising business logic",
5
5
  "homepage": "https://github.com/guardian/commercial-core#readme",
6
6
  "bugs": {