cg / hackerproducts
63 files · 5,740 lines · 159.1 KB — Next.js 15, React 19, TypeScript, PostgreSQL, Object Storage, plain CSS.
Quick jump: page.tsxpage.tsxglobals.cssschema.sqlpackage.json
root / src / components / MinilyticsIdentify.tsx
src/components/MinilyticsIdentify.tsx · 31 lines · 740 B← back to folder
| 1 | "use client"; |
| 2 | |
| 3 | import { useEffect } from "react"; |
| 4 | |
| 5 | export function MinilyticsIdentify({ |
| 6 | user, |
| 7 | }: { |
| 8 | user: { id: string; email: string | null; name: string | null; username: string }; |
| 9 | }) { |
| 10 | useEffect(() => { |
| 11 | const payload = { |
| 12 | user_id: user.id, |
| 13 | email: user.email ?? undefined, |
| 14 | name: user.name || user.username, |
| 15 | }; |
| 16 | |
| 17 | if (typeof window.minilytics === "function") { |
| 18 | window.minilytics("identify", payload); |
| 19 | return; |
| 20 | } |
| 21 | |
| 22 | // Script loads afterInteractive; retry briefly if not yet ready |
| 23 | const timer = setTimeout(() => { |
| 24 | window.minilytics?.("identify", payload); |
| 25 | }, 1500); |
| 26 | return () => clearTimeout(timer); |
| 27 | }, [user.id, user.email, user.name, user.username]); |
| 28 | |
| 29 | return null; |
| 30 | } |
| 31 |