@guardian/commercial-core 3.2.0 → 3.4.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 +23 -5
- package/dist/cjs/ad-sizes.js +118 -4
- package/dist/cjs/constants/index.d.ts +2 -2
- package/dist/cjs/constants/index.js +4 -4
- package/dist/cjs/constants/{prebidTimeout.d.ts → prebid-timeout.d.ts} +0 -0
- package/dist/cjs/constants/{prebidTimeout.js → prebid-timeout.js} +0 -0
- package/dist/cjs/constants/{topAboveNavHeight.d.ts → top-above-nav-height.d.ts} +0 -0
- package/dist/cjs/constants/{topAboveNavHeight.js → top-above-nav-height.js} +0 -0
- package/dist/cjs/{detectAdBlocker.d.ts → detect-ad-blocker.d.ts} +2 -1
- package/dist/cjs/{detectAdBlocker.js → detect-ad-blocker.js} +2 -1
- package/dist/cjs/{EventTimer.d.ts → event-timer.d.ts} +0 -0
- package/dist/cjs/{EventTimer.js → event-timer.js} +2 -2
- package/dist/cjs/{GoogleAnalytics.d.ts → google-analytics.d.ts} +0 -0
- package/dist/cjs/{GoogleAnalytics.js → google-analytics.js} +0 -0
- package/dist/cjs/index.d.ts +4 -4
- package/dist/cjs/index.js +9 -8
- package/dist/cjs/permutive.d.ts +4 -3
- package/dist/cjs/permutive.js +1 -1
- package/dist/{esm/sendCommercialMetrics.d.ts → cjs/send-commercial-metrics.d.ts} +3 -3
- package/dist/cjs/{sendCommercialMetrics.js → send-commercial-metrics.js} +33 -16
- package/dist/cjs/targeting/content.d.ts +4 -3
- package/dist/cjs/targeting/personalised.d.ts +2 -1
- package/dist/cjs/targeting/session.d.ts +5 -4
- package/dist/cjs/targeting/shared.d.ts +8 -5
- package/dist/cjs/targeting/shared.js +1 -1
- package/dist/cjs/targeting/viewport.d.ts +4 -3
- package/dist/cjs/track-scroll-depth.js +2 -2
- package/dist/cjs/types.d.ts +3 -4
- package/dist/esm/ad-sizes.d.ts +23 -5
- package/dist/esm/ad-sizes.js +116 -3
- package/dist/esm/constants/index.d.ts +2 -2
- package/dist/esm/constants/index.js +2 -2
- package/dist/esm/constants/{prebidTimeout.d.ts → prebid-timeout.d.ts} +0 -0
- package/dist/esm/constants/{prebidTimeout.js → prebid-timeout.js} +0 -0
- package/dist/esm/constants/{topAboveNavHeight.d.ts → top-above-nav-height.d.ts} +0 -0
- package/dist/esm/constants/{topAboveNavHeight.js → top-above-nav-height.js} +0 -0
- package/dist/esm/{detectAdBlocker.d.ts → detect-ad-blocker.d.ts} +2 -1
- package/dist/esm/{detectAdBlocker.js → detect-ad-blocker.js} +2 -1
- package/dist/esm/{EventTimer.d.ts → event-timer.d.ts} +0 -0
- package/dist/esm/{EventTimer.js → event-timer.js} +1 -1
- package/dist/esm/{GoogleAnalytics.d.ts → google-analytics.d.ts} +0 -0
- package/dist/esm/{GoogleAnalytics.js → google-analytics.js} +0 -0
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +4 -4
- package/dist/esm/permutive.d.ts +4 -3
- package/dist/esm/permutive.js +4 -3
- package/dist/{cjs/sendCommercialMetrics.d.ts → esm/send-commercial-metrics.d.ts} +3 -3
- package/dist/esm/{sendCommercialMetrics.js → send-commercial-metrics.js} +32 -14
- package/dist/esm/targeting/content.d.ts +4 -3
- package/dist/esm/targeting/content.js +2 -1
- package/dist/esm/targeting/personalised.d.ts +2 -1
- package/dist/esm/targeting/session.d.ts +5 -4
- package/dist/esm/targeting/session.js +2 -1
- package/dist/esm/targeting/shared.d.ts +8 -5
- package/dist/esm/targeting/shared.js +2 -1
- package/dist/esm/targeting/viewport.d.ts +4 -3
- package/dist/esm/targeting/viewport.js +2 -1
- package/dist/esm/track-scroll-depth.js +1 -1
- package/dist/esm/types.d.ts +3 -4
- package/package.json +2 -2
package/dist/cjs/ad-sizes.d.ts
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare type AdSizeString = 'fluid' | `${number},${number}`;
|
|
2
|
+
declare type AdSize = Readonly<{
|
|
3
3
|
width: number;
|
|
4
4
|
height: number;
|
|
5
5
|
toString: () => AdSizeString;
|
|
6
6
|
}>;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
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';
|
|
8
|
+
interface SizeMapping {
|
|
9
|
+
mobile?: AdSize[];
|
|
10
|
+
desktop?: AdSize[];
|
|
11
|
+
phablet?: AdSize[];
|
|
12
|
+
tablet?: AdSize[];
|
|
13
|
+
}
|
|
14
|
+
interface SizeMappings {
|
|
15
|
+
right: SizeMapping;
|
|
16
|
+
comments: SizeMapping;
|
|
17
|
+
'top-above-nav': SizeMapping;
|
|
18
|
+
mostpop: SizeMapping;
|
|
19
|
+
'merchandising-high': SizeMapping;
|
|
20
|
+
merchandising: SizeMapping;
|
|
21
|
+
survey: SizeMapping;
|
|
22
|
+
}
|
|
23
|
+
declare const adSizes: Record<SizeKeys, AdSize>;
|
|
24
|
+
declare const sizeMappings: SizeMappings;
|
|
25
|
+
declare const getAdSize: (size: SizeKeys) => AdSize;
|
|
10
26
|
export declare const _: {
|
|
11
27
|
createAdSize: (width: number, height: number) => AdSize;
|
|
12
28
|
};
|
|
29
|
+
export type { AdSizeString, AdSize, SizeKeys };
|
|
30
|
+
export { adSizes, getAdSize, sizeMappings };
|
package/dist/cjs/ad-sizes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.sizeMappings = exports.getAdSize = exports.adSizes = exports._ = void 0;
|
|
4
4
|
const createAdSize = (width, height) => {
|
|
5
5
|
const toString = () => width === 0 && height === 0 ? 'fluid' : `${width},${height}`;
|
|
6
6
|
return Object.freeze({
|
|
@@ -32,9 +32,8 @@ const adSizesPartial = {
|
|
|
32
32
|
outstreamDesktop: createAdSize(620, 350),
|
|
33
33
|
outstreamGoogleDesktop: createAdSize(550, 310),
|
|
34
34
|
outstreamMobile: createAdSize(300, 197),
|
|
35
|
-
video: createAdSize(620, 1),
|
|
36
35
|
};
|
|
37
|
-
|
|
36
|
+
const adSizes = {
|
|
38
37
|
...adSizesPartial,
|
|
39
38
|
'970x250': adSizesPartial.billboard,
|
|
40
39
|
'728x90': adSizesPartial.leaderboard,
|
|
@@ -43,7 +42,122 @@ exports.adSizes = {
|
|
|
43
42
|
'300x1050': adSizesPartial.portrait,
|
|
44
43
|
'160x600': adSizesPartial.skyscraper,
|
|
45
44
|
};
|
|
46
|
-
|
|
45
|
+
exports.adSizes = adSizes;
|
|
46
|
+
const sizeMappings = {
|
|
47
|
+
right: {
|
|
48
|
+
mobile: [
|
|
49
|
+
adSizes.outOfPage,
|
|
50
|
+
adSizes.empty,
|
|
51
|
+
adSizes.mpu,
|
|
52
|
+
adSizes.googleCard,
|
|
53
|
+
adSizes.halfPage,
|
|
54
|
+
adSizes.fluid,
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
comments: {
|
|
58
|
+
mobile: [
|
|
59
|
+
adSizes.outOfPage,
|
|
60
|
+
adSizes.empty,
|
|
61
|
+
adSizes.halfPage,
|
|
62
|
+
adSizes.outstreamMobile,
|
|
63
|
+
adSizes.mpu,
|
|
64
|
+
adSizes.googleCard,
|
|
65
|
+
adSizes.fluid,
|
|
66
|
+
],
|
|
67
|
+
desktop: [
|
|
68
|
+
adSizes.outOfPage,
|
|
69
|
+
adSizes.empty,
|
|
70
|
+
adSizes.mpu,
|
|
71
|
+
adSizes.googleCard,
|
|
72
|
+
adSizes.fluid,
|
|
73
|
+
adSizes.halfPage,
|
|
74
|
+
adSizes.skyscraper,
|
|
75
|
+
],
|
|
76
|
+
phablet: [
|
|
77
|
+
adSizes.outOfPage,
|
|
78
|
+
adSizes.empty,
|
|
79
|
+
adSizes.outstreamMobile,
|
|
80
|
+
adSizes.mpu,
|
|
81
|
+
adSizes.googleCard,
|
|
82
|
+
adSizes.fluid,
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
'top-above-nav': {
|
|
86
|
+
tablet: [
|
|
87
|
+
adSizes.outOfPage,
|
|
88
|
+
adSizes.empty,
|
|
89
|
+
adSizes.fabric,
|
|
90
|
+
adSizes.fluid,
|
|
91
|
+
adSizes.leaderboard,
|
|
92
|
+
],
|
|
93
|
+
desktop: [
|
|
94
|
+
adSizes.outOfPage,
|
|
95
|
+
adSizes.empty,
|
|
96
|
+
adSizes.leaderboard,
|
|
97
|
+
createAdSize(940, 230),
|
|
98
|
+
createAdSize(900, 250),
|
|
99
|
+
adSizes.billboard,
|
|
100
|
+
adSizes.fabric,
|
|
101
|
+
adSizes.fluid,
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
mostpop: {
|
|
105
|
+
mobile: [
|
|
106
|
+
adSizes.outOfPage,
|
|
107
|
+
adSizes.empty,
|
|
108
|
+
adSizes.mpu,
|
|
109
|
+
adSizes.googleCard,
|
|
110
|
+
adSizes.fluid,
|
|
111
|
+
],
|
|
112
|
+
tablet: [
|
|
113
|
+
adSizes.outOfPage,
|
|
114
|
+
adSizes.empty,
|
|
115
|
+
adSizes.mpu,
|
|
116
|
+
adSizes.googleCard,
|
|
117
|
+
adSizes.halfPage,
|
|
118
|
+
adSizes.leaderboard,
|
|
119
|
+
adSizes.fluid,
|
|
120
|
+
],
|
|
121
|
+
phablet: [
|
|
122
|
+
adSizes.outOfPage,
|
|
123
|
+
adSizes.empty,
|
|
124
|
+
adSizes.outstreamMobile,
|
|
125
|
+
adSizes.mpu,
|
|
126
|
+
adSizes.googleCard,
|
|
127
|
+
adSizes.halfPage,
|
|
128
|
+
adSizes.fluid,
|
|
129
|
+
],
|
|
130
|
+
desktop: [
|
|
131
|
+
adSizes.outOfPage,
|
|
132
|
+
adSizes.empty,
|
|
133
|
+
adSizes.mpu,
|
|
134
|
+
adSizes.googleCard,
|
|
135
|
+
adSizes.halfPage,
|
|
136
|
+
adSizes.fluid,
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
'merchandising-high': {
|
|
140
|
+
mobile: [
|
|
141
|
+
adSizes.outOfPage,
|
|
142
|
+
adSizes.empty,
|
|
143
|
+
adSizes.merchandisingHigh,
|
|
144
|
+
adSizes.fluid,
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
merchandising: {
|
|
148
|
+
mobile: [
|
|
149
|
+
adSizes.outOfPage,
|
|
150
|
+
adSizes.empty,
|
|
151
|
+
adSizes.merchandising,
|
|
152
|
+
adSizes.fluid,
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
survey: {
|
|
156
|
+
desktop: [adSizes.outOfPage],
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
exports.sizeMappings = sizeMappings;
|
|
160
|
+
const getAdSize = (size) => adSizes[size];
|
|
47
161
|
exports.getAdSize = getAdSize;
|
|
48
162
|
// Export for testing
|
|
49
163
|
exports._ = { createAdSize };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { PREBID_TIMEOUT } from './
|
|
2
|
-
export { TOP_ABOVE_NAV_HEIGHT } from './
|
|
1
|
+
export { PREBID_TIMEOUT } from './prebid-timeout';
|
|
2
|
+
export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TOP_ABOVE_NAV_HEIGHT = exports.PREBID_TIMEOUT = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "PREBID_TIMEOUT", { enumerable: true, get: function () { return
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "TOP_ABOVE_NAV_HEIGHT", { enumerable: true, get: function () { return
|
|
4
|
+
var prebid_timeout_1 = require("./prebid-timeout");
|
|
5
|
+
Object.defineProperty(exports, "PREBID_TIMEOUT", { enumerable: true, get: function () { return prebid_timeout_1.PREBID_TIMEOUT; } });
|
|
6
|
+
var top_above_nav_height_1 = require("./top-above-nav-height");
|
|
7
|
+
Object.defineProperty(exports, "TOP_ABOVE_NAV_HEIGHT", { enumerable: true, get: function () { return top_above_nav_height_1.TOP_ABOVE_NAV_HEIGHT; } });
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
Detect whether or not the user has an ad blocking extension enabled.
|
|
3
3
|
A few ad blockers are not detectable with this approach e.g. Safari / Adblock
|
|
4
|
-
Code inspired by just-detect-adblock's:
|
|
4
|
+
Code inspired by just-detect-adblock's:
|
|
5
|
+
https://github.com/wmcmurray/just-detect-adblock/blob/master/src/helpers.js
|
|
5
6
|
*/
|
|
6
7
|
/**
|
|
7
8
|
* Determines whether or not the user has an ad blocking extension enabled.
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
Detect whether or not the user has an ad blocking extension enabled.
|
|
4
4
|
A few ad blockers are not detectable with this approach e.g. Safari / Adblock
|
|
5
|
-
Code inspired by just-detect-adblock's:
|
|
5
|
+
Code inspired by just-detect-adblock's:
|
|
6
|
+
https://github.com/wmcmurray/just-detect-adblock/blob/master/src/helpers.js
|
|
6
7
|
*/
|
|
7
8
|
/*istanbul ignore file -- adElementBlocked can't be tested without patching each of the properties of
|
|
8
9
|
HTMLElement.prototype that it accesses, defeating the purpose of the test! */
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EventTimer = void 0;
|
|
4
|
-
const
|
|
4
|
+
const google_analytics_1 = require("./google-analytics");
|
|
5
5
|
class Event {
|
|
6
6
|
constructor(name, mark) {
|
|
7
7
|
this.name = name;
|
|
@@ -165,7 +165,7 @@ class EventTimer {
|
|
|
165
165
|
const gaEvent = this.gaConfig.logEvents.find((e) => e.timingVariable === eventName);
|
|
166
166
|
if (gaEvent) {
|
|
167
167
|
const labelToUse = gaEvent.timingLabel ?? label;
|
|
168
|
-
(0,
|
|
168
|
+
(0, google_analytics_1.trackEvent)('Commercial Events', gaEvent.timingVariable, labelToUse);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
}
|
|
File without changes
|
|
File without changes
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ export { fbPixel } from './third-party-tags/facebook-pixel';
|
|
|
4
4
|
export { twitter } from './third-party-tags/twitter-uwt';
|
|
5
5
|
export { inizio } from './third-party-tags/inizio';
|
|
6
6
|
export { remarketing } from './third-party-tags/remarketing';
|
|
7
|
-
export { EventTimer } from './
|
|
8
|
-
export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './
|
|
7
|
+
export { EventTimer } from './event-timer';
|
|
8
|
+
export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics';
|
|
9
9
|
export type { ThirdPartyTag } from './types';
|
|
10
|
-
export { adSizes, getAdSize } from './ad-sizes';
|
|
10
|
+
export { adSizes, getAdSize, sizeMappings } from './ad-sizes';
|
|
11
11
|
export type { SizeKeys, AdSizeString, AdSize } from './ad-sizes';
|
|
12
|
-
export { isAdBlockInUse } from './
|
|
12
|
+
export { isAdBlockInUse } from './detect-ad-blocker';
|
|
13
13
|
export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments, } from './permutive';
|
|
14
14
|
export { initTrackScrollDepth } from './track-scroll-depth';
|
|
15
15
|
export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
|
package/dist/cjs/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
20
20
|
return result;
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.pickTargetingValues = exports.getViewportTargeting = exports.getSharedTargeting = exports.getSessionTargeting = exports.getPersonalisedTargeting = exports.getContentTargeting = exports.constants = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.initTrackScrollDepth = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.getAdSize = exports.adSizes = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports.EventTimer = exports.remarketing = exports.inizio = exports.twitter = exports.fbPixel = exports.permutive = exports.ias = void 0;
|
|
23
|
+
exports.pickTargetingValues = exports.getViewportTargeting = exports.getSharedTargeting = exports.getSessionTargeting = exports.getPersonalisedTargeting = exports.getContentTargeting = exports.constants = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.initTrackScrollDepth = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.sizeMappings = exports.getAdSize = exports.adSizes = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports.EventTimer = exports.remarketing = exports.inizio = exports.twitter = exports.fbPixel = exports.permutive = exports.ias = void 0;
|
|
24
24
|
var ias_1 = require("./third-party-tags/ias");
|
|
25
25
|
Object.defineProperty(exports, "ias", { enumerable: true, get: function () { return ias_1.ias; } });
|
|
26
26
|
var permutive_1 = require("./third-party-tags/permutive");
|
|
@@ -33,16 +33,17 @@ var inizio_1 = require("./third-party-tags/inizio");
|
|
|
33
33
|
Object.defineProperty(exports, "inizio", { enumerable: true, get: function () { return inizio_1.inizio; } });
|
|
34
34
|
var remarketing_1 = require("./third-party-tags/remarketing");
|
|
35
35
|
Object.defineProperty(exports, "remarketing", { enumerable: true, get: function () { return remarketing_1.remarketing; } });
|
|
36
|
-
var
|
|
37
|
-
Object.defineProperty(exports, "EventTimer", { enumerable: true, get: function () { return
|
|
38
|
-
var
|
|
39
|
-
Object.defineProperty(exports, "bypassCommercialMetricsSampling", { enumerable: true, get: function () { return
|
|
40
|
-
Object.defineProperty(exports, "initCommercialMetrics", { enumerable: true, get: function () { return
|
|
36
|
+
var event_timer_1 = require("./event-timer");
|
|
37
|
+
Object.defineProperty(exports, "EventTimer", { enumerable: true, get: function () { return event_timer_1.EventTimer; } });
|
|
38
|
+
var send_commercial_metrics_1 = require("./send-commercial-metrics");
|
|
39
|
+
Object.defineProperty(exports, "bypassCommercialMetricsSampling", { enumerable: true, get: function () { return send_commercial_metrics_1.bypassCommercialMetricsSampling; } });
|
|
40
|
+
Object.defineProperty(exports, "initCommercialMetrics", { enumerable: true, get: function () { return send_commercial_metrics_1.initCommercialMetrics; } });
|
|
41
41
|
var ad_sizes_1 = require("./ad-sizes");
|
|
42
42
|
Object.defineProperty(exports, "adSizes", { enumerable: true, get: function () { return ad_sizes_1.adSizes; } });
|
|
43
43
|
Object.defineProperty(exports, "getAdSize", { enumerable: true, get: function () { return ad_sizes_1.getAdSize; } });
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
Object.defineProperty(exports, "sizeMappings", { enumerable: true, get: function () { return ad_sizes_1.sizeMappings; } });
|
|
45
|
+
var detect_ad_blocker_1 = require("./detect-ad-blocker");
|
|
46
|
+
Object.defineProperty(exports, "isAdBlockInUse", { enumerable: true, get: function () { return detect_ad_blocker_1.isAdBlockInUse; } });
|
|
46
47
|
var permutive_2 = require("./permutive");
|
|
47
48
|
Object.defineProperty(exports, "clearPermutiveSegments", { enumerable: true, get: function () { return permutive_2.clearPermutiveSegments; } });
|
|
48
49
|
Object.defineProperty(exports, "getPermutiveSegments", { enumerable: true, get: function () { return permutive_2.getPermutiveSegments; } });
|
package/dist/cjs/permutive.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare const getPermutiveSegments: () => string[];
|
|
2
|
+
declare const getPermutivePFPSegments: () => string[];
|
|
3
|
+
declare const clearPermutiveSegments: () => void;
|
|
4
4
|
export declare const _: {
|
|
5
5
|
PERMUTIVE_KEY: string;
|
|
6
6
|
PERMUTIVE_PFP_KEY: string;
|
|
7
7
|
getSegments: (key: string) => string[];
|
|
8
8
|
};
|
|
9
|
+
export { getPermutiveSegments, getPermutivePFPSegments, clearPermutiveSegments, };
|
package/dist/cjs/permutive.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.clearPermutiveSegments = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports._ = void 0;
|
|
4
4
|
const libs_1 = require("@guardian/libs");
|
|
5
5
|
const PERMUTIVE_KEY = `_papns`;
|
|
6
6
|
const PERMUTIVE_PFP_KEY = `_pdfps`;
|
|
@@ -22,7 +22,7 @@ declare enum Endpoints {
|
|
|
22
22
|
/**
|
|
23
23
|
* A method to asynchronously send metrics after initialization.
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
declare function bypassCommercialMetricsSampling(): Promise<void>;
|
|
26
26
|
interface InitCommercialMetricsArgs {
|
|
27
27
|
pageViewId: string;
|
|
28
28
|
browserId: string | undefined;
|
|
@@ -38,14 +38,14 @@ interface InitCommercialMetricsArgs {
|
|
|
38
38
|
* @param init.adBlockerInUse - indicates whether or not an adblocker is being used.
|
|
39
39
|
* @param init.sampling - rate at which to sample commercial metrics - the default is to send for 1% of pageviews
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
declare function initCommercialMetrics({ pageViewId, browserId, isDev, adBlockerInUse, sampling, }: InitCommercialMetricsArgs): Promise<boolean>;
|
|
42
42
|
export declare const _: {
|
|
43
43
|
Endpoints: typeof Endpoints;
|
|
44
44
|
setEndpoint: (isDev: boolean) => Endpoints;
|
|
45
|
-
filterUndefinedProperties: <T>(transformedProperties: [string, T | undefined][]) => [string, T][];
|
|
46
45
|
mapEventTimerPropertiesToString: (properties: Array<[string, string | number]>) => Property[];
|
|
47
46
|
roundTimeStamp: (events: TimedEvent[]) => Metric[];
|
|
48
47
|
transformToObjectEntries: (eventTimerProperties: EventProperties) => Array<[string, string | number | undefined]>;
|
|
49
48
|
reset: () => void;
|
|
50
49
|
};
|
|
51
50
|
export type { Property, TimedEvent, Metric };
|
|
51
|
+
export { bypassCommercialMetricsSampling, initCommercialMetrics };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports._ = void 0;
|
|
4
|
+
const consent_management_platform_1 = require("@guardian/consent-management-platform");
|
|
4
5
|
const libs_1 = require("@guardian/libs");
|
|
5
|
-
const
|
|
6
|
+
const event_timer_1 = require("./event-timer");
|
|
6
7
|
var Endpoints;
|
|
7
8
|
(function (Endpoints) {
|
|
8
9
|
Endpoints["CODE"] = "//performance-events.code.dev-guardianapis.com/commercial-metrics";
|
|
@@ -38,12 +39,6 @@ const transformToObjectEntries = (eventTimerProperties) => {
|
|
|
38
39
|
// Transforms object {key: value} pairs into an array of [key, value] arrays
|
|
39
40
|
return Object.entries(eventTimerProperties);
|
|
40
41
|
};
|
|
41
|
-
const filterUndefinedProperties = (transformedProperties) => transformedProperties.reduce((acc, [key, value]) => {
|
|
42
|
-
if (typeof value !== 'undefined') {
|
|
43
|
-
acc.push([key, value]);
|
|
44
|
-
}
|
|
45
|
-
return acc;
|
|
46
|
-
}, []);
|
|
47
42
|
const mapEventTimerPropertiesToString = (properties) => {
|
|
48
43
|
return properties.map(([name, value]) => ({
|
|
49
44
|
name: String(name),
|
|
@@ -62,9 +57,9 @@ function sendMetrics() {
|
|
|
62
57
|
}
|
|
63
58
|
function gatherMetricsOnPageUnload() {
|
|
64
59
|
// Assemble commercial properties and metrics
|
|
65
|
-
const eventTimer =
|
|
60
|
+
const eventTimer = event_timer_1.EventTimer.get();
|
|
66
61
|
const transformedEntries = transformToObjectEntries(eventTimer.properties);
|
|
67
|
-
const filteredEventTimerProperties =
|
|
62
|
+
const filteredEventTimerProperties = transformedEntries.filter((item) => typeof item[1] !== 'undefined');
|
|
68
63
|
const mappedEventTimerProperties = mapEventTimerPropertiesToString(filteredEventTimerProperties);
|
|
69
64
|
const properties = mappedEventTimerProperties
|
|
70
65
|
.concat(devProperties)
|
|
@@ -92,15 +87,32 @@ const addVisibilityListeners = () => {
|
|
|
92
87
|
// Safari does not reliably fire the `visibilitychange` on page unload.
|
|
93
88
|
window.addEventListener('pagehide', listener);
|
|
94
89
|
};
|
|
90
|
+
const checkConsent = async () => {
|
|
91
|
+
const consentState = await (0, consent_management_platform_1.onConsent)();
|
|
92
|
+
if (consentState.tcfv2) {
|
|
93
|
+
// TCFv2 mode - check for consent
|
|
94
|
+
const consents = consentState.tcfv2.consents;
|
|
95
|
+
const REQUIRED_CONSENTS = [7, 8];
|
|
96
|
+
return REQUIRED_CONSENTS.every((consent) => consents[consent]);
|
|
97
|
+
}
|
|
98
|
+
// non-TCFv2 mode - don't check for consent
|
|
99
|
+
return true;
|
|
100
|
+
};
|
|
95
101
|
/**
|
|
96
102
|
* A method to asynchronously send metrics after initialization.
|
|
97
103
|
*/
|
|
98
|
-
function bypassCommercialMetricsSampling() {
|
|
104
|
+
async function bypassCommercialMetricsSampling() {
|
|
99
105
|
if (!initialised) {
|
|
100
106
|
console.warn('initCommercialMetrics not yet initialised');
|
|
101
107
|
return;
|
|
102
108
|
}
|
|
103
|
-
|
|
109
|
+
const consented = await checkConsent();
|
|
110
|
+
if (consented) {
|
|
111
|
+
addVisibilityListeners();
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
(0, libs_1.log)('commercial', "Metrics won't be sent because consent wasn't given");
|
|
115
|
+
}
|
|
104
116
|
}
|
|
105
117
|
exports.bypassCommercialMetricsSampling = bypassCommercialMetricsSampling;
|
|
106
118
|
/**
|
|
@@ -111,7 +123,7 @@ exports.bypassCommercialMetricsSampling = bypassCommercialMetricsSampling;
|
|
|
111
123
|
* @param init.adBlockerInUse - indicates whether or not an adblocker is being used.
|
|
112
124
|
* @param init.sampling - rate at which to sample commercial metrics - the default is to send for 1% of pageviews
|
|
113
125
|
*/
|
|
114
|
-
function initCommercialMetrics({ pageViewId, browserId, isDev, adBlockerInUse, sampling = 1 / 100, }) {
|
|
126
|
+
async function initCommercialMetrics({ pageViewId, browserId, isDev, adBlockerInUse, sampling = 1 / 100, }) {
|
|
115
127
|
commercialMetricsPayload.page_view_id = pageViewId;
|
|
116
128
|
commercialMetricsPayload.browser_id = browserId;
|
|
117
129
|
setEndpoint(isDev);
|
|
@@ -123,8 +135,14 @@ function initCommercialMetrics({ pageViewId, browserId, isDev, adBlockerInUse, s
|
|
|
123
135
|
initialised = true;
|
|
124
136
|
const userIsInSamplingGroup = Math.random() <= sampling;
|
|
125
137
|
if (isDev || userIsInSamplingGroup) {
|
|
126
|
-
|
|
127
|
-
|
|
138
|
+
const consented = await checkConsent();
|
|
139
|
+
if (consented) {
|
|
140
|
+
addVisibilityListeners();
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
(0, libs_1.log)('commercial', "Metrics won't be sent because consent wasn't given");
|
|
145
|
+
}
|
|
128
146
|
}
|
|
129
147
|
return false;
|
|
130
148
|
}
|
|
@@ -132,7 +150,6 @@ exports.initCommercialMetrics = initCommercialMetrics;
|
|
|
132
150
|
exports._ = {
|
|
133
151
|
Endpoints,
|
|
134
152
|
setEndpoint,
|
|
135
|
-
filterUndefinedProperties,
|
|
136
153
|
mapEventTimerPropertiesToString,
|
|
137
154
|
roundTimeStamp,
|
|
138
155
|
transformToObjectEntries,
|
|
@@ -12,7 +12,7 @@ declare const videoLengths: readonly ["25", "30", "60", "90", "120", "150", "180
|
|
|
12
12
|
* - a surge in page views per minute
|
|
13
13
|
*
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
declare type ContentTargeting = {
|
|
16
16
|
/**
|
|
17
17
|
* **D**ot**c**om-**r**endering **E**ligible - [see on Ad Manager][gam]
|
|
18
18
|
*
|
|
@@ -66,5 +66,6 @@ declare type Content = {
|
|
|
66
66
|
sensitive: boolean;
|
|
67
67
|
videoLength?: number;
|
|
68
68
|
};
|
|
69
|
-
|
|
70
|
-
export {};
|
|
69
|
+
declare const getContentTargeting: ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, }: Content) => ContentTargeting;
|
|
70
|
+
export { getContentTargeting };
|
|
71
|
+
export type { ContentTargeting };
|
|
@@ -10,7 +10,7 @@ declare type AdManagerGroup = typeof adManagerGroups[number];
|
|
|
10
10
|
* It allows or prevents personalised advertising, restrict data processing
|
|
11
11
|
* and handles access to cookies and local storage
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
declare type PersonalisedTargeting = {
|
|
14
14
|
/**
|
|
15
15
|
* **A**d **M**anager **T**argeting **Gr**ou**p** – [see on Ad Manager][gam]
|
|
16
16
|
*
|
|
@@ -76,3 +76,4 @@ export declare type PersonalisedTargeting = {
|
|
|
76
76
|
};
|
|
77
77
|
declare const getPersonalisedTargeting: (state: ConsentState) => PersonalisedTargeting;
|
|
78
78
|
export { getPersonalisedTargeting };
|
|
79
|
+
export type { PersonalisedTargeting };
|
|
@@ -22,7 +22,7 @@ declare const referrers: readonly [{
|
|
|
22
22
|
* These values identify a browser session are either generated client-side,
|
|
23
23
|
* read from a cookie or passed down from the server.
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
declare type SessionTargeting = {
|
|
26
26
|
/**
|
|
27
27
|
* **AB** Tests – [see on Ad Manager][gam]
|
|
28
28
|
*
|
|
@@ -90,7 +90,7 @@ export declare type SessionTargeting = {
|
|
|
90
90
|
*/
|
|
91
91
|
si: True | False;
|
|
92
92
|
};
|
|
93
|
-
|
|
93
|
+
declare type AllParticipations = {
|
|
94
94
|
clientSideParticipations: Participations;
|
|
95
95
|
serverSideParticipations: {
|
|
96
96
|
[key: `${string}Control`]: 'control';
|
|
@@ -105,5 +105,6 @@ declare type Session = {
|
|
|
105
105
|
participations: AllParticipations;
|
|
106
106
|
referrer: string;
|
|
107
107
|
};
|
|
108
|
-
|
|
109
|
-
export {};
|
|
108
|
+
declare const getSessionTargeting: ({ adTest, countryCode, isSignedIn, pageViewId, participations, referrer, }: Session) => SessionTargeting;
|
|
109
|
+
export type { SessionTargeting, AllParticipations };
|
|
110
|
+
export { getSessionTargeting };
|
|
@@ -25,14 +25,16 @@ declare const surges: {
|
|
|
25
25
|
readonly 400: "1";
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
|
-
* Shared Targeting is passed by `frontend
|
|
28
|
+
* Shared Targeting is passed by `frontend`:
|
|
29
|
+
* https://github.com/guardian/frontend/blob/5b970cd7308175cfc1bcae2d4fb8c06ee13c5fa0/common/app/common/commercial/EditionAdTargeting.scala
|
|
29
30
|
*
|
|
30
|
-
* It is generated in `commercial-shared
|
|
31
|
+
* It is generated in `commercial-shared`:
|
|
32
|
+
* https://github.com/guardian/commercial-shared/blob/a692e8b2eba6e79eeeb666e5594f2193663f6514/src/main/scala/com/gu/commercial/display/AdTargetParam.scala
|
|
31
33
|
*
|
|
32
34
|
*
|
|
33
35
|
*
|
|
34
36
|
*/
|
|
35
|
-
|
|
37
|
+
declare type SharedTargeting = {
|
|
36
38
|
/**
|
|
37
39
|
* **Bl**og tags – [see on Ad Manager][gam]
|
|
38
40
|
*
|
|
@@ -135,8 +137,9 @@ export declare type SharedTargeting = {
|
|
|
135
137
|
/**
|
|
136
138
|
* What goes in comes out
|
|
137
139
|
*/
|
|
138
|
-
|
|
140
|
+
declare const getSharedTargeting: (shared: Partial<SharedTargeting>) => Partial<SharedTargeting>;
|
|
139
141
|
export declare const _: {
|
|
140
142
|
getSurgingParam: (surging: number) => SharedTargeting['su'];
|
|
141
143
|
};
|
|
142
|
-
export {};
|
|
144
|
+
export type { SharedTargeting };
|
|
145
|
+
export { getSharedTargeting };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getSharedTargeting = exports._ = void 0;
|
|
4
4
|
const pick_targeting_values_1 = require("./pick-targeting-values");
|
|
5
5
|
/* -- Types -- */
|
|
6
6
|
const brands = {
|
|
@@ -7,7 +7,7 @@ import type { False, True } from '../types';
|
|
|
7
7
|
* - whether a CMP banner will show
|
|
8
8
|
* - size of page skin
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
declare type ViewportTargeting = {
|
|
11
11
|
/**
|
|
12
12
|
* **B**reak**p**oint – [see on Ad Manager][gam]
|
|
13
13
|
*
|
|
@@ -43,5 +43,6 @@ declare type Viewport = {
|
|
|
43
43
|
viewPortWidth: number;
|
|
44
44
|
cmpBannerWillShow: boolean;
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
export {};
|
|
46
|
+
declare const getViewportTargeting: ({ viewPortWidth, cmpBannerWillShow, }: Viewport) => ViewportTargeting;
|
|
47
|
+
export type { ViewportTargeting };
|
|
48
|
+
export { getViewportTargeting };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initTrackScrollDepth = void 0;
|
|
4
4
|
const libs_1 = require("@guardian/libs");
|
|
5
|
-
const
|
|
5
|
+
const event_timer_1 = require("./event-timer");
|
|
6
6
|
/**
|
|
7
7
|
* Collect commercial metrics on scroll depth
|
|
8
8
|
* Insert hidden elements at intervals of 1 viewport height
|
|
@@ -14,7 +14,7 @@ const initTrackScrollDepth = () => {
|
|
|
14
14
|
const intViewportHeight = window.innerHeight;
|
|
15
15
|
// how many viewports tall is the page?
|
|
16
16
|
const pageHeightVH = Math.floor(pageHeight / intViewportHeight);
|
|
17
|
-
const eventTimer =
|
|
17
|
+
const eventTimer = event_timer_1.EventTimer.get();
|
|
18
18
|
eventTimer.setProperty('pageHeightVH', pageHeightVH);
|
|
19
19
|
const observer = new IntersectionObserver(
|
|
20
20
|
/* istanbul ignore next */
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -55,7 +55,6 @@ export declare type AdsConfigTCFV2 = AdsConfigBasic & {
|
|
|
55
55
|
export declare type AdsConfigEnabled = AdsConfigBasic | AdsConfigCCPAorAus | AdsConfigTCFV2;
|
|
56
56
|
export declare type AdsConfig = AdsConfigEnabled | AdsConfigDisabled;
|
|
57
57
|
export declare type AdTargetingBuilder = () => Promise<AdsConfig>;
|
|
58
|
-
declare type True = 't';
|
|
59
|
-
declare type False = 'f';
|
|
60
|
-
declare type NotApplicable = 'na';
|
|
61
|
-
export type { True, False, NotApplicable };
|
|
58
|
+
export declare type True = 't';
|
|
59
|
+
export declare type False = 'f';
|
|
60
|
+
export declare type NotApplicable = 'na';
|