fancytextstuff/lib/posthog.js

22 lines
586 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// lib/posthog.ts
import { PostHog } from "posthog-node";
export function PostHogClient() {
// Server-Keys verwenden (ohne NEXT_PUBLIC_)
const key = 'phc_1j3wKLzEVz6QGnAZ6jg1njZP8XsAPbNDchwLGvjjc0e'//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;
}