From be9d1208bfeebe6a5ea8ffe6dbb40b7202a1f6f8 Mon Sep 17 00:00:00 2001 From: "brian.mulier" Date: Tue, 19 Mar 2024 10:44:07 +0100 Subject: [PATCH] fix(cookie-consent): prevent multiple cookieconsent registering --- plugins/cookieconsent.client.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/cookieconsent.client.ts b/plugins/cookieconsent.client.ts index 93b8a5e7ab..4fb62ea2c5 100644 --- a/plugins/cookieconsent.client.ts +++ b/plugins/cookieconsent.client.ts @@ -4,6 +4,8 @@ import axios from "axios"; export default defineNuxtPlugin(nuxtApp => { const isEurope = Intl.DateTimeFormat().resolvedOptions().timeZone.indexOf("Europe") === 0; + const cookieConsent = CookieConsent; + nuxtApp.provide("cookieConsent", cookieConsent); nuxtApp.hook('page:finish', () => { const {initialize} = useGtag() @@ -35,9 +37,6 @@ export default defineNuxtPlugin(nuxtApp => { posthog.capture('$pageview'); }; - - const cookieConsent = CookieConsent; - nuxtApp.provide("cookieConsent", cookieConsent); const enabledMarketing = () => { return cookieConsent.loadScript('https://js-eu1.hs-scripts.com/27220195.js',{defer: "defer"}); };