File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ import { InstructionsWizard } from "@/components/instructions-wizard"
77import HeroIconsRow from "@/components/HeroIconsRow"
88import { ThemeToggle } from "@/components/theme-toggle"
99import { getHeroIconItems , getHomeMainClasses } from "@/lib/utils"
10+ import { ANALYTICS_EVENTS } from "@/lib/analytics-events"
11+ import { track } from "@/lib/mixpanel"
1012import { Github } from "lucide-react"
1113import Link from "next/link"
1214
@@ -56,7 +58,10 @@ export default function Home() {
5658 < Button
5759 size = "lg"
5860 className = "px-8 py-6 text-lg"
59- onClick = { ( ) => setShowWizard ( true ) }
61+ onClick = { ( ) => {
62+ track ( ANALYTICS_EVENTS . CREATE_INSTRUCTIONS_FILE )
63+ setShowWizard ( true )
64+ } }
6065 >
6166 Create My Instructions File
6267 </ Button >
Original file line number Diff line number Diff line change 1+ export const ANALYTICS_EVENTS = {
2+ PAGE_VIEW : "Page View" ,
3+ CREATE_INSTRUCTIONS_FILE : "Create My Instructions File" ,
4+ } as const
5+
6+ export type AnalyticsEvent =
7+ ( typeof ANALYTICS_EVENTS ) [ keyof typeof ANALYTICS_EVENTS ]
Original file line number Diff line number Diff line change 11import mixpanel from "mixpanel-browser"
22
3+ import { ANALYTICS_EVENTS , type AnalyticsEvent } from "@/lib/analytics-events"
4+
35const MIXPANEL_TOKEN = process . env . NEXT_PUBLIC_MIXPANEL_TOKEN
46
57let isMixpanelInitialized = false
@@ -24,7 +26,7 @@ export const initMixpanel = () => {
2426 isMixpanelInitialized = true
2527}
2628
27- export const track = ( event : string , props ?: Record < string , unknown > ) => {
29+ export const track = ( event : AnalyticsEvent , props ?: Record < string , unknown > ) => {
2830 if ( typeof window === "undefined" || ! isMixpanelInitialized ) {
2931 return
3032 }
@@ -41,7 +43,7 @@ export const identify = (userId: string) => {
4143}
4244
4345export const trackPageView = ( path : string , search ?: string ) => {
44- track ( "Page View" , {
46+ track ( ANALYTICS_EVENTS . PAGE_VIEW , {
4547 path,
4648 search : search || undefined ,
4749 } )
You can’t perform that action at this time.
0 commit comments