feat(js-sdk): Enable $web_vitals reporting when cookieless mode is enabled#3607
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
93de888 to
eab8a7d
Compare
Contributor
Contributor
|
Size Change: -420 B (0%) Total Size: 16 MB
ℹ️ View Unchanged
|
eab8a7d to
ea4f831
Compare
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
packages/browser/src/extensions/web-vitals/index.ts:33-84
**`_perfConfig` removal violates OnceAndOnlyOnce**
The private `_perfConfig` getter was a clean DRY accessor for `this._instance.config.capture_performance`. Its removal causes that expression to be repeated **8 times** across `allowedMetrics`, `flushToCaptureTimeoutMs`, `useAttribution`, `_maxAllowedValue`, and `isEnabled`. The original getter wasn't a superfluous part — it expressed the concept exactly once per the team's simplicity rule #3. Restoring it would keep the accessor as a single source of truth while still allowing Terser to mangle the name.
Reviews (1): Last reviewed commit: "fix: remove non-existent extendArray imp..." | Re-trigger Greptile |
extendArray was removed from the codebase in #3253 (bundle size reduction. Revert to the spread syntax that replaced it. Add a changeset for posthog-js and @posthog/types. EOF )
ea4f831 to
bfb6339
Compare
lricoy
approved these changes
May 19, 2026
robbie-c
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Right now reporting of
$web_vitalsis disabled whencookieless_modeis enabled, because cookieless mode disables the session ID manager, which gates vitals logic.I think this is a safe change because the ingestion (backend) processing because:
$session_idis generated for cookieless-enabled eventsI think this is safe on the product (access path side) because:
$session_idis available on cookieless web vitals eventsAd-hoc HogQL queries could attempt to access a nested session ID (available on cookieless-disabled events only) and this could break in the product. I'm not sure whether this is a blocker on shipping the change
Verification
After getting this PR through CI, I build the local distribution and replaced the
posthog/frontend/copy of the SDK indistwith myposthog-jsfeature branchdist. Next, I updated the local PostHog app config for the test team (cookieless mode enabled, web vitals enabled.)Finally, I ran a Python script to generate and publish cookieless web vitals events along with some control events to the test account, then verified in ClickHouse that the results were well formed and the ingestion pipeline did not reject them.
Changes
$web_vitalsevents even when cookieless mode is enabled (session ID manager not present)Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file