1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00

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,
This commit is contained in:
Olusegun Akintayo 2022-04-21 22:29:39 +04:00 committed by GitHub
parent 8f47c19b9d
commit 095cc94ed0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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