Skip to content

INP metric: CSS selector generation is too shallow and produces highly ambiguous selectors #104128

Closed

Description

@dariusz-biela

Problem Statement

The current CSS selector generator used for INP spans is too limited (function htmlTreeAsString):

  • it only walks ~5 parent levels up the DOM,
  • it stops once the selector exceeds ~80 characters.

In React Native Web, CSS class names are long, so the 80-character limit is often hit immediately. As a result, the generated selectors are extremely generic and can match 100–150 elements on the page, each performing different actions.
This makes it very difficult to understand which UI interaction actually contributed to the INP measurement.

Solution Brainstorm

Here is one potential solution that would allow for the addition of more meaningful information:

  • Increase the parent traversal depth (e.g., 15–30 levels).
  • During traversal, look for a data-sentry-label attribute on ancestors.
  • If found, prepend that label to the final selector, for example:
[data-sentry-label="ProductCard"] div.css-146c3p1.r-1udh08x.r-1udbk01.r-1iln25a > svg

This would allow developers to annotate interactive elements with stable identifiers and significantly improve the precision and usefulness of INP spans.

Product Area

Unknown

Activity

  1. linear commented on Nov 28, 2025

    @linear
  2. getsantry commented on Nov 28, 2025

    @getsantry
    Contributor

    Assigning to @getsentry/support for routing ⏲️

  3. moved this to Waiting for: Support in GitHub Issues with 👀 3on Nov 28, 2025
  4. getsantry commented on Dec 1, 2025

    @getsantry
    Contributor

    Routing to @getsentry/product-owners-insights for triage ⏲️

  5. moved this from Waiting for: Support to Waiting for: Product Owner in GitHub Issues with 👀 3on Dec 1, 2025
  6. dariusz-biela commented on Dec 3, 2025

    @dariusz-biela
    Author

    I've submitted a PR with the proposed solution: getsentry/sentry-javascript#18398

    Solution Brainstorm
    Here is one potential solution that would allow for the addition of more meaningful information:

    • Increase the parent traversal depth (e.g., 15–30 levels).
    • During traversal, look for a data-sentry-label attribute on ancestors.
    • If found, prepend that label to the final selector, for example:
      [data-sentry-label="ProductCard"] div.css-146c3p1.r-1udh08x.r-1udbk01.r-1iln25a > svg
  7. bcoe commented on Dec 4, 2025

    @bcoe
    Member

    Hey @dariusz-biela looks like this is being discussed on the SDK repo 👍 , I think sentry-javascript is the right place for the discussion. If there are issues with @AbhiPrasad's suggestion of using https://docs.sentry.io/platforms/react-native/integrations/component-names/ we can open issues there.

  8. locked and limited conversation to collaborators on Dec 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions