Skip to content

fix(admin): Clean up sample rate display when rates match#110832

Merged
priscilawebdev merged 9 commits intomasterfrom
priscila/fix/sample-rate-display
Mar 17, 2026
Merged

fix(admin): Clean up sample rate display when rates match#110832
priscilawebdev merged 9 commits intomasterfrom
priscila/fix/sample-rate-display

Conversation

@priscilawebdev
Copy link
Member

@priscilawebdev priscilawebdev commented Mar 17, 2026

When effective and desired sample rates match, the admin "Sample Rate (24h)" field
showed a redundant string like 100.00% instead of 100.00% (~0.00%). Now it shows
the rate cleanly (e.g. 100.00%). All rates consistently display two decimal places.

  • Extract formatRate helper and getSampleRateValue for cleaner display logic
  • Compare formatted strings to handle floating-point imprecision (e.g. 0.600001 ≈ 0.6)
  • Add tests for matching rates, mismatched rates, decimal rates, and missing data

Closes https://linear.app/getsentry/issue/TET-2088/add-special-handling-for-100percent-ds-sample-rate-in-admin

When effective and desired sample rates are equal, show just the rate
(e.g. "100%") instead of the redundant "100.00% instead of 100.00%
(~0.00%)". Also drops unnecessary ".00" suffix for whole numbers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 17, 2026
priscilawebdev and others added 2 commits March 17, 2026 08:45
Apply formatRate to all rate values in the comparison string, dropping
unnecessary ".00" suffixes (e.g. "54% instead of 60%" not "54.00%
instead of 60.00%").

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use toFixed(2) with regex strip instead of modulo check, which is
unreliable with floating point (e.g. 0.14 * 100 = 14.000000000000002).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@linear-code
Copy link

linear-code bot commented Mar 17, 2026

Verifies trailing zeros are preserved (e.g. 50.10% not 50.1%).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@priscilawebdev priscilawebdev marked this pull request as ready for review March 17, 2026 08:00
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Replace exact floating-point comparison (diffSampleRate === 0) with
formatted string comparison to handle near-equal rates like 0.600001
vs 0.6 that both display as "60%".

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
priscilawebdev and others added 2 commits March 17, 2026 09:46
Extract the nested ternary into a getSampleRateValue function
with early returns for improved readability.

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
@shellmayr
Copy link
Member

This PR shows something like 1.86% instead of 2% (~0.14%) now, where previously it shows 1.86% instead of 2.00% (~0.14%) - all sample rates should have the same number of decimal places

@priscilawebdev
Copy link
Member Author

When effective and desired sample rates match, the admin "Sample Rate (24h)" field
showed a redundant string like 100.00% instead of 100.00% (~0.00%). Now it just
shows the rate cleanly (e.g. 100%). Also drops .00 suffix for whole numbers everywhere.

Thanks for the feedback! The decimal removal was intentional... when the value is a whole number (e.g. 100% vs 100.00%), I felt dropping the .00 made it cleaner and easier to scan. That said, I understand the preference for consistency, so I'm happy to add the decimals back.

Always display two decimal places for sample rates instead of
stripping trailing zeros from whole numbers. This keeps the
formatting uniform across all values (e.g. 100.00% not 100%).

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
@priscilawebdev priscilawebdev merged commit 114fc26 into master Mar 17, 2026
65 checks passed
@priscilawebdev priscilawebdev deleted the priscila/fix/sample-rate-display branch March 17, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants