Skip to content

Commit b2042dc

Browse files
committed
send editionId for GetTreatments
1 parent 17508a1 commit b2042dc

File tree

5 files changed

+32
-10
lines changed

5 files changed

+32
-10
lines changed

dotcom-rendering/src/components/Island.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ describe('Island: server-side rendering', () => {
382382
pageId={''}
383383
switches={{}}
384384
contributionsServiceUrl={''}
385+
editionId="UK"
385386
/>
386387
</WithConfig>,
387388
),

dotcom-rendering/src/components/SignInGate/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { CountryCode } from '@guardian/libs';
22
import { isObject, isOneOf, isString } from '@guardian/libs';
3+
import type { EditionId } from '../../lib/edition';
34
import type { TagType } from '../../types/tag';
45

56
export type CanShowGateProps = {
@@ -113,6 +114,7 @@ export interface AuxiaProxyGetTreatmentsPayload {
113114
isSupporter: boolean;
114115
dailyArticleCount: number;
115116
articleIdentifier: string;
117+
editionId: EditionId;
116118
}
117119

118120
export interface AuxiaProxyGetTreatmentsResponse {

dotcom-rendering/src/components/SignInGateSelector.importable.tsx

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
shouldHideSupportMessaging,
66
} from '../lib/contributions';
77
import { getDailyArticleCount, getToday } from '../lib/dailyArticleCount';
8+
import type { EditionId } from '../lib/edition';
89
import { parseCheckoutCompleteCookieData } from '../lib/parser/parseCheckoutOutCookieData';
910
import { constructQuery } from '../lib/querystring';
1011
import { useAB } from '../lib/useAB';
@@ -57,6 +58,19 @@ type Props = {
5758
idUrl?: string;
5859
switches: Switches;
5960
contributionsServiceUrl: string;
61+
editionId: EditionId;
62+
};
63+
64+
type PropsDefault = {
65+
contentType: string;
66+
sectionId?: string;
67+
tags: TagType[];
68+
isPaidContent: boolean;
69+
isPreview: boolean;
70+
host?: string;
71+
pageId: string;
72+
idUrl?: string;
73+
switches: Switches;
6074
};
6175

6276
// interface for the component which shows the sign in gate
@@ -214,14 +228,7 @@ const SignInGateSelectorDefault = ({
214228
pageId,
215229
idUrl = 'https://profile.theguardian.com',
216230
switches,
217-
contributionsServiceUrl,
218-
}: Props) => {
219-
// comment group: auxia-prototype-e55a86ef
220-
// The following (useless) instruction only exists to avoid linting error
221-
// so that SignInGateSelectorDefault, SignInGateSelectorAuxia and SignInGateSelector
222-
// all have the same signature, while we give shape to the Auxia prototype.
223-
contributionsServiceUrl;
224-
231+
}: PropsDefault) => {
225232
const authStatus = useAuthStatus();
226233
const isSignedIn =
227234
authStatus.kind === 'SignedInWithOkta' ||
@@ -372,6 +379,7 @@ export const SignInGateSelector = ({
372379
idUrl = 'https://profile.theguardian.com',
373380
switches,
374381
contributionsServiceUrl,
382+
editionId,
375383
}: Props) => {
376384
const abTestAPI = useAB()?.api;
377385
const userIsInAuxiaExperiment = !!abTestAPI?.isUserInVariant(
@@ -391,7 +399,6 @@ export const SignInGateSelector = ({
391399
pageId={pageId}
392400
idUrl={idUrl}
393401
switches={switches}
394-
contributionsServiceUrl={contributionsServiceUrl}
395402
/>
396403
);
397404
} else {
@@ -401,6 +408,7 @@ export const SignInGateSelector = ({
401408
pageId={pageId}
402409
idUrl={idUrl}
403410
contributionsServiceUrl={contributionsServiceUrl}
411+
editionId={editionId}
404412
/>
405413
);
406414
}
@@ -434,6 +442,7 @@ type PropsAuxia = {
434442
pageId: string;
435443
idUrl: string;
436444
contributionsServiceUrl: string;
445+
editionId: EditionId;
437446
};
438447

439448
interface ShowSignInGateAuxiaProps {
@@ -495,10 +504,10 @@ const fetchProxyGetTreatments = async (
495504
browserId: string | undefined,
496505
isSupporter: boolean,
497506
dailyArticleCount: number,
507+
editionId: EditionId,
498508
): Promise<AuxiaProxyGetTreatmentsResponse> => {
499509
// pageId example: 'money/2017/mar/10/ministers-to-criminalise-use-of-ticket-tout-harvesting-software'
500510
const articleIdentifier = `www.theguardian.com/${pageId}`;
501-
502511
const url = `${contributionsServiceUrl}/auxia/get-treatments`;
503512
const headers = {
504513
'Content-Type': 'application/json',
@@ -508,6 +517,7 @@ const fetchProxyGetTreatments = async (
508517
isSupporter,
509518
dailyArticleCount,
510519
articleIdentifier,
520+
editionId,
511521
};
512522
const params = {
513523
method: 'POST',
@@ -525,6 +535,7 @@ const fetchProxyGetTreatments = async (
525535
const buildAuxiaGateDisplayData = async (
526536
contributionsServiceUrl: string,
527537
pageId: string,
538+
editionId: EditionId,
528539
): Promise<AuxiaGateDisplayData | undefined> => {
529540
const readerPersonalData = await decideAuxiaProxyReaderPersonalData();
530541
const response = await fetchProxyGetTreatments(
@@ -533,6 +544,7 @@ const buildAuxiaGateDisplayData = async (
533544
readerPersonalData.browserId,
534545
readerPersonalData.isSupporter,
535546
readerPersonalData.dailyArticleCount,
547+
editionId,
536548
);
537549
if (response.status && response.data) {
538550
const answer = {
@@ -581,6 +593,7 @@ const SignInGateSelectorAuxia = ({
581593
pageId,
582594
idUrl,
583595
contributionsServiceUrl,
596+
editionId,
584597
}: PropsAuxia) => {
585598
/*
586599
comment group: auxia-prototype-e55a86ef
@@ -643,6 +656,7 @@ const SignInGateSelectorAuxia = ({
643656
const data = await buildAuxiaGateDisplayData(
644657
contributionsServiceUrl,
645658
pageId,
659+
editionId,
646660
);
647661
if (data !== undefined) {
648662
setAuxiaGateDisplayData(data);

dotcom-rendering/src/lib/ArticleRenderer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export const ArticleRenderer = ({
132132
isSensitive,
133133
isDev,
134134
contributionsServiceUrl,
135+
editionId,
135136
})}
136137
</div>
137138
); // classname that space finder is going to target for in-body ads in DCR

dotcom-rendering/src/lib/withSignInGateSlot.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Island } from '../components/Island';
66
import { SignInGateSelector } from '../components/SignInGateSelector.importable';
77
import type { Switches } from '../types/config';
88
import type { TagType } from '../types/tag';
9+
import type { EditionId } from './edition';
910

1011
type Props = {
1112
renderedElements: (JSX.Element | null | undefined)[];
@@ -21,6 +22,7 @@ type Props = {
2122
isSensitive?: boolean;
2223
isDev?: boolean;
2324
contributionsServiceUrl: string;
25+
editionId: EditionId;
2426
};
2527

2628
export const withSignInGateSlot = ({
@@ -35,6 +37,7 @@ export const withSignInGateSlot = ({
3537
idUrl,
3638
switches,
3739
contributionsServiceUrl,
40+
editionId,
3841
}: Props): React.ReactNode => {
3942
return renderedElements.map((element, i) => {
4043
return (
@@ -57,6 +60,7 @@ export const withSignInGateSlot = ({
5760
contributionsServiceUrl={
5861
contributionsServiceUrl
5962
}
63+
editionId={editionId}
6064
/>
6165
</Island>
6266
</div>

0 commit comments

Comments
 (0)