A set of lightweight, zero-dependency Node.js tools to download, decompress, parse, and analyze raw PostHog session recording snapshot replays (which are recorded using rrweb layout) into structured, readable user interaction timelines.
It includes a beautiful, local, developer diagnostics dashboard interface to query recent sessions and perform AI-driven UX analysis in one click.
- Automatic GZIP Decompression: PostHog stores binary snapshots in GZIP blocks (
0x1f 0x8b). This tool handles binary buffer extraction and decompressing using Node's nativezlibmodule. - Batch Retrieval (Bypasses API Limits): PostHog's Snapshot API restricts requests to at most 20 snapshot blobs in a single fetch. The downloader automatically chunks your recording fetch queries into batches and merges them.
- High-Fidelity Parser: Reconstructs the
rrwebDOM actions. Extracts clean timelines tracking page views, clicks, text input values (omitting hidden characters/inputs), key API queries called, and React/console errors. - Diagnostics Dashboard: A local-running developer portal served via a zero-dependency HTTP server (port 3099) styled with dark-mode glassmorphic aesthetics.
- AI Report Synthesis: If configured, the dashboard automatically pipes the parsed sequential log into OpenAI's
gpt-4o-minito write a structured, senior-level UX onboarding analysis report in real-time.
-
download-posthog-session.mjs
A CLI tool that connects to the PostHog API, queries the metadata and snapshot list, downloads the snapshot blobs in chunks, decompresses GZIP segments, and saves a unified, uncompressed JSON file. -
parse-posthog-session.mjs
Reads the uncompressed session JSON, iterates overrrwebsnapshot events, filters out static noise (like Facebook and Google trackers), and compiles a clean, sequential Markdown timeline. -
session-analyzer-dashboard.mjs
A standalone Node server that exposes a diagnostics web portal. It retrieves the latest 200 recordings over the last 10 days, lets you search by email or location, and handles downloading, parsing, and OpenAI synthesis in a single click.
No external npm dependencies are required. All scripts run on native Node.js (v18.17+) using built-in modules (http, zlib, fs, child_process).
-
Clone the repository:
git clone https://github.com/amirfish1/Posthog-session-analyzer.git cd Posthog-session-analyzer -
Add Environment Variables: Create a
.env.localfile at the root of the project:# PostHog personal API key (found under Account Settings > Personal API Keys) POSTHOG_PERSONAL_API_KEY=phx_your_posthog_personal_key # Optional: OpenAI API Key for generating high-level AI onboarding reports OPENAI_API_KEY=sk-proj-your_openai_api_key
To launch the interactive dashboard:
node session-analyzer-dashboard.mjsOpen http://localhost:3099 in your browser. You can search, filter, and click "Analyze" on any session to download and render its rich Markdown report.
To download and parse a specific session directly from your terminal:
node download-posthog-session.mjs <session_recording_uuid> [output_directory]- Example:
This will fetch, decompress, and write:
node download-posthog-session.mjs 019f1f46-f22b-78b4-a9f5-3a505182331c ./reports
posthog-session-019f1f46-f22b-78b4-a9f5-3a505182331c.json(uncompressed raw snapshots)posthog-session-019f1f46-f22b-78b4-a9f5-3a505182331c.timeline.md(parsed raw log)
