Skip to content

Commit 365c6a8

Browse files
committed
next
1 parent e5e06a6 commit 365c6a8

2 files changed

Lines changed: 23 additions & 14 deletions

File tree

src/components/CookieConsentIsland.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ export function CookieConsentWrapper() {
66
useEffect(() => {
77
// Let the legacy script do its thing after mount
88
// You can optionally load or trigger it here
9+
const windowAsAny = (window as any);
10+
if (windowAsAny.tryInitializeWcp) {
11+
console.log('tryInitializeWcp is defined');
12+
windowAsAny.tryInitializeWcp();
13+
} else {
14+
console.warn('tryInitializeWcp is not defined');
15+
}
916
}, []);
1017

1118
return <div id="cookiebanner" ref={ref} suppressHydrationWarning />;

src/components/telemetry.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,23 @@ function evaluateUserConsent() {
7474
}
7575
}
7676
}
77-
WcpConsent.init('en-US', 'cookiebanner', function (err, _siteConsent) {
78-
if (err != undefined) {
79-
if (showTelemetryDebug) {
80-
console.log('WcpConsent.init error', err);
81-
}
82-
return err;
83-
} else {
84-
siteConsent = _siteConsent;
85-
if (showTelemetryDebug) {
86-
console.log('WcpConsent.init', siteConsent);
77+
function tryInitializeWcp() {
78+
WcpConsent.init('en-US', 'cookiebanner', function (err, _siteConsent) {
79+
if (err != undefined) {
80+
if (showTelemetryDebug) {
81+
console.log('WcpConsent.init error', err);
82+
}
83+
return err;
84+
} else {
85+
siteConsent = _siteConsent;
86+
if (showTelemetryDebug) {
87+
console.log('WcpConsent.init', siteConsent);
88+
}
8789
}
88-
}
89-
evaluateShowManagement();
90-
evaluateUserConsent();
91-
}, onConsentChanged);
90+
evaluateShowManagement();
91+
evaluateUserConsent();
92+
}, onConsentChanged);
93+
}
9294

9395
function manageCookies() {
9496
if(siteConsent.isConsentRequired){

0 commit comments

Comments
 (0)