Skip to content

Commit c382119

Browse files
committed
feat(suite): don't report retriable FW check attempts to Sentry
1 parent 7bdfeb4 commit c382119

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

packages/suite/src/components/suite/SecurityCheck/useReportDeviceCompromised.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { useEffect, useMemo } from 'react';
22

3+
import { FIRMWARE } from '@trezor/connect';
34
import { getFirmwareVersion } from '@trezor/device-utils';
45
import { isDeviceAcquired } from '@suite-common/suite-utils';
6+
import { isArrayMember } from '@trezor/utils';
57

68
import { useDevice, useSelector } from 'src/hooks/suite';
79
import { captureSentryMessage, withSentryScope } from 'src/utils/suite/sentry';
@@ -76,13 +78,14 @@ const useReportHashCheck = () => {
7678
const attemptCount = isError ? hashCheck.attemptCount : null;
7779

7880
useEffect(() => {
79-
if (errorType && hashCheckErrorScenarios[errorType].shouldReport) {
80-
reportCheckFail(
81-
'Firmware hash',
82-
{ ...commonData, errorType, attemptCount },
83-
errorPayload,
84-
);
85-
}
81+
if (!errorType) return;
82+
if (!hashCheckErrorScenarios[errorType].shouldReport) return;
83+
const willBeRetried =
84+
isArrayMember(errorType, FIRMWARE.HASH_CHECK_RETRIABLE_ERRORS) &&
85+
(attemptCount ?? 0) < FIRMWARE.HASH_CHECK_MAX_ATTEMPTS;
86+
if (willBeRetried) return;
87+
88+
reportCheckFail('Firmware hash', { ...commonData, errorType, attemptCount }, errorPayload);
8689
}, [commonData, errorType, errorPayload, attemptCount]);
8790

8891
// success bears warning if it needed retries, so we report the previous error payload, see Device.ts in connect

0 commit comments

Comments
 (0)