1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Add some metrics events to the 3box controller (#11447)

This commit is contained in:
Dan J Miller 2021-07-02 17:00:40 -02:30 committed by ryanml
parent e5d54afe80
commit 2da9acd325
2 changed files with 46 additions and 0 deletions

View File

@ -25,6 +25,7 @@ export default class ThreeBoxController {
addressBookController,
version,
getKeyringControllerState,
trackMetaMetricsEvent,
} = opts;
this.preferencesController = preferencesController;
@ -59,6 +60,7 @@ export default class ThreeBoxController {
);
},
});
this._trackMetaMetricsEvent = trackMetaMetricsEvent;
const initState = {
threeBoxSyncingAllowed: false,
@ -83,6 +85,12 @@ export default class ThreeBoxController {
async init() {
const accounts = await this.keyringController.getAccounts();
this.address = accounts[0];
this._trackMetaMetricsEvent({
event: '3Box Initiated',
category: '3Box',
});
if (this.address && !(this.box && this.store.getState().threeBoxSynced)) {
await this.new3Box();
}
@ -140,8 +148,18 @@ export default class ThreeBoxController {
backupExists = threeBoxConfig.spaces && threeBoxConfig.spaces.metamask;
} catch (e) {
if (e.message.match(/^Error: Invalid response \(404\)/u)) {
this._trackMetaMetricsEvent({
event: '3Box Backup does not exist',
category: '3Box',
});
backupExists = false;
} else {
this._trackMetaMetricsEvent({
event: '3Box Config Error',
category: '3Box',
});
throw e;
}
}
@ -175,9 +193,19 @@ export default class ThreeBoxController {
this.store.updateState(stateUpdate);
log.debug('3Box space sync done');
this._trackMetaMetricsEvent({
event: '3Box Synced',
category: '3Box',
});
},
});
} catch (e) {
this._trackMetaMetricsEvent({
event: '3Box Initiation Error',
category: '3Box',
});
console.error(e);
throw e;
}
@ -216,13 +244,28 @@ export default class ThreeBoxController {
preferences && this.preferencesController.store.updateState(preferences);
addressBook && this.addressBookController.update(addressBook, true);
this.setShowRestorePromptToFalse();
this._trackMetaMetricsEvent({
event: '3Box Restored Data',
category: '3Box',
});
}
turnThreeBoxSyncingOn() {
this._trackMetaMetricsEvent({
event: '3Box Sync Turned On',
category: '3Box',
});
this._registerUpdates();
}
turnThreeBoxSyncingOff() {
this._trackMetaMetricsEvent({
event: '3Box Sync Turned Off',
category: '3Box',
});
this.box.logout();
}

View File

@ -315,6 +315,9 @@ export default class MetamaskController extends EventEmitter {
this.keyringController.memStore,
),
version,
trackMetaMetricsEvent: this.metaMetricsController.trackEvent.bind(
this.metaMetricsController,
),
});
this.txController = new TransactionController({