@@ -290,6 +290,7 @@ const fetchProxyGetTreatments = async (
290
290
mvtId : number ,
291
291
should_show_legacy_gate_tmp : boolean ,
292
292
hasConsented : boolean ,
293
+ shouldNotServeMandatory : boolean ,
293
294
) : Promise < AuxiaProxyGetTreatmentsResponse > => {
294
295
// pageId example: 'money/2017/mar/10/ministers-to-criminalise-use-of-ticket-tout-harvesting-software'
295
296
const articleIdentifier = `www.theguardian.com/${ pageId } ` ;
@@ -312,6 +313,7 @@ const fetchProxyGetTreatments = async (
312
313
mvtId,
313
314
should_show_legacy_gate_tmp,
314
315
hasConsented,
316
+ shouldNotServeMandatory,
315
317
} ;
316
318
const params = {
317
319
method : 'POST' ,
@@ -326,6 +328,24 @@ const fetchProxyGetTreatments = async (
326
328
return Promise . resolve ( response ) ;
327
329
} ;
328
330
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
+
329
349
const buildAuxiaGateDisplayData = async (
330
350
contributionsServiceUrl : string ,
331
351
pageId : string ,
@@ -363,6 +383,8 @@ const buildAuxiaGateDisplayData = async (
363
383
) ;
364
384
}
365
385
386
+ const shouldNotServeMandatory = decideShouldNotServeMandatory ( ) ;
387
+
366
388
const response = await fetchProxyGetTreatments (
367
389
contributionsServiceUrl ,
368
390
pageId ,
@@ -378,6 +400,7 @@ const buildAuxiaGateDisplayData = async (
378
400
readerPersonalData . mvtId ,
379
401
should_show_legacy_gate_tmp ,
380
402
readerPersonalData . hasConsented ,
403
+ shouldNotServeMandatory ,
381
404
) ;
382
405
383
406
if ( response . status && response . data ) {
0 commit comments