From d0d7a9710226ebc54458371a22a875fbafd9fbb3 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Wed, 25 Mar 2026 17:46:06 +0100 Subject: [PATCH] feat(settings): add retention, excluded paths, pagespeed to unified privacy tab --- .../settings/unified/tabs/SitePrivacyTab.tsx | 135 +++++++++++++++++- 1 file changed, 128 insertions(+), 7 deletions(-) diff --git a/components/settings/unified/tabs/SitePrivacyTab.tsx b/components/settings/unified/tabs/SitePrivacyTab.tsx index 1f1e2b2..1834578 100644 --- a/components/settings/unified/tabs/SitePrivacyTab.tsx +++ b/components/settings/unified/tabs/SitePrivacyTab.tsx @@ -2,8 +2,13 @@ import { useState, useEffect } from 'react' import { Button, Select, Toggle, toast, Spinner } from '@ciphera-net/ui' -import { useSite } from '@/lib/swr/dashboard' +import { useSite, useSubscription, usePageSpeedConfig } from '@/lib/swr/dashboard' import { updateSite } from '@/lib/api/sites' +import { updatePageSpeedConfig } from '@/lib/api/pagespeed' +import { getRetentionOptionsForPlan, formatRetentionMonths } from '@/lib/plans' +import { generatePrivacySnippet } from '@/lib/utils/privacySnippet' +import { Copy, CheckCircle } from '@phosphor-icons/react' +import Link from 'next/link' const GEO_OPTIONS = [ { value: 'full', label: 'Full (country, region, city)' }, @@ -13,6 +18,8 @@ const GEO_OPTIONS = [ export default function SitePrivacyTab({ siteId }: { siteId: string }) { const { data: site, mutate } = useSite(siteId) + const { data: subscription, error: subscriptionError, mutate: mutateSubscription } = useSubscription() + const { data: psiConfig, mutate: mutatePSIConfig } = usePageSpeedConfig(siteId) const [collectPagePaths, setCollectPagePaths] = useState(true) const [collectReferrers, setCollectReferrers] = useState(true) const [collectDeviceInfo, setCollectDeviceInfo] = useState(true) @@ -20,6 +27,8 @@ export default function SitePrivacyTab({ siteId }: { siteId: string }) { const [collectGeoData, setCollectGeoData] = useState('full') const [hideUnknownLocations, setHideUnknownLocations] = useState(false) const [dataRetention, setDataRetention] = useState(6) + const [excludedPaths, setExcludedPaths] = useState('') + const [snippetCopied, setSnippetCopied] = useState(false) const [saving, setSaving] = useState(false) useEffect(() => { @@ -31,6 +40,7 @@ export default function SitePrivacyTab({ siteId }: { siteId: string }) { setCollectGeoData(site.collect_geo_data ?? 'full') setHideUnknownLocations(site.hide_unknown_locations ?? false) setDataRetention(site.data_retention_months ?? 6) + setExcludedPaths((site.excluded_paths || []).join('\n')) } }, [site]) @@ -45,6 +55,8 @@ export default function SitePrivacyTab({ siteId }: { siteId: string }) { collect_screen_resolution: collectScreenRes, collect_geo_data: collectGeoData as 'full' | 'country' | 'none', hide_unknown_locations: hideUnknownLocations, + data_retention_months: dataRetention, + excluded_paths: excludedPaths.split('\n').map(p => p.trim()).filter(Boolean), }) await mutate() toast.success('Privacy settings updated') @@ -93,12 +105,121 @@ export default function SitePrivacyTab({ siteId }: { siteId: string }) {

Controls location granularity. "Disabled" collects no geographic data at all.

-
- -

- Currently retaining data for {dataRetention} months. - Manage retention in the full site settings. -

+ {/* Data Retention */} +
+

Data Retention

+ + {subscriptionError && ( +
+

Plan limits could not be loaded.

+ +
+ )} + +
+
+
+

Keep raw event data for

+

Events older than this are automatically deleted. Aggregated daily stats are kept permanently.

+
+