---
name: "posthog-feature-flags-analytics"
description: "Instrument product analytics events, feature flags, A/B experiments, and session recordings."
metadata:
  author: "PostHog"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "evaluate feature flag posthog"
  - "track event posthog"
  - "mask sensitive data session replay"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# PostHog Product Analytics, Feature Flags & Session Replay

Integrates PostHog: posthog-js in frontend, posthog-node in backend, evaluating feature flags (isFeatureEnabled), user identification (identify), capturing custom business events, and masking sensitive session replay inputs.

## When to Invoke
Invoke this skill whenever you need to:
- evaluate feature flag posthog
- track event posthog
- mask sensitive data session replay

## Execution SOP & Rules
1. Initialize: posthog.init(apiKey, { api_host: 'https://app.posthog.com', person_profiles: 'identified_only' }).
2. Identify user upon login: posthog.identify(user.id, { email: user.email, plan: user.plan }).
3. Check feature flag: if (posthog.isFeatureEnabled('new-dashboard')) { ... }.
4. Track custom events: posthog.capture('project_created', { category: 'ai' }).

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
