A tool to simulate user traffic for PostHog applications, useful for testing feature flags, events, and analytics.
- Node.js
- Python 3
- PostHog instance
-
Clone the repository:
git clone https://github.com/andehen/posthog-traffic-simulator.git cd posthog-traffic-simulator
-
Install Node.js dependencies:
npm install
Set the following environment variables:
POSTHOG_API_KEY
: Your PostHog API keyFEATURE_FLAG_KEY
: Feature flag key to test (default: "test-anon-2")API_HOST
: PostHog API host (default: "http://localhost:8010")PORT
: Port for the test server (default: 5001)
-
Start the test server:
python serve.py
-
Run the traffic simulator:
node simluate-traffic.js
Adjust simulation parameters in simluate-traffic.js
:
NUM_BROWSERS
: Number of browser instances to createITERATIONS_PER_BROWSER
: Number of page loads per browserMAX_CONCURRENT_BROWSERS
: Maximum concurrent browser instances
The simulator uses Puppeteer to launch headless Chrome browsers that visit your PostHog-instrumented page. It rotates user agents and manages concurrency to create realistic traffic patterns.