From 06bf69c167b4b93dff61ef2181261fd812af5c88 Mon Sep 17 00:00:00 2001
From: anonymousratwastaken
<108170934+anonymousratwastaken@users.noreply.github.com>
Date: Sun, 21 Dec 2025 09:39:58 +0000
Subject: [PATCH] made analytics work
---
src/components/conditional-analytics.tsx | 41 ++++++++++++++++--------
src/components/cookie-notice.tsx | 1 -
2 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/src/components/conditional-analytics.tsx b/src/components/conditional-analytics.tsx
index 66d1cb9..229e800 100644
--- a/src/components/conditional-analytics.tsx
+++ b/src/components/conditional-analytics.tsx
@@ -1,24 +1,39 @@
"use client";
-import { useEffect, useState } from "react";
import { Analytics } from "@vercel/analytics/next";
import { SpeedInsights } from "@vercel/speed-insights/next";
export function ConditionalAnalytics() {
- const [analyticsEnabled, setAnalyticsEnabled] = useState(false);
-
- useEffect(() => {
- // check if analytics are enabled
- const enabled = localStorage.getItem("analytics-enabled") === "true";
- setAnalyticsEnabled(enabled);
- }, []);
-
- if (!analyticsEnabled) return null;
-
return (
<>
-
-
+ {
+ // check if user has consented
+ const analyticsEnabled = localStorage.getItem("analytics-enabled") === "true";
+
+ // if not consented, return null to block the event
+ if (!analyticsEnabled) {
+ return null;
+ }
+
+ // if consented, return the event to send it
+ return event;
+ }}
+ />
+ {
+ // check if user has consented
+ const analyticsEnabled = localStorage.getItem("analytics-enabled") === "true";
+
+ // if not consented, return null to block the event
+ if (!analyticsEnabled) {
+ return null;
+ }
+
+ // if consented, return the event to send it
+ return event;
+ }}
+ />
>
);
}
\ No newline at end of file
diff --git a/src/components/cookie-notice.tsx b/src/components/cookie-notice.tsx
index be87771..027bca5 100644
--- a/src/components/cookie-notice.tsx
+++ b/src/components/cookie-notice.tsx
@@ -23,7 +23,6 @@ export function CookieConsent() {
onClick: () => {
localStorage.setItem("cookie-consent", "accepted");
localStorage.setItem("analytics-enabled", "true");
- window.location.reload();
},
},
cancel: {