track id check events
This commit is contained in:
@@ -24,6 +24,15 @@ export default function RootLayout({
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
{process.env.UMAMI_SCRIPT_URL && process.env.UMAMI_WEBSITE_ID && (
|
||||
<script
|
||||
defer
|
||||
src={process.env.UMAMI_SCRIPT_URL}
|
||||
data-website-id={process.env.UMAMI_WEBSITE_ID}
|
||||
></script>
|
||||
)}
|
||||
</head>
|
||||
<body
|
||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||
>
|
||||
|
@@ -70,6 +70,20 @@ async function lookupSession(sessionId: string) {
|
||||
return res.json();
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
umami?: {
|
||||
track: (eventName: string, eventData?: Record<string, unknown>) => void;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const trackEvent = (eventName: string, eventData?: Record<string, unknown>) => {
|
||||
if (typeof window !== "undefined" && window.umami) {
|
||||
window.umami.track(eventName, eventData);
|
||||
}
|
||||
};
|
||||
|
||||
function HomeInner() {
|
||||
const [session, setSession] = useState<SessionResponse | null>(null);
|
||||
const [scannedCodes, setScannedCodes] = useState<Set<string>>(new Set());
|
||||
@@ -91,6 +105,7 @@ function HomeInner() {
|
||||
if (data && typeof data.age === "number") {
|
||||
setSession(data);
|
||||
setScannedCodes((prev) => new Set(prev).add(variables));
|
||||
trackEvent("id-check");
|
||||
}
|
||||
pendingCodeRef.current = null;
|
||||
},
|
||||
|
Reference in New Issue
Block a user