Bug 1283565 - Add telemetry to determine whether undo works and how often it's unavailable due to sync. r=dolske, data-r=bsmedberg, a=lizzard
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 30 Jun 2016 19:02:46 +0100
changeset 342462 ffc2be7a4b149b9b4aa5fa36dbe5cd9920b06eaf
parent 342461 efd321bddf46bfe6da2881398f9311c1b898ed31
child 342463 b7e08435c4787f937d706187534da49eab575e49
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske, lizzard
bugs1283565
milestone49.0
Bug 1283565 - Add telemetry to determine whether undo works and how often it's unavailable due to sync. r=dolske, data-r=bsmedberg, a=lizzard MozReview-Commit-ID: LwFrwbEQLtV
browser/components/migration/AutoMigrate.jsm
toolkit/components/telemetry/Histograms.json
--- a/browser/components/migration/AutoMigrate.jsm
+++ b/browser/components/migration/AutoMigrate.jsm
@@ -140,42 +140,56 @@ const AutoMigrate = {
 
   canUndo() {
     if (!this.getUndoRange()) {
       return Promise.resolve(false);
     }
     // Return a promise resolving to false if we're signed into sync, resolve
     // to true otherwise.
     let {fxAccounts} = Cu.import("resource://gre/modules/FxAccounts.jsm", {});
-    return fxAccounts.getSignedInUser().then(user => !user, () => Promise.resolve(true));
+    return fxAccounts.getSignedInUser().then(user => {
+      if (user) {
+        Services.telemetry.getHistogramById("FX_STARTUP_MIGRATION_CANT_UNDO_BECAUSE_SYNC").add(true);
+      }
+      return !user;
+    }, () => Promise.resolve(true));
   },
 
   undo: Task.async(function* () {
+    let histogram = Services.telemetry.getHistogramById("FX_STARTUP_MIGRATION_AUTOMATED_IMPORT_UNDO");
+    histogram.add(0);
     if (!(yield this.canUndo())) {
+      histogram.add(5);
       throw new Error("Can't undo!");
     }
 
+    histogram.add(10);
+
     yield PlacesUtils.bookmarks.eraseEverything();
+    histogram.add(15);
 
     // NB: we drop the start time of the migration for now. This is because
     // imported history will always end up being 'backdated' to the actual
     // visit time recorded by the browser from which we imported. As a result,
     // a lower bound on this item doesn't really make sense.
     // Note that for form data this could be different, but we currently don't
     // support form data import from any non-Firefox browser, so it isn't
     // imported from other browsers by the automigration code, nor do we
     // remove it here.
     let range = this.getUndoRange();
     yield PlacesUtils.history.removeVisitsByFilter({
       beginDate: new Date(0),
       endDate: range[1]
     });
+    histogram.add(20);
 
     try {
       Services.logins.removeAllLogins();
     } catch (ex) {
       // ignore failure.
     }
+    histogram.add(25);
     Services.prefs.clearUserPref("browser.migrate.automigrate-started");
     Services.prefs.clearUserPref("browser.migrate.automigrate-finished");
+    histogram.add(30);
   }),
 };
 
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -4470,16 +4470,33 @@
     "bug_numbers": [1271775],
     "alert_emails": ["gijs@mozilla.com"],
     "expires_in_version": "53",
     "kind": "enumerated",
     "n_values": 27,
     "releaseChannelCollection": "opt-out",
     "description": "Where automatic migration was attempted, indicates to what degree we succeeded. Values 0-25 indicate progress through the automatic migration sequence, with 25 indicating the migration finished. 26 is only used when the migration produced errors before it finished."
   },
+  "FX_STARTUP_MIGRATION_AUTOMATED_IMPORT_UNDO": {
+    "bug_numbers": [1283565],
+    "alert_emails": ["gijs@mozilla.com"],
+    "expires_in_version": "53",
+    "kind": "enumerated",
+    "n_values": 31,
+    "releaseChannelCollection": "opt-out",
+    "description": "Where undo of the automatic migration was attempted, indicates to what degree we succeeded to undo. 0 means we started to undo, 5 means we bailed out from the undo because it was not possible to complete it (there was nothing to undo or the user was signed in to sync). All higher values indicate progression through the undo sequence, with 30 indicating we finished the undo without exceptions in the middle."
+  },
+  "FX_STARTUP_MIGRATION_CANT_UNDO_BECAUSE_SYNC": {
+    "bug_numbers": [1283565],
+    "alert_emails": ["gijs@mozilla.com"],
+    "expires_in_version": "53",
+    "kind": "boolean",
+    "releaseChannelCollection": "opt-out",
+    "description": "Where undo of the automatic migration was requested and denied because the user was logged into sync."
+  },
   "FX_STARTUP_EXTERNAL_CONTENT_HANDLER": {
     "bug_numbers": [1276027],
     "alert_emails": ["jaws@mozilla.com"],
     "expires_in_version": "53",
     "kind": "count",
     "description": "Count how often the browser is opened as an external app handler. This is generally used when the browser is set as the default browser."
   },
   "INPUT_EVENT_RESPONSE_MS": {