diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index cabe627..6321337 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -7,7 +7,6 @@ import { notFound } from "next/navigation" import LanguageSelector from "@components/ui/languageSelector" import UmamiAnalytics from "@/components/umamiAnalytics" import { routing } from "@/i18n/routing" -import { getAnalyticsConfig } from "@/lib/analyticsConfig" export const metadata: Metadata = { title: "UiO Gaming", @@ -38,21 +37,13 @@ export default async function RootLayout({ const messages = (await import(`../../../messages/${locale}.json`)).default - const analyticsConfig = getAnalyticsConfig() - return (
{children}
- {analyticsConfig?.enabled && ( - - )} +
diff --git a/src/components/umamiAnalytics.tsx b/src/components/umamiAnalytics.tsx index afc8931..3cd195f 100644 --- a/src/components/umamiAnalytics.tsx +++ b/src/components/umamiAnalytics.tsx @@ -1,49 +1,21 @@ -"use client" - import Script from "next/script" -interface UmamiAnalyticsProps { - websiteId: string - src?: string - domains?: string[] -} +// Umami ignores visits from other domains, so local and preview deployments +// aren't counted +const DOMAINS = ["uiogaming.no", "www.uiogaming.no"] -export default function UmamiAnalytics({ - websiteId, - src = "https://analytics.umami.is/script.js", - domains, -}: UmamiAnalyticsProps) { - if (!websiteId) { - console.warn("Umami: Website ID is required") - return null - } +export default function UmamiAnalytics() { + const websiteId = process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID + const src = + process.env.NEXT_PUBLIC_UMAMI_SRC || "https://analytics.umami.is/script.js" - // Only load analytics in production or if explicitly enabled - if (process.env.NODE_ENV !== "production") { - return null - } - - // Domain validation (client-side check as additional layer) - if (domains && typeof window !== "undefined") { - const currentDomain = window.location.hostname - const isAllowedDomain = domains.some( - domain => currentDomain === domain || currentDomain.endsWith(`.${domain}`) - ) - - if (!isAllowedDomain) { - console.warn( - `Umami: Domain ${currentDomain} not in allowed list:`, - domains - ) - return null - } - } + if (!websiteId || process.env.NODE_ENV !== "production") return null return (