1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02: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 GitHub
parent 6fa3cce7ab
commit 7163c56f3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 0 deletions

View File

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

View File

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