@guardian/commercial-core 6.1.0 → 6.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.
- package/dist/cjs/targeting/build-page-targeting.d.ts +1 -0
- package/dist/cjs/targeting/build-page-targeting.js +4 -3
- package/dist/cjs/targeting/content.d.ts +10 -1
- package/dist/cjs/targeting/content.js +7 -2
- package/dist/cjs/targeting/youtube-ima.js +4 -1
- package/dist/cjs/targeting/youtube.js +2 -0
- package/dist/esm/targeting/build-page-targeting.d.ts +1 -0
- package/dist/esm/targeting/build-page-targeting.js +4 -3
- package/dist/esm/targeting/content.d.ts +10 -1
- package/dist/esm/targeting/content.js +7 -2
- package/dist/esm/targeting/youtube-ima.js +4 -1
- package/dist/esm/targeting/youtube.js +2 -0
- package/package.json +1 -1
|
@@ -33,6 +33,7 @@ type PageTargeting = PartialWithNulls<{
|
|
|
33
33
|
skinsize: 'l' | 's';
|
|
34
34
|
urlkw: string[];
|
|
35
35
|
vl: string;
|
|
36
|
+
allkw: string[];
|
|
36
37
|
[_: string]: string | string[];
|
|
37
38
|
} & SharedTargeting>;
|
|
38
39
|
declare const filterValues: (pageTargets: Record<string, unknown>) => Record<string, string | string[]>;
|
|
@@ -28,6 +28,9 @@ exports.filterValues = filterValues;
|
|
|
28
28
|
const buildPageTargeting = ({ adFree, clientSideParticipations, consentState, youtube = false, }) => {
|
|
29
29
|
const { page, isDotcomRendering } = window.guardian.config;
|
|
30
30
|
const adFreeTargeting = adFree ? { af: 't' } : {};
|
|
31
|
+
const sharedAdTargeting = page.sharedAdTargeting
|
|
32
|
+
? (0, shared_1.getSharedTargeting)(page.sharedAdTargeting)
|
|
33
|
+
: {};
|
|
31
34
|
const contentTargeting = (0, content_1.getContentTargeting)({
|
|
32
35
|
webPublicationDate: page.webPublicationDate,
|
|
33
36
|
eligibleForDCR: page.dcrCouldRender,
|
|
@@ -38,6 +41,7 @@ const buildPageTargeting = ({ adFree, clientSideParticipations, consentState, yo
|
|
|
38
41
|
section: page.section,
|
|
39
42
|
sensitive: page.isSensitive,
|
|
40
43
|
videoLength: page.videoDuration,
|
|
44
|
+
keywords: sharedAdTargeting.k ?? [],
|
|
41
45
|
});
|
|
42
46
|
const getReferrer = () => document.referrer || '';
|
|
43
47
|
const sessionTargeting = (0, session_1.getSessionTargeting)({
|
|
@@ -61,9 +65,6 @@ const buildPageTargeting = ({ adFree, clientSideParticipations, consentState, yo
|
|
|
61
65
|
viewPortWidth: getViewport().width,
|
|
62
66
|
cmpBannerWillShow: !consent_management_platform_1.cmp.hasInitialised() || consent_management_platform_1.cmp.willShowPrivacyMessageSync(),
|
|
63
67
|
});
|
|
64
|
-
const sharedAdTargeting = page.sharedAdTargeting
|
|
65
|
-
? (0, shared_1.getSharedTargeting)(page.sharedAdTargeting)
|
|
66
|
-
: {};
|
|
67
68
|
const personalisedTargeting = (0, personalised_1.getPersonalisedTargeting)({
|
|
68
69
|
state: consentState,
|
|
69
70
|
youtube,
|
|
@@ -63,6 +63,14 @@ type ContentTargeting = {
|
|
|
63
63
|
* [gam]: https://admanager.google.com/59666047#inventory/custom_targeting/detail/custom_key_id=195087
|
|
64
64
|
*/
|
|
65
65
|
vl: null | (typeof videoLengths)[number];
|
|
66
|
+
/**
|
|
67
|
+
* **All** **K**ey**w**ords - [see on Ad Manager][gam]
|
|
68
|
+
* This is a list of all keywords on the page, including the section and the URL keywords
|
|
69
|
+
* Type: _Dynamic_
|
|
70
|
+
*
|
|
71
|
+
* [gam]: https://admanager.google.com/59666047#inventory/custom_targeting/detail/custom_key_id=13995840
|
|
72
|
+
*/
|
|
73
|
+
allkw: string[];
|
|
66
74
|
};
|
|
67
75
|
type Content = {
|
|
68
76
|
eligibleForDCR: boolean;
|
|
@@ -72,7 +80,8 @@ type Content = {
|
|
|
72
80
|
sensitive: boolean;
|
|
73
81
|
videoLength?: number;
|
|
74
82
|
webPublicationDate: number;
|
|
83
|
+
keywords: string[];
|
|
75
84
|
};
|
|
76
|
-
declare const getContentTargeting: ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, webPublicationDate, }: Content) => ContentTargeting;
|
|
85
|
+
declare const getContentTargeting: ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, webPublicationDate, keywords, }: Content) => ContentTargeting;
|
|
77
86
|
export { getContentTargeting };
|
|
78
87
|
export type { ContentTargeting };
|
|
@@ -28,6 +28,9 @@ const getUrlKeywords = (url) => {
|
|
|
28
28
|
.slice(-1)[0];
|
|
29
29
|
return (0, libs_1.isString)(lastSegment) ? lastSegment.split('-').filter(Boolean) : [];
|
|
30
30
|
};
|
|
31
|
+
const concatUnique = (a, b) => [
|
|
32
|
+
...new Set([...a, ...b]),
|
|
33
|
+
];
|
|
31
34
|
// "0" means content < 2 hours old
|
|
32
35
|
// "1" means content between 2 hours and 24 hours old.
|
|
33
36
|
// "2" means content between 24 hours and 3 days old
|
|
@@ -57,15 +60,17 @@ const calculateRecentlyPublishedBucket = (webPublicationDate) => {
|
|
|
57
60
|
return '6';
|
|
58
61
|
return '7';
|
|
59
62
|
};
|
|
60
|
-
const getContentTargeting = ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, webPublicationDate, }) => {
|
|
63
|
+
const getContentTargeting = ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, webPublicationDate, keywords, }) => {
|
|
64
|
+
const urlkw = getUrlKeywords(path);
|
|
61
65
|
return {
|
|
62
66
|
dcre: eligibleForDCR ? 't' : 'f',
|
|
63
67
|
rc: calculateRecentlyPublishedBucket(webPublicationDate),
|
|
64
68
|
rp: renderingPlatform,
|
|
65
69
|
s: section,
|
|
66
70
|
sens: sensitive ? 't' : 'f',
|
|
67
|
-
urlkw
|
|
71
|
+
urlkw,
|
|
68
72
|
vl: videoLength ? getVideoLength(videoLength) : null,
|
|
73
|
+
allkw: concatUnique(urlkw, keywords),
|
|
69
74
|
};
|
|
70
75
|
};
|
|
71
76
|
exports.getContentTargeting = getContentTargeting;
|
|
@@ -36,7 +36,10 @@ const mergeCustomParamsWithTargeting = (customParams, consentState, clientSidePa
|
|
|
36
36
|
(0, libs_1.log)('commercial', 'Error building YouTube IMA custom params', e);
|
|
37
37
|
return customParams;
|
|
38
38
|
}
|
|
39
|
-
const mergedCustomParams = {
|
|
39
|
+
const mergedCustomParams = {
|
|
40
|
+
...customParams,
|
|
41
|
+
...pageTargeting,
|
|
42
|
+
};
|
|
40
43
|
return mergedCustomParams;
|
|
41
44
|
};
|
|
42
45
|
const buildImaAdTagUrl = ({ adUnit, clientSideParticipations, consentState, customParams, }) => {
|
|
@@ -14,6 +14,8 @@ const buildAdsConfig = (cmpConsent, adUnit, customParams, clientSideParticipatio
|
|
|
14
14
|
consentState: cmpConsent,
|
|
15
15
|
youtube: true,
|
|
16
16
|
}),
|
|
17
|
+
// 19/04/2023 This is a temporary update to assist reporting for a YouTube IMA test
|
|
18
|
+
yt_embed_ima: '0',
|
|
17
19
|
};
|
|
18
20
|
const defaultAdsConfig = {
|
|
19
21
|
adTagParameters: {
|
|
@@ -33,6 +33,7 @@ type PageTargeting = PartialWithNulls<{
|
|
|
33
33
|
skinsize: 'l' | 's';
|
|
34
34
|
urlkw: string[];
|
|
35
35
|
vl: string;
|
|
36
|
+
allkw: string[];
|
|
36
37
|
[_: string]: string | string[];
|
|
37
38
|
} & SharedTargeting>;
|
|
38
39
|
declare const filterValues: (pageTargets: Record<string, unknown>) => Record<string, string | string[]>;
|
|
@@ -24,6 +24,9 @@ const filterValues = (pageTargets) => {
|
|
|
24
24
|
const buildPageTargeting = ({ adFree, clientSideParticipations, consentState, youtube = false, }) => {
|
|
25
25
|
const { page, isDotcomRendering } = window.guardian.config;
|
|
26
26
|
const adFreeTargeting = adFree ? { af: 't' } : {};
|
|
27
|
+
const sharedAdTargeting = page.sharedAdTargeting
|
|
28
|
+
? getSharedTargeting(page.sharedAdTargeting)
|
|
29
|
+
: {};
|
|
27
30
|
const contentTargeting = getContentTargeting({
|
|
28
31
|
webPublicationDate: page.webPublicationDate,
|
|
29
32
|
eligibleForDCR: page.dcrCouldRender,
|
|
@@ -34,6 +37,7 @@ const buildPageTargeting = ({ adFree, clientSideParticipations, consentState, yo
|
|
|
34
37
|
section: page.section,
|
|
35
38
|
sensitive: page.isSensitive,
|
|
36
39
|
videoLength: page.videoDuration,
|
|
40
|
+
keywords: sharedAdTargeting.k ?? [],
|
|
37
41
|
});
|
|
38
42
|
const getReferrer = () => document.referrer || '';
|
|
39
43
|
const sessionTargeting = getSessionTargeting({
|
|
@@ -57,9 +61,6 @@ const buildPageTargeting = ({ adFree, clientSideParticipations, consentState, yo
|
|
|
57
61
|
viewPortWidth: getViewport().width,
|
|
58
62
|
cmpBannerWillShow: !cmp.hasInitialised() || cmp.willShowPrivacyMessageSync(),
|
|
59
63
|
});
|
|
60
|
-
const sharedAdTargeting = page.sharedAdTargeting
|
|
61
|
-
? getSharedTargeting(page.sharedAdTargeting)
|
|
62
|
-
: {};
|
|
63
64
|
const personalisedTargeting = getPersonalisedTargeting({
|
|
64
65
|
state: consentState,
|
|
65
66
|
youtube,
|
|
@@ -63,6 +63,14 @@ type ContentTargeting = {
|
|
|
63
63
|
* [gam]: https://admanager.google.com/59666047#inventory/custom_targeting/detail/custom_key_id=195087
|
|
64
64
|
*/
|
|
65
65
|
vl: null | (typeof videoLengths)[number];
|
|
66
|
+
/**
|
|
67
|
+
* **All** **K**ey**w**ords - [see on Ad Manager][gam]
|
|
68
|
+
* This is a list of all keywords on the page, including the section and the URL keywords
|
|
69
|
+
* Type: _Dynamic_
|
|
70
|
+
*
|
|
71
|
+
* [gam]: https://admanager.google.com/59666047#inventory/custom_targeting/detail/custom_key_id=13995840
|
|
72
|
+
*/
|
|
73
|
+
allkw: string[];
|
|
66
74
|
};
|
|
67
75
|
type Content = {
|
|
68
76
|
eligibleForDCR: boolean;
|
|
@@ -72,7 +80,8 @@ type Content = {
|
|
|
72
80
|
sensitive: boolean;
|
|
73
81
|
videoLength?: number;
|
|
74
82
|
webPublicationDate: number;
|
|
83
|
+
keywords: string[];
|
|
75
84
|
};
|
|
76
|
-
declare const getContentTargeting: ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, webPublicationDate, }: Content) => ContentTargeting;
|
|
85
|
+
declare const getContentTargeting: ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, webPublicationDate, keywords, }: Content) => ContentTargeting;
|
|
77
86
|
export { getContentTargeting };
|
|
78
87
|
export type { ContentTargeting };
|
|
@@ -25,6 +25,9 @@ const getUrlKeywords = (url) => {
|
|
|
25
25
|
.slice(-1)[0];
|
|
26
26
|
return isString(lastSegment) ? lastSegment.split('-').filter(Boolean) : [];
|
|
27
27
|
};
|
|
28
|
+
const concatUnique = (a, b) => [
|
|
29
|
+
...new Set([...a, ...b]),
|
|
30
|
+
];
|
|
28
31
|
// "0" means content < 2 hours old
|
|
29
32
|
// "1" means content between 2 hours and 24 hours old.
|
|
30
33
|
// "2" means content between 24 hours and 3 days old
|
|
@@ -54,15 +57,17 @@ const calculateRecentlyPublishedBucket = (webPublicationDate) => {
|
|
|
54
57
|
return '6';
|
|
55
58
|
return '7';
|
|
56
59
|
};
|
|
57
|
-
const getContentTargeting = ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, webPublicationDate, }) => {
|
|
60
|
+
const getContentTargeting = ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, webPublicationDate, keywords, }) => {
|
|
61
|
+
const urlkw = getUrlKeywords(path);
|
|
58
62
|
return {
|
|
59
63
|
dcre: eligibleForDCR ? 't' : 'f',
|
|
60
64
|
rc: calculateRecentlyPublishedBucket(webPublicationDate),
|
|
61
65
|
rp: renderingPlatform,
|
|
62
66
|
s: section,
|
|
63
67
|
sens: sensitive ? 't' : 'f',
|
|
64
|
-
urlkw
|
|
68
|
+
urlkw,
|
|
65
69
|
vl: videoLength ? getVideoLength(videoLength) : null,
|
|
70
|
+
allkw: concatUnique(urlkw, keywords),
|
|
66
71
|
};
|
|
67
72
|
};
|
|
68
73
|
export { getContentTargeting };
|
|
@@ -33,7 +33,10 @@ const mergeCustomParamsWithTargeting = (customParams, consentState, clientSidePa
|
|
|
33
33
|
log('commercial', 'Error building YouTube IMA custom params', e);
|
|
34
34
|
return customParams;
|
|
35
35
|
}
|
|
36
|
-
const mergedCustomParams = {
|
|
36
|
+
const mergedCustomParams = {
|
|
37
|
+
...customParams,
|
|
38
|
+
...pageTargeting,
|
|
39
|
+
};
|
|
37
40
|
return mergedCustomParams;
|
|
38
41
|
};
|
|
39
42
|
const buildImaAdTagUrl = ({ adUnit, clientSideParticipations, consentState, customParams, }) => {
|
|
@@ -10,6 +10,8 @@ const buildAdsConfig = (cmpConsent, adUnit, customParams, clientSideParticipatio
|
|
|
10
10
|
consentState: cmpConsent,
|
|
11
11
|
youtube: true,
|
|
12
12
|
}),
|
|
13
|
+
// 19/04/2023 This is a temporary update to assist reporting for a YouTube IMA test
|
|
14
|
+
yt_embed_ima: '0',
|
|
13
15
|
};
|
|
14
16
|
const defaultAdsConfig = {
|
|
15
17
|
adTagParameters: {
|