diff --git a/app/scripts/controllers/metametrics.js b/app/scripts/controllers/metametrics.js index c7bd148e62d3..84485d495b6b 100644 --- a/app/scripts/controllers/metametrics.js +++ b/app/scripts/controllers/metametrics.js @@ -1017,7 +1017,8 @@ export default class MetaMetricsController { // to be updated to work with the new tracking plan. I think we should use // a config setting for this instead of trying to match the event name const isSendFlow = Boolean(payload.event.match(/^send|^confirm/iu)); - if (isSendFlow) { + // do not filter if excludeMetaMetricsId is explicitly set to false + if (options?.excludeMetaMetricsId !== false && isSendFlow) { excludeMetaMetricsId = true; } // If we are tracking sensitive data we will always use the anonymousId diff --git a/ui/components/app/nfts-items/nfts-items.js b/ui/components/app/nfts-items/nfts-items.js index 7f2cfce7c7cb..4fb3664d9f19 100644 --- a/ui/components/app/nfts-items/nfts-items.js +++ b/ui/components/app/nfts-items/nfts-items.js @@ -164,17 +164,20 @@ export default function NftsItems({ }; const onSendNft = async (nft) => { - trackEvent({ - event: MetaMetricsEventName.sendAssetSelected, - category: MetaMetricsEventCategory.Send, - properties: { - ...sendAnalytics, - is_destination_asset_picker_modal: false, - new_asset_symbol: nft.name, - new_asset_address: nft.address, - is_nft: true, + trackEvent( + { + event: MetaMetricsEventName.sendAssetSelected, + category: MetaMetricsEventCategory.Send, + properties: { + ...sendAnalytics, + is_destination_asset_picker_modal: false, + new_asset_symbol: nft.name, + new_asset_address: nft.address, + is_nft: true, + }, }, - }); + { excludeMetaMetricsId: false }, + ); await dispatch( updateSendAsset({ type: AssetType.NFT, diff --git a/ui/components/app/wallet-overview/coin-buttons.tsx b/ui/components/app/wallet-overview/coin-buttons.tsx index b1774897edc4..095d8fa71aa4 100644 --- a/ui/components/app/wallet-overview/coin-buttons.tsx +++ b/ui/components/app/wallet-overview/coin-buttons.tsx @@ -219,16 +219,19 @@ const CoinButtons = ({ ///: END:ONLY_INCLUDE_IF const handleSendOnClick = useCallback(async () => { - trackEvent({ - event: MetaMetricsEventName.NavSendButtonClicked, - category: MetaMetricsEventCategory.Navigation, - properties: { - token_symbol: 'ETH', - location: 'Home', - text: 'Send', - chain_id: chainId, + trackEvent( + { + event: MetaMetricsEventName.NavSendButtonClicked, + category: MetaMetricsEventCategory.Navigation, + properties: { + token_symbol: 'ETH', + location: 'Home', + text: 'Send', + chain_id: chainId, + }, }, - }); + { excludeMetaMetricsId: false }, + ); await dispatch(startNewDraftTransaction({ type: AssetType.native })); history.push(SEND_ROUTE); }, [chainId]); diff --git a/ui/components/multichain/asset-picker-amount/asset-picker-modal/asset-picker-modal.tsx b/ui/components/multichain/asset-picker-amount/asset-picker-modal/asset-picker-modal.tsx index fc37172f5e15..b82f8d5dafdf 100644 --- a/ui/components/multichain/asset-picker-amount/asset-picker-modal/asset-picker-modal.tsx +++ b/ui/components/multichain/asset-picker-amount/asset-picker-modal/asset-picker-modal.tsx @@ -123,17 +123,20 @@ export function AssetPickerModal({ const handleAssetChange = useCallback( (token: Token) => { onAssetChange(token); - trackEvent({ - event: MetaMetricsEventName.sendAssetSelected, - category: MetaMetricsEventCategory.Send, - properties: { - ...sendAnalytics, - is_destination_asset_picker_modal: Boolean(isDest), - new_asset_symbol: token.symbol, - new_asset_address: token.address, - is_nft: false, + trackEvent( + { + event: MetaMetricsEventName.sendAssetSelected, + category: MetaMetricsEventCategory.Send, + properties: { + ...sendAnalytics, + is_destination_asset_picker_modal: Boolean(isDest), + new_asset_symbol: token.symbol, + new_asset_address: token.address, + is_nft: false, + }, }, - }); + { excludeMetaMetricsId: false }, + ); onClose(); }, [onAssetChange], diff --git a/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.tsx b/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.tsx index 276c89bd50ab..e9656ae38352 100644 --- a/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.tsx +++ b/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.tsx @@ -162,14 +162,17 @@ export function AssetPicker({ backgroundColor={BackgroundColor.transparent} onClick={() => { setShowAssetPickerModal(true); - trackEvent({ - event: MetaMetricsEventName.sendTokenModalOpened, - category: MetaMetricsEventCategory.Send, - properties: { - ...sendAnalytics, - is_destination_asset_picker_modal: Boolean(sendingAsset), + trackEvent( + { + event: MetaMetricsEventName.sendTokenModalOpened, + category: MetaMetricsEventCategory.Send, + properties: { + ...sendAnalytics, + is_destination_asset_picker_modal: Boolean(sendingAsset), + }, }, - }); + { excludeMetaMetricsId: false }, + ); }} endIconName={IconName.ArrowDown} endIconProps={{ diff --git a/ui/components/multichain/pages/send/components/address-book.tsx b/ui/components/multichain/pages/send/components/address-book.tsx index 84e29e0a1ed5..8100646486ca 100644 --- a/ui/components/multichain/pages/send/components/address-book.tsx +++ b/ui/components/multichain/pages/send/components/address-book.tsx @@ -99,14 +99,17 @@ export const SendPageAddressBook = () => { `sendFlow - User clicked recipient from ${type}. address: ${address}, nickname ${nickname}`, ), ); - trackEvent({ - event: MetaMetricsEventName.sendRecipientSelected, - category: MetaMetricsEventCategory.Send, - properties: { - location: 'address book', - inputType: type, + trackEvent( + { + event: MetaMetricsEventName.sendRecipientSelected, + category: MetaMetricsEventCategory.Send, + properties: { + location: 'address book', + inputType: type, + }, }, - }); + { excludeMetaMetricsId: false }, + ); dispatch(updateRecipient({ address, nickname })); dispatch(updateRecipientUserInput(address)); }; diff --git a/ui/components/multichain/pages/send/components/quote-card/index.tsx b/ui/components/multichain/pages/send/components/quote-card/index.tsx index d3815fd3d64c..58f7b2e245d4 100644 --- a/ui/components/multichain/pages/send/components/quote-card/index.tsx +++ b/ui/components/multichain/pages/send/components/quote-card/index.tsx @@ -85,14 +85,17 @@ export function QuoteCard({ scrollRef }: QuoteCardProps) { } if (bestQuote) { - trackEvent({ - event: MetaMetricsEventName.sendSwapQuoteFetched, - category: MetaMetricsEventCategory.Send, - properties: { - ...sendAnalytics, - is_first_fetch: isQuoteJustLoaded, + trackEvent( + { + event: MetaMetricsEventName.sendSwapQuoteFetched, + category: MetaMetricsEventCategory.Send, + properties: { + ...sendAnalytics, + is_first_fetch: isQuoteJustLoaded, + }, }, - }); + { excludeMetaMetricsId: false }, + ); setTimeLeft(REFRESH_INTERVAL); } else { setTimeLeft(undefined); diff --git a/ui/components/multichain/pages/send/components/recipient-input.tsx b/ui/components/multichain/pages/send/components/recipient-input.tsx index debcdbbdca36..4d7d8cee633b 100644 --- a/ui/components/multichain/pages/send/components/recipient-input.tsx +++ b/ui/components/multichain/pages/send/components/recipient-input.tsx @@ -46,14 +46,17 @@ export const SendPageRecipientInput = () => { addHistoryEntry(`sendFlow - Valid address typed ${address}`), ); await dispatch(updateRecipientUserInput(address)); - trackEvent({ - event: MetaMetricsEventName.sendRecipientSelected, - category: MetaMetricsEventCategory.Send, - properties: { - location: 'send page recipient input', - inputType: 'user input', + trackEvent( + { + event: MetaMetricsEventName.sendRecipientSelected, + category: MetaMetricsEventCategory.Send, + properties: { + location: 'send page recipient input', + inputType: 'user input', + }, }, - }); + { excludeMetaMetricsId: false }, + ); dispatch(updateRecipient({ address, nickname: '' })); }} internalSearch={isUsingMyAccountsForRecipientSearch} diff --git a/ui/components/multichain/pages/send/components/recipient.tsx b/ui/components/multichain/pages/send/components/recipient.tsx index 841077cfafcd..f2049493133a 100644 --- a/ui/components/multichain/pages/send/components/recipient.tsx +++ b/ui/components/multichain/pages/send/components/recipient.tsx @@ -67,14 +67,17 @@ export const SendPageRecipient = () => { `sendFlow - User clicked recipient from ${type}. address: ${address}, nickname ${nickname}`, ), ); - trackEvent({ - event: MetaMetricsEventName.sendRecipientSelected, - category: MetaMetricsEventCategory.Send, - properties: { - location: 'send page recipient screen', - inputType: type, + trackEvent( + { + event: MetaMetricsEventName.sendRecipientSelected, + category: MetaMetricsEventCategory.Send, + properties: { + location: 'send page recipient screen', + inputType: type, + }, }, - }); + { excludeMetaMetricsId: false }, + ); dispatch(updateRecipient({ address, nickname })); dispatch(updateRecipientUserInput(address)); }; diff --git a/ui/components/multichain/pages/send/components/your-accounts.tsx b/ui/components/multichain/pages/send/components/your-accounts.tsx index a881e8922634..d05926e7ae87 100644 --- a/ui/components/multichain/pages/send/components/your-accounts.tsx +++ b/ui/components/multichain/pages/send/components/your-accounts.tsx @@ -42,14 +42,17 @@ export const SendPageYourAccounts = () => { `sendFlow - User clicked recipient from my accounts. address: ${account.address}, nickname ${account.name}`, ), ); - trackEvent({ - event: MetaMetricsEventName.sendRecipientSelected, - category: MetaMetricsEventCategory.Send, - properties: { - location: 'my accounts', - inputType: 'click', + trackEvent( + { + event: MetaMetricsEventName.sendRecipientSelected, + category: MetaMetricsEventCategory.Send, + properties: { + location: 'my accounts', + inputType: 'click', + }, }, - }); + { excludeMetaMetricsId: false }, + ); dispatch( updateRecipient({ address: account.address, diff --git a/ui/components/multichain/pages/send/send.js b/ui/components/multichain/pages/send/send.js index b1b11b2d434a..7d62a84ef0b4 100644 --- a/ui/components/multichain/pages/send/send.js +++ b/ui/components/multichain/pages/send/send.js @@ -201,13 +201,16 @@ export const SendPage = () => { } dispatch(resetSendState()); - trackEvent({ - event: MetaMetricsEventName.sendFlowExited, - category: MetaMetricsEventCategory.Send, - properties: { - ...sendAnalytics, + trackEvent( + { + event: MetaMetricsEventName.sendFlowExited, + category: MetaMetricsEventCategory.Send, + properties: { + ...sendAnalytics, + }, }, - }); + { excludeMetaMetricsId: false }, + ); const nextRoute = sendStage === SEND_STAGES.EDIT ? DEFAULT_ROUTE : mostRecentOverviewPage; @@ -216,13 +219,16 @@ export const SendPage = () => { useEffect(() => { if (swapQuotesError) { - trackEvent({ - event: MetaMetricsEventName.sendSwapQuoteError, - category: MetaMetricsEventCategory.Send, - properties: { - ...sendAnalytics, + trackEvent( + { + event: MetaMetricsEventName.sendSwapQuoteError, + category: MetaMetricsEventCategory.Send, + properties: { + ...sendAnalytics, + }, }, - }); + { excludeMetaMetricsId: false }, + ); } // sendAnalytics should not result in the event refiring // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/ui/pages/asset/components/token-buttons.tsx b/ui/pages/asset/components/token-buttons.tsx index 6cd78fab7693..cfa4abee87f0 100644 --- a/ui/pages/asset/components/token-buttons.tsx +++ b/ui/pages/asset/components/token-buttons.tsx @@ -181,16 +181,19 @@ const TokenButtons = ({ { - trackEvent({ - event: MetaMetricsEventName.NavSendButtonClicked, - category: MetaMetricsEventCategory.Navigation, - properties: { - token_symbol: token.symbol, - location: MetaMetricsSwapsEventSource.TokenView, - text: 'Send', - chain_id: chainId, + trackEvent( + { + event: MetaMetricsEventName.NavSendButtonClicked, + category: MetaMetricsEventCategory.Navigation, + properties: { + token_symbol: token.symbol, + location: MetaMetricsSwapsEventSource.TokenView, + text: 'Send', + chain_id: chainId, + }, }, - }); + { excludeMetaMetricsId: false }, + ); try { await dispatch( startNewDraftTransaction({