Skip to content

Commit ebb5b80

Browse files
authored
Merge pull request #3088 from input-output-hk/feat/ddw-1161-round-ram-size-in-analytics
[DDW-1161] Round RAM size in analytics
2 parents 7ebfa92 + 15d61a7 commit ebb5b80

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## vNext
44

5+
### Features
6+
7+
- Implemented rounding RAM size in analytics ([PR 3088](https://github.com/input-output-hk/daedalus/pull/3088))
8+
59
### Chores
610

711
- Updated new Catalyst API URL ([PR 3087](https://github.com/input-output-hk/daedalus/pull/3087))

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)