mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-30 11:26:24 +02:00
feat: added posthog
This commit is contained in:
parent
d9e6947fbd
commit
518958e9a7
15 changed files with 526 additions and 17 deletions
17
surfsense_web/lib/posthog/server.ts
Normal file
17
surfsense_web/lib/posthog/server.ts
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue