mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Remove usages of useMetricEvent hook (#13930)
This commit is contained in:
parent
c81912f6c5
commit
060c6d651c
@ -1,4 +1,4 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React, { useMemo, useContext } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
@ -9,11 +9,11 @@ import Tooltip from '../../ui/tooltip';
|
|||||||
import InfoIcon from '../../ui/icon/info-icon.component';
|
import InfoIcon from '../../ui/icon/info-icon.component';
|
||||||
import Button from '../../ui/button';
|
import Button from '../../ui/button';
|
||||||
import { useI18nContext } from '../../../hooks/useI18nContext';
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
||||||
import { useMetricEvent } from '../../../hooks/useMetricEvent';
|
|
||||||
import { ASSET_TYPES, updateSendAsset } from '../../../ducks/send';
|
import { ASSET_TYPES, updateSendAsset } from '../../../ducks/send';
|
||||||
import { SEND_ROUTE } from '../../../helpers/constants/routes';
|
import { SEND_ROUTE } from '../../../helpers/constants/routes';
|
||||||
import { SEVERITIES } from '../../../helpers/constants/design-system';
|
import { SEVERITIES } from '../../../helpers/constants/design-system';
|
||||||
import { INVALID_ASSET_TYPE } from '../../../helpers/constants/error-keys';
|
import { INVALID_ASSET_TYPE } from '../../../helpers/constants/error-keys';
|
||||||
|
import { MetaMetricsContext } from '../../../contexts/metametrics.new';
|
||||||
|
|
||||||
const AssetListItem = ({
|
const AssetListItem = ({
|
||||||
className,
|
className,
|
||||||
@ -33,13 +33,7 @@ const AssetListItem = ({
|
|||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const sendTokenEvent = useMetricEvent({
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
eventOpts: {
|
|
||||||
category: 'Navigation',
|
|
||||||
action: 'Home',
|
|
||||||
name: 'Clicked Send: Token',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const titleIcon = warning ? (
|
const titleIcon = warning ? (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
wrapperClassName="asset-list-item__warning-tooltip"
|
wrapperClassName="asset-list-item__warning-tooltip"
|
||||||
@ -68,7 +62,14 @@ const AssetListItem = ({
|
|||||||
className="asset-list-item__send-token-button"
|
className="asset-list-item__send-token-button"
|
||||||
onClick={async (e) => {
|
onClick={async (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
sendTokenEvent();
|
trackEvent({
|
||||||
|
event: 'Clicked Send: Token',
|
||||||
|
category: 'Navigation',
|
||||||
|
properties: {
|
||||||
|
action: 'Home',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
await dispatch(
|
await dispatch(
|
||||||
updateSendAsset({
|
updateSendAsset({
|
||||||
@ -93,7 +94,7 @@ const AssetListItem = ({
|
|||||||
);
|
);
|
||||||
}, [
|
}, [
|
||||||
tokenSymbol,
|
tokenSymbol,
|
||||||
sendTokenEvent,
|
trackEvent,
|
||||||
tokenAddress,
|
tokenAddress,
|
||||||
tokenDecimals,
|
tokenDecimals,
|
||||||
history,
|
history,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useContext } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
@ -7,7 +7,6 @@ import TokenList from '../token-list';
|
|||||||
import { IMPORT_TOKEN_ROUTE } from '../../../helpers/constants/routes';
|
import { IMPORT_TOKEN_ROUTE } from '../../../helpers/constants/routes';
|
||||||
import AssetListItem from '../asset-list-item';
|
import AssetListItem from '../asset-list-item';
|
||||||
import { PRIMARY, SECONDARY } from '../../../helpers/constants/common';
|
import { PRIMARY, SECONDARY } from '../../../helpers/constants/common';
|
||||||
import { useMetricEvent } from '../../../hooks/useMetricEvent';
|
|
||||||
import { useUserPreferencedCurrency } from '../../../hooks/useUserPreferencedCurrency';
|
import { useUserPreferencedCurrency } from '../../../hooks/useUserPreferencedCurrency';
|
||||||
import {
|
import {
|
||||||
getCurrentAccountWithSendEtherInfo,
|
getCurrentAccountWithSendEtherInfo,
|
||||||
@ -26,6 +25,7 @@ import {
|
|||||||
JUSTIFY_CONTENT,
|
JUSTIFY_CONTENT,
|
||||||
} 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.new';
|
||||||
|
|
||||||
const AssetList = ({ onClickAsset }) => {
|
const AssetList = ({ onClickAsset }) => {
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
@ -35,20 +35,7 @@ const AssetList = ({ onClickAsset }) => {
|
|||||||
);
|
);
|
||||||
const nativeCurrency = useSelector(getNativeCurrency);
|
const nativeCurrency = useSelector(getNativeCurrency);
|
||||||
const showFiat = useSelector(getShouldShowFiat);
|
const showFiat = useSelector(getShouldShowFiat);
|
||||||
const selectTokenEvent = useMetricEvent({
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
eventOpts: {
|
|
||||||
category: 'Navigation',
|
|
||||||
action: 'Token Menu',
|
|
||||||
name: 'Clicked Token',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const addTokenEvent = useMetricEvent({
|
|
||||||
eventOpts: {
|
|
||||||
category: 'Navigation',
|
|
||||||
action: 'Token Menu',
|
|
||||||
name: 'Clicked "Add Token"',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
currency: primaryCurrency,
|
currency: primaryCurrency,
|
||||||
@ -94,7 +81,14 @@ const AssetList = ({ onClickAsset }) => {
|
|||||||
<TokenList
|
<TokenList
|
||||||
onTokenClick={(tokenAddress) => {
|
onTokenClick={(tokenAddress) => {
|
||||||
onClickAsset(tokenAddress);
|
onClickAsset(tokenAddress);
|
||||||
selectTokenEvent();
|
trackEvent({
|
||||||
|
event: 'Clicked Token',
|
||||||
|
category: 'Navigation',
|
||||||
|
properties: {
|
||||||
|
action: 'Token Menu',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Box marginTop={4}>
|
<Box marginTop={4}>
|
||||||
@ -111,7 +105,14 @@ const AssetList = ({ onClickAsset }) => {
|
|||||||
isMainnet={isMainnet}
|
isMainnet={isMainnet}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
history.push(IMPORT_TOKEN_ROUTE);
|
history.push(IMPORT_TOKEN_ROUTE);
|
||||||
addTokenEvent();
|
trackEvent({
|
||||||
|
event: 'Clicked "Add Token"',
|
||||||
|
category: 'Navigation',
|
||||||
|
properties: {
|
||||||
|
action: 'Token Menu',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
@ -35,8 +35,7 @@ import ActionableMessage from '../../ui/actionable-message/actionable-message';
|
|||||||
|
|
||||||
import { I18nContext } from '../../../contexts/i18n';
|
import { I18nContext } from '../../../contexts/i18n';
|
||||||
import GasTiming from '../gas-timing';
|
import GasTiming from '../gas-timing';
|
||||||
|
import { MetaMetricsContext } from '../../../contexts/metametrics.new';
|
||||||
import { useMetricEvent } from '../../../hooks/useMetricEvent';
|
|
||||||
|
|
||||||
export default function EditGasDisplay({
|
export default function EditGasDisplay({
|
||||||
mode = EDIT_GAS_MODES.MODIFY_IN_PLACE,
|
mode = EDIT_GAS_MODES.MODIFY_IN_PLACE,
|
||||||
@ -133,14 +132,7 @@ export default function EditGasDisplay({
|
|||||||
errorKey = 'gasEstimatesUnavailableWarning';
|
errorKey = 'gasEstimatesUnavailableWarning';
|
||||||
}
|
}
|
||||||
|
|
||||||
const clickedAdvancedOptionsMetricsEvent = useMetricEvent({
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
eventOpts: {
|
|
||||||
category: 'Transactions',
|
|
||||||
action: 'Edit Screen',
|
|
||||||
name: 'Clicked "Advanced Options"',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="edit-gas-display">
|
<div className="edit-gas-display">
|
||||||
<div className="edit-gas-display__content">
|
<div className="edit-gas-display__content">
|
||||||
@ -286,7 +278,14 @@ export default function EditGasDisplay({
|
|||||||
className="edit-gas-display__advanced-button"
|
className="edit-gas-display__advanced-button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setShowAdvancedForm(!showAdvancedForm);
|
setShowAdvancedForm(!showAdvancedForm);
|
||||||
clickedAdvancedOptionsMetricsEvent();
|
trackEvent({
|
||||||
|
event: 'Clicked "Advanced Options"',
|
||||||
|
category: 'Transactions',
|
||||||
|
properties: {
|
||||||
|
action: 'Edit Screen',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('advancedOptions')}{' '}
|
{t('advancedOptions')}{' '}
|
||||||
|
@ -1,22 +1,16 @@
|
|||||||
import React from 'react';
|
import React, { useContext } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { useMetricEvent } from '../../../hooks/useMetricEvent';
|
|
||||||
import { useI18nContext } from '../../../hooks/useI18nContext';
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
||||||
import { IMPORT_TOKEN_ROUTE } from '../../../helpers/constants/routes';
|
import { IMPORT_TOKEN_ROUTE } from '../../../helpers/constants/routes';
|
||||||
import Button from '../../ui/button';
|
import Button from '../../ui/button';
|
||||||
import Box from '../../ui/box/box';
|
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.new';
|
||||||
|
|
||||||
export default function ImportTokenLink({ isMainnet }) {
|
export default function ImportTokenLink({ isMainnet }) {
|
||||||
const addTokenEvent = useMetricEvent({
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
eventOpts: {
|
|
||||||
category: 'Navigation',
|
|
||||||
action: 'Token Menu',
|
|
||||||
name: 'Clicked "Add Token"',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
@ -39,7 +33,14 @@ export default function ImportTokenLink({ isMainnet }) {
|
|||||||
type="link"
|
type="link"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
history.push(IMPORT_TOKEN_ROUTE);
|
history.push(IMPORT_TOKEN_ROUTE);
|
||||||
addTokenEvent();
|
trackEvent({
|
||||||
|
event: 'Clicked "Add Token"',
|
||||||
|
category: 'Navigation',
|
||||||
|
properties: {
|
||||||
|
action: 'Token Menu',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{isMainnet
|
{isMainnet
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useContext } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
@ -15,12 +15,10 @@ import {
|
|||||||
getSelectedIdentity,
|
getSelectedIdentity,
|
||||||
} from '../../../selectors';
|
} from '../../../selectors';
|
||||||
import { useI18nContext } from '../../../hooks/useI18nContext';
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
||||||
import {
|
import { useNewMetricEvent } from '../../../hooks/useMetricEvent';
|
||||||
useMetricEvent,
|
|
||||||
useNewMetricEvent,
|
|
||||||
} from '../../../hooks/useMetricEvent';
|
|
||||||
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 { MetaMetricsContext } from '../../../contexts/metametrics.new';
|
||||||
|
|
||||||
export default function AccountOptionsMenu({ anchorElement, onClose }) {
|
export default function AccountOptionsMenu({ anchorElement, onClose }) {
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
@ -35,29 +33,7 @@ export default function AccountOptionsMenu({ anchorElement, onClose }) {
|
|||||||
const addressLink = getAccountLink(address, chainId, rpcPrefs);
|
const addressLink = getAccountLink(address, chainId, rpcPrefs);
|
||||||
const { blockExplorerUrl } = rpcPrefs;
|
const { blockExplorerUrl } = rpcPrefs;
|
||||||
const blockExplorerUrlSubTitle = getURLHostName(blockExplorerUrl);
|
const blockExplorerUrlSubTitle = getURLHostName(blockExplorerUrl);
|
||||||
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
const openFullscreenEvent = useMetricEvent({
|
|
||||||
eventOpts: {
|
|
||||||
category: 'Navigation',
|
|
||||||
action: 'Account Options',
|
|
||||||
name: 'Clicked Expand View',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const viewAccountDetailsEvent = useMetricEvent({
|
|
||||||
eventOpts: {
|
|
||||||
category: 'Navigation',
|
|
||||||
action: 'Account Options',
|
|
||||||
name: 'Viewed Account Details',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const openConnectedSitesEvent = useMetricEvent({
|
|
||||||
eventOpts: {
|
|
||||||
category: 'Navigation',
|
|
||||||
action: 'Account Options',
|
|
||||||
name: 'Opened Connected Sites',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const blockExplorerLinkClickedEvent = useNewMetricEvent({
|
const blockExplorerLinkClickedEvent = useNewMetricEvent({
|
||||||
category: 'Navigation',
|
category: 'Navigation',
|
||||||
@ -101,7 +77,14 @@ export default function AccountOptionsMenu({ anchorElement, onClose }) {
|
|||||||
{getEnvironmentType() === ENVIRONMENT_TYPE_FULLSCREEN ? null : (
|
{getEnvironmentType() === ENVIRONMENT_TYPE_FULLSCREEN ? null : (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openFullscreenEvent();
|
trackEvent({
|
||||||
|
event: 'Clicked Expand View',
|
||||||
|
category: 'Navigation',
|
||||||
|
properties: {
|
||||||
|
action: 'Account Options',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
global.platform.openExtensionInBrowser();
|
global.platform.openExtensionInBrowser();
|
||||||
onClose();
|
onClose();
|
||||||
}}
|
}}
|
||||||
@ -114,7 +97,14 @@ export default function AccountOptionsMenu({ anchorElement, onClose }) {
|
|||||||
data-testid="account-options-menu__account-details"
|
data-testid="account-options-menu__account-details"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
dispatch(showModal({ name: 'ACCOUNT_DETAILS' }));
|
dispatch(showModal({ name: 'ACCOUNT_DETAILS' }));
|
||||||
viewAccountDetailsEvent();
|
trackEvent({
|
||||||
|
event: 'Viewed Account Details',
|
||||||
|
category: 'Navigation',
|
||||||
|
properties: {
|
||||||
|
action: 'Account Options',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
onClose();
|
onClose();
|
||||||
}}
|
}}
|
||||||
iconClassName="fas fa-qrcode"
|
iconClassName="fas fa-qrcode"
|
||||||
@ -124,7 +114,14 @@ export default function AccountOptionsMenu({ anchorElement, onClose }) {
|
|||||||
<MenuItem
|
<MenuItem
|
||||||
data-testid="account-options-menu__connected-sites"
|
data-testid="account-options-menu__connected-sites"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openConnectedSitesEvent();
|
trackEvent({
|
||||||
|
event: 'Opened Connected Sites',
|
||||||
|
category: 'Navigation',
|
||||||
|
properties: {
|
||||||
|
action: 'Account Options',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
history.push(CONNECTED_ROUTE);
|
history.push(CONNECTED_ROUTE);
|
||||||
onClose();
|
onClose();
|
||||||
}}
|
}}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState, useContext } from 'react';
|
||||||
import extension from 'extensionizer';
|
import extension from 'extensionizer';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
@ -8,19 +8,13 @@ import { getEnvironmentType } from '../../../../app/scripts/lib/util';
|
|||||||
import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app';
|
import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app';
|
||||||
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 { useMetricEvent } from '../../../hooks/useMetricEvent';
|
|
||||||
import { getOriginOfCurrentTab } from '../../../selectors';
|
import { getOriginOfCurrentTab } from '../../../selectors';
|
||||||
|
import { MetaMetricsContext } from '../../../contexts/metametrics.new';
|
||||||
import AccountOptionsMenu from './account-options-menu';
|
import AccountOptionsMenu from './account-options-menu';
|
||||||
|
|
||||||
export default function MenuBar() {
|
export default function MenuBar() {
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
const openAccountOptionsEvent = useMetricEvent({
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
eventOpts: {
|
|
||||||
category: 'Navigation',
|
|
||||||
action: 'Home',
|
|
||||||
name: 'Opened Account Options',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [
|
const [
|
||||||
accountOptionsButtonElement,
|
accountOptionsButtonElement,
|
||||||
@ -50,7 +44,14 @@ export default function MenuBar() {
|
|||||||
ref={setAccountOptionsButtonElement}
|
ref={setAccountOptionsButtonElement}
|
||||||
title={t('accountOptions')}
|
title={t('accountOptions')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openAccountOptionsEvent();
|
trackEvent({
|
||||||
|
event: 'Opened Account Options',
|
||||||
|
category: 'Navigation',
|
||||||
|
properties: {
|
||||||
|
action: 'Home',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
setAccountOptionsMenuOpen(true);
|
setAccountOptionsMenuOpen(true);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useMemo, useState, useCallback } from 'react';
|
import React, { useMemo, useState, useCallback, useContext } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
@ -31,13 +31,13 @@ import {
|
|||||||
getEIP1559V2Enabled,
|
getEIP1559V2Enabled,
|
||||||
} from '../../../selectors';
|
} from '../../../selectors';
|
||||||
import { isLegacyTransaction } from '../../../helpers/utils/transactions.util';
|
import { isLegacyTransaction } from '../../../helpers/utils/transactions.util';
|
||||||
import { useMetricEvent } from '../../../hooks/useMetricEvent';
|
|
||||||
import Button from '../../ui/button';
|
import Button from '../../ui/button';
|
||||||
import AdvancedGasFeePopover from '../advanced-gas-fee-popover';
|
import AdvancedGasFeePopover from '../advanced-gas-fee-popover';
|
||||||
import CancelButton from '../cancel-button';
|
import CancelButton from '../cancel-button';
|
||||||
import CancelSpeedupPopover from '../cancel-speedup-popover';
|
import CancelSpeedupPopover from '../cancel-speedup-popover';
|
||||||
import EditGasFeePopover from '../edit-gas-fee-popover';
|
import EditGasFeePopover from '../edit-gas-fee-popover';
|
||||||
import EditGasPopover from '../edit-gas-popover';
|
import EditGasPopover from '../edit-gas-popover';
|
||||||
|
import { MetaMetricsContext } from '../../../contexts/metametrics.new';
|
||||||
|
|
||||||
function TransactionListItemInner({
|
function TransactionListItemInner({
|
||||||
transactionGroup,
|
transactionGroup,
|
||||||
@ -60,26 +60,19 @@ function TransactionListItemInner({
|
|||||||
primaryTransaction: { err, status },
|
primaryTransaction: { err, status },
|
||||||
} = transactionGroup;
|
} = transactionGroup;
|
||||||
|
|
||||||
const speedUpMetricsEvent = useMetricEvent({
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
eventOpts: {
|
|
||||||
category: 'Navigation',
|
|
||||||
action: 'Activity Log',
|
|
||||||
name: 'Clicked "Speed Up"',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const cancelMetricsEvent = useMetricEvent({
|
|
||||||
eventOpts: {
|
|
||||||
category: 'Navigation',
|
|
||||||
action: 'Activity Log',
|
|
||||||
name: 'Clicked "Cancel"',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const retryTransaction = useCallback(
|
const retryTransaction = useCallback(
|
||||||
async (event) => {
|
async (event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
speedUpMetricsEvent();
|
trackEvent({
|
||||||
|
event: 'Clicked "Speed Up"',
|
||||||
|
category: 'Navigation',
|
||||||
|
properties: {
|
||||||
|
action: 'Activity Log',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
if (supportsEIP1559V2) {
|
if (supportsEIP1559V2) {
|
||||||
setEditGasMode(EDIT_GAS_MODES.SPEED_UP);
|
setEditGasMode(EDIT_GAS_MODES.SPEED_UP);
|
||||||
openModal('cancelSpeedUpTransaction');
|
openModal('cancelSpeedUpTransaction');
|
||||||
@ -87,13 +80,20 @@ function TransactionListItemInner({
|
|||||||
setShowRetryEditGasPopover(true);
|
setShowRetryEditGasPopover(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[openModal, setEditGasMode, speedUpMetricsEvent, supportsEIP1559V2],
|
[openModal, setEditGasMode, trackEvent, supportsEIP1559V2],
|
||||||
);
|
);
|
||||||
|
|
||||||
const cancelTransaction = useCallback(
|
const cancelTransaction = useCallback(
|
||||||
(event) => {
|
(event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
cancelMetricsEvent();
|
trackEvent({
|
||||||
|
event: 'Clicked "Cancel"',
|
||||||
|
category: 'Navigation',
|
||||||
|
properties: {
|
||||||
|
action: 'Activity Log',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
if (supportsEIP1559V2) {
|
if (supportsEIP1559V2) {
|
||||||
setEditGasMode(EDIT_GAS_MODES.CANCEL);
|
setEditGasMode(EDIT_GAS_MODES.CANCEL);
|
||||||
openModal('cancelSpeedUpTransaction');
|
openModal('cancelSpeedUpTransaction');
|
||||||
@ -101,7 +101,7 @@ function TransactionListItemInner({
|
|||||||
setShowCancelEditGasPopover(true);
|
setShowCancelEditGasPopover(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[cancelMetricsEvent, openModal, setEditGasMode, supportsEIP1559V2],
|
[trackEvent, openModal, setEditGasMode, supportsEIP1559V2],
|
||||||
);
|
);
|
||||||
|
|
||||||
const shouldShowSpeedUp = useShouldShowSpeedUp(
|
const shouldShowSpeedUp = useShouldShowSpeedUp(
|
||||||
|
@ -10,10 +10,7 @@ import {
|
|||||||
SEND_ROUTE,
|
SEND_ROUTE,
|
||||||
BUILD_QUOTE_ROUTE,
|
BUILD_QUOTE_ROUTE,
|
||||||
} from '../../../helpers/constants/routes';
|
} from '../../../helpers/constants/routes';
|
||||||
import {
|
import { useNewMetricEvent } from '../../../hooks/useMetricEvent';
|
||||||
useMetricEvent,
|
|
||||||
useNewMetricEvent,
|
|
||||||
} from '../../../hooks/useMetricEvent';
|
|
||||||
import Tooltip from '../../ui/tooltip';
|
import Tooltip from '../../ui/tooltip';
|
||||||
import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display';
|
import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display';
|
||||||
import { PRIMARY, SECONDARY } from '../../../helpers/constants/common';
|
import { PRIMARY, SECONDARY } from '../../../helpers/constants/common';
|
||||||
@ -34,25 +31,13 @@ import SendIcon from '../../ui/icon/overview-send-icon.component';
|
|||||||
import { setSwapsFromToken } from '../../../ducks/swaps/swaps';
|
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.new';
|
||||||
import WalletOverview from './wallet-overview';
|
import WalletOverview from './wallet-overview';
|
||||||
|
|
||||||
const EthOverview = ({ className }) => {
|
const EthOverview = ({ className }) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const t = useContext(I18nContext);
|
const t = useContext(I18nContext);
|
||||||
const sendEvent = useMetricEvent({
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
eventOpts: {
|
|
||||||
category: 'Navigation',
|
|
||||||
action: 'Home',
|
|
||||||
name: 'Clicked Send: Eth',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const depositEvent = useMetricEvent({
|
|
||||||
eventOpts: {
|
|
||||||
category: 'Navigation',
|
|
||||||
action: 'Home',
|
|
||||||
name: 'Clicked Deposit',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const keyring = useSelector(getCurrentKeyring);
|
const keyring = useSelector(getCurrentKeyring);
|
||||||
const usingHardwareWallet = isHardwareKeyring(keyring?.type);
|
const usingHardwareWallet = isHardwareKeyring(keyring?.type);
|
||||||
@ -119,7 +104,14 @@ const EthOverview = ({ className }) => {
|
|||||||
disabled={!isBuyableChain}
|
disabled={!isBuyableChain}
|
||||||
label={t('buy')}
|
label={t('buy')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
depositEvent();
|
trackEvent({
|
||||||
|
event: 'Clicked Deposit',
|
||||||
|
category: 'Navigation',
|
||||||
|
properties: {
|
||||||
|
action: 'Home',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
dispatch(showModal({ name: 'DEPOSIT_ETHER' }));
|
dispatch(showModal({ name: 'DEPOSIT_ETHER' }));
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@ -129,7 +121,14 @@ const EthOverview = ({ className }) => {
|
|||||||
Icon={SendIcon}
|
Icon={SendIcon}
|
||||||
label={t('send')}
|
label={t('send')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
sendEvent();
|
trackEvent({
|
||||||
|
event: 'Clicked Send: Eth',
|
||||||
|
category: 'Navigation',
|
||||||
|
properties: {
|
||||||
|
action: 'Home',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
history.push(SEND_ROUTE);
|
history.push(SEND_ROUTE);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -12,10 +12,7 @@ import {
|
|||||||
SEND_ROUTE,
|
SEND_ROUTE,
|
||||||
BUILD_QUOTE_ROUTE,
|
BUILD_QUOTE_ROUTE,
|
||||||
} from '../../../helpers/constants/routes';
|
} from '../../../helpers/constants/routes';
|
||||||
import {
|
import { useNewMetricEvent } from '../../../hooks/useMetricEvent';
|
||||||
useMetricEvent,
|
|
||||||
useNewMetricEvent,
|
|
||||||
} from '../../../hooks/useMetricEvent';
|
|
||||||
import { useTokenTracker } from '../../../hooks/useTokenTracker';
|
import { useTokenTracker } from '../../../hooks/useTokenTracker';
|
||||||
import { useTokenFiatAmount } from '../../../hooks/useTokenFiatAmount';
|
import { useTokenFiatAmount } from '../../../hooks/useTokenFiatAmount';
|
||||||
import { ASSET_TYPES, updateSendAsset } from '../../../ducks/send';
|
import { ASSET_TYPES, updateSendAsset } from '../../../ducks/send';
|
||||||
@ -31,18 +28,13 @@ import SendIcon from '../../ui/icon/overview-send-icon.component';
|
|||||||
import IconButton from '../../ui/icon-button';
|
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.new';
|
||||||
import WalletOverview from './wallet-overview';
|
import WalletOverview from './wallet-overview';
|
||||||
|
|
||||||
const TokenOverview = ({ className, token }) => {
|
const TokenOverview = ({ className, token }) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const t = useContext(I18nContext);
|
const t = useContext(I18nContext);
|
||||||
const sendTokenEvent = useMetricEvent({
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
eventOpts: {
|
|
||||||
category: 'Navigation',
|
|
||||||
action: 'Home',
|
|
||||||
name: 'Clicked Send: Token',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const keyring = useSelector(getCurrentKeyring);
|
const keyring = useSelector(getCurrentKeyring);
|
||||||
const usingHardwareWallet = isHardwareKeyring(keyring.type);
|
const usingHardwareWallet = isHardwareKeyring(keyring.type);
|
||||||
@ -95,7 +87,14 @@ const TokenOverview = ({ className, token }) => {
|
|||||||
<IconButton
|
<IconButton
|
||||||
className="token-overview__button"
|
className="token-overview__button"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
sendTokenEvent();
|
trackEvent({
|
||||||
|
event: 'Clicked Send: Token',
|
||||||
|
category: 'Navigation',
|
||||||
|
properties: {
|
||||||
|
action: 'Home',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
await dispatch(
|
await dispatch(
|
||||||
updateSendAsset({
|
updateSendAsset({
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { useContext, useCallback } from 'react';
|
import { useContext, useCallback } from 'react';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { useRouteMatch } from 'react-router-dom';
|
import { useRouteMatch } from 'react-router-dom';
|
||||||
import { MetaMetricsContext } from '../contexts/metametrics';
|
|
||||||
import { MetaMetricsContext as NewMetaMetricsContext } from '../contexts/metametrics.new';
|
import { MetaMetricsContext as NewMetaMetricsContext } from '../contexts/metametrics.new';
|
||||||
import { PATH_NAME_MAP } from '../helpers/constants/routes';
|
import { PATH_NAME_MAP } from '../helpers/constants/routes';
|
||||||
import { txDataSelector } from '../selectors';
|
import { txDataSelector } from '../selectors';
|
||||||
@ -13,16 +12,6 @@ import { useEqualityCheck } from './useEqualityCheck';
|
|||||||
* @typedef {import('../../shared/constants/metametrics').MetaMetricsEventOptions} MetaMetricsEventOptions
|
* @typedef {import('../../shared/constants/metametrics').MetaMetricsEventOptions} MetaMetricsEventOptions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function useMetricEvent(config = {}, overrides = {}) {
|
|
||||||
const metricsEvent = useContext(MetaMetricsContext);
|
|
||||||
const trackEvent = useCallback(() => metricsEvent(config, overrides), [
|
|
||||||
config,
|
|
||||||
metricsEvent,
|
|
||||||
overrides,
|
|
||||||
]);
|
|
||||||
return trackEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* track a metametrics event using segment
|
* track a metametrics event using segment
|
||||||
* e.g metricsEvent({ event: 'Unlocked MetaMask', category: 'Navigation' })
|
* e.g metricsEvent({ event: 'Unlocked MetaMask', category: 'Navigation' })
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import Box from '../../../components/ui/box';
|
import Box from '../../../components/ui/box';
|
||||||
@ -15,8 +15,8 @@ import {
|
|||||||
ONBOARDING_PRIVACY_SETTINGS_ROUTE,
|
ONBOARDING_PRIVACY_SETTINGS_ROUTE,
|
||||||
} from '../../../helpers/constants/routes';
|
} from '../../../helpers/constants/routes';
|
||||||
import { setCompletedOnboarding } from '../../../store/actions';
|
import { setCompletedOnboarding } from '../../../store/actions';
|
||||||
import { useMetricEvent } from '../../../hooks/useMetricEvent';
|
|
||||||
import { getFirstTimeFlowType } from '../../../selectors';
|
import { getFirstTimeFlowType } from '../../../selectors';
|
||||||
|
import { MetaMetricsContext } from '../../../contexts/metametrics.new';
|
||||||
|
|
||||||
export default function CreationSuccessful() {
|
export default function CreationSuccessful() {
|
||||||
const firstTimeFlowTypeNameMap = {
|
const firstTimeFlowTypeNameMap = {
|
||||||
@ -28,15 +28,18 @@ export default function CreationSuccessful() {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const firstTimeFlowType = useSelector(getFirstTimeFlowType);
|
const firstTimeFlowType = useSelector(getFirstTimeFlowType);
|
||||||
|
|
||||||
const onboardingCompletedEvent = useMetricEvent({
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
category: 'Onboarding',
|
|
||||||
action: 'Onboarding Complete',
|
|
||||||
name: firstTimeFlowTypeNameMap[firstTimeFlowType],
|
|
||||||
});
|
|
||||||
|
|
||||||
const onComplete = async () => {
|
const onComplete = async () => {
|
||||||
await dispatch(setCompletedOnboarding());
|
await dispatch(setCompletedOnboarding());
|
||||||
onboardingCompletedEvent();
|
trackEvent({
|
||||||
|
event: firstTimeFlowTypeNameMap[firstTimeFlowType],
|
||||||
|
category: 'Onboarding',
|
||||||
|
properties: {
|
||||||
|
action: 'Onboarding Complete',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
history.push(ONBOARDING_PIN_EXTENSION_ROUTE);
|
history.push(ONBOARDING_PIN_EXTENSION_ROUTE);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useContext } from 'react';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
@ -7,23 +7,24 @@ import {
|
|||||||
toggleSendMaxMode,
|
toggleSendMaxMode,
|
||||||
} from '../../../../../ducks/send';
|
} from '../../../../../ducks/send';
|
||||||
import { useI18nContext } from '../../../../../hooks/useI18nContext';
|
import { useI18nContext } from '../../../../../hooks/useI18nContext';
|
||||||
import { useMetricEvent } from '../../../../../hooks/useMetricEvent';
|
import { MetaMetricsContext } from '../../../../../contexts/metametrics.new';
|
||||||
|
|
||||||
export default function AmountMaxButton() {
|
export default function AmountMaxButton() {
|
||||||
const isDraftTransactionInvalid = useSelector(isSendFormInvalid);
|
const isDraftTransactionInvalid = useSelector(isSendFormInvalid);
|
||||||
const maxModeOn = useSelector(getSendMaxModeState);
|
const maxModeOn = useSelector(getSendMaxModeState);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const trackClickedMax = useMetricEvent({
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
eventOpts: {
|
|
||||||
category: 'Transactions',
|
|
||||||
action: 'Edit Screen',
|
|
||||||
name: 'Clicked "Amount Max"',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
|
|
||||||
const onMaxClick = () => {
|
const onMaxClick = () => {
|
||||||
trackClickedMax();
|
trackEvent({
|
||||||
|
event: 'Clicked "Amount Max"',
|
||||||
|
category: 'Transactions',
|
||||||
|
properties: {
|
||||||
|
action: 'Edit Screen',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
dispatch(toggleSendMaxMode());
|
dispatch(toggleSendMaxMode());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useCallback } from 'react';
|
import React, { useEffect, useCallback, useContext } from 'react';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import { useHistory, useLocation } from 'react-router-dom';
|
import { useHistory, useLocation } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
@ -16,7 +16,7 @@ import {
|
|||||||
import { getCurrentChainId, isCustomPriceExcessive } from '../../selectors';
|
import { getCurrentChainId, isCustomPriceExcessive } from '../../selectors';
|
||||||
import { getSendHexDataFeatureFlagState } from '../../ducks/metamask/metamask';
|
import { getSendHexDataFeatureFlagState } from '../../ducks/metamask/metamask';
|
||||||
import { showQrScanner } from '../../store/actions';
|
import { showQrScanner } from '../../store/actions';
|
||||||
import { useMetricEvent } from '../../hooks/useMetricEvent';
|
import { MetaMetricsContext } from '../../contexts/metametrics.new';
|
||||||
import SendHeader from './send-header';
|
import SendHeader from './send-header';
|
||||||
import AddRecipient from './send-content/add-recipient';
|
import AddRecipient from './send-content/add-recipient';
|
||||||
import SendContent from './send-content';
|
import SendContent from './send-content';
|
||||||
@ -38,13 +38,7 @@ export default function SendTransactionScreen() {
|
|||||||
const showHexData = useSelector(getSendHexDataFeatureFlagState);
|
const showHexData = useSelector(getSendHexDataFeatureFlagState);
|
||||||
const userInput = useSelector(getRecipientUserInput);
|
const userInput = useSelector(getRecipientUserInput);
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const trackUsedQRScanner = useMetricEvent({
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
eventOpts: {
|
|
||||||
category: 'Transactions',
|
|
||||||
action: 'Edit Screen',
|
|
||||||
name: 'Used QR scanner',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
@ -109,7 +103,14 @@ export default function SendTransactionScreen() {
|
|||||||
onPaste={(text) => updateRecipient({ address: text, nickname: '' })}
|
onPaste={(text) => updateRecipient({ address: text, nickname: '' })}
|
||||||
onReset={() => dispatch(resetRecipientInput())}
|
onReset={() => dispatch(resetRecipientInput())}
|
||||||
scanQrCode={() => {
|
scanQrCode={() => {
|
||||||
trackUsedQRScanner();
|
trackEvent({
|
||||||
|
event: 'Used QR scanner',
|
||||||
|
category: 'Transactions',
|
||||||
|
properties: {
|
||||||
|
action: 'Edit Screen',
|
||||||
|
legacy_event: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
dispatch(showQrScanner());
|
dispatch(showQrScanner());
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user