'use client' import { useState, useEffect } from 'react' import { Button, Toggle, toast, Spinner } from '@ciphera-net/ui' import { ShieldCheck } from '@phosphor-icons/react' import { useSite, useBotFilterStats } from '@/lib/swr/dashboard' import { updateSite } from '@/lib/api/sites' export default function SiteBotSpamTab({ siteId }: { siteId: string }) { const { data: site, mutate } = useSite(siteId) const { data: botStats } = useBotFilterStats(siteId) const [filterBots, setFilterBots] = useState(false) const [saving, setSaving] = useState(false) useEffect(() => { if (site) setFilterBots(site.filter_bots ?? false) }, [site]) const handleSave = async () => { setSaving(true) try { await updateSite(siteId, { name: site?.name || '', filter_bots: filterBots }) await mutate() toast.success('Bot filtering updated') } catch { toast.error('Failed to save') } finally { setSaving(false) } } if (!site) return
return (

Bot & Spam Filtering

Automatically filter bot traffic and referrer spam from your analytics.

{/* Bot filtering toggle */}

Enable bot filtering

Filter known bots, crawlers, referrer spam, and suspicious traffic.

setFilterBots(p => !p)} />
{/* Stats */} {botStats && (

{botStats.filtered_sessions ?? 0}

Sessions filtered

{botStats.filtered_events ?? 0}

Events filtered

{botStats.auto_blocked_this_month ?? 0}

Auto-blocked this month

)}

For detailed session review and manual blocking, use the full{' '} site settings page .

) }