Skip to content

fix(analytics): capture Web Vitals with PostHog - #146

Draft
posthog-eu[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixanalytics-enable-web-vitals-capture-47df72
Draft

posthog-eu[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixanalytics-enable-web-vitals-capture-47df72

Conversation

@posthog-eu

@posthog-eu posthog-eu Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • The team has no real-user page performance data. PostHog Web Analytics shows pageviews but no Web Vitals (LCP, INP, CLS, FCP).
  • The posthog.init call in src/lib/analytics.ts does not set capture_performance. Thus the SDK does not send $web_vitals events.
  • The PostHog Web Analytics health check reports this gap as an active issue.

Origin

  • Scout: signals-scout-general
  • First signal: 2026-10-11
  • Inbox report: open
  • Task started by: auto-start, after the report was rated P3 and ready to fix

Changes

  • Turn on the posthog-js Web Vitals capture in the existing init call:
     capture_exceptions: true,
+    capture_performance: { web_vitals: true },
  • The existing analytics consent gate does not change. PostHog starts only after the user accepts analytics, and demo builds still send nothing.
  • The SDK loads its Web Vitals script lazily from /ingest/static/…. The existing proxy already sends static/* requests to the PostHog assets host, so no proxy change is necessary.
  • The invitation-URL before_send filter also applies to $web_vitals events.

Note

The consent banner and the privacy page say "pageviews, feature usage, and browser errors" ("for example" on the privacy page). Web Vitals are page-load timings in the same consented analytics scope. This PR does not change that text. Please decide if the text must name performance measurement.

Verification

  • bun run format:check, bun run lint, and bun run typecheck pass.
  • bun run test:unit: 20 tests in 5 files fail. The same 20 tests also fail on main without this change. They are PDF and export tests that need the ICC and font assets (bun run setup:icc), which the sandbox does not have.
  • I did not run the integration tests, the e2e tests, or the build, because they need Docker services.
  • After deploy: make sure that $web_vitals events arrive in PostHog and that the Web Analytics health check resolves.

Agent context

  • No team notes or open PRs touch the analytics initializer. No code comment or doc in the repository records a decision to keep Web Vitals off. A full git log -S search was not possible in the partial clone.

Created with PostHog Desktop from this inbox report.

🤖 Generated with Claude Code

The PostHog init call did not set capture_performance, so the app sent pageviews but no $web_vitals events. Web Vitals capture stays behind the existing analytics consent gate.

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

Generated-By: PostHog Desktop
Task-Id: bfcfecf2-24f9-45fd-a574-ca677b4cf975
@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: abd098ef-d1b4-4b46-9ea9-066de80b11fd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

0 participants