diff --git a/dotcom-rendering/src/components/SignInGate/types.ts b/dotcom-rendering/src/components/SignInGate/types.ts index be6bfe1703c..817b7e9ccd5 100644 --- a/dotcom-rendering/src/components/SignInGate/types.ts +++ b/dotcom-rendering/src/components/SignInGate/types.ts @@ -108,6 +108,8 @@ export interface AuxiaAPIResponseDataUserTreatment { surface: string; } +export type ShowGateValues = 'true' | 'mandatory' | 'dismissible' | undefined; + export interface AuxiaProxyGetTreatmentsPayload { browserId: string | undefined; isSupporter: boolean; @@ -123,7 +125,7 @@ export interface AuxiaProxyGetTreatmentsPayload { should_show_legacy_gate_tmp: boolean; // [1] hasConsented: boolean; shouldServeDismissible: boolean; // [2] - mustShowDefaultGate: boolean; // [3] + showDefaultGate: ShowGateValues; // [3] } // [1] @@ -146,19 +148,19 @@ export interface AuxiaProxyGetTreatmentsPayload { // We will be setting it to false. // [2] -// date: 03rd July 2025 -// If shouldServeDismissible is true, we should show a dismissible gate. +// date: 03rd July 2025// If shouldServeDismissible is true, we should show a dismissible gate. // [3] -// date: 23rd July 2025 + +// date: 25rd July 2025 // author: Pascal -// In order to facilitate internal testing, this attribute forces -// the display of a sign-in gate, namely the default gu gate. If it is true then -// the default gate is going to be displayed. Note that this applies to both auxia and -// non auxia audiences. In particular because it also applies to auxia audiences, for which -// the value of should_show_legacy_gate_tmp is ignored, then the information needs to come to -// the SDC server as a new parameter in the GetTreatments payload. To trigger -// gate display, the url should have query parameter `showgate=true` + +// In order to facilitate internal testing, this attribute, when defined, forces +// the display of a sign-in gate. The values 'true' and 'dismissible' displays the +// dismissible variant of the gu default gate, and the value 'mandatory' displays +// the mandatory variant of the gu default gate. + +// Note that this attributes override the value of should_show_legacy_gate_tmp. export interface AuxiaProxyGetTreatmentsResponse { status: boolean; diff --git a/dotcom-rendering/src/components/SignInGateSelector.importable.tsx b/dotcom-rendering/src/components/SignInGateSelector.importable.tsx index fd0f2a1a3be..3cdceab4825 100644 --- a/dotcom-rendering/src/components/SignInGateSelector.importable.tsx +++ b/dotcom-rendering/src/components/SignInGateSelector.importable.tsx @@ -32,6 +32,7 @@ import type { AuxiaProxyLogTreatmentInteractionPayload, CanShowGateProps, CurrentSignInGateABTest, + ShowGateValues, } from './SignInGate/types'; // ------------------------------------------------------------------------------------------ @@ -291,7 +292,7 @@ const fetchProxyGetTreatments = async ( should_show_legacy_gate_tmp: boolean, hasConsented: boolean, shouldServeDismissible: boolean, - mustShowDefaultGate: boolean, + showDefaultGate: ShowGateValues, ): Promise => { // pageId example: 'money/2017/mar/10/ministers-to-criminalise-use-of-ticket-tout-harvesting-software' const articleIdentifier = `www.theguardian.com/${pageId}`; @@ -315,7 +316,7 @@ const fetchProxyGetTreatments = async ( should_show_legacy_gate_tmp, hasConsented, shouldServeDismissible, - mustShowDefaultGate, + showDefaultGate, }; const params = { method: 'POST', @@ -332,8 +333,8 @@ const fetchProxyGetTreatments = async ( const decideShouldServeDismissible = (): boolean => { // Return a boolean indicating whether or not we accept mandatory gates for this call. - // If the answer is `false` this doesn't decide whether the gate should be displayed or not, - // it only means that if a gate is returned, then it must be mandatory. + // If the answer is `true` this doesn't decide whether the gate should be displayed or not, + // it only means that if a gate is returned, then it must be dismissible (not be mandatory). // Now the question is how do we decide the answer ? // We return false if the following query parameter is present in the url: @@ -348,7 +349,7 @@ const decideShouldServeDismissible = (): boolean => { return false; }; -const decideMustShowDefaultGate = (): boolean => { +const decideShowDefaultGate = (): ShowGateValues => { // In order to facilitate internal testing, this function observes a query parameter which forces // the display of a sign-in gate, namely the default gu gate. If this returns true then // the default gate is going to be displayed. Note that this applies to both auxia and @@ -360,7 +361,17 @@ const decideMustShowDefaultGate = (): boolean => { const params = new URLSearchParams(window.location.search); const value: string | null = params.get('showgate'); - return value === 'true'; + + if (value === null) { + return undefined; + } + + const validValues = ['true', 'dismissible', 'mandatory']; + if (validValues.includes(value)) { + return value as ShowGateValues; + } + + return undefined; }; const buildAuxiaGateDisplayData = async ( @@ -402,7 +413,7 @@ const buildAuxiaGateDisplayData = async ( const shouldServeDismissible = decideShouldServeDismissible(); - const mustShowDefaultGate = decideMustShowDefaultGate(); + const showDefaultGate = decideShowDefaultGate(); const response = await fetchProxyGetTreatments( contributionsServiceUrl, @@ -420,7 +431,7 @@ const buildAuxiaGateDisplayData = async ( should_show_legacy_gate_tmp, readerPersonalData.hasConsented, shouldServeDismissible, - mustShowDefaultGate, + showDefaultGate, ); if (response.status && response.data) {