Skip to content

Commit f4bc00e

Browse files
committed
fix: added event for Add Wallet and Import SRP
1 parent 6182154 commit f4bc00e

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,21 @@ export const AddWalletModal: React.FC<AddWalletModalProps> = ({
127127
const handleOptionClick = (option: WalletOption) => {
128128
onClose?.();
129129

130+
// Track the event for the selected option.
131+
trackEvent({
132+
category: MetaMetricsEventCategory.Navigation,
133+
event:
134+
option.id === 'import-wallet'
135+
? MetaMetricsEventName.ImportSecretRecoveryPhraseClicked
136+
: option.titleKey,
137+
properties: {
138+
location: 'Main Menu',
139+
// TODO: Fix in https://github.com/MetaMask/metamask-extension/issues/31860
140+
// eslint-disable-next-line @typescript-eslint/naming-convention
141+
hd_entropy_index: null,
142+
},
143+
});
144+
130145
// Hardware wallet connections require expanded view
131146
if (option.id === 'hardware-wallet') {
132147
if (getEnvironmentType() === ENVIRONMENT_TYPE_POPUP) {

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React, { useContext, useEffect, useState } from 'react';
22
import { useDispatch, useSelector } from 'react-redux';
33
import { useNavigate } from 'react-router-dom-v5-compat';
44
import { useI18nContext } from '../../../hooks/useI18nContext';
@@ -18,7 +18,7 @@ import {
1818
import { setShowNewSrpAddedToast } from '../../../components/app/toast-master/utils';
1919
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes';
2020
import { Header, Page } from '../../../components/multichain/pages/page';
21-
import { getIsSocialLoginFlow } from '../../../selectors';
21+
import { getHDEntropyIndex, getIsSocialLoginFlow } from '../../../selectors';
2222
import { getIsSeedlessPasswordOutdated } from '../../../ducks/metamask/metamask';
2323
import PasswordOutdatedModal from '../../../components/app/password-outdated-modal';
2424
import { 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

3641
export 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

Comments
 (0)