import React, { useContext } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { useHistory } from 'react-router-dom'; import Typography from '../../../components/ui/typography/typography'; import { TypographyVariant, FONT_WEIGHT, TEXT_ALIGN, TextColor, IconColor, } from '../../../helpers/constants/design-system'; import Button from '../../../components/ui/button'; import { useI18nContext } from '../../../hooks/useI18nContext'; import { setParticipateInMetaMetrics } from '../../../store/actions'; import { getFirstTimeFlowTypeRoute, getFirstTimeFlowType, } from '../../../selectors'; import { MetaMetricsEventAccountType, MetaMetricsEventCategory, MetaMetricsEventName, } from '../../../../shared/constants/metametrics'; import { MetaMetricsContext } from '../../../contexts/metametrics'; import { Icon, IconName, IconSize, } from '../../../components/component-library'; import Box from '../../../components/ui/box/box'; export default function OnboardingMetametrics() { const t = useI18nContext(); const dispatch = useDispatch(); const history = useHistory(); const nextRoute = useSelector(getFirstTimeFlowTypeRoute); const firstTimeFlowType = useSelector(getFirstTimeFlowType); const trackEvent = useContext(MetaMetricsContext); const onConfirm = async () => { const [, metaMetricsId] = await dispatch(setParticipateInMetaMetrics(true)); try { trackEvent( { category: MetaMetricsEventCategory.Onboarding, event: MetaMetricsEventName.WalletSetupStarted, properties: { account_type: firstTimeFlowType === 'create' ? MetaMetricsEventAccountType.Default : MetaMetricsEventAccountType.Imported, }, }, { isOptIn: true, metaMetricsId, flushImmediately: true, }, ); } finally { history.push(nextRoute); } }; const onCancel = async () => { await dispatch(setParticipateInMetaMetrics(false)); history.push(nextRoute); }; return (