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' ;
2
2
import { useState } from 'react' ;
3
3
import {
4
4
hasCmpConsentForBrowserId ,
@@ -376,7 +376,15 @@ const decideShowDefaultGate = (): ShowGateValues => {
376
376
377
377
const getGateDisplayCount = ( ) : number => {
378
378
// 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 ) ;
380
388
} ;
381
389
382
390
const buildAuxiaGateDisplayData = async (
@@ -732,6 +740,10 @@ const ShowSignInGateAuxia = ({
732
740
} ,
733
741
renderingTarget ,
734
742
) ;
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 ( ) ;
735
747
} , [ componentId ] ) ;
736
748
737
749
return (
You can’t perform that action at this time.
0 commit comments