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
5 changes: 5 additions & 0 deletions .changeset/gorgeous-days-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@guardian/support-dotcom-components': minor
---

Add pageId to targeting
5 changes: 5 additions & 0 deletions src/server/api/bannerRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
TestTracking,
BannerDesignFromTool,
Tracking,
hideSRMessagingForInfoPageIds,
} from '../../shared/types';
import { selectAmountsTestVariant } from '../lib/ab';
import { ChannelSwitches } from '../channelSwitches';
Expand Down Expand Up @@ -60,6 +61,10 @@ export const buildBannerRouter = (
return {};
}

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

const selectedTest = selectBannerTest(
targeting,
getDeviceType(req),
Expand Down
5 changes: 5 additions & 0 deletions src/server/api/epicRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
EpicTest,
EpicType,
EpicVariant,
hideSRMessagingForInfoPageIds,
TestTracking,
Tracking,
WeeklyArticleLog,
Expand Down Expand Up @@ -83,6 +84,10 @@ export const buildEpicRouter = (
return {};
}

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

const targetingMvtId = targeting.mvtId || 1;

const tests =
Expand Down
6 changes: 6 additions & 0 deletions src/server/api/gutterRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
TestTracking,
GutterTargeting,
Tracking,
hideSRMessagingForInfoPageIds,
} from '../../shared/types';
import { ChannelSwitches } from '../channelSwitches';
import { getDeviceType } from '../lib/deviceType';
Expand Down Expand Up @@ -41,6 +42,11 @@ export const buildGutterRouter = (
if (!enableGutterLiveblogs) {
return {};
}

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

const testSelection = selectGutterTest(
targeting,
tests.get(),
Expand Down
1 change: 1 addition & 0 deletions src/shared/types/targeting/banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type BannerTargeting = {
isSignedIn: boolean;
hasConsented: boolean;
abandonedBasket?: AbandonedBasket;
pageId?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we do this for the gutter ask as well, just in case?

};

export type BannerPayload = {
Expand Down
1 change: 1 addition & 0 deletions src/shared/types/targeting/epic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type EpicTargeting = {
url?: string;
browserId?: string; // Only present if the user has consented to browserId-based targeting
isSignedIn?: boolean;
pageId?: string;
};

export type EpicPayload = {
Expand Down
1 change: 1 addition & 0 deletions src/shared/types/targeting/gutter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface GutterTargeting {
isSignedIn: boolean;
tagIds?: string[];
sectionId?: string;
pageId?: string;
}

export type GutterPayload = {
Expand Down
16 changes: 16 additions & 0 deletions src/shared/types/targeting/shared.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { z } from 'zod';
import { purchaseInfoProduct, purchaseInfoUser } from '../purchaseInfo';
import { BannerTargeting } from './banner';
import { EpicTargeting } from './epic';
import { GutterTargeting } from './gutter';

export type TagCounts = {
[tag: string]: number;
Expand Down Expand Up @@ -28,6 +31,19 @@ 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