From c807568e93a2eccf76872e5d66da7c03424cc69a Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Mon, 19 Jan 2026 11:49:25 +0100 Subject: [PATCH] feat: Add data collection settings to Site interface and update SiteSettingsPage --- app/sites/[id]/settings/page.tsx | 155 +++++++++++++++++++++++++++++-- lib/api/sites.ts | 14 +++ 2 files changed, 160 insertions(+), 9 deletions(-) diff --git a/app/sites/[id]/settings/page.tsx b/app/sites/[id]/settings/page.tsx index 26b4ff8..8af5a90 100644 --- a/app/sites/[id]/settings/page.tsx +++ b/app/sites/[id]/settings/page.tsx @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react' import { useParams, useRouter } from 'next/navigation' -import { getSite, updateSite, resetSiteData, deleteSite, type Site } from '@/lib/api/sites' +import { getSite, updateSite, resetSiteData, deleteSite, type Site, type GeoDataLevel } from '@/lib/api/sites' import { getRealtime } from '@/lib/api/stats' import { toast } from 'sonner' import LoadingOverlay from '@/components/LoadingOverlay' @@ -52,7 +52,13 @@ export default function SiteSettingsPage() { timezone: 'UTC', is_public: false, password: '', - excluded_paths: '' + excluded_paths: '', + // Data collection settings + collect_page_paths: true, + collect_referrers: true, + collect_device_info: true, + collect_geo_data: 'full' as GeoDataLevel, + collect_screen_resolution: true }) const [scriptCopied, setScriptCopied] = useState(false) const [linkCopied, setLinkCopied] = useState(false) @@ -73,7 +79,13 @@ export default function SiteSettingsPage() { timezone: data.timezone || 'UTC', is_public: data.is_public || false, password: '', // Don't show existing password - excluded_paths: (data.excluded_paths || []).join('\n') + excluded_paths: (data.excluded_paths || []).join('\n'), + // Data collection settings (default to true/full for backwards compatibility) + collect_page_paths: data.collect_page_paths ?? true, + collect_referrers: data.collect_referrers ?? true, + collect_device_info: data.collect_device_info ?? true, + collect_geo_data: data.collect_geo_data || 'full', + collect_screen_resolution: data.collect_screen_resolution ?? true }) if (data.has_password) { setIsPasswordEnabled(true) @@ -103,7 +115,13 @@ export default function SiteSettingsPage() { is_public: formData.is_public, password: isPasswordEnabled ? (formData.password || undefined) : undefined, clear_password: !isPasswordEnabled, - excluded_paths: excludedPathsArray + excluded_paths: excludedPathsArray, + // Data collection settings + collect_page_paths: formData.collect_page_paths, + collect_referrers: formData.collect_referrers, + collect_device_info: formData.collect_device_info, + collect_geo_data: formData.collect_geo_data, + collect_screen_resolution: formData.collect_screen_resolution }) toast.success('Site updated successfully') loadSite() @@ -521,10 +539,129 @@ export default function SiteSettingsPage() {

Data & Privacy

-

Manage data collection and filtering.

+

Control what visitor data is collected. Less data = more privacy.

+ {/* Data Collection Controls */}
+

Data Collection

+ + {/* Page Paths Toggle */} +
+
+
+

Page Paths

+

+ Track which pages visitors view +

+
+ +
+
+ + {/* Referrers Toggle */} +
+
+
+

Referrers

+

+ Track where visitors come from +

+
+ +
+
+ + {/* Device Info Toggle */} +
+
+
+

Device Info

+

+ Track browser, OS, and device type +

+
+ +
+
+ + {/* Geographic Data Dropdown */} +
+
+
+

Geographic Data

+

+ Control location tracking granularity +

+
+
+ +
+ + + +
+
+
+
+ + {/* Screen Resolution Toggle */} +
+
+
+

Screen Resolution

+

+ Track visitor screen sizes +

+
+ +
+
+
+ + {/* Excluded Paths */} +
+

Path Filtering