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 = {
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"

View File

@ -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',
},
});
}}

View File

@ -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();
}

View File

@ -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',
},
});
}}

View File

@ -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);

View File

@ -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',
},
});
}}

View File

@ -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 }) {
<MenuItem
onClick={() => {
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);

View File

@ -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);

View File

@ -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 {
<Button
type="secondary"
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')}
</Button>

View File

@ -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({

View File

@ -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 (
<div
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}
</div>
@ -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')}
</Button>
)}
{privateKey ? (
<Button
onClick={() => hideModal()}
onClick={() => {
hideModal();
}}
type="primary"
large
className="export-private-key-modal__button"
@ -110,9 +155,17 @@ export default class ExportPrivateKeyModal extends Component {
</Button>
) : (
<Button
onClick={() =>
this.exportAccountAndGetPrivateKey(this.state.password, address)
}
onClick={() => {
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"
large
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 { isHardwareKeyring } from '../../../helpers/utils/hardware';
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 { startNewDraftTransaction } from '../../../ducks/send';
import { ASSET_TYPES } from '../../../../shared/constants/transaction';
@ -109,11 +109,11 @@ const EthOverview = ({ className }) => {
label={t('buy')}
onClick={() => {
trackEvent({
event: 'Clicked Deposit',
event: EVENT_NAMES.NAV_BUY_BUTTON_CLICKED,
category: EVENT.CATEGORIES.NAVIGATION,
properties: {
action: 'Home',
legacy_event: true,
location: 'Home',
text: 'Buy',
},
});
dispatch(showModal({ name: 'DEPOSIT_ETHER' }));
@ -126,11 +126,12 @@ const EthOverview = ({ className }) => {
label={t('send')}
onClick={() => {
trackEvent({
event: 'Clicked Send: Eth',
event: EVENT_NAMES.NAV_SEND_BUTTON_CLICKED,
category: EVENT.CATEGORIES.NAVIGATION,
properties: {
action: 'Home',
legacy_event: true,
token_symbol: 'ETH',
location: 'Home',
text: 'Send',
},
});
dispatch(
@ -147,11 +148,12 @@ const EthOverview = ({ className }) => {
onClick={() => {
if (isSwapsChain) {
trackEvent({
event: 'Swaps Opened',
event: EVENT_NAMES.NAV_SWAP_BUTTON_CLICKED,
category: EVENT.CATEGORIES.SWAPS,
properties: {
source: EVENT.SOURCE.SWAPS.MAIN_VIEW,
active_currency: 'ETH',
token_symbol: 'ETH',
location: EVENT.SOURCE.SWAPS.MAIN_VIEW,
text: 'Swap',
},
});
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 { showModal } from '../../../store/actions';
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 WalletOverview from './wallet-overview';
@ -84,11 +84,12 @@ const TokenOverview = ({ className, token }) => {
className="token-overview__button"
onClick={async () => {
trackEvent({
event: 'Clicked Send: Token',
event: EVENT_NAMES.NAV_SEND_BUTTON_CLICKED,
category: EVENT.CATEGORIES.NAVIGATION,
properties: {
action: 'Home',
legacy_event: true,
token_symbol: token.symbol,
location: EVENT.SOURCE.SWAPS.TOKEN_VIEW,
text: 'Send',
},
});
try {
@ -117,11 +118,12 @@ const TokenOverview = ({ className, token }) => {
onClick={() => {
if (isSwapsChain) {
trackEvent({
event: 'Swaps Opened',
event: EVENT_NAMES.NAV_SWAP_BUTTON_CLICKED,
category: EVENT.CATEGORIES.SWAPS,
properties: {
source: EVENT.SOURCE.SWAPS.TOKEN_VIEW,
active_currency: token.symbol,
token_symbol: token.symbol,
location: EVENT.SOURCE.SWAPS.TOKEN_VIEW,
text: 'Swap',
},
});
dispatch(

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,6 +5,7 @@ import classnames from 'classnames';
import { requestRevealSeedWords } from '../../store/actions';
import ExportTextContainer from '../../components/ui/export-text-container';
import { getMostRecentOverviewPage } from '../../ducks/history/history';
import { EVENT, EVENT_NAMES } from '../../../shared/constants/metametrics';
import Button from '../../components/ui/button';
@ -31,10 +32,27 @@ class RevealSeedPage extends Component {
this.setState({ seedWords: null, error: null });
this.props
.requestRevealSeedWords(this.state.password)
.then((seedWords) =>
this.setState({ seedWords, screen: REVEAL_SEED_SCREEN }),
)
.catch((error) => this.setState({ error: error.message }));
.then((seedWords) => {
this.context.trackEvent({
category: EVENT.CATEGORIES.KEYS,
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() {
@ -87,14 +105,36 @@ class RevealSeedPage extends Component {
}
renderRevealSeedContent() {
const { t } = this.context;
const { t, trackEvent } = this.context;
return (
<div>
<label className="reveal-seed__label">
{t('yourPrivateSeedPhrase')}
</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>
);
}
@ -113,9 +153,16 @@ class RevealSeedPage extends Component {
type="secondary"
large
className="page-container__footer-button"
onClick={() =>
this.props.history.push(this.props.mostRecentOverviewPage)
}
onClick={() => {
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')}
</Button>
@ -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) => {

View File

@ -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);

View File

@ -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();
}}

View File

@ -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);

View File

@ -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({

View File

@ -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({
<button
onClick={() => {
trackEvent({
event: 'Clicked Block Explorer Link',
event: EVENT_NAMES.EXTERNAL_LINK_CLICKED,
category: EVENT.CATEGORIES.SWAPS,
sensitiveProperties: sensitiveTrackingProperties,
properties: {
link_type: 'Transaction Block Explorer',
action: 'Swap Transaction',
block_explorer_domain: blockExplorerHostName,
link_type: EVENT.EXTERNAL_LINK_TYPES.TRANSACTION_BLOCK_EXPLORER,
location: 'Swap Transaction',
url_domain: blockExplorerHostName,
},
});
global.platform.openTab({ url: blockExplorerUrl });

View File

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