@@ -32,6 +32,7 @@ import type {
32
32
AuxiaProxyLogTreatmentInteractionPayload ,
33
33
CanShowGateProps ,
34
34
CurrentSignInGateABTest ,
35
+ ShowGateValues ,
35
36
} from './SignInGate/types' ;
36
37
37
38
// ------------------------------------------------------------------------------------------
@@ -291,7 +292,7 @@ const fetchProxyGetTreatments = async (
291
292
should_show_legacy_gate_tmp : boolean ,
292
293
hasConsented : boolean ,
293
294
shouldServeDismissible : boolean ,
294
- mustShowDefaultGate : boolean ,
295
+ showDefaultGate : ShowGateValues ,
295
296
) : Promise < AuxiaProxyGetTreatmentsResponse > => {
296
297
// pageId example: 'money/2017/mar/10/ministers-to-criminalise-use-of-ticket-tout-harvesting-software'
297
298
const articleIdentifier = `www.theguardian.com/${ pageId } ` ;
@@ -315,7 +316,7 @@ const fetchProxyGetTreatments = async (
315
316
should_show_legacy_gate_tmp,
316
317
hasConsented,
317
318
shouldServeDismissible,
318
- mustShowDefaultGate ,
319
+ showDefaultGate ,
319
320
} ;
320
321
const params = {
321
322
method : 'POST' ,
@@ -332,8 +333,8 @@ const fetchProxyGetTreatments = async (
332
333
333
334
const decideShouldServeDismissible = ( ) : boolean => {
334
335
// 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) .
337
338
338
339
// Now the question is how do we decide the answer ?
339
340
// We return false if the following query parameter is present in the url:
@@ -348,7 +349,7 @@ const decideShouldServeDismissible = (): boolean => {
348
349
return false ;
349
350
} ;
350
351
351
- const decideMustShowDefaultGate = ( ) : boolean => {
352
+ const decideShowDefaultGate = ( ) : ShowGateValues => {
352
353
// In order to facilitate internal testing, this function observes a query parameter which forces
353
354
// the display of a sign-in gate, namely the default gu gate. If this returns true then
354
355
// the default gate is going to be displayed. Note that this applies to both auxia and
@@ -360,7 +361,17 @@ const decideMustShowDefaultGate = (): boolean => {
360
361
361
362
const params = new URLSearchParams ( window . location . search ) ;
362
363
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 ;
364
375
} ;
365
376
366
377
const buildAuxiaGateDisplayData = async (
@@ -402,7 +413,7 @@ const buildAuxiaGateDisplayData = async (
402
413
403
414
const shouldServeDismissible = decideShouldServeDismissible ( ) ;
404
415
405
- const mustShowDefaultGate = decideMustShowDefaultGate ( ) ;
416
+ const showDefaultGate = decideShowDefaultGate ( ) ;
406
417
407
418
const response = await fetchProxyGetTreatments (
408
419
contributionsServiceUrl ,
@@ -420,7 +431,7 @@ const buildAuxiaGateDisplayData = async (
420
431
should_show_legacy_gate_tmp ,
421
432
readerPersonalData . hasConsented ,
422
433
shouldServeDismissible ,
423
- mustShowDefaultGate ,
434
+ showDefaultGate ,
424
435
) ;
425
436
426
437
if ( response . status && response . data ) {
0 commit comments