From 82368e7451a2ec6e3836298d9808f428646a78be Mon Sep 17 00:00:00 2001 From: John Brennan <211638+worldlyjohn@users.noreply.github.com> Date: Tue, 16 Aug 2022 09:39:23 -0700 Subject: [PATCH] Rename some events (#15543) Co-authored-by: Brad Decker --- shared/constants/metametrics.js | 72 +++++++++++++++-- .../account-menu/account-menu.component.js | 28 ++++--- .../app/app-header/app-header.component.js | 16 ++-- ui/components/app/asset-list/asset-list.js | 8 +- .../app/dropdowns/network-dropdown.js | 10 +-- .../import-token-link.component.js | 7 +- .../app/menu-bar/account-options-menu.js | 25 +++--- ui/components/app/menu-bar/menu-bar.js | 7 +- .../account-details-modal.component.js | 25 ++++-- .../deposit-ether-modal.component.js | 37 +++++---- .../export-private-key-modal.component.js | 73 +++++++++++++++--- .../app/wallet-overview/eth-overview.js | 22 +++--- .../app/wallet-overview/token-overview.js | 16 ++-- .../export-text-container.component.js | 18 ++++- .../create-account/connect-hardware/index.js | 14 ++-- .../create-account/import-account/json.js | 14 ++-- .../import-account/private-key.js | 14 ++-- .../create-account/new-account.component.js | 14 ++-- .../new-account/new-account.component.js | 29 ++----- ui/pages/keychains/reveal-seed.js | 77 ++++++++++++++++--- .../create-password/create-password.js | 4 +- .../advanced-tab/advanced-tab.component.js | 9 +-- .../security-tab/security-tab.component.js | 8 +- ui/pages/swaps/build-quote/build-quote.js | 10 +-- .../view-on-block-explorer.js | 10 +-- ui/pages/unlock-page/unlock-page.component.js | 19 ++--- 26 files changed, 379 insertions(+), 207 deletions(-) diff --git a/shared/constants/metametrics.js b/shared/constants/metametrics.js index dd498f0aa..5d53e060b 100644 --- a/shared/constants/metametrics.js +++ b/shared/constants/metametrics.js @@ -278,23 +278,53 @@ export const REJECT_NOTFICIATION_CLOSE_SIG = */ 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_UNLOCKED: 'App Unlocked', + APP_UNLOCKED_FAILED: 'App Unlocked Failed', + APP_WINDOW_EXPANDED: 'App Window Expanded', DECRYPTION_APPROVED: 'Decryption Approved', DECRYPTION_REJECTED: 'Decryption Rejected', DECRYPTION_REQUESTED: 'Decryption Requested', - ENCRYPTION_PUBLIC_KEY_APPROVED: 'Encryption Public Key Approved', - ENCRYPTION_PUBLIC_KEY_REJECTED: 'Encryption Public Key Rejected', - ENCRYPTION_PUBLIC_KEY_REQUESTED: 'Encryption Public Key Requested', + ENCRYPTION_PUBLIC_KEY_APPROVED: 'Encryption Approved', + ENCRYPTION_PUBLIC_KEY_REJECTED: 'Encryption Rejected', + 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_IMPORTED: 'New Wallet Imported', NFT_ADDED: 'NFT Added', + ONRAMP_PROVIDER_SELECTED: 'On-ramp Provider Selected', PERMISSIONS_APPROVED: 'Permissions Approved', PERMISSIONS_REJECTED: 'Permissions Rejected', PERMISSIONS_REQUESTED: 'Permissions Requested', + PUBLIC_ADDRESS_COPIED: 'Public Address Copied', PROVIDER_METHOD_CALLED: 'Provider Method Called', SIGNATURE_APPROVED: 'Signature Approved', SIGNATURE_REJECTED: 'Signature Rejected', SIGNATURE_REQUESTED: 'Signature Requested', + TOKEN_IMPORT_BUTTON_CLICKED: 'Import Token Button Clicked', + TOKEN_SCREEN_OPENED: 'Token Screen Opened', SUPPORT_LINK_CLICKED: 'Support Link Clicked', TOKEN_ADDED: 'Token Added', TOKEN_DETECTED: 'Token Detected', @@ -304,6 +334,16 @@ export const EVENT_NAMES = { }; export const EVENT = { + ACCOUNT_TYPES: { + DEFAULT: 'metamask', + IMPORTED: 'imported', + HARDWARE: 'hardware', + }, + ACCOUNT_IMPORT_TYPES: { + JSON: 'json', + PRIVATE_KEY: 'private_key', + SRP: 'srp', + }, CATEGORIES: { ACCOUNTS: 'Accounts', APP: 'App', @@ -313,6 +353,7 @@ export const EVENT = { FOOTER: 'Footer', HOME: 'Home', INPAGE_PROVIDER: 'inpage_provider', + KEYS: 'Keys', MESSAGES: 'Messages', NAVIGATION: 'Navigation', NETWORK: 'Network', @@ -324,10 +365,22 @@ export const EVENT = { TRANSACTIONS: 'Transactions', WALLET: 'Wallet', }, - LOCATION: { - TOKEN_DETAILS: 'token_details', - TOKEN_DETECTION: 'token_detection', - TOKEN_MENU: 'token_menu', + EXTERNAL_LINK_TYPES: { + TRANSACTION_BLOCK_EXPLORER: 'Transaction Block Explorer', + BLOCK_EXPLORER: 'Block Explorer', + 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: { NETWORK: { @@ -349,6 +402,11 @@ export const EVENT = { 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" diff --git a/ui/components/app/account-menu/account-menu.component.js b/ui/components/app/account-menu/account-menu.component.js index 6a708e678..fbd67f923 100644 --- a/ui/components/app/account-menu/account-menu.component.js +++ b/ui/components/app/account-menu/account-menu.component.js @@ -214,10 +214,9 @@ export default class AccountMenu extends Component { onClick={() => { this.context.trackEvent({ category: EVENT.CATEGORIES.NAVIGATION, - event: 'Switched Account', + event: EVENT_NAMES.NAV_ACCOUNT_SWITCHED, properties: { - action: 'Main Menu', - legacy_event: true, + location: 'Main Menu', }, }); showAccountDetail(identity.address); @@ -362,10 +361,10 @@ export default class AccountMenu extends Component { toggleAccountMenu(); trackEvent({ category: EVENT.CATEGORIES.NAVIGATION, - event: 'Clicked Create account', + event: EVENT_NAMES.ACCOUNT_ADD_SELECTED, properties: { - action: 'Main Menu', - legacy_event: true, + account_type: EVENT.ACCOUNT_TYPES.DEFAULT, + location: 'Main Menu', }, }); history.push(NEW_ACCOUNT_ROUTE); @@ -378,10 +377,10 @@ export default class AccountMenu extends Component { toggleAccountMenu(); trackEvent({ category: EVENT.CATEGORIES.NAVIGATION, - event: 'Clicked Import Account', + event: EVENT_NAMES.ACCOUNT_ADD_SELECTED, properties: { - action: 'Main Menu', - legacy_event: true, + account_type: EVENT.ACCOUNT_TYPES.IMPORTED, + location: 'Main Menu', }, }); history.push(IMPORT_ACCOUNT_ROUTE); @@ -399,10 +398,10 @@ export default class AccountMenu extends Component { toggleAccountMenu(); trackEvent({ category: EVENT.CATEGORIES.NAVIGATION, - event: 'Clicked Connect Hardware', + event: EVENT_NAMES.ACCOUNT_ADD_SELECTED, properties: { - action: 'Main Menu', - legacy_event: true, + account_type: EVENT.ACCOUNT_TYPES.HARDWARE, + location: 'Main Menu', }, }); if (getEnvironmentType() === ENVIRONMENT_TYPE_POPUP) { @@ -475,10 +474,9 @@ export default class AccountMenu extends Component { history.push(SETTINGS_ROUTE); this.context.trackEvent({ category: EVENT.CATEGORIES.NAVIGATION, - event: 'Opened Settings', + event: EVENT_NAMES.NAV_SETTINGS_OPENED, properties: { - action: 'Main Menu', - legacy_event: true, + location: 'Main Menu', }, }); }} diff --git a/ui/components/app/app-header/app-header.component.js b/ui/components/app/app-header/app-header.component.js index 8f3fc588d..7355af677 100644 --- a/ui/components/app/app-header/app-header.component.js +++ b/ui/components/app/app-header/app-header.component.js @@ -4,7 +4,7 @@ import classnames from 'classnames'; import Identicon from '../../ui/identicon'; import MetaFoxLogo from '../../ui/metafox-logo'; 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'; export default class AppHeader extends PureComponent { @@ -50,11 +50,8 @@ export default class AppHeader extends PureComponent { if (networkDropdownOpen === false) { this.context.trackEvent({ category: EVENT.CATEGORIES.NAVIGATION, - event: 'Opened Network Menu', - properties: { - action: 'Home', - legacy_event: true, - }, + event: EVENT_NAMES.NAV_NETWORK_MENU_OPENED, + properties: {}, }); showNetworkDropdown(); } else { @@ -85,11 +82,8 @@ export default class AppHeader extends PureComponent { !isAccountMenuOpen && this.context.trackEvent({ category: EVENT.CATEGORIES.NAVIGATION, - event: 'Opened Main Menu', - properties: { - action: 'Home', - legacy_event: true, - }, + event: EVENT_NAMES.NAV_MAIN_MENU_OPENED, + properties: {}, }); toggleAccountMenu(); } diff --git a/ui/components/app/asset-list/asset-list.js b/ui/components/app/asset-list/asset-list.js index 66c882616..a55ed3677 100644 --- a/ui/components/app/asset-list/asset-list.js +++ b/ui/components/app/asset-list/asset-list.js @@ -25,7 +25,7 @@ import { } from '../../../helpers/constants/design-system'; import { useI18nContext } from '../../../hooks/useI18nContext'; 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 DetectedTokensLink from './detetcted-tokens-link/detected-tokens-link'; @@ -87,11 +87,11 @@ const AssetList = ({ onClickAsset }) => { onTokenClick={(tokenAddress) => { onClickAsset(tokenAddress); trackEvent({ - event: 'Clicked Token', + event: EVENT_NAMES.TOKEN_SCREEN_OPENED, category: EVENT.CATEGORIES.NAVIGATION, properties: { - action: 'Token Menu', - legacy_event: true, + token_symbol: primaryCurrencyProperties.suffix, + location: 'Home', }, }); }} diff --git a/ui/components/app/dropdowns/network-dropdown.js b/ui/components/app/dropdowns/network-dropdown.js index 43706675c..c6b89fe5e 100644 --- a/ui/components/app/dropdowns/network-dropdown.js +++ b/ui/components/app/dropdowns/network-dropdown.js @@ -17,7 +17,7 @@ import { COLORS, SIZES } from '../../../helpers/constants/design-system'; import { getShowTestNetworks } from '../../../selectors'; import { getEnvironmentType } from '../../../../app/scripts/lib/util'; import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app'; -import { EVENT } from '../../../../shared/constants/metametrics'; +import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics'; import { ADD_NETWORK_ROUTE, ADD_POPULAR_CUSTOM_NETWORK, @@ -115,12 +115,10 @@ class NetworkDropdown extends Component { trackEvent({ category: EVENT.CATEGORIES.NAVIGATION, - event: 'Switched Networks', + event: EVENT_NAMES.NAV_NETWORK_SWITCHED, properties: { - action: 'Home', - legacy_event: true, - fromNetwork: providerType, - toNetwork: newProviderType, + from_network: providerType, + to_network: newProviderType, }, }); setProviderType(newProviderType); diff --git a/ui/components/app/import-token-link/import-token-link.component.js b/ui/components/app/import-token-link/import-token-link.component.js index 08473b387..6f5e93a1b 100644 --- a/ui/components/app/import-token-link/import-token-link.component.js +++ b/ui/components/app/import-token-link/import-token-link.component.js @@ -8,7 +8,7 @@ import Box from '../../ui/box/box'; import { TEXT_ALIGN } from '../../../helpers/constants/design-system'; import { detectNewTokens } from '../../../store/actions'; import { MetaMetricsContext } from '../../../contexts/metametrics'; -import { EVENT } from '../../../../shared/constants/metametrics'; +import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics'; import { getIsTokenDetectionSupported, getIsTokenDetectionInactiveOnMainnet, @@ -51,11 +51,10 @@ export default function ImportTokenLink() { onClick={() => { history.push(IMPORT_TOKEN_ROUTE); trackEvent({ - event: 'Clicked "Add token"', + event: EVENT_NAMES.TOKEN_IMPORT_BUTTON_CLICKED, category: EVENT.CATEGORIES.NAVIGATION, properties: { - action: 'Token Menu', - legacy_event: true, + location: 'Home', }, }); }} diff --git a/ui/components/app/menu-bar/account-options-menu.js b/ui/components/app/menu-bar/account-options-menu.js index 2d8a22826..5ab170ece 100644 --- a/ui/components/app/menu-bar/account-options-menu.js +++ b/ui/components/app/menu-bar/account-options-menu.js @@ -21,7 +21,7 @@ import { import { useI18nContext } from '../../../hooks/useI18nContext'; import { getEnvironmentType } from '../../../../app/scripts/lib/util'; 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'; export default function AccountOptionsMenu({ anchorElement, onClose }) { @@ -48,12 +48,12 @@ export default function AccountOptionsMenu({ anchorElement, onClose }) { const openBlockExplorer = () => { trackEvent({ - event: 'Clicked Block Explorer Link', + event: EVENT_NAMES.EXTERNAL_LINK_CLICKED, category: EVENT.CATEGORIES.NAVIGATION, properties: { - link_type: 'Account Tracker', - action: 'Account Options', - block_explorer_domain: getURLHostName(addressLink), + link_type: EVENT.EXTERNAL_LINK_TYPES.ACCOUNT_TRACKER, + location: 'Account Options', + url_domain: getURLHostName(addressLink), }, }); global.platform.openTab({ @@ -94,11 +94,10 @@ export default function AccountOptionsMenu({ anchorElement, onClose }) { { trackEvent({ - event: 'Clicked Expand View', + event: EVENT_NAMES.APP_WINDOW_EXPANDED, category: EVENT.CATEGORIES.NAVIGATION, properties: { - action: 'Account Options', - legacy_event: true, + location: 'Account Options', }, }); global.platform.openExtensionInBrowser(); @@ -114,11 +113,10 @@ export default function AccountOptionsMenu({ anchorElement, onClose }) { onClick={() => { dispatch(showModal({ name: 'ACCOUNT_DETAILS' })); trackEvent({ - event: 'Viewed Account Details', + event: EVENT_NAMES.NAV_ACCOUNT_DETAILS_OPENED, category: EVENT.CATEGORIES.NAVIGATION, properties: { - action: 'Account Options', - legacy_event: true, + location: 'Account Options', }, }); onClose(); @@ -131,11 +129,10 @@ export default function AccountOptionsMenu({ anchorElement, onClose }) { data-testid="account-options-menu__connected-sites" onClick={() => { trackEvent({ - event: 'Opened Connected Sites', + event: EVENT_NAMES.NAV_CONNECTED_SITES_OPENED, category: EVENT.CATEGORIES.NAVIGATION, properties: { - action: 'Account Options', - legacy_event: true, + location: 'Account Options', }, }); history.push(CONNECTED_ROUTE); diff --git a/ui/components/app/menu-bar/menu-bar.js b/ui/components/app/menu-bar/menu-bar.js index ba69dd3dc..79899eba5 100644 --- a/ui/components/app/menu-bar/menu-bar.js +++ b/ui/components/app/menu-bar/menu-bar.js @@ -6,7 +6,7 @@ import SelectedAccount from '../selected-account'; import ConnectedStatusIndicator from '../connected-status-indicator'; import { getEnvironmentType } from '../../../../app/scripts/lib/util'; 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 { useI18nContext } from '../../../hooks/useI18nContext'; import { getOriginOfCurrentTab } from '../../../selectors'; @@ -44,11 +44,10 @@ export default function MenuBar() { title={t('accountOptions')} onClick={() => { trackEvent({ - event: 'Opened Account Options', + event: EVENT_NAMES.NAV_ACCOUNT_MENU_OPENED, category: EVENT.CATEGORIES.NAVIGATION, properties: { - action: 'Home', - legacy_event: true, + location: 'Home', }, }); setAccountOptionsMenuOpen(true); diff --git a/ui/components/app/modals/account-details-modal/account-details-modal.component.js b/ui/components/app/modals/account-details-modal/account-details-modal.component.js index 2c5040027..240acd37a 100644 --- a/ui/components/app/modals/account-details-modal/account-details-modal.component.js +++ b/ui/components/app/modals/account-details-modal/account-details-modal.component.js @@ -8,7 +8,10 @@ import EditableLabel from '../../../ui/editable-label'; import Button from '../../../ui/button'; import { getURLHostName } from '../../../../helpers/utils/util'; 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'; export default class AccountDetailsModal extends Component { @@ -70,11 +73,11 @@ export default class AccountDetailsModal extends Component { const accountLink = getAccountLink(address, chainId, rpcPrefs); this.context.trackEvent({ category: EVENT.CATEGORIES.NAVIGATION, - event: 'Clicked Block Explorer Link', + event: EVENT_NAMES.EXTERNAL_LINK_CLICKED, properties: { - link_type: 'Account Tracker', - action: 'Account Details Modal', - block_explorer_domain: getURLHostName(accountLink), + link_type: EVENT.EXTERNAL_LINK_TYPES.ACCOUNT_TRACKER, + location: 'Account Details Modal', + url_domain: getURLHostName(accountLink), }, }); global.platform.openTab({ @@ -120,7 +123,17 @@ export default class AccountDetailsModal extends Component { diff --git a/ui/components/app/modals/deposit-ether-modal/deposit-ether-modal.component.js b/ui/components/app/modals/deposit-ether-modal/deposit-ether-modal.component.js index 561932fa1..435ebf2a1 100644 --- a/ui/components/app/modals/deposit-ether-modal/deposit-ether-modal.component.js +++ b/ui/components/app/modals/deposit-ether-modal/deposit-ether-modal.component.js @@ -4,7 +4,10 @@ import { NETWORK_TO_NAME_MAP, BUYABLE_CHAINS_MAP, } from '../../../../../shared/constants/network'; -import { EVENT } from '../../../../../shared/constants/metametrics'; +import { + EVENT, + EVENT_NAMES, +} from '../../../../../shared/constants/metametrics'; import Button from '../../../ui/button'; import LogoMoonPay from '../../../ui/logo/logo-moonpay'; import LogoWyre from '../../../ui/logo/logo-wyre'; @@ -144,10 +147,9 @@ export default class DepositEtherModal extends Component { onButtonClick: () => { this.context.trackEvent({ category: EVENT.CATEGORIES.ACCOUNTS, - event: 'Click buy Ether via Coinbase Pay', + event: EVENT_NAMES.ONRAMP_PROVIDER_SELECTED, properties: { - action: 'Deposit Ether', - legacy_event: true, + onramp_provider_type: EVENT.ONRAMP_PROVIDER_TYPES.COINBASE, }, }); toCoinbasePay(address, chainId); @@ -162,10 +164,9 @@ export default class DepositEtherModal extends Component { onButtonClick: () => { this.context.trackEvent({ category: EVENT.CATEGORIES.ACCOUNTS, - event: 'Click buy Ether via Transak', + event: EVENT_NAMES.ONRAMP_PROVIDER_SELECTED, properties: { - action: 'Deposit Ether', - legacy_event: true, + onramp_provider_type: EVENT.ONRAMP_PROVIDER_TYPES.TRANSAK, }, }); toTransak(address, chainId); @@ -180,10 +181,9 @@ export default class DepositEtherModal extends Component { onButtonClick: () => { this.context.trackEvent({ category: EVENT.CATEGORIES.ACCOUNTS, - event: 'Click buy Ether via MoonPay', + event: EVENT_NAMES.ONRAMP_PROVIDER_SELECTED, properties: { - action: 'Deposit Ether', - legacy_event: true, + onramp_provider_type: EVENT.ONRAMP_PROVIDER_TYPES.MOONPAY, }, }); toMoonPay(address, chainId); @@ -198,10 +198,9 @@ export default class DepositEtherModal extends Component { onButtonClick: () => { this.context.trackEvent({ category: EVENT.CATEGORIES.ACCOUNTS, - event: 'Click buy Ether via Wyre', + event: EVENT_NAMES.ONRAMP_PROVIDER_SELECTED, properties: { - action: 'Deposit Ether', - legacy_event: true, + onramp_provider_type: EVENT.ONRAMP_PROVIDER_TYPES.WYRE, }, }); toWyre(address, chainId); @@ -215,7 +214,17 @@ export default class DepositEtherModal extends Component { title: t('directDepositCrypto', [symbol]), text: t('directDepositCryptoExplainer', [symbol]), 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 && this.renderRow({ diff --git a/ui/components/app/modals/export-private-key-modal/export-private-key-modal.component.js b/ui/components/app/modals/export-private-key-modal/export-private-key-modal.component.js index 2b5cb0acb..73c5280b6 100644 --- a/ui/components/app/modals/export-private-key-modal/export-private-key-modal.component.js +++ b/ui/components/app/modals/export-private-key-modal/export-private-key-modal.component.js @@ -7,10 +7,15 @@ import copyToClipboard from 'copy-to-clipboard'; import Button from '../../../ui/button'; import AccountModalContainer from '../account-modal-container'; import { toChecksumHexAddress } from '../../../../../shared/modules/hexstring-utils'; +import { + EVENT, + EVENT_NAMES, +} from '../../../../../shared/constants/metametrics'; export default class ExportPrivateKeyModal extends Component { static contextTypes = { t: PropTypes.func, + trackEvent: PropTypes.func, }; static defaultProps = { @@ -44,13 +49,32 @@ export default class ExportPrivateKeyModal extends Component { const { exportAccount } = this.props; 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({ privateKey, 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) { @@ -79,7 +103,17 @@ export default class ExportPrivateKeyModal extends Component { return (
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}
@@ -94,14 +128,25 @@ export default class ExportPrivateKeyModal extends Component { type="secondary" large 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')} )} {privateKey ? ( ) : ( @@ -123,7 +170,16 @@ class RevealSeedPage extends Component { type="primary" large 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 === ''} > {this.context.t('next')} @@ -179,6 +235,7 @@ RevealSeedPage.propTypes = { RevealSeedPage.contextTypes = { t: PropTypes.func, + trackEvent: PropTypes.func, }; const mapStateToProps = (state) => { diff --git a/ui/pages/onboarding-flow/create-password/create-password.js b/ui/pages/onboarding-flow/create-password/create-password.js index 0bb23a96d..dd2ce1989 100644 --- a/ui/pages/onboarding-flow/create-password/create-password.js +++ b/ui/pages/onboarding-flow/create-password/create-password.js @@ -30,7 +30,7 @@ import ZENDESK_URLS from '../../../helpers/constants/zendesk-url'; import { getFirstTimeFlowType } from '../../../selectors'; import { FIRST_TIME_FLOW_TYPES } from '../../../helpers/constants/onboarding'; import { MetaMetricsContext } from '../../../contexts/metametrics'; -import { EVENT } from '../../../../shared/constants/metametrics'; +import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics'; export default function CreatePassword({ createNewAccount, @@ -140,7 +140,7 @@ export default function CreatePassword({ await createNewAccount(password); } trackEvent({ - event: 'Submit Password', + event: EVENT_NAMES.ACCOUNT_PASSWORD_CREATED, category: EVENT.CATEGORIES.ONBOARDING, }); history.push(ONBOARDING_SECURE_YOUR_WALLET_ROUTE); diff --git a/ui/pages/settings/advanced-tab/advanced-tab.component.js b/ui/pages/settings/advanced-tab/advanced-tab.component.js index 1f33b4fda..2301c7904 100644 --- a/ui/pages/settings/advanced-tab/advanced-tab.component.js +++ b/ui/pages/settings/advanced-tab/advanced-tab.component.js @@ -20,7 +20,7 @@ import { LEDGER_TRANSPORT_TYPES, LEDGER_USB_VENDOR_ID, } 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 ActionableMessage from '../../../components/ui/actionable-message'; @@ -302,11 +302,8 @@ export default class AdvancedTab extends PureComponent { event.preventDefault(); this.context.trackEvent({ category: EVENT.CATEGORIES.SETTINGS, - event: 'Reset Account', - properties: { - action: 'Reset Account', - legacy_event: true, - }, + event: EVENT_NAMES.ACCOUNT_RESET, + properties: {}, }); showResetAccountConfirmationModal(); }} diff --git a/ui/pages/settings/security-tab/security-tab.component.js b/ui/pages/settings/security-tab/security-tab.component.js index fefd932c4..47edcded2 100644 --- a/ui/pages/settings/security-tab/security-tab.component.js +++ b/ui/pages/settings/security-tab/security-tab.component.js @@ -7,7 +7,7 @@ import { getNumberOfSettingsInSection, handleSettingsRefs, } 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 { static contextTypes = { @@ -65,10 +65,10 @@ export default class SecurityTab extends PureComponent { event.preventDefault(); this.context.trackEvent({ category: EVENT.CATEGORIES.SETTINGS, - event: 'Reveal Seed Phrase', + event: EVENT_NAMES.KEY_EXPORT_SELECTED, properties: { - action: 'Reveal Seed Phrase', - legacy_event: true, + key_type: EVENT.KEY_TYPES.SRP, + location: 'Settings', }, }); history.push(REVEAL_SEED_ROUTE); diff --git a/ui/pages/swaps/build-quote/build-quote.js b/ui/pages/swaps/build-quote/build-quote.js index af4ba4aa6..be697748e 100644 --- a/ui/pages/swaps/build-quote/build-quote.js +++ b/ui/pages/swaps/build-quote/build-quote.js @@ -86,7 +86,7 @@ import { isSwapsDefaultTokenAddress, isSwapsDefaultTokenSymbol, } from '../../../../shared/modules/swaps.utils'; -import { EVENT } from '../../../../shared/constants/metametrics'; +import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics'; import { SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP, SWAPS_CHAINID_DEFAULT_TOKEN_MAP, @@ -485,12 +485,12 @@ export default function BuildQuote({ key="build-quote-etherscan-link" onClick={() => { trackEvent({ - event: 'Clicked Block Explorer Link', + event: EVENT_NAMES.EXTERNAL_LINK_CLICKED, category: EVENT.CATEGORIES.SWAPS, properties: { - link_type: 'Token Tracker', - action: 'Swaps Confirmation', - block_explorer_domain: getURLHostName(blockExplorerTokenLink), + link_type: EVENT.EXTERNAL_LINK_TYPES.TOKEN_TRACKER, + location: 'Swaps Confirmation', + url_domain: getURLHostName(blockExplorerTokenLink), }, }); global.platform.openTab({ diff --git a/ui/pages/swaps/view-on-block-explorer/view-on-block-explorer.js b/ui/pages/swaps/view-on-block-explorer/view-on-block-explorer.js index 145ca010f..534e3f4a4 100644 --- a/ui/pages/swaps/view-on-block-explorer/view-on-block-explorer.js +++ b/ui/pages/swaps/view-on-block-explorer/view-on-block-explorer.js @@ -5,7 +5,7 @@ import Box from '../../../components/ui/box'; import { I18nContext } from '../../../contexts/i18n'; import { getURLHostName } from '../../../helpers/utils/util'; import { MetaMetricsContext } from '../../../contexts/metametrics'; -import { EVENT } from '../../../../shared/constants/metametrics'; +import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics'; export default function ViewOnBlockExplorer({ blockExplorerUrl, @@ -20,13 +20,13 @@ export default function ViewOnBlockExplorer({