posthog-performance-tuning

Featured

Optimize PostHog performance: local flag evaluation, client batching config, event sampling, efficient HogQL queries, and serverless flush patterns. Trigger: "posthog performance", "optimize posthog", "posthog latency", "posthog caching", "posthog slow", "posthog batch", "posthog fast".

AI & Automation 2,266 stars 315 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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 ### Step 1: Enable Local Feature Flag Evaluation The single biggest performance improvement. Without local evaluation, every `getFeatureFlag()` call makes a network request (~50-200ms). With local evaluation, flag definitions are cached and evaluation is instant (~0.1ms). ```typescript import { PostHog } from 'posthog-node'; const posthog = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, { host: 'https://us.i.posthog.com', // This is the key: personal API key enables local flag evaluation personalApiKey: process.env.POSTHOG_PERSONAL_API_KEY, // Flag definitions are polled every 30 seconds by default // Adjust if you need faster flag updates: // featureFlagsPollingInterval: 10000, // 10 seconds }); // With personalApiKey set, this evaluates locally (no network call) const variant = await posthog.getFeatureFlag('pricing-experiment', 'user-123', { personProperties: { plan: 'pro', country: 'US' }, }); // Get all flags at once (still local, still fast) const allFlags = await posthog.getAllFla...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
7 months ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Featured

posthog-observability

Monitor PostHog integration health: event ingestion rates, feature flag evaluation latency, billing volume tracking, and Prometheus/Grafana alerting. Trigger: "posthog monitoring", "posthog metrics", "posthog observability", "monitor posthog", "posthog alerts", "posthog dashboard".

2,266 Updated today
jeremylongshore
AI & Automation Featured

posthog-core-workflow-b

Implement PostHog feature flags, A/B experiments, and cohort management. Use when rolling out features with flags, running A/B tests, creating cohorts, or evaluating multivariate experiments with PostHog. Trigger: "posthog feature flag", "posthog experiment", "posthog A/B test", "posthog cohort", "feature rollout posthog", "posthog multivariate".

2,266 Updated today
jeremylongshore
AI & Automation Featured

posthog-hello-world

Create a minimal working PostHog example with event capture, identify, and feature flags. Use when starting a new PostHog integration, testing your setup, or learning basic posthog-js and posthog-node patterns. Trigger: "posthog hello world", "posthog example", "posthog quick start", "simple posthog code", "first posthog event".

2,266 Updated today
jeremylongshore
AI & Automation Featured

posthog-local-dev-loop

Configure PostHog local development with mocking, debug mode, and testing. Use when setting up a development environment, mocking PostHog for tests, or establishing a fast iteration cycle with posthog-js or posthog-node. Trigger: "posthog dev setup", "posthog local development", "posthog dev environment", "mock posthog", "test posthog".

2,266 Updated today
jeremylongshore
AI & Automation Featured

posthog-reference-architecture

Production PostHog architecture: event taxonomy, SDK layering, feature flag strategy, analytics module layout, and data pipeline integration patterns. Trigger: "posthog architecture", "posthog best practices", "posthog project structure", "how to organize posthog", "posthog design".

2,266 Updated today
jeremylongshore