@guardian/commercial-core 4.23.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.
@@ -15,7 +15,7 @@ export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments,
15
15
  export { initTrackScrollDepth } from './track-scroll-depth';
16
16
  export { initTrackLabsContainer } from './track-labs-container';
17
17
  export { initTrackGpcSignal } from './track-gpc-signal';
18
- export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
18
+ export { buildAdsConfigWithConsent, disabledAds } from './targeting/youtube';
19
19
  export { createAdSlot, concatSizeMappings } from './create-ad-slot';
20
20
  export type { AdsConfig, AdsConfigBasic, AdsConfigDisabled, AdTargetingBuilder, CustomParams, } from './types';
21
21
  export * as constants from './constants';
package/dist/cjs/index.js CHANGED
@@ -61,9 +61,9 @@ var track_labs_container_1 = require("./track-labs-container");
61
61
  Object.defineProperty(exports, "initTrackLabsContainer", { enumerable: true, get: function () { return track_labs_container_1.initTrackLabsContainer; } });
62
62
  var track_gpc_signal_1 = require("./track-gpc-signal");
63
63
  Object.defineProperty(exports, "initTrackGpcSignal", { enumerable: true, get: function () { return track_gpc_signal_1.initTrackGpcSignal; } });
64
- var ad_targeting_youtube_1 = require("./ad-targeting-youtube");
65
- Object.defineProperty(exports, "buildAdsConfigWithConsent", { enumerable: true, get: function () { return ad_targeting_youtube_1.buildAdsConfigWithConsent; } });
66
- Object.defineProperty(exports, "disabledAds", { enumerable: true, get: function () { return ad_targeting_youtube_1.disabledAds; } });
64
+ var youtube_1 = require("./targeting/youtube");
65
+ Object.defineProperty(exports, "buildAdsConfigWithConsent", { enumerable: true, get: function () { return youtube_1.buildAdsConfigWithConsent; } });
66
+ Object.defineProperty(exports, "disabledAds", { enumerable: true, get: function () { return youtube_1.disabledAds; } });
67
67
  var create_ad_slot_1 = require("./create-ad-slot");
68
68
  Object.defineProperty(exports, "createAdSlot", { enumerable: true, get: function () { return create_ad_slot_1.createAdSlot; } });
69
69
  Object.defineProperty(exports, "concatSizeMappings", { enumerable: true, get: function () { return create_ad_slot_1.concatSizeMappings; } });
@@ -35,7 +35,11 @@ const isConsentlessKey = (key) => consentlessTargetingKeys.includes(key);
35
35
  * @returns ConsentlessPageTargeting
36
36
  */
37
37
  const buildPageTargetingConsentless = (consentState, adFree) => {
38
- const consentedPageTargeting = (0, build_page_targeting_1.buildPageTargeting)(consentState, adFree);
38
+ const consentedPageTargeting = (0, build_page_targeting_1.buildPageTargeting)({
39
+ adFree,
40
+ consentState,
41
+ clientSideParticipations: {},
42
+ });
39
43
  return Object.fromEntries(Object.entries(consentedPageTargeting).filter(([k]) => isConsentlessKey(k)));
40
44
  };
41
45
  exports.buildPageTargetingConsentless = buildPageTargetingConsentless;
@@ -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';
@@ -34,6 +35,12 @@ declare type PageTargeting = PartialWithNulls<{
34
35
  [_: string]: string | string[];
35
36
  } & SharedTargeting>;
36
37
  declare const filterValues: (pageTargets: Record<string, unknown>) => Record<string, string | string[]>;
37
- declare const buildPageTargeting: (consentState: ConsentState, adFree: boolean) => PageTargeting;
38
+ declare type BuildPageTargetingParams = {
39
+ adFree: boolean;
40
+ clientSideParticipations: Participations;
41
+ consentState: ConsentState;
42
+ youtube?: boolean;
43
+ };
44
+ declare const buildPageTargeting: ({ adFree, clientSideParticipations, consentState, youtube, }: BuildPageTargetingParams) => Record<string, string | string[]>;
38
45
  export { buildPageTargeting, filterValues };
39
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 = (consentState, adFree) => {
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) => {
46
45
  isSignedIn: !!(0, libs_1.getCookie)({ name: 'GU_U' }),
47
46
  pageViewId: window.guardian.config.ophan.pageViewId,
48
47
  participations: {
49
- clientSideParticipations: (0, ab_localstorage_1.getParticipationsFromLocalStorage)(),
48
+ clientSideParticipations,
50
49
  serverSideParticipations: window.guardian.config.tests ?? {},
51
50
  },
52
51
  referrer: getReferrer(),
@@ -64,7 +63,10 @@ const buildPageTargeting = (consentState, adFree) => {
64
63
  const sharedAdTargeting = page.sharedAdTargeting
65
64
  ? (0, shared_1.getSharedTargeting)(page.sharedAdTargeting)
66
65
  : {};
67
- const personalisedTargeting = (0, personalised_1.getPersonalisedTargeting)(consentState);
66
+ const personalisedTargeting = (0, personalised_1.getPersonalisedTargeting)({
67
+ state: consentState,
68
+ youtube,
69
+ });
68
70
  const pageTargets = {
69
71
  ...personalisedTargeting,
70
72
  ...sharedAdTargeting,
@@ -75,6 +75,10 @@ declare type PersonalisedTargeting = {
75
75
  */
76
76
  rdp: True | False | NotApplicable;
77
77
  };
78
- declare const getPersonalisedTargeting: (state: ConsentState) => PersonalisedTargeting;
78
+ declare type Personalised = {
79
+ state: ConsentState;
80
+ youtube: boolean;
81
+ };
82
+ declare const getPersonalisedTargeting: ({ state, youtube, }: Personalised) => PersonalisedTargeting;
79
83
  export { getPersonalisedTargeting };
80
84
  export type { PersonalisedTargeting, AdManagerGroup, Frequency };
@@ -124,17 +124,17 @@ const getAdManagerGroup = (state) => {
124
124
  ? existingGroup
125
125
  : createAdManagerGroup();
126
126
  };
127
- const getPermutiveWithState = (state) => {
128
- if (state.canTarget)
129
- return (0, permutive_1.getPermutiveSegments)();
127
+ const getPermutiveWithState = (state, youtube) => {
128
+ if (state.canTarget) {
129
+ return youtube ? (0, permutive_1.getPermutivePFPSegments)() : (0, permutive_1.getPermutiveSegments)();
130
+ }
130
131
  (0, permutive_1.clearPermutiveSegments)();
131
132
  return [];
132
133
  };
133
- /* -- Targeting -- */
134
- const getPersonalisedTargeting = (state) => ({
134
+ const getPersonalisedTargeting = ({ state, youtube, }) => ({
135
135
  amtgrp: getAdManagerGroup(state),
136
136
  fr: getFrequencyValue(state),
137
- permutive: getPermutiveWithState(state),
137
+ permutive: getPermutiveWithState(state, youtube),
138
138
  ...getCMPTargeting(state),
139
139
  });
140
140
  exports.getPersonalisedTargeting = getPersonalisedTargeting;
@@ -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 const buildImaAdTagUrl: (adUnit: string, customParams: CustomParams, consentState: ConsentState) => string;
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,10 +18,14 @@ 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
- pageTargeting = (0, build_page_targeting_1.buildPageTargeting)(consentState, false);
24
+ pageTargeting = (0, build_page_targeting_1.buildPageTargeting)({
25
+ adFree: false,
26
+ clientSideParticipations,
27
+ consentState: consentState,
28
+ });
25
29
  }
26
30
  catch (e) {
27
31
  /**
@@ -35,8 +39,8 @@ const mergeCustomParamsWithTargeting = (customParams, consentState) => {
35
39
  const mergedCustomParams = { ...customParams, ...pageTargeting };
36
40
  return mergedCustomParams;
37
41
  };
38
- const buildImaAdTagUrl = (adUnit, customParams, consentState) => {
39
- const mergedCustomParams = mergeCustomParamsWithTargeting(customParams, consentState);
42
+ const buildImaAdTagUrl = ({ adUnit, clientSideParticipations, consentState, customParams, }) => {
43
+ const mergedCustomParams = mergeCustomParamsWithTargeting(customParams, consentState, clientSideParticipations);
40
44
  const queryParams = {
41
45
  iu: adUnit,
42
46
  tfcd: '0',
@@ -0,0 +1,13 @@
1
+ import type { Participations } from '@guardian/ab-core';
2
+ import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
3
+ import type { AdsConfig, AdsConfigDisabled, CustomParams } from '../types';
4
+ declare const disabledAds: AdsConfigDisabled;
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;
13
+ export { buildAdsConfigWithConsent, disabledAds };
@@ -1,22 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.disabledAds = exports.buildAdsConfigWithConsent = void 0;
4
- const libs_1 = require("@guardian/libs");
5
- const can_use_dom_1 = require("./lib/can-use-dom");
6
- const construct_query_1 = require("./lib/construct-query");
7
- const permutive_1 = require("./permutive");
4
+ const construct_query_1 = require("../lib/construct-query");
5
+ const build_page_targeting_1 = require("./build-page-targeting");
8
6
  const disabledAds = { disableAds: true };
9
7
  exports.disabledAds = disabledAds;
10
- const buildCustomParamsFromCookies = () => (0, can_use_dom_1.canUseDom)()
11
- ? {
12
- permutive: (0, permutive_1.getPermutivePFPSegments)(),
13
- si: (0, libs_1.getCookie)({ name: 'GU_U' }) ? 't' : 'f',
14
- }
15
- : {};
16
- const buildAdsConfig = (cmpConsent, adUnit, customParams) => {
8
+ const buildAdsConfig = (cmpConsent, adUnit, customParams, clientSideParticipations) => {
17
9
  const mergedCustomParams = {
18
10
  ...customParams,
19
- ...buildCustomParamsFromCookies(),
11
+ ...(0, build_page_targeting_1.buildPageTargeting)({
12
+ adFree: false,
13
+ clientSideParticipations,
14
+ consentState: cmpConsent,
15
+ youtube: true,
16
+ }),
20
17
  };
21
18
  const defaultAdsConfig = {
22
19
  adTagParameters: {
@@ -56,10 +53,10 @@ const buildAdsConfig = (cmpConsent, adUnit, customParams) => {
56
53
  // Shouldn't happen but handle if no matching framework
57
54
  return disabledAds;
58
55
  };
59
- const buildAdsConfigWithConsent = (isAdFreeUser, adUnit, customParamsToMerge, consentState) => {
56
+ const buildAdsConfigWithConsent = ({ adUnit, clientSideParticipations, consentState, customParams, isAdFreeUser, }) => {
60
57
  if (isAdFreeUser) {
61
58
  return disabledAds;
62
59
  }
63
- return buildAdsConfig(consentState, adUnit, customParamsToMerge);
60
+ return buildAdsConfig(consentState, adUnit, customParams, clientSideParticipations);
64
61
  };
65
62
  exports.buildAdsConfigWithConsent = buildAdsConfigWithConsent;
@@ -15,7 +15,7 @@ export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments,
15
15
  export { initTrackScrollDepth } from './track-scroll-depth';
16
16
  export { initTrackLabsContainer } from './track-labs-container';
17
17
  export { initTrackGpcSignal } from './track-gpc-signal';
18
- export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
18
+ export { buildAdsConfigWithConsent, disabledAds } from './targeting/youtube';
19
19
  export { createAdSlot, concatSizeMappings } from './create-ad-slot';
20
20
  export type { AdsConfig, AdsConfigBasic, AdsConfigDisabled, AdTargetingBuilder, CustomParams, } from './types';
21
21
  export * as constants from './constants';
package/dist/esm/index.js CHANGED
@@ -13,7 +13,7 @@ export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments,
13
13
  export { initTrackScrollDepth } from './track-scroll-depth';
14
14
  export { initTrackLabsContainer } from './track-labs-container';
15
15
  export { initTrackGpcSignal } from './track-gpc-signal';
16
- export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
16
+ export { buildAdsConfigWithConsent, disabledAds } from './targeting/youtube';
17
17
  export { createAdSlot, concatSizeMappings } from './create-ad-slot';
18
18
  import * as constants_1 from './constants';
19
19
  export { constants_1 as constants };
@@ -32,7 +32,11 @@ const isConsentlessKey = (key) => consentlessTargetingKeys.includes(key);
32
32
  * @returns ConsentlessPageTargeting
33
33
  */
34
34
  const buildPageTargetingConsentless = (consentState, adFree) => {
35
- const consentedPageTargeting = buildPageTargeting(consentState, adFree);
35
+ const consentedPageTargeting = buildPageTargeting({
36
+ adFree,
37
+ consentState,
38
+ clientSideParticipations: {},
39
+ });
36
40
  return Object.fromEntries(Object.entries(consentedPageTargeting).filter(([k]) => isConsentlessKey(k)));
37
41
  };
38
42
  export { buildPageTargetingConsentless };
@@ -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';
@@ -34,6 +35,12 @@ declare type PageTargeting = PartialWithNulls<{
34
35
  [_: string]: string | string[];
35
36
  } & SharedTargeting>;
36
37
  declare const filterValues: (pageTargets: Record<string, unknown>) => Record<string, string | string[]>;
37
- declare const buildPageTargeting: (consentState: ConsentState, adFree: boolean) => PageTargeting;
38
+ declare type BuildPageTargetingParams = {
39
+ adFree: boolean;
40
+ clientSideParticipations: Participations;
41
+ consentState: ConsentState;
42
+ youtube?: boolean;
43
+ };
44
+ declare const buildPageTargeting: ({ adFree, clientSideParticipations, consentState, youtube, }: BuildPageTargetingParams) => Record<string, string | string[]>;
38
45
  export { buildPageTargeting, filterValues };
39
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 = (consentState, adFree) => {
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) => {
42
41
  isSignedIn: !!getCookie({ name: 'GU_U' }),
43
42
  pageViewId: window.guardian.config.ophan.pageViewId,
44
43
  participations: {
45
- clientSideParticipations: getParticipationsFromLocalStorage(),
44
+ clientSideParticipations,
46
45
  serverSideParticipations: window.guardian.config.tests ?? {},
47
46
  },
48
47
  referrer: getReferrer(),
@@ -60,7 +59,10 @@ const buildPageTargeting = (consentState, adFree) => {
60
59
  const sharedAdTargeting = page.sharedAdTargeting
61
60
  ? getSharedTargeting(page.sharedAdTargeting)
62
61
  : {};
63
- const personalisedTargeting = getPersonalisedTargeting(consentState);
62
+ const personalisedTargeting = getPersonalisedTargeting({
63
+ state: consentState,
64
+ youtube,
65
+ });
64
66
  const pageTargets = {
65
67
  ...personalisedTargeting,
66
68
  ...sharedAdTargeting,
@@ -75,6 +75,10 @@ declare type PersonalisedTargeting = {
75
75
  */
76
76
  rdp: True | False | NotApplicable;
77
77
  };
78
- declare const getPersonalisedTargeting: (state: ConsentState) => PersonalisedTargeting;
78
+ declare type Personalised = {
79
+ state: ConsentState;
80
+ youtube: boolean;
81
+ };
82
+ declare const getPersonalisedTargeting: ({ state, youtube, }: Personalised) => PersonalisedTargeting;
79
83
  export { getPersonalisedTargeting };
80
84
  export type { PersonalisedTargeting, AdManagerGroup, Frequency };
@@ -1,5 +1,5 @@
1
1
  import { storage } from '@guardian/libs';
2
- import { clearPermutiveSegments, getPermutiveSegments } from '../permutive';
2
+ import { clearPermutiveSegments, getPermutivePFPSegments, getPermutiveSegments, } from '../permutive';
3
3
  /* -- Types -- */
4
4
  const frequency = [
5
5
  '0',
@@ -121,17 +121,17 @@ const getAdManagerGroup = (state) => {
121
121
  ? existingGroup
122
122
  : createAdManagerGroup();
123
123
  };
124
- const getPermutiveWithState = (state) => {
125
- if (state.canTarget)
126
- return getPermutiveSegments();
124
+ const getPermutiveWithState = (state, youtube) => {
125
+ if (state.canTarget) {
126
+ return youtube ? getPermutivePFPSegments() : getPermutiveSegments();
127
+ }
127
128
  clearPermutiveSegments();
128
129
  return [];
129
130
  };
130
- /* -- Targeting -- */
131
- const getPersonalisedTargeting = (state) => ({
131
+ const getPersonalisedTargeting = ({ state, youtube, }) => ({
132
132
  amtgrp: getAdManagerGroup(state),
133
133
  fr: getFrequencyValue(state),
134
- permutive: getPermutiveWithState(state),
134
+ permutive: getPermutiveWithState(state, youtube),
135
135
  ...getCMPTargeting(state),
136
136
  });
137
137
  export { getPersonalisedTargeting };
@@ -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 const buildImaAdTagUrl: (adUnit: string, customParams: CustomParams, consentState: ConsentState) => string;
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,10 +15,14 @@ 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
- pageTargeting = buildPageTargeting(consentState, false);
21
+ pageTargeting = buildPageTargeting({
22
+ adFree: false,
23
+ clientSideParticipations,
24
+ consentState: consentState,
25
+ });
22
26
  }
23
27
  catch (e) {
24
28
  /**
@@ -32,8 +36,8 @@ const mergeCustomParamsWithTargeting = (customParams, consentState) => {
32
36
  const mergedCustomParams = { ...customParams, ...pageTargeting };
33
37
  return mergedCustomParams;
34
38
  };
35
- const buildImaAdTagUrl = (adUnit, customParams, consentState) => {
36
- const mergedCustomParams = mergeCustomParamsWithTargeting(customParams, consentState);
39
+ const buildImaAdTagUrl = ({ adUnit, clientSideParticipations, consentState, customParams, }) => {
40
+ const mergedCustomParams = mergeCustomParamsWithTargeting(customParams, consentState, clientSideParticipations);
37
41
  const queryParams = {
38
42
  iu: adUnit,
39
43
  tfcd: '0',
@@ -0,0 +1,13 @@
1
+ import type { Participations } from '@guardian/ab-core';
2
+ import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
3
+ import type { AdsConfig, AdsConfigDisabled, CustomParams } from '../types';
4
+ declare const disabledAds: AdsConfigDisabled;
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;
13
+ export { buildAdsConfigWithConsent, disabledAds };
@@ -1,18 +1,15 @@
1
- import { getCookie } from '@guardian/libs';
2
- import { canUseDom } from './lib/can-use-dom';
3
- import { constructQuery } from './lib/construct-query';
4
- import { getPermutivePFPSegments } from './permutive';
1
+ import { constructQuery } from '../lib/construct-query';
2
+ import { buildPageTargeting } from './build-page-targeting';
5
3
  const disabledAds = { disableAds: true };
6
- const buildCustomParamsFromCookies = () => canUseDom()
7
- ? {
8
- permutive: getPermutivePFPSegments(),
9
- si: getCookie({ name: 'GU_U' }) ? 't' : 'f',
10
- }
11
- : {};
12
- const buildAdsConfig = (cmpConsent, adUnit, customParams) => {
4
+ const buildAdsConfig = (cmpConsent, adUnit, customParams, clientSideParticipations) => {
13
5
  const mergedCustomParams = {
14
6
  ...customParams,
15
- ...buildCustomParamsFromCookies(),
7
+ ...buildPageTargeting({
8
+ adFree: false,
9
+ clientSideParticipations,
10
+ consentState: cmpConsent,
11
+ youtube: true,
12
+ }),
16
13
  };
17
14
  const defaultAdsConfig = {
18
15
  adTagParameters: {
@@ -52,10 +49,10 @@ const buildAdsConfig = (cmpConsent, adUnit, customParams) => {
52
49
  // Shouldn't happen but handle if no matching framework
53
50
  return disabledAds;
54
51
  };
55
- const buildAdsConfigWithConsent = (isAdFreeUser, adUnit, customParamsToMerge, consentState) => {
52
+ const buildAdsConfigWithConsent = ({ adUnit, clientSideParticipations, consentState, customParams, isAdFreeUser, }) => {
56
53
  if (isAdFreeUser) {
57
54
  return disabledAds;
58
55
  }
59
- return buildAdsConfig(consentState, adUnit, customParamsToMerge);
56
+ return buildAdsConfig(consentState, adUnit, customParams, clientSideParticipations);
60
57
  };
61
58
  export { buildAdsConfigWithConsent, disabledAds };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/commercial-core",
3
- "version": "4.23.0",
3
+ "version": "4.25.0",
4
4
  "description": "Guardian advertising business logic",
5
5
  "homepage": "https://github.com/guardian/commercial-core#readme",
6
6
  "bugs": {
@@ -1,5 +0,0 @@
1
- import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
2
- import type { AdsConfig, AdsConfigDisabled, CustomParams } from './types';
3
- declare const disabledAds: AdsConfigDisabled;
4
- declare const buildAdsConfigWithConsent: (isAdFreeUser: boolean, adUnit: string, customParamsToMerge: CustomParams, consentState: ConsentState) => AdsConfig;
5
- export { buildAdsConfigWithConsent, disabledAds };
@@ -1,5 +0,0 @@
1
- import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
2
- import type { AdsConfig, AdsConfigDisabled, CustomParams } from './types';
3
- declare const disabledAds: AdsConfigDisabled;
4
- declare const buildAdsConfigWithConsent: (isAdFreeUser: boolean, adUnit: string, customParamsToMerge: CustomParams, consentState: ConsentState) => AdsConfig;
5
- export { buildAdsConfigWithConsent, disabledAds };