diff --git a/app/components/ActivityFeed.tsx b/app/components/ActivityFeed.tsx index 8a534f4..c30339b 100644 --- a/app/components/ActivityFeed.tsx +++ b/app/components/ActivityFeed.tsx @@ -13,6 +13,8 @@ import { ChevronUp, Activity, X, + Eye, + EyeOff, } from "lucide-react"; // Types matching your n8n output @@ -54,6 +56,14 @@ export default function ActivityFeed() { const [isExpanded, setIsExpanded] = useState(true); const [isMinimized, setIsMinimized] = useState(false); const [hasActivity, setHasActivity] = useState(false); + const [isTrackingEnabled, setIsTrackingEnabled] = useState(() => { + // Check localStorage for tracking preference + if (typeof window !== 'undefined') { + const stored = localStorage.getItem('activityTrackingEnabled'); + return stored !== 'false'; // Default to true if not set + } + return true; + }); const [quote, setQuote] = useState<{ content: string; author: string; @@ -61,6 +71,11 @@ export default function ActivityFeed() { // Fetch data every 30 seconds (optimized to match server cache) useEffect(() => { + // Don't fetch if tracking is disabled + if (!isTrackingEnabled) { + return; + } + const fetchData = async () => { try { // Add timestamp to prevent aggressive caching but respect server cache @@ -109,7 +124,7 @@ export default function ActivityFeed() { // The n8n API already has 30s cache, so faster polling doesn't help const interval = setInterval(fetchData, 30000); return () => clearInterval(interval); - }, [isMinimized]); + }, [isMinimized, isTrackingEnabled]); // Fetch nerdy quote when idle useEffect(() => { @@ -1144,6 +1159,45 @@ export default function ActivityFeed() { } }, [hasActivity, quote]); + // Toggle tracking on/off + const toggleTracking = () => { + const newValue = !isTrackingEnabled; + setIsTrackingEnabled(newValue); + if (typeof window !== 'undefined') { + localStorage.setItem('activityTrackingEnabled', String(newValue)); + } + // Clear data when disabling + if (!newValue) { + setData(null); + setHasActivity(false); + } + }; + + // Don't render if tracking is disabled and no data + if (!isTrackingEnabled && !data) return null; + + // If tracking disabled but we have data, show a disabled state + if (!isTrackingEnabled && data) { + return ( +