@guardian/commercial-core 4.13.0 → 4.15.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.
@@ -31,6 +31,14 @@ declare type SlotName = 'right' | 'comments' | 'top-above-nav' | 'mostpop' | 'me
31
31
  declare type SizeMapping = Partial<Record<Breakpoint, AdSize[]>>;
32
32
  declare type SlotSizeMappings = Record<SlotName, SizeMapping>;
33
33
  declare const createAdSize: (width: number, height: number) => AdSize;
34
+ declare const standardAdSizes: {
35
+ '970x250': AdSize;
36
+ '300x600': AdSize;
37
+ '728x90': AdSize;
38
+ '300x250': AdSize;
39
+ '300x1050': AdSize;
40
+ '160x600': AdSize;
41
+ };
34
42
  declare const adSizes: Record<SizeKeys, AdSize>;
35
43
  /**
36
44
  * mark: 432b3a46-90c1-4573-90d3-2400b51af8d0
@@ -43,4 +51,4 @@ export declare const _: {
43
51
  createAdSize: (width: number, height: number) => AdSize;
44
52
  };
45
53
  export type { AdSizeString, AdSize, SizeKeys, SizeMapping, SlotSizeMappings, SlotName, };
46
- export { adSizes, getAdSize, slotSizeMappings, createAdSize };
54
+ export { adSizes, standardAdSizes, getAdSize, slotSizeMappings, createAdSize };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAdSize = exports.slotSizeMappings = exports.getAdSize = exports.adSizes = exports._ = void 0;
3
+ exports.createAdSize = exports.slotSizeMappings = exports.getAdSize = exports.standardAdSizes = exports.adSizes = exports._ = void 0;
4
4
  /**
5
5
  * Store ad sizes in a way that is compatible with google-tag but also accessible via
6
6
  * more semantic `width`/`height` properties and keep things readonly.
@@ -43,8 +43,7 @@ const createAdSize = (width, height) => {
43
43
  return new AdSize([width, height]);
44
44
  };
45
45
  exports.createAdSize = createAdSize;
46
- const adSizesPartial = {
47
- // standard ad sizes
46
+ const namedStandardAdSizes = {
48
47
  billboard: createAdSize(970, 250),
49
48
  halfPage: createAdSize(300, 600),
50
49
  leaderboard: createAdSize(728, 90),
@@ -52,11 +51,22 @@ const adSizesPartial = {
52
51
  mpu: createAdSize(300, 250),
53
52
  portrait: createAdSize(300, 1050),
54
53
  skyscraper: createAdSize(160, 600),
55
- // dfp proprietary ad sizes
54
+ };
55
+ const standardAdSizes = {
56
+ '970x250': namedStandardAdSizes.billboard,
57
+ '300x600': namedStandardAdSizes.halfPage,
58
+ '728x90': namedStandardAdSizes.leaderboard,
59
+ '300x250': namedStandardAdSizes.mpu,
60
+ '300x1050': namedStandardAdSizes.portrait,
61
+ '160x600': namedStandardAdSizes.skyscraper,
62
+ };
63
+ exports.standardAdSizes = standardAdSizes;
64
+ const dfpProprietaryAdSizes = {
56
65
  fluid: createAdSize(0, 0),
57
66
  googleCard: createAdSize(300, 274),
58
67
  outOfPage: createAdSize(1, 1),
59
- // guardian proprietary ad sizes
68
+ };
69
+ const guardianProprietaryAdSizes = {
60
70
  empty: createAdSize(2, 2),
61
71
  fabric: createAdSize(88, 71),
62
72
  inlineMerchandising: createAdSize(88, 85),
@@ -69,13 +79,10 @@ const adSizesPartial = {
69
79
  cascade: createAdSize(940, 230),
70
80
  };
71
81
  const adSizes = {
72
- ...adSizesPartial,
73
- '970x250': adSizesPartial.billboard,
74
- '728x90': adSizesPartial.leaderboard,
75
- '300x250': adSizesPartial.mpu,
76
- '300x600': adSizesPartial.halfPage,
77
- '300x1050': adSizesPartial.portrait,
78
- '160x600': adSizesPartial.skyscraper,
82
+ ...namedStandardAdSizes,
83
+ ...standardAdSizes,
84
+ ...dfpProprietaryAdSizes,
85
+ ...guardianProprietaryAdSizes,
79
86
  };
80
87
  exports.adSizes = adSizes;
81
88
  /**
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Unit: pixels
3
+ */
4
+ export declare const AD_LABEL_HEIGHT = 24;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AD_LABEL_HEIGHT = void 0;
4
+ /**
5
+ * Unit: pixels
6
+ */
7
+ exports.AD_LABEL_HEIGHT = 24;
@@ -1,2 +1,3 @@
1
+ export { AD_LABEL_HEIGHT } from './adLabelHeight';
1
2
  export { PREBID_TIMEOUT } from './prebid-timeout';
2
3
  export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height';
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TOP_ABOVE_NAV_HEIGHT = exports.PREBID_TIMEOUT = void 0;
3
+ exports.TOP_ABOVE_NAV_HEIGHT = exports.PREBID_TIMEOUT = exports.AD_LABEL_HEIGHT = void 0;
4
+ var adLabelHeight_1 = require("./adLabelHeight");
5
+ Object.defineProperty(exports, "AD_LABEL_HEIGHT", { enumerable: true, get: function () { return adLabelHeight_1.AD_LABEL_HEIGHT; } });
4
6
  var prebid_timeout_1 = require("./prebid-timeout");
5
7
  Object.defineProperty(exports, "PREBID_TIMEOUT", { enumerable: true, get: function () { return prebid_timeout_1.PREBID_TIMEOUT; } });
6
8
  var top_above_nav_height_1 = require("./top-above-nav-height");
@@ -1,6 +1,4 @@
1
1
  /**
2
- * Unit: milliseconds.
3
- *
4
- * This value is currently being investigated.
2
+ * Unit: milliseconds
5
3
  */
6
4
  export declare const PREBID_TIMEOUT = 1500;
@@ -2,13 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PREBID_TIMEOUT = void 0;
4
4
  /**
5
- * Unit: milliseconds.
6
- *
7
- * This value is currently being investigated.
5
+ * Unit: milliseconds
8
6
  */
9
7
  exports.PREBID_TIMEOUT = 1500;
10
- /*
11
-
12
- cc @chrislomaxjones
13
-
14
- */
@@ -7,7 +7,7 @@ export { remarketing } from './third-party-tags/remarketing';
7
7
  export { EventTimer } from './event-timer';
8
8
  export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics';
9
9
  export type { ThirdPartyTag } from './types';
10
- export { adSizes, getAdSize, slotSizeMappings, createAdSize } from './ad-sizes';
10
+ export { adSizes, standardAdSizes, getAdSize, slotSizeMappings, createAdSize, } from './ad-sizes';
11
11
  export { isBreakpoint } from './lib/breakpoint';
12
12
  export type { Breakpoint } from './lib/breakpoint';
13
13
  export type { SizeKeys, AdSizeString, AdSize, SizeMapping, SlotSizeMappings, SlotName, } from './ad-sizes';
@@ -35,4 +35,5 @@ export { init as initMessenger } from './messenger';
35
35
  export type { RegisterListener, RegisterPersistentListener, RespondProxy, } from './messenger';
36
36
  export { postMessage } from './messenger/post-message';
37
37
  export { buildPageTargeting } from './targeting/build-page-targeting';
38
+ export { buildPageTargetingConsentless } from './targeting/build-page-targeting-consentless';
38
39
  export type { PageTargeting } from './targeting/build-page-targeting';
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.buildPageTargeting = exports.postMessage = exports.initMessenger = exports.pickTargetingValues = exports.getViewportTargeting = exports.getSharedTargeting = exports.getSessionTargeting = exports.getPersonalisedTargeting = exports.getContentTargeting = exports.constants = exports.concatSizeMappings = exports.createAdSlot = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.initTrackGpcSignal = exports.initTrackLabsContainer = exports.initTrackScrollDepth = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.isBreakpoint = 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.buildPageTargetingConsentless = exports.buildPageTargeting = exports.postMessage = exports.initMessenger = exports.pickTargetingValues = exports.getViewportTargeting = exports.getSharedTargeting = exports.getSessionTargeting = exports.getPersonalisedTargeting = exports.getContentTargeting = exports.constants = exports.concatSizeMappings = exports.createAdSlot = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.initTrackGpcSignal = exports.initTrackLabsContainer = exports.initTrackScrollDepth = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.isBreakpoint = exports.createAdSize = exports.slotSizeMappings = exports.getAdSize = exports.standardAdSizes = 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");
@@ -44,6 +44,7 @@ Object.defineProperty(exports, "bypassCommercialMetricsSampling", { enumerable:
44
44
  Object.defineProperty(exports, "initCommercialMetrics", { enumerable: true, get: function () { return send_commercial_metrics_1.initCommercialMetrics; } });
45
45
  var ad_sizes_1 = require("./ad-sizes");
46
46
  Object.defineProperty(exports, "adSizes", { enumerable: true, get: function () { return ad_sizes_1.adSizes; } });
47
+ Object.defineProperty(exports, "standardAdSizes", { enumerable: true, get: function () { return ad_sizes_1.standardAdSizes; } });
47
48
  Object.defineProperty(exports, "getAdSize", { enumerable: true, get: function () { return ad_sizes_1.getAdSize; } });
48
49
  Object.defineProperty(exports, "slotSizeMappings", { enumerable: true, get: function () { return ad_sizes_1.slotSizeMappings; } });
49
50
  Object.defineProperty(exports, "createAdSize", { enumerable: true, get: function () { return ad_sizes_1.createAdSize; } });
@@ -86,3 +87,5 @@ var post_message_1 = require("./messenger/post-message");
86
87
  Object.defineProperty(exports, "postMessage", { enumerable: true, get: function () { return post_message_1.postMessage; } });
87
88
  var build_page_targeting_1 = require("./targeting/build-page-targeting");
88
89
  Object.defineProperty(exports, "buildPageTargeting", { enumerable: true, get: function () { return build_page_targeting_1.buildPageTargeting; } });
90
+ var build_page_targeting_consentless_1 = require("./targeting/build-page-targeting-consentless");
91
+ Object.defineProperty(exports, "buildPageTargetingConsentless", { enumerable: true, get: function () { return build_page_targeting_consentless_1.buildPageTargetingConsentless; } });
@@ -0,0 +1,19 @@
1
+ import type { Participations } from '@guardian/ab-core';
2
+ import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
3
+ import type { CountryCode } from '@guardian/libs';
4
+ import type { PageTargeting } from './build-page-targeting';
5
+ declare const consentlessTargetingKeys: readonly ["ab", "at", "bl", "bp", "br", "cc", "ct", "dcre", "edition", "k", "rp", "s", "se", "sens", "sh", "si", "skinsize", "su", "tn", "url", "urlkw"];
6
+ declare type ConsentlessTargetingKeys = typeof consentlessTargetingKeys[number];
7
+ declare type ConsentlessPageTargeting = Partial<Pick<PageTargeting, ConsentlessTargetingKeys>>;
8
+ /**
9
+ * Call buildPageTargeting then filter out the keys that are not needed for
10
+ * consentless targeting.
11
+ *
12
+ * @param {ConsentState} consentState
13
+ * @param {boolean} adFree
14
+ * @param {CountryCode} countryCode
15
+ * @param {Participations} clientSideParticipations
16
+ * @returns ConsentlessPageTargeting
17
+ */
18
+ declare const buildPageTargetingConsentless: (consentState: ConsentState, adFree: boolean, countryCode: CountryCode, clientSideParticipations: Participations) => ConsentlessPageTargeting;
19
+ export { buildPageTargetingConsentless };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildPageTargetingConsentless = void 0;
4
+ const build_page_targeting_1 = require("./build-page-targeting");
5
+ const consentlessTargetingKeys = [
6
+ 'ab',
7
+ 'at',
8
+ 'bl',
9
+ 'bp',
10
+ 'br',
11
+ 'cc',
12
+ 'ct',
13
+ 'dcre',
14
+ 'edition',
15
+ 'k',
16
+ 'rp',
17
+ 's',
18
+ 'se',
19
+ 'sens',
20
+ 'sh',
21
+ 'si',
22
+ 'skinsize',
23
+ 'su',
24
+ 'tn',
25
+ 'url',
26
+ 'urlkw',
27
+ ];
28
+ const isConsentlessKey = (key) => consentlessTargetingKeys.includes(key);
29
+ /**
30
+ * Call buildPageTargeting then filter out the keys that are not needed for
31
+ * consentless targeting.
32
+ *
33
+ * @param {ConsentState} consentState
34
+ * @param {boolean} adFree
35
+ * @param {CountryCode} countryCode
36
+ * @param {Participations} clientSideParticipations
37
+ * @returns ConsentlessPageTargeting
38
+ */
39
+ const buildPageTargetingConsentless = (consentState, adFree, countryCode, clientSideParticipations) => {
40
+ const consentedPageTargeting = (0, build_page_targeting_1.buildPageTargeting)(consentState, adFree, countryCode, clientSideParticipations);
41
+ return Object.fromEntries(Object.entries(consentedPageTargeting).filter(([k]) => isConsentlessKey(k)));
42
+ };
43
+ exports.buildPageTargetingConsentless = buildPageTargetingConsentless;
@@ -31,6 +31,14 @@ declare type SlotName = 'right' | 'comments' | 'top-above-nav' | 'mostpop' | 'me
31
31
  declare type SizeMapping = Partial<Record<Breakpoint, AdSize[]>>;
32
32
  declare type SlotSizeMappings = Record<SlotName, SizeMapping>;
33
33
  declare const createAdSize: (width: number, height: number) => AdSize;
34
+ declare const standardAdSizes: {
35
+ '970x250': AdSize;
36
+ '300x600': AdSize;
37
+ '728x90': AdSize;
38
+ '300x250': AdSize;
39
+ '300x1050': AdSize;
40
+ '160x600': AdSize;
41
+ };
34
42
  declare const adSizes: Record<SizeKeys, AdSize>;
35
43
  /**
36
44
  * mark: 432b3a46-90c1-4573-90d3-2400b51af8d0
@@ -43,4 +51,4 @@ export declare const _: {
43
51
  createAdSize: (width: number, height: number) => AdSize;
44
52
  };
45
53
  export type { AdSizeString, AdSize, SizeKeys, SizeMapping, SlotSizeMappings, SlotName, };
46
- export { adSizes, getAdSize, slotSizeMappings, createAdSize };
54
+ export { adSizes, standardAdSizes, getAdSize, slotSizeMappings, createAdSize };
@@ -39,8 +39,7 @@ class AdSize extends Array {
39
39
  const createAdSize = (width, height) => {
40
40
  return new AdSize([width, height]);
41
41
  };
42
- const adSizesPartial = {
43
- // standard ad sizes
42
+ const namedStandardAdSizes = {
44
43
  billboard: createAdSize(970, 250),
45
44
  halfPage: createAdSize(300, 600),
46
45
  leaderboard: createAdSize(728, 90),
@@ -48,11 +47,21 @@ const adSizesPartial = {
48
47
  mpu: createAdSize(300, 250),
49
48
  portrait: createAdSize(300, 1050),
50
49
  skyscraper: createAdSize(160, 600),
51
- // dfp proprietary ad sizes
50
+ };
51
+ const standardAdSizes = {
52
+ '970x250': namedStandardAdSizes.billboard,
53
+ '300x600': namedStandardAdSizes.halfPage,
54
+ '728x90': namedStandardAdSizes.leaderboard,
55
+ '300x250': namedStandardAdSizes.mpu,
56
+ '300x1050': namedStandardAdSizes.portrait,
57
+ '160x600': namedStandardAdSizes.skyscraper,
58
+ };
59
+ const dfpProprietaryAdSizes = {
52
60
  fluid: createAdSize(0, 0),
53
61
  googleCard: createAdSize(300, 274),
54
62
  outOfPage: createAdSize(1, 1),
55
- // guardian proprietary ad sizes
63
+ };
64
+ const guardianProprietaryAdSizes = {
56
65
  empty: createAdSize(2, 2),
57
66
  fabric: createAdSize(88, 71),
58
67
  inlineMerchandising: createAdSize(88, 85),
@@ -65,13 +74,10 @@ const adSizesPartial = {
65
74
  cascade: createAdSize(940, 230),
66
75
  };
67
76
  const adSizes = {
68
- ...adSizesPartial,
69
- '970x250': adSizesPartial.billboard,
70
- '728x90': adSizesPartial.leaderboard,
71
- '300x250': adSizesPartial.mpu,
72
- '300x600': adSizesPartial.halfPage,
73
- '300x1050': adSizesPartial.portrait,
74
- '160x600': adSizesPartial.skyscraper,
77
+ ...namedStandardAdSizes,
78
+ ...standardAdSizes,
79
+ ...dfpProprietaryAdSizes,
80
+ ...guardianProprietaryAdSizes,
75
81
  };
76
82
  /**
77
83
  * mark: 432b3a46-90c1-4573-90d3-2400b51af8d0
@@ -251,4 +257,4 @@ const slotSizeMappings = {
251
257
  const getAdSize = (size) => adSizes[size];
252
258
  // Export for testing
253
259
  export const _ = { createAdSize };
254
- export { adSizes, getAdSize, slotSizeMappings, createAdSize };
260
+ export { adSizes, standardAdSizes, getAdSize, slotSizeMappings, createAdSize };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Unit: pixels
3
+ */
4
+ export declare const AD_LABEL_HEIGHT = 24;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Unit: pixels
3
+ */
4
+ export const AD_LABEL_HEIGHT = 24;
@@ -1,2 +1,3 @@
1
+ export { AD_LABEL_HEIGHT } from './adLabelHeight';
1
2
  export { PREBID_TIMEOUT } from './prebid-timeout';
2
3
  export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height';
@@ -1,2 +1,3 @@
1
+ export { AD_LABEL_HEIGHT } from './adLabelHeight';
1
2
  export { PREBID_TIMEOUT } from './prebid-timeout';
2
3
  export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height';
@@ -1,6 +1,4 @@
1
1
  /**
2
- * Unit: milliseconds.
3
- *
4
- * This value is currently being investigated.
2
+ * Unit: milliseconds
5
3
  */
6
4
  export declare const PREBID_TIMEOUT = 1500;
@@ -1,11 +1,4 @@
1
1
  /**
2
- * Unit: milliseconds.
3
- *
4
- * This value is currently being investigated.
2
+ * Unit: milliseconds
5
3
  */
6
4
  export const PREBID_TIMEOUT = 1500;
7
- /*
8
-
9
- cc @chrislomaxjones
10
-
11
- */
@@ -7,7 +7,7 @@ export { remarketing } from './third-party-tags/remarketing';
7
7
  export { EventTimer } from './event-timer';
8
8
  export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics';
9
9
  export type { ThirdPartyTag } from './types';
10
- export { adSizes, getAdSize, slotSizeMappings, createAdSize } from './ad-sizes';
10
+ export { adSizes, standardAdSizes, getAdSize, slotSizeMappings, createAdSize, } from './ad-sizes';
11
11
  export { isBreakpoint } from './lib/breakpoint';
12
12
  export type { Breakpoint } from './lib/breakpoint';
13
13
  export type { SizeKeys, AdSizeString, AdSize, SizeMapping, SlotSizeMappings, SlotName, } from './ad-sizes';
@@ -35,4 +35,5 @@ export { init as initMessenger } from './messenger';
35
35
  export type { RegisterListener, RegisterPersistentListener, RespondProxy, } from './messenger';
36
36
  export { postMessage } from './messenger/post-message';
37
37
  export { buildPageTargeting } from './targeting/build-page-targeting';
38
+ export { buildPageTargetingConsentless } from './targeting/build-page-targeting-consentless';
38
39
  export type { PageTargeting } from './targeting/build-page-targeting';
package/dist/esm/index.js CHANGED
@@ -7,7 +7,7 @@ export { inizio } from './third-party-tags/inizio';
7
7
  export { remarketing } from './third-party-tags/remarketing';
8
8
  export { EventTimer } from './event-timer';
9
9
  export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics';
10
- export { adSizes, getAdSize, slotSizeMappings, createAdSize } from './ad-sizes';
10
+ export { adSizes, standardAdSizes, getAdSize, slotSizeMappings, createAdSize, } from './ad-sizes';
11
11
  export { isBreakpoint } from './lib/breakpoint';
12
12
  export { isAdBlockInUse } from './detect-ad-blocker';
13
13
  export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments, } from './permutive';
@@ -27,3 +27,4 @@ export { pickTargetingValues } from './targeting/pick-targeting-values';
27
27
  export { init as initMessenger } from './messenger';
28
28
  export { postMessage } from './messenger/post-message';
29
29
  export { buildPageTargeting } from './targeting/build-page-targeting';
30
+ export { buildPageTargetingConsentless } from './targeting/build-page-targeting-consentless';
@@ -0,0 +1,19 @@
1
+ import type { Participations } from '@guardian/ab-core';
2
+ import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
3
+ import type { CountryCode } from '@guardian/libs';
4
+ import type { PageTargeting } from './build-page-targeting';
5
+ declare const consentlessTargetingKeys: readonly ["ab", "at", "bl", "bp", "br", "cc", "ct", "dcre", "edition", "k", "rp", "s", "se", "sens", "sh", "si", "skinsize", "su", "tn", "url", "urlkw"];
6
+ declare type ConsentlessTargetingKeys = typeof consentlessTargetingKeys[number];
7
+ declare type ConsentlessPageTargeting = Partial<Pick<PageTargeting, ConsentlessTargetingKeys>>;
8
+ /**
9
+ * Call buildPageTargeting then filter out the keys that are not needed for
10
+ * consentless targeting.
11
+ *
12
+ * @param {ConsentState} consentState
13
+ * @param {boolean} adFree
14
+ * @param {CountryCode} countryCode
15
+ * @param {Participations} clientSideParticipations
16
+ * @returns ConsentlessPageTargeting
17
+ */
18
+ declare const buildPageTargetingConsentless: (consentState: ConsentState, adFree: boolean, countryCode: CountryCode, clientSideParticipations: Participations) => ConsentlessPageTargeting;
19
+ export { buildPageTargetingConsentless };
@@ -0,0 +1,40 @@
1
+ import { buildPageTargeting } from './build-page-targeting';
2
+ const consentlessTargetingKeys = [
3
+ 'ab',
4
+ 'at',
5
+ 'bl',
6
+ 'bp',
7
+ 'br',
8
+ 'cc',
9
+ 'ct',
10
+ 'dcre',
11
+ 'edition',
12
+ 'k',
13
+ 'rp',
14
+ 's',
15
+ 'se',
16
+ 'sens',
17
+ 'sh',
18
+ 'si',
19
+ 'skinsize',
20
+ 'su',
21
+ 'tn',
22
+ 'url',
23
+ 'urlkw',
24
+ ];
25
+ const isConsentlessKey = (key) => consentlessTargetingKeys.includes(key);
26
+ /**
27
+ * Call buildPageTargeting then filter out the keys that are not needed for
28
+ * consentless targeting.
29
+ *
30
+ * @param {ConsentState} consentState
31
+ * @param {boolean} adFree
32
+ * @param {CountryCode} countryCode
33
+ * @param {Participations} clientSideParticipations
34
+ * @returns ConsentlessPageTargeting
35
+ */
36
+ const buildPageTargetingConsentless = (consentState, adFree, countryCode, clientSideParticipations) => {
37
+ const consentedPageTargeting = buildPageTargeting(consentState, adFree, countryCode, clientSideParticipations);
38
+ return Object.fromEntries(Object.entries(consentedPageTargeting).filter(([k]) => isConsentlessKey(k)));
39
+ };
40
+ export { buildPageTargetingConsentless };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/commercial-core",
3
- "version": "4.13.0",
3
+ "version": "4.15.0",
4
4
  "description": "Guardian advertising business logic",
5
5
  "homepage": "https://github.com/guardian/commercial-core#readme",
6
6
  "bugs": {