Files
zeekay cadd04ca8f fix(analytics): use @hanzo/analytics, drop @vercel/analytics
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.
2026-07-25 10:57:38 -07:00

34 lines
763 B
TypeScript

import { z } from "zod"
import { analytics } from "@/lib/analytics"
const eventSchema = z.object({
name: z.enum([
"copy_npm_command",
"copy_usage_import_code",
"copy_usage_code",
"copy_primitive_code",
"copy_theme_code",
"copy_block_code",
"copy_chunk_code",
"copy_color",
"enable_lift_mode",
]),
// declare type AllowedPropertyValues = string | number | boolean | null
properties: z
.record(
z.string(),
z.union([z.string(), z.number(), z.boolean(), z.null()])
)
.optional(),
})
export type Event = z.infer<typeof eventSchema>
export function trackEvent(input: Event): void {
const event = eventSchema.parse(input)
if (event) {
analytics.capture(event.name, event.properties)
}
}