diff --git a/packages/suite-analytics/src/constants.ts b/packages/suite-analytics/src/constants.ts index c20af4c43207..418301e34db6 100644 --- a/packages/suite-analytics/src/constants.ts +++ b/packages/suite-analytics/src/constants.ts @@ -87,4 +87,6 @@ export enum EventType { GetDesktopApp = 'promo/desktop', GetMobileApp = 'promo/mobile', T2B1DashboardPromo = 'promo/t2b1-dashboard', + + OnboardingSelectBackupTypeOpened = 'onboarding/select-backup-type-opened', } diff --git a/packages/suite-analytics/src/types/events.ts b/packages/suite-analytics/src/types/events.ts index 870beb5c137e..75a0c0c161b8 100644 --- a/packages/suite-analytics/src/types/events.ts +++ b/packages/suite-analytics/src/types/events.ts @@ -417,4 +417,13 @@ export type SuiteAnalyticsEvent = payload: { action: 'shop' | 'close'; }; + } + | { + type: EventType.OnboardingSelectBackupTypeOpened; + payload: { + finalSelectedOption: 'shamir-default' | 'shamir-advance' | '12-words' | '24-words'; + wasSelectTypeOpened: boolean; + device: string; + unitPackaging: number; + }; }; diff --git a/packages/suite/src/views/onboarding/steps/ResetDevice.tsx b/packages/suite/src/views/onboarding/steps/ResetDevice.tsx index f4139e3f7245..86cd50f682dd 100644 --- a/packages/suite/src/views/onboarding/steps/ResetDevice.tsx +++ b/packages/suite/src/views/onboarding/steps/ResetDevice.tsx @@ -11,6 +11,7 @@ import { Button, Divider, Text } from '@trezor/components'; import { SelectBackupType, getDefaultBackupType, isShamirBackupType } from './SelectBackupType'; import { DeviceModelInternal } from '@trezor/connect'; import { BackupType } from '../../../reducers/onboarding/onboardingReducer'; +import { analytics, EventType } from '@trezor/suite-analytics'; const SelectWrapper = styled.div` width: 100%; @@ -44,6 +45,7 @@ export const ResetDeviceStep = () => { const [submitted, setSubmitted] = useState(false); const [backupType, setBackupType] = useState(deviceDefaultBackupType); + const [wasSelectTypeOpened, setWasSelectTypeOpened] = useState(false); const { goToPreviousStep, goToNextStep, updateAnalytics, updateBackupType } = useOnboarding(); const dispatch = useDispatch(); @@ -72,6 +74,16 @@ export const ResetDeviceStep = () => { const handleSubmit = useCallback( async (type: BackupType) => { + analytics.report({ + type: EventType.OnboardingSelectBackupTypeOpened, + payload: { + wasSelectTypeOpened, + finalSelectedOption: type, + device: deviceModel ?? '', + unitPackaging, + }, + }); + switch (type) { case 'shamir-default': await onResetDevice({ backup_type: 1 }); @@ -150,7 +162,8 @@ export const ResetDeviceStep = () => { <> setWasSelectTypeOpened(true)} + onSelect={value => setBackupType(value)} isDisabled={isDeviceLocked} data-test="@onboarding/select-seed-type-open-dialog" /> diff --git a/packages/suite/src/views/onboarding/steps/SelectBackupType.tsx b/packages/suite/src/views/onboarding/steps/SelectBackupType.tsx index 51cf5b20c4f5..22f3a69153cf 100644 --- a/packages/suite/src/views/onboarding/steps/SelectBackupType.tsx +++ b/packages/suite/src/views/onboarding/steps/SelectBackupType.tsx @@ -401,12 +401,14 @@ type SelectBackupTypeProps = { isDisabled: boolean; selected: BackupType; onSelect: (value: BackupType) => void; + onOpen: () => void; 'data-test'?: string; }; export const SelectBackupType = ({ selected, onSelect, + onOpen, isDisabled, 'data-test': dataTest, }: SelectBackupTypeProps) => { @@ -450,11 +452,16 @@ export const SelectBackupType = ({ const isShamirDefault = isShamirBackupType(defaultBackupType); const isShamirSelected = isShamirBackupType(selected); + const handleOpen = () => { + setIsOpen(true); + onOpen(); + }; + return ( - setIsOpen(true)}> +