Skip to content

Commit 0952f3c

Browse files
author
Marcin Mazurek
committed
[DDW-1163] Avoid running regexes for empty CPU model
1 parent 162a514 commit 0952f3c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
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]: getShortCpuDescription(
36-
this.environment.cpu[0]?.model || ''
36+
this.environment.cpu[0]?.model
3737
),
3838
[RAM_DIMENSION_KEY]: formattedBytesToSize(this.environment.ram),
3939
[VERSION_DIMENSION_KEY]: this.environment.version,

source/renderer/app/utils/getShortCpuDescription.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ const amdRyzenRegex = /AMD Ryzen ([0-9]+)/;
44
const amdARegex = /AMD A([0-9]+)/;
55
const otherAmdCpuRegex = /AMD ([A-Za-z][A-Za-z\s]*[A-Za-z]|[A-Za-z])[\s|(-]/;
66

7-
export const getShortCpuDescription = (cpu: string): string => {
7+
export const getShortCpuDescription = (cpu: string | undefined): string => {
8+
if (!cpu) {
9+
return 'Other';
10+
}
11+
812
if (cpu.includes('Apple')) {
913
return cpu;
1014
}

0 commit comments

Comments
 (0)