For one person tracking their own apps, the core of Mixpanel is a collector, an events table and a few queries: counts, funnels and retention. DuckDB and an agent can produce that over a weekend, with the SQL on screen so you can check it. What you give up is what teams pay for: SDKs for every platform, session replay, experiments and flags, identity handling proven on millions of users, and a report builder non-engineers can use. If you want that breadth for free, PostHog or OpenPanel are already built.
Before you buildMixpanel Free covers 1M events a month with unlimited seats. If your app stays under that, you may not need to pay or build.
Build me a small self-hosted event analytics tool to replace Mixpanel for my own apps. Requirements:
- Node.js 22 + TypeScript: a Fastify server and a React dashboard built with Vite, charts with `uPlot`.
`npm start` serves http://localhost:4400.
- Collector: POST /v1/track takes {event, distinct_id, timestamp?, properties{}} singly or in batches
of up to 100. Write keys per project live in .env as PROJECT_KEYS=name:key,...; reject unknown keys
with 401 and allow CORS only for origins listed in ALLOWED_ORIGINS.
- Storage: DuckDB through `@duckdb/node-api` in ./data/events.duckdb. An events table (project, event,
distinct_id, ts, properties JSON, insert_id) drops repeats by insert_id; POST /v1/identify writes an
anonymous-id to user-id table that all reports use to join a visitor's history.
- Browser snippet: serve /t.js (under 3 KB) exposing mp.track(event, props) and mp.identify(userId),
with a random anonymous id in localStorage, no cookies, and a flush with sendBeacon on page hide.
- Reports, each with a date range and up to two property filters: Events (count or unique users per
day, split by one property), Funnel (2-6 steps, a conversion window in hours, drop-off per step),
Retention (days 0-30, with a first-event and a return-event picker) and Users (the last 100 events
of one distinct_id). Save reports by name.
- Write the funnel and retention SQL by hand, show it on each report, and test it against a fixture of
50,000 generated events with known answers.
- A nightly job deletes events older than RETENTION_DAYS (default 365).
- Single user: the dashboard sits behind one password from .env (signed cookie). No accounts, no
telemetry, local-first.
- Out of scope: session replay, heatmaps, experiments, feature flags, alerts, mobile SDKs.
- README: adding the snippet, exposing the collector through a tunnel, the events per second you
measured with `autocannon`, and a note that one machine is not Mixpanel's pipeline.Opens your agent with the prompt filled in, you press enter. Or copy it and paste it into an empty folder.
The first prompt builds the core. Run these one at a time in the same folder to grow it into your own Mixpanel.
Add a data catalogue to the analytics tool in this folder. Requirements: - A Catalogue page listing every event name seen, its first and last time, its count over 30 days and the property keys with their inferred types. - Let me mark an event as hidden or add a description, stored in DuckDB. - Add a merge action that rewrites one event name to another in old data after a confirmation that shows the number of rows touched. - Report builders only offer non-hidden events. - Update the README.
Add a weekly digest to the analytics tool in this folder. Requirements: - Pick up to five saved reports; every Monday at 08:00 in TZ from .env render each as a small HTML table with the change versus the previous week. - Send through nodemailer using SMTP settings from .env; add a "send test now" button. - Log each send, and skip silently if the report returns no rows. - Update the README.
Add an importer to the analytics tool in this folder. Requirements: - Read JSONL files produced by Mixpanel's raw event export from ./import/, one event per line with an event name and a properties object holding distinct_id, time and $insert_id. - Map time (Unix seconds) to ts, keep every other property, and use $insert_id to skip repeats. - Insert in batches of 10,000 and print a progress count; a rerun must not duplicate rows. - Report the lines it could not parse. - Update the README.
Teams buy Mixpanel so product managers and marketers can ask funnel and retention questions without writing SQL, on events that engineers instrument once and then trust. For small apps the free million events is enough, so money goes to volume beyond that and to replay, experiments and group analytics in the same tool.
Estimate · Free on your own machine; a $5 VPS covers a small collector. Mixpanel's calculator shows $140 a month at 1.5M events, so volume is where a build can save money. The build is token usage on your agent plan.
| Plan | Monthly | Annual, per month | What you get |
|---|---|---|---|
| Free | $0 | $0 | Up to 1M events a month, unlimited seats, 5 saved reports per seat, 10 active feature flags, 1K monthly experiment users. |
| Growth | $140 | $120 | The first 1M events each month are free, then usage-based up to 20M a month; unlimited saved reports, up to 50 feature flags, up to 5 alerts, custom and borrowed properties. |
| Enterprise | custom | — | Up to 1T events a month, custom replay and experiment volumes, unlimited alerts with anomaly detection, a custom retention policy, a dedicated success team and priority support. |
Free covers up to 1M events a month with unlimited seats; past the cap, reports stay locked until the month resets, and nothing is billed.
Kinda. The core is a weekend build with the prompt on this page, but real gaps remain: Session replay, heatmaps, experiments and feature flags, which Mixpanel now bundles, SDKs for mobile and server languages, autocapture and a data dictionary to keep event names tidy.
About $140 a month on the Growth, 1.5M events a month plan, $1,680 a year (checked 2026-10-14).
Session replay, heatmaps, experiments and feature flags, which Mixpanel now bundles; SDKs for mobile and server languages, autocapture and a data dictionary to keep event names tidy; Warehouse connectors and cohort syncs to other tools; Roles, permissions and an audit trail for a team; Volume headroom: one machine is not a pipeline built for billions of events. If any of those matter to you, keep paying.
Yes: PostHog (open source), OpenPanel (open source), Umami (open source).