Skip to content

Commit b89c322

Browse files
committed
decideShouldNotServeNonDismissible
1 parent b19cbb3 commit b89c322

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export interface AuxiaProxyGetTreatmentsPayload {
122122
mvtId: number;
123123
should_show_legacy_gate_tmp: boolean; // [1]
124124
hasConsented: boolean;
125-
shouldNotServeNonDismissible: boolean; // [2]
125+
shouldNotServeMandatory: boolean; // [2]
126126
}
127127

128128
// [1]
@@ -146,7 +146,7 @@ export interface AuxiaProxyGetTreatmentsPayload {
146146

147147
// [2]
148148
// date: 03rd July 2025
149-
// If shouldNotServeNonDismissible, we should not show a non dismissible gate.
149+
// If shouldNotServeMandatory, we should not show a mandatory gate.
150150

151151
export interface AuxiaProxyGetTreatmentsResponse {
152152
status: boolean;

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ const fetchProxyGetTreatments = async (
290290
mvtId: number,
291291
should_show_legacy_gate_tmp: boolean,
292292
hasConsented: boolean,
293-
shouldNotServeNonDismissible: boolean,
293+
shouldNotServeMandatory: boolean,
294294
): Promise<AuxiaProxyGetTreatmentsResponse> => {
295295
// pageId example: 'money/2017/mar/10/ministers-to-criminalise-use-of-ticket-tout-harvesting-software'
296296
const articleIdentifier = `www.theguardian.com/${pageId}`;
@@ -313,7 +313,7 @@ const fetchProxyGetTreatments = async (
313313
mvtId,
314314
should_show_legacy_gate_tmp,
315315
hasConsented,
316-
shouldNotServeNonDismissible,
316+
shouldNotServeMandatory,
317317
};
318318
const params = {
319319
method: 'POST',
@@ -328,6 +328,23 @@ const fetchProxyGetTreatments = async (
328328
return Promise.resolve(response);
329329
};
330330

331+
const decideShouldNotServeMandatory = (): boolean => {
332+
// Return a boolean indicating whether or not we accept mandatory gates for this call.
333+
// If the answer is `false` this doesn't decide whether the gate should be displayed or not,
334+
// it only means that if a gate is returned, then it must be mandatory.
335+
336+
// Now the question is how do we decide the answer ?
337+
// We return false if the following query parameter is present in the url:
338+
// utm_source=newsshowcase
339+
340+
// This may be extended in the future.
341+
342+
const params = new URLSearchParams(window.location.search);
343+
const value: string | null = params.get('utm_source');
344+
345+
return value === 'newsshowcase';
346+
};
347+
331348
const buildAuxiaGateDisplayData = async (
332349
contributionsServiceUrl: string,
333350
pageId: string,
@@ -365,7 +382,7 @@ const buildAuxiaGateDisplayData = async (
365382
);
366383
}
367384

368-
const shouldNotServeNonDismissible = false; // todo get the value.
385+
const shouldNotServeMandatory = decideShouldNotServeMandatory();
369386

370387
const response = await fetchProxyGetTreatments(
371388
contributionsServiceUrl,
@@ -382,7 +399,7 @@ const buildAuxiaGateDisplayData = async (
382399
readerPersonalData.mvtId,
383400
should_show_legacy_gate_tmp,
384401
readerPersonalData.hasConsented,
385-
shouldNotServeNonDismissible,
402+
shouldNotServeMandatory,
386403
);
387404

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

0 commit comments

Comments
 (0)