@@ -67,7 +67,7 @@ function stopReoDev(): void {
6767
6868async function initializeReoDev ( ) : Promise < void > {
6969 if ( typeof window === "undefined" ) return ;
70- if ( ! hasMarketingConsent ( ) ) return ;
70+ if ( ! await hasMarketingConsent ( ) ) return ;
7171 if ( isInitialized || reoInstance || reoPromise || typeof window . Reo !== 'undefined' ) return ;
7272
7373 try {
@@ -84,13 +84,10 @@ async function initializeReoDev(): Promise<void> {
8484}
8585
8686function applyConsentState ( ) : void {
87- console . log ( "[ReoDev] applyConsentState called" ) ;
8887 hasMarketingConsent ( ) . then ( ( consented ) => {
8988 if ( consented ) {
90- console . log ( "[ReoDev] Consent granted, initializing" ) ;
9189 void initializeReoDev ( ) ;
9290 } else {
93- console . log ( "[ReoDev] Consent denied, stopping" ) ;
9491 stopReoDev ( ) ;
9592 }
9693 } ) ;
@@ -101,20 +98,13 @@ function setupConsentListeners(): void {
10198 if ( listenersRegistered ) return ;
10299 listenersRegistered = true ;
103100
104- window . addEventListener ( "UC_CONSENT" , ( e ) => {
105- console . log ( "[ReoDev] UC_CONSENT event" , e ) ;
106- applyConsentState ( ) ;
107- } ) ;
108- window . addEventListener ( "UC_UI_INITIALIZED" , ( e ) => {
109- console . log ( "[ReoDev] UC_UI_INITIALIZED event" , e ) ;
101+ window . addEventListener ( "UC_CONSENT" , ( ) => {
110102 applyConsentState ( ) ;
111103 } ) ;
112104
113- // Check if CMP is already initialized (in case we missed the event)
114- if ( window . UC_UI ?. isInitialized ?.( ) ) {
115- console . log ( "[ReoDev] CMP already initialized, applying state" ) ;
105+ window . addEventListener ( "UC_UI_INITIALIZED" , ( ) => {
116106 applyConsentState ( ) ;
117- }
107+ } ) ;
118108}
119109
120110export function useReoDev ( ) {
0 commit comments