'use client' import Link from 'next/link' import { formatNumber } from '@ciphera-net/ui' import { Target } from '@phosphor-icons/react' import { BookOpenIcon, ArrowRightIcon } from '@ciphera-net/ui' import type { GoalCountStat } from '@/lib/api/stats' interface GoalStatsProps { goalCounts: GoalCountStat[] onSelectEvent?: (eventName: string) => void } const LIMIT = 10 export default function GoalStats({ goalCounts, onSelectEvent }: GoalStatsProps) { const list = (goalCounts || []).slice(0, LIMIT) const hasData = list.length > 0 const total = list.reduce((sum, r) => sum + r.count, 0) const emptySlots = Math.max(0, 6 - list.length) return (

Goals & Events

{hasData ? (
{list.map((row) => (
onSelectEvent?.(row.event_name)} className={`flex items-center justify-between h-9 group hover:bg-neutral-50 dark:hover:bg-neutral-800 rounded-lg px-2 -mx-2 transition-colors${onSelectEvent ? ' cursor-pointer' : ''}`} >
{row.display_name ?? row.event_name.replace(/_/g, ' ')}
{total > 0 ? `${Math.round((row.count / total) * 100)}%` : ''} {formatNumber(row.count)}
))} {Array.from({ length: emptySlots }).map((_, i) => ( ) : (

Need help tracking goals?

Add pulse.track('event_name') where actions happen on your site, then see counts here. Check our guide for step-by-step instructions.

Read documentation
)}
) }