@guardian/commercial-core 4.15.0 → 4.17.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 +7 -1
- package/dist/cjs/ad-sizes.js +18 -5
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +4 -3
- package/dist/cjs/lib/get-locale.d.ts +8 -0
- package/dist/cjs/lib/get-locale.js +43 -0
- package/dist/cjs/targeting/build-page-targeting-consentless.d.ts +1 -3
- package/dist/cjs/targeting/build-page-targeting-consentless.js +2 -3
- package/dist/cjs/targeting/build-page-targeting.d.ts +1 -1
- package/dist/cjs/targeting/build-page-targeting.js +3 -2
- package/dist/cjs/types.d.ts +2 -1
- package/dist/esm/ad-sizes.d.ts +7 -1
- package/dist/esm/ad-sizes.js +17 -5
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/lib/get-locale.d.ts +8 -0
- package/dist/esm/lib/get-locale.js +38 -0
- package/dist/esm/targeting/build-page-targeting-consentless.d.ts +1 -3
- package/dist/esm/targeting/build-page-targeting-consentless.js +2 -3
- package/dist/esm/targeting/build-page-targeting.d.ts +1 -1
- package/dist/esm/targeting/build-page-targeting.js +3 -2
- package/dist/esm/types.d.ts +2 -1
- package/package.json +1 -1
package/dist/cjs/ad-sizes.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare class AdSize extends Array<number> {
|
|
|
23
23
|
constructor([width, height]: [number, number]);
|
|
24
24
|
toString(): AdSizeString;
|
|
25
25
|
toArray(): number[];
|
|
26
|
+
isProxy(): boolean;
|
|
26
27
|
get width(): number;
|
|
27
28
|
get height(): number;
|
|
28
29
|
}
|
|
@@ -39,6 +40,11 @@ declare const standardAdSizes: {
|
|
|
39
40
|
'300x1050': AdSize;
|
|
40
41
|
'160x600': AdSize;
|
|
41
42
|
};
|
|
43
|
+
declare const outstreamSizes: {
|
|
44
|
+
outstreamDesktop: AdSize;
|
|
45
|
+
outstreamGoogleDesktop: AdSize;
|
|
46
|
+
outstreamMobile: AdSize;
|
|
47
|
+
};
|
|
42
48
|
declare const adSizes: Record<SizeKeys, AdSize>;
|
|
43
49
|
/**
|
|
44
50
|
* mark: 432b3a46-90c1-4573-90d3-2400b51af8d0
|
|
@@ -51,4 +57,4 @@ export declare const _: {
|
|
|
51
57
|
createAdSize: (width: number, height: number) => AdSize;
|
|
52
58
|
};
|
|
53
59
|
export type { AdSizeString, AdSize, SizeKeys, SizeMapping, SlotSizeMappings, SlotName, };
|
|
54
|
-
export { adSizes, standardAdSizes, getAdSize, slotSizeMappings, createAdSize };
|
|
60
|
+
export { adSizes, standardAdSizes, outstreamSizes, getAdSize, slotSizeMappings, createAdSize, };
|
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.createAdSize = exports.slotSizeMappings = exports.getAdSize = exports.standardAdSizes = exports.adSizes = exports._ = void 0;
|
|
3
|
+
exports.createAdSize = exports.slotSizeMappings = exports.getAdSize = exports.outstreamSizes = 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.
|
|
@@ -32,6 +32,15 @@ class AdSize extends Array {
|
|
|
32
32
|
toArray() {
|
|
33
33
|
return [this[0], this[1]];
|
|
34
34
|
}
|
|
35
|
+
// The advert size is not reflective of the actual size of the advert.
|
|
36
|
+
// For example, fluid ads and Guardian merch ads are larger than the dimensions
|
|
37
|
+
isProxy() {
|
|
38
|
+
const isOutOfPage = this.width === 1 && this.height === 1;
|
|
39
|
+
const isEmpty = this.width === 2 && this.height === 2;
|
|
40
|
+
const isFluid = this.toString() === 'fluid';
|
|
41
|
+
const isMerch = this.width === 88;
|
|
42
|
+
return isOutOfPage || isEmpty || isFluid || isMerch;
|
|
43
|
+
}
|
|
35
44
|
get width() {
|
|
36
45
|
return this[0];
|
|
37
46
|
}
|
|
@@ -51,6 +60,7 @@ const namedStandardAdSizes = {
|
|
|
51
60
|
mpu: createAdSize(300, 250),
|
|
52
61
|
portrait: createAdSize(300, 1050),
|
|
53
62
|
skyscraper: createAdSize(160, 600),
|
|
63
|
+
cascade: createAdSize(940, 230),
|
|
54
64
|
};
|
|
55
65
|
const standardAdSizes = {
|
|
56
66
|
'970x250': namedStandardAdSizes.billboard,
|
|
@@ -61,6 +71,12 @@ const standardAdSizes = {
|
|
|
61
71
|
'160x600': namedStandardAdSizes.skyscraper,
|
|
62
72
|
};
|
|
63
73
|
exports.standardAdSizes = standardAdSizes;
|
|
74
|
+
const outstreamSizes = {
|
|
75
|
+
outstreamDesktop: createAdSize(620, 350),
|
|
76
|
+
outstreamGoogleDesktop: createAdSize(550, 310),
|
|
77
|
+
outstreamMobile: createAdSize(300, 197),
|
|
78
|
+
};
|
|
79
|
+
exports.outstreamSizes = outstreamSizes;
|
|
64
80
|
const dfpProprietaryAdSizes = {
|
|
65
81
|
fluid: createAdSize(0, 0),
|
|
66
82
|
googleCard: createAdSize(300, 274),
|
|
@@ -73,14 +89,11 @@ const guardianProprietaryAdSizes = {
|
|
|
73
89
|
merchandising: createAdSize(88, 88),
|
|
74
90
|
merchandisingHigh: createAdSize(88, 87),
|
|
75
91
|
merchandisingHighAdFeature: createAdSize(88, 89),
|
|
76
|
-
outstreamDesktop: createAdSize(620, 350),
|
|
77
|
-
outstreamGoogleDesktop: createAdSize(550, 310),
|
|
78
|
-
outstreamMobile: createAdSize(300, 197),
|
|
79
|
-
cascade: createAdSize(940, 230),
|
|
80
92
|
};
|
|
81
93
|
const adSizes = {
|
|
82
94
|
...namedStandardAdSizes,
|
|
83
95
|
...standardAdSizes,
|
|
96
|
+
...outstreamSizes,
|
|
84
97
|
...dfpProprietaryAdSizes,
|
|
85
98
|
...guardianProprietaryAdSizes,
|
|
86
99
|
};
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -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,
|
|
10
|
+
export { adSizes, createAdSize, getAdSize, outstreamSizes, slotSizeMappings, standardAdSizes, } 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';
|
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.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.
|
|
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.standardAdSizes = exports.slotSizeMappings = exports.outstreamSizes = exports.getAdSize = exports.createAdSize = 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,10 +44,11 @@ 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, "
|
|
47
|
+
Object.defineProperty(exports, "createAdSize", { enumerable: true, get: function () { return ad_sizes_1.createAdSize; } });
|
|
48
48
|
Object.defineProperty(exports, "getAdSize", { enumerable: true, get: function () { return ad_sizes_1.getAdSize; } });
|
|
49
|
+
Object.defineProperty(exports, "outstreamSizes", { enumerable: true, get: function () { return ad_sizes_1.outstreamSizes; } });
|
|
49
50
|
Object.defineProperty(exports, "slotSizeMappings", { enumerable: true, get: function () { return ad_sizes_1.slotSizeMappings; } });
|
|
50
|
-
Object.defineProperty(exports, "
|
|
51
|
+
Object.defineProperty(exports, "standardAdSizes", { enumerable: true, get: function () { return ad_sizes_1.standardAdSizes; } });
|
|
51
52
|
var breakpoint_1 = require("./lib/breakpoint");
|
|
52
53
|
Object.defineProperty(exports, "isBreakpoint", { enumerable: true, get: function () { return breakpoint_1.isBreakpoint; } });
|
|
53
54
|
var detect_ad_blocker_1 = require("./detect-ad-blocker");
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CountryCode } from '@guardian/libs';
|
|
2
|
+
export declare const __resetCachedValue: () => void;
|
|
3
|
+
/**
|
|
4
|
+
* Fetches the user's current location as an ISO 3166-1 alpha-2 string e.g. 'GB', 'AU' etc
|
|
5
|
+
* Note: This has been copied from guardian-libs and made syncronous by ommiting the call to
|
|
6
|
+
* the geolocation API
|
|
7
|
+
*/
|
|
8
|
+
export declare const getLocale: () => CountryCode;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLocale = exports.__resetCachedValue = void 0;
|
|
4
|
+
const libs_1 = require("@guardian/libs");
|
|
5
|
+
const KEY = 'GU_geo_country';
|
|
6
|
+
const KEY_OVERRIDE = 'gu.geo.override';
|
|
7
|
+
const COUNTRY_REGEX = /^[A-Z]{2}$/;
|
|
8
|
+
// best guess that we have a valid code, without actually shipping the entire list
|
|
9
|
+
const isValidCountryCode = (country) => (0, libs_1.isString)(country) && COUNTRY_REGEX.test(country);
|
|
10
|
+
// we'll cache any successful lookups so we only have to do this once
|
|
11
|
+
let locale;
|
|
12
|
+
const editionToGeolocationMap = {
|
|
13
|
+
UK: 'GB',
|
|
14
|
+
US: 'US',
|
|
15
|
+
AU: 'AU',
|
|
16
|
+
};
|
|
17
|
+
const editionToGeolocation = (editionKey) => editionToGeolocationMap[editionKey];
|
|
18
|
+
// just used for tests
|
|
19
|
+
const __resetCachedValue = () => (locale = undefined);
|
|
20
|
+
exports.__resetCachedValue = __resetCachedValue;
|
|
21
|
+
/**
|
|
22
|
+
* Fetches the user's current location as an ISO 3166-1 alpha-2 string e.g. 'GB', 'AU' etc
|
|
23
|
+
* Note: This has been copied from guardian-libs and made syncronous by ommiting the call to
|
|
24
|
+
* the geolocation API
|
|
25
|
+
*/
|
|
26
|
+
const getLocale = () => {
|
|
27
|
+
if (locale)
|
|
28
|
+
return locale;
|
|
29
|
+
// return overridden geo from localStorage, used for changing geo only for development purposes
|
|
30
|
+
const geoOverride = libs_1.storage.local.get(KEY_OVERRIDE);
|
|
31
|
+
if (isValidCountryCode(geoOverride)) {
|
|
32
|
+
return (locale = geoOverride);
|
|
33
|
+
}
|
|
34
|
+
// return locale from cookie if it exists
|
|
35
|
+
const stored = (0, libs_1.getCookie)({ name: KEY });
|
|
36
|
+
if (stored && isValidCountryCode(stored)) {
|
|
37
|
+
return (locale = stored);
|
|
38
|
+
}
|
|
39
|
+
// return locale from edition
|
|
40
|
+
const editionCountryCode = editionToGeolocation(window.guardian.config.page.edition);
|
|
41
|
+
return (locale = editionCountryCode);
|
|
42
|
+
};
|
|
43
|
+
exports.getLocale = getLocale;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Participations } from '@guardian/ab-core';
|
|
2
2
|
import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
|
|
3
|
-
import type { CountryCode } from '@guardian/libs';
|
|
4
3
|
import type { PageTargeting } from './build-page-targeting';
|
|
5
4
|
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
5
|
declare type ConsentlessTargetingKeys = typeof consentlessTargetingKeys[number];
|
|
@@ -11,9 +10,8 @@ declare type ConsentlessPageTargeting = Partial<Pick<PageTargeting, ConsentlessT
|
|
|
11
10
|
*
|
|
12
11
|
* @param {ConsentState} consentState
|
|
13
12
|
* @param {boolean} adFree
|
|
14
|
-
* @param {CountryCode} countryCode
|
|
15
13
|
* @param {Participations} clientSideParticipations
|
|
16
14
|
* @returns ConsentlessPageTargeting
|
|
17
15
|
*/
|
|
18
|
-
declare const buildPageTargetingConsentless: (consentState: ConsentState, adFree: boolean,
|
|
16
|
+
declare const buildPageTargetingConsentless: (consentState: ConsentState, adFree: boolean, clientSideParticipations: Participations) => ConsentlessPageTargeting;
|
|
19
17
|
export { buildPageTargetingConsentless };
|
|
@@ -32,12 +32,11 @@ const isConsentlessKey = (key) => consentlessTargetingKeys.includes(key);
|
|
|
32
32
|
*
|
|
33
33
|
* @param {ConsentState} consentState
|
|
34
34
|
* @param {boolean} adFree
|
|
35
|
-
* @param {CountryCode} countryCode
|
|
36
35
|
* @param {Participations} clientSideParticipations
|
|
37
36
|
* @returns ConsentlessPageTargeting
|
|
38
37
|
*/
|
|
39
|
-
const buildPageTargetingConsentless = (consentState, adFree,
|
|
40
|
-
const consentedPageTargeting = (0, build_page_targeting_1.buildPageTargeting)(consentState, adFree,
|
|
38
|
+
const buildPageTargetingConsentless = (consentState, adFree, clientSideParticipations) => {
|
|
39
|
+
const consentedPageTargeting = (0, build_page_targeting_1.buildPageTargeting)(consentState, adFree, clientSideParticipations);
|
|
41
40
|
return Object.fromEntries(Object.entries(consentedPageTargeting).filter(([k]) => isConsentlessKey(k)));
|
|
42
41
|
};
|
|
43
42
|
exports.buildPageTargetingConsentless = buildPageTargetingConsentless;
|
|
@@ -34,6 +34,6 @@ declare type PageTargeting = PartialWithNulls<{
|
|
|
34
34
|
vl: string;
|
|
35
35
|
[_: string]: string | string[];
|
|
36
36
|
} & SharedTargeting>;
|
|
37
|
-
declare const buildPageTargeting: (consentState: ConsentState, adFree: boolean,
|
|
37
|
+
declare const buildPageTargeting: (consentState: ConsentState, adFree: boolean, clientSideParticipations: Participations) => PageTargeting;
|
|
38
38
|
export { buildPageTargeting };
|
|
39
39
|
export type { PageTargeting };
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.buildPageTargeting = void 0;
|
|
4
4
|
const consent_management_platform_1 = require("@guardian/consent-management-platform");
|
|
5
5
|
const libs_1 = require("@guardian/libs");
|
|
6
|
+
const get_locale_1 = require("../lib/get-locale");
|
|
6
7
|
const content_1 = require("./content");
|
|
7
8
|
const personalised_1 = require("./personalised");
|
|
8
9
|
const session_1 = require("./session");
|
|
@@ -23,7 +24,7 @@ const filterEmptyValues = (pageTargets) => {
|
|
|
23
24
|
}
|
|
24
25
|
return filtered;
|
|
25
26
|
};
|
|
26
|
-
const buildPageTargeting = (consentState, adFree,
|
|
27
|
+
const buildPageTargeting = (consentState, adFree, clientSideParticipations) => {
|
|
27
28
|
const { page, isDotcomRendering } = window.guardian.config;
|
|
28
29
|
const adFreeTargeting = adFree ? { af: 't' } : {};
|
|
29
30
|
const contentTargeting = (0, content_1.getContentTargeting)({
|
|
@@ -39,7 +40,7 @@ const buildPageTargeting = (consentState, adFree, countryCode, clientSidePartici
|
|
|
39
40
|
const getReferrer = () => document.referrer || '';
|
|
40
41
|
const sessionTargeting = (0, session_1.getSessionTargeting)({
|
|
41
42
|
adTest: (0, libs_1.getCookie)({ name: 'adtest', shouldMemoize: true }),
|
|
42
|
-
countryCode,
|
|
43
|
+
countryCode: (0, get_locale_1.getLocale)(),
|
|
43
44
|
isSignedIn: !!(0, libs_1.getCookie)({ name: 'GU_U' }),
|
|
44
45
|
pageViewId: window.guardian.config.ophan.pageViewId,
|
|
45
46
|
participations: {
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare type GetThirdPartyTag = (arg0: {
|
|
|
21
21
|
export declare type GuardianAnalyticsConfig = {
|
|
22
22
|
trackers: Record<string, string>;
|
|
23
23
|
};
|
|
24
|
+
export declare type Edition = 'UK' | 'AU' | 'US';
|
|
24
25
|
export declare type GuardianWindowConfig = {
|
|
25
26
|
googleAnalytics?: GuardianAnalyticsConfig;
|
|
26
27
|
isDotcomRendering: boolean;
|
|
@@ -30,11 +31,11 @@ export declare type GuardianWindowConfig = {
|
|
|
30
31
|
};
|
|
31
32
|
page: {
|
|
32
33
|
sharedAdTargeting?: Record<string, string | string[]>;
|
|
33
|
-
pageAdTargeting?: Record<string, string | string[]>;
|
|
34
34
|
isSensitive: boolean;
|
|
35
35
|
pageId: string;
|
|
36
36
|
section: string;
|
|
37
37
|
videoDuration: number;
|
|
38
|
+
edition: Edition;
|
|
38
39
|
};
|
|
39
40
|
tests?: {
|
|
40
41
|
[key: `${string}Control`]: 'control';
|
package/dist/esm/ad-sizes.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare class AdSize extends Array<number> {
|
|
|
23
23
|
constructor([width, height]: [number, number]);
|
|
24
24
|
toString(): AdSizeString;
|
|
25
25
|
toArray(): number[];
|
|
26
|
+
isProxy(): boolean;
|
|
26
27
|
get width(): number;
|
|
27
28
|
get height(): number;
|
|
28
29
|
}
|
|
@@ -39,6 +40,11 @@ declare const standardAdSizes: {
|
|
|
39
40
|
'300x1050': AdSize;
|
|
40
41
|
'160x600': AdSize;
|
|
41
42
|
};
|
|
43
|
+
declare const outstreamSizes: {
|
|
44
|
+
outstreamDesktop: AdSize;
|
|
45
|
+
outstreamGoogleDesktop: AdSize;
|
|
46
|
+
outstreamMobile: AdSize;
|
|
47
|
+
};
|
|
42
48
|
declare const adSizes: Record<SizeKeys, AdSize>;
|
|
43
49
|
/**
|
|
44
50
|
* mark: 432b3a46-90c1-4573-90d3-2400b51af8d0
|
|
@@ -51,4 +57,4 @@ export declare const _: {
|
|
|
51
57
|
createAdSize: (width: number, height: number) => AdSize;
|
|
52
58
|
};
|
|
53
59
|
export type { AdSizeString, AdSize, SizeKeys, SizeMapping, SlotSizeMappings, SlotName, };
|
|
54
|
-
export { adSizes, standardAdSizes, getAdSize, slotSizeMappings, createAdSize };
|
|
60
|
+
export { adSizes, standardAdSizes, outstreamSizes, getAdSize, slotSizeMappings, createAdSize, };
|
package/dist/esm/ad-sizes.js
CHANGED
|
@@ -29,6 +29,15 @@ class AdSize extends Array {
|
|
|
29
29
|
toArray() {
|
|
30
30
|
return [this[0], this[1]];
|
|
31
31
|
}
|
|
32
|
+
// The advert size is not reflective of the actual size of the advert.
|
|
33
|
+
// For example, fluid ads and Guardian merch ads are larger than the dimensions
|
|
34
|
+
isProxy() {
|
|
35
|
+
const isOutOfPage = this.width === 1 && this.height === 1;
|
|
36
|
+
const isEmpty = this.width === 2 && this.height === 2;
|
|
37
|
+
const isFluid = this.toString() === 'fluid';
|
|
38
|
+
const isMerch = this.width === 88;
|
|
39
|
+
return isOutOfPage || isEmpty || isFluid || isMerch;
|
|
40
|
+
}
|
|
32
41
|
get width() {
|
|
33
42
|
return this[0];
|
|
34
43
|
}
|
|
@@ -47,6 +56,7 @@ const namedStandardAdSizes = {
|
|
|
47
56
|
mpu: createAdSize(300, 250),
|
|
48
57
|
portrait: createAdSize(300, 1050),
|
|
49
58
|
skyscraper: createAdSize(160, 600),
|
|
59
|
+
cascade: createAdSize(940, 230),
|
|
50
60
|
};
|
|
51
61
|
const standardAdSizes = {
|
|
52
62
|
'970x250': namedStandardAdSizes.billboard,
|
|
@@ -56,6 +66,11 @@ const standardAdSizes = {
|
|
|
56
66
|
'300x1050': namedStandardAdSizes.portrait,
|
|
57
67
|
'160x600': namedStandardAdSizes.skyscraper,
|
|
58
68
|
};
|
|
69
|
+
const outstreamSizes = {
|
|
70
|
+
outstreamDesktop: createAdSize(620, 350),
|
|
71
|
+
outstreamGoogleDesktop: createAdSize(550, 310),
|
|
72
|
+
outstreamMobile: createAdSize(300, 197),
|
|
73
|
+
};
|
|
59
74
|
const dfpProprietaryAdSizes = {
|
|
60
75
|
fluid: createAdSize(0, 0),
|
|
61
76
|
googleCard: createAdSize(300, 274),
|
|
@@ -68,14 +83,11 @@ const guardianProprietaryAdSizes = {
|
|
|
68
83
|
merchandising: createAdSize(88, 88),
|
|
69
84
|
merchandisingHigh: createAdSize(88, 87),
|
|
70
85
|
merchandisingHighAdFeature: createAdSize(88, 89),
|
|
71
|
-
outstreamDesktop: createAdSize(620, 350),
|
|
72
|
-
outstreamGoogleDesktop: createAdSize(550, 310),
|
|
73
|
-
outstreamMobile: createAdSize(300, 197),
|
|
74
|
-
cascade: createAdSize(940, 230),
|
|
75
86
|
};
|
|
76
87
|
const adSizes = {
|
|
77
88
|
...namedStandardAdSizes,
|
|
78
89
|
...standardAdSizes,
|
|
90
|
+
...outstreamSizes,
|
|
79
91
|
...dfpProprietaryAdSizes,
|
|
80
92
|
...guardianProprietaryAdSizes,
|
|
81
93
|
};
|
|
@@ -257,4 +269,4 @@ const slotSizeMappings = {
|
|
|
257
269
|
const getAdSize = (size) => adSizes[size];
|
|
258
270
|
// Export for testing
|
|
259
271
|
export const _ = { createAdSize };
|
|
260
|
-
export { adSizes, standardAdSizes, getAdSize, slotSizeMappings, createAdSize };
|
|
272
|
+
export { adSizes, standardAdSizes, outstreamSizes, getAdSize, slotSizeMappings, createAdSize, };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -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,
|
|
10
|
+
export { adSizes, createAdSize, getAdSize, outstreamSizes, slotSizeMappings, standardAdSizes, } 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';
|
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,
|
|
10
|
+
export { adSizes, createAdSize, getAdSize, outstreamSizes, slotSizeMappings, standardAdSizes, } 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';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CountryCode } from '@guardian/libs';
|
|
2
|
+
export declare const __resetCachedValue: () => void;
|
|
3
|
+
/**
|
|
4
|
+
* Fetches the user's current location as an ISO 3166-1 alpha-2 string e.g. 'GB', 'AU' etc
|
|
5
|
+
* Note: This has been copied from guardian-libs and made syncronous by ommiting the call to
|
|
6
|
+
* the geolocation API
|
|
7
|
+
*/
|
|
8
|
+
export declare const getLocale: () => CountryCode;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getCookie, isString, storage } from '@guardian/libs';
|
|
2
|
+
const KEY = 'GU_geo_country';
|
|
3
|
+
const KEY_OVERRIDE = 'gu.geo.override';
|
|
4
|
+
const COUNTRY_REGEX = /^[A-Z]{2}$/;
|
|
5
|
+
// best guess that we have a valid code, without actually shipping the entire list
|
|
6
|
+
const isValidCountryCode = (country) => isString(country) && COUNTRY_REGEX.test(country);
|
|
7
|
+
// we'll cache any successful lookups so we only have to do this once
|
|
8
|
+
let locale;
|
|
9
|
+
const editionToGeolocationMap = {
|
|
10
|
+
UK: 'GB',
|
|
11
|
+
US: 'US',
|
|
12
|
+
AU: 'AU',
|
|
13
|
+
};
|
|
14
|
+
const editionToGeolocation = (editionKey) => editionToGeolocationMap[editionKey];
|
|
15
|
+
// just used for tests
|
|
16
|
+
export const __resetCachedValue = () => (locale = undefined);
|
|
17
|
+
/**
|
|
18
|
+
* Fetches the user's current location as an ISO 3166-1 alpha-2 string e.g. 'GB', 'AU' etc
|
|
19
|
+
* Note: This has been copied from guardian-libs and made syncronous by ommiting the call to
|
|
20
|
+
* the geolocation API
|
|
21
|
+
*/
|
|
22
|
+
export const getLocale = () => {
|
|
23
|
+
if (locale)
|
|
24
|
+
return locale;
|
|
25
|
+
// return overridden geo from localStorage, used for changing geo only for development purposes
|
|
26
|
+
const geoOverride = storage.local.get(KEY_OVERRIDE);
|
|
27
|
+
if (isValidCountryCode(geoOverride)) {
|
|
28
|
+
return (locale = geoOverride);
|
|
29
|
+
}
|
|
30
|
+
// return locale from cookie if it exists
|
|
31
|
+
const stored = getCookie({ name: KEY });
|
|
32
|
+
if (stored && isValidCountryCode(stored)) {
|
|
33
|
+
return (locale = stored);
|
|
34
|
+
}
|
|
35
|
+
// return locale from edition
|
|
36
|
+
const editionCountryCode = editionToGeolocation(window.guardian.config.page.edition);
|
|
37
|
+
return (locale = editionCountryCode);
|
|
38
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Participations } from '@guardian/ab-core';
|
|
2
2
|
import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
|
|
3
|
-
import type { CountryCode } from '@guardian/libs';
|
|
4
3
|
import type { PageTargeting } from './build-page-targeting';
|
|
5
4
|
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
5
|
declare type ConsentlessTargetingKeys = typeof consentlessTargetingKeys[number];
|
|
@@ -11,9 +10,8 @@ declare type ConsentlessPageTargeting = Partial<Pick<PageTargeting, ConsentlessT
|
|
|
11
10
|
*
|
|
12
11
|
* @param {ConsentState} consentState
|
|
13
12
|
* @param {boolean} adFree
|
|
14
|
-
* @param {CountryCode} countryCode
|
|
15
13
|
* @param {Participations} clientSideParticipations
|
|
16
14
|
* @returns ConsentlessPageTargeting
|
|
17
15
|
*/
|
|
18
|
-
declare const buildPageTargetingConsentless: (consentState: ConsentState, adFree: boolean,
|
|
16
|
+
declare const buildPageTargetingConsentless: (consentState: ConsentState, adFree: boolean, clientSideParticipations: Participations) => ConsentlessPageTargeting;
|
|
19
17
|
export { buildPageTargetingConsentless };
|
|
@@ -29,12 +29,11 @@ const isConsentlessKey = (key) => consentlessTargetingKeys.includes(key);
|
|
|
29
29
|
*
|
|
30
30
|
* @param {ConsentState} consentState
|
|
31
31
|
* @param {boolean} adFree
|
|
32
|
-
* @param {CountryCode} countryCode
|
|
33
32
|
* @param {Participations} clientSideParticipations
|
|
34
33
|
* @returns ConsentlessPageTargeting
|
|
35
34
|
*/
|
|
36
|
-
const buildPageTargetingConsentless = (consentState, adFree,
|
|
37
|
-
const consentedPageTargeting = buildPageTargeting(consentState, adFree,
|
|
35
|
+
const buildPageTargetingConsentless = (consentState, adFree, clientSideParticipations) => {
|
|
36
|
+
const consentedPageTargeting = buildPageTargeting(consentState, adFree, clientSideParticipations);
|
|
38
37
|
return Object.fromEntries(Object.entries(consentedPageTargeting).filter(([k]) => isConsentlessKey(k)));
|
|
39
38
|
};
|
|
40
39
|
export { buildPageTargetingConsentless };
|
|
@@ -34,6 +34,6 @@ declare type PageTargeting = PartialWithNulls<{
|
|
|
34
34
|
vl: string;
|
|
35
35
|
[_: string]: string | string[];
|
|
36
36
|
} & SharedTargeting>;
|
|
37
|
-
declare const buildPageTargeting: (consentState: ConsentState, adFree: boolean,
|
|
37
|
+
declare const buildPageTargeting: (consentState: ConsentState, adFree: boolean, clientSideParticipations: Participations) => PageTargeting;
|
|
38
38
|
export { buildPageTargeting };
|
|
39
39
|
export type { PageTargeting };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cmp } from '@guardian/consent-management-platform';
|
|
2
2
|
import { getCookie, isString } from '@guardian/libs';
|
|
3
|
+
import { getLocale } from '../lib/get-locale';
|
|
3
4
|
import { getContentTargeting } from './content';
|
|
4
5
|
import { getPersonalisedTargeting } from './personalised';
|
|
5
6
|
import { getSessionTargeting } from './session';
|
|
@@ -20,7 +21,7 @@ const filterEmptyValues = (pageTargets) => {
|
|
|
20
21
|
}
|
|
21
22
|
return filtered;
|
|
22
23
|
};
|
|
23
|
-
const buildPageTargeting = (consentState, adFree,
|
|
24
|
+
const buildPageTargeting = (consentState, adFree, clientSideParticipations) => {
|
|
24
25
|
const { page, isDotcomRendering } = window.guardian.config;
|
|
25
26
|
const adFreeTargeting = adFree ? { af: 't' } : {};
|
|
26
27
|
const contentTargeting = getContentTargeting({
|
|
@@ -36,7 +37,7 @@ const buildPageTargeting = (consentState, adFree, countryCode, clientSidePartici
|
|
|
36
37
|
const getReferrer = () => document.referrer || '';
|
|
37
38
|
const sessionTargeting = getSessionTargeting({
|
|
38
39
|
adTest: getCookie({ name: 'adtest', shouldMemoize: true }),
|
|
39
|
-
countryCode,
|
|
40
|
+
countryCode: getLocale(),
|
|
40
41
|
isSignedIn: !!getCookie({ name: 'GU_U' }),
|
|
41
42
|
pageViewId: window.guardian.config.ophan.pageViewId,
|
|
42
43
|
participations: {
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare type GetThirdPartyTag = (arg0: {
|
|
|
21
21
|
export declare type GuardianAnalyticsConfig = {
|
|
22
22
|
trackers: Record<string, string>;
|
|
23
23
|
};
|
|
24
|
+
export declare type Edition = 'UK' | 'AU' | 'US';
|
|
24
25
|
export declare type GuardianWindowConfig = {
|
|
25
26
|
googleAnalytics?: GuardianAnalyticsConfig;
|
|
26
27
|
isDotcomRendering: boolean;
|
|
@@ -30,11 +31,11 @@ export declare type GuardianWindowConfig = {
|
|
|
30
31
|
};
|
|
31
32
|
page: {
|
|
32
33
|
sharedAdTargeting?: Record<string, string | string[]>;
|
|
33
|
-
pageAdTargeting?: Record<string, string | string[]>;
|
|
34
34
|
isSensitive: boolean;
|
|
35
35
|
pageId: string;
|
|
36
36
|
section: string;
|
|
37
37
|
videoDuration: number;
|
|
38
|
+
edition: Edition;
|
|
38
39
|
};
|
|
39
40
|
tests?: {
|
|
40
41
|
[key: `${string}Control`]: 'control';
|