Skip to content

[No QA] Fix Sentry not using data-sentry-label - #104340

Merged
mountiny merged 3 commits into
Expensify:mainfrom
software-mansion-labs:@GCyganek/fix-sentry-label-browser-utils
Oct 20, 2026
Merged

mountiny merged 3 commits into
Expensify:mainfrom
software-mansion-labs:@GCyganek/fix-sentry-label-browser-utils

Conversation

@GCyganek

@GCyganek GCyganek commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Related to #100711

Since the @sentry/core 10.73 bump (9.4.76), web INP/CLS/LCP spans and click breadcrumbs use @sentry/browser-utils' own htmlTreeAsString, so our data-sentry-label patch on @sentry/core became dead code and labels vanished from Sentry. This moves the patch to @sentry/browser-utils and drops the unused core hunk.

See labeled clicks trace where it drops to 0

Fixed Issues

$ #100694
PROPOSAL: N/A

Tests

Test 1: Labeled pressables are identified by their label

  1. Run npm i so the new patch is applied, then start the web app with npm run web and log in
  2. Press Ctrl + D (or go to Settings > Troubleshoot) to open the test tools, enable "Log Sentry requests to console" and set "Highlighted span names" to ui.interaction.click
  3. Click a chat row in the Inbox, then click the "Account" tab in the navigation bar
  4. Verify that the console shows a [SPAN][ui.interaction.click] entry whose description is a label selector such as [data-sentry-label="LHN-OptionRow"] or [data-sentry-label="NavigationTabBar-Account"], not a bare div.css-… selector

Test 2: Elements without a label keep the default selector

  1. With the same setup as Test 1, click an element that has no data-sentry-label on it or its ancestors (for example, empty space in a report's chat area)
  2. Verify that the logged ui.interaction.click span description is the plain CSS selector (for example div.css-175oi2r > …) and that no errors appear in the console
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

[No QA] — telemetry-only change with no user-facing behavior. After deploy, an engineer can verify it in Sentry:

  1. Open Explore > Traces for the app project
  2. Query span.op:ui.interaction.click span.description:*data-sentry-label* and filter by the release containing this PR
  3. Verify that labeled click spans appear again
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-10-19.at.12.03.46.mov

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@GCyganek
GCyganek marked this pull request as ready for review October 19, 2026 10:12
@GCyganek
GCyganek requested a review from a team as a code owner October 19, 2026 10:12
@melvin-bot
melvin-bot Bot requested review from bernhardoj and removed request for a team October 19, 2026 10:12
@melvin-bot

melvin-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

@bernhardoj Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T10:26:57.821154Z 62bece9 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@GCyganek

Copy link
Copy Markdown
Contributor Author

cc: @mountiny @rlinoz

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 62bece9edd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@dariusz-biela dariusz-biela left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM I'm just leaving a few non-blocking comments that are worth addressing.

Comment thread patches/sentry-browser-utils/details.md Outdated
`@sentry/browser-utils` ships its own copy of `htmlTreeAsString`, which INP, CLS and LCP spans, click breadcrumbs and Session Replay use. This logic used to be patched into the `@sentry/core` copy, which the browser SDK stopped calling after the upgrade to `@sentry/core` 10.73 (https://github.com/Expensify/App/commit/9689acf98e3), so labels disappeared from web spans from release 9.4.76 on.
- Upstream PR/issue: https://github.com/getsentry/sentry-javascript/pull/18398
- E/App issue: https://github.com/Expensify/App/issues/76128
- PR Introducing Patch: https://github.com/Expensify/App/pull/76547

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#76547 never touched browser-utils. This PR is the one that adds this patch.

Suggested change
- PR Introducing Patch: https://github.com/Expensify/App/pull/76547
- PR Introducing Patch: https://github.com/Expensify/App/pull/104340

@bernhardoj

Copy link
Copy Markdown
Contributor

@mountiny Does this need a C+ review?

@mountiny

Copy link
Copy Markdown
Contributor

I dont think it does

@mountiny

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix

@mountiny
mountiny removed the request for review from bernhardoj October 20, 2026 14:14
@mountiny
mountiny merged commit f277461 into Expensify:main Oct 20, 2026
43 of 44 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.5.15-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.5.15-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@GCyganek

Copy link
Copy Markdown
Contributor Author

@MelvinBot please create an issue based on this plan:

Improve data-sentry-label granularity and add inp.category grouping for Sentry INP

  1. Add inp.category to Sentry INP spans. Add a beforeSendSpan middleware in src/libs/telemetry/middlewares/ and wire it into Sentry.init(). For spans whose op starts with ui.interaction.:

    • Read the label from the description with /\[data-sentry-label="([^"]+)"\]/. Don't split the raw description, because it's a CSS selector.
    • If the label follows <Area>-<Action>-<Detail>, set span.data['inp.category'] to <Area>-<Action>. Use span.data, not span.attributes.
    • Cover the logic with unit tests.
  2. Add a table widget to the Sentry INP dashboard. Filter by has:inp.category and group by inp.category to show aggregated INP per group.

  3. Update existing labels from the FullStory list. For example, split Search-ActionCellAction into Search-ActionCellAction-Submit, -Approve, -Pay and so on. Existing 3-part labels such as SelectionList-ListHeader-SelectAll will become categories automatically; rename them or accept that. List the renamed labels in the PR, since they lose their history.

  4. Add the missing labels from the FullStory list.

  5. Document data-sentry-label in contributingGuides/INP_IMPROVEMENT_WORKFLOW.md, or a doc linked from it. Cover the naming schema, how inp.category is derived, and the rule that labels contain no IDs or user data.

  6. Cover Button, MenuItem and other components that wrap pressables and pass sentryLabel to them. Add the missing labels, and extend the existing no-restricted-syntax rule in config/eslint/eslint.config.mjs so it also requires sentryLabel on these components. It currently only checks direct Pressable* usages.

@MelvinBot

Copy link
Copy Markdown
Contributor

I created Improve data-sentry-label granularity and add inp.category grouping for Sentry INP with all 6 steps of your plan.

It links back to this PR and to the umbrella issue, [Sentry] Extending Sentry Analysis to Systematically Reduce High INP Events. I found no existing issue that covers this work. I didn't add labels or assignees.


view run

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.

6 participants