()
| 12 | } |
| 13 | |
| 14 | function 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 | |
| 36 | type PersonProperties = Record<string, string | number | boolean> |
| 37 |
no outgoing calls
no test coverage detected