Skip to content

Commit 2383bc8

Browse files
authored
Merge pull request #14177 from guardian/ph-20250703-1510-shouldNotServeNonDismissible
Introduce shouldNotServeMandatory
2 parents 09eaa30 + fbb8184 commit 2383bc8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

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

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

127128
// [1]
@@ -143,6 +144,10 @@ export interface AuxiaProxyGetTreatmentsPayload {
143144
// Obviously, the value it carries for standard Auxia audience requests in irrelevant.
144145
// We will be setting it to false.
145146

147+
// [2]
148+
// date: 03rd July 2025
149+
// If shouldNotServeMandatory, we should not show a mandatory gate.
150+
146151
export interface AuxiaProxyGetTreatmentsResponse {
147152
status: boolean;
148153
data?: AuxiaProxyGetTreatmentsProxyResponseData;

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ const fetchProxyGetTreatments = async (
290290
mvtId: number,
291291
should_show_legacy_gate_tmp: boolean,
292292
hasConsented: boolean,
293+
shouldNotServeMandatory: boolean,
293294
): Promise<AuxiaProxyGetTreatmentsResponse> => {
294295
// pageId example: 'money/2017/mar/10/ministers-to-criminalise-use-of-ticket-tout-harvesting-software'
295296
const articleIdentifier = `www.theguardian.com/${pageId}`;
@@ -312,6 +313,7 @@ const fetchProxyGetTreatments = async (
312313
mvtId,
313314
should_show_legacy_gate_tmp,
314315
hasConsented,
316+
shouldNotServeMandatory,
315317
};
316318
const params = {
317319
method: 'POST',
@@ -326,6 +328,24 @@ const fetchProxyGetTreatments = async (
326328
return Promise.resolve(response);
327329
};
328330

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+
// return value === 'newsshowcase';
345+
346+
return false;
347+
};
348+
329349
const buildAuxiaGateDisplayData = async (
330350
contributionsServiceUrl: string,
331351
pageId: string,
@@ -363,6 +383,8 @@ const buildAuxiaGateDisplayData = async (
363383
);
364384
}
365385

386+
const shouldNotServeMandatory = decideShouldNotServeMandatory();
387+
366388
const response = await fetchProxyGetTreatments(
367389
contributionsServiceUrl,
368390
pageId,
@@ -378,6 +400,7 @@ const buildAuxiaGateDisplayData = async (
378400
readerPersonalData.mvtId,
379401
should_show_legacy_gate_tmp,
380402
readerPersonalData.hasConsented,
403+
shouldNotServeMandatory,
381404
);
382405

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

0 commit comments

Comments
 (0)