24 lines
No EOL
575 B
TypeScript
24 lines
No EOL
575 B
TypeScript
"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 (
|
|
<>
|
|
<Analytics />
|
|
<SpeedInsights />
|
|
</>
|
|
);
|
|
} |