@guardian/commercial-core 3.1.0 → 3.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.
Files changed (60) hide show
  1. package/dist/cjs/ad-sizes.d.ts +23 -5
  2. package/dist/cjs/ad-sizes.js +118 -4
  3. package/dist/cjs/constants/index.d.ts +2 -2
  4. package/dist/cjs/constants/index.js +4 -4
  5. package/dist/cjs/constants/{prebidTimeout.d.ts → prebid-timeout.d.ts} +0 -0
  6. package/dist/cjs/constants/{prebidTimeout.js → prebid-timeout.js} +0 -0
  7. package/dist/cjs/constants/{topAboveNavHeight.d.ts → top-above-nav-height.d.ts} +0 -0
  8. package/dist/cjs/constants/{topAboveNavHeight.js → top-above-nav-height.js} +0 -0
  9. package/dist/cjs/{detectAdBlocker.d.ts → detect-ad-blocker.d.ts} +2 -1
  10. package/dist/cjs/{detectAdBlocker.js → detect-ad-blocker.js} +2 -1
  11. package/dist/cjs/{EventTimer.d.ts → event-timer.d.ts} +2 -1
  12. package/dist/cjs/{EventTimer.js → event-timer.js} +2 -2
  13. package/dist/cjs/{GoogleAnalytics.d.ts → google-analytics.d.ts} +0 -0
  14. package/dist/cjs/{GoogleAnalytics.js → google-analytics.js} +0 -0
  15. package/dist/cjs/index.d.ts +4 -4
  16. package/dist/cjs/index.js +9 -8
  17. package/dist/cjs/permutive.d.ts +4 -3
  18. package/dist/cjs/permutive.js +1 -1
  19. package/dist/{esm/sendCommercialMetrics.d.ts → cjs/send-commercial-metrics.d.ts} +3 -2
  20. package/dist/cjs/{sendCommercialMetrics.js → send-commercial-metrics.js} +3 -3
  21. package/dist/cjs/targeting/content.d.ts +4 -3
  22. package/dist/cjs/targeting/personalised.d.ts +2 -1
  23. package/dist/cjs/targeting/session.d.ts +5 -4
  24. package/dist/cjs/targeting/shared.d.ts +8 -5
  25. package/dist/cjs/targeting/shared.js +1 -1
  26. package/dist/cjs/targeting/viewport.d.ts +4 -3
  27. package/dist/cjs/track-scroll-depth.js +2 -2
  28. package/dist/cjs/types.d.ts +3 -4
  29. package/dist/esm/ad-sizes.d.ts +23 -5
  30. package/dist/esm/ad-sizes.js +116 -3
  31. package/dist/esm/constants/index.d.ts +2 -2
  32. package/dist/esm/constants/index.js +2 -2
  33. package/dist/esm/constants/{prebidTimeout.d.ts → prebid-timeout.d.ts} +0 -0
  34. package/dist/esm/constants/{prebidTimeout.js → prebid-timeout.js} +0 -0
  35. package/dist/esm/constants/{topAboveNavHeight.d.ts → top-above-nav-height.d.ts} +0 -0
  36. package/dist/esm/constants/{topAboveNavHeight.js → top-above-nav-height.js} +0 -0
  37. package/dist/esm/{detectAdBlocker.d.ts → detect-ad-blocker.d.ts} +2 -1
  38. package/dist/esm/{detectAdBlocker.js → detect-ad-blocker.js} +2 -1
  39. package/dist/esm/{EventTimer.d.ts → event-timer.d.ts} +2 -1
  40. package/dist/esm/{EventTimer.js → event-timer.js} +1 -1
  41. package/dist/esm/{GoogleAnalytics.d.ts → google-analytics.d.ts} +0 -0
  42. package/dist/esm/{GoogleAnalytics.js → google-analytics.js} +0 -0
  43. package/dist/esm/index.d.ts +4 -4
  44. package/dist/esm/index.js +4 -4
  45. package/dist/esm/permutive.d.ts +4 -3
  46. package/dist/esm/permutive.js +4 -3
  47. package/dist/{cjs/sendCommercialMetrics.d.ts → esm/send-commercial-metrics.d.ts} +3 -2
  48. package/dist/esm/{sendCommercialMetrics.js → send-commercial-metrics.js} +4 -3
  49. package/dist/esm/targeting/content.d.ts +4 -3
  50. package/dist/esm/targeting/content.js +2 -1
  51. package/dist/esm/targeting/personalised.d.ts +2 -1
  52. package/dist/esm/targeting/session.d.ts +5 -4
  53. package/dist/esm/targeting/session.js +2 -1
  54. package/dist/esm/targeting/shared.d.ts +8 -5
  55. package/dist/esm/targeting/shared.js +2 -1
  56. package/dist/esm/targeting/viewport.d.ts +4 -3
  57. package/dist/esm/targeting/viewport.js +2 -1
  58. package/dist/esm/track-scroll-depth.js +1 -1
  59. package/dist/esm/types.d.ts +3 -4
  60. package/package.json +1 -1
@@ -1,12 +1,30 @@
1
- export declare type AdSizeString = 'fluid' | `${number},${number}`;
2
- export declare type AdSize = Readonly<{
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
- export 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' | 'video';
8
- export declare const adSizes: Record<SizeKeys, AdSize>;
9
- export declare const getAdSize: (size: SizeKeys) => AdSize;
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 };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._ = exports.getAdSize = exports.adSizes = void 0;
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
- exports.adSizes = {
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
- const getAdSize = (size) => exports.adSizes[size];
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 './prebidTimeout';
2
- export { TOP_ABOVE_NAV_HEIGHT } from './topAboveNavHeight';
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 prebidTimeout_1 = require("./prebidTimeout");
5
- Object.defineProperty(exports, "PREBID_TIMEOUT", { enumerable: true, get: function () { return prebidTimeout_1.PREBID_TIMEOUT; } });
6
- var topAboveNavHeight_1 = require("./topAboveNavHeight");
7
- Object.defineProperty(exports, "TOP_ABOVE_NAV_HEIGHT", { enumerable: true, get: function () { return topAboveNavHeight_1.TOP_ABOVE_NAV_HEIGHT; } });
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; } });
@@ -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: https://git.io/JgL4L
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: https://git.io/JgL4L
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! */
@@ -30,6 +30,7 @@ interface EventTimerProperties {
30
30
  adSlotsInline?: number;
31
31
  adSlotsTotal?: number;
32
32
  pageHeightVH?: number;
33
+ lazyLoadMarginPercent?: number;
33
34
  }
34
35
  export declare class EventTimer {
35
36
  private _events;
@@ -70,7 +71,7 @@ export declare class EventTimer {
70
71
  * @param {string} name - the property's name
71
72
  * @param {value} number - the property's value
72
73
  */
73
- setProperty(name: 'adSlotsInline' | 'adSlotsTotal' | 'pageHeightVH', value: number): void;
74
+ setProperty(name: 'adSlotsInline' | 'adSlotsTotal' | 'pageHeightVH' | 'lazyLoadMarginPercent', value: number): void;
74
75
  /**
75
76
  * Creates a new performance mark
76
77
  * For slot events also ensures each TYPE of event event is marked only once for 'first'
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EventTimer = void 0;
4
- const GoogleAnalytics_1 = require("./GoogleAnalytics");
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, GoogleAnalytics_1.trackEvent)('Commercial Events', gaEvent.timingVariable, labelToUse);
168
+ (0, google_analytics_1.trackEvent)('Commercial Events', gaEvent.timingVariable, labelToUse);
169
169
  }
170
170
  }
171
171
  }
@@ -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 './EventTimer';
8
- export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './sendCommercialMetrics';
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 './detectAdBlocker';
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 EventTimer_1 = require("./EventTimer");
37
- Object.defineProperty(exports, "EventTimer", { enumerable: true, get: function () { return EventTimer_1.EventTimer; } });
38
- var sendCommercialMetrics_1 = require("./sendCommercialMetrics");
39
- Object.defineProperty(exports, "bypassCommercialMetricsSampling", { enumerable: true, get: function () { return sendCommercialMetrics_1.bypassCommercialMetricsSampling; } });
40
- Object.defineProperty(exports, "initCommercialMetrics", { enumerable: true, get: function () { return sendCommercialMetrics_1.initCommercialMetrics; } });
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
- var detectAdBlocker_1 = require("./detectAdBlocker");
45
- Object.defineProperty(exports, "isAdBlockInUse", { enumerable: true, get: function () { return detectAdBlocker_1.isAdBlockInUse; } });
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; } });
@@ -1,8 +1,9 @@
1
- export declare const getPermutiveSegments: () => string[];
2
- export declare const getPermutivePFPSegments: () => string[];
3
- export declare const clearPermutiveSegments: () => void;
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, };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._ = exports.clearPermutiveSegments = exports.getPermutivePFPSegments = exports.getPermutiveSegments = void 0;
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
- export declare function bypassCommercialMetricsSampling(): void;
25
+ declare function bypassCommercialMetricsSampling(): void;
26
26
  interface InitCommercialMetricsArgs {
27
27
  pageViewId: string;
28
28
  browserId: string | undefined;
@@ -38,7 +38,7 @@ 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
- export declare function initCommercialMetrics({ pageViewId, browserId, isDev, adBlockerInUse, sampling, }: InitCommercialMetricsArgs): boolean;
41
+ declare function initCommercialMetrics({ pageViewId, browserId, isDev, adBlockerInUse, sampling, }: InitCommercialMetricsArgs): boolean;
42
42
  export declare const _: {
43
43
  Endpoints: typeof Endpoints;
44
44
  setEndpoint: (isDev: boolean) => Endpoints;
@@ -49,3 +49,4 @@ export declare const _: {
49
49
  reset: () => void;
50
50
  };
51
51
  export type { Property, TimedEvent, Metric };
52
+ export { bypassCommercialMetricsSampling, initCommercialMetrics };
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._ = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = void 0;
3
+ exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports._ = void 0;
4
4
  const libs_1 = require("@guardian/libs");
5
- const EventTimer_1 = require("./EventTimer");
5
+ const event_timer_1 = require("./event-timer");
6
6
  var Endpoints;
7
7
  (function (Endpoints) {
8
8
  Endpoints["CODE"] = "//performance-events.code.dev-guardianapis.com/commercial-metrics";
@@ -62,7 +62,7 @@ function sendMetrics() {
62
62
  }
63
63
  function gatherMetricsOnPageUnload() {
64
64
  // Assemble commercial properties and metrics
65
- const eventTimer = EventTimer_1.EventTimer.get();
65
+ const eventTimer = event_timer_1.EventTimer.get();
66
66
  const transformedEntries = transformToObjectEntries(eventTimer.properties);
67
67
  const filteredEventTimerProperties = filterUndefinedProperties(transformedEntries);
68
68
  const mappedEventTimerProperties = mapEventTimerPropertiesToString(filteredEventTimerProperties);
@@ -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
- export declare type ContentTargeting = {
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
- export declare const getContentTargeting: ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, }: Content) => ContentTargeting;
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
- export declare type PersonalisedTargeting = {
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
- export declare type SessionTargeting = {
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
- export declare type AllParticipations = {
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
- export declare const getSessionTargeting: ({ adTest, countryCode, isSignedIn, pageViewId, participations, referrer, }: Session) => SessionTargeting;
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` https://git.io/JDJ6W
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` https://git.io/JDJ62
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
- export declare type SharedTargeting = {
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
- export declare const getSharedTargeting: (shared: Partial<SharedTargeting>) => Partial<SharedTargeting>;
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._ = exports.getSharedTargeting = void 0;
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
- export declare type ViewportTargeting = {
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
- export declare const getViewportTargeting: ({ viewPortWidth, cmpBannerWillShow, }: Viewport) => ViewportTargeting;
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 EventTimer_1 = require("./EventTimer");
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 = EventTimer_1.EventTimer.get();
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 */
@@ -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';
@@ -1,12 +1,30 @@
1
- export declare type AdSizeString = 'fluid' | `${number},${number}`;
2
- export declare type AdSize = Readonly<{
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
- export 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' | 'video';
8
- export declare const adSizes: Record<SizeKeys, AdSize>;
9
- export declare const getAdSize: (size: SizeKeys) => AdSize;
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 };
@@ -29,9 +29,8 @@ const adSizesPartial = {
29
29
  outstreamDesktop: createAdSize(620, 350),
30
30
  outstreamGoogleDesktop: createAdSize(550, 310),
31
31
  outstreamMobile: createAdSize(300, 197),
32
- video: createAdSize(620, 1),
33
32
  };
34
- export const adSizes = {
33
+ const adSizes = {
35
34
  ...adSizesPartial,
36
35
  '970x250': adSizesPartial.billboard,
37
36
  '728x90': adSizesPartial.leaderboard,
@@ -40,6 +39,120 @@ export const adSizes = {
40
39
  '300x1050': adSizesPartial.portrait,
41
40
  '160x600': adSizesPartial.skyscraper,
42
41
  };
43
- export const getAdSize = (size) => adSizes[size];
42
+ const sizeMappings = {
43
+ right: {
44
+ mobile: [
45
+ adSizes.outOfPage,
46
+ adSizes.empty,
47
+ adSizes.mpu,
48
+ adSizes.googleCard,
49
+ adSizes.halfPage,
50
+ adSizes.fluid,
51
+ ],
52
+ },
53
+ comments: {
54
+ mobile: [
55
+ adSizes.outOfPage,
56
+ adSizes.empty,
57
+ adSizes.halfPage,
58
+ adSizes.outstreamMobile,
59
+ adSizes.mpu,
60
+ adSizes.googleCard,
61
+ adSizes.fluid,
62
+ ],
63
+ desktop: [
64
+ adSizes.outOfPage,
65
+ adSizes.empty,
66
+ adSizes.mpu,
67
+ adSizes.googleCard,
68
+ adSizes.fluid,
69
+ adSizes.halfPage,
70
+ adSizes.skyscraper,
71
+ ],
72
+ phablet: [
73
+ adSizes.outOfPage,
74
+ adSizes.empty,
75
+ adSizes.outstreamMobile,
76
+ adSizes.mpu,
77
+ adSizes.googleCard,
78
+ adSizes.fluid,
79
+ ],
80
+ },
81
+ 'top-above-nav': {
82
+ tablet: [
83
+ adSizes.outOfPage,
84
+ adSizes.empty,
85
+ adSizes.fabric,
86
+ adSizes.fluid,
87
+ adSizes.leaderboard,
88
+ ],
89
+ desktop: [
90
+ adSizes.outOfPage,
91
+ adSizes.empty,
92
+ adSizes.leaderboard,
93
+ createAdSize(940, 230),
94
+ createAdSize(900, 250),
95
+ adSizes.billboard,
96
+ adSizes.fabric,
97
+ adSizes.fluid,
98
+ ],
99
+ },
100
+ mostpop: {
101
+ mobile: [
102
+ adSizes.outOfPage,
103
+ adSizes.empty,
104
+ adSizes.mpu,
105
+ adSizes.googleCard,
106
+ adSizes.fluid,
107
+ ],
108
+ tablet: [
109
+ adSizes.outOfPage,
110
+ adSizes.empty,
111
+ adSizes.mpu,
112
+ adSizes.googleCard,
113
+ adSizes.halfPage,
114
+ adSizes.leaderboard,
115
+ adSizes.fluid,
116
+ ],
117
+ phablet: [
118
+ adSizes.outOfPage,
119
+ adSizes.empty,
120
+ adSizes.outstreamMobile,
121
+ adSizes.mpu,
122
+ adSizes.googleCard,
123
+ adSizes.halfPage,
124
+ adSizes.fluid,
125
+ ],
126
+ desktop: [
127
+ adSizes.outOfPage,
128
+ adSizes.empty,
129
+ adSizes.mpu,
130
+ adSizes.googleCard,
131
+ adSizes.halfPage,
132
+ adSizes.fluid,
133
+ ],
134
+ },
135
+ 'merchandising-high': {
136
+ mobile: [
137
+ adSizes.outOfPage,
138
+ adSizes.empty,
139
+ adSizes.merchandisingHigh,
140
+ adSizes.fluid,
141
+ ],
142
+ },
143
+ merchandising: {
144
+ mobile: [
145
+ adSizes.outOfPage,
146
+ adSizes.empty,
147
+ adSizes.merchandising,
148
+ adSizes.fluid,
149
+ ],
150
+ },
151
+ survey: {
152
+ desktop: [adSizes.outOfPage],
153
+ },
154
+ };
155
+ const getAdSize = (size) => adSizes[size];
44
156
  // Export for testing
45
157
  export const _ = { createAdSize };
158
+ export { adSizes, getAdSize, sizeMappings };
@@ -1,2 +1,2 @@
1
- export { PREBID_TIMEOUT } from './prebidTimeout';
2
- export { TOP_ABOVE_NAV_HEIGHT } from './topAboveNavHeight';
1
+ export { PREBID_TIMEOUT } from './prebid-timeout';
2
+ export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height';
@@ -1,2 +1,2 @@
1
- export { PREBID_TIMEOUT } from './prebidTimeout';
2
- export { TOP_ABOVE_NAV_HEIGHT } from './topAboveNavHeight';
1
+ export { PREBID_TIMEOUT } from './prebid-timeout';
2
+ export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height';
@@ -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: https://git.io/JgL4L
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.
@@ -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: https://git.io/JgL4L
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
  /*istanbul ignore file -- adElementBlocked can't be tested without patching each of the properties of
7
8
  HTMLElement.prototype that it accesses, defeating the purpose of the test! */
@@ -30,6 +30,7 @@ interface EventTimerProperties {
30
30
  adSlotsInline?: number;
31
31
  adSlotsTotal?: number;
32
32
  pageHeightVH?: number;
33
+ lazyLoadMarginPercent?: number;
33
34
  }
34
35
  export declare class EventTimer {
35
36
  private _events;
@@ -70,7 +71,7 @@ export declare class EventTimer {
70
71
  * @param {string} name - the property's name
71
72
  * @param {value} number - the property's value
72
73
  */
73
- setProperty(name: 'adSlotsInline' | 'adSlotsTotal' | 'pageHeightVH', value: number): void;
74
+ setProperty(name: 'adSlotsInline' | 'adSlotsTotal' | 'pageHeightVH' | 'lazyLoadMarginPercent', value: number): void;
74
75
  /**
75
76
  * Creates a new performance mark
76
77
  * For slot events also ensures each TYPE of event event is marked only once for 'first'
@@ -1,4 +1,4 @@
1
- import { trackEvent } from './GoogleAnalytics';
1
+ import { trackEvent } from './google-analytics';
2
2
  class Event {
3
3
  constructor(name, mark) {
4
4
  this.name = name;
@@ -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 './EventTimer';
8
- export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './sendCommercialMetrics';
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 './detectAdBlocker';
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/esm/index.js CHANGED
@@ -5,10 +5,10 @@ export { fbPixel } from './third-party-tags/facebook-pixel';
5
5
  export { twitter } from './third-party-tags/twitter-uwt';
6
6
  export { inizio } from './third-party-tags/inizio';
7
7
  export { remarketing } from './third-party-tags/remarketing';
8
- export { EventTimer } from './EventTimer';
9
- export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './sendCommercialMetrics';
10
- export { adSizes, getAdSize } from './ad-sizes';
11
- export { isAdBlockInUse } from './detectAdBlocker';
8
+ export { EventTimer } from './event-timer';
9
+ export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics';
10
+ export { adSizes, getAdSize, sizeMappings } from './ad-sizes';
11
+ export { isAdBlockInUse } from './detect-ad-blocker';
12
12
  export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments, } from './permutive';
13
13
  export { initTrackScrollDepth } from './track-scroll-depth';
14
14
  export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
@@ -1,8 +1,9 @@
1
- export declare const getPermutiveSegments: () => string[];
2
- export declare const getPermutivePFPSegments: () => string[];
3
- export declare const clearPermutiveSegments: () => void;
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, };
@@ -19,9 +19,9 @@ const getSegments = (key) => {
19
19
  return [];
20
20
  }
21
21
  };
22
- export const getPermutiveSegments = () => getSegments(PERMUTIVE_KEY);
23
- export const getPermutivePFPSegments = () => getSegments(PERMUTIVE_PFP_KEY);
24
- export const clearPermutiveSegments = () => {
22
+ const getPermutiveSegments = () => getSegments(PERMUTIVE_KEY);
23
+ const getPermutivePFPSegments = () => getSegments(PERMUTIVE_PFP_KEY);
24
+ const clearPermutiveSegments = () => {
25
25
  storage.local.remove(PERMUTIVE_KEY);
26
26
  storage.local.remove(PERMUTIVE_PFP_KEY);
27
27
  };
@@ -30,3 +30,4 @@ export const _ = {
30
30
  PERMUTIVE_PFP_KEY,
31
31
  getSegments,
32
32
  };
33
+ export { getPermutiveSegments, getPermutivePFPSegments, clearPermutiveSegments, };
@@ -22,7 +22,7 @@ declare enum Endpoints {
22
22
  /**
23
23
  * A method to asynchronously send metrics after initialization.
24
24
  */
25
- export declare function bypassCommercialMetricsSampling(): void;
25
+ declare function bypassCommercialMetricsSampling(): void;
26
26
  interface InitCommercialMetricsArgs {
27
27
  pageViewId: string;
28
28
  browserId: string | undefined;
@@ -38,7 +38,7 @@ 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
- export declare function initCommercialMetrics({ pageViewId, browserId, isDev, adBlockerInUse, sampling, }: InitCommercialMetricsArgs): boolean;
41
+ declare function initCommercialMetrics({ pageViewId, browserId, isDev, adBlockerInUse, sampling, }: InitCommercialMetricsArgs): boolean;
42
42
  export declare const _: {
43
43
  Endpoints: typeof Endpoints;
44
44
  setEndpoint: (isDev: boolean) => Endpoints;
@@ -49,3 +49,4 @@ export declare const _: {
49
49
  reset: () => void;
50
50
  };
51
51
  export type { Property, TimedEvent, Metric };
52
+ export { bypassCommercialMetricsSampling, initCommercialMetrics };
@@ -1,5 +1,5 @@
1
1
  import { log } from '@guardian/libs';
2
- import { EventTimer } from './EventTimer';
2
+ import { EventTimer } from './event-timer';
3
3
  var Endpoints;
4
4
  (function (Endpoints) {
5
5
  Endpoints["CODE"] = "//performance-events.code.dev-guardianapis.com/commercial-metrics";
@@ -92,7 +92,7 @@ const addVisibilityListeners = () => {
92
92
  /**
93
93
  * A method to asynchronously send metrics after initialization.
94
94
  */
95
- export function bypassCommercialMetricsSampling() {
95
+ function bypassCommercialMetricsSampling() {
96
96
  if (!initialised) {
97
97
  console.warn('initCommercialMetrics not yet initialised');
98
98
  return;
@@ -107,7 +107,7 @@ export function bypassCommercialMetricsSampling() {
107
107
  * @param init.adBlockerInUse - indicates whether or not an adblocker is being used.
108
108
  * @param init.sampling - rate at which to sample commercial metrics - the default is to send for 1% of pageviews
109
109
  */
110
- export function initCommercialMetrics({ pageViewId, browserId, isDev, adBlockerInUse, sampling = 1 / 100, }) {
110
+ function initCommercialMetrics({ pageViewId, browserId, isDev, adBlockerInUse, sampling = 1 / 100, }) {
111
111
  commercialMetricsPayload.page_view_id = pageViewId;
112
112
  commercialMetricsPayload.browser_id = browserId;
113
113
  setEndpoint(isDev);
@@ -144,3 +144,4 @@ export const _ = {
144
144
  removeEventListener('pagehide', listener);
145
145
  },
146
146
  };
147
+ export { bypassCommercialMetricsSampling, initCommercialMetrics };
@@ -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
- export declare type ContentTargeting = {
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
- export declare const getContentTargeting: ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, }: Content) => ContentTargeting;
70
- export {};
69
+ declare const getContentTargeting: ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, }: Content) => ContentTargeting;
70
+ export { getContentTargeting };
71
+ export type { ContentTargeting };
@@ -25,7 +25,7 @@ const getUrlKeywords = (url) => {
25
25
  .slice(-1)[0];
26
26
  return isString(lastSegment) ? lastSegment.split('-').filter(Boolean) : [];
27
27
  };
28
- export const getContentTargeting = ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, }) => {
28
+ const getContentTargeting = ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, }) => {
29
29
  return {
30
30
  dcre: eligibleForDCR ? 't' : 'f',
31
31
  rp: renderingPlatform,
@@ -35,3 +35,4 @@ export const getContentTargeting = ({ eligibleForDCR, path, renderingPlatform, s
35
35
  vl: videoLength ? getVideoLength(videoLength) : null,
36
36
  };
37
37
  };
38
+ export { getContentTargeting };
@@ -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
- export declare type PersonalisedTargeting = {
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
- export declare type SessionTargeting = {
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
- export declare type AllParticipations = {
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
- export declare const getSessionTargeting: ({ adTest, countryCode, isSignedIn, pageViewId, participations, referrer, }: Session) => SessionTargeting;
109
- export {};
108
+ declare const getSessionTargeting: ({ adTest, countryCode, isSignedIn, pageViewId, participations, referrer, }: Session) => SessionTargeting;
109
+ export type { SessionTargeting, AllParticipations };
110
+ export { getSessionTargeting };
@@ -46,7 +46,7 @@ const experimentsTargeting = ({ clientSideParticipations, serverSideParticipatio
46
46
  }
47
47
  return [...clientSideExperiment, ...serverSideExperiments];
48
48
  };
49
- export const getSessionTargeting = ({ adTest, countryCode, isSignedIn, pageViewId, participations, referrer, }) => ({
49
+ const getSessionTargeting = ({ adTest, countryCode, isSignedIn, pageViewId, participations, referrer, }) => ({
50
50
  ab: experimentsTargeting(participations),
51
51
  at: adTest,
52
52
  cc: countryCode,
@@ -54,3 +54,4 @@ export const getSessionTargeting = ({ adTest, countryCode, isSignedIn, pageViewI
54
54
  ref: getReferrer(referrer),
55
55
  si: isSignedIn ? 't' : 'f',
56
56
  });
57
+ 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` https://git.io/JDJ6W
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` https://git.io/JDJ62
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
- export declare type SharedTargeting = {
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
- export declare const getSharedTargeting: (shared: Partial<SharedTargeting>) => Partial<SharedTargeting>;
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 };
@@ -48,7 +48,8 @@ const getSurgingParam = (surging) => {
48
48
  /**
49
49
  * What goes in comes out
50
50
  */
51
- export const getSharedTargeting = (shared) => pickTargetingValues(shared);
51
+ const getSharedTargeting = (shared) => pickTargetingValues(shared);
52
52
  export const _ = {
53
53
  getSurgingParam,
54
54
  };
55
+ export { getSharedTargeting };
@@ -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
- export declare type ViewportTargeting = {
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
- export declare const getViewportTargeting: ({ viewPortWidth, cmpBannerWillShow, }: Viewport) => ViewportTargeting;
47
- export {};
46
+ declare const getViewportTargeting: ({ viewPortWidth, cmpBannerWillShow, }: Viewport) => ViewportTargeting;
47
+ export type { ViewportTargeting };
48
+ export { getViewportTargeting };
@@ -6,7 +6,7 @@ const findBreakpoint = (width) => {
6
6
  return 'tablet';
7
7
  return 'mobile';
8
8
  };
9
- export const getViewportTargeting = ({ viewPortWidth, cmpBannerWillShow, }) => {
9
+ const getViewportTargeting = ({ viewPortWidth, cmpBannerWillShow, }) => {
10
10
  // Don’t show inskin if if a privacy message will be shown
11
11
  const inskin = cmpBannerWillShow ? 'f' : 't';
12
12
  return {
@@ -15,3 +15,4 @@ export const getViewportTargeting = ({ viewPortWidth, cmpBannerWillShow, }) => {
15
15
  inskin,
16
16
  };
17
17
  };
18
+ export { getViewportTargeting };
@@ -1,5 +1,5 @@
1
1
  import { log } from '@guardian/libs';
2
- import { EventTimer } from './EventTimer';
2
+ import { EventTimer } from './event-timer';
3
3
  /**
4
4
  * Collect commercial metrics on scroll depth
5
5
  * Insert hidden elements at intervals of 1 viewport height
@@ -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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/commercial-core",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "Guardian advertising business logic",
5
5
  "homepage": "https://github.com/guardian/commercial-core#readme",
6
6
  "bugs": {