Add new token added event (duplicating the existing event structure) when collectible is manually added (#14279)

* Add new token added event (duplicating the existing event structure) when auto detection occurs for NFTs
Set source property to detected on the new token added event,
feature/default_network_editable
Olusegun Akintayo 3 years ago committed by GitHub
parent 8f47c19b9d
commit 095cc94ed0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      ui/pages/add-collectible/add-collectible.js

@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useContext, useState } from 'react';
import { useHistory } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import { util } from '@metamask/controllers';
@ -17,6 +17,7 @@ import ActionableMessage from '../../components/ui/actionable-message';
import PageContainer from '../../components/ui/page-container';
import {
addCollectibleVerifyOwnership,
getTokenStandardAndDetails,
removeToken,
setNewCollectibleAddedMessage,
} from '../../store/actions';
@ -24,6 +25,8 @@ import FormField from '../../components/ui/form-field';
import { getIsMainnet, getUseCollectibleDetection } from '../../selectors';
import { getCollectiblesDetectionNoticeDismissed } from '../../ducks/metamask/metamask';
import CollectiblesDetectionNotice from '../../components/app/collectibles-detection-notice';
import { MetaMetricsContext } from '../../contexts/metametrics';
import { ASSET_TYPES } from '../../../shared/constants/transaction';
export default function AddCollectible() {
const t = useI18nContext();
@ -47,6 +50,7 @@ export default function AddCollectible() {
const [tokenId, setTokenId] = useState('');
const [disabled, setDisabled] = useState(true);
const [collectibleAddFailed, setCollectibleAddFailed] = useState(false);
const trackEvent = useContext(MetaMetricsContext);
const handleAddCollectible = async () => {
try {
@ -65,6 +69,26 @@ export default function AddCollectible() {
);
}
dispatch(setNewCollectibleAddedMessage('success'));
const tokenDetails = await getTokenStandardAndDetails(
address,
null,
tokenId.toString(),
);
trackEvent({
event: 'Token Added',
category: 'Wallet',
sensitiveProperties: {
token_contract_address: address,
token_symbol: tokenDetails?.symbol,
tokenId: tokenId.toString(),
asset_type: ASSET_TYPES.COLLECTIBLE,
token_standard: tokenDetails?.standard,
source: 'custom',
},
});
history.push(DEFAULT_ROUTE);
};

Loading…
Cancel
Save