mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01: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:
parent
8f47c19b9d
commit
095cc94ed0
@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useContext, useState } 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 { util } from '@metamask/controllers';
|
import { util } from '@metamask/controllers';
|
||||||
@ -17,6 +17,7 @@ import ActionableMessage from '../../components/ui/actionable-message';
|
|||||||
import PageContainer from '../../components/ui/page-container';
|
import PageContainer from '../../components/ui/page-container';
|
||||||
import {
|
import {
|
||||||
addCollectibleVerifyOwnership,
|
addCollectibleVerifyOwnership,
|
||||||
|
getTokenStandardAndDetails,
|
||||||
removeToken,
|
removeToken,
|
||||||
setNewCollectibleAddedMessage,
|
setNewCollectibleAddedMessage,
|
||||||
} from '../../store/actions';
|
} from '../../store/actions';
|
||||||
@ -24,6 +25,8 @@ import FormField from '../../components/ui/form-field';
|
|||||||
import { getIsMainnet, getUseCollectibleDetection } from '../../selectors';
|
import { getIsMainnet, getUseCollectibleDetection } from '../../selectors';
|
||||||
import { getCollectiblesDetectionNoticeDismissed } from '../../ducks/metamask/metamask';
|
import { getCollectiblesDetectionNoticeDismissed } from '../../ducks/metamask/metamask';
|
||||||
import CollectiblesDetectionNotice from '../../components/app/collectibles-detection-notice';
|
import CollectiblesDetectionNotice from '../../components/app/collectibles-detection-notice';
|
||||||
|
import { MetaMetricsContext } from '../../contexts/metametrics';
|
||||||
|
import { ASSET_TYPES } from '../../../shared/constants/transaction';
|
||||||
|
|
||||||
export default function AddCollectible() {
|
export default function AddCollectible() {
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
@ -47,6 +50,7 @@ export default function AddCollectible() {
|
|||||||
const [tokenId, setTokenId] = useState('');
|
const [tokenId, setTokenId] = useState('');
|
||||||
const [disabled, setDisabled] = useState(true);
|
const [disabled, setDisabled] = useState(true);
|
||||||
const [collectibleAddFailed, setCollectibleAddFailed] = useState(false);
|
const [collectibleAddFailed, setCollectibleAddFailed] = useState(false);
|
||||||
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
|
|
||||||
const handleAddCollectible = async () => {
|
const handleAddCollectible = async () => {
|
||||||
try {
|
try {
|
||||||
@ -65,6 +69,26 @@ export default function AddCollectible() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
dispatch(setNewCollectibleAddedMessage('success'));
|
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);
|
history.push(DEFAULT_ROUTE);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user