AnalyticsUsage
useAnalytics
Hook for tracking events and identifying users
The main hook for analytics in client components.
Import
import { } from "@repo/analytics"Usage
"use client"
import { } from "@repo/analytics"
export function () {
const { , , , } = ()
return (
< ={() => ("BUTTON_CLICKED", { : "cta" })}>
Click me
</>
)
}Return Value
| Method | Description |
|---|---|
track | Track a custom event with optional properties |
identify | Associate events with a user identity |
page | Track a page view (automatic in Next.js) |
reset | Clear user identity (on logout) |
Example
"use client"
import { } from "@repo/analytics"
import { } from "@repo/auth"
export function () {
const { , } = ()
const { } = ()
async function () {
("EXPORT_CLICKED", { : "csv" })
await exportData()
}
async function () {
await ()
()
}
return (
<>
< ={}>Export</>
< ={}>Sign Out</>
</>
)
}