Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update @guardian/libs and @guardian/commercial for usnat framework #12483

Merged
merged 9 commits into from
Oct 15, 2024
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
Loading