Bug 1920562 - Remove JS uses of Services.telemetry.setEventRecordingEnabled r=florian,settings-reviewers,pip-reviewers,credential-management-reviewers,search-reviewers,devtools-reviewers,sync-reviewers,sessionstore-reviewers,omc-reviewers,migration-reviewers,firefox-desktop-core-reviewers ,urlbar-reviewers,sfoster,nchevobbe,valentin,Gijs,dimi,lina,mconley,pdahiya

Differential Revision: https://phabricator.services.mozilla.com/D223833
This commit is contained in:
Chris H-C 2024-10-07 17:29:57 +00:00
parent a0d39c1e98
commit 27ba170e6f
82 changed files with 6 additions and 469 deletions

View File

@ -31,10 +31,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
let gSearchBannerShownThisSession;
export class AboutPrivateBrowsingParent extends JSWindowActorParent {
constructor() {
super();
Services.telemetry.setEventRecordingEnabled("aboutprivatebrowsing", true);
}
// Used by tests
static setShownThisSession(shown) {
gSearchBannerShownThisSession = shown;

View File

@ -1453,7 +1453,6 @@ pref("app.support.baseURL", "https://support.mozilla.org/1/firefox/%VERSION%/%OS
// base url for web-based feedback pages
pref("app.feedback.baseURL", "https://ideas.mozilla.org/");
pref("security.certerrors.recordEventTelemetry", true);
pref("security.certerrors.permanentOverride", true);
pref("security.certerrors.mitm.priming.enabled", true);
pref("security.certerrors.mitm.priming.endpoint", "https://mitmdetection.services.mozilla.com/");
@ -2000,8 +1999,6 @@ pref("browser.ml.chat.shortcuts.custom", true);
pref("browser.ml.chat.shortcuts.longPress", 60000);
pref("browser.ml.chat.sidebar", true);
pref("security.protectionspopup.recordEventTelemetry", true);
// Block insecure active content on https pages
pref("security.mixed_content.block_active_content", true);

View File

@ -936,7 +936,6 @@ var gBrowserInit = {
"resource:///modules/DownloadsMacFinderProgress.sys.mjs"
).DownloadsMacFinderProgress.register();
}
Services.telemetry.setEventRecordingEnabled("downloads", true);
} catch (ex) {
console.error(ex);
}

View File

@ -806,8 +806,6 @@ function updateFxaToolbarMenu(enable, isInitialUpdate = false) {
fxaPanelEl.addEventListener("ViewShowing", gSync.updateSendToDeviceTitle);
Services.telemetry.setEventRecordingEnabled("fxa_app_menu", true);
if (enable && syncEnabled) {
mainWindowEl.setAttribute("fxatoolbarmenu", "visible");
@ -817,8 +815,6 @@ function updateFxaToolbarMenu(enable, isInitialUpdate = false) {
if (!isInitialUpdate) {
gSync.maybeUpdateUIState();
}
Services.telemetry.setEventRecordingEnabled("fxa_avatar_menu", true);
} else {
mainWindowEl.removeAttribute("fxatoolbarmenu");
}
@ -7607,7 +7603,6 @@ var FirefoxViewHandler = {
let viewCount = Services.prefs.getIntPref(PREF_NAME, 0);
// Record telemetry
Services.telemetry.setEventRecordingEnabled("firefoxview_next", true);
Glean.firefoxviewNext.tabSelectedToolbarbutton.record();
if (viewCount < MAX_VIEW_COUNT) {

View File

@ -6,11 +6,8 @@
const ISSUED_BY_CCA_SITE = "https://issued-by-cca.example.com";
const UNKNOWN_ISSUER_SITE = "https://untrusted.example.com";
Services.telemetry.setEventRecordingEnabled("security.ui.certerror", true);
registerCleanupFunction(async () => {
await resetTelemetry();
Services.telemetry.setEventRecordingEnabled("security.ui.certerror", false);
});
async function resetTelemetry() {

View File

@ -40,11 +40,6 @@ add_task(async function checkTelemetryClickEvents() {
return !events || !events.length;
});
// Now enable recording our telemetry. Even if this is disabled, content
// processes will send event telemetry to the parent, thus we needed to ensure
// we waited and cleared first. Sigh.
Services.telemetry.setEventRecordingEnabled("security.ui.certerror", true);
for (let useFrame of [false, true]) {
let recordedObjects = [
"advanced_button",
@ -153,12 +148,4 @@ add_task(async function checkTelemetryClickEvents() {
BrowserTestUtils.removeTab(gBrowser.selectedTab);
}
}
let enableCertErrorUITelemetry = Services.prefs.getBoolPref(
"security.certerrors.recordEventTelemetry"
);
Services.telemetry.setEventRecordingEnabled(
"security.ui.certerror",
enableCertErrorUITelemetry
);
});

View File

@ -45,7 +45,6 @@ async function resetTelemetry() {
).content;
return !events || !events.length;
});
Services.telemetry.setEventRecordingEnabled("security.ui.tlserror", true);
}
async function checkTelemetry(errorString, nssError) {

View File

@ -50,7 +50,6 @@ async function verifyError(url, fallbackWarning, testName) {
).content;
return !events || !events.length;
});
Services.telemetry.setEventRecordingEnabled("security.doh.neterror", true);
let browser;
let pageLoaded;

View File

@ -89,7 +89,6 @@ add_task(async function TRROnlyExceptionButtonTelemetry() {
).content;
return !events || !events.length;
});
Services.telemetry.setEventRecordingEnabled("security.doh.neterror", true);
let browser = await loadErrorPage();

View File

@ -1346,10 +1346,6 @@ nsDefaultCommandLineHandler.prototype = {
}
if (notificationData?.privilegedName) {
Services.telemetry.setEventRecordingEnabled(
"browser.launched_to_handle",
true
);
Glean.browserLaunchedToHandle.systemNotification.record({
name: notificationData.privilegedName,
});

View File

@ -1361,10 +1361,6 @@ BrowserGlue.prototype = {
// If we don't start with last profile, the user
// likely sees the profile selector on launch.
if (Services.prefs.getBoolPref(launchOnLoginPref)) {
Services.telemetry.setEventRecordingEnabled(
"launch_on_login",
true
);
Glean.launchOnLogin.lastProfileDisableStartup.record();
}
Services.prefs.setBoolPref(launchOnLoginPref, false);
@ -1950,13 +1946,6 @@ BrowserGlue.prototype = {
lazy.NewTabUtils.init();
Services.telemetry.setEventRecordingEnabled(
"security.ui.protections",
true
);
Services.telemetry.setEventRecordingEnabled("security.doh.neterror", true);
lazy.PageActions.init();
lazy.DoHController.init();
@ -2099,13 +2088,6 @@ BrowserGlue.prototype = {
},
_recordContentBlockingTelemetry() {
Services.telemetry.setEventRecordingEnabled(
"security.ui.protectionspopup",
Services.prefs.getBoolPref(
"security.protectionspopup.recordEventTelemetry"
)
);
let tpEnabled = Services.prefs.getBoolPref(
"privacy.trackingprotection.enabled"
);
@ -2616,24 +2598,6 @@ BrowserGlue.prototype = {
},
},
{
name: "enableCertErrorUITelemetry",
task: () => {
let enableCertErrorUITelemetry = Services.prefs.getBoolPref(
"security.certerrors.recordEventTelemetry",
true
);
Services.telemetry.setEventRecordingEnabled(
"security.ui.certerror",
enableCertErrorUITelemetry
);
Services.telemetry.setEventRecordingEnabled(
"security.ui.tlserror",
enableCertErrorUITelemetry
);
},
},
// Load the Login Manager data from disk off the main thread, some time
// after startup. If the data is required before this runs, for example
// because a restored page contains a password field, it will be loaded on
@ -4747,7 +4711,6 @@ BrowserGlue.prototype = {
})();
// Record why the dialog is showing or not.
Services.telemetry.setEventRecordingEnabled("upgrade_dialog", true);
Glean.upgradeDialog.triggerReason.record({
value: dialogReason || "satisfied",
});
@ -5211,12 +5174,6 @@ BrowserGlue.prototype = {
},
_collectTelemetryPiPEnabled() {
Services.telemetry.setEventRecordingEnabled(
"pictureinpicture.settings",
true
);
Services.telemetry.setEventRecordingEnabled("pictureinpicture", true);
const TOGGLE_ENABLED_PREF =
"media.videocontrols.picture-in-picture.video-toggle.enabled";

View File

@ -416,7 +416,6 @@ const TEST_GLOBAL = {
notifyObservers() {},
},
telemetry: {
setEventRecordingEnabled: () => {},
recordEvent: _eventDetails => {},
scalarSet: () => {},
keyedScalarAdd: () => {},

View File

@ -689,7 +689,6 @@ export class _ASRouter {
this._onExperimentEnrollmentsUpdated =
this._onExperimentEnrollmentsUpdated.bind(this);
this.forcePBWindow = this.forcePBWindow.bind(this);
Services.telemetry.setEventRecordingEnabled("messaging_experiments", true);
this.messagesEnabledInAutomation = [];
}

View File

@ -424,7 +424,6 @@ const TEST_GLOBAL = {
notifyObservers() {},
},
telemetry: {
setEventRecordingEnabled: () => {},
scalarSet: () => {},
keyedScalarAdd: () => {},
},

View File

@ -110,9 +110,6 @@ const NATIVE_FALLBACK_WARNING_PREF = "network.trr.display_fallback_warning";
const NATIVE_FALLBACK_WARNING_HEURISTIC_LIST_PREF =
"network.trr.fallback_warning_heuristic_list";
const HEURISTICS_TELEMETRY_CATEGORY = "doh";
const TRRSELECT_TELEMETRY_CATEGORY = "security.doh.trrPerformance";
const kLinkStatusChangedTopic = "network:link-status-changed";
const kConnectivityTopic = "network:captive-portal-connectivity-changed";
const kPrefChangedTopic = "nsPref:changed";
@ -143,15 +140,6 @@ export const DoHController = {
_heuristicsAreEnabled: false,
async init() {
Services.telemetry.setEventRecordingEnabled(
HEURISTICS_TELEMETRY_CATEGORY,
true
);
Services.telemetry.setEventRecordingEnabled(
TRRSELECT_TELEMETRY_CATEGORY,
true
);
await lazy.DoHConfigController.initComplete;
Services.obs.addObserver(this, lazy.DoHConfigController.kConfigUpdateTopic);

View File

@ -15,11 +15,6 @@
* usable network until a full set of results has been captured. We stop retrying
* after 5 attempts.
*/
Services.telemetry.setEventRecordingEnabled(
"security.doh.trrPerformance",
true
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};

View File

@ -43,11 +43,6 @@ let gHasOpenedBefore = false;
* the associated MigrationWizardChild.
*/
export class MigrationWizardParent extends JSWindowActorParent {
constructor() {
super();
Services.telemetry.setEventRecordingEnabled("browser.migration", true);
}
didDestroy() {
Services.obs.notifyObservers(this, "MigrationWizard:Destroyed");
MigrationUtils.finishMigration();

View File

@ -1499,11 +1499,6 @@ export class TelemetryFeed {
// init has finished setting up the observer
}
// Only uninit if the getter has initialized it
if (Object.prototype.hasOwnProperty.call(this, "utEvents")) {
this.utEvents.uninit();
}
// TODO: Send any unfinished sessions
}
}

View File

@ -16,7 +16,6 @@ const EXTRAS_FIELD_NAMES = [
export class UTEventReporting {
constructor() {
Services.telemetry.setEventRecordingEnabled("activity_stream", true);
this.sendUserEvent = this.sendUserEvent.bind(this);
this.sendSessionEndEvent = this.sendSessionEndEvent.bind(this);
}
@ -48,8 +47,4 @@ export class UTEventReporting {
this._createExtras(data, data.session_duration)
);
}
uninit() {
Services.telemetry.setEventRecordingEnabled("activity_stream", false);
}
}

View File

@ -48,7 +48,6 @@ describe("UTEventReporting", () => {
beforeEach(() => {
globals = new GlobalOverrider();
sandbox = globals.sandbox;
sandbox.stub(global.Services.telemetry, "setEventRecordingEnabled");
utEvents = new UTEventReporting();
});
@ -84,27 +83,4 @@ describe("UTEventReporting", () => {
assert.validate(ping, UTSessionPing);
});
});
describe("#uninit()", () => {
it("should call setEventRecordingEnabled with a false value", () => {
assert.equal(
global.Services.telemetry.setEventRecordingEnabled.firstCall.args[0],
"activity_stream"
);
assert.equal(
global.Services.telemetry.setEventRecordingEnabled.firstCall.args[1],
true
);
utEvents.uninit();
assert.equal(
global.Services.telemetry.setEventRecordingEnabled.secondCall.args[0],
"activity_stream"
);
assert.equal(
global.Services.telemetry.setEventRecordingEnabled.secondCall.args[1],
false
);
});
});
});

View File

@ -394,7 +394,6 @@ const TEST_GLOBAL = {
notifyObservers() {},
},
telemetry: {
setEventRecordingEnabled: () => {},
recordEvent: _eventDetails => {},
scalarSet: () => {},
keyedScalarAdd: () => {},

View File

@ -1575,20 +1575,6 @@ add_task(
}
);
add_task(async function test_uninit_calls_utEvents_uninit() {
info("TelemetryFeed.uninit should call .utEvents.uninit");
let sandbox = sinon.createSandbox();
let instance = new TelemetryFeed();
sandbox.stub(instance.utEvents, "uninit");
instance.uninit();
Assert.ok(
instance.utEvents.uninit.calledOnce,
"TelemetryFeed.utEvents.uninit should be called"
);
sandbox.restore();
});
add_task(async function test_uninit_deregisters_observer() {
info(
"TelemetryFeed.uninit should make this.browserOpenNewtabStart() stop " +

View File

@ -1397,12 +1397,6 @@ var gMainPane = {
},
initPrimaryBrowserLanguageUI() {
// Enable telemetry.
Services.telemetry.setEventRecordingEnabled(
"intl.ui.browserLanguage",
true
);
// This will register the "command" listener.
let menulist = document.getElementById("primaryBrowserLocale");
new SelectionChangedMenulist(menulist, event => {

View File

@ -191,7 +191,6 @@ function init_all() {
// Asks Preferences to queue an update of the attribute values of
// the entire document.
Preferences.queueUpdateOfAllElements();
Services.telemetry.setEventRecordingEnabled("aboutpreferences", true);
register_module("paneGeneral", gMainPane);
register_module("paneHome", gHomePane);

View File

@ -882,8 +882,6 @@ var gPrivacyPane = {
* Init DoH corresponding prefs
*/
initDoH() {
Services.telemetry.setEventRecordingEnabled("security.doh.settings", true);
setEventListener("dohDefaultArrow", "command", this.toggleExpansion);
setEventListener("dohEnabledArrow", "command", this.toggleExpansion);
setEventListener("dohStrictArrow", "command", this.toggleExpansion);
@ -992,10 +990,6 @@ var gPrivacyPane = {
this._initTrackingProtectionExtensionControl();
this._initThirdPartyCertsToggle();
Services.telemetry.setEventRecordingEnabled("privacy.ui.fpp", true);
Services.telemetry.setEventRecordingEnabled("pwmgr", true);
Preferences.get("privacy.trackingprotection.enabled").on(
"change",
gPrivacyPane.trackingProtectionReadPrefs.bind(gPrivacyPane)

View File

@ -141,7 +141,6 @@ add_task(async function testwhenPrefDisabled() {
add_task(async function test_aboutpreferences_event_telemetry() {
Services.telemetry.clearEvents();
Services.telemetry.setEventRecordingEnabled("aboutpreferences", true);
await SpecialPowers.pushPrefEnv({
set: [["browser.preferences.moreFromMozilla", true]],

View File

@ -102,8 +102,6 @@ add_task(async function checkTelemetryLoadEvents() {
return !events || !events.length;
});
Services.telemetry.setEventRecordingEnabled("security.ui.protections", true);
let tab = await BrowserTestUtils.openNewForegroundTab({
url: "about:protections",
gBrowser,
@ -199,8 +197,6 @@ add_task(async function checkTelemetryClickEvents() {
return !events || !events.length;
});
Services.telemetry.setEventRecordingEnabled("security.ui.protections", true);
let tab = await BrowserTestUtils.openNewForegroundTab({
url: "about:protections",
gBrowser,
@ -804,8 +800,6 @@ add_task(async function checkTelemetryLoadEventForEntrypoint() {
return !events || !events.length;
});
Services.telemetry.setEventRecordingEnabled("security.ui.protections", true);
info("Typo in 'entrypoint' should not be recorded");
let tab = await BrowserTestUtils.openNewForegroundTab({
url: "about:protections?entryPoint=newPage",
@ -888,8 +882,6 @@ add_task(async function checkTelemetryClickEventsVPN() {
).content;
return !events || !events.length;
});
Services.telemetry.setEventRecordingEnabled("security.ui.protections", true);
// user is not subscribed to VPN, and is in the us
AboutProtectionsParent.setTestOverride(getVPNOverrides(false, "us"));
await SpecialPowers.pushPrefEnv({
@ -1055,7 +1047,6 @@ add_task(async function checkTelemetryEventsVPNBanner() {
return !events || !events.length;
});
Services.telemetry.setEventRecordingEnabled("security.ui.protections", true);
// User is not subscribed to VPN
AboutProtectionsParent.setTestOverride(getVPNOverrides(false, "us"));

View File

@ -176,7 +176,6 @@ export var ScreenshotsUtils = {
return;
}
this.resetMethodsUsed();
Services.telemetry.setEventRecordingEnabled("screenshots", true);
Services.obs.addObserver(this, "menuitem-screenshot");
this.initialized = true;
if (Cu.isInAutomation) {

View File

@ -195,7 +195,6 @@ var SessionFileInternal = {
},
async _readInternal(useOldExtension) {
Services.telemetry.setEventRecordingEnabled("session_restore", true);
let result;
let noFilesFound = true;
this._usingOldExtension = useOldExtension;

View File

@ -87,9 +87,6 @@ add_setup(async function () {
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
// Enable event recording for the events tested here.
Services.telemetry.setEventRecordingEnabled("navigation", true);
// Clear history so that history added by previous tests doesn't mess up this
// test when it selects results in the urlbar.
await PlacesUtils.history.clear();
@ -100,7 +97,6 @@ add_setup(async function () {
Services.telemetry.canRecordExtended = oldCanRecord;
await PlacesUtils.history.clear();
await PlacesUtils.bookmarks.eraseEverything();
Services.telemetry.setEventRecordingEnabled("navigation", false);
});
});

View File

@ -28,14 +28,10 @@ add_setup(async () => {
let cleanup = await installPersistTestEngines();
testEngine = Services.search.getEngineByName("Example");
// Enable event recording for the events.
Services.telemetry.setEventRecordingEnabled("navigation", true);
registerCleanupFunction(async function () {
await PlacesUtils.history.clear();
Services.telemetry.clearScalars();
Services.telemetry.clearEvents();
Services.telemetry.setEventRecordingEnabled("navigation", false);
cleanup();
});
});

View File

@ -102,9 +102,6 @@ add_setup(async function () {
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
// Enable event recording for the events tested here.
Services.telemetry.setEventRecordingEnabled("navigation", true);
// Clear history so that history added by previous tests doesn't mess up this
// test when it selects results in the urlbar.
await PlacesUtils.history.clear();
@ -121,7 +118,6 @@ add_setup(async function () {
Services.telemetry.canRecordExtended = oldCanRecord;
await PlacesUtils.history.clear();
await PlacesUtils.bookmarks.eraseEverything();
Services.telemetry.setEventRecordingEnabled("navigation", false);
});
});

View File

@ -90,9 +90,6 @@ add_setup(async function () {
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
// Enable event recording for the events tested here.
Services.telemetry.setEventRecordingEnabled("navigation", true);
// Clear history so that history added by previous tests doesn't mess up this
// test when it selects results in the urlbar.
await PlacesUtils.history.clear();
@ -149,7 +146,6 @@ add_setup(async function () {
Services.telemetry.canRecordExtended = oldCanRecord;
await PlacesUtils.history.clear();
await PlacesUtils.bookmarks.eraseEverything();
Services.telemetry.setEventRecordingEnabled("navigation", false);
});
});

View File

@ -125,7 +125,6 @@ add_setup(async function () {
registerCleanupFunction(async function () {
Services.telemetry.canRecordExtended = oldCanRecord;
await PlacesUtils.history.clear();
Services.telemetry.setEventRecordingEnabled("navigation", false);
});
});

View File

@ -292,7 +292,6 @@ add_task(async function test_remote_tab_result() {
SyncedTabs._internal = originalSyncedTabsInternal;
await PlacesUtils.history.clear();
await PlacesUtils.bookmarks.eraseEverything();
Services.telemetry.setEventRecordingEnabled("navigation", false);
});
await BrowserTestUtils.withNewTab({ gBrowser }, async () => {

View File

@ -264,14 +264,8 @@ add_setup(async function () {
],
});
Services.telemetry.setEventRecordingEnabled(EVENT_CATEGORY, true);
Services.telemetry.clearEvents();
Services.telemetry.clearScalars();
registerCleanupFunction(() => {
Services.telemetry.setEventRecordingEnabled(EVENT_CATEGORY, false);
});
});
add_task(async function test_popup_opened() {

View File

@ -37,10 +37,6 @@ function assertGleanTelemetry(events, expected_number_of_flowid = 1) {
}
add_setup(async function () {
Services.telemetry.setEventRecordingEnabled("creditcard", true);
registerCleanupFunction(async function () {
Services.telemetry.setEventRecordingEnabled("creditcard", false);
});
await clearGleanTelemetry();
});

View File

@ -191,10 +191,6 @@ async function openTabAndUseCreditCard(
}
add_setup(async function () {
Services.telemetry.setEventRecordingEnabled("creditcard", true);
registerCleanupFunction(async function () {
Services.telemetry.setEventRecordingEnabled("creditcard", false);
});
await clearGleanTelemetry();
});

View File

@ -27,7 +27,6 @@ const SEARCH_TOPIC_ENGINE_MODIFIED = "browser-search-engine-modified";
this.addonsSearchDetection = class extends ExtensionAPI {
getAPI(context) {
Services.telemetry.setEventRecordingEnabled("addonsSearchDetection", true);
const { extension } = context;
// We want to temporarily store the first monitored URLs that have been

View File

@ -1567,7 +1567,6 @@ export let BrowserUsageTelemetry = {
let { installer_type, extra } = data;
// Record the event (mirrored to legacy telemetry using GIFFT)
Services.telemetry.setEventRecordingEnabled("installation", true);
if (installer_type == "full") {
Glean.installation.firstSeenFull.record(extra);
} else if (installer_type == "stub") {

View File

@ -76,8 +76,6 @@ export let HomePage = {
return;
}
Services.telemetry.setEventRecordingEnabled("homepage", true);
// Now we have the values, listen for future updates.
this._ignoreListListener = this._handleIgnoreListUpdated.bind(this);

View File

@ -33,7 +33,6 @@ export var PartnerLinkAttribution = {
async makeRequest({ targetURL, source, campaignID }) {
let partner = targetURL.match(/^https?:\/\/(?:www.)?([^.]*)/)[1];
Services.telemetry.setEventRecordingEnabled("partner_link", true);
let extra = { value: partner };
if (source == "newtab") {
Glean.partnerLink.clickNewtab.record(extra);

View File

@ -92,7 +92,6 @@ export var ProcessHangMonitor = {
Services.obs.addObserver(this, "quit-application-granted");
Services.obs.addObserver(this, "xpcom-shutdown");
Services.ww.registerNotification(this);
Services.telemetry.setEventRecordingEnabled("slow_script_warning", true);
},
/**

View File

@ -103,7 +103,6 @@ function DevTools() {
EventEmitter.decorate(this);
this._telemetry = new Telemetry();
this._telemetry.setEventRecordingEnabled(true);
// List of all commands of debugged local Web Extension.
this._commandsPromiseByWebExtId = new Map(); // Map<extensionId, commands>

View File

@ -19,8 +19,6 @@ const { TelemetryEnvironment } = ChromeUtils.importESModule(
);
const WeakMapMap = require("resource://devtools/client/shared/WeakMapMap.js");
const CATEGORY = "devtools.main";
// Object to be shared among all instances.
const PENDING_EVENT_PROPERTIES = new WeakMapMap();
const PENDING_EVENTS = new WeakMapMap();
@ -50,7 +48,6 @@ class Telemetry {
this.keyedScalarAdd = this.keyedScalarAdd.bind(this);
this.keyedScalarSet = this.keyedScalarSet.bind(this);
this.recordEvent = this.recordEvent.bind(this);
this.setEventRecordingEnabled = this.setEventRecordingEnabled.bind(this);
this.preparePendingEvent = this.preparePendingEvent.bind(this);
this.addEventProperty = this.addEventProperty.bind(this);
this.addEventProperties = this.addEventProperties.bind(this);
@ -389,17 +386,6 @@ class Telemetry {
}
}
/**
* Event telemetry is disabled by default. Use this method to enable or
* disable it.
*
* @param {Boolean} enabled
* Enabled: true or false.
*/
setEventRecordingEnabled(enabled) {
return Services.telemetry.setEventRecordingEnabled(CATEGORY, enabled);
}
/**
* Telemetry events often need to make use of a number of properties from
* completely different codepaths. To make this possible we create a

View File

@ -45,7 +45,6 @@ export const DevToolsShim = {
get telemetry() {
if (!this._telemetry) {
this._telemetry = new lazy.Telemetry();
this._telemetry.setEventRecordingEnabled(true);
}
return this._telemetry;
},

View File

@ -330,7 +330,6 @@ DevToolsStartup.prototype = {
get telemetry() {
if (!this._telemetry) {
this._telemetry = new lazy.Telemetry();
this._telemetry.setEventRecordingEnabled(true);
}
return this._telemetry;
},

View File

@ -63,8 +63,6 @@ const TEST_CASES = [
];
add_setup(async function () {
Services.telemetry.setEventRecordingEnabled("security.ui.xfocsperror", true);
await SpecialPowers.pushPrefEnv({
set: [
["security.xfocsp.errorReporting.enabled", true],

View File

@ -93,7 +93,6 @@ function makeChan() {
add_task(async function test_empty_jar_file_async() {
var chan = makeChan();
Services.telemetry.setEventRecordingEnabled("zero_byte_load", true);
Services.telemetry.clearEvents();
await new Promise(resolve => {
@ -127,7 +126,6 @@ add_task(async function test_empty_jar_file_async() {
add_task(async function test_empty_jar_file_sync() {
var chan = makeChan();
Services.telemetry.setEventRecordingEnabled("zero_byte_load", true);
Services.telemetry.clearEvents();
await new Promise(resolve => {

View File

@ -44,7 +44,6 @@ add_task(async function sanitized_pref_test() {
],
});
Services.telemetry.setEventRecordingEnabled("security", true);
Services.telemetry.clearEvents();
TelemetryTestUtils.assertNumberOfEvents(0, { process: "content" });

View File

@ -6,7 +6,6 @@ const { TelemetryTestUtils } = ChromeUtils.importESModule(
add_task(async function test_popup_opened() {
Services.telemetry.clearEvents();
Services.telemetry.setEventRecordingEnabled("ysod", true);
const PAGE_URL = getRootDirectory(gTestPath) + "broken_xml.xhtml";
let viewSourceTab = await BrowserTestUtils.openNewForegroundTab(

View File

@ -24,9 +24,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
"services.common.uptake.sampleRate"
);
// Telemetry events id (see Events.yaml).
const TELEMETRY_EVENTS_ID = "uptake.remotecontent.result";
/**
* A wrapper around certain low-level operations that can be substituted for testing.
*/
@ -163,14 +160,6 @@ export class UptakeTelemetry {
throw new Error(`Unknown status '${status}'`);
}
// Report event for real-time monitoring. See Events.yaml for registration.
// Contrary to histograms, Telemetry Events are not enabled by default.
// Enable them on first call to `report()`.
if (!this._eventsEnabled) {
Services.telemetry.setEventRecordingEnabled(TELEMETRY_EVENTS_ID, true);
this._eventsEnabled = true;
}
const hash = await UptakeTelemetry.Policy.getClientIDHash();
const channel = UptakeTelemetry.Policy.getChannel();
const shouldSendEvent =

View File

@ -35,7 +35,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
export class FxAccountsTelemetry {
constructor(fxai) {
this._fxai = fxai;
Services.telemetry.setEventRecordingEnabled("fxa", true);
}
// Records an event *in the Fxa/Sync ping*.

View File

@ -402,7 +402,6 @@ export var SyncedTabs = {
},
recordSyncedTabsTelemetry(object, tabEvent, extraOptions) {
Services.telemetry.setEventRecordingEnabled("synced_tabs", true);
if (
!["fxa_avatar_menu", "fxa_app_menu", "synced_tabs_sidebar"].includes(
object

View File

@ -652,7 +652,6 @@ add_task(async function test_DownloadSummary_notifications() {
*/
add_task(async function test_downloadAddedTelemetry() {
Services.telemetry.clearEvents();
Services.telemetry.setEventRecordingEnabled("downloads", true);
let targetFile = getTempFile(TEST_TARGET_FILE_NAME);

View File

@ -119,13 +119,9 @@ this.telemetry = class extends ExtensionAPI {
throw new ExtensionUtils.ExtensionError(ex);
}
},
setEventRecordingEnabled(category, enabled) {
setEventRecordingEnabled(_category, _enabled) {
desktopCheck();
try {
Services.telemetry.setEventRecordingEnabled(category, enabled);
} catch (ex) {
throw new ExtensionUtils.ExtensionError(ex);
}
// No-op since bug 1920562 (Fx133).
},
registerEvents(_category, _data) {
desktopCheck();

View File

@ -363,6 +363,7 @@
},
{
"name": "setEventRecordingEnabled",
"deprecated": "`setEventRecordingEnabled` has been deprecated since Firefox 133 (see bug 1920562)",
"type": "function",
"description": "Enable recording of events in a category. Events default to recording enabled. This allows to toggle recording for all events in the specified category.",
"async": true,

View File

@ -535,7 +535,6 @@ if (AppConstants.MOZ_BUILD_APP === "browser") {
add_task(async function test_telemetry_record_event() {
Services.telemetry.clearEvents();
Services.telemetry.setEventRecordingEnabled("telemetry.test", true);
ExtensionTestUtils.failOnSchemaWarnings(false);
@ -568,14 +567,12 @@ if (AppConstants.MOZ_BUILD_APP === "browser") {
ExtensionTestUtils.failOnSchemaWarnings(true);
Services.telemetry.setEventRecordingEnabled("telemetry.test", false);
Services.telemetry.clearEvents();
});
// Bug 1536877
add_task(async function test_telemetry_record_event_value_must_be_string() {
Services.telemetry.clearEvents();
Services.telemetry.setEventRecordingEnabled("telemetry.test", true);
ExtensionTestUtils.failOnSchemaWarnings(false);
@ -619,7 +616,6 @@ if (AppConstants.MOZ_BUILD_APP === "browser") {
ExtensionTestUtils.failOnSchemaWarnings(true);
Services.telemetry.setEventRecordingEnabled("telemetry.test", false);
Services.telemetry.clearEvents();
});

View File

@ -93,9 +93,6 @@ export let FormAutofillStatus = {
if (FormAutofill.isAutofillCreditCardsAvailable) {
Services.prefs.addObserver(ENABLED_AUTOFILL_CREDITCARDS_PREF, this);
}
Services.telemetry.setEventRecordingEnabled("creditcard", true);
Services.telemetry.setEventRecordingEnabled("address", true);
},
/**

View File

@ -156,14 +156,6 @@ Assert.equal(true, snapshot["telemetry.test.mirror_for_labeled_bool"]["1".repeat
### Telemetry Events
A Glean event can be mirrored to a Telemetry Event.
If the Telemetry Event is disabled
(by calling `Services.telemetry.setEventRecordingEnabled("event.category", false);`),
recording to the Glean event will still work,
and the event will be Summarized in Telemetry as all disabled events are.
See
[the Telemetry Event docs](/toolkit/components/telemetry/collection/events.rst)
for details on how disabled Telemetry Events behave.
In order to make use of the `value` field in Telemetry Events, you must
first define an event extra in the metrics.yaml file with the name "value".

View File

@ -218,8 +218,6 @@ add_task(function test_gifft_string_list_works() {
});
add_task(function test_gifft_events() {
Telemetry.setEventRecordingEnabled("telemetry.test", true);
Glean.testOnlyIpc.noExtraEvent.record();
var events = Glean.testOnlyIpc.noExtraEvent.testGetValue();
Assert.equal(1, events.length);

View File

@ -134,8 +134,6 @@ add_task({ skip_if: () => runningInParent }, async function run_child_stuff() {
add_task(
{ skip_if: () => !runningInParent },
async function test_child_metrics() {
Telemetry.setEventRecordingEnabled("telemetry.test", true);
// Clear any stray Telemetry data
Telemetry.clearScalars();
Telemetry.getSnapshotForHistograms("main", true);

View File

@ -20,7 +20,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
setTimeout: "resource://gre/modules/Timer.sys.mjs",
});
const TARGETING_EVENT_CATEGORY = "messaging_experiments";
const DEFAULT_TIMEOUT = 5000;
const ERROR_TYPES = {
ATTRIBUTE_ERROR: "AttributeError",
@ -81,9 +80,6 @@ export class TargetingContext {
// Used in telemetry to report where the targeting expression is coming from
this.#telemetrySource = options.source;
// Enable event recording
Services.telemetry.setEventRecordingEnabled(TARGETING_EVENT_CATEGORY, true);
}
setTelemetrySource(source) {

View File

@ -25,7 +25,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
COLLECTION_ID_PREF,
COLLECTION_ID_FALLBACK
);
const EXPOSURE_EVENT_CATEGORY = "normandy";
function parseJSON(value) {
if (value) {
@ -267,7 +266,6 @@ export const ExperimentAPI = {
},
recordExposureEvent({ featureId, experimentSlug, branchSlug }) {
Services.telemetry.setEventRecordingEnabled(EXPOSURE_EVENT_CATEGORY, true);
Glean.normandy.exposeNimbusExperiment.record({
value: experimentSlug,
branchSlug,

View File

@ -2,12 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const TELEMETRY_CATEGORY = "normandy";
export const TelemetryEvents = {
init() {
Services.telemetry.setEventRecordingEnabled(TELEMETRY_CATEGORY, true);
},
init() {},
sendEvent(method, object, value, extra) {
for (const val of Object.values(extra)) {

View File

@ -407,8 +407,6 @@ export const LoginHelper = {
// Watch for pref changes to update cached pref values.
Services.prefs.addObserver("signon.", () => this.updateSignonPrefs());
this.updateSignonPrefs();
Services.telemetry.setEventRecordingEnabled("pwmgr", true);
Services.telemetry.setEventRecordingEnabled("form_autocomplete", true);
// Watch for FXA Logout to reset signon.firefoxRelay to 'available'
// Using hard-coded value for FxAccountsCommon.ONLOGOUT_NOTIFICATION because

View File

@ -170,7 +170,6 @@ add_setup(async function () {
const canRecordExtendedOld = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
Services.telemetry.clearEvents();
Services.telemetry.setEventRecordingEnabled("relay_integration", true);
gRelayACOptionsTitles = await new Localization([
"browser/firefoxRelay.ftl",
@ -186,7 +185,6 @@ add_setup(async function () {
resolve();
});
});
Services.telemetry.setEventRecordingEnabled("relay_integration", false);
Services.telemetry.clearEvents();
Services.telemetry.canRecordExtended = canRecordExtendedOld;
sinon.restore();

View File

@ -223,7 +223,6 @@ add_task(async function test_eventTelemetry() {
url: TEST_PAGE,
},
async browser => {
Services.telemetry.setEventRecordingEnabled("pictureinpicture", true);
let videoID = "no-controls";
const PIP_PREF =

View File

@ -85,8 +85,6 @@ const DEFAULT_COLORS = {
"selection-highlight": "#FFFFCC",
};
Services.telemetry.setEventRecordingEnabled("readermode", true);
const zoomOnCtrl =
Services.prefs.getIntPref("mousewheel.with_control.action", 3) == 3;
const zoomOnMeta =

View File

@ -42,8 +42,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
const gIsFirefoxDesktop =
Services.appinfo.ID == "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
Services.telemetry.setEventRecordingEnabled("readermode", true);
export var ReaderMode = {
DEBUG: 0,

View File

@ -743,7 +743,6 @@ class RelayDisabled {}
class RelayFeature extends OptInFeature {
constructor() {
super(RelayOffered, RelayEnabled, RelayDisabled, gConfig.relayFeaturePref);
Services.telemetry.setEventRecordingEnabled("relay_integration", true);
// Update the config when the signon.firefoxRelay.base_url pref is changed.
// This is added mainly for tests.
Services.prefs.addObserver(

View File

@ -157,29 +157,6 @@ Since Firefox 132 (see `bug 1863031 <https://bugzilla.mozilla.org/show_bug.cgi?i
events in Firefox Desktop are
:doc:`recorded using the Glean API <../../glean/user/glean_for_legacy_events>`.
``setEventRecordingEnabled()``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: js
Services.telemetry.setEventRecordingEnabled(category, enabled);
Event recording is currently enabled by default for events registered in Events.yaml.
Dynamically-registered events (those registered using ``registerEvents()``) cannot be disabled.
Privileged add-ons and Firefox code can enable & disable recording events for specific categories using this function.
Example:
.. code-block:: js
Services.telemetry.setEventRecordingEnabled("ui", false);
// ... now "ui" events will not be recorded anymore.
.. note::
Even if your event category isn't enabled, counts of events that attempted to be recorded will
be :ref:`summarized <events.event-summary>`.
.. note::
Events can be expensive to store, submit, and query.
You are responsible for ensuring that you don't submit too many events.

View File

@ -135,11 +135,6 @@ Instead, use :doc:`Glean event definitions <../../glean/user/glean_for_legacy_ev
``setEventRecordingEnabled``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: js
Deprecated since Firefox 133 by bug 1920562.
browser.telemetry.setEventRecordingEnabled(category, enabled);
Enable recording of events in a category. Events default to recording enabled. This allows to toggle recording for all events in the specified category.
* ``category`` - *(string)* The category name.
* ``enabled`` - *(boolean)* Whether recording is enabled for events in that category.
Instead, use :doc:`Glean event definitions <../../glean/user/glean_for_legacy_events>` for your extension's events.

View File

@ -83,8 +83,6 @@ add_task(async function () {
await TelemetryController.testSetup();
// Make sure we don't generate unexpected pings due to pref changes.
await setEmptyPrefWatchlist();
// Enable recording for the test event category.
Telemetry.setEventRecordingEnabled("telemetry.test", true);
// Register dynamic test events.
Telemetry.registerEvents("telemetry.test.dynamic", {

View File

@ -56,7 +56,6 @@ add_task(async function setup() {
await TelemetryController.testSetup();
TelemetryEventPing.testReset();
Telemetry.setEventRecordingEnabled("telemetry.test", true);
});
// Tests often take the form of faking policy within faked policy.

View File

@ -61,8 +61,6 @@ add_task(async function test_setup() {
expired: true,
},
});
Telemetry.setEventRecordingEnabled(TEST_STATIC_EVENT_NAME, true);
Telemetry.setEventRecordingEnabled(TEST_EVENT_NAME, true);
Telemetry.recordEvent(TEST_EVENT_NAME, "dynamic", "builtin");
Telemetry.recordEvent(TEST_STATIC_EVENT_NAME, "main_and_content", "object1");

View File

@ -161,61 +161,6 @@ add_task(async function test_event_summary_limit() {
);
});
add_task(async function test_recording_state() {
Telemetry.clearEvents();
Telemetry.clearScalars();
const events = [
["telemetry.test", "test1", "object1"],
["telemetry.test.second", "test", "object1"],
];
Telemetry.setEventRecordingEnabled("telemetry.test", false);
Telemetry.setEventRecordingEnabled("telemetry.test.second", false);
// Both test categories should now be off.
events.forEach(e => Telemetry.recordEvent(...e));
TelemetryTestUtils.assertEvents([]);
checkEventSummary(
events.map(e => ["parent", e, 1]),
true
);
// Enable one test category and see that we record correctly.
Telemetry.setEventRecordingEnabled("telemetry.test", true);
events.forEach(e => Telemetry.recordEvent(...e));
TelemetryTestUtils.assertEvents([events[0]]);
checkEventSummary(
events.map(e => ["parent", e, 1]),
true
);
// Also enable the other test category and see that we record correctly.
Telemetry.setEventRecordingEnabled("telemetry.test.second", true);
events.forEach(e => Telemetry.recordEvent(...e));
TelemetryTestUtils.assertEvents(events);
checkEventSummary(
events.map(e => ["parent", e, 1]),
true
);
// Now turn of one category again and check that this works as expected.
Telemetry.setEventRecordingEnabled("telemetry.test", false);
events.forEach(e => Telemetry.recordEvent(...e));
TelemetryTestUtils.assertEvents([events[1]]);
checkEventSummary(
events.map(e => ["parent", e, 1]),
true
);
});
add_task(async function recording_setup() {
// Make sure both test categories are enabled for the remaining tests.
// Otherwise their event recording won't work.
Telemetry.setEventRecordingEnabled("telemetry.test", true);
Telemetry.setEventRecordingEnabled("telemetry.test.second", true);
});
add_task(async function test_recording() {
Telemetry.clearScalars();
Telemetry.clearEvents();

View File

@ -102,9 +102,6 @@ add_task(
const TEST_EVENT_NAME = "telemetry.test.builtin";
const DYNAMIC_EVENT_CATEGORY = "telemetry.test.expired";
const STATIC_EVENT_CATEGORY = "telemetry.test";
Telemetry.setEventRecordingEnabled(TEST_EVENT_NAME, true);
Telemetry.setEventRecordingEnabled(DYNAMIC_EVENT_CATEGORY, true);
Telemetry.setEventRecordingEnabled(STATIC_EVENT_CATEGORY, true);
Telemetry.recordEvent(TEST_EVENT_NAME, "test1", "object1");
Telemetry.recordEvent(TEST_EVENT_NAME, "test2", "object1", null, {
key1: "foo",
@ -180,7 +177,6 @@ add_task(async function test_dynamicBuiltinEvents() {
});
// Record some events.
Telemetry.setEventRecordingEnabled(TEST_EVENT_NAME, true);
Telemetry.recordEvent(TEST_EVENT_NAME, "test1", "object1");
Telemetry.recordEvent(TEST_EVENT_NAME, "test2", "object1", null, {
key1: "foo",
@ -228,62 +224,6 @@ add_task(async function test_dynamicBuiltinEvents() {
}
});
add_task(async function test_dynamicBuiltinEventsDisabledByDefault() {
Telemetry.clearEvents();
Telemetry.canRecordExtended = true;
const TEST_EVENT_NAME = "telemetry.test.offbydefault";
// Register some dynamic builtin test events.
Telemetry.registerBuiltinEvents(TEST_EVENT_NAME, {
// Event with only required fields.
test1: {
methods: ["test1"],
objects: ["object1"],
},
});
// Record some events.
// Explicitely disable the category
Telemetry.setEventRecordingEnabled(TEST_EVENT_NAME, false);
Telemetry.recordEvent(TEST_EVENT_NAME, "test1", "object1");
// Now check that the snapshot contains the expected data.
let snapshot = Telemetry.snapshotEvents(
Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS,
false
);
Assert.ok(
!("parent" in snapshot),
"Should not have parent events in the snapshot."
);
// Now enable the category and record again
Telemetry.setEventRecordingEnabled(TEST_EVENT_NAME, true);
Telemetry.recordEvent(TEST_EVENT_NAME, "test1", "object1");
snapshot = Telemetry.snapshotEvents(
Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS,
false
);
Assert.ok("parent" in snapshot, "Should have parent events in the snapshot.");
let expected = [[TEST_EVENT_NAME, "test1", "object1"]];
let events = snapshot.parent;
Assert.equal(
events.length,
expected.length,
"Should have recorded the right amount of events."
);
for (let i = 0; i < expected.length; ++i) {
Assert.deepEqual(
events[i].slice(1),
expected[i],
"Should have recorded the expected event data."
);
}
});
add_task(async function test_dynamicBuiltinDontOverwriteStaticData() {
Telemetry.clearEvents();
Telemetry.canRecordExtended = true;
@ -299,10 +239,6 @@ add_task(async function test_dynamicBuiltinDontOverwriteStaticData() {
},
});
// First enable the categories we're using
Telemetry.setEventRecordingEnabled(TEST_STATIC_EVENT_NAME, true);
Telemetry.setEventRecordingEnabled(TEST_EVENT_NAME, true);
// Now record some dynamic-builtin and static events
Telemetry.recordEvent(TEST_EVENT_NAME, "dynamic", "builtin");
Telemetry.recordEvent(TEST_STATIC_EVENT_NAME, "test1", "object1");
@ -357,7 +293,6 @@ add_task(async function test_dynamicBuiltinEventsOverridingStatic() {
});
// Record some events that should be available in the static event already .
Telemetry.setEventRecordingEnabled(TEST_EVENT_NAME, true);
Telemetry.recordEvent(TEST_EVENT_NAME, "test1", "object1");
Telemetry.recordEvent(TEST_EVENT_NAME, "test2", "object1", null, {
key1: "foo",
@ -423,7 +358,6 @@ add_task(async function test_realDynamicDontOverwrite() {
});
// Record some events that should be available in the static event already .
Telemetry.setEventRecordingEnabled(TEST_EVENT_NAME, true);
Telemetry.recordEvent(TEST_EVENT_NAME, "test1", "object1");
Telemetry.recordEvent(TEST_EVENT_NAME, "test2", "object1", null, {
key1: "foo",

View File

@ -122,8 +122,6 @@ export function JSONFile(config) {
this._finalizeInternalBound,
() => ({ sanitizedBasename: this.sanitizedBasename })
);
Services.telemetry.setEventRecordingEnabled("jsonfile", true);
}
JSONFile.prototype = {

View File

@ -48,7 +48,6 @@ const PROXY_CONFIG_TYPES = [
function recordEvent(service, source = {}) {
try {
Services.telemetry.setEventRecordingEnabled("service_request", true);
source.value = service;
Glean.serviceRequest.bypassProxyInfo.record(source);
} catch (err) {

View File

@ -595,9 +595,6 @@ var AddonManagerInternal = {
this.recordTimestamp("AMI_startup_begin");
// Enable the addonsManager telemetry event category.
AMTelemetry.init();
// Enable the AMRemoteSettings client.
AMRemoteSettings.init();
@ -4679,13 +4676,6 @@ AMRemoteSettings = {
AMTelemetry = {
telemetrySetupDone: false,
init() {
// Enable the addonsManager telemetry event category before the AddonManager
// has completed its startup, otherwise telemetry events recorded during the
// AddonManager/XPIProvider startup will not be recorded.
Services.telemetry.setEventRecordingEnabled("addonsManager", true);
},
// This method is called by the AddonManager, once it has been started, so that we can
// init the telemetry event category and start listening for the events related to the
// addons installation and management.

View File

@ -10500,7 +10500,6 @@ interface nsITelemetry extends nsISupports {
clearScalars(): void;
flushBatchedChildTelemetry(): void;
recordEvent(aCategory: string, aMethod: string, aObject: string, aValue?: any, extra?: any): void;
setEventRecordingEnabled(aCategory: string, aEnabled: boolean): void;
snapshotEvents(aDataset: u32, aClear?: boolean, aEventLimit?: u32): any;
registerEvents(aCategory: string, aEventData: any): void;
registerBuiltinEvents(aCategory: string, aEventData: any): void;