1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 20:39:08 +01:00
metamask-extension/ui/pages/swaps/view-on-block-explorer/view-on-block-explorer.js
John Brennan 82368e7451
Rename some events (#15543)
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
2022-08-16 11:39:23 -05:00

48 lines
1.5 KiB
JavaScript

import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import Box from '../../../components/ui/box';
import { I18nContext } from '../../../contexts/i18n';
import { getURLHostName } from '../../../helpers/utils/util';
import { MetaMetricsContext } from '../../../contexts/metametrics';
import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
export default function ViewOnBlockExplorer({
blockExplorerUrl,
sensitiveTrackingProperties,
}) {
const t = useContext(I18nContext);
const trackEvent = useContext(MetaMetricsContext);
const blockExplorerHostName = getURLHostName(blockExplorerUrl);
return (
<Box marginTop={6} className="view-on-block-explorer">
<button
onClick={() => {
trackEvent({
event: EVENT_NAMES.EXTERNAL_LINK_CLICKED,
category: EVENT.CATEGORIES.SWAPS,
sensitiveProperties: sensitiveTrackingProperties,
properties: {
link_type: EVENT.EXTERNAL_LINK_TYPES.TRANSACTION_BLOCK_EXPLORER,
location: 'Swap Transaction',
url_domain: blockExplorerHostName,
},
});
global.platform.openTab({ url: blockExplorerUrl });
}}
>
{t('viewOnCustomBlockExplorer', [
t('blockExplorerSwapAction'),
blockExplorerHostName,
])}
</button>
</Box>
);
}
ViewOnBlockExplorer.propTypes = {
blockExplorerUrl: PropTypes.string.isRequired,
sensitiveTrackingProperties: PropTypes.object.isRequired,
};