Skip to content

Commit 6c9a424

Browse files
feat(suite): add anayltics to the device onboarding (seed backup types),
add analytics to multi share backup
1 parent 8ca0111 commit 6c9a424

File tree

11 files changed

+75
-10
lines changed

11 files changed

+75
-10
lines changed

Diff for: packages/suite-analytics/src/constants.ts

+2
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,6 @@ export enum EventType {
8787
GetDesktopApp = 'promo/desktop',
8888
GetMobileApp = 'promo/mobile',
8989
T2B1DashboardPromo = 'promo/t2b1-dashboard',
90+
91+
SettingsMultiShareBackup = 'settings/device/multi-share-backup',
9092
}

Diff for: packages/suite-analytics/src/types/definitions.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type OnboardingAnalytics = {
55
firmware: 'install' | 'update' | 'skip' | 'up-to-date';
66
seed: 'create' | 'recovery' | 'recovery-in-progress';
77
seedType: 'shamir-single' | 'shamir-advanced' | '12-words' | '24-words';
8+
wasSelectTypeOpened: boolean;
89
recoveryType: 'standard' | 'advanced';
910
backup: 'create' | 'skip';
1011
pin: 'create' | 'skip';

Diff for: packages/suite-analytics/src/types/events.ts

+7
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export type SuiteAnalyticsEvent =
8787
payload: Partial<Omit<OnboardingAnalytics, 'startTime'>> & {
8888
duration: number;
8989
device: string;
90+
unitPackaging: number;
9091
};
9192
}
9293
| {
@@ -417,4 +418,10 @@ export type SuiteAnalyticsEvent =
417418
payload: {
418419
action: 'shop' | 'close';
419420
};
421+
}
422+
| {
423+
type: EventType.SettingsMultiShareBackup;
424+
payload: {
425+
action: 'start' | 'done' | 'learn-more' | 'close-modal';
426+
};
420427
};

Diff for: packages/suite/src/components/onboarding/SkipStepConfirmation.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ export const SkipStepConfirmation = ({ onCancel }: SkipStepConfirmationProps) =>
4646
throw new Error(`Unexpected step to skip: ${activeStepId}`);
4747
}
4848

49+
const handleSkipStepConfirm = () => {
50+
goToNextStep(nextStep);
51+
};
52+
4953
return (
5054
<StyledModal
5155
isCancelable
@@ -59,7 +63,7 @@ export const SkipStepConfirmation = ({ onCancel }: SkipStepConfirmationProps) =>
5963
<Button
6064
variant="tertiary"
6165
data-test="@onboarding/skip-button-confirm"
62-
onClick={() => goToNextStep(nextStep)}
66+
onClick={handleSkipStepConfirm}
6367
>
6468
{text}
6569
</Button>

Diff for: packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/MultiShareBackupModal/MultiShareBackupModal.tsx

+34-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ import { MultiShareBackupStep5Done } from './MultiShareBackupStep5Done';
1818
import { isAdditionalShamirBackupInProgress } from '../../../../../../utils/device/isRecoveryInProgress';
1919
import { MultiShareBackupStep3VerifyOwnership } from './MultiShareBackupStep3VerifyOwnership';
2020
import { MultiShareBackupStep4BackupSeed } from './MultiShareBackupStep4BackupSeed';
21+
import { EventType, analytics } from '@trezor/suite-analytics';
2122

2223
type Steps = 'first-info' | 'second-info' | 'verify-ownership' | 'backup-seed' | 'done';
2324

24-
export const MultiShareBackupModal = ({ onCancel }: { onCancel: () => void }) => {
25+
export const MultiShareBackupModal = ({
26+
onCancel: onCancelFromProps,
27+
}: {
28+
onCancel: () => void;
29+
}) => {
2530
const device = useSelector(selectDevice);
2631

2732
const isInBackupMode =
@@ -33,6 +38,24 @@ export const MultiShareBackupModal = ({ onCancel }: { onCancel: () => void }) =>
3338
const [isChecked2, setIsChecked2] = useState(false);
3439
const [isSubmitted, setIsSubmitted] = useState(false);
3540

41+
const learnMoreClicked = () => {
42+
analytics.report({
43+
type: EventType.SettingsMultiShareBackup,
44+
payload: { action: 'learn-more' },
45+
});
46+
};
47+
48+
const onCancel = () => {
49+
if (step !== 'done') {
50+
analytics.report({
51+
type: EventType.SettingsMultiShareBackup,
52+
payload: { action: 'close-modal' },
53+
});
54+
}
55+
56+
onCancelFromProps();
57+
};
58+
3659
const closeWithCancelOnDevice = () => {
3760
TrezorConnect.cancel('cancel');
3861
onCancel();
@@ -68,7 +91,11 @@ export const MultiShareBackupModal = ({ onCancel }: { onCancel: () => void }) =>
6891
<Button onClick={goToStepNextStep}>
6992
<Translation id="TR_CREATE_MULTI_SHARE_BACKUP" />
7093
</Button>
71-
<LearnMoreButton url={HELP_CENTER_SEED_CARD_URL} size="medium" />
94+
<LearnMoreButton
95+
url={HELP_CENTER_SEED_CARD_URL}
96+
size="medium"
97+
onClick={learnMoreClicked}
98+
/>
7299
</>
73100
),
74101
};
@@ -90,6 +117,11 @@ export const MultiShareBackupModal = ({ onCancel }: { onCancel: () => void }) =>
90117
setStep('backup-seed');
91118
TrezorConnect.backupDevice().then(response => {
92119
if (response.success) {
120+
analytics.report({
121+
type: EventType.SettingsMultiShareBackup,
122+
payload: { action: 'done' },
123+
});
124+
93125
setStep('done');
94126
} else {
95127
onCancel();

Diff for: packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/MultiShareBackupModal/instructionSteps.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import styled from 'styled-components';
33

44
import { Image, Text } from '@trezor/components';
55
import { borders, spacings, spacingsPx } from '@trezor/theme';
6-
import { ESHOP_KEEP_METAL_URL, HELP_CENTER_SEED_CARD_URL } from '@trezor/urls';
6+
import { ESHOP_KEEP_METAL_SINGLE_SHARE_URL, ESHOP_KEEP_METAL_URL, HELP_CENTER_SEED_CARD_URL } from '@trezor/urls';
77

88
import { Translation, TrezorLink } from 'src/components/suite';
99
import { BackupInstructionsCard } from './BackupInstructionsCard';
@@ -68,7 +68,7 @@ export const createSharesInstruction: InstructionBaseConfig = {
6868
</TrezorLink>
6969
),
7070
keepLink: chunks => (
71-
<TrezorLink href={ESHOP_KEEP_METAL_URL} variant="underline">
71+
<TrezorLink href={ESHOP_KEEP_METAL_SINGLE_SHARE_URL} variant="underline">
7272
{chunks}
7373
</TrezorLink>
7474
),

Diff for: packages/suite/src/views/onboarding/steps/Final.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ export const FinalStep = () => {
221221
...onboardingAnalytics,
222222
duration: Date.now() - onboardingAnalytics.startTime!,
223223
device: device.features.internal_model,
224+
unitPackaging: device.features.unit_packaging ?? 0,
224225
};
225226
delete payload.startTime;
226227

Diff for: packages/suite/src/views/onboarding/steps/ResetDevice.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ export const ResetDeviceStep = () => {
9292
}
9393

9494
updateBackupType(type);
95-
updateAnalytics({ recoveryType: undefined, seedType: type });
95+
updateAnalytics({ seedType: type });
9696
},
97-
[updateAnalytics, onResetDevice, updateBackupType],
97+
[updateBackupType, updateAnalytics, onResetDevice],
9898
);
9999

100100
useEffect(() => {
@@ -154,6 +154,7 @@ export const ResetDeviceStep = () => {
154154
<>
155155
<SelectBackupType
156156
selected={backupType}
157+
onOpen={() => updateAnalytics({ wasSelectTypeOpened: true })}
157158
onSelect={setBackupType}
158159
isDisabled={isDeviceLocked}
159160
data-test="@onboarding/select-seed-type-open-dialog"

Diff for: packages/suite/src/views/onboarding/steps/SelectBackupType/SelectBackupType.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ type SelectBackupTypeProps = {
8484
selected: BackupType;
8585
onSelect: (value: BackupType) => void;
8686
'data-test'?: string;
87+
onOpen: () => void;
8788
};
8889

8990
export const SelectBackupType = ({
9091
selected,
9192
onSelect,
9293
isDisabled,
9394
'data-test': dataTest,
95+
onOpen,
9496
}: SelectBackupTypeProps) => {
9597
const { elevation } = useElevation();
9698
const [isOpen, setIsOpen] = useState(false);
@@ -136,7 +138,13 @@ export const SelectBackupType = ({
136138
<Wrapper>
137139
<SelectWrapper $elevation={elevation} ref={refs.setReference} {...getReferenceProps()}>
138140
<ElevationUp>
139-
<SelectedOption isDisabled={isDisabled} onClick={() => setIsOpen(true)}>
141+
<SelectedOption
142+
isDisabled={isDisabled}
143+
onClick={() => {
144+
setIsOpen(true);
145+
onOpen();
146+
}}
147+
>
140148
<OptionText data-test={dataTest}>
141149
<Text variant="tertiary" typographyStyle="hint">
142150
<Translation id="TR_ONBOARDING_BACKUP_TYPE" />

Diff for: packages/suite/src/views/settings/SettingsDevice/MultiShareBackup.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { useDispatch, useSelector } from 'src/hooks/suite';
1010
import { selectDevice } from '@suite-common/wallet-core';
1111
import { TrezorDevice } from '@suite-common/suite-types';
1212
import { goto } from '../../../actions/suite/routerActions';
13+
import { EventType, analytics } from '@trezor/suite-analytics';
1314

1415
const doesSupportMultiShare = (device: TrezorDevice | undefined): boolean => {
1516
if (device?.features === undefined) {
@@ -38,7 +39,14 @@ export const MultiShareBackup = () => {
3839
return;
3940
}
4041

41-
const handleClick = () => dispatch(goto('create-multi-share-backup'));
42+
const handleClick = () => {
43+
analytics.report({
44+
type: EventType.SettingsMultiShareBackup,
45+
payload: { action: 'start' },
46+
});
47+
48+
dispatch(goto('create-multi-share-backup'));
49+
};
4250

4351
return (
4452
<SectionItem>

Diff for: packages/urls/src/urls.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const HELP_CENTER_ETH_STAKING =
7373
'https://trezor.io/learn/a/stake-ethereum-eth-in-trezor-suite';
7474
export const HELP_CENTER_SEED_CARD_URL = 'https://trezor.io/learn/a/recovery-seed-card';
7575
export const HELP_CENTER_MULTI_SHARE_BACKUP_URL =
76-
'https://trezor.io/learn/a/introducing-multi-share-backup';
76+
'https://trezor.io/learn/a/multi-share-backup-on-trezor';
7777
export const HELP_CENTER_KEEPING_SEED_SAFE_URL =
7878
'https://trezor.io/learn/a/keeping-your-recovery-seed-safe';
7979

@@ -101,3 +101,4 @@ export const ZKSNACKS_TERMS_URL =
101101
export const CROWDIN_URL = 'https://crowdin.com/project/trezor-suite';
102102

103103
export const ESHOP_KEEP_METAL_URL = 'https://trezor.io/trezor-keep-metal';
104+
export const ESHOP_KEEP_METAL_SINGLE_SHARE_URL = 'https://trezor.io/trezor-keep-metal-single-share';

0 commit comments

Comments
 (0)