@guardian/commercial-core 4.24.0 → 4.25.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/targeting/build-page-targeting-consentless.js +2 -1
- package/dist/cjs/targeting/build-page-targeting.d.ts +4 -2
- package/dist/cjs/targeting/build-page-targeting.js +2 -3
- package/dist/cjs/targeting/youtube-ima.d.ts +8 -1
- package/dist/cjs/targeting/youtube-ima.js +5 -4
- package/dist/cjs/targeting/youtube.d.ts +9 -1
- package/dist/cjs/targeting/youtube.js +5 -4
- package/dist/esm/targeting/build-page-targeting-consentless.js +2 -1
- package/dist/esm/targeting/build-page-targeting.d.ts +4 -2
- package/dist/esm/targeting/build-page-targeting.js +2 -3
- package/dist/esm/targeting/youtube-ima.d.ts +8 -1
- package/dist/esm/targeting/youtube-ima.js +5 -4
- package/dist/esm/targeting/youtube.d.ts +9 -1
- package/dist/esm/targeting/youtube.js +5 -4
- package/package.json +1 -1
|
@@ -36,8 +36,9 @@ const isConsentlessKey = (key) => consentlessTargetingKeys.includes(key);
|
|
|
36
36
|
*/
|
|
37
37
|
const buildPageTargetingConsentless = (consentState, adFree) => {
|
|
38
38
|
const consentedPageTargeting = (0, build_page_targeting_1.buildPageTargeting)({
|
|
39
|
-
consentState,
|
|
40
39
|
adFree,
|
|
40
|
+
consentState,
|
|
41
|
+
clientSideParticipations: {},
|
|
41
42
|
});
|
|
42
43
|
return Object.fromEntries(Object.entries(consentedPageTargeting).filter(([k]) => isConsentlessKey(k)));
|
|
43
44
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Participations } from '@guardian/ab-core';
|
|
1
2
|
import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
|
|
2
3
|
import type { CountryCode } from '@guardian/libs';
|
|
3
4
|
import type { False, True } from '../types';
|
|
@@ -35,10 +36,11 @@ declare type PageTargeting = PartialWithNulls<{
|
|
|
35
36
|
} & SharedTargeting>;
|
|
36
37
|
declare const filterValues: (pageTargets: Record<string, unknown>) => Record<string, string | string[]>;
|
|
37
38
|
declare type BuildPageTargetingParams = {
|
|
38
|
-
consentState: ConsentState;
|
|
39
39
|
adFree: boolean;
|
|
40
|
+
clientSideParticipations: Participations;
|
|
41
|
+
consentState: ConsentState;
|
|
40
42
|
youtube?: boolean;
|
|
41
43
|
};
|
|
42
|
-
declare const buildPageTargeting: ({
|
|
44
|
+
declare const buildPageTargeting: ({ adFree, clientSideParticipations, consentState, youtube, }: BuildPageTargetingParams) => Record<string, string | string[]>;
|
|
43
45
|
export { buildPageTargeting, filterValues };
|
|
44
46
|
export type { PageTargeting };
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.filterValues = 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");
|
|
7
6
|
const get_locale_1 = require("../lib/get-locale");
|
|
8
7
|
const content_1 = require("./content");
|
|
9
8
|
const personalised_1 = require("./personalised");
|
|
@@ -26,7 +25,7 @@ const filterValues = (pageTargets) => {
|
|
|
26
25
|
return filtered;
|
|
27
26
|
};
|
|
28
27
|
exports.filterValues = filterValues;
|
|
29
|
-
const buildPageTargeting = ({
|
|
28
|
+
const buildPageTargeting = ({ adFree, clientSideParticipations, consentState, youtube = false, }) => {
|
|
30
29
|
const { page, isDotcomRendering } = window.guardian.config;
|
|
31
30
|
const adFreeTargeting = adFree ? { af: 't' } : {};
|
|
32
31
|
const contentTargeting = (0, content_1.getContentTargeting)({
|
|
@@ -46,7 +45,7 @@ const buildPageTargeting = ({ consentState, adFree, youtube = false, }) => {
|
|
|
46
45
|
isSignedIn: !!(0, libs_1.getCookie)({ name: 'GU_U' }),
|
|
47
46
|
pageViewId: window.guardian.config.ophan.pageViewId,
|
|
48
47
|
participations: {
|
|
49
|
-
clientSideParticipations
|
|
48
|
+
clientSideParticipations,
|
|
50
49
|
serverSideParticipations: window.guardian.config.tests ?? {},
|
|
51
50
|
},
|
|
52
51
|
referrer: getReferrer(),
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
import type { Participations } from '@guardian/ab-core';
|
|
1
2
|
import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
|
|
2
3
|
import type { CustomParams } from '../types';
|
|
3
|
-
declare
|
|
4
|
+
declare type BuildImaAdTagUrl = {
|
|
5
|
+
adUnit: string;
|
|
6
|
+
customParams: CustomParams;
|
|
7
|
+
consentState: ConsentState;
|
|
8
|
+
clientSideParticipations: Participations;
|
|
9
|
+
};
|
|
10
|
+
declare const buildImaAdTagUrl: ({ adUnit, clientSideParticipations, consentState, customParams, }: BuildImaAdTagUrl) => string;
|
|
4
11
|
export { buildImaAdTagUrl };
|
|
@@ -18,12 +18,13 @@ const encodeCustomParams = (params) => {
|
|
|
18
18
|
.join('&');
|
|
19
19
|
return encodedParams;
|
|
20
20
|
};
|
|
21
|
-
const mergeCustomParamsWithTargeting = (customParams, consentState) => {
|
|
21
|
+
const mergeCustomParamsWithTargeting = (customParams, consentState, clientSideParticipations) => {
|
|
22
22
|
let pageTargeting = {};
|
|
23
23
|
try {
|
|
24
24
|
pageTargeting = (0, build_page_targeting_1.buildPageTargeting)({
|
|
25
|
-
consentState: consentState,
|
|
26
25
|
adFree: false,
|
|
26
|
+
clientSideParticipations,
|
|
27
|
+
consentState: consentState,
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
catch (e) {
|
|
@@ -38,8 +39,8 @@ const mergeCustomParamsWithTargeting = (customParams, consentState) => {
|
|
|
38
39
|
const mergedCustomParams = { ...customParams, ...pageTargeting };
|
|
39
40
|
return mergedCustomParams;
|
|
40
41
|
};
|
|
41
|
-
const buildImaAdTagUrl = (adUnit, customParams,
|
|
42
|
-
const mergedCustomParams = mergeCustomParamsWithTargeting(customParams, consentState);
|
|
42
|
+
const buildImaAdTagUrl = ({ adUnit, clientSideParticipations, consentState, customParams, }) => {
|
|
43
|
+
const mergedCustomParams = mergeCustomParamsWithTargeting(customParams, consentState, clientSideParticipations);
|
|
43
44
|
const queryParams = {
|
|
44
45
|
iu: adUnit,
|
|
45
46
|
tfcd: '0',
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
import type { Participations } from '@guardian/ab-core';
|
|
1
2
|
import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
|
|
2
3
|
import type { AdsConfig, AdsConfigDisabled, CustomParams } from '../types';
|
|
3
4
|
declare const disabledAds: AdsConfigDisabled;
|
|
4
|
-
declare
|
|
5
|
+
declare type BuildAdsConfigWithConsent = {
|
|
6
|
+
isAdFreeUser: boolean;
|
|
7
|
+
adUnit: string;
|
|
8
|
+
customParams: CustomParams;
|
|
9
|
+
consentState: ConsentState;
|
|
10
|
+
clientSideParticipations: Participations;
|
|
11
|
+
};
|
|
12
|
+
declare const buildAdsConfigWithConsent: ({ adUnit, clientSideParticipations, consentState, customParams, isAdFreeUser, }: BuildAdsConfigWithConsent) => AdsConfig;
|
|
5
13
|
export { buildAdsConfigWithConsent, disabledAds };
|
|
@@ -5,12 +5,13 @@ const construct_query_1 = require("../lib/construct-query");
|
|
|
5
5
|
const build_page_targeting_1 = require("./build-page-targeting");
|
|
6
6
|
const disabledAds = { disableAds: true };
|
|
7
7
|
exports.disabledAds = disabledAds;
|
|
8
|
-
const buildAdsConfig = (cmpConsent, adUnit, customParams) => {
|
|
8
|
+
const buildAdsConfig = (cmpConsent, adUnit, customParams, clientSideParticipations) => {
|
|
9
9
|
const mergedCustomParams = {
|
|
10
10
|
...customParams,
|
|
11
11
|
...(0, build_page_targeting_1.buildPageTargeting)({
|
|
12
|
-
consentState: cmpConsent,
|
|
13
12
|
adFree: false,
|
|
13
|
+
clientSideParticipations,
|
|
14
|
+
consentState: cmpConsent,
|
|
14
15
|
youtube: true,
|
|
15
16
|
}),
|
|
16
17
|
};
|
|
@@ -52,10 +53,10 @@ const buildAdsConfig = (cmpConsent, adUnit, customParams) => {
|
|
|
52
53
|
// Shouldn't happen but handle if no matching framework
|
|
53
54
|
return disabledAds;
|
|
54
55
|
};
|
|
55
|
-
const buildAdsConfigWithConsent = (
|
|
56
|
+
const buildAdsConfigWithConsent = ({ adUnit, clientSideParticipations, consentState, customParams, isAdFreeUser, }) => {
|
|
56
57
|
if (isAdFreeUser) {
|
|
57
58
|
return disabledAds;
|
|
58
59
|
}
|
|
59
|
-
return buildAdsConfig(consentState, adUnit,
|
|
60
|
+
return buildAdsConfig(consentState, adUnit, customParams, clientSideParticipations);
|
|
60
61
|
};
|
|
61
62
|
exports.buildAdsConfigWithConsent = buildAdsConfigWithConsent;
|
|
@@ -33,8 +33,9 @@ const isConsentlessKey = (key) => consentlessTargetingKeys.includes(key);
|
|
|
33
33
|
*/
|
|
34
34
|
const buildPageTargetingConsentless = (consentState, adFree) => {
|
|
35
35
|
const consentedPageTargeting = buildPageTargeting({
|
|
36
|
-
consentState,
|
|
37
36
|
adFree,
|
|
37
|
+
consentState,
|
|
38
|
+
clientSideParticipations: {},
|
|
38
39
|
});
|
|
39
40
|
return Object.fromEntries(Object.entries(consentedPageTargeting).filter(([k]) => isConsentlessKey(k)));
|
|
40
41
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Participations } from '@guardian/ab-core';
|
|
1
2
|
import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
|
|
2
3
|
import type { CountryCode } from '@guardian/libs';
|
|
3
4
|
import type { False, True } from '../types';
|
|
@@ -35,10 +36,11 @@ declare type PageTargeting = PartialWithNulls<{
|
|
|
35
36
|
} & SharedTargeting>;
|
|
36
37
|
declare const filterValues: (pageTargets: Record<string, unknown>) => Record<string, string | string[]>;
|
|
37
38
|
declare type BuildPageTargetingParams = {
|
|
38
|
-
consentState: ConsentState;
|
|
39
39
|
adFree: boolean;
|
|
40
|
+
clientSideParticipations: Participations;
|
|
41
|
+
consentState: ConsentState;
|
|
40
42
|
youtube?: boolean;
|
|
41
43
|
};
|
|
42
|
-
declare const buildPageTargeting: ({
|
|
44
|
+
declare const buildPageTargeting: ({ adFree, clientSideParticipations, consentState, youtube, }: BuildPageTargetingParams) => Record<string, string | string[]>;
|
|
43
45
|
export { buildPageTargeting, filterValues };
|
|
44
46
|
export type { PageTargeting };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { cmp } from '@guardian/consent-management-platform';
|
|
2
2
|
import { getCookie, isString } from '@guardian/libs';
|
|
3
|
-
import { getParticipationsFromLocalStorage } from '../lib/ab-localstorage';
|
|
4
3
|
import { getLocale } from '../lib/get-locale';
|
|
5
4
|
import { getContentTargeting } from './content';
|
|
6
5
|
import { getPersonalisedTargeting } from './personalised';
|
|
@@ -22,7 +21,7 @@ const filterValues = (pageTargets) => {
|
|
|
22
21
|
}
|
|
23
22
|
return filtered;
|
|
24
23
|
};
|
|
25
|
-
const buildPageTargeting = ({
|
|
24
|
+
const buildPageTargeting = ({ adFree, clientSideParticipations, consentState, youtube = false, }) => {
|
|
26
25
|
const { page, isDotcomRendering } = window.guardian.config;
|
|
27
26
|
const adFreeTargeting = adFree ? { af: 't' } : {};
|
|
28
27
|
const contentTargeting = getContentTargeting({
|
|
@@ -42,7 +41,7 @@ const buildPageTargeting = ({ consentState, adFree, youtube = false, }) => {
|
|
|
42
41
|
isSignedIn: !!getCookie({ name: 'GU_U' }),
|
|
43
42
|
pageViewId: window.guardian.config.ophan.pageViewId,
|
|
44
43
|
participations: {
|
|
45
|
-
clientSideParticipations
|
|
44
|
+
clientSideParticipations,
|
|
46
45
|
serverSideParticipations: window.guardian.config.tests ?? {},
|
|
47
46
|
},
|
|
48
47
|
referrer: getReferrer(),
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
import type { Participations } from '@guardian/ab-core';
|
|
1
2
|
import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
|
|
2
3
|
import type { CustomParams } from '../types';
|
|
3
|
-
declare
|
|
4
|
+
declare type BuildImaAdTagUrl = {
|
|
5
|
+
adUnit: string;
|
|
6
|
+
customParams: CustomParams;
|
|
7
|
+
consentState: ConsentState;
|
|
8
|
+
clientSideParticipations: Participations;
|
|
9
|
+
};
|
|
10
|
+
declare const buildImaAdTagUrl: ({ adUnit, clientSideParticipations, consentState, customParams, }: BuildImaAdTagUrl) => string;
|
|
4
11
|
export { buildImaAdTagUrl };
|
|
@@ -15,12 +15,13 @@ const encodeCustomParams = (params) => {
|
|
|
15
15
|
.join('&');
|
|
16
16
|
return encodedParams;
|
|
17
17
|
};
|
|
18
|
-
const mergeCustomParamsWithTargeting = (customParams, consentState) => {
|
|
18
|
+
const mergeCustomParamsWithTargeting = (customParams, consentState, clientSideParticipations) => {
|
|
19
19
|
let pageTargeting = {};
|
|
20
20
|
try {
|
|
21
21
|
pageTargeting = buildPageTargeting({
|
|
22
|
-
consentState: consentState,
|
|
23
22
|
adFree: false,
|
|
23
|
+
clientSideParticipations,
|
|
24
|
+
consentState: consentState,
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
catch (e) {
|
|
@@ -35,8 +36,8 @@ const mergeCustomParamsWithTargeting = (customParams, consentState) => {
|
|
|
35
36
|
const mergedCustomParams = { ...customParams, ...pageTargeting };
|
|
36
37
|
return mergedCustomParams;
|
|
37
38
|
};
|
|
38
|
-
const buildImaAdTagUrl = (adUnit, customParams,
|
|
39
|
-
const mergedCustomParams = mergeCustomParamsWithTargeting(customParams, consentState);
|
|
39
|
+
const buildImaAdTagUrl = ({ adUnit, clientSideParticipations, consentState, customParams, }) => {
|
|
40
|
+
const mergedCustomParams = mergeCustomParamsWithTargeting(customParams, consentState, clientSideParticipations);
|
|
40
41
|
const queryParams = {
|
|
41
42
|
iu: adUnit,
|
|
42
43
|
tfcd: '0',
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
import type { Participations } from '@guardian/ab-core';
|
|
1
2
|
import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
|
|
2
3
|
import type { AdsConfig, AdsConfigDisabled, CustomParams } from '../types';
|
|
3
4
|
declare const disabledAds: AdsConfigDisabled;
|
|
4
|
-
declare
|
|
5
|
+
declare type BuildAdsConfigWithConsent = {
|
|
6
|
+
isAdFreeUser: boolean;
|
|
7
|
+
adUnit: string;
|
|
8
|
+
customParams: CustomParams;
|
|
9
|
+
consentState: ConsentState;
|
|
10
|
+
clientSideParticipations: Participations;
|
|
11
|
+
};
|
|
12
|
+
declare const buildAdsConfigWithConsent: ({ adUnit, clientSideParticipations, consentState, customParams, isAdFreeUser, }: BuildAdsConfigWithConsent) => AdsConfig;
|
|
5
13
|
export { buildAdsConfigWithConsent, disabledAds };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { constructQuery } from '../lib/construct-query';
|
|
2
2
|
import { buildPageTargeting } from './build-page-targeting';
|
|
3
3
|
const disabledAds = { disableAds: true };
|
|
4
|
-
const buildAdsConfig = (cmpConsent, adUnit, customParams) => {
|
|
4
|
+
const buildAdsConfig = (cmpConsent, adUnit, customParams, clientSideParticipations) => {
|
|
5
5
|
const mergedCustomParams = {
|
|
6
6
|
...customParams,
|
|
7
7
|
...buildPageTargeting({
|
|
8
|
-
consentState: cmpConsent,
|
|
9
8
|
adFree: false,
|
|
9
|
+
clientSideParticipations,
|
|
10
|
+
consentState: cmpConsent,
|
|
10
11
|
youtube: true,
|
|
11
12
|
}),
|
|
12
13
|
};
|
|
@@ -48,10 +49,10 @@ const buildAdsConfig = (cmpConsent, adUnit, customParams) => {
|
|
|
48
49
|
// Shouldn't happen but handle if no matching framework
|
|
49
50
|
return disabledAds;
|
|
50
51
|
};
|
|
51
|
-
const buildAdsConfigWithConsent = (
|
|
52
|
+
const buildAdsConfigWithConsent = ({ adUnit, clientSideParticipations, consentState, customParams, isAdFreeUser, }) => {
|
|
52
53
|
if (isAdFreeUser) {
|
|
53
54
|
return disabledAds;
|
|
54
55
|
}
|
|
55
|
-
return buildAdsConfig(consentState, adUnit,
|
|
56
|
+
return buildAdsConfig(consentState, adUnit, customParams, clientSideParticipations);
|
|
56
57
|
};
|
|
57
58
|
export { buildAdsConfigWithConsent, disabledAds };
|