Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/server/api/bannerRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -69,7 +69,7 @@ export const buildBannerRouter = (
return {};
}

if (hideSRMessagingForInfoPageIds(targeting)) {
if (pageIdIsExcluded(targeting)) {
return {};
}

Expand Down
4 changes: 2 additions & 2 deletions src/server/api/epicRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -92,7 +92,7 @@ export const buildEpicRouter = (
return {};
}

if (hideSRMessagingForInfoPageIds(targeting)) {
if (pageIdIsExcluded(targeting)) {
return {};
}

Expand Down
4 changes: 2 additions & 2 deletions src/server/api/gutterRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -45,7 +45,7 @@ export const buildGutterRouter = (
return {};
}

if (hideSRMessagingForInfoPageIds(targeting)) {
if (pageIdIsExcluded(targeting)) {
return {};
}

Expand Down
16 changes: 16 additions & 0 deletions src/server/lib/targeting.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type {
AbandonedBasket,
BannerChannel,
BannerTargeting,
ConsentStatus,
EpicTargeting,
EpicViewLog,
GutterTargeting,
PageContextTargeting,
SignedInStatus,
Test,
Expand Down Expand Up @@ -166,3 +168,17 @@ export const pageContextMatches = (

return inclusionsMatch && !exclusionsMatch;
};

// Hide all messages on these pages
const excludedPageIds = new Set<string>([
'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;
};
16 changes: 0 additions & 16 deletions src/shared/types/targeting/shared.ts
Original file line number Diff line number Diff line change
@@ -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<string, number>;

Expand Down Expand Up @@ -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<string>([
'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')]),
Expand Down