Bug 1283565 - add telemetry to determine whether undo works and how often it's unavailable due to sync, r=dolske,r?bsmedberg draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 30 Jun 2016 19:02:46 +0100
changeset 382871 51b20d73e5a87c52bfe384446a1095777d37776c
parent 382870 0e94936ba7baedb5a951d59ea687e64c48d934ad
child 524317 82ba5a310785ced1bfad3833953f9a83286fbf1c
push id21853
push usergijskruitbosch@gmail.com
push dateThu, 30 Jun 2016 18:13:03 +0000
reviewersdolske, bsmedberg
bugs1283565
milestone50.0a1
Bug 1283565 - add telemetry to determine whether undo works and how often it's unavailable due to sync, r=dolske,r?bsmedberg MozReview-Commit-ID: H9sABIISxTP
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
@@ -4319,16 +4319,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."
+  },
+  "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_MIGRATION_DATA_RECENCY": {
     "bug_numbers": [1276694],
     "alert_emails": ["gijs@mozilla.com"],
     "expires_in_version": "53",
     "keyed": true,
     "kind": "exponential",
     "n_buckets": 50,
     "high": 8760,