mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-20 19:30:41 -05:00
21 lines
479 B
TypeScript
21 lines
479 B
TypeScript
import { PostHog } from "posthog-node";
|
|
|
|
let posthogClient: PostHog | null = null;
|
|
|
|
export function getPostHogClient(): PostHog {
|
|
if (!posthogClient) {
|
|
posthogClient = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
|
|
host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
|
|
flushAt: 1,
|
|
flushInterval: 0,
|
|
});
|
|
}
|
|
return posthogClient;
|
|
}
|
|
|
|
export async function shutdownPostHog(): Promise<void> {
|
|
if (posthogClient) {
|
|
await posthogClient.shutdown();
|
|
}
|
|
}
|