Skip to content

Commit dad59d7

Browse files
committed
add country data to auxia payload
1 parent 65f515e commit dad59d7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export interface AuxiaProxyGetTreatmentsPayload {
118118
sectionId: string;
119119
tagIds: string[];
120120
gateDismissCount: number;
121+
countryCode: string;
121122
}
122123

123124
export interface AuxiaProxyGetTreatmentsResponse {
@@ -162,6 +163,7 @@ export interface AuxiaGateReaderPersonalData {
162163
browserId: string | undefined;
163164
dailyArticleCount: number;
164165
isSupporter: boolean;
166+
countryCode: string;
165167
}
166168

167169
export interface AuxiaGateDisplayData {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
} from '../lib/contributions';
77
import { getDailyArticleCount, getToday } from '../lib/dailyArticleCount';
88
import type { EditionId } from '../lib/edition';
9+
import { getLocaleCode } from '../lib/getCountryCode';
910
import { isUserLoggedIn } from '../lib/identity';
1011
import { parseCheckoutCompleteCookieData } from '../lib/parser/parseCheckoutOutCookieData';
1112
import { constructQuery } from '../lib/querystring';
@@ -503,10 +504,12 @@ const decideAuxiaProxyReaderPersonalData =
503504
const dailyArticleCount = decideDailyArticleCount();
504505
const hasConsent = await hasCmpConsentForBrowserId();
505506
const isSupporter = decideIsSupporter();
507+
const countryCode = (await getLocaleCode()) ?? ''; // default to empty string
506508
const data = {
507509
browserId: hasConsent ? browserId : undefined,
508510
dailyArticleCount,
509511
isSupporter,
512+
countryCode,
510513
};
511514
return Promise.resolve(data);
512515
};
@@ -522,6 +525,7 @@ const fetchProxyGetTreatments = async (
522525
sectionId: string,
523526
tagIds: string[],
524527
gateDismissCount: number,
528+
countryCode: string,
525529
): Promise<AuxiaProxyGetTreatmentsResponse> => {
526530
// pageId example: 'money/2017/mar/10/ministers-to-criminalise-use-of-ticket-tout-harvesting-software'
527531
const articleIdentifier = `www.theguardian.com/${pageId}`;
@@ -539,6 +543,7 @@ const fetchProxyGetTreatments = async (
539543
sectionId,
540544
tagIds,
541545
gateDismissCount,
546+
countryCode,
542547
};
543548
const params = {
544549
method: 'POST',
@@ -575,6 +580,7 @@ const buildAuxiaGateDisplayData = async (
575580
sectionId,
576581
tagIds,
577582
gateDismissCount,
583+
readerPersonalData.countryCode,
578584
);
579585
if (response.status && response.data) {
580586
const answer = {

0 commit comments

Comments
 (0)