mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-09 16:58:32 +01:00
feat(suite): add customFw to event device-update-firmware and device-connect
This commit is contained in:
committed by
Tomáš Klíma
parent
20d48b35ac
commit
91970a2e8e
@@ -1,6 +1,17 @@
|
||||
import { isDeviceInBootloaderMode } from './modeUtils';
|
||||
import { FirmwareType, FirmwareVersionString, PartialDevice, VersionArray } from './types';
|
||||
|
||||
export const isOfficialFirmware = (device?: PartialDevice): boolean => {
|
||||
if (
|
||||
device?.authenticityChecks?.firmwareRevision?.success &&
|
||||
device?.authenticityChecks?.firmwareHash?.success
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
export const getFirmwareRevision = (device?: PartialDevice) => device?.features?.revision || '';
|
||||
|
||||
export const getFirmwareVersionArray = (device?: PartialDevice): VersionArray | null => {
|
||||
|
||||
@@ -62,6 +62,10 @@ export type FeaturesNarrowing =
|
||||
// todo: this is copy-pasted from packages/protobuf/src/messages
|
||||
export type PartialDevice = {
|
||||
firmwareType?: FirmwareType;
|
||||
authenticityChecks?: {
|
||||
firmwareRevision: { success: boolean } | null;
|
||||
firmwareHash: { success: boolean } | null;
|
||||
};
|
||||
|
||||
features?: {
|
||||
major_version: number;
|
||||
|
||||
@@ -91,6 +91,7 @@ export type SuiteAnalyticsEvent =
|
||||
payload: {
|
||||
mode: 'normal' | 'bootloader' | 'initialize' | 'seedless';
|
||||
firmware: string;
|
||||
isOfficialFw: boolean;
|
||||
bootloader?: string;
|
||||
pin_protection?: boolean | null;
|
||||
passphrase_protection?: boolean | null;
|
||||
@@ -116,6 +117,7 @@ export type SuiteAnalyticsEvent =
|
||||
fromFwVersion: string;
|
||||
toFwVersion?: string;
|
||||
toBtcOnly?: boolean;
|
||||
isOfficialFw: boolean;
|
||||
error: string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
getFirmwareVersion,
|
||||
hasBitcoinOnlyFirmware,
|
||||
isDeviceInBootloaderMode,
|
||||
isOfficialFirmware,
|
||||
} from '@trezor/device-utils';
|
||||
import { EventType, analytics } from '@trezor/suite-analytics';
|
||||
import { BigNumber } from '@trezor/utils/src/bigNumber';
|
||||
@@ -73,6 +74,7 @@ const analyticsMiddleware =
|
||||
error,
|
||||
toBtcOnly,
|
||||
toFwVersion,
|
||||
isOfficialFw: isOfficialFirmware(device),
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -122,6 +124,7 @@ const analyticsMiddleware =
|
||||
language: features.language,
|
||||
model: features.internal_model,
|
||||
optiga_sec: features.optiga_sec,
|
||||
isOfficialFw: isOfficialFirmware(action.payload.device),
|
||||
},
|
||||
});
|
||||
} else {
|
||||
@@ -131,6 +134,7 @@ const analyticsMiddleware =
|
||||
mode: 'bootloader',
|
||||
firmware: getFirmwareVersion(action.payload.device),
|
||||
bootloader: getBootloaderVersion(action.payload.device),
|
||||
isOfficialFw: isOfficialFirmware(action.payload.device),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user