-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(suite-native): log FW revision check result to Sentry
- Loading branch information
Showing
6 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
suite-native/device/src/hooks/useReportDeviceCompromised.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { useSelector } from 'react-redux'; | ||
import { useEffect, useMemo } from 'react'; | ||
|
||
import * as Sentry from '@sentry/react-native'; | ||
|
||
import { getFirmwareVersion } from '@trezor/device-utils'; | ||
import { selectSelectedDevice } from '@suite-common/wallet-core'; | ||
|
||
import { selectFirmwareRevisionCheckError } from '../selectors'; | ||
|
||
const reportCheckFail = (checkType: 'Firmware revision', contextData: any) => { | ||
Sentry.captureException(`${checkType} check failed! ${JSON.stringify(contextData)}`); | ||
}; | ||
|
||
const useCommonData = () => { | ||
const device = useSelector(selectSelectedDevice); | ||
const model = device?.features?.internal_model; | ||
const revision = device?.features?.revision; | ||
const version = getFirmwareVersion(device); | ||
const vendor = device?.features?.fw_vendor; | ||
|
||
return useMemo( | ||
() => ({ model, revision, version, vendor }), | ||
[model, revision, version, vendor], | ||
); | ||
}; | ||
|
||
export const useReportDeviceCompromised = () => { | ||
const commonData = useCommonData(); | ||
|
||
const revisionCheckError = useSelector(selectFirmwareRevisionCheckError); | ||
|
||
useEffect(() => { | ||
if (revisionCheckError !== null) { | ||
reportCheckFail('Firmware revision', { ...commonData, revisionCheckError }); | ||
} | ||
}, [commonData, revisionCheckError]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters