'use client' import { formatNumber } from '@ciphera-net/ui' 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 return (

Scroll Depth

{hasData ? (
{THRESHOLDS.map((threshold) => { const count = scrollCounts.get(threshold) ?? 0 const pct = totalPageviews > 0 ? Math.round((count / totalPageviews) * 100) : 0 const barWidth = Math.max(pct, 2) return (
{threshold}%
{formatNumber(count)} {pct}%
) })}
) : (

No scroll data yet

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

)}
) }