Analytics
PostHog
Enable PostHog analytics with project token and host configuration.
To use PostHog with TurboJet, create a PostHog account and copy your project API key (project token).
Environment
Add the keys to the root .env (and your deployment environment). See Environment.
NEXT_PUBLIC_ENABLE_POSTHOG=true
NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN=your_key_here
NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com| Key | Notes |
|---|---|
NEXT_PUBLIC_ENABLE_POSTHOG | Feature flag; set to false to disable. Defaults on unless "false". |
NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN | Required for init; empty token disables PostHog |
NEXT_PUBLIC_POSTHOG_HOST | Defaults to https://us.i.posthog.com |
EU projects: set the host to https://eu.i.posthog.com.
Activation needs both the feature flag enabled and a non-empty token (packages/shared/src/features.ts → posthog, plus the check in @repo/analytics).
Package
posthog-js is already a dependency of @repo/analytics. You do not need to install it in each app.
Marketing and docs call initPostHogClient() from instrumentation-client.ts. Customize init options in:
posthog.init(token, {
api_host: getHost(),
defaults: "2026-01-30",
capture_pageview: true,
capture_pageleave: true,
person_profiles: "identified_only",
});Custom events
After setup, track events with captureEvent — see Analytics.