MCPcopy Index your code
hub / github.com/simstudioai/sim / getClient

Function getClient

apps/sim/lib/posthog/server.ts:14–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12}
13
14function getClient(): PostHog | null {
15 if (_disabled) return null
16 if (_client) return _client
17
18 const key = process.env.NEXT_PUBLIC_POSTHOG_KEY
19 const enabled = process.env.NEXT_PUBLIC_POSTHOG_ENABLED
20
21 if (!key || !enabled || enabled === 'false' || enabled === '0') {
22 _disabled = true
23 return null
24 }
25
26 // eslint-disable-next-line @typescript-eslint/no-require-imports
27 const { PostHog } = require('posthog-node') as typeof import('posthog-node')
28 _client = new PostHog(key, {
29 host: 'https://us.i.posthog.com',
30 flushAt: 20,
31 flushInterval: 10_000,
32 })
33 return _client
34}
35
36type PersonProperties = Record<string, string | number | boolean>
37

Callers 2

getPostHogClientFunction · 0.70
captureServerEventFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected