Agent skill · data analytics · jeremylongshore

posthog-performance-tuning

Tune PostHog SDK queues, serverless delivery, local flag evaluation, browser defaults, and query scope from measured bottlenecks. Use when PostHog adds latency or loses events under load. Trigger with "PostHog performance", "PostHog batching", or "slow PostHog flags".

Why this skill is useful

Provides specific optimization techniques and code snippets for improving PostHog performance that the AI may not generate on its own.

What it needs

Requires posthog-js, posthog-node installed locally. Requires posthog account access. About 4k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.

What this skill does

PostHog Performance Tuning Overview Optimize PostHog for production workloads. The biggest performance wins are: local feature flag evaluation (eliminates network calls), proper batching configuration, event sampling for high-volume apps, and efficient HogQL queries with date filters. Prerequisites posthog-node and/or posthog-js installed Personal API key (phx...) for local flag evaluation Feature flags configured (if applicable) Instructions Tool discipline Use Read to inspect the relevant configuration and implementation before proposing changes. Use Write only for a new, explicitly requested artifact inside the target project. Use Edit for minimal changes to existing project files after the evidence pass. Step 1: Enable Local Feature Flag Evaluation With server-side local evaluation, the SDK periodically fetches flag definitions and evaluates compatible flags from its local cache. A cold cache, unsupported condition, or evaluation failure can still fall back to a remote request, so measure cache readiness and fallback behavior in the target runtime. Step 2: Optimize Client Batching Step 3: Event Sampling (Browser) Step 4: Efficient HogQL Queries Step 5: Session Recording Performance Performance Benchmarks Operation Without Optimization With Optimization ----------- --------------------- ------------------- Feature flag evaluation Remote request per evaluation Local definition cache with measured fallback behavior Event capture Individual sends Batched (20 events/req) HogQL query (7d) 2-5s <1s (with filters) HogQL query (no filter) 30-60s (timeout risk) N/A (always filter) Error Handling Issue Cause Solution ------- ------- ---------- Events dropped on exit No shutdown hook Add posthog.shutdown() to SIGTERM handler Flag evaluation slow No secure flag key or cold cache Add the feature flags secure API key and inspect cache/polling behavior High event cost Capturing everything Implement beforesend sampling HogQL timeout No date filter Always include timestamp > now( …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills jeremylongshore/posthog-performance-tuning

View the source on GitHub

Browse the @skills marketplace