mirror of
https://github.com/hanzoai/shadcn.git
synced 2026-10-30 18:22:59 +00:00
ui.hanzo.ai is a static export on GitHub Pages, not Vercel, so @vercel/analytics injected /_vercel/insights/script.js — which 404s and is then refused as text/html, on every page. It was also a second way to do a thing we already own: pkgs/capture ships @hanzo/analytics. Route both call sites through one client (lib/analytics.ts): the mount sends pageviews, trackEvent sends events. Neither knows the vendor — they name what happened and the client owns where it goes.
22 lines
430 B
TypeScript
22 lines
430 B
TypeScript
"use client"
|
|
|
|
import { useEffect, useRef } from "react"
|
|
import { usePathname } from "next/navigation"
|
|
|
|
import { analytics } from "@/lib/analytics"
|
|
|
|
export function Analytics() {
|
|
const pathname = usePathname()
|
|
const started = useRef(false)
|
|
|
|
useEffect(() => {
|
|
if (!started.current) {
|
|
started.current = true
|
|
analytics.init()
|
|
}
|
|
analytics.pageview(pathname ?? undefined)
|
|
}, [pathname])
|
|
|
|
return null
|
|
}
|