Skip to content

Commit

Permalink
feat(suite): unify onboarding analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-sanderson committed May 20, 2024
1 parent d209a0c commit 7701cd9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 29 deletions.
1 change: 1 addition & 0 deletions packages/suite-analytics/src/types/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type OnboardingAnalytics = {
firmware: 'install' | 'update' | 'skip' | 'up-to-date';
seed: 'create' | 'recovery' | 'recovery-in-progress';
seedType: 'shamir-default' | 'shamir-advance' | '12-words' | '24-words';
wasSelectTypeOpened: boolean;
recoveryType: 'standard' | 'advanced';
backup: 'create' | 'skip';
pin: 'create' | 'skip';
Expand Down
10 changes: 1 addition & 9 deletions packages/suite-analytics/src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export type SuiteAnalyticsEvent =
payload: Partial<Omit<OnboardingAnalytics, 'startTime'>> & {
duration: number;
device: string;
unitPackaging: number;
};
}
| {
Expand Down Expand Up @@ -417,13 +418,4 @@ export type SuiteAnalyticsEvent =
payload: {
action: 'shop' | 'close';
};
}
| {
type: EventType.OnboardingSelectBackupType;
payload: {
finalSelectedOption: 'shamir-default' | 'shamir-advance' | '12-words' | '24-words';
wasSelectTypeOpened: boolean;
device: string;
unitPackaging: number;
};
};
1 change: 1 addition & 0 deletions packages/suite/src/views/onboarding/steps/Final.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export const FinalStep = () => {
...onboardingAnalytics,
duration: Date.now() - onboardingAnalytics.startTime!,
device: device.features.internal_model,
unitPackaging: device.features.unit_packaging ?? 0,
};
delete payload.startTime;

Expand Down
22 changes: 2 additions & 20 deletions packages/suite/src/views/onboarding/steps/ResetDevice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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%;
Expand Down Expand Up @@ -74,16 +73,6 @@ export const ResetDeviceStep = () => {

const handleSubmit = useCallback(
async (type: BackupType) => {
analytics.report({
type: EventType.OnboardingSelectBackupType,
payload: {
wasSelectTypeOpened,
finalSelectedOption: type,
device: deviceModel ?? '',
unitPackaging,
},
});

switch (type) {
case 'shamir-default':
await onResetDevice({ backup_type: 1 });
Expand All @@ -100,16 +89,9 @@ export const ResetDeviceStep = () => {
}

updateBackupType(type);
updateAnalytics({ recoveryType: undefined, seedType: type });
updateAnalytics({ wasSelectTypeOpened, seedType: type });
},
[
wasSelectTypeOpened,
deviceModel,
unitPackaging,
updateBackupType,
updateAnalytics,
onResetDevice,
],
[wasSelectTypeOpened, updateBackupType, updateAnalytics, onResetDevice],
);

useEffect(() => {
Expand Down

0 comments on commit 7701cd9

Please sign in to comment.