typescript-analytics
Skill17 starsChanged 21 days agoMITView on GitHub
Use when implementing analytics with PostHog in a TypeScript app — capturing events, identifying users, adding feature flags, tracking errors, or wiring API lifecycle telemetry. Triggers on edits to analytics integration files, or mentions of "PostHog", "analytics", "feature flag", "event tracking", "capture", "identify", "A/B test", or "experiment".
In this repository38 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- adversarial-claims-reviewerSkill
- autoresearchSkill
- browser-testing-with-devtoolsSkill
- codebase-cost-estimatorSkill
- code-review-and-qualitySkill
- content-opsSkill
- content-pipelineSkill
- conversion-opsSkill
- data-model-documentationSkill
- data-model-verificationSkill
- deployment-pipelinesSkill
- findings-ledgerSkill
- game-balancerSkill
- game-systems-designerSkill
- godot-engineerSkill
- growth-engineSkill
- iap-managerSkill
- library-investigatorSkill
- marketing-shaperSkill
- memory-extractionSkill
- outbound-engineSkill
- phaser-engineerSkill
- planning-and-task-breakdownSkill
- prompt-shaperSkill
- release-managerSkill
- revenue-intelligenceSkill
- rust-engineerSkill
- security-engineeringSkill
- securitySkill
- seo-opsSkill
- session-stateSkill
- skill-library-reviewSkill
- telemetrySkill
- typescript-data-engineeringSkill
- typescript-testing-backendSkill
- typescript-testing-frontendSkill
- web3-smart-contract-engineeringSkill
The file
Files
Analytics Engineering (PostHog + TypeScript)
You are operating as an analytics engineer. Your job is to ship telemetry that product can actually trust — explicit events, consistent naming, and full lifecycle coverage — never autocapture noise.
PostHog client/server SDKs integrated into a Next.js app via a unified getPostHog() getter, with proxied ingest to bypass ad blockers, typed event enums, and serverless-safe flush semantics. Covers explicit event capture, feature flags, error tracking, user identification, and source-map uploads.
Universal Rules
- Never use autocapture — all events must be explicit and registered in the project's event enum.
- Track the full lifecycle —
cta_clicked→in_progress→success/error. - Use the unified pattern — use the project's analytics wrapper functions for both client and server, not raw SDK imports.
- Flush immediately on server —
flushAt: 1,flushInterval: 0, alwaysshutdown()infinally. - Default flags to disabled —
falseon error or when flags haven't loaded (fail-closed). - Identify by user ID — never by email; set email as a person property.
- Proxy through
/ph— never call PostHog directly from the client. - Add new events to the project's event enum — never use raw strings for event names.
- Include domain context — slug, name, status, and relevant IDs in every event.
- Mask sensitive data — wallet addresses should be masked in properties.
References
- references/setup-and-architecture.md — dependencies, proxy, init, env vars, file layout, unified client/server pattern, automatic metadata injection
- references/event-tracking.md —
EVENTSenum, naming convention,capturePostHogEvent,captureApiEvent, manual capture example - references/typed-analytics.md —
ANALYTICS_EVENTS, typed property maps,Analyticsclass,useAnalyticshook, pageview tracking - references/user-identification.md —
PosthogTrackIdentity, identify by user ID, group membership - references/feature-flags.md —
FEATURE_FLAGSenum, client-sideuseFeatureFlag, server-sidecheckFeatureFlag/getFeatureFlag - references/error-tracking.md —
capturePosthogError,useComponentError,ERROR_TYPES, automatic API error tracking - references/properties-and-source-maps.md — auto-injected metadata, commonly tracked properties, PostHog source map upload workflow
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

