File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
dotcom-rendering/src/components Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 1- import { getCookie , isUndefined } from '@guardian/libs' ;
1+ import { getCookie , isUndefined , storage } from '@guardian/libs' ;
22import { useState } from 'react' ;
33import {
44 hasCmpConsentForBrowserId ,
@@ -376,7 +376,15 @@ const decideShowDefaultGate = (): ShowGateValues => {
376376
377377const getGateDisplayCount = ( ) : number => {
378378 // TODO: retrieve the number of time the page has been displayed
379- return 0 ;
379+ const count = storage . local . get ( 'gate_display_count' ) as number ;
380+ return count ;
381+ } ;
382+
383+ const incrementGateDisplayCount = ( ) => {
384+ const count = getGateDisplayCount ( ) ;
385+ const now = new Date ( ) ;
386+ const oneYearFromNow = new Date ( now . getTime ( ) + 365 * 86400 ) ;
387+ storage . local . set ( 'gate_display_count' , count + 1 , oneYearFromNow ) ;
380388} ;
381389
382390const buildAuxiaGateDisplayData = async (
@@ -732,6 +740,10 @@ const ShowSignInGateAuxia = ({
732740 } ,
733741 renderingTarget ,
734742 ) ;
743+
744+ // Once the gate is being displayed we need to update
745+ // the tracking of the number of times the gate has been displayed
746+ incrementGateDisplayCount ( ) ;
735747 } , [ componentId ] ) ;
736748
737749 return (
You can’t perform that action at this time.
0 commit comments