@@ -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+
329349const 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