forked from shadcn-ui/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(www): implement event tracking (shadcn-ui#218)
* feat(www): implement event tracking * fix(www): always show copy button * fix(www): update align props for copy button
- Loading branch information
Showing
9 changed files
with
176 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
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", | ||
]), | ||
// 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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.