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 (
)
diff --git a/src/lib/analyticsConfig.ts b/src/lib/analyticsConfig.ts
deleted file mode 100644
index e1b74d8..0000000
--- a/src/lib/analyticsConfig.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-interface AnalyticsConfig {
- websiteId: string
- src: string
- domains: string[]
- enabled: boolean
-}
-
-export function getAnalyticsConfig(): AnalyticsConfig | null {
- const websiteId = process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID
- const src =
- process.env.NEXT_PUBLIC_UMAMI_SRC || "https://analytics.umami.is/script.js"
-
- if (!websiteId) {
- return null
- }
-
- // Define allowed domains
- const domains = ["uiogaming.no", "www.uiogaming.no"]
-
- // Additional environment-based checks
- const enabled = process.env.NODE_ENV === "production"
-
- return {
- websiteId,
- src,
- domains,
- enabled,
- }
-}