Skip to content

Commit 22748e7

Browse files
author
Marcin Mazurek
committed
[DDW-1161] Round RAM size in analytics
1 parent 4fb516a commit 22748e7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

source/renderer/app/analytics/MatomoClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class MatomoClient implements AnalyticsClient {
3333
action_name: pageTitle,
3434
url: this.getAnalyticsURL(),
3535
[CPU_DIMENSION_KEY]: formatCpuInfo(this.environment.cpu),
36-
[RAM_DIMENSION_KEY]: formattedBytesToSize(this.environment.ram),
36+
[RAM_DIMENSION_KEY]: formattedBytesToSize(this.environment.ram, 0),
3737
[OS_DIMENSION_KEY]: this.environment.os,
3838
[VERSION_DIMENSION_KEY]: this.environment.version,
3939
});

source/renderer/app/utils/formatters.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ export const formattedLovelaceToAmount = (lovelace: number): number =>
185185
formattedAmountToBigNumber(String(lovelace))
186186
.dividedBy(LOVELACES_PER_ADA)
187187
.toNumber();
188-
export const formattedBytesToSize = (bytes: number): string => {
188+
export const formattedBytesToSize = (
189+
bytes: number,
190+
decimalPlaces = 1
191+
): string => {
189192
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
190193
if (bytes === 0) return 'n/a';
191194
const i = parseInt(
@@ -194,7 +197,7 @@ export const formattedBytesToSize = (bytes: number): string => {
194197
10
195198
);
196199
if (i === 0) return `${bytes} ${sizes[i]})`;
197-
return `${formattedNumber(bytes / 1024 ** i, 1)} ${sizes[i]}`;
200+
return `${formattedNumber(bytes / 1024 ** i, decimalPlaces)} ${sizes[i]}`;
198201
};
199202
export type FormattedDownloadData = {
200203
timeLeft: string;

0 commit comments

Comments
 (0)