api-analytics-setup-posthog
PostHog Analytics & Feature Flags Setup
Quick Guide: One-time setup for PostHog analytics and feature flags. Covers
posthog-jsclient provider,posthog-nodeserver client, and environment variables. PostHog handles both analytics AND feature flags with a generous free tier (1M events + 1M flag requests/month).
<critical_requirements>
CRITICAL: Before Using This Skill
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST initialize posthog-js only in a client/browser context - it requires browser APIs like window and localStorage)
(You MUST call posthog.shutdown(), posthog.flush(), or use captureImmediate() after server-side event capture to prevent lost events)
(You MUST use defaults: '2026-01-30' for automatic SPA page tracking and latest recommended behaviors)
</critical_requirements>