@@ -313,8 +313,7 @@ const ConsentComponentCustomApp = (props: any) => {
313313 }
314314 } ;
315315
316- const handleAgree = async ( visitor_uuid ?: string ) => {
317- const uuidConsent = visitor_uuid ?? uuid ;
316+ const handleAgree = async ( ) => {
318317 try {
319318 let flag = true ;
320319 // Wallets
@@ -381,7 +380,7 @@ const ConsentComponentCustomApp = (props: any) => {
381380 await agreeConsents (
382381 endpoint ,
383382 level ,
384- uuidConsent ,
383+ uuid ,
385384 consents ,
386385 account ,
387386 signature ,
@@ -413,7 +412,7 @@ const ConsentComponentCustomApp = (props: any) => {
413412 }
414413 } else {
415414 setLoading ( 'saving' ) ;
416- const consentList = await getConsents ( endpoint , uuidConsent ) ;
415+ const consentList = await getConsents ( endpoint , uuid ) ;
417416 consents . forEach ( async ( consent ) => {
418417 const existConsent = consentList . find ( ( item : any ) => item ?. consent === consent ) ;
419418 if ( ! existConsent ) {
@@ -424,7 +423,7 @@ const ConsentComponentCustomApp = (props: any) => {
424423 : disabledBlockDomains ?. length || window [ 'disabledBlockJSDomains' ] ?. length
425424 ? 5
426425 : 1 ,
427- uuidConsent ,
426+ uuid ,
428427 consent ,
429428 null ,
430429 null ,
@@ -446,7 +445,7 @@ const ConsentComponentCustomApp = (props: any) => {
446445 : disabledBlockDomains ?. length || window [ 'disabledBlockJSDomains' ] ?. length
447446 ? 5
448447 : 1 ,
449- uuidConsent ,
448+ uuid ,
450449 consent ,
451450 null ,
452451 null ,
@@ -462,7 +461,7 @@ const ConsentComponentCustomApp = (props: any) => {
462461 }
463462
464463 if ( flag && ( account || level < 3 ) ) {
465- sessionStorage . setItem ( 'aesirx-analytics-uuid' , uuidConsent ) ;
464+ sessionStorage . setItem ( 'aesirx-analytics-uuid' , uuid ) ;
466465 sessionStorage . setItem ( 'aesirx-analytics-allow' , '1' ) ;
467466
468467 setShow ( false ) ;
@@ -760,16 +759,11 @@ const ConsentComponentCustomApp = (props: any) => {
760759 }
761760 const init = async ( ) => {
762761 const isAnalyticsEnabled = window [ 'aesirx-analytics-enable' ] === 'true' ;
763- const isOptOutMode = window [ 'aesirxOptOutMode' ] === 'true' ;
764762 const disableGPC = window [ 'disableGPCsupport' ] === 'true' ;
765763 const hasGlobalPrivacyControl = ( navigator as any ) . globalPrivacyControl ;
766764 const shouldStartTracking =
767765 ( ! analyticsContext ?. setUUID && ! isAnalyticsEnabled ) ||
768766 ( analyticsContext ?. setUUID && isAnalyticsEnabled ) ;
769- const isConsented =
770- showRevoke ||
771- ( sessionStorage . getItem ( 'aesirx-analytics-revoke' ) &&
772- sessionStorage . getItem ( 'aesirx-analytics-revoke' ) !== '0' ) ;
773767
774768 if ( shouldStartTracking ) {
775769 const response = await startTracker ( endpoint , '' , '' , '' , window [ 'attributes' ] ) ;
@@ -786,10 +780,6 @@ const ConsentComponentCustomApp = (props: any) => {
786780 window [ 'event_uuid' ] = response . event_uuid ;
787781 }
788782 }
789-
790- if ( isOptOutMode && ! isConsented && ! isRejected ) {
791- handleAgree ( response . visitor_uuid ) ;
792- }
793783 }
794784 }
795785
@@ -800,6 +790,21 @@ const ConsentComponentCustomApp = (props: any) => {
800790 init ( ) ;
801791 } , [ ] ) ;
802792
793+ useEffect ( ( ) => {
794+ const isOptOutMode = window [ 'aesirxOptOutMode' ] === 'true' ;
795+ const isRejected = sessionStorage . getItem ( 'aesirx-analytics-rejected' ) === 'true' ;
796+ const isConsented =
797+ showRevoke ||
798+ ( sessionStorage . getItem ( 'aesirx-analytics-revoke' ) &&
799+ sessionStorage . getItem ( 'aesirx-analytics-revoke' ) !== '0' ) ;
800+ const uuid = sessionStorage . getItem ( 'aesirx-analytics-uuid' ) ;
801+ if ( uuid ) {
802+ if ( isOptOutMode && ! isConsented && ! isRejected ) {
803+ handleAgree ( ) ;
804+ }
805+ }
806+ } , [ showRevoke , show ] ) ;
807+
803808 useEffect ( ( ) => {
804809 ( gtagId || gtmId ) && loadConsentDefault ( gtagId , gtmId ) ;
805810 } , [ layout , gtagId , gtmId ] ) ;
0 commit comments