Skip to content

fix: move long numbers to the next unit when they round up - #4658

Merged
mikecao merged 1 commit into
umami-software:devfrom
Enesuygurs:fix/format-long-number-rounding
Oct 22, 2026
Merged

mikecao merged 1 commit into
umami-software:devfrom
Enesuygurs:fix/format-long-number-rounding

Conversation

@Enesuygurs

@Enesuygurs Enesuygurs commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

formatLongNumber (src/lib/format.ts) picks the unit from the raw value and then rounds with toFixed, so values just below a unit boundary round up to an impossible label:

  • 999999 → 1000k (should be 1.0m)
  • 999999999 → 1000.0m (should be 1.0b)
  • 99999 → 100.0k (should be 100k)
  • 9999 → 10.00k (should be 10.0k)
  • 999.6 → 1000 (should be 1.00k)

formatLongNumber is used in the link and pixel metrics bars and in the attribution, funnel, goal, heatmap and journey reports, so the wrong labels show up in all of them.

Fix

Lower each threshold by half of the smaller format's last digit (999950000, 999500, 99950, 9995, 999.5). A value that would round up to the next boundary now uses the next format instead. Values outside these small ranges format exactly as before.

Tests

Added a formatLongNumber test in src/lib/format.test.ts that covers the value just above and just below each new threshold.

  • Without the fix, the new test fails with expected '1000.0m' to be '1.0b'.
  • With the fix, npx vitest run src/lib/format.test.ts passes all 9 tests.
  • biome lint is clean on both changed files.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

@Enesuygurs is attempting to deploy a commit to the Umami Software Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

formatLongNumber now switches formats before rounding would produce labels such as 1000k.

  • Count labels switch units when rounding reaches the next boundary.

No actionable issues found. Tests were inspected, not run.

Reviews (1) · Last reviewed commit: "fix: move long numbers to the next unit ..." · Reviewed by Greptile

@mikecao
mikecao merged commit 047051b into umami-software:dev Oct 22, 2026
1 of 5 checks passed
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.

2 participants