@guardian/commercial-core 4.2.1 → 4.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.
@@ -73,39 +73,27 @@ const getFrequencyValue = (state) => {
73
73
  }
74
74
  return '0';
75
75
  };
76
- const tcfv2AllPurposesConsented = (consents) => Object.keys(consents).length > 0 && Object.values(consents).every(Boolean);
77
- const personalisedAdvertising = (state) => {
78
- if (state.tcfv2)
79
- return tcfv2AllPurposesConsented(state.tcfv2.consents);
80
- if (state.ccpa)
81
- return !state.ccpa.doNotSell;
82
- if (state.aus)
83
- return state.aus.personalisedAdvertising;
84
- return false;
85
- };
86
76
  const getCMPTargeting = (state) => {
87
77
  if (state.tcfv2) {
88
78
  return {
89
79
  cmp_interaction: state.tcfv2.eventStatus,
90
- pa: tcfv2AllPurposesConsented(state.tcfv2.consents) ? 't' : 'f',
91
- consent_tcfv2: tcfv2AllPurposesConsented(state.tcfv2.consents)
92
- ? 't'
93
- : 'f',
80
+ pa: state.canTarget ? 't' : 'f',
81
+ consent_tcfv2: state.canTarget ? 't' : 'f',
94
82
  rdp: 'na',
95
83
  };
96
84
  }
97
85
  if (state.ccpa) {
98
86
  return {
99
87
  consent_tcfv2: 'na',
100
- rdp: state.ccpa.doNotSell ? 't' : 'f',
101
- pa: state.ccpa.doNotSell ? 'f' : 't',
88
+ rdp: !state.canTarget ? 't' : 'f',
89
+ pa: state.canTarget ? 't' : 'f',
102
90
  };
103
91
  }
104
92
  if (state.aus) {
105
93
  return {
106
94
  consent_tcfv2: 'na',
107
95
  rdp: 'na',
108
- pa: state.aus.personalisedAdvertising ? 't' : 'f',
96
+ pa: state.canTarget ? 't' : 'f',
109
97
  };
110
98
  }
111
99
  return {
@@ -123,7 +111,11 @@ const createAdManagerGroup = () => {
123
111
  return group;
124
112
  };
125
113
  const getAdManagerGroup = (state) => {
126
- if (!personalisedAdvertising(state)) {
114
+ if (!state.framework) {
115
+ libs_1.storage.local.remove(AMTGRP_STORAGE_KEY);
116
+ return null;
117
+ }
118
+ if (state.tcfv2 && !state.canTarget) {
127
119
  libs_1.storage.local.remove(AMTGRP_STORAGE_KEY);
128
120
  return null;
129
121
  }
@@ -133,7 +125,7 @@ const getAdManagerGroup = (state) => {
133
125
  : createAdManagerGroup();
134
126
  };
135
127
  const getPermutiveWithState = (state) => {
136
- if (personalisedAdvertising(state))
128
+ if (state.canTarget)
137
129
  return (0, permutive_1.getPermutiveSegments)();
138
130
  (0, permutive_1.clearPermutiveSegments)();
139
131
  return [];
@@ -70,39 +70,27 @@ const getFrequencyValue = (state) => {
70
70
  }
71
71
  return '0';
72
72
  };
73
- const tcfv2AllPurposesConsented = (consents) => Object.keys(consents).length > 0 && Object.values(consents).every(Boolean);
74
- const personalisedAdvertising = (state) => {
75
- if (state.tcfv2)
76
- return tcfv2AllPurposesConsented(state.tcfv2.consents);
77
- if (state.ccpa)
78
- return !state.ccpa.doNotSell;
79
- if (state.aus)
80
- return state.aus.personalisedAdvertising;
81
- return false;
82
- };
83
73
  const getCMPTargeting = (state) => {
84
74
  if (state.tcfv2) {
85
75
  return {
86
76
  cmp_interaction: state.tcfv2.eventStatus,
87
- pa: tcfv2AllPurposesConsented(state.tcfv2.consents) ? 't' : 'f',
88
- consent_tcfv2: tcfv2AllPurposesConsented(state.tcfv2.consents)
89
- ? 't'
90
- : 'f',
77
+ pa: state.canTarget ? 't' : 'f',
78
+ consent_tcfv2: state.canTarget ? 't' : 'f',
91
79
  rdp: 'na',
92
80
  };
93
81
  }
94
82
  if (state.ccpa) {
95
83
  return {
96
84
  consent_tcfv2: 'na',
97
- rdp: state.ccpa.doNotSell ? 't' : 'f',
98
- pa: state.ccpa.doNotSell ? 'f' : 't',
85
+ rdp: !state.canTarget ? 't' : 'f',
86
+ pa: state.canTarget ? 't' : 'f',
99
87
  };
100
88
  }
101
89
  if (state.aus) {
102
90
  return {
103
91
  consent_tcfv2: 'na',
104
92
  rdp: 'na',
105
- pa: state.aus.personalisedAdvertising ? 't' : 'f',
93
+ pa: state.canTarget ? 't' : 'f',
106
94
  };
107
95
  }
108
96
  return {
@@ -120,7 +108,11 @@ const createAdManagerGroup = () => {
120
108
  return group;
121
109
  };
122
110
  const getAdManagerGroup = (state) => {
123
- if (!personalisedAdvertising(state)) {
111
+ if (!state.framework) {
112
+ storage.local.remove(AMTGRP_STORAGE_KEY);
113
+ return null;
114
+ }
115
+ if (state.tcfv2 && !state.canTarget) {
124
116
  storage.local.remove(AMTGRP_STORAGE_KEY);
125
117
  return null;
126
118
  }
@@ -130,7 +122,7 @@ const getAdManagerGroup = (state) => {
130
122
  : createAdManagerGroup();
131
123
  };
132
124
  const getPermutiveWithState = (state) => {
133
- if (personalisedAdvertising(state))
125
+ if (state.canTarget)
134
126
  return getPermutiveSegments();
135
127
  clearPermutiveSegments();
136
128
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/commercial-core",
3
- "version": "4.2.1",
3
+ "version": "4.3.0",
4
4
  "description": "Guardian advertising business logic",
5
5
  "homepage": "https://github.com/guardian/commercial-core#readme",
6
6
  "bugs": {