Bug 1275114 - add telemetry to determine how to make browser choices when automatically migrating on first profile startup, r?MattN
MozReview-Commit-ID: zVmKTBzAS9
--- a/browser/components/migration/MigrationUtils.jsm
+++ b/browser/components/migration/MigrationUtils.jsm
@@ -44,50 +44,16 @@ function getMigrationBundle() {
if (!gMigrationBundle) {
gMigrationBundle = Services.strings.createBundle(
"chrome://browser/locale/migration/migration.properties");
}
return gMigrationBundle;
}
/**
- * Figure out what is the default browser, and if there is a migrator
- * for it, return that migrator's internal name.
- * For the time being, the "internal name" of a migrator is its contract-id
- * trailer (e.g. ie for @mozilla.org/profile/migrator;1?app=browser&type=ie),
- * but it will soon be exposed properly.
- */
-function getMigratorKeyForDefaultBrowser() {
- // Canary uses the same description as Chrome so we can't distinguish them.
- const APP_DESC_TO_KEY = {
- "Internet Explorer": "ie",
- "Safari": "safari",
- "Firefox": "firefox",
- "Google Chrome": "chrome", // Windows, Linux
- "Chrome": "chrome", // OS X
- "Chromium": "chromium", // Windows, OS X
- "Chromium Web Browser": "chromium", // Linux
- "360\u5b89\u5168\u6d4f\u89c8\u5668": "360se",
- };
-
- let browserDesc = "";
- try {
- let browserDesc =
- Cc["@mozilla.org/uriloader/external-protocol-service;1"].
- getService(Ci.nsIExternalProtocolService).
- getApplicationDescription("http");
- return APP_DESC_TO_KEY[browserDesc] || "";
- }
- catch(ex) {
- Cu.reportError("Could not detect default browser: " + ex);
- }
- return "";
-}
-
-/**
* Shared prototype for migrators, implementing nsIBrowserProfileMigrator.
*
* To implement a migrator:
* 1. Import this module.
* 2. Create the prototype for the migrator, extending MigratorPrototype.
* Namely: MosaicMigrator.prototype = Object.create(MigratorPrototype);
* 3. Set classDescription, contractID and classID for your migrator, and set
* NSGetFactory appropriately.
@@ -516,16 +482,50 @@ this.MigrationUtils = Object.freeze({
this._migrators.set(aKey, migrator);
}
try {
return migrator && migrator.sourceExists ? migrator : null;
} catch (ex) { Cu.reportError(ex); return null }
},
+ /**
+ * Figure out what is the default browser, and if there is a migrator
+ * for it, return that migrator's internal name.
+ * For the time being, the "internal name" of a migrator is its contract-id
+ * trailer (e.g. ie for @mozilla.org/profile/migrator;1?app=browser&type=ie),
+ * but it will soon be exposed properly.
+ */
+ getMigratorKeyForDefaultBrowser() {
+ // Canary uses the same description as Chrome so we can't distinguish them.
+ const APP_DESC_TO_KEY = {
+ "Internet Explorer": "ie",
+ "Safari": "safari",
+ "Firefox": "firefox",
+ "Google Chrome": "chrome", // Windows, Linux
+ "Chrome": "chrome", // OS X
+ "Chromium": "chromium", // Windows, OS X
+ "Chromium Web Browser": "chromium", // Linux
+ "360\u5b89\u5168\u6d4f\u89c8\u5668": "360se",
+ };
+
+ let browserDesc = "";
+ try {
+ let browserDesc =
+ Cc["@mozilla.org/uriloader/external-protocol-service;1"].
+ getService(Ci.nsIExternalProtocolService).
+ getApplicationDescription("http");
+ return APP_DESC_TO_KEY[browserDesc] || "";
+ }
+ catch(ex) {
+ Cu.reportError("Could not detect default browser: " + ex);
+ }
+ return "";
+ },
+
// Whether or not we're in the process of startup migration
get isStartupMigration() {
return gProfileStartup != null;
},
/**
* In the case of startup migration, this is set to the nsIProfileStartup
* instance passed to ProfileMigrator's migrate.
@@ -656,17 +656,17 @@ this.MigrationUtils = Object.freeze({
this.finishMigration();
throw new Error("startMigration was asked to open auto-migrate from " +
"a non-existent source: " + aMigratorKey);
}
migratorKey = aMigratorKey;
skipSourcePage = true;
}
else {
- let defaultBrowserKey = getMigratorKeyForDefaultBrowser();
+ let defaultBrowserKey = this.getMigratorKeyForDefaultBrowser();
if (defaultBrowserKey) {
migrator = this.getMigrator(defaultBrowserKey);
if (migrator)
migratorKey = defaultBrowserKey;
}
}
if (!migrator) {
--- a/browser/components/migration/content/migration.js
+++ b/browser/components/migration/content/migration.js
@@ -29,16 +29,17 @@ var MigrationWizard = {
os.addObserver(this, "Migration:ItemError", false);
os.addObserver(this, "Migration:Ended", false);
this._wiz = document.documentElement;
let args = window.arguments;
let entryPointId = args[0] || MigrationUtils.MIGRATION_ENTRYPOINT_UNKNOWN;
Services.telemetry.getHistogramById("FX_MIGRATION_ENTRY_POINT").add(entryPointId);
+ this.isInitialMigration = entryPointId == MigrationUtils.MIGRATION_ENTRYPOINT_FIRSTRUN;
if (args.length > 1) {
this._source = args[1];
this._migrator = args[2] instanceof kIMig ? args[2] : null;
this._autoMigrate = args[3].QueryInterface(kIPStartup);
this._skipImportSourcePage = args[4];
if (this._migrator && args[5]) {
let sourceProfiles = this._migrator.sourceProfiles;
@@ -80,31 +81,42 @@ var MigrationWizard = {
document.getElementById("closeSourceBrowser").style.visibility = visibility;
}
this._wiz.canRewind = false;
var selectedMigrator = null;
// Figure out what source apps are are available to import from:
var group = document.getElementById("importSourceGroup");
+ var availableMigratorCount = 0;
for (var i = 0; i < group.childNodes.length; ++i) {
var migratorKey = group.childNodes[i].id;
if (migratorKey != "nothing") {
var migrator = MigrationUtils.getMigrator(migratorKey);
if (migrator) {
// Save this as the first selectable item, if we don't already have
// one, or if it is the migrator that was passed to us.
if (!selectedMigrator || this._source == migratorKey)
selectedMigrator = group.childNodes[i];
+ availableMigratorCount++;
} else {
// Hide this option
group.childNodes[i].hidden = true;
}
}
}
+ if (this.isInitialMigration) {
+ Services.telemetry.getHistogramById("FX_STARTUP_MIGRATION_BROWSER_COUNT")
+ .add(availableMigratorCount);
+ let defaultBrowser = MigrationUtils.getMigratorKeyForDefaultBrowser();
+ // This will record 0 for unknown default browser IDs.
+ defaultBrowser = MigrationUtils.getSourceIdForTelemetry(defaultBrowser);
+ Services.telemetry.getHistogramById("FX_STARTUP_MIGRATION_EXISTING_DEFAULT_BROWSER")
+ .add(defaultBrowser);
+ }
group.addEventListener("command", toggleCloseBrowserWarning);
if (selectedMigrator) {
group.selectedItem = selectedMigrator;
toggleCloseBrowserWarning();
} else {
// We didn't find a migrator, notify the user
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -4400,16 +4400,34 @@
},
"FX_MIGRATION_HOMEPAGE_IMPORTED": {
"expires_in_version": "49",
"kind": "boolean",
"keyed": true,
"releaseChannelCollection": "opt-out",
"description": "Whether the homepage was imported during browser migration. Only available on release builds during firstrun."
},
+ "FX_STARTUP_MIGRATION_BROWSER_COUNT": {
+ "bug_numbers": [1275114],
+ "alert_emails": ["gijs@mozilla.com"],
+ "expires_in_version": "53",
+ "kind": "enumerated",
+ "n_values": 15,
+ "releaseChannelCollection": "opt-out",
+ "description": "Number of browsers from which the user could migrate on initial profile migration. Only available on release builds during firstrun."
+ },
+ "FX_STARTUP_MIGRATION_EXISTING_DEFAULT_BROWSER": {
+ "bug_numbers": [1275114],
+ "alert_emails": ["gijs@mozilla.com"],
+ "expires_in_version": "53",
+ "kind": "enumerated",
+ "n_values": 15,
+ "releaseChannelCollection": "opt-out",
+ "description": "The browser that was the default on the initial profile migration. The values correspond to the internal browser ID (see MigrationUtils.jsm)"
+ },
"INPUT_EVENT_RESPONSE_MS": {
"alert_emails": ["perf-telemetry-alerts@mozilla.com"],
"bug_numbers": [1235908],
"expires_in_version": "never",
"kind": "exponential",
"high": 10000,
"n_buckets": 50,
"description": "Time (ms) from the Input event being created to the end of it being handled"