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,940 stars 439 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
1 years ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category