diff --git a/browser/components/migration/MigrationUtils.sys.mjs b/browser/components/migration/MigrationUtils.sys.mjs index 6e3a473a5b78..3603000c3d0b 100644 --- a/browser/components/migration/MigrationUtils.sys.mjs +++ b/browser/components/migration/MigrationUtils.sys.mjs @@ -24,6 +24,7 @@ var gFileMigrators = null; var gProfileStartup = null; var gL10n = null; var gPreviousDefaultBrowserKey = ""; +var gHasOpenedLegacyWizard = false; let gForceExitSpinResolve = false; let gKeepUndoData = false; @@ -689,6 +690,11 @@ class MigrationUtils { return Promise.resolve(); } // Legacy migration dialog + if (!gHasOpenedLegacyWizard) { + gHasOpenedLegacyWizard = true; + aOptions.openedTime = Cu.now(); + } + const DIALOG_URL = "chrome://browser/content/migration/migration.xhtml"; let features = "chrome,dialog,modal,centerscreen,titlebar,resizable=no"; if (AppConstants.platform == "macosx" && !this.isStartupMigration) { diff --git a/browser/components/migration/MigrationWizardParent.sys.mjs b/browser/components/migration/MigrationWizardParent.sys.mjs index f81b09e9b464..1f18e9b8c18a 100644 --- a/browser/components/migration/MigrationWizardParent.sys.mjs +++ b/browser/components/migration/MigrationWizardParent.sys.mjs @@ -35,6 +35,12 @@ XPCOMUtils.defineLazyModuleGetters(lazy, { LoginCSVImport: "resource://gre/modules/LoginCSVImport.jsm", }); +/** + * Set to true once the first instance of MigrationWizardParent has received + * a "GetAvailableMigrators" message. + */ +let gHasOpenedBefore = false; + /** * This class is responsible for communicating with MigrationUtils to do the * actual heavy-lifting of any kinds of migration work, based on messages from @@ -75,6 +81,8 @@ export class MigrationWizardParent extends JSWindowActorParent { switch (message.name) { case "GetAvailableMigrators": { + let start = Cu.now(); + let availableMigrators = []; for (const key of MigrationUtils.availableMigratorKeys) { availableMigrators.push(this.#getMigratorAndProfiles(key)); @@ -98,6 +106,15 @@ export class MigrationWizardParent extends JSWindowActorParent { return b.lastModifiedDate - a.lastModifiedDate; }); + let elapsed = Cu.now() - start; + if (!gHasOpenedBefore) { + gHasOpenedBefore = true; + Services.telemetry.scalarSet( + "migration.time_to_produce_migrator_list", + elapsed + ); + } + return filteredResults; } diff --git a/browser/components/migration/content/migration.js b/browser/components/migration/content/migration.js index bc27bb4c9d93..2804f53a29af 100644 --- a/browser/components/migration/content/migration.js +++ b/browser/components/migration/content/migration.js @@ -42,6 +42,7 @@ var MigrationWizard = { _autoMigrate: null, _receivedPermissions: new Set(), _succeededMigrationEventArgs: null, + _openedTime: null, init() { Services.telemetry.setEventRecordingEnabled("browser.migration", true); @@ -71,6 +72,14 @@ var MigrationWizard = { .getHistogramById("FX_MIGRATION_ENTRY_POINT") .add(entryPointId); + // If the caller passed openedTime, that means this is the first time that + // the migration wizard is opening, and we want to measure its performance. + // Stash the time that opening was invoked so that we can measure the + // total elapsed time when the source list is shown. + if (args.openedTime) { + this._openedTime = args.openedTime; + } + this.isInitialMigration = entrypoint == MigrationUtils.MIGRATION_ENTRYPOINTS.FIRSTRUN; @@ -289,6 +298,17 @@ var MigrationWizard = { document.getElementById("importAll").hidden = true; } + // This must be the first time we're opening the migration wizard, + // and we want to know how long it took to get to this point, where + // we're showing the source list. + if (this._openedTime !== null) { + let elapsed = Cu.now() - this._openedTime; + Services.telemetry.scalarSet( + "migration.time_to_produce_legacy_migrator_list", + elapsed + ); + } + // Advance to the next page if the caller told us to. if (this._migrator && this._skipImportSourcePage) { this._wiz.advance(); diff --git a/browser/components/migration/tests/browser/browser_do_migration.js b/browser/components/migration/tests/browser/browser_do_migration.js index 054f29c61029..fab9641960a7 100644 --- a/browser/components/migration/tests/browser/browser_do_migration.js +++ b/browser/components/migration/tests/browser/browser_do_migration.js @@ -54,6 +54,15 @@ add_task(async function test_successful_migrations() { ]); }); + // We should make sure that the migration.time_to_produce_migrator_list + // scalar was set, since we know that at least one migration wizard has + // been opened. + let scalars = TelemetryTestUtils.getProcessScalars("parent", false, false); + Assert.ok( + scalars["migration.time_to_produce_migrator_list"] > 0, + "Non-zero scalar value recorded for migration.time_to_produce_migrator_list" + ); + // Scenario 2: Several resource types are available, but only 1 // is checked / expected. migration = waitForTestMigration( diff --git a/browser/components/migration/tests/browser/browser_entrypoint_telemetry.js b/browser/components/migration/tests/browser/browser_entrypoint_telemetry.js index c8c529bc0d2f..f15082af3682 100644 --- a/browser/components/migration/tests/browser/browser_entrypoint_telemetry.js +++ b/browser/components/migration/tests/browser/browser_entrypoint_telemetry.js @@ -99,4 +99,13 @@ add_task(async function test_legacy_wizard() { TelemetryTestUtils.assertHistogram(legacyHistogram, entrypointId, 1); } } + + // We should make sure that the migration.time_to_produce_legacy_migrator_list + // scalar was set, since we know that at least one legacy migration wizard has + // been opened. + let scalars = TelemetryTestUtils.getProcessScalars("parent", false, false); + Assert.ok( + scalars["migration.time_to_produce_legacy_migrator_list"] > 0, + "Non-zero scalar value recorded for migration.time_to_produce_migrator_list" + ); }); diff --git a/toolkit/components/telemetry/Scalars.yaml b/toolkit/components/telemetry/Scalars.yaml index 26729239228e..4e29dff07445 100644 --- a/toolkit/components/telemetry/Scalars.yaml +++ b/toolkit/components/telemetry/Scalars.yaml @@ -8348,6 +8348,36 @@ migration: - 'firefox' record_in_processes: - main + time_to_produce_legacy_migrator_list: + bug_numbers: + - 1840917 + description: > + The amount of time it took in milliseconds to produce the list of migrators in the + legacy migration wizard. + expires: never + kind: uint + notification_emails: + - mconley@mozilla.com + release_channel_collection: opt-out + products: + - 'firefox' + record_in_processes: + - main + time_to_produce_migrator_list: + bug_numbers: + - 1840917 + description: > + The amount of time it took in milliseconds to produce the list of migrators and profiles + for the first time the migration wizard opened during the process lifetime. + expires: never + kind: uint + notification_emails: + - mconley@mozilla.com + release_channel_collection: opt-out + products: + - 'firefox' + record_in_processes: + - main contextual.services.topsites: impression: