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

Prevent user from getting stuck on opt in page (#9856)

Failed metric events on the opt-in page no longer leave the user stuck
on that page. If the metric events fail, they still bubble up as errors
to be caught by Sentry and logged to the console, but the user is still
brought to the next page.

Fixes #9800
This commit is contained in:
Mark Stacey 2020-11-11 18:33:11 -03:30 committed by GitHub
parent 6b38017b23
commit d5076e142a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,11 +101,12 @@ export default class MetaMetricsOptIn extends Component {
</div>
<div className="metametrics-opt-in__footer">
<PageContainerFooter
onCancel={() => {
setParticipateInMetaMetrics(false).then(() => {
const promise =
participateInMetaMetrics === true
? metricsEvent({
onCancel={async () => {
await setParticipateInMetaMetrics(false)
try {
if (participateInMetaMetrics === true) {
await metricsEvent({
eventOpts: {
category: 'Onboarding',
action: 'Metrics Option',
@ -113,32 +114,33 @@ export default class MetaMetricsOptIn extends Component {
},
isOptIn: true,
})
: Promise.resolve()
promise.then(() => {
}
} finally {
history.push(nextRoute)
})
})
}
}}
cancelText={t('noThanks')}
hideCancel={false}
onSubmit={() => {
setParticipateInMetaMetrics(true).then(([_, metaMetricsId]) => {
const promise =
participateInMetaMetrics === false
? metricsEvent({
onSubmit={async () => {
const [, metaMetricsId] = await setParticipateInMetaMetrics(
true,
)
try {
const metrics = []
if (participateInMetaMetrics === false) {
metrics.push(
metricsEvent({
eventOpts: {
category: 'Onboarding',
action: 'Metrics Option',
name: 'Metrics Opt In',
},
isOptIn: true,
})
: Promise.resolve()
promise
.then(() => {
return metricsEvent({
}),
)
}
metrics.push(
metricsEvent({
eventOpts: {
category: 'Onboarding',
action: 'Import or Create',
@ -146,12 +148,12 @@ export default class MetaMetricsOptIn extends Component {
},
isOptIn: true,
metaMetricsId,
})
})
.then(() => {
}),
)
await Promise.all(metrics)
} finally {
history.push(nextRoute)
})
})
}
}}
submitText={t('affirmAgree')}
submitButtonType="primary"