feat: emit element-selector attribution on web-vitals metrics#515
Merged
feat: emit element-selector attribution on web-vitals metrics#515
Conversation
Switches the web-vitals listener to the `web-vitals/attribution` build and emits per-vital attribution attributes (LCP element, CLS largest- shift target, INP/FID interaction target, etc.) on the gauge metrics so slow vitals can be attributed to a specific DOM element on the page. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 64a49d8. Configure here.
ntiner1
approved these changes
Apr 30, 2026
- Wrap LCP `web_vital.attribution.url` with sanitizeUrl() to match observe.ts and avoid leaking signed-URL credentials/tokens in metric tag values. - Tighten addTag guard from `v !== undefined` to truthiness so empty strings (commonly returned by web-vitals when the attributed DOM element has been removed) don't pollute metrics with empty `web_vital.element` tags. Addresses Cursor bugbot comments on PR #515. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Merged
Vadman97
pushed a commit
that referenced
this pull request
May 1, 2026
🤖 I have created a release *beep* *boop* --- <details><summary>observability: 1.1.7</summary> ## [1.1.7](observability-1.1.6...observability-1.1.7) (2026-05-01) ### Dependencies * The following workspace dependencies were updated * dependencies * highlight.run bumped to 10.2.0 </details> <details><summary>session-replay: 1.1.7</summary> ## [1.1.7](session-replay-1.1.6...session-replay-1.1.7) (2026-05-01) ### Dependencies * The following workspace dependencies were updated * dependencies * highlight.run bumped to 10.2.0 </details> <details><summary>highlight.run: 10.2.0</summary> ## [10.2.0](highlight.run-10.1.2...highlight.run-10.2.0) (2026-05-01) ### Features * emit element-selector attribution on web-vitals metrics ([#515](#515)) ([d8288b1](d8288b1)) * include LD context keys in metric event attributes ([#514](#514)) ([edefe2c](edefe2c)) ### Bug Fixes * emit url.query_params as nested otel attributes ([#517](#517)) ([69629e1](69629e1)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk release-only changes: version bumps and changelog updates with no code logic modifications in this PR. Runtime behavior changes come only from the upgraded `highlight.run` dependency. > > **Overview** > Bumps released package versions for `@launchdarkly/observability` and `@launchdarkly/session-replay` to `1.1.7`, and updates the workspace `highlight.run` package to `10.2.0` (with corresponding changelog entries). > > Updates `.release-please-manifest.json` to reflect the new versions and documents `highlight.run` 10.2.0 feature/bugfix notes (web-vitals element selector attribution, additional LD context keys on metric attributes, and nested `url.query_params` OTEL attributes). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit cdd7820. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
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.

Summary
Switches the SDK's web-vitals listener from the plain
web-vitalsbuild toweb-vitals/attributionso we can attribute each LCP / CLS / INP / FID to a specific DOM element. The selector and a couple of high-signal context fields are emitted as OTel attributes on the gauge metric, closing a feature parity gap with Datadog RUM's_target_selector.Attribute keys (kept tight to limit cardinality):
web_vital.element,web_vital.attribution.url(sanitized)web_vital.element(largest-shift target),web_vital.load_stateweb_vital.element(event target),web_vital.event_type,web_vital.load_stateweb_vital.element,web_vital.event_typeweb_vital.load_stateBoth consumers (
sdk/observe.tsandclient/index.tsx) get the new attributes; their existing differing shapes (semconv keys vs. plain group/category) are preserved.Bundle-size delta (brotli, the enforced metric): 166.07 kB → 166.99 kB (+0.92 kB), well under the 256 kB cap. Gzipped
index.umd.jsgrows by ~1.4 kB.Test plan
yarn turbo run build --filter highlight.runyarn turbo run test --filter highlight.run(406/406 pass)yarn enforce-size(166.99 kB / 256 kB)yarn format-checkweb_vital.element/web_vital.event_typeetc.🤖 Generated with Claude Code
Note
Medium Risk
Changes how web-vitals metrics are sourced and adds new per-metric attribution fields, which can affect telemetry shape/cardinality and downstream dashboards. Low security risk but does emit additional (sanitized) URL and DOM-selector data.
Overview
Web-vitals collection now uses
web-vitals/attributionand exposes a typedWebVitalMetricunion so consumers can safely access per-metric attribution fields.Both metric emitters (
client/index.tsxandsdk/observe.ts) now attach additional web-vitals attributes (e.g.web_vital.element,web_vital.event_type,web_vital.load_state, and a sanitizedweb_vital.attribution.url) when recording gauges, while keeping each emitter’s existing metric attribute/tag shape intact.Reviewed by Cursor Bugbot for commit 54e116b. Bugbot is set up for automated code reviews on this repo. Configure here.