Skip to content

Commit 72fd1d7

Browse files
Merge pull request #1298 from guardian/lp-hide-support-messages-on-info-pages-sdc
Hide epic and banners for info pages
2 parents f35854a + 2a1a474 commit 72fd1d7

File tree

8 files changed

+40
-0
lines changed

8 files changed

+40
-0
lines changed

.changeset/gorgeous-days-give.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@guardian/support-dotcom-components': minor
3+
---
4+
5+
Add pageId to targeting

src/server/api/bannerRouter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
TestTracking,
1010
BannerDesignFromTool,
1111
Tracking,
12+
hideSRMessagingForInfoPageIds,
1213
} from '../../shared/types';
1314
import { selectAmountsTestVariant } from '../lib/ab';
1415
import { ChannelSwitches } from '../channelSwitches';
@@ -60,6 +61,10 @@ export const buildBannerRouter = (
6061
return {};
6162
}
6263

64+
if (hideSRMessagingForInfoPageIds(targeting)) {
65+
return {};
66+
}
67+
6368
const selectedTest = selectBannerTest(
6469
targeting,
6570
getDeviceType(req),

src/server/api/epicRouter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
EpicTest,
77
EpicType,
88
EpicVariant,
9+
hideSRMessagingForInfoPageIds,
910
TestTracking,
1011
Tracking,
1112
WeeklyArticleLog,
@@ -83,6 +84,10 @@ export const buildEpicRouter = (
8384
return {};
8485
}
8586

87+
if (hideSRMessagingForInfoPageIds(targeting)) {
88+
return {};
89+
}
90+
8691
const targetingMvtId = targeting.mvtId || 1;
8792

8893
const tests =

src/server/api/gutterRouter.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
TestTracking,
99
GutterTargeting,
1010
Tracking,
11+
hideSRMessagingForInfoPageIds,
1112
} from '../../shared/types';
1213
import { ChannelSwitches } from '../channelSwitches';
1314
import { getDeviceType } from '../lib/deviceType';
@@ -41,6 +42,11 @@ export const buildGutterRouter = (
4142
if (!enableGutterLiveblogs) {
4243
return {};
4344
}
45+
46+
if (hideSRMessagingForInfoPageIds(targeting)) {
47+
return {};
48+
}
49+
4450
const testSelection = selectGutterTest(
4551
targeting,
4652
tests.get(),

src/shared/types/targeting/banner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type BannerTargeting = {
2121
isSignedIn: boolean;
2222
hasConsented: boolean;
2323
abandonedBasket?: AbandonedBasket;
24+
pageId?: string;
2425
};
2526

2627
export type BannerPayload = {

src/shared/types/targeting/epic.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type EpicTargeting = {
2525
url?: string;
2626
browserId?: string; // Only present if the user has consented to browserId-based targeting
2727
isSignedIn?: boolean;
28+
pageId?: string;
2829
};
2930

3031
export type EpicPayload = {

src/shared/types/targeting/gutter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface GutterTargeting {
55
isSignedIn: boolean;
66
tagIds?: string[];
77
sectionId?: string;
8+
pageId?: string;
89
}
910

1011
export type GutterPayload = {

src/shared/types/targeting/shared.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { z } from 'zod';
22
import { purchaseInfoProduct, purchaseInfoUser } from '../purchaseInfo';
3+
import { BannerTargeting } from './banner';
4+
import { EpicTargeting } from './epic';
5+
import { GutterTargeting } from './gutter';
36

47
export type TagCounts = {
58
[tag: string]: number;
@@ -28,6 +31,19 @@ export interface PurchaseInfo {
2831
product: purchaseInfoProduct;
2932
}
3033

34+
//The pageIdsOfInterest has the pageIds in which we want to hide the SR messages
35+
export const pageIdsOfInterest = new Set<string>([
36+
'info/privacy',
37+
'info/complaints-and-corrections',
38+
'about',
39+
]);
40+
41+
export const hideSRMessagingForInfoPageIds = (
42+
targeting: BannerTargeting | EpicTargeting | GutterTargeting,
43+
): boolean => {
44+
return targeting.pageId ? pageIdsOfInterest.has(targeting.pageId) : false;
45+
};
46+
3147
export const abandonedBasketSchema = z.object({
3248
amount: z.union([z.number(), z.literal('other')]),
3349
billingPeriod: z.union([z.literal('ONE_OFF'), z.literal('MONTHLY'), z.literal('ANNUAL')]),

0 commit comments

Comments
 (0)