snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
41
apps/v4/lib/events.ts
Normal file
41
apps/v4/lib/events.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import va from "@vercel/analytics"
|
||||
import { z } from "zod"
|
||||
|
||||
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",
|
||||
"enable_lift_mode",
|
||||
"copy_chart_code",
|
||||
"copy_chart_theme",
|
||||
"copy_chart_data",
|
||||
"copy_color",
|
||||
"set_layout",
|
||||
"search_query",
|
||||
"create_app",
|
||||
"copy_create_share_url",
|
||||
"copy_registry_add_command",
|
||||
"copy_preset_command",
|
||||
"copy_apply_command",
|
||||
"copy_typeset_css",
|
||||
"copy_typeset_prompt",
|
||||
]),
|
||||
// declare type AllowedPropertyValues = string | number | boolean | null
|
||||
properties: z
|
||||
.record(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) {
|
||||
va.track(event.name, event.properties)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user