diff --git a/.changeset/wise-dancers-travel.md b/.changeset/wise-dancers-travel.md new file mode 100644 index 000000000..e7cf22023 --- /dev/null +++ b/.changeset/wise-dancers-travel.md @@ -0,0 +1,5 @@ +--- +'@guardian/libs': minor +--- + +Stop showing CMP on info pages diff --git a/@types/window.d.ts b/@types/window.d.ts index ae4cad9a4..675772a85 100644 --- a/@types/window.d.ts +++ b/@types/window.d.ts @@ -20,6 +20,7 @@ declare global { tests?: ServerSideTests; page?: { isPreview: boolean; + section?: string; }; stage?: string; isDev?: boolean; diff --git a/libs/@guardian/libs/src/consent-management-platform/exclusionList.test.js b/libs/@guardian/libs/src/consent-management-platform/exclusionList.test.js new file mode 100644 index 000000000..b37eeeb5f --- /dev/null +++ b/libs/@guardian/libs/src/consent-management-platform/exclusionList.test.js @@ -0,0 +1,15 @@ +import { isExcludedFromCMP } from './exclusionList.ts'; + +describe('isExcludedFromCMP', () => { + test('should return false if empty', () => { + expect(isExcludedFromCMP('')).toBe(false); + }); + + test('should return false if param not in sectionExclusionList', () => { + expect(isExcludedFromCMP('foo')).toBe(false); + }); + + test('should return true if param in sectionExclusionList', () => { + expect(isExcludedFromCMP('info')).toBe(true); + }); +}); diff --git a/libs/@guardian/libs/src/consent-management-platform/exclusionList.ts b/libs/@guardian/libs/src/consent-management-platform/exclusionList.ts new file mode 100644 index 000000000..63bd8be0f --- /dev/null +++ b/libs/@guardian/libs/src/consent-management-platform/exclusionList.ts @@ -0,0 +1,6 @@ +const sectionExclusionList = ['info', 'help']; + +export const isExcludedFromCMP = (pageSection: string): boolean => { + console.log('pageSection', pageSection); + return sectionExclusionList.some((section) => section === pageSection); +}; diff --git a/libs/@guardian/libs/src/consent-management-platform/lib/sourcepointConfig.ts b/libs/@guardian/libs/src/consent-management-platform/lib/sourcepointConfig.ts index 6dbaab03e..5ddc37000 100644 --- a/libs/@guardian/libs/src/consent-management-platform/lib/sourcepointConfig.ts +++ b/libs/@guardian/libs/src/consent-management-platform/lib/sourcepointConfig.ts @@ -2,7 +2,8 @@ import { isGuardianDomain } from './domain'; export const ACCOUNT_ID = 1257; export const PRIVACY_MANAGER_USNAT = 1068329; -export const PROPERTY_ID = 7417; +// export const PROPERTY_ID = 7417; +export const PROPERTY_ID = 9398; export const PROPERTY_ID_AUSTRALIA = 13348; export const PRIVACY_MANAGER_TCFV2 = 106842; export const PRIVACY_MANAGER_AUSTRALIA = 1178486; diff --git a/libs/@guardian/libs/src/consent-management-platform/sourcepoint.ts b/libs/@guardian/libs/src/consent-management-platform/sourcepoint.ts index d6a30b2e7..661a596d0 100644 --- a/libs/@guardian/libs/src/consent-management-platform/sourcepoint.ts +++ b/libs/@guardian/libs/src/consent-management-platform/sourcepoint.ts @@ -1,4 +1,5 @@ import { log } from '../logger/logger'; +import { isExcludedFromCMP } from './exclusionList'; import { setCurrentFramework } from './getCurrentFramework'; import { isGuardianDomain } from './lib/domain'; import { mark } from './lib/mark'; @@ -30,7 +31,8 @@ const getPropertyHref = (framework: ConsentFramework): Property => { if (framework == 'aus') { return 'https://au.theguardian.com'; } - return isGuardianDomain() ? null : 'https://test.theguardian.com'; + return isGuardianDomain() ? null : 'http://ui-dev'; + // return isGuardianDomain() ? null : 'https://test.theguardian.com'; }; const getPropertyId = (framework: ConsentFramework): number => { @@ -74,6 +76,7 @@ export const init = (framework: ConsentFramework, pubData = {}): void => { log('cmp', `framework: ${framework}`); log('cmp', `frameworkMessageType: ${frameworkMessageType}`); + const pageSection = window.guardian?.config?.page?.section as string; window._sp_queue = []; /* istanbul ignore next */ @@ -84,6 +87,7 @@ export const init = (framework: ConsentFramework, pubData = {}): void => { propertyHref: getPropertyHref(framework), targetingParams: { framework, + excludePage: isExcludedFromCMP(pageSection), }, pubData: { ...pubData, cmpInitTimeUtc: new Date().getTime() }, @@ -195,11 +199,15 @@ export const init = (framework: ConsentFramework, pubData = {}): void => { switch (framework) { case 'tcfv2': - window._sp_.config.gdpr = { - targetingParams: { - framework, - }, - }; + { + const pageSection = window.guardian?.config?.page?.section as string; + window._sp_.config.gdpr = { + targetingParams: { + framework, + excludePage: isExcludedFromCMP(pageSection), + }, + }; + } break; case 'usnat': window._sp_.config.usnat = { diff --git a/libs/@guardian/libs/src/consent-management-platform/types/window.d.ts b/libs/@guardian/libs/src/consent-management-platform/types/window.d.ts index 26d1c4d2a..dd43b4b6a 100644 --- a/libs/@guardian/libs/src/consent-management-platform/types/window.d.ts +++ b/libs/@guardian/libs/src/consent-management-platform/types/window.d.ts @@ -36,6 +36,7 @@ declare global { propertyId?: number; targetingParams: { framework: ConsentFramework; + excludePage: boolean; }; ccpa?: { targetingParams?: { @@ -45,6 +46,7 @@ declare global { gdpr?: { targetingParams?: { framework: ConsentFramework; + excludePage: boolean; }; }; usnat?: {