Posthog integration
This commit is contained in:
21
lib/posthog.js
Normal file
21
lib/posthog.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// lib/posthog.ts
|
||||
import { PostHog } from "posthog-node";
|
||||
|
||||
export function PostHogClient() {
|
||||
// Server-Keys verwenden (ohne NEXT_PUBLIC_)
|
||||
const key = process.env.POSTHOG_API_KEY;
|
||||
const host = process.env.POSTHOG_HOST ?? "https://us.i.posthog.com";
|
||||
|
||||
if (!key) {
|
||||
// Fail fast – sonst sendest du stumm nichts
|
||||
throw new Error("POSTHOG_API_KEY ist nicht gesetzt (serverseitige Env).");
|
||||
}
|
||||
|
||||
const client = new PostHog(key, {
|
||||
host,
|
||||
flushAt: 1,
|
||||
flushInterval: 0,
|
||||
});
|
||||
|
||||
return client;
|
||||
}
|
||||
Reference in New Issue
Block a user