Skip to content

Commit

Permalink
Merge f92b664 into f98e690
Browse files Browse the repository at this point in the history
  • Loading branch information
akinsola-guardian authored Jan 9, 2025
2 parents f98e690 + f92b664 commit 8fce388
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/wise-dancers-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@guardian/libs': minor
---

Stop showing CMP on info pages
1 change: 1 addition & 0 deletions @types/window.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ declare global {
tests?: ServerSideTests;
page?: {
isPreview: boolean;
section?: string;
};
stage?: string;
isDev?: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const sectionExclusionList = ['info', 'help'];

export const isExcludedFromCMP = (pageSection: string): boolean => {
console.log('pageSection', pageSection);
return sectionExclusionList.some((section) => section === pageSection);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 14 additions & 6 deletions libs/@guardian/libs/src/consent-management-platform/sourcepoint.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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 */
Expand All @@ -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() },

Expand Down Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ declare global {
propertyId?: number;
targetingParams: {
framework: ConsentFramework;
excludePage: boolean;
};
ccpa?: {
targetingParams?: {
Expand All @@ -45,6 +46,7 @@ declare global {
gdpr?: {
targetingParams?: {
framework: ConsentFramework;
excludePage: boolean;
};
};
usnat?: {
Expand Down

0 comments on commit 8fce388

Please sign in to comment.