Backed out changeset d07e792e7623 (bug 1811374) for causing xpcshell failures in test_TelemetryController.js CLOSED TREE

This commit is contained in:
Cristian Tuns 2024-05-27 10:48:02 -04:00
parent 55d4a9cdad
commit acd8a13933
7 changed files with 16 additions and 681 deletions

View File

@ -439,8 +439,6 @@ export let URICountListener = {
]),
};
let gInstallationTelemetryPromise = null;
export let BrowserUsageTelemetry = {
/**
* This is a policy object used to override behavior for testing.
@ -1311,23 +1309,23 @@ export let BrowserUsageTelemetry = {
/**
* Check if this is the first run of this profile since installation,
* if so then collect installation telemetry.
* if so then send installation telemetry.
*
* @param {nsIFile} [dataPathOverride] Optional, full data file path, for tests.
* @param {Array<string>} [msixPackagePrefixes] Optional, list of prefixes to
consider "existing" installs when looking at installed MSIX packages.
Defaults to prefixes for builds produced in Firefox automation.
* @return {Promise<Object>} A JSON object containing install telemetry.
* @return {Promise}
* @resolves When the event has been recorded, or if the data file was not found.
* @rejects JavaScript exception on any failure.
*/
async collectInstallationTelemetry(
async reportInstallationTelemetry(
dataPathOverride,
msixPackagePrefixes = ["Mozilla.Firefox", "Mozilla.MozillaFirefox"]
) {
if (AppConstants.platform != "win") {
// This is a windows-only feature.
return {};
return;
}
const TIMESTAMP_PREF = "app.installation.timestamp";
@ -1370,7 +1368,7 @@ export let BrowserUsageTelemetry = {
if (pfn) {
if (lastInstallTime != null) {
// We've already seen this install
return {};
return;
}
// First time seeing this install, record the timestamp.
@ -1413,7 +1411,7 @@ export let BrowserUsageTelemetry = {
if (ex.name == "NotFoundError") {
// Many systems will not have the data file, return silently if not found as
// there is nothing to record.
return {};
return;
}
throw ex;
}
@ -1422,7 +1420,7 @@ export let BrowserUsageTelemetry = {
if (lastInstallTime && data.install_timestamp == lastInstallTime) {
// We've already seen this install
return {};
return;
}
// First time seeing this install, record the timestamp.
@ -1450,69 +1448,15 @@ export let BrowserUsageTelemetry = {
extra.default_path = data.default_path.toString();
}
}
return { installer_type, extra };
},
async reportInstallationTelemetry(
dataPathOverride,
msixPackagePrefixes = ["Mozilla.Firefox", "Mozilla.MozillaFirefox"]
) {
// The optional dataPathOverride is only used for testing purposes.
// Use this as a proxy for whether we're in a testing environment.
// If we're in a testing environment we don't want to return the
// same data even if we call this function multiple times in the
// same instance.
if (gInstallationTelemetryPromise && !dataPathOverride) {
return gInstallationTelemetryPromise;
}
gInstallationTelemetryPromise = (async () => {
let data = await BrowserUsageTelemetry.collectInstallationTelemetry(
dataPathOverride,
msixPackagePrefixes
);
if (data?.installer_type) {
let { installer_type, extra } = data;
// Record the event
Services.telemetry.setEventRecordingEnabled("installation", true);
Services.telemetry.recordEvent(
"installation",
"first_seen",
installer_type,
null,
extra
);
// Scalars for the new-profile ping. We don't need to collect the build version
// These are mirrored to legacy telemetry using GIFFT
Glean.installationFirstSeen.installerType.set(installer_type);
Glean.installationFirstSeen.version.set(extra.version);
// Convert "true" or "false" strings back into booleans
Glean.installationFirstSeen.adminUser.set(extra.admin_user === "true");
Glean.installationFirstSeen.installExisted.set(
extra.install_existed === "true"
);
Glean.installationFirstSeen.profdirExisted.set(
extra.profdir_existed === "true"
);
Glean.installationFirstSeen.otherInst.set(extra.other_inst === "true");
Glean.installationFirstSeen.otherMsixInst.set(
extra.other_msix_inst === "true"
);
if (installer_type == "full") {
Glean.installationFirstSeen.silent.set(extra.silent === "true");
Glean.installationFirstSeen.fromMsi.set(extra.from_msi === "true");
Glean.installationFirstSeen.defaultPath.set(
extra.default_path === "true"
);
}
}
return data;
})();
return gInstallationTelemetryPromise;
// Record the event
Services.telemetry.setEventRecordingEnabled("installation", true);
Services.telemetry.recordEvent(
"installation",
"first_seen",
installer_type,
null,
extra
);
},
};

View File

@ -94,189 +94,6 @@ browser.engagement:
- metrics
expires: never
installation.first_seen:
failure_reason:
type: string
description: >
Only sent if unable to collect firstSeen data. Can have
value "NotFoundError" if file not found or other values
depending on the failure reason.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_sensitivity:
- technical
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
expires: never
telemetry_mirror: INSTALLATION_FIRSTSEEN_FAILURE_REASON
installer_type:
type: string
description: >
The type of installer used to install Firefox.
The value is one of "stub", "full", or "msix"
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_sensitivity:
- technical
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
expires: never
telemetry_mirror: INSTALLATION_FIRSTSEEN_INSTALLER_TYPE
version:
type: string
description: >
The application version installed by the installer
(not necessarily the current version)
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_sensitivity:
- technical
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
expires: never
telemetry_mirror: INSTALLATION_FIRSTSEEN_VERSION
admin_user:
type: boolean
description: >
Whether the installer is running from an elevated admin user
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_sensitivity:
- technical
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
expires: never
telemetry_mirror: INSTALLATION_FIRSTSEEN_ADMIN_USER
install_existed:
type: boolean
description: >
Whether there was already an install in this location
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_sensitivity:
- technical
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
expires: never
telemetry_mirror: INSTALLATION_FIRSTSEEN_INSTALL_EXISTED
profdir_existed:
type: boolean
description: >
Whether the top-level profile directory existed
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_sensitivity:
- technical
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
expires: never
telemetry_mirror: INSTALLATION_FIRSTSEEN_PROFDIR_EXISTED
other_inst:
type: boolean
description: >
Whether there was already any non-MSIX install on this system
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_sensitivity:
- technical
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
expires: never
telemetry_mirror: INSTALLATION_FIRSTSEEN_OTHER_INST
other_msix_inst:
type: boolean
description: >
Whether there was already any MSIX install on this system
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_sensitivity:
- technical
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
expires: never
telemetry_mirror: INSTALLATION_FIRSTSEEN_OTHER_MSIX_INST
silent:
type: boolean
description: >
(optional, present if installer_type is "full")
Whether this was a silent install
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_sensitivity:
- technical
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
expires: never
telemetry_mirror: INSTALLATION_FIRSTSEEN_SILENT
from_msi:
type: boolean
description: >
(optional, present if installer_type is "full")
Whether this was an MSI install
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_sensitivity:
- technical
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
expires: never
telemetry_mirror: INSTALLATION_FIRSTSEEN_FROM_MSI
default_path:
type: boolean
description: >
(optional, present if installer_type is "full")
Whether the default path was used
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1811374
data_sensitivity:
- technical
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
expires: never
telemetry_mirror: INSTALLATION_FIRSTSEEN_DEFAULT_PATH
performance.interaction:
tab_switch_composite:

View File

@ -155,223 +155,6 @@ a11y:
record_in_processes:
- 'main'
installation.firstSeen:
failure_reason:
bug_numbers:
- 1811374
description: >
Only sent if unable to collect firstSeen data. Can have
value "NotFoundError" if file not found or other values
depending on the failure reason.
keyed: false
expires: "134"
kind: string
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- 'all'
record_into_store:
- 'new-profile'
installer_type:
bug_numbers:
- 1811374
description: >
The type of installer used to install Firefox.
The value is one of "stub", "full", or "msix"
keyed: false
expires: "134"
kind: string
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- 'all'
record_into_store:
- 'new-profile'
version:
bug_numbers:
- 1811374
description: >
The application version installed by the installer
(not necessarily the current version)
keyed: false
expires: "134"
kind: string
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- 'all'
record_into_store:
- 'new-profile'
admin_user:
bug_numbers:
- 1811374
description: >
Whether the installer is running from an elevated admin user
keyed: false
expires: "134"
kind: boolean
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- 'all'
record_into_store:
- 'new-profile'
install_existed:
bug_numbers:
- 1811374
description: >
'Whether there was already an install in this location'
keyed: false
expires: "134"
kind: boolean
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- 'all'
record_into_store:
- 'new-profile'
profdir_existed:
bug_numbers:
- 1811374
description: >
'Whether the top-level profile directory existed'
keyed: false
expires: "134"
kind: boolean
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- 'all'
record_into_store:
- 'new-profile'
other_inst:
bug_numbers:
- 1811374
description: >
'Whether there was already any non-MSIX install on this system'
keyed: false
expires: "134"
kind: boolean
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- 'all'
record_into_store:
- 'new-profile'
other_msix_inst:
bug_numbers:
- 1811374
description: >
'Whether there was already any MSIX install on this system'
keyed: false
expires: "134"
kind: boolean
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- 'all'
record_into_store:
- 'new-profile'
silent:
bug_numbers:
- 1811374
description: >
(optional, present if installer_type is "full")
Whether this was a silent install
keyed: false
expires: "134"
kind: boolean
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- 'all'
record_into_store:
- 'new-profile'
from_msi:
bug_numbers:
- 1811374
description: >
(optional, present if installer_type is "full")
Whether this was an MSI install
keyed: false
expires: "134"
kind: boolean
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- 'all'
record_into_store:
- 'new-profile'
default_path:
bug_numbers:
- 1811374
description: >
(optional, present if installer_type is "full")
Whether the default path was used
keyed: false
expires: "134"
kind: boolean
notification_emails:
- rtestard@mozilla.com
- application-update-telemetry-alerts@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- 'all'
record_into_store:
- 'new-profile'
browser.backup:
prof_d_disk_space:
bug_numbers:

View File

@ -36,7 +36,6 @@ const REASON_GATHER_SUBSESSION_PAYLOAD = "gather-subsession-payload";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
BrowserUsageTelemetry: "resource://gre/modules/BrowserUsageTelemetry.sys.mjs",
ClientID: "resource://gre/modules/ClientID.sys.mjs",
CoveragePing: "resource://gre/modules/CoveragePing.sys.mjs",
TelemetryArchive: "resource://gre/modules/TelemetryArchive.sys.mjs",
@ -1236,17 +1235,6 @@ var Impl = {
NEWPROFILE_PING_DEFAULT_DELAY
);
try {
// This is asynchronous, but we aren't going to await on it now. Just
// kick it off.
lazy.BrowserUsageTelemetry.reportInstallationTelemetry();
} catch (ex) {
this._log.warn(
"scheduleNewProfilePing - reportInstallationTelemetry failed",
ex
);
}
this._delayedNewPingTask = new DeferredTask(async () => {
try {
await this.sendNewProfilePing();
@ -1266,25 +1254,6 @@ var Impl = {
"sendNewProfilePing - shutting down: " + this._shuttingDown
);
try {
await lazy.BrowserUsageTelemetry.reportInstallationTelemetry();
} catch (ex) {
this._log.warn(
"sendNewProfilePing - reportInstallationTelemetry failed",
ex
);
// No dataPathOverride here so we can check the default location
// for installation_telemetry.json
let dataPath = Services.dirsvc.get("GreD", Ci.nsIFile);
dataPath.append("installation_telemetry.json");
let fileExists = await IOUtils.exists(dataPath.path);
if (!fileExists) {
Glean.installationFirstSeen.failureReason.set("NotFoundError");
} else {
Glean.installationFirstSeen.failureReason.set(ex.name);
}
}
const scalars = Services.telemetry.getSnapshotForScalars(
"new-profile",
/* clear */ true

View File

@ -732,25 +732,6 @@ add_task(async function test_sendNewProfile() {
"The new-profile ping generated after startup must have processes.parent data"
);
Assert.ok(
"scalars" in ping.payload.processes.parent,
"The new-profile ping should have a field for scalars"
);
Assert.ok(
"installation.firstSeen.failure_reason" in
ping.payload.processes.parent.scalars,
"The new-profile ping should have an installation.firstSeen.failure_reason scalar"
);
Assert.equal(
ping.payload.processes.parent.scalars[
"installation.firstSeen.failure_reason"
],
"NotFoundError",
"The new-profile ping should return NotFoundError as we don't have a telemetry state file"
);
// Check that is not sent with the pingsender during startup.
Assert.throws(
() => req.getHeader("X-PingSender-Version"),
@ -779,25 +760,6 @@ add_task(async function test_sendNewProfile() {
"The new-profile ping generated at shutdown must have processes.parent data"
);
Assert.ok(
"scalars" in ping.payload.processes.parent,
"The new-profile ping should have a field for scalars"
);
Assert.ok(
"installation.firstSeen.failure_reason" in
ping.payload.processes.parent.scalars,
"The new-profile ping should have an installation.firstSeen.failure_reason scalar"
);
Assert.equal(
ping.payload.processes.parent.scalars[
"installation.firstSeen.failure_reason"
],
"NotFoundError",
"The new-profile ping should return NotFoundError as we don't have a telemetry state file"
);
// Check that the new-profile ping is sent at shutdown using the pingsender.
Assert.equal(
req.getHeader("User-Agent"),

View File

@ -1,137 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
*/
const { BrowserUsageTelemetry } = ChromeUtils.importESModule(
"resource:///modules/BrowserUsageTelemetry.sys.mjs"
);
const { TelemetryTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TelemetryTestUtils.sys.mjs"
);
const TIMESTAMP_TEST_VALUE = "007357735773577357";
let jsonPath = Services.dirsvc.get("XREExeF", Ci.nsIFile).parent;
jsonPath.append("installation_telemetry.json");
let scalarSnapshot = null;
let testDataJSON = {
version: "000.0a1",
build_id: "00000000000000",
admin_user: true,
install_existed: false,
profdir_existed: false,
installer_type: "full",
other_inst: false,
other_msix_inst: false,
silent: false,
from_msi: false,
default_path: true,
install_timestamp: TIMESTAMP_TEST_VALUE,
};
async function createTestInstallationTelemetry() {
let utf16Array = new Uint16Array(
[...JSON.stringify(testDataJSON)].map(char => char.charCodeAt(0))
);
let byteArray = new Uint8Array(utf16Array.buffer);
await IOUtils.write(jsonPath.path, byteArray);
}
add_setup(
{
skip_if: () =>
Services.prefs.getBoolPref("telemetry.fog.artifact_build", false),
},
function () {
do_get_profile();
Services.fog.initializeFOG();
}
);
add_setup(async function () {
Services.telemetry.clearScalars();
await createTestInstallationTelemetry();
await BrowserUsageTelemetry.reportInstallationTelemetry();
scalarSnapshot = Services.telemetry.getSnapshotForScalars(
"new-profile",
false
).parent;
});
registerCleanupFunction(async () => {
await IOUtils.remove(jsonPath.path, { ignoreAbsent: true });
});
add_task(async function test_new_profile_ping() {
Object.entries(testDataJSON).forEach(([key, value]) => {
// We don't log "build_id" as a scalar
if (key == "build_id") {
return;
}
// We must not log install_timestamp as a scalar due
// to fingerprinting risk. Verify that we don't.
if (key == "install_timestamp") {
Assert.ok(
!(`installation.firstSeen.${key}` in scalarSnapshot),
"Must not record " + key + " as a scalar"
);
return;
}
TelemetryTestUtils.assertScalar(
scalarSnapshot,
`installation.firstSeen.${key}`,
value
);
});
});
add_task(
{
skip_if: () =>
Services.prefs.getBoolPref("telemetry.fog.artifact_build", false),
},
async function test_new_profile_gifft_mirror() {
Assert.equal(
testDataJSON.installer_type,
Glean.installationFirstSeen.installerType.testGetValue()
);
Assert.equal(
testDataJSON.version,
Glean.installationFirstSeen.version.testGetValue()
);
Assert.equal(
testDataJSON.admin_user,
Glean.installationFirstSeen.adminUser.testGetValue()
);
Assert.equal(
testDataJSON.install_existed,
Glean.installationFirstSeen.installExisted.testGetValue()
);
Assert.equal(
testDataJSON.profdir_existed,
Glean.installationFirstSeen.profdirExisted.testGetValue()
);
Assert.equal(
testDataJSON.other_inst,
Glean.installationFirstSeen.otherInst.testGetValue()
);
Assert.equal(
testDataJSON.other_msix_inst,
Glean.installationFirstSeen.otherMsixInst.testGetValue()
);
Assert.equal(
testDataJSON.silent,
Glean.installationFirstSeen.silent.testGetValue()
);
Assert.equal(
testDataJSON.from_msi,
Glean.installationFirstSeen.fromMsi.testGetValue()
);
Assert.equal(
testDataJSON.default_path,
Glean.installationFirstSeen.defaultPath.testGetValue()
);
}
);

View File

@ -184,6 +184,3 @@ run-if = ["os == 'win'"]
["test_failover_retry.js"]
skip-if = ["os == 'android'"] # Android doesn't support telemetry though some tests manage to pass with xpcshell
["test_new_profile.js"]
run-if = ["os == 'win'"]