'use client' import { PolarAngleAxis, PolarGrid, Radar, RadarChart, Tooltip } from 'recharts' import { BarChartIcon } from '@ciphera-net/ui' import type { GoalCountStat } from '@/lib/api/stats' interface ScrollDepthProps { goalCounts: GoalCountStat[] totalPageviews: number } const THRESHOLDS = [25, 50, 75, 100] as const export default function ScrollDepth({ goalCounts, totalPageviews }: ScrollDepthProps) { const scrollCounts = new Map() for (const row of goalCounts) { const match = row.event_name.match(/^scroll_(\d+)$/) if (match) { scrollCounts.set(Number(match[1]), row.count) } } const hasData = scrollCounts.size > 0 && totalPageviews > 0 const chartData = [ { label: '0%', value: 100 }, ...THRESHOLDS.map((threshold) => ({ label: `${threshold}%`, value: totalPageviews > 0 ? Math.round(((scrollCounts.get(threshold) ?? 0) / totalPageviews) * 100) : 0, })), ] return (

Scroll Depth

{hasData ? (
[`${value}%`, 'Reached']} />
) : (

No scroll data yet

Scroll depth tracking is automatic — data will appear here once visitors start scrolling on your pages.

)}
) }