Skip to content

Commit

Permalink
Merge pull request #43 from game-node-app/dev
Browse files Browse the repository at this point in the history
logging
  • Loading branch information
Lamarcke authored Mar 19, 2024
2 parents 966fa48 + c962724 commit 302f99b
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/components/general/MatomoTracker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>({
Expand Down Expand Up @@ -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}`,
);
Expand Down

0 comments on commit 302f99b

Please sign in to comment.