diff --git a/src/components/general/MatomoTracker.tsx b/src/components/general/MatomoTracker.tsx index 53256f4..f809834 100644 --- a/src/components/general/MatomoTracker.tsx +++ b/src/components/general/MatomoTracker.tsx @@ -5,10 +5,6 @@ import { notifications } from "@mantine/notifications"; import { Button, Flex, Group, Stack, Text } from "@mantine/core"; import Link from "next/link"; -const MATOMO_URL = process.env.NEXT_PUBLIC_MATOMO_URL; -const MATOMO_SITE_ID = process.env.NEXT_PUBLIC_MATOMO_SITE_ID; -const IS_DEV_ENV = process.env.NODE_ENV !== "production"; - const MatomoTracker = () => { const [hasAcceptedCookies, setHasAcceptedCookies] = useLocalStorage({ @@ -58,11 +54,24 @@ const MatomoTracker = () => { }, [hasAcceptedCookies, showCookieConsentNotification]); useEffect(() => { + const MATOMO_URL = process.env.NEXT_PUBLIC_MATOMO_URL; + const MATOMO_SITE_ID = process.env.NEXT_PUBLIC_MATOMO_SITE_ID; + const IS_DEV_ENV = process.env.NODE_ENV !== "production"; + console.log("Checking if Matomo should be initialized"); console.log( - `Conditional: ${!IS_DEV_ENV && MATOMO_URL && MATOMO_SITE_ID}`, + `Conditional: ${!IS_DEV_ENV && MATOMO_URL != undefined && MATOMO_SITE_ID != undefined}`, + ); + console.log( + !IS_DEV_ENV && + MATOMO_URL != undefined && + MATOMO_SITE_ID != undefined, ); - if (!IS_DEV_ENV && MATOMO_URL && MATOMO_SITE_ID) { + if ( + !IS_DEV_ENV && + MATOMO_URL != undefined && + MATOMO_SITE_ID != undefined + ) { console.log( `Matomo initialized! URL: ${MATOMO_URL} | SiteID: ${MATOMO_SITE_ID}`, );