Skip to content

Commit

Permalink
Update @guardian/libs and @guardian/commercial for usnat framework (#…
Browse files Browse the repository at this point in the history
…12483)

* Use latest version of libs that contains usnat. Use beta commercial

* Swap ccpa with usnat through code base.

Check for both ccpaUUID and usnatUUID cookie for US

* Update @guardian/libs

* Use latest commercial beta

* Bumped version of commercial
  • Loading branch information
akinsola-guardian authored Oct 15, 2024
1 parent f45b82e commit 802cafa
Show file tree
Hide file tree
Showing 6 changed files with 428 additions and 422 deletions.
4 changes: 2 additions & 2 deletions dotcom-rendering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
"@guardian/bridget": "7.0.0",
"@guardian/browserslist-config": "6.1.0",
"@guardian/cdk": "50.13.0",
"@guardian/commercial": "22.3.0",
"@guardian/commercial": "23.0.0",
"@guardian/core-web-vitals": "7.0.0",
"@guardian/eslint-config": "7.0.1",
"@guardian/eslint-config-typescript": "9.0.1",
"@guardian/identity-auth": "2.1.0",
"@guardian/identity-auth-frontend": "4.0.0",
"@guardian/libs": "18.0.0",
"@guardian/libs": "19.1.0",
"@guardian/ophan-tracker-js": "2.2.5",
"@guardian/shimport": "1.0.2",
"@guardian/source": "8.0.0",
Expand Down
14 changes: 9 additions & 5 deletions dotcom-rendering/src/client/bootCmp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const submitConsentToOphan = async (renderingTarget: RenderingTarget) => {
const consentState: ConsentState = await onConsent();

const consentDetails = (): {
consentJurisdiction: 'TCF' | 'CCPA' | 'AUS' | 'OTHER';
consentJurisdiction: 'TCF' | 'USNAT' | 'AUS' | 'OTHER';
consentUUID: string;
consent: string;
} => {
Expand All @@ -20,11 +20,15 @@ const submitConsentToOphan = async (renderingTarget: RenderingTarget) => {
consent: consentState.tcfv2.tcString,
};
}
if (consentState.ccpa) {
if (consentState.usnat) {
// Users who interacted with the CCPA banner before the migration to usnat will still have a ccpaUUID cookie. The usnatUUID cookie is set when the USNAT banner is interacted with. We need to check both cookies to ensure we have the correct consentUUID.
const consentUUID =
getCookie({ name: 'usnatUUID' }) ??
getCookie({ name: 'ccpaUUID' });
return {
consentJurisdiction: 'CCPA',
consentUUID: getCookie({ name: 'ccpaUUID' }) ?? '',
consent: consentState.ccpa.doNotSell ? 'false' : 'true',
consentJurisdiction: 'USNAT',
consentUUID: consentUUID ?? '',
consent: consentState.usnat.doNotSell ? 'false' : 'true',
};
}
if (consentState.aus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const PrivacySettingsLink = ({ extraClasses }: Props) => {
cmp.showPrivacyManager();
}}
>
{framework === 'ccpa'
{framework === 'usnat'
? 'California resident – Do Not Sell'
: 'Privacy settings'}
</ButtonLink>
Expand Down
8 changes: 4 additions & 4 deletions dotcom-rendering/src/lib/braze/hasRequiredConsents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ describe('hasRequiredConsents', () => {
});
});

describe('when the user is covered by ccpa and consent is given', () => {
describe('when the user is covered by usnat and consent is given', () => {
it('returns a promise which resolves with true', async () => {
mockOnConsentChangeResult = {
ccpa: {
usnat: {
doNotSell: false,
},
};
Expand All @@ -55,10 +55,10 @@ describe('hasRequiredConsents', () => {
});
});

describe('when the user is covered by ccpa and consent is not given', () => {
describe('when the user is covered by usnat and consent is not given', () => {
it('returns a promise which resolves with false', async () => {
mockOnConsentChangeResult = {
ccpa: {
usnat: {
doNotSell: true,
},
};
Expand Down
8 changes: 4 additions & 4 deletions dotcom-rendering/src/lib/contributions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ export const hasCmpConsentForArticleCount = (): Promise<boolean> => {
if (getCookie({ name: 'gu-cmp-disabled', shouldMemoize: true })) {
resolve(true);
}
onConsentChange(({ ccpa, tcfv2, aus }) => {
if (ccpa ?? aus) {
onConsentChange(({ usnat, tcfv2, aus }) => {
if (usnat ?? aus) {
resolve(true);
} else if (tcfv2) {
const hasRequiredConsents =
Expand Down Expand Up @@ -236,8 +236,8 @@ export const hasCmpConsentForBrowserId = (): Promise<boolean> =>
if (getCookie({ name: 'gu-cmp-disabled', shouldMemoize: true })) {
resolve(true);
}
onConsentChange(({ ccpa, tcfv2, aus }) => {
if (ccpa ?? aus) {
onConsentChange(({ usnat, tcfv2, aus }) => {
if (usnat ?? aus) {
resolve(true);
} else if (tcfv2) {
const hasRequiredConsents =
Expand Down
Loading

0 comments on commit 802cafa

Please sign in to comment.