Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

fix(format): divide by 1e9 in formatLongNumber billions branch

Rup Sarmah0715aef47766
diff --git a/src/lib/format.test.ts b/src/lib/format.test.ts
index b70b5f2e1..cf6d82c1b 100644
--- a/src/lib/format.test.ts
+++ b/src/lib/format.test.ts
@@ -27,6 +27,8 @@ test('formatNumber', () => {
});
test('formatLongNumber', () => {
+ expect(format.formatLongNumber(1000000000)).toBe('1.0b');
+ expect(format.formatLongNumber(2500000000)).toBe('2.5b');
expect(format.formatLongNumber(1200000)).toBe('1.2m');
expect(format.formatLongNumber(575000)).toBe('575k');
expect(format.formatLongNumber(10500)).toBe('10.5k');
diff --git a/src/lib/format.ts b/src/lib/format.ts
index 07110d935..c791a2171 100644
--- a/src/lib/format.ts
+++ b/src/lib/format.ts
@@ -51,7 +51,7 @@ export function formatLongNumber(value: number) {
const n = Number(value);
if (n >= 1000000000) {
- return `${(n / 1000000).toFixed(1)}b`;
+ return `${(n / 1000000000).toFixed(1)}b`;
}
if (n >= 1000000) {
return `${(n / 1000000).toFixed(1)}m`;