Skip to content

Commit 1ba97b4

Browse files
authored
Merge pull request #14273 from guardian/ph-20250723-1654-newsshowcase
implement new showDefaultGate semantics
2 parents eefe403 + fc734fa commit 1ba97b4

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ export interface AuxiaAPIResponseDataUserTreatment {
108108
surface: string;
109109
}
110110

111+
export type ShowGateValues = 'true' | 'mandatory' | 'dismissible' | undefined;
112+
111113
export interface AuxiaProxyGetTreatmentsPayload {
112114
browserId: string | undefined;
113115
isSupporter: boolean;
@@ -123,7 +125,7 @@ export interface AuxiaProxyGetTreatmentsPayload {
123125
should_show_legacy_gate_tmp: boolean; // [1]
124126
hasConsented: boolean;
125127
shouldServeDismissible: boolean; // [2]
126-
mustShowDefaultGate: boolean; // [3]
128+
showDefaultGate: ShowGateValues; // [3]
127129
}
128130

129131
// [1]
@@ -146,19 +148,19 @@ export interface AuxiaProxyGetTreatmentsPayload {
146148
// We will be setting it to false.
147149

148150
// [2]
149-
// date: 03rd July 2025
150-
// If shouldServeDismissible is true, we should show a dismissible gate.
151+
// date: 03rd July 2025// If shouldServeDismissible is true, we should show a dismissible gate.
151152

152153
// [3]
153-
// date: 23rd July 2025
154+
155+
// date: 25rd July 2025
154156
// author: Pascal
155-
// In order to facilitate internal testing, this attribute forces
156-
// the display of a sign-in gate, namely the default gu gate. If it is true then
157-
// the default gate is going to be displayed. Note that this applies to both auxia and
158-
// non auxia audiences. In particular because it also applies to auxia audiences, for which
159-
// the value of should_show_legacy_gate_tmp is ignored, then the information needs to come to
160-
// the SDC server as a new parameter in the GetTreatments payload. To trigger
161-
// gate display, the url should have query parameter `showgate=true`
157+
158+
// In order to facilitate internal testing, this attribute, when defined, forces
159+
// the display of a sign-in gate. The values 'true' and 'dismissible' displays the
160+
// dismissible variant of the gu default gate, and the value 'mandatory' displays
161+
// the mandatory variant of the gu default gate.
162+
163+
// Note that this attributes override the value of should_show_legacy_gate_tmp.
162164

163165
export interface AuxiaProxyGetTreatmentsResponse {
164166
status: boolean;

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import type {
3232
AuxiaProxyLogTreatmentInteractionPayload,
3333
CanShowGateProps,
3434
CurrentSignInGateABTest,
35+
ShowGateValues,
3536
} from './SignInGate/types';
3637

3738
// ------------------------------------------------------------------------------------------
@@ -291,7 +292,7 @@ const fetchProxyGetTreatments = async (
291292
should_show_legacy_gate_tmp: boolean,
292293
hasConsented: boolean,
293294
shouldServeDismissible: boolean,
294-
mustShowDefaultGate: boolean,
295+
showDefaultGate: ShowGateValues,
295296
): Promise<AuxiaProxyGetTreatmentsResponse> => {
296297
// pageId example: 'money/2017/mar/10/ministers-to-criminalise-use-of-ticket-tout-harvesting-software'
297298
const articleIdentifier = `www.theguardian.com/${pageId}`;
@@ -315,7 +316,7 @@ const fetchProxyGetTreatments = async (
315316
should_show_legacy_gate_tmp,
316317
hasConsented,
317318
shouldServeDismissible,
318-
mustShowDefaultGate,
319+
showDefaultGate,
319320
};
320321
const params = {
321322
method: 'POST',
@@ -332,8 +333,8 @@ const fetchProxyGetTreatments = async (
332333

333334
const decideShouldServeDismissible = (): boolean => {
334335
// Return a boolean indicating whether or not we accept mandatory gates for this call.
335-
// If the answer is `false` this doesn't decide whether the gate should be displayed or not,
336-
// it only means that if a gate is returned, then it must be mandatory.
336+
// If the answer is `true` this doesn't decide whether the gate should be displayed or not,
337+
// it only means that if a gate is returned, then it must be dismissible (not be mandatory).
337338

338339
// Now the question is how do we decide the answer ?
339340
// We return false if the following query parameter is present in the url:
@@ -348,7 +349,7 @@ const decideShouldServeDismissible = (): boolean => {
348349
return false;
349350
};
350351

351-
const decideMustShowDefaultGate = (): boolean => {
352+
const decideShowDefaultGate = (): ShowGateValues => {
352353
// In order to facilitate internal testing, this function observes a query parameter which forces
353354
// the display of a sign-in gate, namely the default gu gate. If this returns true then
354355
// the default gate is going to be displayed. Note that this applies to both auxia and
@@ -360,7 +361,17 @@ const decideMustShowDefaultGate = (): boolean => {
360361

361362
const params = new URLSearchParams(window.location.search);
362363
const value: string | null = params.get('showgate');
363-
return value === 'true';
364+
365+
if (value === null) {
366+
return undefined;
367+
}
368+
369+
const validValues = ['true', 'dismissible', 'mandatory'];
370+
if (validValues.includes(value)) {
371+
return value as ShowGateValues;
372+
}
373+
374+
return undefined;
364375
};
365376

366377
const buildAuxiaGateDisplayData = async (
@@ -402,7 +413,7 @@ const buildAuxiaGateDisplayData = async (
402413

403414
const shouldServeDismissible = decideShouldServeDismissible();
404415

405-
const mustShowDefaultGate = decideMustShowDefaultGate();
416+
const showDefaultGate = decideShowDefaultGate();
406417

407418
const response = await fetchProxyGetTreatments(
408419
contributionsServiceUrl,
@@ -420,7 +431,7 @@ const buildAuxiaGateDisplayData = async (
420431
should_show_legacy_gate_tmp,
421432
readerPersonalData.hasConsented,
422433
shouldServeDismissible,
423-
mustShowDefaultGate,
434+
showDefaultGate,
424435
);
425436

426437
if (response.status && response.data) {

0 commit comments

Comments
 (0)