PostHog
We make your product self-driving
Developer Tools & Product Analytics
The verdict
Build a simplified single-tenant subset containing basic event tracking, funnels, and feature flags, but bypass the petabyte-scale ClickHouse ingestion engine entirely.
Trying to clone PostHog in its entirety is an exercise in infrastructure madness. The core product relies on a distributed columnar store (ClickHouse) to process billions of high-frequency events, alongside complex DOM mutation tracking for session replays and a real-time MCP server. While an AI agent can easily scaffold the Next.js UI, the telemetry ingestion pipeline and efficient querying of unstructured JSON event properties will cause massive debugging bottlenecks for a solo developer.
Estimated effort: 4-6 weeks of intensive development
What you can't replicate
- Petabyte-scale distributed ClickHouse ingestion infrastructure
- Zero-latency session replay DOM mutation compression engine
- The massive ecosystem of 120+ out-of-the-box third-party data pipeline integrations
Founded
2020
Raised
$194M
Team
210
Cheapest paid tier
$0/mo
What PostHog does
An all-in-one product analytics, session replay, feature flags, and data warehouse platform designed for engineering and product teams.
Core features
- Lightweight JS SDK for autocapturing pageviews, clicks, and form submissions
- Event ingestion pipeline processing and indexing high-throughput telemetry
- Product analytics dashboard rendering trends, funnels, and retention curves
- Session replay capturing DOM mutations and user interactions
- Feature flags evaluation engine with real-time payload delivery
- Data warehouse storage layer with SQL execution capabilities
- Model Context Protocol (MCP) server for querying analytics from AI coding agents
The business
Pricing
- Free$0/mo
- Pay-as-you-go$0/mo base
Funding
$194M from Stripe, Peak XV Partners, Google Ventures, Y Combinator, Sofina
The hard parts of vibe coding PostHog
- High-throughput event ingestion architecture handling billions of rows without database bottlenecks
- Client-side DOM mutation recorder for session replay that avoids bloating bundle sizes or breaking page hydration
- Real-time SQL query compilation translating user-defined funnels and retention matrices into fast database scans
- MCP server synchronization securely bridging local AI coding tools to private event databases
How to vibecode PostHog
Prerequisites
Node.jsfree
Required to run the Next.js development server and build toolchain.
GitHubfree
Version control and repository hosting for your codebase.
AI coding tools
Recommended stack
| Frontend | Next.js with Tailwind CSS and Recharts for analytics data visualization |
|---|---|
| Backend | Next.js API Routes / Server Actions with Node.js ingestion endpoints |
| Database | Supabase (PostgreSQL with JSONB columns for event property storage) |
| Auth | Supabase Auth |
| Payments | None (Personal use clone) |
| Other | Zod for payload validation, Model Context Protocol (MCP) SDK for AI editor integration |
Build guide
01Project Scaffolding & Database Schema
Initialize the Next.js project with Tailwind CSS, configure Supabase client bindings, and create relational tables for projects, events, person profiles, and feature flags.
Scrape together a new Next.js project using TypeScript and Tailwind CSS. Connect Supabase as the primary database provider and configure an environment variables template (.env.local) with SUPABASE_URL and SUPABASE_ANON_KEY. Write a migration script or SQL schema to create four tables: `projects` (id, name, created_at), `persons` (id, project_id, distinct_id, properties JSONB, created_at), `events` (id, project_id, distinct_id, event_name, properties JSONB, timestamp), and `feature_flags` (id, project_id, key, rollout_percentage, enabled BOOLEAN). Ensure proper indexes are set up on project_id and event_name in the events table to optimize for filtering queries. Provide clear instructions on running the migration.02Lightweight Client Telemetry SDK
Build a client-side JavaScript tracking snippet and wrapper library that captures pageviews, custom events, and user identification payloads, dispatching them to the backend ingestion route.
Build a lightweight TypeScript client-side tracking script (packaged as a React hook and a vanilla JS snippet) that initializes with a project token. It must automatically track pageviews on route changes, capture click events on elements with data-attr attributes, and support manual event capture via `posthog.capture(event_name, properties)` and user identification via `posthog.identify(distinct_id, user_properties)`. The SDK should batch events locally in memory and flush them via `navigator.sendBeacon` or a batched POST request to `/api/v1/capture` every 5 seconds or when the buffer reaches 20 events. Handle network failures gracefully with exponential backoff.03High-Throughput Ingestion Endpoint
Implement a high-performance API route to receive, validate, and store incoming telemetry batches into the PostgreSQL database.
Create a Next.js API route at `/api/v1/capture` that accepts incoming telemetry batches from the tracking SDK. The endpoint must validate project tokens against the `projects` table, parse the incoming JSON array of events and person profiles, and perform bulk insertions into the `events` and `persons` tables using Supabase. Implement robust error handling for malformed payloads, rate limiting per project token, and ensure timestamps are normalized to UTC. Return a lightweight 200 OK JSON response upon successful ingestion.04Product Analytics & Trends Dashboard
Create the core analytics dashboard UI with interactive charts showing daily active users, event trends, and custom filter breakdowns.
Build a comprehensive Product Analytics dashboard page in Next.js using Recharts and Tailwind CSS. The page should allow users to select a date range, choose an event name from a dropdown of ingested events, and group data by day or week to render a trends line chart. Implement a query builder component that translates user filters (such as event property matching or custom date ranges) into optimized SQL queries executed against the Supabase events table. Include loading states, empty states for new projects, and a responsive sidebar navigation layout matching modern SaaS aesthetics.05Funnels & Retention Analysis Subsystem
Develop multi-step funnel visualization and user retention cohort curves to analyze conversion drop-offs.
Implement a Funnels and Retention analysis module within the dashboard. Create a Funnel builder screen where users can sequence multiple events (e.g., pageview -> signup -> project_created) and calculate conversion rates and drop-off percentages between steps. Write the underlying database query logic to track user progression through the ordered steps within a specified time window. Additionally, build a Retention cohort matrix view that calculates day-1, day-7, and day-30 retention curves based on user startup events and subsequent activity.06Feature Flags Evaluation Engine
Build a real-time feature flag management interface and evaluation API endpoint for client applications.
Develop a Feature Flags management section where users can create, toggle, and configure rollout percentages for feature keys. Implement a public evaluation API route at `/api/v1/decide` that accepts a project token and distinct ID, deterministically evaluates flag status using a consistent hashing algorithm over the distinct ID against the rollout percentage, and returns active feature flags for the client. Build a React hook `useFeatureFlag(key)` in the frontend SDK that fetches and caches flag states on application load.07Model Context Protocol (MCP) Server
Create a local Model Context Protocol (MCP) server enabling AI coding assistants to query product analytics and error metrics directly from code editors.
Build a Node.js-based Model Context Protocol (MCP) server script using the official `@modelcontextprotocol/sdk` package. The server should expose tools allowing AI agents (like Claude Code or Cursor) to query analytics data from your Supabase database: `query_trends` (returns event volume over time), `get_funnel_dropoffs` (returns conversion rates for a step sequence), and `list_recent_errors`. Configure the server with standard stdio transport so developers can easily register it in their local AI editor configuration files (e.g., `claude_desktop_config.json`).
Cost vs paying for PostHog
What will you build it with?
Starting total with Claude Code$0 one-time
Starting costs (one-time)
- Custom Domain (optional)$12/yr
- AI Coding Assistant Subscription$20
Total~$32 one-time
Ongoing costs (monthly)
- Vercel Hobby Hosting$0/mo
- Supabase Free Tier Database$0/mo
Total$0/mo
Paying for PostHog
$0/mo (Generous free tier)
Your time to build
45-60 hours
AI tool credits
$20 (One month of Claude Pro / Cursor Pro)
Break-even
Not applicable (PostHog has a robust free tier)
Sources
Vibecoded copycats
All copies →Loading…