@guardian/commercial-core 0.34.1 → 0.35.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.
@@ -58,12 +58,13 @@ export declare type ContentTargeting = {
58
58
  */
59
59
  vl: null | typeof videoLengths[number];
60
60
  };
61
- export declare const getContentTargeting: ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, }: {
61
+ declare type Content = {
62
62
  eligibleForDCR: boolean;
63
63
  path: SharedTargeting['url'];
64
64
  renderingPlatform: ContentTargeting['rp'];
65
65
  section: ContentTargeting['s'];
66
66
  sensitive: boolean;
67
- videoLength?: number | undefined;
68
- }) => ContentTargeting;
67
+ videoLength?: number;
68
+ };
69
+ export declare const getContentTargeting: ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, }: Content) => ContentTargeting;
69
70
  export {};
@@ -28,7 +28,6 @@ const getUrlKeywords = (url) => {
28
28
  .slice(-1)[0];
29
29
  return (0, libs_1.isString)(lastSegment) ? lastSegment.split('-').filter(Boolean) : [];
30
30
  };
31
- /* -- Targeting -- */
32
31
  const getContentTargeting = ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, }) => {
33
32
  return {
34
33
  dcre: eligibleForDCR ? 't' : 'f',
@@ -92,7 +92,18 @@ export declare type SessionTargeting = {
92
92
  };
93
93
  export declare type AllParticipations = {
94
94
  clientSideParticipations: Participations;
95
- serverSideParticipations: Record<string, 'control' | 'variant'>;
95
+ serverSideParticipations: {
96
+ [key: `${string}Control`]: 'control';
97
+ [key: `${string}Variant`]: 'variant';
98
+ };
96
99
  };
97
- export declare const getSessionTargeting: (referrer: string, participations: AllParticipations, targeting: Omit<SessionTargeting, 'ab' | 'ref'>) => SessionTargeting;
100
+ declare type Session = {
101
+ adTest: SessionTargeting['at'];
102
+ countryCode: CountryCode;
103
+ isSignedIn: boolean;
104
+ pageViewId: SessionTargeting['pv'];
105
+ participations: AllParticipations;
106
+ referrer: string;
107
+ };
108
+ export declare const getSessionTargeting: ({ adTest, countryCode, isSignedIn, pageViewId, participations, referrer, }: Session) => SessionTargeting;
98
109
  export {};
@@ -49,10 +49,12 @@ const experimentsTargeting = ({ clientSideParticipations, serverSideParticipatio
49
49
  }
50
50
  return [...clientSideExperiment, ...serverSideExperiments];
51
51
  };
52
- /* -- Targeting -- */
53
- const getSessionTargeting = (referrer, participations, targeting) => ({
54
- ref: getReferrer(referrer),
52
+ const getSessionTargeting = ({ adTest, countryCode, isSignedIn, pageViewId, participations, referrer, }) => ({
55
53
  ab: experimentsTargeting(participations),
56
- ...targeting,
54
+ at: adTest,
55
+ cc: countryCode,
56
+ pv: pageViewId,
57
+ ref: getReferrer(referrer),
58
+ si: isSignedIn ? 't' : 'f',
57
59
  });
58
60
  exports.getSessionTargeting = getSessionTargeting;
@@ -58,12 +58,13 @@ export declare type ContentTargeting = {
58
58
  */
59
59
  vl: null | typeof videoLengths[number];
60
60
  };
61
- export declare const getContentTargeting: ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, }: {
61
+ declare type Content = {
62
62
  eligibleForDCR: boolean;
63
63
  path: SharedTargeting['url'];
64
64
  renderingPlatform: ContentTargeting['rp'];
65
65
  section: ContentTargeting['s'];
66
66
  sensitive: boolean;
67
- videoLength?: number | undefined;
68
- }) => ContentTargeting;
67
+ videoLength?: number;
68
+ };
69
+ export declare const getContentTargeting: ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, }: Content) => ContentTargeting;
69
70
  export {};
@@ -25,7 +25,6 @@ const getUrlKeywords = (url) => {
25
25
  .slice(-1)[0];
26
26
  return isString(lastSegment) ? lastSegment.split('-').filter(Boolean) : [];
27
27
  };
28
- /* -- Targeting -- */
29
28
  export const getContentTargeting = ({ eligibleForDCR, path, renderingPlatform, section, sensitive, videoLength, }) => {
30
29
  return {
31
30
  dcre: eligibleForDCR ? 't' : 'f',
@@ -92,7 +92,18 @@ export declare type SessionTargeting = {
92
92
  };
93
93
  export declare type AllParticipations = {
94
94
  clientSideParticipations: Participations;
95
- serverSideParticipations: Record<string, 'control' | 'variant'>;
95
+ serverSideParticipations: {
96
+ [key: `${string}Control`]: 'control';
97
+ [key: `${string}Variant`]: 'variant';
98
+ };
96
99
  };
97
- export declare const getSessionTargeting: (referrer: string, participations: AllParticipations, targeting: Omit<SessionTargeting, 'ab' | 'ref'>) => SessionTargeting;
100
+ declare type Session = {
101
+ adTest: SessionTargeting['at'];
102
+ countryCode: CountryCode;
103
+ isSignedIn: boolean;
104
+ pageViewId: SessionTargeting['pv'];
105
+ participations: AllParticipations;
106
+ referrer: string;
107
+ };
108
+ export declare const getSessionTargeting: ({ adTest, countryCode, isSignedIn, pageViewId, participations, referrer, }: Session) => SessionTargeting;
98
109
  export {};
@@ -46,9 +46,11 @@ const experimentsTargeting = ({ clientSideParticipations, serverSideParticipatio
46
46
  }
47
47
  return [...clientSideExperiment, ...serverSideExperiments];
48
48
  };
49
- /* -- Targeting -- */
50
- export const getSessionTargeting = (referrer, participations, targeting) => ({
51
- ref: getReferrer(referrer),
49
+ export const getSessionTargeting = ({ adTest, countryCode, isSignedIn, pageViewId, participations, referrer, }) => ({
52
50
  ab: experimentsTargeting(participations),
53
- ...targeting,
51
+ at: adTest,
52
+ cc: countryCode,
53
+ pv: pageViewId,
54
+ ref: getReferrer(referrer),
55
+ si: isSignedIn ? 't' : 'f',
54
56
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/commercial-core",
3
- "version": "0.34.1",
3
+ "version": "0.35.0",
4
4
  "description": "Guardian advertising business logic",
5
5
  "homepage": "https://github.com/guardian/commercial-core#readme",
6
6
  "bugs": {