feat: added posthog

This commit is contained in:
DESKTOP-RTLN3BA\$punk 2025-12-25 13:53:41 -08:00
parent d9e6947fbd
commit 518958e9a7
15 changed files with 526 additions and 17 deletions

View file

@ -0,0 +1,17 @@
import { PostHog } from "posthog-node";
export default function PostHogClient() {
if (!process.env.NEXT_PUBLIC_POSTHOG_KEY) {
throw new Error("NEXT_PUBLIC_POSTHOG_KEY is not set");
}
const posthogClient = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
// Because server-side functions in Next.js can be short-lived,
// we set flushAt to 1 and flushInterval to 0 to ensure events are sent immediately
flushAt: 1,
flushInterval: 0,
});
return posthogClient;
}