Skip to content

Capture PostHog web vitals again - #330

Merged
ashtonanderson merged 1 commit into
mainfrom
claude/web-vitals-capture
Nov 2, 2026
Merged

ashtonanderson merged 1 commit into
mainfrom
claude/web-vitals-capture

Conversation

@ashtonanderson

@ashtonanderson ashtonanderson commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Turns PostHog web vitals back on, so we can see real-user CLS, LCP, INP and FCP per page. It's one line in src/lib/posthog-browser-config.ts:

capture_performance: { web_vitals: true, network_timing: false },

Why

capture_performance: false went in with the autocapture cleanup on 03-26 (815de5e). In posthog-js 1.257.2 a boolean there overrides the project setting, so vitals stopped even though they're still on in PostHog. Weekly $web_vitals events went from 20,900 (week of 03-09) to 9 (week of 04-20), and there have been 4 in the last 45 days.

Autocapture and pageleave stay off. Network timing stays off too, as it is today.

Cost

  • Events: about 75,000 more a month, based on the 0.82 vitals events per pageview before March and about 91,000 pageviews in the last 30 days. The project sends about 260,000 a month now, and the free tier is 1 million.
  • Page weight: PostHog loads web-vitals.js (about 4 KB compressed) after it starts. It isn't in our bundle.

What the data will look like

  • Separate events: one page's metrics often arrive in separate $web_vitals events, so count each metric on its own.
  • Fewer CLS samples: the SDK waits 5 s before sending, so a metric that reports as the visitor leaves can be lost. From 03-02 to 03-22 there were 19,861 events with FCP, 16,355 with LCP, 15,227 with INP and 9,057 with CLS.
  • A rough "before": p75 across those weeks was CLS 0.78 and LCP 1.47 s, pooled across all pages and devices.

With #328

Draft #328 delays PostHog until the page is idle. It keeps using browserPostHogConfig and doesn't touch this file, so the two shouldn't conflict. Visitors who leave before PostHog loads wouldn't report vitals. The two haven't been tested together.

Testing

  • npx tsc --noEmit, ESLint on the changed file and npx jest (76 tests) all pass, and CI is green.
  • On the preview, in headless Chrome: web-vitals.js loads, the recorder script doesn't, and FCP, LCP, CLS and INP all arrived in PostHog for / and /puzzles. To get CLS I simulated hiding the page.
  • These test events are in the production PostHog project under the preview's host. Their timings aren't meaningful.
  • Not tested on production or on real phones.

🤖 Generated with Claude Code

capture_performance: false, added with the autocapture cleanup in
815de5e, also turned off web vitals: a boolean here overrides the
project setting. Capture vitals only; network timing stays off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
maia-platform-frontend Ready Ready Preview Nov 2, 2026 8:56am UTC

Request Review

@ashtonanderson
ashtonanderson merged commit 3787306 into main Nov 2, 2026
6 checks passed
ashtonanderson added a commit that referenced this pull request Nov 3, 2026
The rebase on #330 and #332 gave round 8's commit a new ID, and the
old one is no longer on any branch. The round 7 build it was measured
against keeps its old ID, marked as from before the rebase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — c6d837f7 Deployed Nov 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant