Skip to content

Commit 3e501a4

Browse files
authored
Merge pull request #1426 from guardian/tf-whole-pic
Exclude /the-whole-picture
1 parent 7d55e24 commit 3e501a4

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

src/server/api/bannerRouter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import type {
1212
Tracking,
1313
} from '../../shared/types';
1414
import { channelFromBannerChannel } from '../../shared/types';
15-
import { hideSRMessagingForInfoPageIds } from '../../shared/types';
1615
import type { ChannelSwitches } from '../channelSwitches';
1716
import { getChoiceCardsSettings } from '../lib/choiceCards/choiceCards';
1817
import { getDeviceType } from '../lib/deviceType';
@@ -22,6 +21,7 @@ import { getArticleViewCounts } from '../lib/history';
2221
import type { Params } from '../lib/params';
2322
import { getQueryParams } from '../lib/params';
2423
import type { PromotionsCache } from '../lib/promotions/promotions';
24+
import { pageIdIsExcluded } from '../lib/targeting';
2525
import { buildBannerCampaignCode } from '../lib/tracking';
2626
import type { ProductCatalog } from '../productCatalog';
2727
import { selectAmountsTestVariant } from '../selection/ab';
@@ -69,7 +69,7 @@ export const buildBannerRouter = (
6969
return {};
7070
}
7171

72-
if (hideSRMessagingForInfoPageIds(targeting)) {
72+
if (pageIdIsExcluded(targeting)) {
7373
return {};
7474
}
7575

src/server/api/epicRouter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import type {
1212
Tracking,
1313
WeeklyArticleLog,
1414
} from '../../shared/types';
15-
import { hideSRMessagingForInfoPageIds } from '../../shared/types';
1615
import type { ChannelSwitches } from '../channelSwitches';
1716
import { getChoiceCardsSettings } from '../lib/choiceCards/choiceCards';
1817
import { getDeviceType } from '../lib/deviceType';
@@ -23,6 +22,7 @@ import type { Params } from '../lib/params';
2322
import { getQueryParams } from '../lib/params';
2423
import type { PromotionsCache } from '../lib/promotions/promotions';
2524
import type { SuperModeArticle } from '../lib/superMode';
25+
import { pageIdIsExcluded } from '../lib/targeting';
2626
import { buildEpicCampaignCode } from '../lib/tracking';
2727
import type { ProductCatalog } from '../productCatalog';
2828
import { selectAmountsTestVariant } from '../selection/ab';
@@ -92,7 +92,7 @@ export const buildEpicRouter = (
9292
return {};
9393
}
9494

95-
if (hideSRMessagingForInfoPageIds(targeting)) {
95+
if (pageIdIsExcluded(targeting)) {
9696
return {};
9797
}
9898

src/server/api/gutterRouter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import type {
77
TestTracking,
88
Tracking,
99
} from '../../shared/types';
10-
import { hideSRMessagingForInfoPageIds } from '../../shared/types';
1110
import type { ChannelSwitches } from '../channelSwitches';
1211
import { getDeviceType } from '../lib/deviceType';
1312
import { baseUrl } from '../lib/env';
1413
import { getQueryParams } from '../lib/params';
1514
import type { Params } from '../lib/params';
15+
import { pageIdIsExcluded } from '../lib/targeting';
1616
import { buildGutterCampaignCode } from '../lib/tracking';
1717
import { bodyContainsAllFields } from '../middleware';
1818
import { selectGutterTest } from '../tests/gutters/gutterSelection';
@@ -45,7 +45,7 @@ export const buildGutterRouter = (
4545
return {};
4646
}
4747

48-
if (hideSRMessagingForInfoPageIds(targeting)) {
48+
if (pageIdIsExcluded(targeting)) {
4949
return {};
5050
}
5151

src/server/lib/targeting.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import type {
22
AbandonedBasket,
33
BannerChannel,
4+
BannerTargeting,
45
ConsentStatus,
56
EpicTargeting,
67
EpicViewLog,
8+
GutterTargeting,
79
PageContextTargeting,
810
SignedInStatus,
911
Test,
@@ -166,3 +168,17 @@ export const pageContextMatches = (
166168

167169
return inclusionsMatch && !exclusionsMatch;
168170
};
171+
172+
// Hide all messages on these pages
173+
const excludedPageIds = new Set<string>([
174+
'info/privacy',
175+
'info/complaints-and-corrections',
176+
'about',
177+
'the-whole-picture',
178+
]);
179+
180+
export const pageIdIsExcluded = (
181+
targeting: BannerTargeting | EpicTargeting | GutterTargeting,
182+
): boolean => {
183+
return targeting.pageId ? excludedPageIds.has(targeting.pageId) : false;
184+
};

src/shared/types/targeting/shared.ts

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

74
export type TagCounts = Record<string, number>;
85

@@ -30,19 +27,6 @@ export interface PurchaseInfo {
3027
product: purchaseInfoProduct;
3128
}
3229

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

0 commit comments

Comments
 (0)