diff --git a/src/server/api/bannerRouter.ts b/src/server/api/bannerRouter.ts index f163c2982..db10b4579 100644 --- a/src/server/api/bannerRouter.ts +++ b/src/server/api/bannerRouter.ts @@ -12,7 +12,6 @@ import type { Tracking, } from '../../shared/types'; import { channelFromBannerChannel } from '../../shared/types'; -import { hideSRMessagingForInfoPageIds } from '../../shared/types'; import type { ChannelSwitches } from '../channelSwitches'; import { getChoiceCardsSettings } from '../lib/choiceCards/choiceCards'; import { getDeviceType } from '../lib/deviceType'; @@ -22,6 +21,7 @@ import { getArticleViewCounts } from '../lib/history'; import type { Params } from '../lib/params'; import { getQueryParams } from '../lib/params'; import type { PromotionsCache } from '../lib/promotions/promotions'; +import { pageIdIsExcluded } from '../lib/targeting'; import { buildBannerCampaignCode } from '../lib/tracking'; import type { ProductCatalog } from '../productCatalog'; import { selectAmountsTestVariant } from '../selection/ab'; @@ -69,7 +69,7 @@ export const buildBannerRouter = ( return {}; } - if (hideSRMessagingForInfoPageIds(targeting)) { + if (pageIdIsExcluded(targeting)) { return {}; } diff --git a/src/server/api/epicRouter.ts b/src/server/api/epicRouter.ts index 871085b00..fc9bbb530 100644 --- a/src/server/api/epicRouter.ts +++ b/src/server/api/epicRouter.ts @@ -12,7 +12,6 @@ import type { Tracking, WeeklyArticleLog, } from '../../shared/types'; -import { hideSRMessagingForInfoPageIds } from '../../shared/types'; import type { ChannelSwitches } from '../channelSwitches'; import { getChoiceCardsSettings } from '../lib/choiceCards/choiceCards'; import { getDeviceType } from '../lib/deviceType'; @@ -23,6 +22,7 @@ import type { Params } from '../lib/params'; import { getQueryParams } from '../lib/params'; import type { PromotionsCache } from '../lib/promotions/promotions'; import type { SuperModeArticle } from '../lib/superMode'; +import { pageIdIsExcluded } from '../lib/targeting'; import { buildEpicCampaignCode } from '../lib/tracking'; import type { ProductCatalog } from '../productCatalog'; import { selectAmountsTestVariant } from '../selection/ab'; @@ -92,7 +92,7 @@ export const buildEpicRouter = ( return {}; } - if (hideSRMessagingForInfoPageIds(targeting)) { + if (pageIdIsExcluded(targeting)) { return {}; } diff --git a/src/server/api/gutterRouter.ts b/src/server/api/gutterRouter.ts index 772f96cd1..7fdae3bb3 100644 --- a/src/server/api/gutterRouter.ts +++ b/src/server/api/gutterRouter.ts @@ -7,12 +7,12 @@ import type { TestTracking, Tracking, } from '../../shared/types'; -import { hideSRMessagingForInfoPageIds } from '../../shared/types'; import type { ChannelSwitches } from '../channelSwitches'; import { getDeviceType } from '../lib/deviceType'; import { baseUrl } from '../lib/env'; import { getQueryParams } from '../lib/params'; import type { Params } from '../lib/params'; +import { pageIdIsExcluded } from '../lib/targeting'; import { buildGutterCampaignCode } from '../lib/tracking'; import { bodyContainsAllFields } from '../middleware'; import { selectGutterTest } from '../tests/gutters/gutterSelection'; @@ -45,7 +45,7 @@ export const buildGutterRouter = ( return {}; } - if (hideSRMessagingForInfoPageIds(targeting)) { + if (pageIdIsExcluded(targeting)) { return {}; } diff --git a/src/server/lib/targeting.ts b/src/server/lib/targeting.ts index c2596b8d0..f088a4178 100644 --- a/src/server/lib/targeting.ts +++ b/src/server/lib/targeting.ts @@ -1,9 +1,11 @@ import type { AbandonedBasket, BannerChannel, + BannerTargeting, ConsentStatus, EpicTargeting, EpicViewLog, + GutterTargeting, PageContextTargeting, SignedInStatus, Test, @@ -166,3 +168,17 @@ export const pageContextMatches = ( return inclusionsMatch && !exclusionsMatch; }; + +// Hide all messages on these pages +const excludedPageIds = new Set([ + 'info/privacy', + 'info/complaints-and-corrections', + 'about', + 'the-whole-picture', +]); + +export const pageIdIsExcluded = ( + targeting: BannerTargeting | EpicTargeting | GutterTargeting, +): boolean => { + return targeting.pageId ? excludedPageIds.has(targeting.pageId) : false; +}; diff --git a/src/shared/types/targeting/shared.ts b/src/shared/types/targeting/shared.ts index 3c9262b09..9180dd0a0 100644 --- a/src/shared/types/targeting/shared.ts +++ b/src/shared/types/targeting/shared.ts @@ -1,8 +1,5 @@ import { z } from 'zod'; import type { purchaseInfoProduct, purchaseInfoUser } from '../purchaseInfo'; -import type { BannerTargeting } from './banner'; -import type { EpicTargeting } from './epic'; -import type { GutterTargeting } from './gutter'; export type TagCounts = Record; @@ -30,19 +27,6 @@ export interface PurchaseInfo { product: purchaseInfoProduct; } -//The pageIdsOfInterest has the pageIds in which we want to hide the SR messages -export const pageIdsOfInterest = new Set([ - 'info/privacy', - 'info/complaints-and-corrections', - 'about', -]); - -export const hideSRMessagingForInfoPageIds = ( - targeting: BannerTargeting | EpicTargeting | GutterTargeting, -): boolean => { - return targeting.pageId ? pageIdsOfInterest.has(targeting.pageId) : false; -}; - export const abandonedBasketSchema = z.object({ amount: z.union([z.number(), z.literal('other')]), billingPeriod: z.union([z.literal('ONE_OFF'), z.literal('MONTHLY'), z.literal('ANNUAL')]),