1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-13 13:17:13 +01:00
metamask-extension/ui/pages/first-time-flow/welcome/welcome.component.js
Dan J Miller 101fe0b27a
Metrics adjustments (#15313)
* Don't send errors to sentry if users have not opted-in to participate in metametrics

* Don't capture opt-out metrics

* Move the metrics-opt in screen to immediately after the welcome screen

* Ensure that global.getSentryState is set in the background

* Fix e2e tests after rearranging onboardin flow

* Fix unit tests

* More e2e test fixes

* Remove unnecessary wrappers around capture exception
2022-07-22 18:09:48 -02:30

82 lines
2.1 KiB
JavaScript

import EventEmitter from 'events';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import Mascot from '../../../components/ui/mascot';
import Button from '../../../components/ui/button';
import {
INITIALIZE_CREATE_PASSWORD_ROUTE,
INITIALIZE_SELECT_ACTION_ROUTE,
INITIALIZE_METAMETRICS_OPT_IN_ROUTE,
} from '../../../helpers/constants/routes';
import { isBeta } from '../../../helpers/utils/build-types';
import WelcomeFooter from './welcome-footer.component';
import BetaWelcomeFooter from './beta-welcome-footer.component';
export default class Welcome extends PureComponent {
static propTypes = {
history: PropTypes.object,
participateInMetaMetrics: PropTypes.bool,
welcomeScreenSeen: PropTypes.bool,
isInitialized: PropTypes.bool,
};
static contextTypes = {
t: PropTypes.func,
};
constructor(props) {
super(props);
this.animationEventEmitter = new EventEmitter();
}
componentDidMount() {
const {
history,
participateInMetaMetrics,
welcomeScreenSeen,
isInitialized,
} = this.props;
if (
welcomeScreenSeen &&
isInitialized &&
participateInMetaMetrics !== null
) {
history.push(INITIALIZE_CREATE_PASSWORD_ROUTE);
} else if (welcomeScreenSeen && participateInMetaMetrics !== null) {
history.push(INITIALIZE_SELECT_ACTION_ROUTE);
} else if (welcomeScreenSeen) {
history.push(INITIALIZE_METAMETRICS_OPT_IN_ROUTE);
}
}
handleContinue = () => {
this.props.history.push(INITIALIZE_METAMETRICS_OPT_IN_ROUTE);
};
render() {
const { t } = this.context;
return (
<div className="welcome-page__wrapper">
<div className="welcome-page">
<Mascot
animationEventEmitter={this.animationEventEmitter}
width="125"
height="125"
/>
{isBeta() ? <BetaWelcomeFooter /> : <WelcomeFooter />}
<Button
type="primary"
className="first-time-flow__button"
onClick={this.handleContinue}
>
{t('getStarted')}
</Button>
</div>
</div>
);
}
}