Skip to content

Commit f22cf05

Browse files
authored
fix: add missing metrics to import SRP flow and grouped Import SRP events (#37567)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> In this PR, added missing track event for SRP import: click event in Add Wallet modal and completion event with hd_entropy_index on import. - Metrics - Import Secret Recovery Phrase Clicked: This event needs to be added It should fire when the user clicks the import wallet button on the account list. - Import Secret Recovery Phrase Continue Button Clicked: It should fire when the user finishes importing an SRP (they click continue) Also we've enhanced our tracking by grouping the Import Secret Recovery Phrase event with specific status properties: 'started', 'continue_button_clicked', and 'completed', along with location data. This provides visibility into the full workflow timeline from initiation to completion. Jira Link: https://consensyssoftware.atlassian.net/browse/SL-277 Segment Schema PR: https://github.com/Consensys/segment-schema/pull/367/files [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/37567?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: added missing metrics to import SRP flow ## **Related issues** Fixes: ## **Manual testing steps** 1. Open extesnion. 2. Create Wallet. 3. Add wallet and track event when user clicks on 'Import a wallet' and when user successfully import the SRP. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> <img width="1728" height="858" alt="Screenshot 2025-11-06 at 3 20 25 PM" src="https://github.com/user-attachments/assets/ce66954e-ebf5-40e8-903b-2b219ec5d968" /> <img width="1727" height="1070" alt="Screenshot 2025-11-06 at 3 21 04 PM" src="https://github.com/user-attachments/assets/aed9cbf7-3c88-4033-a4b1-31b539ceb796" /> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Unifies SRP import tracking into a single event with start/continue/completed statuses and adds hd_entropy_index and discovered account counts on completion. > > - **Metrics**: > - Consolidate `ImportSecretRecoveryPhraseClicked`/`Completed` into `ImportSecretRecoveryPhrase` with status-based phases (`started`, `continue_button_clicked`, `completed`). > - **Background** (`app/scripts/metamask-controller.js`): > - On SRP import completion, track `ImportSecretRecoveryPhrase` with `hd_entropy_index`, `number_of_solana_accounts_discovered`, and `number_of_bitcoin_accounts_discovered`. > - **UI**: > - `ui/components/multichain-accounts/add-wallet-modal/add-wallet-modal.tsx`: Track `ImportSecretRecoveryPhrase` with `status: 'started'` when selecting "Import a wallet" (location: Add Wallet Modal). > - `ui/components/multichain/account-menu/account-menu.tsx`: Track `ImportSecretRecoveryPhrase` with `status: 'started'` when clicking SRP import (location: Account Menu). > - `ui/pages/multi-srp/import-srp/import-srp.tsx`: Track `ImportSecretRecoveryPhrase` with `status: 'continue_button_clicked'` on continue (location: Multi SRP Import). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit b1ca69d. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent d30e743 commit f22cf05

File tree

5 files changed

+34
-6
lines changed

5 files changed

+34
-6
lines changed

app/scripts/metamask-controller.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4605,8 +4605,9 @@ export default class MetamaskController extends EventEmitter {
46054605
const newHdEntropyIndex = this.getHDEntropyIndex();
46064606

46074607
this.metaMetricsController.trackEvent({
4608-
event: MetaMetricsEventName.ImportSecretRecoveryPhraseCompleted,
4608+
event: MetaMetricsEventName.ImportSecretRecoveryPhrase,
46094609
properties: {
4610+
status: 'completed',
46104611
// eslint-disable-next-line @typescript-eslint/naming-convention
46114612
hd_entropy_index: newHdEntropyIndex,
46124613
// eslint-disable-next-line @typescript-eslint/naming-convention

shared/constants/metametrics.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,8 +719,7 @@ export enum MetaMetricsEventName {
719719
EncryptionPublicKeyRequested = 'Encryption Requested',
720720
ErrorOccured = 'Error occured',
721721
ExternalLinkClicked = 'External Link Clicked',
722-
ImportSecretRecoveryPhraseClicked = 'Import Secret Recovery Phrase Clicked',
723-
ImportSecretRecoveryPhraseCompleted = 'Import Secret Recovery Phrase Completed',
722+
ImportSecretRecoveryPhrase = 'Import Secret Recovery Phrase',
724723
KeyExportSelected = 'Key Export Selected',
725724
KeyExportRequested = 'Key Export Requested',
726725
KeyExportFailed = 'Key Export Failed',

ui/components/multichain-accounts/add-wallet-modal/add-wallet-modal.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ export const AddWalletModal: React.FC<AddWalletModalProps> = ({
130130
const handleOptionClick = (option: WalletOption) => {
131131
onClose?.();
132132

133+
if (option.id === 'import-wallet') {
134+
// Track the event for the selected option.
135+
trackEvent({
136+
category: MetaMetricsEventCategory.Navigation,
137+
event: MetaMetricsEventName.ImportSecretRecoveryPhrase,
138+
properties: {
139+
status: 'started',
140+
location: 'Add Wallet Modal',
141+
},
142+
});
143+
}
144+
133145
// Hardware wallet connections require expanded view
134146
if (option.id === 'hardware-wallet') {
135147
if (

ui/components/multichain/account-menu/account-menu.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,11 @@ export const AccountMenu = ({
563563
onClick={() => {
564564
trackEvent({
565565
category: MetaMetricsEventCategory.Navigation,
566-
event:
567-
MetaMetricsEventName.ImportSecretRecoveryPhraseClicked,
566+
event: MetaMetricsEventName.ImportSecretRecoveryPhrase,
567+
properties: {
568+
status: 'started',
569+
location: 'Account Menu',
570+
},
568571
});
569572
history.push(IMPORT_SRP_ROUTE);
570573
onClose();

ui/pages/multi-srp/import-srp/import-srp.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React, { useEffect, useState, useContext } from 'react';
22
import { useDispatch, useSelector } from 'react-redux';
33
import { useNavigate } from 'react-router-dom-v5-compat';
44
import { useI18nContext } from '../../../hooks/useI18nContext';
@@ -32,6 +32,8 @@ import {
3232
TextAlign,
3333
TextVariant,
3434
} from '../../../helpers/constants/design-system';
35+
import { MetaMetricsContext } from '../../../contexts/metametrics';
36+
import { MetaMetricsEventName } from '../../../../shared/constants/metametrics';
3537

3638
export const ImportSrp = () => {
3739
const t = useI18nContext();
@@ -41,6 +43,7 @@ export const ImportSrp = () => {
4143
const [secretRecoveryPhrase, setSecretRecoveryPhrase] = useState('');
4244
const isSocialLoginEnabled = useSelector(getIsSocialLoginFlow);
4345
const isSeedlessPasswordOutdated = useSelector(getIsSeedlessPasswordOutdated);
46+
const trackEvent = useContext(MetaMetricsContext);
4447

4548
// Providing duplicate SRP throws an error in metamask-controller, which results in a warning in the UI
4649
// We want to hide the warning when the component unmounts
@@ -64,7 +67,17 @@ export const ImportSrp = () => {
6467
return;
6568
}
6669
}
70+
71+
trackEvent({
72+
event: MetaMetricsEventName.ImportSecretRecoveryPhrase,
73+
properties: {
74+
status: 'continue_button_clicked',
75+
location: 'Multi SRP Import',
76+
},
77+
});
78+
6779
await dispatch(importMnemonicToVault(secretRecoveryPhrase));
80+
6881
navigate(DEFAULT_ROUTE);
6982
dispatch(setShowNewSrpAddedToast(true));
7083
} catch (error) {

0 commit comments

Comments
 (0)