1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Rename some events (#15543)

Co-authored-by: Brad Decker <bhdecker84@gmail.com>
This commit is contained in:
John Brennan 2022-08-16 09:39:23 -07:00 committed by GitHub
parent 8464ed150c
commit 82368e7451
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 379 additions and 207 deletions

View File

@ -278,23 +278,53 @@ export const REJECT_NOTFICIATION_CLOSE_SIG =
*/ */
export const EVENT_NAMES = { export const EVENT_NAMES = {
ACCOUNT_ADDED: 'Account Added',
ACCOUNT_ADD_SELECTED: 'Account Add Selected',
ACCOUNT_ADD_FAILED: 'Account Add Failed',
ACCOUNT_PASSWORD_CREATED: 'Account Password Created',
ACCOUNT_RESET: 'Account Reset',
APP_INSTALLED: 'App Installed', APP_INSTALLED: 'App Installed',
APP_UNLOCKED: 'App Unlocked',
APP_UNLOCKED_FAILED: 'App Unlocked Failed',
APP_WINDOW_EXPANDED: 'App Window Expanded',
DECRYPTION_APPROVED: 'Decryption Approved', DECRYPTION_APPROVED: 'Decryption Approved',
DECRYPTION_REJECTED: 'Decryption Rejected', DECRYPTION_REJECTED: 'Decryption Rejected',
DECRYPTION_REQUESTED: 'Decryption Requested', DECRYPTION_REQUESTED: 'Decryption Requested',
ENCRYPTION_PUBLIC_KEY_APPROVED: 'Encryption Public Key Approved', ENCRYPTION_PUBLIC_KEY_APPROVED: 'Encryption Approved',
ENCRYPTION_PUBLIC_KEY_REJECTED: 'Encryption Public Key Rejected', ENCRYPTION_PUBLIC_KEY_REJECTED: 'Encryption Rejected',
ENCRYPTION_PUBLIC_KEY_REQUESTED: 'Encryption Public Key Requested', ENCRYPTION_PUBLIC_KEY_REQUESTED: 'Encryption Requested',
EXTERNAL_LINK_CLICKED: 'External Link Clicked',
KEY_EXPORT_SELECTED: 'Key Export Selected',
KEY_EXPORT_REQUESTED: 'Key Export Requested',
KEY_EXPORT_FAILED: 'Key Export Failed',
KEY_EXPORT_CANCELED: 'Key Export Canceled',
KEY_EXPORT_REVEALED: 'Key Material Revealed',
KEY_EXPORT_COPIED: 'Key Material Copied',
NAV_ACCOUNT_MENU_OPENED: 'Account Menu Opened',
NAV_ACCOUNT_DETAILS_OPENED: 'Account Details Opened',
NAV_CONNECTED_SITES_OPENED: 'Connected Sites Opened',
NAV_MAIN_MENU_OPENED: 'Main Menu Opened',
NAV_NETWORK_MENU_OPENED: 'Network Menu Opened',
NAV_SETTINGS_OPENED: 'Settings Opened',
NAV_ACCOUNT_SWITCHED: 'Account Switched',
NAV_NETWORK_SWITCHED: 'Network Switched',
NAV_BUY_BUTTON_CLICKED: 'Buy Button Clicked',
NAV_SEND_BUTTON_CLICKED: 'Send Button Clicked',
NAV_SWAP_BUTTON_CLICKED: 'Swap Button Clicked',
NEW_WALLET_CREATED: 'New Wallet Created', NEW_WALLET_CREATED: 'New Wallet Created',
NEW_WALLET_IMPORTED: 'New Wallet Imported', NEW_WALLET_IMPORTED: 'New Wallet Imported',
NFT_ADDED: 'NFT Added', NFT_ADDED: 'NFT Added',
ONRAMP_PROVIDER_SELECTED: 'On-ramp Provider Selected',
PERMISSIONS_APPROVED: 'Permissions Approved', PERMISSIONS_APPROVED: 'Permissions Approved',
PERMISSIONS_REJECTED: 'Permissions Rejected', PERMISSIONS_REJECTED: 'Permissions Rejected',
PERMISSIONS_REQUESTED: 'Permissions Requested', PERMISSIONS_REQUESTED: 'Permissions Requested',
PUBLIC_ADDRESS_COPIED: 'Public Address Copied',
PROVIDER_METHOD_CALLED: 'Provider Method Called', PROVIDER_METHOD_CALLED: 'Provider Method Called',
SIGNATURE_APPROVED: 'Signature Approved', SIGNATURE_APPROVED: 'Signature Approved',
SIGNATURE_REJECTED: 'Signature Rejected', SIGNATURE_REJECTED: 'Signature Rejected',
SIGNATURE_REQUESTED: 'Signature Requested', SIGNATURE_REQUESTED: 'Signature Requested',
TOKEN_IMPORT_BUTTON_CLICKED: 'Import Token Button Clicked',
TOKEN_SCREEN_OPENED: 'Token Screen Opened',
SUPPORT_LINK_CLICKED: 'Support Link Clicked', SUPPORT_LINK_CLICKED: 'Support Link Clicked',
TOKEN_ADDED: 'Token Added', TOKEN_ADDED: 'Token Added',
TOKEN_DETECTED: 'Token Detected', TOKEN_DETECTED: 'Token Detected',
@ -304,6 +334,16 @@ export const EVENT_NAMES = {
}; };
export const EVENT = { export const EVENT = {
ACCOUNT_TYPES: {
DEFAULT: 'metamask',
IMPORTED: 'imported',
HARDWARE: 'hardware',
},
ACCOUNT_IMPORT_TYPES: {
JSON: 'json',
PRIVATE_KEY: 'private_key',
SRP: 'srp',
},
CATEGORIES: { CATEGORIES: {
ACCOUNTS: 'Accounts', ACCOUNTS: 'Accounts',
APP: 'App', APP: 'App',
@ -313,6 +353,7 @@ export const EVENT = {
FOOTER: 'Footer', FOOTER: 'Footer',
HOME: 'Home', HOME: 'Home',
INPAGE_PROVIDER: 'inpage_provider', INPAGE_PROVIDER: 'inpage_provider',
KEYS: 'Keys',
MESSAGES: 'Messages', MESSAGES: 'Messages',
NAVIGATION: 'Navigation', NAVIGATION: 'Navigation',
NETWORK: 'Network', NETWORK: 'Network',
@ -324,10 +365,22 @@ export const EVENT = {
TRANSACTIONS: 'Transactions', TRANSACTIONS: 'Transactions',
WALLET: 'Wallet', WALLET: 'Wallet',
}, },
LOCATION: { EXTERNAL_LINK_TYPES: {
TOKEN_DETAILS: 'token_details', TRANSACTION_BLOCK_EXPLORER: 'Transaction Block Explorer',
TOKEN_DETECTION: 'token_detection', BLOCK_EXPLORER: 'Block Explorer',
TOKEN_MENU: 'token_menu', ACCOUNT_TRACKER: 'Account Tracker',
TOKEN_TRACKER: 'Token Tracker',
},
KEY_TYPES: {
PKEY: 'private_key',
SRP: 'srp',
},
ONRAMP_PROVIDER_TYPES: {
COINBASE: 'coinbase',
MOONPAY: 'moonpay',
WYRE: 'wyre',
TRANSAK: 'transak',
SELF_DEPOSIT: 'direct_deposit',
}, },
SOURCE: { SOURCE: {
NETWORK: { NETWORK: {
@ -349,6 +402,11 @@ export const EVENT = {
USER: 'user', USER: 'user',
}, },
}, },
LOCATION: {
TOKEN_DETAILS: 'token_details',
TOKEN_DETECTION: 'token_detection',
TOKEN_MENU: 'token_menu',
},
}; };
// Values below (e.g. 'location') can be used in the "properties" // Values below (e.g. 'location') can be used in the "properties"

View File

@ -214,10 +214,9 @@ export default class AccountMenu extends Component {
onClick={() => { onClick={() => {
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
event: 'Switched Account', event: EVENT_NAMES.NAV_ACCOUNT_SWITCHED,
properties: { properties: {
action: 'Main Menu', location: 'Main Menu',
legacy_event: true,
}, },
}); });
showAccountDetail(identity.address); showAccountDetail(identity.address);
@ -362,10 +361,10 @@ export default class AccountMenu extends Component {
toggleAccountMenu(); toggleAccountMenu();
trackEvent({ trackEvent({
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
event: 'Clicked Create account', event: EVENT_NAMES.ACCOUNT_ADD_SELECTED,
properties: { properties: {
action: 'Main Menu', account_type: EVENT.ACCOUNT_TYPES.DEFAULT,
legacy_event: true, location: 'Main Menu',
}, },
}); });
history.push(NEW_ACCOUNT_ROUTE); history.push(NEW_ACCOUNT_ROUTE);
@ -378,10 +377,10 @@ export default class AccountMenu extends Component {
toggleAccountMenu(); toggleAccountMenu();
trackEvent({ trackEvent({
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
event: 'Clicked Import Account', event: EVENT_NAMES.ACCOUNT_ADD_SELECTED,
properties: { properties: {
action: 'Main Menu', account_type: EVENT.ACCOUNT_TYPES.IMPORTED,
legacy_event: true, location: 'Main Menu',
}, },
}); });
history.push(IMPORT_ACCOUNT_ROUTE); history.push(IMPORT_ACCOUNT_ROUTE);
@ -399,10 +398,10 @@ export default class AccountMenu extends Component {
toggleAccountMenu(); toggleAccountMenu();
trackEvent({ trackEvent({
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
event: 'Clicked Connect Hardware', event: EVENT_NAMES.ACCOUNT_ADD_SELECTED,
properties: { properties: {
action: 'Main Menu', account_type: EVENT.ACCOUNT_TYPES.HARDWARE,
legacy_event: true, location: 'Main Menu',
}, },
}); });
if (getEnvironmentType() === ENVIRONMENT_TYPE_POPUP) { if (getEnvironmentType() === ENVIRONMENT_TYPE_POPUP) {
@ -475,10 +474,9 @@ export default class AccountMenu extends Component {
history.push(SETTINGS_ROUTE); history.push(SETTINGS_ROUTE);
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
event: 'Opened Settings', event: EVENT_NAMES.NAV_SETTINGS_OPENED,
properties: { properties: {
action: 'Main Menu', location: 'Main Menu',
legacy_event: true,
}, },
}); });
}} }}

View File

@ -4,7 +4,7 @@ import classnames from 'classnames';
import Identicon from '../../ui/identicon'; import Identicon from '../../ui/identicon';
import MetaFoxLogo from '../../ui/metafox-logo'; import MetaFoxLogo from '../../ui/metafox-logo';
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes'; import { DEFAULT_ROUTE } from '../../../helpers/constants/routes';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import NetworkDisplay from '../network-display'; import NetworkDisplay from '../network-display';
export default class AppHeader extends PureComponent { export default class AppHeader extends PureComponent {
@ -50,11 +50,8 @@ export default class AppHeader extends PureComponent {
if (networkDropdownOpen === false) { if (networkDropdownOpen === false) {
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
event: 'Opened Network Menu', event: EVENT_NAMES.NAV_NETWORK_MENU_OPENED,
properties: { properties: {},
action: 'Home',
legacy_event: true,
},
}); });
showNetworkDropdown(); showNetworkDropdown();
} else { } else {
@ -85,11 +82,8 @@ export default class AppHeader extends PureComponent {
!isAccountMenuOpen && !isAccountMenuOpen &&
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
event: 'Opened Main Menu', event: EVENT_NAMES.NAV_MAIN_MENU_OPENED,
properties: { properties: {},
action: 'Home',
legacy_event: true,
},
}); });
toggleAccountMenu(); toggleAccountMenu();
} }

View File

@ -25,7 +25,7 @@ import {
} from '../../../helpers/constants/design-system'; } from '../../../helpers/constants/design-system';
import { useI18nContext } from '../../../hooks/useI18nContext'; import { useI18nContext } from '../../../hooks/useI18nContext';
import { MetaMetricsContext } from '../../../contexts/metametrics'; import { MetaMetricsContext } from '../../../contexts/metametrics';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import DetectedToken from '../detected-token/detected-token'; import DetectedToken from '../detected-token/detected-token';
import DetectedTokensLink from './detetcted-tokens-link/detected-tokens-link'; import DetectedTokensLink from './detetcted-tokens-link/detected-tokens-link';
@ -87,11 +87,11 @@ const AssetList = ({ onClickAsset }) => {
onTokenClick={(tokenAddress) => { onTokenClick={(tokenAddress) => {
onClickAsset(tokenAddress); onClickAsset(tokenAddress);
trackEvent({ trackEvent({
event: 'Clicked Token', event: EVENT_NAMES.TOKEN_SCREEN_OPENED,
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
properties: { properties: {
action: 'Token Menu', token_symbol: primaryCurrencyProperties.suffix,
legacy_event: true, location: 'Home',
}, },
}); });
}} }}

View File

@ -17,7 +17,7 @@ import { COLORS, SIZES } from '../../../helpers/constants/design-system';
import { getShowTestNetworks } from '../../../selectors'; import { getShowTestNetworks } from '../../../selectors';
import { getEnvironmentType } from '../../../../app/scripts/lib/util'; import { getEnvironmentType } from '../../../../app/scripts/lib/util';
import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app'; import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import { import {
ADD_NETWORK_ROUTE, ADD_NETWORK_ROUTE,
ADD_POPULAR_CUSTOM_NETWORK, ADD_POPULAR_CUSTOM_NETWORK,
@ -115,12 +115,10 @@ class NetworkDropdown extends Component {
trackEvent({ trackEvent({
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
event: 'Switched Networks', event: EVENT_NAMES.NAV_NETWORK_SWITCHED,
properties: { properties: {
action: 'Home', from_network: providerType,
legacy_event: true, to_network: newProviderType,
fromNetwork: providerType,
toNetwork: newProviderType,
}, },
}); });
setProviderType(newProviderType); setProviderType(newProviderType);

View File

@ -8,7 +8,7 @@ import Box from '../../ui/box/box';
import { TEXT_ALIGN } from '../../../helpers/constants/design-system'; import { TEXT_ALIGN } from '../../../helpers/constants/design-system';
import { detectNewTokens } from '../../../store/actions'; import { detectNewTokens } from '../../../store/actions';
import { MetaMetricsContext } from '../../../contexts/metametrics'; import { MetaMetricsContext } from '../../../contexts/metametrics';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import { import {
getIsTokenDetectionSupported, getIsTokenDetectionSupported,
getIsTokenDetectionInactiveOnMainnet, getIsTokenDetectionInactiveOnMainnet,
@ -51,11 +51,10 @@ export default function ImportTokenLink() {
onClick={() => { onClick={() => {
history.push(IMPORT_TOKEN_ROUTE); history.push(IMPORT_TOKEN_ROUTE);
trackEvent({ trackEvent({
event: 'Clicked "Add token"', event: EVENT_NAMES.TOKEN_IMPORT_BUTTON_CLICKED,
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
properties: { properties: {
action: 'Token Menu', location: 'Home',
legacy_event: true,
}, },
}); });
}} }}

View File

@ -21,7 +21,7 @@ import {
import { useI18nContext } from '../../../hooks/useI18nContext'; import { useI18nContext } from '../../../hooks/useI18nContext';
import { getEnvironmentType } from '../../../../app/scripts/lib/util'; import { getEnvironmentType } from '../../../../app/scripts/lib/util';
import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../shared/constants/app'; import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../shared/constants/app';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import { MetaMetricsContext } from '../../../contexts/metametrics'; import { MetaMetricsContext } from '../../../contexts/metametrics';
export default function AccountOptionsMenu({ anchorElement, onClose }) { export default function AccountOptionsMenu({ anchorElement, onClose }) {
@ -48,12 +48,12 @@ export default function AccountOptionsMenu({ anchorElement, onClose }) {
const openBlockExplorer = () => { const openBlockExplorer = () => {
trackEvent({ trackEvent({
event: 'Clicked Block Explorer Link', event: EVENT_NAMES.EXTERNAL_LINK_CLICKED,
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
properties: { properties: {
link_type: 'Account Tracker', link_type: EVENT.EXTERNAL_LINK_TYPES.ACCOUNT_TRACKER,
action: 'Account Options', location: 'Account Options',
block_explorer_domain: getURLHostName(addressLink), url_domain: getURLHostName(addressLink),
}, },
}); });
global.platform.openTab({ global.platform.openTab({
@ -94,11 +94,10 @@ export default function AccountOptionsMenu({ anchorElement, onClose }) {
<MenuItem <MenuItem
onClick={() => { onClick={() => {
trackEvent({ trackEvent({
event: 'Clicked Expand View', event: EVENT_NAMES.APP_WINDOW_EXPANDED,
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
properties: { properties: {
action: 'Account Options', location: 'Account Options',
legacy_event: true,
}, },
}); });
global.platform.openExtensionInBrowser(); global.platform.openExtensionInBrowser();
@ -114,11 +113,10 @@ export default function AccountOptionsMenu({ anchorElement, onClose }) {
onClick={() => { onClick={() => {
dispatch(showModal({ name: 'ACCOUNT_DETAILS' })); dispatch(showModal({ name: 'ACCOUNT_DETAILS' }));
trackEvent({ trackEvent({
event: 'Viewed Account Details', event: EVENT_NAMES.NAV_ACCOUNT_DETAILS_OPENED,
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
properties: { properties: {
action: 'Account Options', location: 'Account Options',
legacy_event: true,
}, },
}); });
onClose(); onClose();
@ -131,11 +129,10 @@ export default function AccountOptionsMenu({ anchorElement, onClose }) {
data-testid="account-options-menu__connected-sites" data-testid="account-options-menu__connected-sites"
onClick={() => { onClick={() => {
trackEvent({ trackEvent({
event: 'Opened Connected Sites', event: EVENT_NAMES.NAV_CONNECTED_SITES_OPENED,
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
properties: { properties: {
action: 'Account Options', location: 'Account Options',
legacy_event: true,
}, },
}); });
history.push(CONNECTED_ROUTE); history.push(CONNECTED_ROUTE);

View File

@ -6,7 +6,7 @@ import SelectedAccount from '../selected-account';
import ConnectedStatusIndicator from '../connected-status-indicator'; import ConnectedStatusIndicator from '../connected-status-indicator';
import { getEnvironmentType } from '../../../../app/scripts/lib/util'; import { getEnvironmentType } from '../../../../app/scripts/lib/util';
import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app'; import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import { CONNECTED_ACCOUNTS_ROUTE } from '../../../helpers/constants/routes'; import { CONNECTED_ACCOUNTS_ROUTE } from '../../../helpers/constants/routes';
import { useI18nContext } from '../../../hooks/useI18nContext'; import { useI18nContext } from '../../../hooks/useI18nContext';
import { getOriginOfCurrentTab } from '../../../selectors'; import { getOriginOfCurrentTab } from '../../../selectors';
@ -44,11 +44,10 @@ export default function MenuBar() {
title={t('accountOptions')} title={t('accountOptions')}
onClick={() => { onClick={() => {
trackEvent({ trackEvent({
event: 'Opened Account Options', event: EVENT_NAMES.NAV_ACCOUNT_MENU_OPENED,
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
properties: { properties: {
action: 'Home', location: 'Home',
legacy_event: true,
}, },
}); });
setAccountOptionsMenuOpen(true); setAccountOptionsMenuOpen(true);

View File

@ -8,7 +8,10 @@ import EditableLabel from '../../../ui/editable-label';
import Button from '../../../ui/button'; import Button from '../../../ui/button';
import { getURLHostName } from '../../../../helpers/utils/util'; import { getURLHostName } from '../../../../helpers/utils/util';
import { isHardwareKeyring } from '../../../../helpers/utils/hardware'; import { isHardwareKeyring } from '../../../../helpers/utils/hardware';
import { EVENT } from '../../../../../shared/constants/metametrics'; import {
EVENT,
EVENT_NAMES,
} from '../../../../../shared/constants/metametrics';
import { NETWORKS_ROUTE } from '../../../../helpers/constants/routes'; import { NETWORKS_ROUTE } from '../../../../helpers/constants/routes';
export default class AccountDetailsModal extends Component { export default class AccountDetailsModal extends Component {
@ -70,11 +73,11 @@ export default class AccountDetailsModal extends Component {
const accountLink = getAccountLink(address, chainId, rpcPrefs); const accountLink = getAccountLink(address, chainId, rpcPrefs);
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
event: 'Clicked Block Explorer Link', event: EVENT_NAMES.EXTERNAL_LINK_CLICKED,
properties: { properties: {
link_type: 'Account Tracker', link_type: EVENT.EXTERNAL_LINK_TYPES.ACCOUNT_TRACKER,
action: 'Account Details Modal', location: 'Account Details Modal',
block_explorer_domain: getURLHostName(accountLink), url_domain: getURLHostName(accountLink),
}, },
}); });
global.platform.openTab({ global.platform.openTab({
@ -120,7 +123,17 @@ export default class AccountDetailsModal extends Component {
<Button <Button
type="secondary" type="secondary"
className="account-details-modal__button" className="account-details-modal__button"
onClick={() => showExportPrivateKeyModal()} onClick={() => {
this.context.trackEvent({
category: EVENT.CATEGORIES.ACCOUNTS,
event: EVENT_NAMES.KEY_EXPORT_SELECTED,
properties: {
key_type: EVENT.KEY_TYPES.PKEY,
location: 'Account Details Modal',
},
});
showExportPrivateKeyModal();
}}
> >
{this.context.t('exportPrivateKey')} {this.context.t('exportPrivateKey')}
</Button> </Button>

View File

@ -4,7 +4,10 @@ import {
NETWORK_TO_NAME_MAP, NETWORK_TO_NAME_MAP,
BUYABLE_CHAINS_MAP, BUYABLE_CHAINS_MAP,
} from '../../../../../shared/constants/network'; } from '../../../../../shared/constants/network';
import { EVENT } from '../../../../../shared/constants/metametrics'; import {
EVENT,
EVENT_NAMES,
} from '../../../../../shared/constants/metametrics';
import Button from '../../../ui/button'; import Button from '../../../ui/button';
import LogoMoonPay from '../../../ui/logo/logo-moonpay'; import LogoMoonPay from '../../../ui/logo/logo-moonpay';
import LogoWyre from '../../../ui/logo/logo-wyre'; import LogoWyre from '../../../ui/logo/logo-wyre';
@ -144,10 +147,9 @@ export default class DepositEtherModal extends Component {
onButtonClick: () => { onButtonClick: () => {
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.ACCOUNTS, category: EVENT.CATEGORIES.ACCOUNTS,
event: 'Click buy Ether via Coinbase Pay', event: EVENT_NAMES.ONRAMP_PROVIDER_SELECTED,
properties: { properties: {
action: 'Deposit Ether', onramp_provider_type: EVENT.ONRAMP_PROVIDER_TYPES.COINBASE,
legacy_event: true,
}, },
}); });
toCoinbasePay(address, chainId); toCoinbasePay(address, chainId);
@ -162,10 +164,9 @@ export default class DepositEtherModal extends Component {
onButtonClick: () => { onButtonClick: () => {
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.ACCOUNTS, category: EVENT.CATEGORIES.ACCOUNTS,
event: 'Click buy Ether via Transak', event: EVENT_NAMES.ONRAMP_PROVIDER_SELECTED,
properties: { properties: {
action: 'Deposit Ether', onramp_provider_type: EVENT.ONRAMP_PROVIDER_TYPES.TRANSAK,
legacy_event: true,
}, },
}); });
toTransak(address, chainId); toTransak(address, chainId);
@ -180,10 +181,9 @@ export default class DepositEtherModal extends Component {
onButtonClick: () => { onButtonClick: () => {
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.ACCOUNTS, category: EVENT.CATEGORIES.ACCOUNTS,
event: 'Click buy Ether via MoonPay', event: EVENT_NAMES.ONRAMP_PROVIDER_SELECTED,
properties: { properties: {
action: 'Deposit Ether', onramp_provider_type: EVENT.ONRAMP_PROVIDER_TYPES.MOONPAY,
legacy_event: true,
}, },
}); });
toMoonPay(address, chainId); toMoonPay(address, chainId);
@ -198,10 +198,9 @@ export default class DepositEtherModal extends Component {
onButtonClick: () => { onButtonClick: () => {
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.ACCOUNTS, category: EVENT.CATEGORIES.ACCOUNTS,
event: 'Click buy Ether via Wyre', event: EVENT_NAMES.ONRAMP_PROVIDER_SELECTED,
properties: { properties: {
action: 'Deposit Ether', onramp_provider_type: EVENT.ONRAMP_PROVIDER_TYPES.WYRE,
legacy_event: true,
}, },
}); });
toWyre(address, chainId); toWyre(address, chainId);
@ -215,7 +214,17 @@ export default class DepositEtherModal extends Component {
title: t('directDepositCrypto', [symbol]), title: t('directDepositCrypto', [symbol]),
text: t('directDepositCryptoExplainer', [symbol]), text: t('directDepositCryptoExplainer', [symbol]),
buttonLabel: t('viewAccount'), buttonLabel: t('viewAccount'),
onButtonClick: () => this.goToAccountDetailsModal(), onButtonClick: () => {
this.context.trackEvent({
category: EVENT.CATEGORIES.ACCOUNTS,
event: EVENT_NAMES.ONRAMP_PROVIDER_SELECTED,
properties: {
onramp_provider_type:
EVENT.ONRAMP_PROVIDER_TYPES.SELF_DEPOSIT,
},
});
this.goToAccountDetailsModal();
},
})} })}
{networkName && {networkName &&
this.renderRow({ this.renderRow({

View File

@ -7,10 +7,15 @@ import copyToClipboard from 'copy-to-clipboard';
import Button from '../../../ui/button'; import Button from '../../../ui/button';
import AccountModalContainer from '../account-modal-container'; import AccountModalContainer from '../account-modal-container';
import { toChecksumHexAddress } from '../../../../../shared/modules/hexstring-utils'; import { toChecksumHexAddress } from '../../../../../shared/modules/hexstring-utils';
import {
EVENT,
EVENT_NAMES,
} from '../../../../../shared/constants/metametrics';
export default class ExportPrivateKeyModal extends Component { export default class ExportPrivateKeyModal extends Component {
static contextTypes = { static contextTypes = {
t: PropTypes.func, t: PropTypes.func,
trackEvent: PropTypes.func,
}; };
static defaultProps = { static defaultProps = {
@ -44,13 +49,32 @@ export default class ExportPrivateKeyModal extends Component {
const { exportAccount } = this.props; const { exportAccount } = this.props;
exportAccount(password, address) exportAccount(password, address)
.then((privateKey) => .then((privateKey) => {
this.context.trackEvent({
category: EVENT.CATEGORIES.KEYS,
event: EVENT_NAMES.KEY_EXPORT_REVEALED,
properties: {
key_type: EVENT.KEY_TYPES.PKEY,
},
});
this.setState({ this.setState({
privateKey, privateKey,
showWarning: false, showWarning: false,
}), });
) })
.catch((e) => log.error(e)); .catch((e) => {
this.context.trackEvent({
category: EVENT.CATEGORIES.KEYS,
event: EVENT_NAMES.KEY_EXPORT_FAILED,
properties: {
key_type: EVENT.KEY_TYPES.PKEY,
reason: 'incorrect_password',
},
});
log.error(e);
});
}; };
renderPasswordLabel(privateKey) { renderPasswordLabel(privateKey) {
@ -79,7 +103,17 @@ export default class ExportPrivateKeyModal extends Component {
return ( return (
<div <div
className="export-private-key-modal__private-key-display" className="export-private-key-modal__private-key-display"
onClick={() => copyToClipboard(plainKey)} onClick={() => {
copyToClipboard(plainKey);
this.context.trackEvent({
category: EVENT.CATEGORIES.KEYS,
event: EVENT_NAMES.KEY_EXPORT_COPIED,
properties: {
key_type: EVENT.KEY_TYPES.PKEY,
copy_method: 'clipboard',
},
});
}}
> >
{plainKey} {plainKey}
</div> </div>
@ -94,14 +128,25 @@ export default class ExportPrivateKeyModal extends Component {
type="secondary" type="secondary"
large large
className="export-private-key-modal__button export-private-key-modal__button--cancel" className="export-private-key-modal__button export-private-key-modal__button--cancel"
onClick={() => hideModal()} onClick={() => {
this.context.trackEvent({
category: EVENT.CATEGORIES.KEYS,
event: EVENT_NAMES.KEY_EXPORT_CANCELED,
properties: {
key_type: EVENT.KEY_TYPES.PKEY,
},
});
hideModal();
}}
> >
{this.context.t('cancel')} {this.context.t('cancel')}
</Button> </Button>
)} )}
{privateKey ? ( {privateKey ? (
<Button <Button
onClick={() => hideModal()} onClick={() => {
hideModal();
}}
type="primary" type="primary"
large large
className="export-private-key-modal__button" className="export-private-key-modal__button"
@ -110,9 +155,17 @@ export default class ExportPrivateKeyModal extends Component {
</Button> </Button>
) : ( ) : (
<Button <Button
onClick={() => onClick={() => {
this.exportAccountAndGetPrivateKey(this.state.password, address) this.context.trackEvent({
} category: EVENT.CATEGORIES.KEYS,
event: EVENT_NAMES.KEY_EXPORT_REQUESTED,
properties: {
key_type: EVENT.KEY_TYPES.PKEY,
},
});
this.exportAccountAndGetPrivateKey(this.state.password, address);
}}
type="primary" type="primary"
large large
className="export-private-key-modal__button" className="export-private-key-modal__button"

View File

@ -31,7 +31,7 @@ import { setSwapsFromToken } from '../../../ducks/swaps/swaps';
import IconButton from '../../ui/icon-button'; import IconButton from '../../ui/icon-button';
import { isHardwareKeyring } from '../../../helpers/utils/hardware'; import { isHardwareKeyring } from '../../../helpers/utils/hardware';
import { MetaMetricsContext } from '../../../contexts/metametrics'; import { MetaMetricsContext } from '../../../contexts/metametrics';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import Spinner from '../../ui/spinner'; import Spinner from '../../ui/spinner';
import { startNewDraftTransaction } from '../../../ducks/send'; import { startNewDraftTransaction } from '../../../ducks/send';
import { ASSET_TYPES } from '../../../../shared/constants/transaction'; import { ASSET_TYPES } from '../../../../shared/constants/transaction';
@ -109,11 +109,11 @@ const EthOverview = ({ className }) => {
label={t('buy')} label={t('buy')}
onClick={() => { onClick={() => {
trackEvent({ trackEvent({
event: 'Clicked Deposit', event: EVENT_NAMES.NAV_BUY_BUTTON_CLICKED,
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
properties: { properties: {
action: 'Home', location: 'Home',
legacy_event: true, text: 'Buy',
}, },
}); });
dispatch(showModal({ name: 'DEPOSIT_ETHER' })); dispatch(showModal({ name: 'DEPOSIT_ETHER' }));
@ -126,11 +126,12 @@ const EthOverview = ({ className }) => {
label={t('send')} label={t('send')}
onClick={() => { onClick={() => {
trackEvent({ trackEvent({
event: 'Clicked Send: Eth', event: EVENT_NAMES.NAV_SEND_BUTTON_CLICKED,
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
properties: { properties: {
action: 'Home', token_symbol: 'ETH',
legacy_event: true, location: 'Home',
text: 'Send',
}, },
}); });
dispatch( dispatch(
@ -147,11 +148,12 @@ const EthOverview = ({ className }) => {
onClick={() => { onClick={() => {
if (isSwapsChain) { if (isSwapsChain) {
trackEvent({ trackEvent({
event: 'Swaps Opened', event: EVENT_NAMES.NAV_SWAP_BUTTON_CLICKED,
category: EVENT.CATEGORIES.SWAPS, category: EVENT.CATEGORIES.SWAPS,
properties: { properties: {
source: EVENT.SOURCE.SWAPS.MAIN_VIEW, token_symbol: 'ETH',
active_currency: 'ETH', location: EVENT.SOURCE.SWAPS.MAIN_VIEW,
text: 'Swap',
}, },
}); });
dispatch(setSwapsFromToken(defaultSwapsToken)); dispatch(setSwapsFromToken(defaultSwapsToken));

View File

@ -28,7 +28,7 @@ import IconButton from '../../ui/icon-button';
import { INVALID_ASSET_TYPE } from '../../../helpers/constants/error-keys'; import { INVALID_ASSET_TYPE } from '../../../helpers/constants/error-keys';
import { showModal } from '../../../store/actions'; import { showModal } from '../../../store/actions';
import { MetaMetricsContext } from '../../../contexts/metametrics'; import { MetaMetricsContext } from '../../../contexts/metametrics';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import { ASSET_TYPES } from '../../../../shared/constants/transaction'; import { ASSET_TYPES } from '../../../../shared/constants/transaction';
import WalletOverview from './wallet-overview'; import WalletOverview from './wallet-overview';
@ -84,11 +84,12 @@ const TokenOverview = ({ className, token }) => {
className="token-overview__button" className="token-overview__button"
onClick={async () => { onClick={async () => {
trackEvent({ trackEvent({
event: 'Clicked Send: Token', event: EVENT_NAMES.NAV_SEND_BUTTON_CLICKED,
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
properties: { properties: {
action: 'Home', token_symbol: token.symbol,
legacy_event: true, location: EVENT.SOURCE.SWAPS.TOKEN_VIEW,
text: 'Send',
}, },
}); });
try { try {
@ -117,11 +118,12 @@ const TokenOverview = ({ className, token }) => {
onClick={() => { onClick={() => {
if (isSwapsChain) { if (isSwapsChain) {
trackEvent({ trackEvent({
event: 'Swaps Opened', event: EVENT_NAMES.NAV_SWAP_BUTTON_CLICKED,
category: EVENT.CATEGORIES.SWAPS, category: EVENT.CATEGORIES.SWAPS,
properties: { properties: {
source: EVENT.SOURCE.SWAPS.TOKEN_VIEW, token_symbol: token.symbol,
active_currency: token.symbol, location: EVENT.SOURCE.SWAPS.TOKEN_VIEW,
text: 'Swap',
}, },
}); });
dispatch( dispatch(

View File

@ -5,7 +5,11 @@ import { useI18nContext } from '../../../hooks/useI18nContext';
import { useCopyToClipboard } from '../../../hooks/useCopyToClipboard'; import { useCopyToClipboard } from '../../../hooks/useCopyToClipboard';
import { exportAsFile } from '../../../../shared/modules/export-utils'; import { exportAsFile } from '../../../../shared/modules/export-utils';
function ExportTextContainer({ text = '' }) { function ExportTextContainer({
text = '',
onClickCopy = null,
onClickDownload = null,
}) {
const t = useI18nContext(); const t = useI18nContext();
const [copied, handleCopy] = useCopyToClipboard(); const [copied, handleCopy] = useCopyToClipboard();
@ -18,6 +22,9 @@ function ExportTextContainer({ text = '' }) {
<div <div
className="export-text-container__button export-text-container__button--copy" className="export-text-container__button export-text-container__button--copy"
onClick={() => { onClick={() => {
if (onClickCopy) {
onClickCopy();
}
handleCopy(text); handleCopy(text);
}} }}
> >
@ -28,7 +35,12 @@ function ExportTextContainer({ text = '' }) {
</div> </div>
<div <div
className="export-text-container__button" className="export-text-container__button"
onClick={() => exportAsFile('', text)} onClick={() => {
if (onClickDownload) {
onClickDownload();
}
exportAsFile('', text);
}}
> >
<img src="images/download.svg" alt="" /> <img src="images/download.svg" alt="" />
<div className="export-text-container__button-text"> <div className="export-text-container__button-text">
@ -42,6 +54,8 @@ function ExportTextContainer({ text = '' }) {
ExportTextContainer.propTypes = { ExportTextContainer.propTypes = {
text: PropTypes.string, text: PropTypes.string,
onClickCopy: PropTypes.func,
onClickDownload: PropTypes.func,
}; };
export default React.memo(ExportTextContainer); export default React.memo(ExportTextContainer);

View File

@ -10,7 +10,7 @@ import {
} from '../../../selectors'; } from '../../../selectors';
import { formatBalance } from '../../../helpers/utils/util'; import { formatBalance } from '../../../helpers/utils/util';
import { getMostRecentOverviewPage } from '../../../ducks/history/history'; import { getMostRecentOverviewPage } from '../../../ducks/history/history';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import { SECOND } from '../../../../shared/constants/time'; import { SECOND } from '../../../../shared/constants/time';
import { import {
DEVICE_NAMES, DEVICE_NAMES,
@ -253,10 +253,10 @@ class ConnectHardwareForm extends Component {
.then((_) => { .then((_) => {
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.ACCOUNTS, category: EVENT.CATEGORIES.ACCOUNTS,
event: `Connected Account with: ${device}`, event: EVENT_NAMES.ACCOUNT_ADDED,
properties: { properties: {
action: 'Connected Hardware Wallet', account_type: EVENT.ACCOUNT_TYPES.HARDWARE,
legacy_event: true, account_hardware_type: device,
}, },
}); });
history.push(mostRecentOverviewPage); history.push(mostRecentOverviewPage);
@ -264,10 +264,10 @@ class ConnectHardwareForm extends Component {
.catch((e) => { .catch((e) => {
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.ACCOUNTS, category: EVENT.CATEGORIES.ACCOUNTS,
event: 'Error connecting hardware wallet', event: EVENT_NAMES.ACCOUNT_ADD_FAILED,
properties: { properties: {
action: 'Connected Hardware Wallet', account_type: EVENT.ACCOUNT_TYPES.HARDWARE,
legacy_event: true, account_hardware_type: device,
error: e.message, error: e.message,
}, },
}); });

View File

@ -7,7 +7,7 @@ import FileInput from 'react-simple-file-input';
import * as actions from '../../../store/actions'; import * as actions from '../../../store/actions';
import { getMetaMaskAccounts } from '../../../selectors'; import { getMetaMaskAccounts } from '../../../selectors';
import Button from '../../../components/ui/button'; import Button from '../../../components/ui/button';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import { getMostRecentOverviewPage } from '../../../ducks/history/history'; import { getMostRecentOverviewPage } from '../../../ducks/history/history';
const HELP_LINK = const HELP_LINK =
@ -119,10 +119,10 @@ class JsonImportSubview extends Component {
history.push(mostRecentOverviewPage); history.push(mostRecentOverviewPage);
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.ACCOUNTS, category: EVENT.CATEGORIES.ACCOUNTS,
event: 'Imported Account with JSON', event: EVENT_NAMES.ACCOUNT_ADDED,
properties: { properties: {
action: 'Import account', account_type: EVENT.ACCOUNT_TYPES.IMPORTED,
legacy_event: true, account_import_type: EVENT.ACCOUNT_IMPORT_TYPES.JSON,
}, },
}); });
displayWarning(null); displayWarning(null);
@ -130,10 +130,10 @@ class JsonImportSubview extends Component {
displayWarning(t('importAccountError')); displayWarning(t('importAccountError'));
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.ACCOUNTS, category: EVENT.CATEGORIES.ACCOUNTS,
event: 'Error importing JSON', event: EVENT_NAMES.ACCOUNT_ADD_FAILED,
properties: { properties: {
action: 'Import account', account_type: EVENT.ACCOUNT_TYPES.IMPORTED,
legacy_event: true, account_import_type: EVENT.ACCOUNT_IMPORT_TYPES.JSON,
}, },
}); });
setSelectedAddress(firstAddress); setSelectedAddress(firstAddress);

View File

@ -7,7 +7,7 @@ import * as actions from '../../../store/actions';
import { getMetaMaskAccounts } from '../../../selectors'; import { getMetaMaskAccounts } from '../../../selectors';
import Button from '../../../components/ui/button'; import Button from '../../../components/ui/button';
import { getMostRecentOverviewPage } from '../../../ducks/history/history'; import { getMostRecentOverviewPage } from '../../../ducks/history/history';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
class PrivateKeyImportView extends Component { class PrivateKeyImportView extends Component {
static contextTypes = { static contextTypes = {
@ -46,10 +46,10 @@ class PrivateKeyImportView extends Component {
if (selectedAddress) { if (selectedAddress) {
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.ACCOUNTS, category: EVENT.CATEGORIES.ACCOUNTS,
event: 'Imported Account with Private Key', event: EVENT_NAMES.ACCOUNT_ADDED,
properties: { properties: {
action: 'Import account', account_type: EVENT.ACCOUNT_TYPES.IMPORTED,
legacy_event: true, account_import_type: EVENT.ACCOUNT_IMPORT_TYPES.PRIVATE_KEY,
}, },
}); });
history.push(mostRecentOverviewPage); history.push(mostRecentOverviewPage);
@ -58,10 +58,10 @@ class PrivateKeyImportView extends Component {
displayWarning(t('importAccountError')); displayWarning(t('importAccountError'));
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.ACCOUNTS, category: EVENT.CATEGORIES.ACCOUNTS,
event: 'Error importing with Private Key', event: EVENT_NAMES.ACCOUNT_ADD_FAILED,
properties: { properties: {
action: 'Import account', account_type: EVENT.ACCOUNT_TYPES.IMPORTED,
legacy_event: true, account_import_type: EVENT.ACCOUNT_IMPORT_TYPES.PRIVATE_KEY,
}, },
}); });
setSelectedAddress(firstAddress); setSelectedAddress(firstAddress);

View File

@ -2,7 +2,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import classnames from 'classnames'; import classnames from 'classnames';
import Button from '../../components/ui/button'; import Button from '../../components/ui/button';
import { EVENT } from '../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../shared/constants/metametrics';
export default class NewAccountCreateForm extends Component { export default class NewAccountCreateForm extends Component {
static defaultProps = { static defaultProps = {
@ -26,10 +26,9 @@ export default class NewAccountCreateForm extends Component {
.then(() => { .then(() => {
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.ACCOUNTS, category: EVENT.CATEGORIES.ACCOUNTS,
event: 'Added New Account', event: EVENT_NAMES.ACCOUNT_ADDED,
properties: { properties: {
action: 'Add New Account', account_type: EVENT.ACCOUNT_TYPES.DEFAULT,
legacy_event: true,
}, },
}); });
history.push(mostRecentOverviewPage); history.push(mostRecentOverviewPage);
@ -37,11 +36,10 @@ export default class NewAccountCreateForm extends Component {
.catch((e) => { .catch((e) => {
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.ACCOUNTS, category: EVENT.CATEGORIES.ACCOUNTS,
event: 'Error', event: EVENT_NAMES.ACCOUNT_ADD_FAILED,
properties: { properties: {
action: 'Add New Account', account_type: EVENT.ACCOUNT_TYPES.DEFAULT,
legacy_event: true, error: e.message,
errorMessage: e.message,
}, },
}); });
}); });

View File

@ -6,7 +6,10 @@ import {
INITIALIZE_SELECT_ACTION_ROUTE, INITIALIZE_SELECT_ACTION_ROUTE,
} from '../../../../helpers/constants/routes'; } from '../../../../helpers/constants/routes';
import TextField from '../../../../components/ui/text-field'; import TextField from '../../../../components/ui/text-field';
import { EVENT } from '../../../../../shared/constants/metametrics'; import {
EVENT,
EVENT_NAMES,
} from '../../../../../shared/constants/metametrics';
export default class NewAccount extends PureComponent { export default class NewAccount extends PureComponent {
static contextTypes = { static contextTypes = {
@ -99,11 +102,8 @@ export default class NewAccount extends PureComponent {
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.ONBOARDING, category: EVENT.CATEGORIES.ONBOARDING,
event: 'Submit Password', event: EVENT_NAMES.ACCOUNT_PASSWORD_CREATED,
properties: { properties: {},
action: 'Create password',
legacy_event: true,
},
}); });
history.push(INITIALIZE_SEED_PHRASE_INTRO_ROUTE); history.push(INITIALIZE_SEED_PHRASE_INTRO_ROUTE);
@ -113,15 +113,6 @@ export default class NewAccount extends PureComponent {
}; };
toggleTermsCheck = () => { toggleTermsCheck = () => {
this.context.trackEvent({
category: EVENT.CATEGORIES.ONBOARDING,
event: 'Check ToS',
properties: {
action: 'Create password',
legacy_event: true,
},
});
this.setState((prevState) => ({ this.setState((prevState) => ({
termsChecked: !prevState.termsChecked, termsChecked: !prevState.termsChecked,
})); }));
@ -149,14 +140,6 @@ export default class NewAccount extends PureComponent {
<a <a
onClick={(e) => { onClick={(e) => {
e.preventDefault(); e.preventDefault();
this.context.trackEvent({
category: EVENT.CATEGORIES.ONBOARDING,
event: 'Go Back from Onboarding Create',
properties: {
action: 'Create password',
legacy_event: true,
},
});
this.props.history.push(INITIALIZE_SELECT_ACTION_ROUTE); this.props.history.push(INITIALIZE_SELECT_ACTION_ROUTE);
}} }}
href="#" href="#"

View File

@ -5,6 +5,7 @@ import classnames from 'classnames';
import { requestRevealSeedWords } from '../../store/actions'; import { requestRevealSeedWords } from '../../store/actions';
import ExportTextContainer from '../../components/ui/export-text-container'; import ExportTextContainer from '../../components/ui/export-text-container';
import { getMostRecentOverviewPage } from '../../ducks/history/history'; import { getMostRecentOverviewPage } from '../../ducks/history/history';
import { EVENT, EVENT_NAMES } from '../../../shared/constants/metametrics';
import Button from '../../components/ui/button'; import Button from '../../components/ui/button';
@ -31,10 +32,27 @@ class RevealSeedPage extends Component {
this.setState({ seedWords: null, error: null }); this.setState({ seedWords: null, error: null });
this.props this.props
.requestRevealSeedWords(this.state.password) .requestRevealSeedWords(this.state.password)
.then((seedWords) => .then((seedWords) => {
this.setState({ seedWords, screen: REVEAL_SEED_SCREEN }), this.context.trackEvent({
) category: EVENT.CATEGORIES.KEYS,
.catch((error) => this.setState({ error: error.message })); event: EVENT_NAMES.KEY_EXPORT_REVEALED,
properties: {
key_type: EVENT.KEY_TYPES.SRP,
},
});
this.setState({ seedWords, screen: REVEAL_SEED_SCREEN });
})
.catch((error) => {
this.context.trackEvent({
category: EVENT.CATEGORIES.KEYS,
event: EVENT_NAMES.KEY_EXPORT_FAILED,
properties: {
key_type: EVENT.KEY_TYPES.SRP,
reason: error.message, // 'incorrect_password',
},
});
this.setState({ error: error.message });
});
} }
renderWarning() { renderWarning() {
@ -87,14 +105,36 @@ class RevealSeedPage extends Component {
} }
renderRevealSeedContent() { renderRevealSeedContent() {
const { t } = this.context; const { t, trackEvent } = this.context;
return ( return (
<div> <div>
<label className="reveal-seed__label"> <label className="reveal-seed__label">
{t('yourPrivateSeedPhrase')} {t('yourPrivateSeedPhrase')}
</label> </label>
<ExportTextContainer text={this.state.seedWords} /> <ExportTextContainer
text={this.state.seedWords}
onClickCopy={() => {
trackEvent({
category: EVENT.CATEGORIES.KEYS,
event: EVENT_NAMES.KEY_EXPORT_COPIED,
properties: {
key_type: EVENT.KEY_TYPES.SRP,
copy_method: 'clipboard',
},
});
}}
onClickDownload={() => {
trackEvent({
category: EVENT.CATEGORIES.KEYS,
event: EVENT_NAMES.KEY_EXPORT_COPIED,
properties: {
key_type: EVENT.KEY_TYPES.SRP,
copy_method: 'file_download',
},
});
}}
/>
</div> </div>
); );
} }
@ -113,9 +153,16 @@ class RevealSeedPage extends Component {
type="secondary" type="secondary"
large large
className="page-container__footer-button" className="page-container__footer-button"
onClick={() => onClick={() => {
this.props.history.push(this.props.mostRecentOverviewPage) this.context.trackEvent({
} category: EVENT.CATEGORIES.KEYS,
event: EVENT_NAMES.KEY_EXPORT_CANCELED,
properties: {
key_type: EVENT.KEY_TYPES.SRP,
},
});
this.props.history.push(this.props.mostRecentOverviewPage);
}}
> >
{this.context.t('cancel')} {this.context.t('cancel')}
</Button> </Button>
@ -123,7 +170,16 @@ class RevealSeedPage extends Component {
type="primary" type="primary"
large large
className="page-container__footer-button" className="page-container__footer-button"
onClick={(event) => this.handleSubmit(event)} onClick={(event) => {
this.context.trackEvent({
category: EVENT.CATEGORIES.KEYS,
event: EVENT_NAMES.KEY_EXPORT_REQUESTED,
properties: {
key_type: EVENT.KEY_TYPES.SRP,
},
});
this.handleSubmit(event);
}}
disabled={this.state.password === ''} disabled={this.state.password === ''}
> >
{this.context.t('next')} {this.context.t('next')}
@ -179,6 +235,7 @@ RevealSeedPage.propTypes = {
RevealSeedPage.contextTypes = { RevealSeedPage.contextTypes = {
t: PropTypes.func, t: PropTypes.func,
trackEvent: PropTypes.func,
}; };
const mapStateToProps = (state) => { const mapStateToProps = (state) => {

View File

@ -30,7 +30,7 @@ import ZENDESK_URLS from '../../../helpers/constants/zendesk-url';
import { getFirstTimeFlowType } from '../../../selectors'; import { getFirstTimeFlowType } from '../../../selectors';
import { FIRST_TIME_FLOW_TYPES } from '../../../helpers/constants/onboarding'; import { FIRST_TIME_FLOW_TYPES } from '../../../helpers/constants/onboarding';
import { MetaMetricsContext } from '../../../contexts/metametrics'; import { MetaMetricsContext } from '../../../contexts/metametrics';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
export default function CreatePassword({ export default function CreatePassword({
createNewAccount, createNewAccount,
@ -140,7 +140,7 @@ export default function CreatePassword({
await createNewAccount(password); await createNewAccount(password);
} }
trackEvent({ trackEvent({
event: 'Submit Password', event: EVENT_NAMES.ACCOUNT_PASSWORD_CREATED,
category: EVENT.CATEGORIES.ONBOARDING, category: EVENT.CATEGORIES.ONBOARDING,
}); });
history.push(ONBOARDING_SECURE_YOUR_WALLET_ROUTE); history.push(ONBOARDING_SECURE_YOUR_WALLET_ROUTE);

View File

@ -20,7 +20,7 @@ import {
LEDGER_TRANSPORT_TYPES, LEDGER_TRANSPORT_TYPES,
LEDGER_USB_VENDOR_ID, LEDGER_USB_VENDOR_ID,
} from '../../../../shared/constants/hardware-wallets'; } from '../../../../shared/constants/hardware-wallets';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import { exportAsFile } from '../../../../shared/modules/export-utils'; import { exportAsFile } from '../../../../shared/modules/export-utils';
import ActionableMessage from '../../../components/ui/actionable-message'; import ActionableMessage from '../../../components/ui/actionable-message';
@ -302,11 +302,8 @@ export default class AdvancedTab extends PureComponent {
event.preventDefault(); event.preventDefault();
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.SETTINGS, category: EVENT.CATEGORIES.SETTINGS,
event: 'Reset Account', event: EVENT_NAMES.ACCOUNT_RESET,
properties: { properties: {},
action: 'Reset Account',
legacy_event: true,
},
}); });
showResetAccountConfirmationModal(); showResetAccountConfirmationModal();
}} }}

View File

@ -7,7 +7,7 @@ import {
getNumberOfSettingsInSection, getNumberOfSettingsInSection,
handleSettingsRefs, handleSettingsRefs,
} from '../../../helpers/utils/settings-search'; } from '../../../helpers/utils/settings-search';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
export default class SecurityTab extends PureComponent { export default class SecurityTab extends PureComponent {
static contextTypes = { static contextTypes = {
@ -65,10 +65,10 @@ export default class SecurityTab extends PureComponent {
event.preventDefault(); event.preventDefault();
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.SETTINGS, category: EVENT.CATEGORIES.SETTINGS,
event: 'Reveal Seed Phrase', event: EVENT_NAMES.KEY_EXPORT_SELECTED,
properties: { properties: {
action: 'Reveal Seed Phrase', key_type: EVENT.KEY_TYPES.SRP,
legacy_event: true, location: 'Settings',
}, },
}); });
history.push(REVEAL_SEED_ROUTE); history.push(REVEAL_SEED_ROUTE);

View File

@ -86,7 +86,7 @@ import {
isSwapsDefaultTokenAddress, isSwapsDefaultTokenAddress,
isSwapsDefaultTokenSymbol, isSwapsDefaultTokenSymbol,
} from '../../../../shared/modules/swaps.utils'; } from '../../../../shared/modules/swaps.utils';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import { import {
SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP, SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP,
SWAPS_CHAINID_DEFAULT_TOKEN_MAP, SWAPS_CHAINID_DEFAULT_TOKEN_MAP,
@ -485,12 +485,12 @@ export default function BuildQuote({
key="build-quote-etherscan-link" key="build-quote-etherscan-link"
onClick={() => { onClick={() => {
trackEvent({ trackEvent({
event: 'Clicked Block Explorer Link', event: EVENT_NAMES.EXTERNAL_LINK_CLICKED,
category: EVENT.CATEGORIES.SWAPS, category: EVENT.CATEGORIES.SWAPS,
properties: { properties: {
link_type: 'Token Tracker', link_type: EVENT.EXTERNAL_LINK_TYPES.TOKEN_TRACKER,
action: 'Swaps Confirmation', location: 'Swaps Confirmation',
block_explorer_domain: getURLHostName(blockExplorerTokenLink), url_domain: getURLHostName(blockExplorerTokenLink),
}, },
}); });
global.platform.openTab({ global.platform.openTab({

View File

@ -5,7 +5,7 @@ import Box from '../../../components/ui/box';
import { I18nContext } from '../../../contexts/i18n'; import { I18nContext } from '../../../contexts/i18n';
import { getURLHostName } from '../../../helpers/utils/util'; import { getURLHostName } from '../../../helpers/utils/util';
import { MetaMetricsContext } from '../../../contexts/metametrics'; import { MetaMetricsContext } from '../../../contexts/metametrics';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
export default function ViewOnBlockExplorer({ export default function ViewOnBlockExplorer({
blockExplorerUrl, blockExplorerUrl,
@ -20,13 +20,13 @@ export default function ViewOnBlockExplorer({
<button <button
onClick={() => { onClick={() => {
trackEvent({ trackEvent({
event: 'Clicked Block Explorer Link', event: EVENT_NAMES.EXTERNAL_LINK_CLICKED,
category: EVENT.CATEGORIES.SWAPS, category: EVENT.CATEGORIES.SWAPS,
sensitiveProperties: sensitiveTrackingProperties, sensitiveProperties: sensitiveTrackingProperties,
properties: { properties: {
link_type: 'Transaction Block Explorer', link_type: EVENT.EXTERNAL_LINK_TYPES.TRANSACTION_BLOCK_EXPLORER,
action: 'Swap Transaction', location: 'Swap Transaction',
block_explorer_domain: blockExplorerHostName, url_domain: blockExplorerHostName,
}, },
}); });
global.platform.openTab({ url: blockExplorerUrl }); global.platform.openTab({ url: blockExplorerUrl });

View File

@ -53,6 +53,8 @@ export default class UnlockPage extends Component {
submitting = false; submitting = false;
failed_attempts = 0;
animationEventEmitter = new EventEmitter(); animationEventEmitter = new EventEmitter();
UNSAFE_componentWillMount() { UNSAFE_componentWillMount() {
@ -83,10 +85,9 @@ export default class UnlockPage extends Component {
this.context.trackEvent( this.context.trackEvent(
{ {
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
event: 'Success', event: EVENT_NAMES.APP_UNLOCKED,
properties: { properties: {
action: 'Unlock', failed_attempts: this.failed_attempts,
legacy_event: true,
}, },
}, },
{ {
@ -101,16 +102,16 @@ export default class UnlockPage extends Component {
showOptInModal(); showOptInModal();
} }
} catch ({ message }) { } catch ({ message }) {
this.failed_attempts += 1;
if (message === 'Incorrect password') { if (message === 'Incorrect password') {
const newState = await forceUpdateMetamaskState(); await forceUpdateMetamaskState();
this.context.trackEvent({ this.context.trackEvent({
category: EVENT.CATEGORIES.NAVIGATION, category: EVENT.CATEGORIES.NAVIGATION,
event: 'Incorrect Password', event: EVENT_NAMES.APP_UNLOCKED_FAILED,
properties: { properties: {
action: 'Unlock', reason: 'incorrect_password',
legacy_event: true, failed_attempts: this.failed_attempts,
numberOfTokens: newState.tokens.length,
numberOfAccounts: Object.keys(newState.accounts).length,
}, },
}); });
} }