@guardian/commercial-core 30.0.0 → 30.1.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.
@@ -1,3 +1,3 @@
1
- type HashClient = 'id5' | 'uid2';
1
+ type HashClient = 'id5' | 'uid2' | 'euid';
2
2
  declare function hashEmailForClient(email: string, client: HashClient): Promise<string>;
3
3
  export { hashEmailForClient };
@@ -21,6 +21,7 @@ async function hashEmailForClient(email, client) {
21
21
  case 'id5':
22
22
  return toHex(hashBuffer);
23
23
  case 'uid2':
24
+ case 'euid':
24
25
  return toBase64(hashBuffer);
25
26
  }
26
27
  }
@@ -30,6 +30,7 @@ type PageTargeting = PartialWithNulls<{
30
30
  s: string;
31
31
  sens: TrueOrFalse;
32
32
  si: TrueOrFalse;
33
+ idp: string[];
33
34
  skinsize: 'l' | 's';
34
35
  urlkw: string[];
35
36
  vl: string;
@@ -37,13 +38,24 @@ type PageTargeting = PartialWithNulls<{
37
38
  [_: string]: string | string[];
38
39
  } & SharedTargeting>;
39
40
  declare const filterValues: (pageTargets: Record<string, unknown>) => Record<string, string | string[]>;
41
+ type UserId = {
42
+ name: string;
43
+ params?: Record<string, string | number>;
44
+ storage?: {
45
+ type: 'cookie' | 'html5';
46
+ name: string;
47
+ expires: number;
48
+ refreshInSeconds?: number;
49
+ };
50
+ };
40
51
  type BuildPageTargetingParams = {
41
52
  adFree: boolean;
42
53
  clientSideParticipations: Participations;
43
54
  consentState: ConsentState;
44
55
  isSignedIn?: boolean;
45
56
  youtube?: boolean;
57
+ idProviders?: UserId[];
46
58
  };
47
- declare const buildPageTargeting: ({ adFree, clientSideParticipations, consentState, isSignedIn, youtube, }: BuildPageTargetingParams) => Record<string, string | string[]>;
59
+ declare const buildPageTargeting: ({ adFree, clientSideParticipations, consentState, isSignedIn, youtube, idProviders, }: BuildPageTargetingParams) => Record<string, string | string[]>;
48
60
  export { buildPageTargeting, filterValues, getLocalHour };
49
- export type { PageTargeting };
61
+ export type { UserId, PageTargeting };
@@ -49,7 +49,7 @@ const isFirstVisit = (referrer) => {
49
49
  }
50
50
  return !referrerMatchesHost(referrer);
51
51
  };
52
- const buildPageTargeting = ({ adFree, clientSideParticipations, consentState, isSignedIn = false, youtube = false, }) => {
52
+ const buildPageTargeting = ({ adFree, clientSideParticipations, consentState, isSignedIn = false, youtube = false, idProviders = [], }) => {
53
53
  const { page, isDotcomRendering } = window.guardian.config;
54
54
  const adFreeTargeting = adFree ? { af: 't' } : {};
55
55
  const sharedAdTargeting = page.sharedAdTargeting
@@ -80,6 +80,7 @@ const buildPageTargeting = ({ adFree, clientSideParticipations, consentState, is
80
80
  betaAbTestParticipations: window.guardian.modules.abTests?.getParticipations() ?? {},
81
81
  },
82
82
  referrer,
83
+ idProviders,
83
84
  });
84
85
  const getViewport = () => {
85
86
  return {
@@ -1,5 +1,6 @@
1
1
  import type { Participations } from '@guardian/ab-core';
2
2
  import type { CountryCode } from '@guardian/libs';
3
+ import type { UserId } from '../targeting/build-page-targeting.js';
3
4
  import type { False, True } from './types.js';
4
5
  declare const referrers: readonly [{
5
6
  readonly id: "facebook";
@@ -97,6 +98,14 @@ type SessionTargeting = {
97
98
  * [gam]: https://admanager.google.com/59666047#inventory/custom_targeting/detail/custom_key_id=215727
98
99
  */
99
100
  si: True | False;
101
+ /**
102
+ * **I**d **P**roviders – [see on Ad Manager][gam]
103
+ *
104
+ * Denote which id providers have been integrated.
105
+ *
106
+ * [gam]: To be added
107
+ */
108
+ idp: string[] | null;
100
109
  };
101
110
  type AllParticipations = {
102
111
  clientSideParticipations: Participations;
@@ -119,7 +128,8 @@ type Session = {
119
128
  pageViewId: SessionTargeting['pv'];
120
129
  participations: AllParticipations;
121
130
  referrer: string;
131
+ idProviders: UserId[];
122
132
  };
123
- declare const getSessionTargeting: ({ adTest, countryCode, localHour, isSignedIn, pageViewId, participations, referrer, }: Session) => SessionTargeting;
133
+ declare const getSessionTargeting: ({ adTest, countryCode, localHour, isSignedIn, pageViewId, participations, referrer, idProviders, }: Session) => SessionTargeting;
124
134
  export type { SessionTargeting, AllParticipations };
125
135
  export { getSessionTargeting, experimentsTargeting };
@@ -63,7 +63,10 @@ const experimentsTargeting = ({ clientSideParticipations, serverSideParticipatio
63
63
  return [...clientSideExperiment, ...serverSideExperiments, ...betaAbTests];
64
64
  };
65
65
  exports.experimentsTargeting = experimentsTargeting;
66
- const getSessionTargeting = ({ adTest, countryCode, localHour, isSignedIn, pageViewId, participations, referrer, }) => ({
66
+ const getIdProviders = (userIds) => {
67
+ return userIds.map((id) => id.name);
68
+ };
69
+ const getSessionTargeting = ({ adTest, countryCode, localHour, isSignedIn, pageViewId, participations, referrer, idProviders, }) => ({
67
70
  ab: experimentsTargeting(participations),
68
71
  at: adTest,
69
72
  cc: countryCode,
@@ -71,5 +74,6 @@ const getSessionTargeting = ({ adTest, countryCode, localHour, isSignedIn, pageV
71
74
  pv: pageViewId,
72
75
  ref: getReferrer(referrer),
73
76
  si: isSignedIn ? 't' : 'f',
77
+ idp: getIdProviders(idProviders),
74
78
  });
75
79
  exports.getSessionTargeting = getSessionTargeting;
@@ -1,3 +1,3 @@
1
- type HashClient = 'id5' | 'uid2';
1
+ type HashClient = 'id5' | 'uid2' | 'euid';
2
2
  declare function hashEmailForClient(email: string, client: HashClient): Promise<string>;
3
3
  export { hashEmailForClient };
@@ -18,6 +18,7 @@ async function hashEmailForClient(email, client) {
18
18
  case 'id5':
19
19
  return toHex(hashBuffer);
20
20
  case 'uid2':
21
+ case 'euid':
21
22
  return toBase64(hashBuffer);
22
23
  }
23
24
  }
@@ -30,6 +30,7 @@ type PageTargeting = PartialWithNulls<{
30
30
  s: string;
31
31
  sens: TrueOrFalse;
32
32
  si: TrueOrFalse;
33
+ idp: string[];
33
34
  skinsize: 'l' | 's';
34
35
  urlkw: string[];
35
36
  vl: string;
@@ -37,13 +38,24 @@ type PageTargeting = PartialWithNulls<{
37
38
  [_: string]: string | string[];
38
39
  } & SharedTargeting>;
39
40
  declare const filterValues: (pageTargets: Record<string, unknown>) => Record<string, string | string[]>;
41
+ type UserId = {
42
+ name: string;
43
+ params?: Record<string, string | number>;
44
+ storage?: {
45
+ type: 'cookie' | 'html5';
46
+ name: string;
47
+ expires: number;
48
+ refreshInSeconds?: number;
49
+ };
50
+ };
40
51
  type BuildPageTargetingParams = {
41
52
  adFree: boolean;
42
53
  clientSideParticipations: Participations;
43
54
  consentState: ConsentState;
44
55
  isSignedIn?: boolean;
45
56
  youtube?: boolean;
57
+ idProviders?: UserId[];
46
58
  };
47
- declare const buildPageTargeting: ({ adFree, clientSideParticipations, consentState, isSignedIn, youtube, }: BuildPageTargetingParams) => Record<string, string | string[]>;
59
+ declare const buildPageTargeting: ({ adFree, clientSideParticipations, consentState, isSignedIn, youtube, idProviders, }: BuildPageTargetingParams) => Record<string, string | string[]>;
48
60
  export { buildPageTargeting, filterValues, getLocalHour };
49
- export type { PageTargeting };
61
+ export type { UserId, PageTargeting };
@@ -44,7 +44,7 @@ const isFirstVisit = (referrer) => {
44
44
  }
45
45
  return !referrerMatchesHost(referrer);
46
46
  };
47
- const buildPageTargeting = ({ adFree, clientSideParticipations, consentState, isSignedIn = false, youtube = false, }) => {
47
+ const buildPageTargeting = ({ adFree, clientSideParticipations, consentState, isSignedIn = false, youtube = false, idProviders = [], }) => {
48
48
  const { page, isDotcomRendering } = window.guardian.config;
49
49
  const adFreeTargeting = adFree ? { af: 't' } : {};
50
50
  const sharedAdTargeting = page.sharedAdTargeting
@@ -75,6 +75,7 @@ const buildPageTargeting = ({ adFree, clientSideParticipations, consentState, is
75
75
  betaAbTestParticipations: window.guardian.modules.abTests?.getParticipations() ?? {},
76
76
  },
77
77
  referrer,
78
+ idProviders,
78
79
  });
79
80
  const getViewport = () => {
80
81
  return {
@@ -1,5 +1,6 @@
1
1
  import type { Participations } from '@guardian/ab-core';
2
2
  import type { CountryCode } from '@guardian/libs';
3
+ import type { UserId } from '../targeting/build-page-targeting.js';
3
4
  import type { False, True } from './types.js';
4
5
  declare const referrers: readonly [{
5
6
  readonly id: "facebook";
@@ -97,6 +98,14 @@ type SessionTargeting = {
97
98
  * [gam]: https://admanager.google.com/59666047#inventory/custom_targeting/detail/custom_key_id=215727
98
99
  */
99
100
  si: True | False;
101
+ /**
102
+ * **I**d **P**roviders – [see on Ad Manager][gam]
103
+ *
104
+ * Denote which id providers have been integrated.
105
+ *
106
+ * [gam]: To be added
107
+ */
108
+ idp: string[] | null;
100
109
  };
101
110
  type AllParticipations = {
102
111
  clientSideParticipations: Participations;
@@ -119,7 +128,8 @@ type Session = {
119
128
  pageViewId: SessionTargeting['pv'];
120
129
  participations: AllParticipations;
121
130
  referrer: string;
131
+ idProviders: UserId[];
122
132
  };
123
- declare const getSessionTargeting: ({ adTest, countryCode, localHour, isSignedIn, pageViewId, participations, referrer, }: Session) => SessionTargeting;
133
+ declare const getSessionTargeting: ({ adTest, countryCode, localHour, isSignedIn, pageViewId, participations, referrer, idProviders, }: Session) => SessionTargeting;
124
134
  export type { SessionTargeting, AllParticipations };
125
135
  export { getSessionTargeting, experimentsTargeting };
@@ -59,7 +59,10 @@ const experimentsTargeting = ({ clientSideParticipations, serverSideParticipatio
59
59
  }
60
60
  return [...clientSideExperiment, ...serverSideExperiments, ...betaAbTests];
61
61
  };
62
- const getSessionTargeting = ({ adTest, countryCode, localHour, isSignedIn, pageViewId, participations, referrer, }) => ({
62
+ const getIdProviders = (userIds) => {
63
+ return userIds.map((id) => id.name);
64
+ };
65
+ const getSessionTargeting = ({ adTest, countryCode, localHour, isSignedIn, pageViewId, participations, referrer, idProviders, }) => ({
63
66
  ab: experimentsTargeting(participations),
64
67
  at: adTest,
65
68
  cc: countryCode,
@@ -67,5 +70,6 @@ const getSessionTargeting = ({ adTest, countryCode, localHour, isSignedIn, pageV
67
70
  pv: pageViewId,
68
71
  ref: getReferrer(referrer),
69
72
  si: isSignedIn ? 't' : 'f',
73
+ idp: getIdProviders(idProviders),
70
74
  });
71
75
  export { getSessionTargeting, experimentsTargeting };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/commercial-core",
3
- "version": "30.0.0",
3
+ "version": "30.1.0",
4
4
  "description": "Guardian advertising business logic",
5
5
  "homepage": "https://github.com/guardian/commercial#readme",
6
6
  "bugs": {