1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Call metrics event for wallet type selection at the right time (#15591)

This commit is contained in:
Dan J Miller 2022-08-15 20:12:08 -02:30 committed by GitHub
parent 6855b06e13
commit 65d2ff9c8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 36 deletions

View File

@ -9,7 +9,6 @@ export default class MetaMetricsOptIn extends Component {
static propTypes = {
history: PropTypes.object,
setParticipateInMetaMetrics: PropTypes.func,
firstTimeSelectionMetaMetricsName: PropTypes.string,
participateInMetaMetrics: PropTypes.bool,
};
@ -20,12 +19,8 @@ export default class MetaMetricsOptIn extends Component {
render() {
const { trackEvent, t } = this.context;
const {
history,
setParticipateInMetaMetrics,
firstTimeSelectionMetaMetricsName,
participateInMetaMetrics,
} = this.props;
const { history, setParticipateInMetaMetrics, participateInMetaMetrics } =
this.props;
return (
<div className="metametrics-opt-in">
@ -109,50 +104,27 @@ export default class MetaMetricsOptIn extends Component {
cancelText={t('noThanks')}
hideCancel={false}
onSubmit={async () => {
const [, metaMetricsId] = await setParticipateInMetaMetrics(
true,
);
await setParticipateInMetaMetrics(true);
try {
const metrics = [];
if (
participateInMetaMetrics === null ||
participateInMetaMetrics === false
) {
metrics.push(
trackEvent(
{
category: EVENT.CATEGORIES.ONBOARDING,
event: 'Metrics Opt In',
properties: {
action: 'Metrics Option',
legacy_event: true,
},
},
{
isOptIn: true,
flushImmediately: true,
},
),
);
}
metrics.push(
trackEvent(
await trackEvent(
{
category: EVENT.CATEGORIES.ONBOARDING,
event: firstTimeSelectionMetaMetricsName,
event: 'Metrics Opt In',
properties: {
action: 'Import or Create',
action: 'Metrics Option',
legacy_event: true,
},
},
{
isOptIn: true,
metaMetricsId,
flushImmediately: true,
},
),
);
await Promise.all(metrics);
);
}
} finally {
history.push(INITIALIZE_SELECT_ACTION_ROUTE);
}

View File

@ -2,6 +2,7 @@ import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import Button from '../../../components/ui/button';
import MetaFoxLogo from '../../../components/ui/metafox-logo';
import { EVENT } from '../../../../shared/constants/metametrics';
import {
INITIALIZE_CREATE_PASSWORD_ROUTE,
INITIALIZE_IMPORT_WITH_SEED_PHRASE_ROUTE,
@ -13,9 +14,11 @@ export default class SelectAction extends PureComponent {
isInitialized: PropTypes.bool,
setFirstTimeFlowType: PropTypes.func,
nextRoute: PropTypes.string,
metaMetricsId: PropTypes.string,
};
static contextTypes = {
trackEvent: PropTypes.func,
t: PropTypes.func,
};
@ -28,12 +31,46 @@ export default class SelectAction extends PureComponent {
}
handleCreate = () => {
const { metaMetricsId } = this.props;
const { trackEvent } = this.context;
this.props.setFirstTimeFlowType('create');
trackEvent(
{
category: EVENT.CATEGORIES.ONBOARDING,
event: 'Selected Create New Wallet',
properties: {
action: 'Import or Create',
legacy_event: true,
},
},
{
isOptIn: true,
metaMetricsId,
flushImmediately: true,
},
);
this.props.history.push(INITIALIZE_CREATE_PASSWORD_ROUTE);
};
handleImport = () => {
const { metaMetricsId } = this.props;
const { trackEvent } = this.context;
this.props.setFirstTimeFlowType('import');
trackEvent(
{
category: EVENT.CATEGORIES.ONBOARDING,
event: 'Selected Import Wallet',
properties: {
action: 'Import or Create',
legacy_event: true,
},
},
{
isOptIn: true,
metaMetricsId,
flushImmediately: true,
},
);
this.props.history.push(INITIALIZE_IMPORT_WITH_SEED_PHRASE_ROUTE);
};

View File

@ -8,6 +8,7 @@ import Welcome from './select-action.component';
const mapStateToProps = (state) => {
return {
nextRoute: getFirstTimeFlowTypeRoute(state),
metaMetricsId: state.metamask.metaMetricsId,
};
};