diff --git a/app/scripts/controllers/metametrics.js b/app/scripts/controllers/metametrics.js index 39bbae6f9743..55a50803e90c 100644 --- a/app/scripts/controllers/metametrics.js +++ b/app/scripts/controllers/metametrics.js @@ -170,33 +170,28 @@ export default class MetaMetricsController { ); if (hasAlarm) { - Object.values(this.store.getState().fragments).forEach( - (fragment) => { - if ( - fragment.timeout && - Date.now() - fragment.lastUpdated / 1000 > fragment.timeout - ) { - this.finalizeEventFragment(fragment.id, { abandoned: true }); - } - }, - ); + this.finalizeAbandonedFragments(); } }); }); } else { setInterval(() => { - Object.values(this.store.getState().fragments).forEach((fragment) => { - if ( - fragment.timeout && - Date.now() - fragment.lastUpdated / 1000 > fragment.timeout - ) { - this.finalizeEventFragment(fragment.id, { abandoned: true }); - } - }); + this.finalizeAbandonedFragments(); }, SECOND * 30); } } + finalizeAbandonedFragments() { + Object.values(this.store.getState().fragments).forEach((fragment) => { + if ( + fragment.timeout && + Date.now() - fragment.lastUpdated / 1000 > fragment.timeout + ) { + this.finalizeEventFragment(fragment.id, { abandoned: true }); + } + }); + } + generateMetaMetricsId() { return bufferToHex( keccak(