1- import React , { useEffect , useState } from 'react' ;
1+ import React , { useContext , useEffect , useState } from 'react' ;
22import { useDispatch , useSelector } from 'react-redux' ;
33import { useNavigate } from 'react-router-dom-v5-compat' ;
44import { useI18nContext } from '../../../hooks/useI18nContext' ;
@@ -18,7 +18,7 @@ import {
1818import { setShowNewSrpAddedToast } from '../../../components/app/toast-master/utils' ;
1919import { DEFAULT_ROUTE } from '../../../helpers/constants/routes' ;
2020import { Header , Page } from '../../../components/multichain/pages/page' ;
21- import { getIsSocialLoginFlow } from '../../../selectors' ;
21+ import { getHDEntropyIndex , getIsSocialLoginFlow } from '../../../selectors' ;
2222import { getIsSeedlessPasswordOutdated } from '../../../ducks/metamask/metamask' ;
2323import PasswordOutdatedModal from '../../../components/app/password-outdated-modal' ;
2424import { MetaMaskReduxDispatch } from '../../../store/store' ;
@@ -32,6 +32,11 @@ import {
3232 TextAlign ,
3333 TextVariant ,
3434} from '../../../helpers/constants/design-system' ;
35+ import { MetaMetricsContext } from '../../../contexts/metametrics' ;
36+ import {
37+ MetaMetricsEventCategory ,
38+ MetaMetricsEventName ,
39+ } from '../../../../shared/constants/metametrics' ;
3540
3641export const ImportSrp = ( ) => {
3742 const t = useI18nContext ( ) ;
@@ -41,6 +46,8 @@ export const ImportSrp = () => {
4146 const [ secretRecoveryPhrase , setSecretRecoveryPhrase ] = useState ( '' ) ;
4247 const isSocialLoginEnabled = useSelector ( getIsSocialLoginFlow ) ;
4348 const isSeedlessPasswordOutdated = useSelector ( getIsSeedlessPasswordOutdated ) ;
49+ const hdEntropyIndex = useSelector ( getHDEntropyIndex ) ;
50+ const trackEvent = useContext ( MetaMetricsContext ) ;
4451
4552 // Providing duplicate SRP throws an error in metamask-controller, which results in a warning in the UI
4653 // We want to hide the warning when the component unmounts
@@ -65,6 +72,17 @@ export const ImportSrp = () => {
6572 }
6673 }
6774 await dispatch ( importMnemonicToVault ( secretRecoveryPhrase ) ) ;
75+
76+ // Track the event for the successful import.
77+ trackEvent ( {
78+ category : MetaMetricsEventCategory . Wallet ,
79+ event : MetaMetricsEventName . ImportSecretRecoveryPhraseCompleted ,
80+ properties : {
81+ // eslint-disable-next-line @typescript-eslint/naming-convention
82+ hd_entropy_index : hdEntropyIndex ,
83+ } ,
84+ } ) ;
85+
6886 navigate ( DEFAULT_ROUTE ) ;
6987 dispatch ( setShowNewSrpAddedToast ( true ) ) ;
7088 } catch ( error ) {
0 commit comments