1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-01 21:57:06 +01:00
metamask-extension/ui/pages/onboarding-flow/metametrics/metametrics.js

198 lines
5.6 KiB
JavaScript
Raw Normal View History

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,
UX: Icons: Remove IconCheck and fa-check (#17787) * UX: Icons: Remove IconCheck and fa-check * update jest snapshots * Update story * Remove dead CSS * Update ui/components/app/account-menu/account-menu.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/dropdowns/network-dropdown.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/modals/metametrics-opt-in-modal/metametrics-opt-in-modal.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/settings/networks-tab/networks-list-item/networks-list-item.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/settings/networks-tab/networks-list-item/networks-list-item.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/permissions-connect/redirect/permissions-redirect.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/send/send-content/add-recipient/domain-input.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/onboarding-flow/metametrics/metametrics.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/modals/transaction-confirmed/transaction-confirmed.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/modals/metametrics-opt-in-modal/metametrics-opt-in-modal.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Fix jest snapshots * Update sizes of network andd account menu checks * Fix ICON_SIZES in account menu * Improvements * Use IconColor * Use IconColor * Lint * Update snapshots --------- Co-authored-by: George Marshall <george.marshall@consensys.net>
2023-02-23 14:19:28 +01:00
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';
2022-08-18 23:31:07 +02:00
import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import { MetaMetricsContext } from '../../../contexts/metametrics';
UX: Icons: Remove IconCheck and fa-check (#17787) * UX: Icons: Remove IconCheck and fa-check * update jest snapshots * Update story * Remove dead CSS * Update ui/components/app/account-menu/account-menu.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/dropdowns/network-dropdown.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/modals/metametrics-opt-in-modal/metametrics-opt-in-modal.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/settings/networks-tab/networks-list-item/networks-list-item.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/settings/networks-tab/networks-list-item/networks-list-item.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/permissions-connect/redirect/permissions-redirect.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/send/send-content/add-recipient/domain-input.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/onboarding-flow/metametrics/metametrics.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/modals/transaction-confirmed/transaction-confirmed.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/modals/metametrics-opt-in-modal/metametrics-opt-in-modal.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Fix jest snapshots * Update sizes of network andd account menu checks * Fix ICON_SIZES in account menu * Improvements * Use IconColor * Use IconColor * Lint * Update snapshots --------- Co-authored-by: George Marshall <george.marshall@consensys.net>
2023-02-23 14:19:28 +01:00
import { Icon, ICON_NAMES } from '../../../components/component-library';
export default function OnboardingMetametrics() {
const t = useI18nContext();
const dispatch = useDispatch();
const history = useHistory();
const nextRoute = useSelector(getFirstTimeFlowTypeRoute);
const firstTimeFlowType = useSelector(getFirstTimeFlowType);
2022-03-29 15:46:24 +02:00
const trackEvent = useContext(MetaMetricsContext);
const onConfirm = async () => {
const [, metaMetricsId] = await dispatch(setParticipateInMetaMetrics(true));
try {
2022-03-29 15:46:24 +02:00
trackEvent(
{
category: EVENT.CATEGORIES.ONBOARDING,
2022-08-18 23:31:07 +02:00
event: EVENT_NAMES.WALLET_SETUP_STARTED,
2022-03-29 15:46:24 +02:00
properties: {
2022-08-18 23:31:07 +02:00
account_type:
firstTimeFlowType === 'create'
? EVENT.ACCOUNT_TYPES.DEFAULT
: EVENT.ACCOUNT_TYPES.IMPORTED,
2022-03-29 15:46:24 +02:00
},
},
{
isOptIn: true,
metaMetricsId,
flushImmediately: true,
},
2022-03-29 15:46:24 +02:00
);
} finally {
history.push(nextRoute);
}
};
const onCancel = async () => {
await dispatch(setParticipateInMetaMetrics(false));
history.push(nextRoute);
};
return (
<div
className="onboarding-metametrics"
data-testid="onboarding-metametrics"
>
<Typography
variant={TypographyVariant.H2}
align={TEXT_ALIGN.CENTER}
fontWeight={FONT_WEIGHT.BOLD}
>
{t('onboardingMetametricsTitle')}
</Typography>
<Typography
className="onboarding-metametrics__desc"
align={TEXT_ALIGN.CENTER}
>
{t('onboardingMetametricsDescription')}
</Typography>
<Typography
className="onboarding-metametrics__desc"
align={TEXT_ALIGN.CENTER}
>
{t('onboardingMetametricsDescription2')}
</Typography>
<ul>
<li>
UX: Icons: Remove IconCheck and fa-check (#17787) * UX: Icons: Remove IconCheck and fa-check * update jest snapshots * Update story * Remove dead CSS * Update ui/components/app/account-menu/account-menu.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/dropdowns/network-dropdown.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/modals/metametrics-opt-in-modal/metametrics-opt-in-modal.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/settings/networks-tab/networks-list-item/networks-list-item.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/settings/networks-tab/networks-list-item/networks-list-item.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/permissions-connect/redirect/permissions-redirect.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/send/send-content/add-recipient/domain-input.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/onboarding-flow/metametrics/metametrics.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/modals/transaction-confirmed/transaction-confirmed.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/modals/metametrics-opt-in-modal/metametrics-opt-in-modal.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Fix jest snapshots * Update sizes of network andd account menu checks * Fix ICON_SIZES in account menu * Improvements * Use IconColor * Use IconColor * Lint * Update snapshots --------- Co-authored-by: George Marshall <george.marshall@consensys.net>
2023-02-23 14:19:28 +01:00
<Icon
name={ICON_NAMES.CHECK}
color={IconColor.successDefault}
marginInlineEnd={3}
/>
{t('onboardingMetametricsAllowOptOut')}
</li>
<li>
UX: Icons: Remove IconCheck and fa-check (#17787) * UX: Icons: Remove IconCheck and fa-check * update jest snapshots * Update story * Remove dead CSS * Update ui/components/app/account-menu/account-menu.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/dropdowns/network-dropdown.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/modals/metametrics-opt-in-modal/metametrics-opt-in-modal.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/settings/networks-tab/networks-list-item/networks-list-item.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/settings/networks-tab/networks-list-item/networks-list-item.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/permissions-connect/redirect/permissions-redirect.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/send/send-content/add-recipient/domain-input.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/pages/onboarding-flow/metametrics/metametrics.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/modals/transaction-confirmed/transaction-confirmed.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/modals/metametrics-opt-in-modal/metametrics-opt-in-modal.component.js Co-authored-by: George Marshall <george.marshall@consensys.net> * Fix jest snapshots * Update sizes of network andd account menu checks * Fix ICON_SIZES in account menu * Improvements * Use IconColor * Use IconColor * Lint * Update snapshots --------- Co-authored-by: George Marshall <george.marshall@consensys.net>
2023-02-23 14:19:28 +01:00
<Icon
name={ICON_NAMES.CHECK}
color={IconColor.successDefault}
marginInlineEnd={3}
/>
{t('onboardingMetametricsSendAnonymize')}
</li>
<li>
<i className="fa fa-times" />
{t('onboardingMetametricsNeverCollect', [
<Typography
variant={TypographyVariant.Span}
key="never"
fontWeight={FONT_WEIGHT.BOLD}
>
{t('onboardingMetametricsNeverEmphasis')}
</Typography>,
])}
</li>
<li>
<i className="fa fa-times" />
{t('onboardingMetametricsNeverCollectIP', [
<Typography
variant={TypographyVariant.Span}
key="never-collect"
fontWeight={FONT_WEIGHT.BOLD}
>
{t('onboardingMetametricsNeverEmphasis')}
</Typography>,
])}
</li>
<li>
<i className="fa fa-times" />
{t('onboardingMetametricsNeverSellData', [
<Typography
variant={TypographyVariant.Span}
key="never-sell"
fontWeight={FONT_WEIGHT.BOLD}
>
{t('onboardingMetametricsNeverEmphasis')}
</Typography>,
])}
</li>
</ul>
<Typography
color={TextColor.textAlternative}
align={TEXT_ALIGN.CENTER}
variant={TypographyVariant.H6}
className="onboarding-metametrics__terms"
>
{t('onboardingMetametricsDataTerms')}
</Typography>
<Typography
color={TextColor.textAlternative}
align={TEXT_ALIGN.CENTER}
variant={TypographyVariant.H6}
className="onboarding-metametrics__terms"
>
{t('onboardingMetametricsInfuraTerms', [
<a
href="https://consensys.net/blog/news/consensys-data-retention-update/"
target="_blank"
rel="noopener noreferrer"
key="retention-link"
>
{t('onboardingMetametricsInfuraTermsPolicyLink')}
</a>,
<a
href="https://metamask.io/privacy.html"
target="_blank"
rel="noopener noreferrer"
key="privacy-link"
>
{t('onboardingMetametricsInfuraTermsPolicy')}
</a>,
])}
</Typography>
<div className="onboarding-metametrics__buttons">
<Button
data-testid="metametrics-i-agree"
type="primary"
large
onClick={onConfirm}
>
{t('onboardingMetametricsAgree')}
</Button>
<Button
data-testid="metametrics-no-thanks"
type="secondary"
large
onClick={onCancel}
>
{t('onboardingMetametricsDisagree')}
</Button>
</div>
</div>
);
}