@guardian/commercial-core 4.18.0 → 4.20.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/README.md +0 -6
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +1 -3
- package/dist/cjs/lib/ab-localstorage.d.ts +2 -0
- package/dist/cjs/lib/ab-localstorage.js +14 -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 -2
- package/dist/cjs/targeting/build-page-targeting.js +3 -2
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/lib/ab-localstorage.d.ts +2 -0
- package/dist/esm/lib/ab-localstorage.js +10 -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 -2
- package/dist/esm/targeting/build-page-targeting.js +3 -2
- package/package.json +1 -1
- package/dist/cjs/third-party-tags/facebook-pixel.d.ts +0 -7
- package/dist/cjs/third-party-tags/facebook-pixel.js +0 -15
- package/dist/esm/third-party-tags/facebook-pixel.d.ts +0 -7
- package/dist/esm/third-party-tags/facebook-pixel.js +0 -11
package/README.md
CHANGED
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { ias } from './third-party-tags/ias';
|
|
2
2
|
export { permutive } from './third-party-tags/permutive';
|
|
3
|
-
export { fbPixel } from './third-party-tags/facebook-pixel';
|
|
4
3
|
export { twitter } from './third-party-tags/twitter-uwt';
|
|
5
4
|
export { inizio } from './third-party-tags/inizio';
|
|
6
5
|
export { remarketing } from './third-party-tags/remarketing';
|
package/dist/cjs/index.js
CHANGED
|
@@ -24,13 +24,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.pubmatic = exports.launchpad = exports.ipsosMoriStub = exports.a9Apstag = 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.
|
|
27
|
+
exports.pubmatic = exports.launchpad = exports.ipsosMoriStub = exports.a9Apstag = 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.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");
|
|
31
31
|
Object.defineProperty(exports, "permutive", { enumerable: true, get: function () { return permutive_1.permutive; } });
|
|
32
|
-
var facebook_pixel_1 = require("./third-party-tags/facebook-pixel");
|
|
33
|
-
Object.defineProperty(exports, "fbPixel", { enumerable: true, get: function () { return facebook_pixel_1.fbPixel; } });
|
|
34
32
|
var twitter_uwt_1 = require("./third-party-tags/twitter-uwt");
|
|
35
33
|
Object.defineProperty(exports, "twitter", { enumerable: true, get: function () { return twitter_uwt_1.twitter; } });
|
|
36
34
|
var inizio_1 = require("./third-party-tags/inizio");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getParticipationsFromLocalStorage = void 0;
|
|
4
|
+
const libs_1 = require("@guardian/libs");
|
|
5
|
+
const participationsKey = 'gu.ab.participations';
|
|
6
|
+
const isParticipations = (participations) => {
|
|
7
|
+
return ((0, libs_1.isObject)(participations) &&
|
|
8
|
+
Object.values(participations).every((participation) => (0, libs_1.isObject)(participation) && (0, libs_1.isString)(participation.variant)));
|
|
9
|
+
};
|
|
10
|
+
const getParticipationsFromLocalStorage = () => {
|
|
11
|
+
const participations = libs_1.storage.local.get(participationsKey);
|
|
12
|
+
return isParticipations(participations) ? participations : {};
|
|
13
|
+
};
|
|
14
|
+
exports.getParticipationsFromLocalStorage = getParticipationsFromLocalStorage;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Participations } from '@guardian/ab-core';
|
|
2
1
|
import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
|
|
3
2
|
import type { PageTargeting } from './build-page-targeting';
|
|
4
3
|
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"];
|
|
@@ -10,8 +9,7 @@ declare type ConsentlessPageTargeting = Partial<Pick<PageTargeting, ConsentlessT
|
|
|
10
9
|
*
|
|
11
10
|
* @param {ConsentState} consentState
|
|
12
11
|
* @param {boolean} adFree
|
|
13
|
-
* @param {Participations} clientSideParticipations
|
|
14
12
|
* @returns ConsentlessPageTargeting
|
|
15
13
|
*/
|
|
16
|
-
declare const buildPageTargetingConsentless: (consentState: ConsentState, adFree: boolean
|
|
14
|
+
declare const buildPageTargetingConsentless: (consentState: ConsentState, adFree: boolean) => ConsentlessPageTargeting;
|
|
17
15
|
export { buildPageTargetingConsentless };
|
|
@@ -32,11 +32,10 @@ const isConsentlessKey = (key) => consentlessTargetingKeys.includes(key);
|
|
|
32
32
|
*
|
|
33
33
|
* @param {ConsentState} consentState
|
|
34
34
|
* @param {boolean} adFree
|
|
35
|
-
* @param {Participations} clientSideParticipations
|
|
36
35
|
* @returns ConsentlessPageTargeting
|
|
37
36
|
*/
|
|
38
|
-
const buildPageTargetingConsentless = (consentState, adFree
|
|
39
|
-
const consentedPageTargeting = (0, build_page_targeting_1.buildPageTargeting)(consentState, adFree
|
|
37
|
+
const buildPageTargetingConsentless = (consentState, adFree) => {
|
|
38
|
+
const consentedPageTargeting = (0, build_page_targeting_1.buildPageTargeting)(consentState, adFree);
|
|
40
39
|
return Object.fromEntries(Object.entries(consentedPageTargeting).filter(([k]) => isConsentlessKey(k)));
|
|
41
40
|
};
|
|
42
41
|
exports.buildPageTargetingConsentless = buildPageTargetingConsentless;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Participations } from '@guardian/ab-core';
|
|
2
1
|
import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
|
|
3
2
|
import type { CountryCode } from '@guardian/libs';
|
|
4
3
|
import type { False, True } from '../types';
|
|
@@ -34,6 +33,6 @@ declare type PageTargeting = PartialWithNulls<{
|
|
|
34
33
|
vl: string;
|
|
35
34
|
[_: string]: string | string[];
|
|
36
35
|
} & SharedTargeting>;
|
|
37
|
-
declare const buildPageTargeting: (consentState: ConsentState, adFree: boolean
|
|
36
|
+
declare const buildPageTargeting: (consentState: ConsentState, adFree: boolean) => PageTargeting;
|
|
38
37
|
export { buildPageTargeting };
|
|
39
38
|
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 ab_localstorage_1 = require("../lib/ab-localstorage");
|
|
6
7
|
const get_locale_1 = require("../lib/get-locale");
|
|
7
8
|
const content_1 = require("./content");
|
|
8
9
|
const personalised_1 = require("./personalised");
|
|
@@ -24,7 +25,7 @@ const filterEmptyValues = (pageTargets) => {
|
|
|
24
25
|
}
|
|
25
26
|
return filtered;
|
|
26
27
|
};
|
|
27
|
-
const buildPageTargeting = (consentState, adFree
|
|
28
|
+
const buildPageTargeting = (consentState, adFree) => {
|
|
28
29
|
const { page, isDotcomRendering } = window.guardian.config;
|
|
29
30
|
const adFreeTargeting = adFree ? { af: 't' } : {};
|
|
30
31
|
const contentTargeting = (0, content_1.getContentTargeting)({
|
|
@@ -44,7 +45,7 @@ const buildPageTargeting = (consentState, adFree, clientSideParticipations) => {
|
|
|
44
45
|
isSignedIn: !!(0, libs_1.getCookie)({ name: 'GU_U' }),
|
|
45
46
|
pageViewId: window.guardian.config.ophan.pageViewId,
|
|
46
47
|
participations: {
|
|
47
|
-
clientSideParticipations,
|
|
48
|
+
clientSideParticipations: (0, ab_localstorage_1.getParticipationsFromLocalStorage)(),
|
|
48
49
|
serverSideParticipations: window.guardian.config.tests ?? {},
|
|
49
50
|
},
|
|
50
51
|
referrer: getReferrer(),
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { ias } from './third-party-tags/ias';
|
|
2
2
|
export { permutive } from './third-party-tags/permutive';
|
|
3
|
-
export { fbPixel } from './third-party-tags/facebook-pixel';
|
|
4
3
|
export { twitter } from './third-party-tags/twitter-uwt';
|
|
5
4
|
export { inizio } from './third-party-tags/inizio';
|
|
6
5
|
export { remarketing } from './third-party-tags/remarketing';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* istanbul ignore file -- there's no point check this for test coverage */
|
|
2
2
|
export { ias } from './third-party-tags/ias';
|
|
3
3
|
export { permutive } from './third-party-tags/permutive';
|
|
4
|
-
export { fbPixel } from './third-party-tags/facebook-pixel';
|
|
5
4
|
export { twitter } from './third-party-tags/twitter-uwt';
|
|
6
5
|
export { inizio } from './third-party-tags/inizio';
|
|
7
6
|
export { remarketing } from './third-party-tags/remarketing';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isObject, isString, storage } from '@guardian/libs';
|
|
2
|
+
const participationsKey = 'gu.ab.participations';
|
|
3
|
+
const isParticipations = (participations) => {
|
|
4
|
+
return (isObject(participations) &&
|
|
5
|
+
Object.values(participations).every((participation) => isObject(participation) && isString(participation.variant)));
|
|
6
|
+
};
|
|
7
|
+
export const getParticipationsFromLocalStorage = () => {
|
|
8
|
+
const participations = storage.local.get(participationsKey);
|
|
9
|
+
return isParticipations(participations) ? participations : {};
|
|
10
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Participations } from '@guardian/ab-core';
|
|
2
1
|
import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
|
|
3
2
|
import type { PageTargeting } from './build-page-targeting';
|
|
4
3
|
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"];
|
|
@@ -10,8 +9,7 @@ declare type ConsentlessPageTargeting = Partial<Pick<PageTargeting, ConsentlessT
|
|
|
10
9
|
*
|
|
11
10
|
* @param {ConsentState} consentState
|
|
12
11
|
* @param {boolean} adFree
|
|
13
|
-
* @param {Participations} clientSideParticipations
|
|
14
12
|
* @returns ConsentlessPageTargeting
|
|
15
13
|
*/
|
|
16
|
-
declare const buildPageTargetingConsentless: (consentState: ConsentState, adFree: boolean
|
|
14
|
+
declare const buildPageTargetingConsentless: (consentState: ConsentState, adFree: boolean) => ConsentlessPageTargeting;
|
|
17
15
|
export { buildPageTargetingConsentless };
|
|
@@ -29,11 +29,10 @@ const isConsentlessKey = (key) => consentlessTargetingKeys.includes(key);
|
|
|
29
29
|
*
|
|
30
30
|
* @param {ConsentState} consentState
|
|
31
31
|
* @param {boolean} adFree
|
|
32
|
-
* @param {Participations} clientSideParticipations
|
|
33
32
|
* @returns ConsentlessPageTargeting
|
|
34
33
|
*/
|
|
35
|
-
const buildPageTargetingConsentless = (consentState, adFree
|
|
36
|
-
const consentedPageTargeting = buildPageTargeting(consentState, adFree
|
|
34
|
+
const buildPageTargetingConsentless = (consentState, adFree) => {
|
|
35
|
+
const consentedPageTargeting = buildPageTargeting(consentState, adFree);
|
|
37
36
|
return Object.fromEntries(Object.entries(consentedPageTargeting).filter(([k]) => isConsentlessKey(k)));
|
|
38
37
|
};
|
|
39
38
|
export { buildPageTargetingConsentless };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Participations } from '@guardian/ab-core';
|
|
2
1
|
import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
|
|
3
2
|
import type { CountryCode } from '@guardian/libs';
|
|
4
3
|
import type { False, True } from '../types';
|
|
@@ -34,6 +33,6 @@ declare type PageTargeting = PartialWithNulls<{
|
|
|
34
33
|
vl: string;
|
|
35
34
|
[_: string]: string | string[];
|
|
36
35
|
} & SharedTargeting>;
|
|
37
|
-
declare const buildPageTargeting: (consentState: ConsentState, adFree: boolean
|
|
36
|
+
declare const buildPageTargeting: (consentState: ConsentState, adFree: boolean) => PageTargeting;
|
|
38
37
|
export { buildPageTargeting };
|
|
39
38
|
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 { getParticipationsFromLocalStorage } from '../lib/ab-localstorage';
|
|
3
4
|
import { getLocale } from '../lib/get-locale';
|
|
4
5
|
import { getContentTargeting } from './content';
|
|
5
6
|
import { getPersonalisedTargeting } from './personalised';
|
|
@@ -21,7 +22,7 @@ const filterEmptyValues = (pageTargets) => {
|
|
|
21
22
|
}
|
|
22
23
|
return filtered;
|
|
23
24
|
};
|
|
24
|
-
const buildPageTargeting = (consentState, adFree
|
|
25
|
+
const buildPageTargeting = (consentState, adFree) => {
|
|
25
26
|
const { page, isDotcomRendering } = window.guardian.config;
|
|
26
27
|
const adFreeTargeting = adFree ? { af: 't' } : {};
|
|
27
28
|
const contentTargeting = getContentTargeting({
|
|
@@ -41,7 +42,7 @@ const buildPageTargeting = (consentState, adFree, clientSideParticipations) => {
|
|
|
41
42
|
isSignedIn: !!getCookie({ name: 'GU_U' }),
|
|
42
43
|
pageViewId: window.guardian.config.ophan.pageViewId,
|
|
43
44
|
participations: {
|
|
44
|
-
clientSideParticipations,
|
|
45
|
+
clientSideParticipations: getParticipationsFromLocalStorage(),
|
|
45
46
|
serverSideParticipations: window.guardian.config.tests ?? {},
|
|
46
47
|
},
|
|
47
48
|
referrer: getReferrer(),
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fbPixel = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* tracking pixel
|
|
6
|
-
* https://en-gb.facebook.com/business/learn/facebook-ads-pixel
|
|
7
|
-
* @param {} {shouldRun}
|
|
8
|
-
*/
|
|
9
|
-
const fbPixel = ({ shouldRun }) => ({
|
|
10
|
-
shouldRun,
|
|
11
|
-
url: `https://www.facebook.com/tr?id=279880532344561&ev=PageView&noscript=1`,
|
|
12
|
-
name: 'fb',
|
|
13
|
-
useImage: true,
|
|
14
|
-
});
|
|
15
|
-
exports.fbPixel = fbPixel;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tracking pixel
|
|
3
|
-
* https://en-gb.facebook.com/business/learn/facebook-ads-pixel
|
|
4
|
-
* @param {} {shouldRun}
|
|
5
|
-
*/
|
|
6
|
-
export const fbPixel = ({ shouldRun }) => ({
|
|
7
|
-
shouldRun,
|
|
8
|
-
url: `https://www.facebook.com/tr?id=279880532344561&ev=PageView&noscript=1`,
|
|
9
|
-
name: 'fb',
|
|
10
|
-
useImage: true,
|
|
11
|
-
});
|