Bug 1908732 - Add event probes for the backup component. r=backup-reviewers,kpatenio
Differential Revision: https://phabricator.services.mozilla.com/D221660
This commit is contained in:
@@ -13,7 +13,10 @@ import {
|
||||
BYTES_IN_MEBIBYTE,
|
||||
} from "resource:///modules/backup/MeasurementUtils.sys.mjs";
|
||||
|
||||
import { ERRORS } from "chrome://browser/content/backup/backup-constants.mjs";
|
||||
import {
|
||||
ERRORS,
|
||||
STEPS,
|
||||
} from "chrome://browser/content/backup/backup-constants.mjs";
|
||||
import { BackupError } from "resource:///modules/backup/BackupError.mjs";
|
||||
|
||||
const BACKUP_DIR_PREF_NAME = "browser.backup.location";
|
||||
@@ -1142,6 +1145,7 @@ export class BackupService extends EventTarget {
|
||||
BackupService.WRITE_BACKUP_LOCK_NAME,
|
||||
{ signal: this.#backupWriteAbortController.signal },
|
||||
async () => {
|
||||
let currentStep = STEPS.CREATE_BACKUP_ENTRYPOINT;
|
||||
this.#backupInProgress = true;
|
||||
const backupTimer = Glean.browserBackup.totalBackupTime.start();
|
||||
|
||||
@@ -1150,6 +1154,7 @@ export class BackupService extends EventTarget {
|
||||
`Creating backup for profile at ${profilePath}`
|
||||
);
|
||||
|
||||
currentStep = STEPS.CREATE_BACKUP_RESOLVE_DESTINATION;
|
||||
let archiveDestFolderPath = await this.resolveArchiveDestFolderPath(
|
||||
lazy.backupDirPref
|
||||
);
|
||||
@@ -1157,8 +1162,10 @@ export class BackupService extends EventTarget {
|
||||
`Destination for archive: ${archiveDestFolderPath}`
|
||||
);
|
||||
|
||||
currentStep = STEPS.CREATE_BACKUP_CREATE_MANIFEST;
|
||||
let manifest = await this.#createBackupManifest();
|
||||
|
||||
currentStep = STEPS.CREATE_BACKUP_CREATE_BACKUPS_FOLDER;
|
||||
// First, check to see if a `backups` directory already exists in the
|
||||
// profile.
|
||||
let backupDirPath = PathUtils.join(
|
||||
@@ -1175,6 +1182,7 @@ export class BackupService extends EventTarget {
|
||||
createAncestors: true,
|
||||
});
|
||||
|
||||
currentStep = STEPS.CREATE_BACKUP_CREATE_STAGING_FOLDER;
|
||||
let stagingPath = await this.#prepareStagingFolder(backupDirPath);
|
||||
|
||||
// Sort resources be priority.
|
||||
@@ -1184,10 +1192,12 @@ export class BackupService extends EventTarget {
|
||||
}
|
||||
);
|
||||
|
||||
currentStep = STEPS.CREATE_BACKUP_LOAD_ENCSTATE;
|
||||
let encState = await this.loadEncryptionState(profilePath);
|
||||
let encryptionEnabled = !!encState;
|
||||
lazy.logConsole.debug("Encryption enabled: ", encryptionEnabled);
|
||||
|
||||
currentStep = STEPS.CREATE_BACKUP_RUN_BACKUP;
|
||||
// Perform the backup for each resource.
|
||||
for (let resourceClass of sortedResources) {
|
||||
try {
|
||||
@@ -1235,6 +1245,7 @@ export class BackupService extends EventTarget {
|
||||
}
|
||||
}
|
||||
|
||||
currentStep = STEPS.CREATE_BACKUP_VERIFY_MANIFEST;
|
||||
// Ensure that the manifest abides by the current schema, and log
|
||||
// an error if somehow it doesn't. We'll want to collect telemetry for
|
||||
// this case to make sure it's not happening in the wild. We debated
|
||||
@@ -1257,6 +1268,7 @@ export class BackupService extends EventTarget {
|
||||
// TODO: Collect telemetry for this case. (bug 1891817)
|
||||
}
|
||||
|
||||
currentStep = STEPS.CREATE_BACKUP_WRITE_MANIFEST;
|
||||
// Write the manifest to the staging folder.
|
||||
let manifestPath = PathUtils.join(
|
||||
stagingPath,
|
||||
@@ -1264,6 +1276,7 @@ export class BackupService extends EventTarget {
|
||||
);
|
||||
await IOUtils.writeJSON(manifestPath, manifest);
|
||||
|
||||
currentStep = STEPS.CREATE_BACKUP_FINALIZE_STAGING;
|
||||
let renamedStagingPath = await this.#finalizeStagingFolder(
|
||||
stagingPath
|
||||
);
|
||||
@@ -1289,6 +1302,7 @@ export class BackupService extends EventTarget {
|
||||
totalSizeBytesNearestMebibyte / BYTES_IN_MEBIBYTE
|
||||
);
|
||||
|
||||
currentStep = STEPS.CREATE_BACKUP_COMPRESS_STAGING;
|
||||
let compressedStagingPath = await this.#compressStagingFolder(
|
||||
renamedStagingPath,
|
||||
backupDirPath
|
||||
@@ -1296,6 +1310,7 @@ export class BackupService extends EventTarget {
|
||||
await IOUtils.remove(renamedStagingPath, { recursive: true });
|
||||
});
|
||||
|
||||
currentStep = STEPS.CREATE_BACKUP_CREATE_ARCHIVE;
|
||||
// Now create the single-file archive. For now, we'll stash this in the
|
||||
// backups folder while it gets written. Once that's done, we'll attempt
|
||||
// to move it to the user's configured backup path.
|
||||
@@ -1330,6 +1345,7 @@ export class BackupService extends EventTarget {
|
||||
archiveSizeBytesNearestMebibyte / BYTES_IN_MEBIBYTE
|
||||
);
|
||||
|
||||
currentStep = STEPS.CREATE_BACKUP_FINALIZE_ARCHIVE;
|
||||
let archivePath = await this.finalizeSingleFileArchive(
|
||||
archiveTmpPath,
|
||||
archiveDestFolderPath,
|
||||
@@ -1344,9 +1360,15 @@ export class BackupService extends EventTarget {
|
||||
this.#_state.lastBackupDate = nowSeconds;
|
||||
Glean.browserBackup.totalBackupTime.stopAndAccumulate(backupTimer);
|
||||
|
||||
Glean.browserBackup.created.record();
|
||||
|
||||
return { manifest, archivePath };
|
||||
} catch {
|
||||
} catch (e) {
|
||||
Glean.browserBackup.totalBackupTime.cancel(backupTimer);
|
||||
Glean.browserBackup.error.record({
|
||||
error_code: String(e.cause || ERRORS.UNKNOWN),
|
||||
backup_step: String(currentStep),
|
||||
});
|
||||
return null;
|
||||
} finally {
|
||||
this.#backupInProgress = false;
|
||||
@@ -2817,6 +2839,8 @@ export class BackupService extends EventTarget {
|
||||
async onUpdateLocationDirPath(newDirPath) {
|
||||
lazy.logConsole.debug(`Updating backup location to ${newDirPath}`);
|
||||
|
||||
Glean.browserBackup.changeLocation.record();
|
||||
|
||||
this.#_state.backupDirPath = newDirPath;
|
||||
this.stateUpdate();
|
||||
}
|
||||
@@ -2863,6 +2887,12 @@ export class BackupService extends EventTarget {
|
||||
*/
|
||||
onUpdateScheduledBackups(isScheduledBackupsEnabled) {
|
||||
if (this.#_state.scheduledBackupsEnabled != isScheduledBackupsEnabled) {
|
||||
if (isScheduledBackupsEnabled) {
|
||||
Glean.browserBackup.toggleOn.record();
|
||||
} else {
|
||||
Glean.browserBackup.toggleOff.record();
|
||||
}
|
||||
|
||||
lazy.logConsole.debug(
|
||||
"Updating scheduled backups",
|
||||
isScheduledBackupsEnabled
|
||||
|
||||
@@ -96,6 +96,7 @@ export class BackupUIParent extends JSWindowActorParent {
|
||||
}
|
||||
if (password) {
|
||||
await this.#bs.enableEncryption(password);
|
||||
Glean.browserBackup.passwordAdded.record();
|
||||
}
|
||||
this.#bs.setScheduledBackups(true);
|
||||
} catch (e) {
|
||||
@@ -187,6 +188,7 @@ export class BackupUIParent extends JSWindowActorParent {
|
||||
} else if (message.name == "EnableEncryption") {
|
||||
try {
|
||||
await this.#bs.enableEncryption(message.data.password);
|
||||
Glean.browserBackup.passwordAdded.record();
|
||||
} catch (e) {
|
||||
lazy.logConsole.error(`Failed to enable encryption`, e);
|
||||
return { success: false, errorCode: e.cause || lazy.ERRORS.UNKNOWN };
|
||||
@@ -199,6 +201,7 @@ export class BackupUIParent extends JSWindowActorParent {
|
||||
} else if (message.name == "DisableEncryption") {
|
||||
try {
|
||||
await this.#bs.disableEncryption();
|
||||
Glean.browserBackup.passwordRemoved.record();
|
||||
} catch (e) {
|
||||
lazy.logConsole.error(`Failed to disable encryption`, e);
|
||||
return { success: false, errorCode: e.cause || lazy.ERRORS.UNKNOWN };
|
||||
@@ -214,6 +217,7 @@ export class BackupUIParent extends JSWindowActorParent {
|
||||
|
||||
await this.#bs.disableEncryption();
|
||||
await this.#bs.enableEncryption(password);
|
||||
Glean.browserBackup.passwordChanged.record();
|
||||
} catch (e) {
|
||||
lazy.logConsole.error(`Failed to rerun encryption`, e);
|
||||
return { success: false, errorCode: e.cause || lazy.ERRORS.UNKNOWN };
|
||||
|
||||
@@ -47,3 +47,81 @@ export const ERRORS = Object.freeze({
|
||||
*/
|
||||
UNSUPPORTED_APPLICATION: 14,
|
||||
});
|
||||
|
||||
/**
|
||||
* These are steps that the BackupService or any of its subcomponents might
|
||||
* be going through during configuration, creation, deletion of or restoration
|
||||
* from a backup. This is used to provide extra information to our error
|
||||
* telemetry.
|
||||
*/
|
||||
export const STEPS = Object.freeze({
|
||||
/**
|
||||
* This is the initial step upon creating a backup before any other steps
|
||||
* begin.
|
||||
*/
|
||||
CREATE_BACKUP_ENTRYPOINT: 1,
|
||||
|
||||
/**
|
||||
* Determine the final destination for the written archive.
|
||||
*/
|
||||
CREATE_BACKUP_RESOLVE_DESTINATION: 2,
|
||||
|
||||
/**
|
||||
* Generate the manifest object for the backup.
|
||||
*/
|
||||
CREATE_BACKUP_CREATE_MANIFEST: 3,
|
||||
|
||||
/**
|
||||
* Create the main `backups` working directory in the profile directory if it
|
||||
* doesn't already exist.
|
||||
*/
|
||||
CREATE_BACKUP_CREATE_BACKUPS_FOLDER: 4,
|
||||
|
||||
/**
|
||||
* Create the staging directory for the backup.
|
||||
*/
|
||||
CREATE_BACKUP_CREATE_STAGING_FOLDER: 5,
|
||||
|
||||
/**
|
||||
* Attempt to load the encryption state if one exists.
|
||||
*/
|
||||
CREATE_BACKUP_LOAD_ENCSTATE: 6,
|
||||
|
||||
/**
|
||||
* Run the backup routine for each BackupResource.
|
||||
*/
|
||||
CREATE_BACKUP_RUN_BACKUP: 7,
|
||||
|
||||
/**
|
||||
* After populating with the data from each BackupResource, verify that
|
||||
* the manifest adheres to the BackupManifest schema.
|
||||
*/
|
||||
CREATE_BACKUP_VERIFY_MANIFEST: 8,
|
||||
|
||||
/**
|
||||
* Write the backup manifest to the staging directory.
|
||||
*/
|
||||
CREATE_BACKUP_WRITE_MANIFEST: 9,
|
||||
|
||||
/**
|
||||
* Rename the staging directory with the time code, and clear out any
|
||||
* expired directories.
|
||||
*/
|
||||
CREATE_BACKUP_FINALIZE_STAGING: 10,
|
||||
|
||||
/**
|
||||
* Compress the staging directory into a single file.
|
||||
*/
|
||||
CREATE_BACKUP_COMPRESS_STAGING: 11,
|
||||
|
||||
/**
|
||||
* Generate the single-file archive.
|
||||
*/
|
||||
CREATE_BACKUP_CREATE_ARCHIVE: 12,
|
||||
|
||||
/**
|
||||
* Finalize the single-file archive and move it into the destination
|
||||
* directory.
|
||||
*/
|
||||
CREATE_BACKUP_FINALIZE_ARCHIVE: 13,
|
||||
});
|
||||
|
||||
@@ -452,3 +452,149 @@ browser.backup:
|
||||
- mconley@mozilla.com
|
||||
expires: never
|
||||
telemetry_mirror: BROWSER_BACKUP_EXTENSIONS_STORAGE_SIZE
|
||||
|
||||
toggle_on:
|
||||
type: event
|
||||
description: >
|
||||
Dispatched when scheduled backups are enabled.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
send_in_pings:
|
||||
- events
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
expires: never
|
||||
telemetry_mirror: BrowserBackup_ToggleOn_Backupservice
|
||||
|
||||
toggle_off:
|
||||
type: event
|
||||
description: >
|
||||
Dispatched when scheduled backups are disabled.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
send_in_pings:
|
||||
- events
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
expires: never
|
||||
telemetry_mirror: BrowserBackup_ToggleOff_Backupservice
|
||||
|
||||
created:
|
||||
type: event
|
||||
description: >
|
||||
Dispatched when a backup is successfully created.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_sensitivity:
|
||||
- technical
|
||||
send_in_pings:
|
||||
- events
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
expires: never
|
||||
telemetry_mirror: BrowserBackup_Created_Backupservice
|
||||
|
||||
change_location:
|
||||
type: event
|
||||
description: >
|
||||
Dispatched when the backup destination location is changed.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
send_in_pings:
|
||||
- events
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
expires: never
|
||||
telemetry_mirror: BrowserBackup_ChangeLocation_Backupservice
|
||||
|
||||
password_changed:
|
||||
type: event
|
||||
description: >
|
||||
Dispatched when the backup encryption password is changed.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
send_in_pings:
|
||||
- events
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
expires: never
|
||||
telemetry_mirror: BrowserBackup_PasswordChanged_Backupservice
|
||||
|
||||
password_added:
|
||||
type: event
|
||||
description: >
|
||||
Dispatched when the backup encryption is enabled.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
send_in_pings:
|
||||
- events
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
expires: never
|
||||
telemetry_mirror: BrowserBackup_PasswordAdded_Backupservice
|
||||
|
||||
password_removed:
|
||||
type: event
|
||||
description: >
|
||||
Dispatched when the backup encryption is removed.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
send_in_pings:
|
||||
- events
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
expires: never
|
||||
telemetry_mirror: BrowserBackup_PasswordRemoved_Backupservice
|
||||
|
||||
error:
|
||||
type: event
|
||||
description: >
|
||||
Dispatched when a backup fails to be created. We encode the error code
|
||||
as well as the stage the backup failed in in the extra data.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908732
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
send_in_pings:
|
||||
- events
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
expires: never
|
||||
extra_keys:
|
||||
error_code:
|
||||
type: string
|
||||
description: The string representation of the error code.
|
||||
backup_step:
|
||||
type: string
|
||||
description: >
|
||||
The string representation of the step that backup creation was in
|
||||
when the error occurred.
|
||||
telemetry_mirror: BrowserBackup_Error_Backupservice
|
||||
|
||||
@@ -57,6 +57,9 @@ add_task(async function test_preferences_visibility() {
|
||||
* from the settings page.
|
||||
*/
|
||||
add_task(async function test_disable_backup_encryption_confirm() {
|
||||
Services.telemetry.clearEvents();
|
||||
Services.fog.testResetFOG();
|
||||
|
||||
await BrowserTestUtils.withNewTab("about:preferences", async browser => {
|
||||
let sandbox = sinon.createSandbox();
|
||||
let disableEncryptionStub = sandbox
|
||||
@@ -115,6 +118,23 @@ add_task(async function test_disable_backup_encryption_confirm() {
|
||||
disableEncryptionStub.calledOnce,
|
||||
"BackupService was called to disable encryption"
|
||||
);
|
||||
|
||||
let legacyEvents = TelemetryTestUtils.getEvents(
|
||||
{
|
||||
category: "browser.backup",
|
||||
method: "password_removed",
|
||||
object: "BackupService",
|
||||
},
|
||||
{ process: "parent" }
|
||||
);
|
||||
Assert.equal(
|
||||
legacyEvents.length,
|
||||
1,
|
||||
"Found the password_removed legacy event."
|
||||
);
|
||||
let events = Glean.browserBackup.passwordRemoved.testGetValue();
|
||||
Assert.equal(events.length, 1, "Found the passwordRemoved Glean event.");
|
||||
|
||||
sandbox.restore();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
@@ -10,6 +10,9 @@ const SCHEDULED_BACKUPS_ENABLED_PREF = "browser.backup.scheduled.enabled";
|
||||
* from the settings page via the toggle checkbox.
|
||||
*/
|
||||
add_task(async function test_enable_backup_encryption_checkbox_confirm() {
|
||||
Services.telemetry.clearEvents();
|
||||
Services.fog.testResetFOG();
|
||||
|
||||
await BrowserTestUtils.withNewTab("about:preferences", async browser => {
|
||||
let sandbox = sinon.createSandbox();
|
||||
let enableEncryptionStub = sandbox
|
||||
@@ -102,6 +105,22 @@ add_task(async function test_enable_backup_encryption_checkbox_confirm() {
|
||||
"BackupService was called to enable encryption with inputted password"
|
||||
);
|
||||
|
||||
let legacyEvents = TelemetryTestUtils.getEvents(
|
||||
{
|
||||
category: "browser.backup",
|
||||
method: "password_added",
|
||||
object: "BackupService",
|
||||
},
|
||||
{ process: "parent" }
|
||||
);
|
||||
Assert.equal(
|
||||
legacyEvents.length,
|
||||
1,
|
||||
"Found the password_added legacy event."
|
||||
);
|
||||
let events = Glean.browserBackup.passwordAdded.testGetValue();
|
||||
Assert.equal(events.length, 1, "Found the passwordAdded Glean event.");
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
sandbox.restore();
|
||||
});
|
||||
@@ -113,6 +132,9 @@ add_task(async function test_enable_backup_encryption_checkbox_confirm() {
|
||||
*/
|
||||
add_task(
|
||||
async function test_enable_backup_encryption_change_password_confirm() {
|
||||
Services.telemetry.clearEvents();
|
||||
Services.fog.testResetFOG();
|
||||
|
||||
await BrowserTestUtils.withNewTab("about:preferences", async browser => {
|
||||
let sandbox = sinon.createSandbox();
|
||||
let enableEncryptionStub = sandbox
|
||||
@@ -201,6 +223,22 @@ add_task(
|
||||
"BackupService was called to re-run encryption with changed password"
|
||||
);
|
||||
|
||||
let legacyEvents = TelemetryTestUtils.getEvents(
|
||||
{
|
||||
category: "browser.backup",
|
||||
method: "password_changed",
|
||||
object: "BackupService",
|
||||
},
|
||||
{ process: "parent" }
|
||||
);
|
||||
Assert.equal(
|
||||
legacyEvents.length,
|
||||
1,
|
||||
"Found the password_changed legacy event."
|
||||
);
|
||||
let events = Glean.browserBackup.passwordChanged.testGetValue();
|
||||
Assert.equal(events.length, 1, "Found the passwordChanged Glean event.");
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
@@ -57,6 +57,9 @@ async function turnOffScheduledBackupsHelper(browser, taskFn) {
|
||||
*/
|
||||
add_task(async function test_turn_off_scheduled_backups_confirm() {
|
||||
await BrowserTestUtils.withNewTab("about:preferences", async browser => {
|
||||
Services.telemetry.clearEvents();
|
||||
Services.fog.testResetFOG();
|
||||
|
||||
let sandbox = sinon.createSandbox();
|
||||
let deleteLastBackupStub = sandbox
|
||||
.stub(BackupService.prototype, "deleteLastBackup")
|
||||
@@ -78,6 +81,18 @@ add_task(async function test_turn_off_scheduled_backups_confirm() {
|
||||
);
|
||||
});
|
||||
|
||||
let legacyEvents = TelemetryTestUtils.getEvents(
|
||||
{
|
||||
category: "browser.backup",
|
||||
method: "toggle_off",
|
||||
object: "BackupService",
|
||||
},
|
||||
{ process: "parent" }
|
||||
);
|
||||
Assert.equal(legacyEvents.length, 1, "Found the toggle_off legacy event.");
|
||||
let events = Glean.browserBackup.toggleOff.testGetValue();
|
||||
Assert.equal(events.length, 1, "Found the toggleOff Glean event.");
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
@@ -21,6 +21,9 @@ add_setup(async () => {
|
||||
* browser.backup.scheduled.enabled to true from the settings page.
|
||||
*/
|
||||
add_task(async function test_turn_on_scheduled_backups_confirm() {
|
||||
Services.telemetry.clearEvents();
|
||||
Services.fog.testResetFOG();
|
||||
|
||||
await BrowserTestUtils.withNewTab("about:preferences", async browser => {
|
||||
let settings = browser.contentDocument.querySelector("backup-settings");
|
||||
|
||||
@@ -61,6 +64,21 @@ add_task(async function test_turn_on_scheduled_backups_confirm() {
|
||||
SCHEDULED_BACKUPS_ENABLED_PREF
|
||||
);
|
||||
Assert.ok(scheduledPrefVal, "Scheduled backups pref should be true");
|
||||
|
||||
let legacyEvents = TelemetryTestUtils.getEvents(
|
||||
{
|
||||
category: "browser.backup",
|
||||
method: "toggle_on",
|
||||
object: "BackupService",
|
||||
},
|
||||
{ process: "parent" }
|
||||
);
|
||||
Assert.equal(legacyEvents.length, 1, "Found the toggle_on legacy event.");
|
||||
let events = Glean.browserBackup.toggleOn.testGetValue();
|
||||
Assert.equal(events.length, 1, "Found the toggleOn Glean event.");
|
||||
|
||||
// Reset scheduled backups again for subsequent tests.
|
||||
Services.prefs.clearUserPref(SCHEDULED_BACKUPS_ENABLED_PREF);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -70,6 +88,9 @@ add_task(async function test_turn_on_scheduled_backups_confirm() {
|
||||
* that path, and sets browser.backup.location to the path from the settings page.
|
||||
*/
|
||||
add_task(async function test_turn_on_custom_location_filepicker() {
|
||||
Services.telemetry.clearEvents();
|
||||
Services.fog.testResetFOG();
|
||||
|
||||
await BrowserTestUtils.withNewTab("about:preferences", async browser => {
|
||||
const mockCustomParentDir = await IOUtils.createUniqueDirectory(
|
||||
PathUtils.tempDir,
|
||||
@@ -175,6 +196,37 @@ add_task(async function test_turn_on_custom_location_filepicker() {
|
||||
ignoreAbsent: true,
|
||||
recursive: true,
|
||||
});
|
||||
|
||||
let legacyEvents = TelemetryTestUtils.getEvents(
|
||||
{
|
||||
category: "browser.backup",
|
||||
method: "toggle_on",
|
||||
object: "BackupService",
|
||||
},
|
||||
{ process: "parent" }
|
||||
);
|
||||
Assert.equal(legacyEvents.length, 1, "Found the toggle_on legacy event.");
|
||||
let events = Glean.browserBackup.toggleOn.testGetValue();
|
||||
Assert.equal(events.length, 1, "Found the toggleOn Glean event.");
|
||||
|
||||
legacyEvents = TelemetryTestUtils.getEvents(
|
||||
{
|
||||
category: "browser.backup",
|
||||
method: "change_location",
|
||||
object: "BackupService",
|
||||
},
|
||||
{ process: "parent" }
|
||||
);
|
||||
Assert.equal(
|
||||
legacyEvents.length,
|
||||
1,
|
||||
"Found the change_location legacy event."
|
||||
);
|
||||
events = Glean.browserBackup.changeLocation.testGetValue();
|
||||
Assert.equal(events.length, 1, "Found the changeLocation Glean event.");
|
||||
|
||||
// Reset scheduled backups again for subsequent tests.
|
||||
Services.prefs.clearUserPref(SCHEDULED_BACKUPS_ENABLED_PREF);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -183,6 +235,9 @@ add_task(async function test_turn_on_custom_location_filepicker() {
|
||||
* turn-on-scheduled-backups dialog.
|
||||
*/
|
||||
add_task(async function test_turn_on_scheduled_backups_encryption() {
|
||||
Services.telemetry.clearEvents();
|
||||
Services.fog.testResetFOG();
|
||||
|
||||
await BrowserTestUtils.withNewTab("about:preferences", async browser => {
|
||||
let sandbox = sinon.createSandbox();
|
||||
let settings = browser.contentDocument.querySelector("backup-settings");
|
||||
@@ -252,6 +307,34 @@ add_task(async function test_turn_on_scheduled_backups_encryption() {
|
||||
"BackupService was called to enable encryption and received the expected argument"
|
||||
);
|
||||
|
||||
let legacyEvents = TelemetryTestUtils.getEvents(
|
||||
{
|
||||
category: "browser.backup",
|
||||
method: "toggle_on",
|
||||
object: "BackupService",
|
||||
},
|
||||
{ process: "parent" }
|
||||
);
|
||||
Assert.equal(legacyEvents.length, 1, "Found the toggle_on legacy event.");
|
||||
let events = Glean.browserBackup.toggleOn.testGetValue();
|
||||
Assert.equal(events.length, 1, "Found the toggleOn Glean event.");
|
||||
|
||||
legacyEvents = TelemetryTestUtils.getEvents(
|
||||
{
|
||||
category: "browser.backup",
|
||||
method: "password_added",
|
||||
object: "BackupService",
|
||||
},
|
||||
{ process: "parent" }
|
||||
);
|
||||
Assert.equal(
|
||||
legacyEvents.length,
|
||||
1,
|
||||
"Found the password_added legacy event."
|
||||
);
|
||||
events = Glean.browserBackup.passwordAdded.testGetValue();
|
||||
Assert.equal(events.length, 1, "Found the passwordAdded Glean event.");
|
||||
|
||||
sandbox.restore();
|
||||
Services.prefs.clearUserPref(SCHEDULED_BACKUPS_ENABLED_PREF);
|
||||
});
|
||||
|
||||
@@ -14,6 +14,10 @@ const { sinon } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/Sinon.sys.mjs"
|
||||
);
|
||||
|
||||
const { TelemetryTestUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/TelemetryTestUtils.sys.mjs"
|
||||
);
|
||||
|
||||
const MOCK_PASSWORD = "mckP@ss3x2 fake_password";
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,7 +87,9 @@ add_setup(function () {
|
||||
* @returns {Promise<undefined>}
|
||||
*/
|
||||
async function testCreateBackupHelper(sandbox, taskFn) {
|
||||
Services.telemetry.clearEvents();
|
||||
Services.fog.testResetFOG();
|
||||
|
||||
// Handle for the metric for total byte size of staging folder
|
||||
let totalBackupSizeHistogram = TelemetryTestUtils.getAndClearHistogram(
|
||||
"BROWSER_BACKUP_TOTAL_BACKUP_SIZE"
|
||||
@@ -158,6 +160,14 @@ async function testCreateBackupHelper(sandbox, taskFn) {
|
||||
});
|
||||
Assert.ok(bs.state.lastBackupDate, "The backup date was recorded.");
|
||||
|
||||
let legacyEvents = TelemetryTestUtils.getEvents(
|
||||
{ category: "browser.backup", method: "created", object: "BackupService" },
|
||||
{ process: "parent" }
|
||||
);
|
||||
Assert.equal(legacyEvents.length, 1, "Found the created legacy event.");
|
||||
let events = Glean.browserBackup.created.testGetValue();
|
||||
Assert.equal(events.length, 1, "Found the created Glean event.");
|
||||
|
||||
// Validate total backup time metrics were recorded
|
||||
assertSingleTimeMeasurement(
|
||||
Glean.browserBackup.totalBackupTime.testGetValue()
|
||||
|
||||
@@ -3875,3 +3875,115 @@ session_restore:
|
||||
- 1874742
|
||||
expiry_version: "never"
|
||||
release_channel_collection: opt-out
|
||||
|
||||
browser.backup:
|
||||
toggle_on:
|
||||
objects: ["BackupService"]
|
||||
description: >
|
||||
Dispatched when scheduled backups are enabled.
|
||||
bug_numbers:
|
||||
- 1908732
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
products:
|
||||
- "firefox"
|
||||
record_in_processes: [main]
|
||||
release_channel_collection: opt-out
|
||||
expiry_version: never
|
||||
toggle_off:
|
||||
objects: ["BackupService"]
|
||||
description: >
|
||||
Dispatched when scheduled backups are disabled.
|
||||
bug_numbers:
|
||||
- 1908732
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
products:
|
||||
- "firefox"
|
||||
record_in_processes: [main]
|
||||
release_channel_collection: opt-out
|
||||
expiry_version: never
|
||||
created:
|
||||
objects: ["BackupService"]
|
||||
description: >
|
||||
Dispatched when a backup is successfully created.
|
||||
bug_numbers:
|
||||
- 1908732
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
products:
|
||||
- "firefox"
|
||||
record_in_processes: [main]
|
||||
release_channel_collection: opt-out
|
||||
expiry_version: never
|
||||
change_location:
|
||||
objects: ["BackupService"]
|
||||
description: >
|
||||
Dispatched when the backup destination location is changed.
|
||||
bug_numbers:
|
||||
- 1908732
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
products:
|
||||
- "firefox"
|
||||
record_in_processes: [main]
|
||||
release_channel_collection: opt-out
|
||||
expiry_version: never
|
||||
password_changed:
|
||||
objects: ["BackupService"]
|
||||
description: >
|
||||
Dispatched when the backup encryption password is changed.
|
||||
bug_numbers:
|
||||
- 1908732
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
products:
|
||||
- "firefox"
|
||||
record_in_processes: [main]
|
||||
release_channel_collection: opt-out
|
||||
expiry_version: never
|
||||
password_added:
|
||||
objects: ["BackupService"]
|
||||
description: >
|
||||
Dispatched when the backup encryption is enabled.
|
||||
bug_numbers:
|
||||
- 1908732
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
products:
|
||||
- "firefox"
|
||||
record_in_processes: [main]
|
||||
release_channel_collection: opt-out
|
||||
expiry_version: never
|
||||
password_removed:
|
||||
objects: ["BackupService"]
|
||||
description: >
|
||||
Dispatched when the backup encryption is removed.
|
||||
bug_numbers:
|
||||
- 1908732
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
products:
|
||||
- "firefox"
|
||||
record_in_processes: [main]
|
||||
release_channel_collection: opt-out
|
||||
expiry_version: never
|
||||
error:
|
||||
objects: ["BackupService"]
|
||||
description: >
|
||||
Dispatched when a backup fails to be created. We encode the error code
|
||||
as well as the stage the backup failed in in the extra data.
|
||||
bug_numbers:
|
||||
- 1908732
|
||||
notification_emails:
|
||||
- mconley@mozilla.com
|
||||
products:
|
||||
- "firefox"
|
||||
record_in_processes: [main]
|
||||
release_channel_collection: opt-out
|
||||
expiry_version: never
|
||||
extra_keys:
|
||||
error_code: The string representation of the error code.
|
||||
backup_step: >
|
||||
The string representation of the step that backup creation was in
|
||||
when the error occurred.
|
||||
|
||||
Reference in New Issue
Block a user