forked from BeOnAuto/auto-engineer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents.ts
More file actions
31 lines (28 loc) · 798 Bytes
/
events.ts
File metadata and controls
31 lines (28 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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',
]),
// 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);
}
}