Browse Source

Issue #21 - Remove Telemetry accumulation/structures from toolkit js.

This fixes toolkit modules and prevents toolkit component breakage.
Also removes about:telemetry
tracking
Moonchild 8 months ago committed by roytam1
parent
commit
44388b01a3
  1. 4
      docshell/base/nsAboutRedirector.cpp
  2. 5
      toolkit/components/addoncompat/CompatWarning.jsm
  3. 2
      toolkit/components/alerts/resources/content/alert.js
  4. 12
      toolkit/components/asyncshutdown/AsyncShutdown.jsm
  5. 1
      toolkit/components/asyncshutdown/nsAsyncShutdown.js
  6. 5
      toolkit/components/asyncshutdown/nsIAsyncShutdown.idl
  7. 5
      toolkit/components/blocklist/nsBlocklistService.js
  8. 67
      toolkit/components/crashes/CrashManager.jsm
  9. 41
      toolkit/components/gfx/SanityTest.js
  10. 4
      toolkit/components/osfile/NativeOSFileInternals.cpp
  11. 25
      toolkit/components/osfile/modules/osfile_async_front.jsm
  12. 1
      toolkit/components/osfile/modules/osfile_async_worker.js
  13. 3
      toolkit/components/parentalcontrols/nsIParentalControlsService.idl
  14. 1
      toolkit/components/passwordmgr/InsecurePasswordUtils.jsm
  15. 5
      toolkit/components/passwordmgr/LoginManagerContent.jsm
  16. 11
      toolkit/components/passwordmgr/content/passwordManager.js
  17. 75
      toolkit/components/passwordmgr/nsLoginManager.js
  18. 20
      toolkit/components/passwordmgr/nsLoginManagerPrompter.js
  19. 12
      toolkit/components/perfmonitoring/AddonWatcher.jsm
  20. 8
      toolkit/components/places/BookmarkHTMLUtils.jsm
  21. 8
      toolkit/components/places/BookmarkJSONUtils.jsm
  22. 8
      toolkit/components/places/PlacesBackups.jsm
  23. 9
      toolkit/components/places/PlacesCategoriesStarter.js
  24. 186
      toolkit/components/places/PlacesDBUtils.jsm
  25. 4
      toolkit/components/places/UnifiedComplete.js
  26. 17
      toolkit/components/places/nsPlacesAutoComplete.js
  27. 32
      toolkit/components/places/nsPlacesExpiration.js
  28. 13
      toolkit/components/printing/content/printUtils.js
  29. 4
      toolkit/components/terminator/terminator.manifest
  30. 59
      toolkit/components/thumbnails/BackgroundPageThumbs.jsm
  31. 7
      toolkit/components/thumbnails/PageThumbs.jsm
  32. 4
      toolkit/components/thumbnails/content/backgroundPageThumbsContent.js
  33. 9
      toolkit/components/viewsource/content/viewSourceUtils.js
  34. 271
      toolkit/content/aboutTelemetry.css
  35. 2168
      toolkit/content/aboutTelemetry.js
  36. 290
      toolkit/content/aboutTelemetry.xhtml
  37. 3
      toolkit/content/jar.mn
  38. 73
      toolkit/mozapps/extensions/AddonManager.jsm
  39. 17
      toolkit/mozapps/extensions/content/update.js
  40. 11
      toolkit/mozapps/extensions/internal/GMPProvider.jsm
  41. 54
      toolkit/mozapps/extensions/internal/XPIProvider.jsm
  42. 49
      toolkit/mozapps/extensions/internal/XPIProviderUtils.js

4
docshell/base/nsAboutRedirector.cpp

@ -135,10 +135,6 @@ static RedirEntry kRedirMap[] = {
{
"support", "chrome://global/content/aboutSupport.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{
"telemetry", "chrome://global/content/aboutTelemetry.xhtml",
nsIAboutModule::ALLOW_SCRIPT
#ifdef MOZ_WEBRTC
},
{

5
toolkit/components/addoncompat/CompatWarning.jsm

@ -47,11 +47,6 @@ var CompatWarning = {
}
alreadyWarned = true;
if (addon) {
let histogram = Services.telemetry.getKeyedHistogramById("ADDON_SHIM_USAGE");
histogram.add(addon, warning ? warning.number : 0);
}
if (!Preferences.get("dom.ipc.shims.enabledWarnings", false))
return;

2
toolkit/components/alerts/resources/content/alert.js

@ -329,8 +329,6 @@ function doNotDisturb() {
.getService(Ci.nsIAlertsService)
.QueryInterface(Ci.nsIAlertsDoNotDisturb);
alertService.manualDoNotDisturb = true;
Services.telemetry.getHistogramById("WEB_NOTIFICATION_MENU")
.add(0);
onAlertClose();
}

12
toolkit/components/asyncshutdown/AsyncShutdown.jsm

@ -9,12 +9,11 @@
* sequentially. Typically, each shutdown phase removes some
* capabilities from the application. For instance, at the end of
* phase profileBeforeChange, no service is permitted to write to the
* profile directory (with the exception of Telemetry). Consequently,
* if any service has requested I/O to the profile directory before or
* during phase profileBeforeChange, the system must be informed that
* these requests need to be completed before the end of phase
* profileBeforeChange. Failing to inform the system of this
* requirement can (and has been known to) cause data loss.
* profile directory. Consequently, if any service has requested I/O
* to the profile directory before or during phase profileBeforeChange,
* the system must be informed that these requests need to be completed
* before the end of phase profileBeforeChange. Failing to inform the
* system of this requirement can (and has been known to) cause data loss.
*
* Example: At some point during shutdown, the Add-On Manager needs to
* ensure that all add-ons have safely written their data to disk,
@ -1001,7 +1000,6 @@ if (!isContent) {
this.AsyncShutdown.profileChangeTeardown = getPhase("profile-change-teardown");
this.AsyncShutdown.profileBeforeChange = getPhase("profile-before-change");
this.AsyncShutdown.placesClosingInternalConnection = getPhase("places-will-close-connection");
this.AsyncShutdown.sendTelemetry = getPhase("profile-before-change-telemetry");
}
// Notifications that fire in the parent and content process, but should

1
toolkit/components/asyncshutdown/nsAsyncShutdown.js

@ -230,7 +230,6 @@ function nsAsyncShutdownService() {
"profileBeforeChange",
"profileChangeTeardown",
"quitApplicationGranted",
"sendTelemetry",
// Child processes
"contentChildShutdown",

5
toolkit/components/asyncshutdown/nsIAsyncShutdown.idl

@ -192,11 +192,6 @@ interface nsIAsyncShutdownService: nsISupports {
*/
readonly attribute nsIAsyncShutdownClient quitApplicationGranted;
/**
* Barrier for notification profile-before-change-telemetry.
*/
readonly attribute nsIAsyncShutdownClient sendTelemetry;
// Barriers for global shutdown stages in all processes.

5
toolkit/components/blocklist/nsBlocklistService.js

@ -748,10 +748,7 @@ Blocklist.prototype = {
return;
}
let telemetry = Services.telemetry;
if (this._isBlocklistPreloaded()) {
telemetry.getHistogramById("BLOCKLIST_SYNC_FILE_LOAD").add(false);
this._loadBlocklistFromString(this._preloadedBlocklistContent);
delete this._preloadedBlocklistContent;
return;
@ -762,8 +759,6 @@ Blocklist.prototype = {
return;
}
telemetry.getHistogramById("BLOCKLIST_SYNC_FILE_LOAD").add(true);
let text = "";
let fstream = null;
let cstream = null;

67
toolkit/components/crashes/CrashManager.jsm

@ -14,7 +14,6 @@ Cu.import("resource://gre/modules/Services.jsm", this);
Cu.import("resource://gre/modules/Task.jsm", this);
Cu.import("resource://gre/modules/Timer.jsm", this);
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
Cu.import("resource://gre/modules/TelemetryController.jsm");
Cu.import("resource://gre/modules/KeyValueParser.jsm");
this.EXPORTED_SYMBOLS = [
@ -64,9 +63,6 @@ function dateToDays(date) {
* storeDir (string)
* Directory we will use for our data store. This instance will write
* data files into the directory specified.
*
* telemetryStoreSizeKey (string)
* Telemetry histogram to report store size under.
*/
this.CrashManager = function (options) {
for (let k of ["pendingDumpsDir", "submittedDumpsDir", "eventsDirs",
@ -98,10 +94,6 @@ this.CrashManager = function (options) {
this._storeDir = v;
break;
case "telemetryStoreSizeKey":
this._telemetryStoreSizeKey = v;
break;
default:
throw new Error("Unknown property in options: " + k);
}
@ -531,48 +523,6 @@ this.CrashManager.prototype = Object.freeze({
store.addCrash(this.PROCESS_TYPE_MAIN, this.CRASH_TYPE_CRASH,
crashID, date, metadata);
// If we have a saved environment, use it. Otherwise report
// the current environment.
let crashEnvironment = null;
let sessionId = null;
let stackTraces = null;
let reportMeta = Cu.cloneInto(metadata, myScope);
if ('TelemetryEnvironment' in reportMeta) {
try {
crashEnvironment = JSON.parse(reportMeta.TelemetryEnvironment);
} catch (e) {
Cu.reportError(e);
}
delete reportMeta.TelemetryEnvironment;
}
if ('TelemetrySessionId' in reportMeta) {
sessionId = reportMeta.TelemetrySessionId;
delete reportMeta.TelemetrySessionId;
}
if ('StackTraces' in reportMeta) {
try {
stackTraces = JSON.parse(reportMeta.StackTraces);
} catch (e) {
Cu.reportError(e);
}
delete reportMeta.StackTraces;
}
TelemetryController.submitExternalPing("crash",
{
version: 1,
crashDate: date.toISOString().slice(0, 10), // YYYY-MM-DD
sessionId: sessionId,
crashId: entry.id,
stackTraces: stackTraces,
metadata: reportMeta,
hasCrashEnvironment: (crashEnvironment !== null),
},
{
retentionDays: 180,
addClientId: true,
addEnvironment: true,
overrideEnvironment: crashEnvironment,
});
break;
case "crash.submission.1":
@ -665,8 +615,7 @@ this.CrashManager.prototype = Object.freeze({
unixMode: OS.Constants.libc.S_IRWXU,
});
let store = new CrashStore(this._storeDir,
this._telemetryStoreSizeKey);
let store = new CrashStore(this._storeDir);
yield store.load();
this._store = store;
@ -756,13 +705,9 @@ var gCrashManager;
*
* @param storeDir (string)
* Directory the store should be located in.
* @param telemetrySizeKey (string)
* The telemetry histogram that should be used to store the size
* of the data file.
*/
function CrashStore(storeDir, telemetrySizeKey) {
function CrashStore(storeDir) {
this._storeDir = storeDir;
this._telemetrySizeKey = telemetrySizeKey;
this._storePath = OS.Path.join(storeDir, "store.json.mozlz4");
@ -950,9 +895,6 @@ CrashStore.prototype = Object.freeze({
let size = yield OS.File.writeAtomic(this._storePath, data, {
tmpPath: this._storePath + ".tmp",
compression: "lz4"});
if (this._telemetrySizeKey) {
Services.telemetry.getHistogramById(this._telemetrySizeKey).add(size);
}
}.bind(this));
},
@ -1209,8 +1151,6 @@ CrashStore.prototype = Object.freeze({
}
submission.requestDate = date;
Services.telemetry.getKeyedHistogramById("PROCESS_CRASH_SUBMIT_ATTEMPT")
.add(crash.type, 1);
return true;
},
@ -1229,8 +1169,6 @@ CrashStore.prototype = Object.freeze({
submission.responseDate = date;
submission.result = result;
Services.telemetry.getKeyedHistogramById("PROCESS_CRASH_SUBMIT_SUCCESS")
.add(crash.type, result == "ok");
return true;
},
@ -1333,7 +1271,6 @@ XPCOMUtils.defineLazyGetter(this.CrashManager, "Singleton", function () {
submittedDumpsDir: OS.Path.join(crPath, "submitted"),
eventsDirs: [OS.Path.join(crPath, "events"), OS.Path.join(storePath, "events")],
storeDir: storePath,
telemetryStoreSizeKey: "CRASH_STORE_COMPRESSED_BYTES",
});
// Automatically aggregate event files shortly after startup. This

41
toolkit/components/gfx/SanityTest.js

@ -55,31 +55,6 @@ function testPixel(ctx, x, y, r, g, b, a, fuzz) {
return false;
}
function reportResult(val) {
try {
let histogram = Services.telemetry.getHistogramById("GRAPHICS_SANITY_TEST");
histogram.add(val);
} catch (e) {}
Preferences.set(RUNNING_PREF, false);
Services.prefs.savePrefFile(null);
}
function reportTestReason(val) {
let histogram = Services.telemetry.getHistogramById("GRAPHICS_SANITY_TEST_REASON");
histogram.add(val);
}
function annotateCrashReport(value) {
try {
// "1" if we're annotating the crash report, "" to remove the annotation.
var crashReporter = Cc['@mozilla.org/toolkit/crash-reporter;1'].
getService(Ci.nsICrashReporter);
crashReporter.annotateCrashReport("GraphicsSanityTest", value ? "1" : "");
} catch (e) {
}
}
function setTimeout(aMs, aCallback) {
var timer = Cc['@mozilla.org/timer;1'].
createInstance(Ci.nsITimer);
@ -125,18 +100,15 @@ function testCompositor(win, ctx) {
var testPassed = true;
if (!verifyVideoRendering(ctx)) {
reportResult(TEST_FAILED_VIDEO);
Preferences.set(DISABLE_VIDEO_PREF, true);
testPassed = false;
}
if (!verifyLayersRendering(ctx)) {
reportResult(TEST_FAILED_RENDER);
testPassed = false;
}
if (testPassed) {
reportResult(TEST_PASSED);
}
return testPassed;
@ -160,7 +132,6 @@ var listener = {
.getInterface(Ci.nsIDOMWindowUtils);
setTimeout(TIMEOUT_SEC * 1000, () => {
if (this.win) {
reportResult(TEST_TIMEOUT);
this.endTest();
}
});
@ -227,10 +198,6 @@ var listener = {
this.mm = null;
}
// Remove the annotation after we've cleaned everything up, to catch any
// incidental crashes from having performed the sanity test.
annotateCrashReport(false);
}
};
@ -248,7 +215,6 @@ SanityTest.prototype = {
if (Preferences.get(RUNNING_PREF, false)) {
Preferences.set(DISABLE_VIDEO_PREF, true);
reportResult(TEST_CRASHED);
return false;
}
@ -257,11 +223,6 @@ SanityTest.prototype = {
if (prefValue == value) {
return true;
}
if (prefValue === undefined) {
reportTestReason(REASON_FIRST_RUN);
} else {
reportTestReason(reason);
}
return false;
}
@ -296,8 +257,6 @@ SanityTest.prototype = {
if (!this.shouldRunTest()) return;
annotateCrashReport(true);
// Open a tiny window to render our test page, and notify us when it's loaded
var sanityTest = Services.ww.openWindow(null,
"chrome://gfxsanity/content/sanityparent.html",

4
toolkit/components/osfile/NativeOSFileInternals.cpp

@ -169,7 +169,7 @@ public:
* as the AbstractResult is cycle-collected.
*
* @param aStartDate The instant at which the operation was
* requested. Used to collect Telemetry statistics.
* requested.
*/
explicit AbstractResult(TimeStamp aStartDate)
: mStartDate(aStartDate)
@ -182,7 +182,7 @@ public:
* Setup the AbstractResult once data is available.
*
* @param aDispatchDate The instant at which the IO thread received
* the operation request. Used to collect Telemetry statistics.
* the operation request.
* @param aExecutionDuration The duration of the operation on the
* IO thread.
*/

25
toolkit/components/osfile/modules/osfile_async_front.jsm

@ -434,34 +434,11 @@ var Scheduler = this.Scheduler = {
Scheduler.Debugging.latestReceived = [Date.now(), error.message, error.fileName, error.lineNumber];
throw error;
} finally {
if (firstLaunch) {
Scheduler._updateTelemetry();
}
Scheduler.restartTimer();
}
}.bind(this)));
},
/**
* Post Telemetry statistics.
*
* This is only useful on first launch.
*/
_updateTelemetry: function() {
let worker = this.worker;
let workerTimeStamps = worker.workerTimeStamps;
if (!workerTimeStamps) {
// If the first call to OS.File results in an uncaught errors,
// the timestamps are absent. As this case is a developer error,
// let's not waste time attempting to extract telemetry from it.
return;
}
let HISTOGRAM_LAUNCH = Services.telemetry.getHistogramById("OSFILE_WORKER_LAUNCH_MS");
HISTOGRAM_LAUNCH.add(worker.workerTimeStamps.entered - worker.launchTimeStamp);
let HISTOGRAM_READY = Services.telemetry.getHistogramById("OSFILE_WORKER_READY_MS");
HISTOGRAM_READY.add(worker.workerTimeStamps.loaded - worker.launchTimeStamp);
}
};
const PREF_OSFILE_LOG = "toolkit.osfile.log";

1
toolkit/components/osfile/modules/osfile_async_worker.js

@ -12,7 +12,6 @@ if (this.Components) {
(function(exports) {
"use strict";
// Timestamps, for use in Telemetry.
// The object is set to |null| once it has been sent
// to the main thread.
let timeStamps = {

3
toolkit/components/parentalcontrols/nsIParentalControlsService.idl

@ -36,8 +36,7 @@ interface nsIParentalControlsService : nsISupports
const short ADVANCED_SETTINGS = 17; // Advanced settings
const short CAMERA_MICROPHONE = 18; // Camera and microphone (WebRTC)
const short BLOCK_LIST = 19; // Block websites that include sensitive content
const short TELEMETRY = 20; // Submit telemetry data
const short HEALTH_REPORT = 21; // Submit FHR data
// 20 and 21 are unused. Was: Telemetry, FHR
const short DEFAULT_THEME = 22; // Use default theme or a special parental controls theme
/**

1
toolkit/components/passwordmgr/InsecurePasswordUtils.jsm

@ -145,6 +145,5 @@ this.InsecurePasswordUtils = {
passwordSafety = 5;
}
Services.telemetry.getHistogramById("PWMGR_LOGIN_PAGE_SAFETY").add(passwordSafety);
},
};

5
toolkit/components/passwordmgr/LoginManagerContent.jsm

@ -1068,8 +1068,6 @@ var LoginManagerContent = {
}
// Nothing to do if we have no matching logins available.
// Only insecure pages reach this block and logs the same
// telemetry flag.
if (foundLogins.length == 0) {
// We don't log() here since this is a very common case.
autofillResult = AUTOFILL_RESULT.NO_SAVED_LOGINS;
@ -1234,9 +1232,6 @@ var LoginManagerContent = {
}
if (!userTriggered) {
// Ignore fills as a result of user action for this probe.
Services.telemetry.getHistogramById("PWMGR_FORM_AUTOFILL_RESULT").add(autofillResult);
if (usernameField) {
let focusedElement = this._formFillService.focusedInput;
if (usernameField == focusedElement &&

11
toolkit/components/passwordmgr/content/passwordManager.js

@ -90,7 +90,6 @@ function Startup() {
}
SignonColumnSort(sortField);
Services.telemetry.getKeyedHistogramById("PWMGR_MANAGE_SORTED").add(sortField);
});
LoadSignons();
@ -100,9 +99,6 @@ function Startup() {
window.arguments[0] &&
window.arguments[0].filterString) {
setFilter(window.arguments[0].filterString);
Services.telemetry.getHistogramById("PWMGR_MANAGE_OPENED").add(1);
} else {
Services.telemetry.getHistogramById("PWMGR_MANAGE_OPENED").add(0);
}
FocusFilterBox();
@ -434,7 +430,6 @@ function DeleteAllSignons() {
removeButton.setAttribute("disabled", "true");
removeAllButton.setAttribute("disabled", "true");
FinalizeSignonDeletions(syncNeeded);
Services.telemetry.getHistogramById("PWMGR_MANAGE_DELETED_ALL").add(1);
}
function TogglePasswordVisible() {
@ -449,7 +444,6 @@ function TogglePasswordVisible() {
// Notify observers that the password visibility toggling is
// completed. (Mostly useful for tests)
Services.obs.notifyObservers(null, "passwordmgr-password-toggle-complete", null);
Services.telemetry.getHistogramById("PWMGR_MANAGE_VISIBILITY_TOGGLED").add(showingPasswords);
}
function AskUserShowPasswords() {
@ -466,7 +460,6 @@ function AskUserShowPasswords() {
function FinalizeSignonDeletions(syncNeeded) {
for (let s = 0; s < deletedSignons.length; s++) {
Services.logins.removeLogin(deletedSignons[s]);
Services.telemetry.getHistogramById("PWMGR_MANAGE_DELETED").add(1);
}
// If the deletion has been performed in a filtered view, reflect the deletion in the unfiltered table.
// See bug 405389.
@ -640,7 +633,6 @@ function CopyPassword() {
let row = signonsTree.currentIndex;
let password = signonsTreeView.getCellText(row, {id : "passwordCol" });
clipboard.copyString(password);
Services.telemetry.getHistogramById("PWMGR_MANAGE_COPIED_PASSWORD").add(1);
}
function CopyUsername() {
@ -650,7 +642,6 @@ function CopyUsername() {
let row = signonsTree.currentIndex;
let username = signonsTreeView.getCellText(row, {id : "userCol" });
clipboard.copyString(username);
Services.telemetry.getHistogramById("PWMGR_MANAGE_COPIED_USERNAME").add(1);
}
function EditCellInSelectedRow(columnName) {
@ -729,7 +720,7 @@ function escapeKeyHandler() {
#if defined(MC_BASILISK) || defined(HYPE_ICEWEASEL)
function OpenMigrator() {
const { MigrationUtils } = Cu.import("resource:///modules/MigrationUtils.jsm", {});
// We pass in the type of source we're using for use in telemetry:
// We pass in the type of source we're using:
MigrationUtils.showMigrationWizard(window, [MigrationUtils.MIGRATION_ENTRYPOINT_PASSWORDS]);
}
#endif

75
toolkit/components/passwordmgr/nsLoginManager.js

@ -107,7 +107,6 @@ LoginManager.prototype = {
this._initStorage();
}
Services.obs.addObserver(this._observer, "gather-telemetry", false);
},
@ -168,91 +167,17 @@ LoginManager.prototype = {
Services.obs.notifyObservers(null,
"passwordmgr-storage-replace-complete", null);
}.bind(this));
} else if (topic == "gather-telemetry") {
// When testing, the "data" parameter is a string containing the
// reference time in milliseconds for time-based statistics.
this._pwmgr._gatherTelemetry(data ? parseInt(data)
: new Date().getTime());
} else {
log.debug("Oops! Unexpected notification:", topic);
}
}
},
/**
* Collects statistics about the current logins and settings. The telemetry
* histograms used here are not accumulated, but are reset each time this
* function is called, since it can be called multiple times in a session.
*
* This function might also not be called at all in the current session.
*
* @param referenceTimeMs
* Current time used to calculate time-based statistics, expressed as
* the number of milliseconds since January 1, 1970, 00:00:00 UTC.
* This is set to a fake value during unit testing.
*/
_gatherTelemetry(referenceTimeMs) {
function clearAndGetHistogram(histogramId) {
let histogram = Services.telemetry.getHistogramById(histogramId);
histogram.clear();
return histogram;
}
clearAndGetHistogram("PWMGR_BLOCKLIST_NUM_SITES").add(
this.getAllDisabledHosts({}).length
);
clearAndGetHistogram("PWMGR_NUM_SAVED_PASSWORDS").add(
this.countLogins("", "", "")
);
clearAndGetHistogram("PWMGR_NUM_HTTPAUTH_PASSWORDS").add(
this.countLogins("", null, "")
);
// This is a boolean histogram, and not a flag, because we don't want to
// record any value if _gatherTelemetry is not called.
clearAndGetHistogram("PWMGR_SAVING_ENABLED").add(this._remember);
// Don't try to get logins if MP is enabled, since we don't want to show a MP prompt.
if (!this.isLoggedIn) {
return;
}
let logins = this.getAllLogins({});
let usernamePresentHistogram = clearAndGetHistogram("PWMGR_USERNAME_PRESENT");
let loginLastUsedDaysHistogram = clearAndGetHistogram("PWMGR_LOGIN_LAST_USED_DAYS");
let hostnameCount = new Map();
for (let login of logins) {
usernamePresentHistogram.add(!!login.username);
let hostname = login.hostname;
hostnameCount.set(hostname, (hostnameCount.get(hostname) || 0 ) + 1);
login.QueryInterface(Ci.nsILoginMetaInfo);
let timeLastUsedAgeMs = referenceTimeMs - login.timeLastUsed;
if (timeLastUsedAgeMs > 0) {
loginLastUsedDaysHistogram.add(
Math.floor(timeLastUsedAgeMs / MS_PER_DAY)
);
}
}
let passwordsCountHistogram = clearAndGetHistogram("PWMGR_NUM_PASSWORDS_PER_HOSTNAME");
for (let count of hostnameCount.values()) {
passwordsCountHistogram.add(count);
}
},
/* ---------- Primary Public interfaces ---------- */
/**
* @type Promise
* This promise is resolved when initialization is complete, and is rejected

20
toolkit/components/passwordmgr/nsLoginManagerPrompter.js

@ -18,14 +18,6 @@ const LoginInfo =
const BRAND_BUNDLE = "chrome://branding/locale/brand.properties";
/**
* Constants for password prompt telemetry. */
const PROMPT_DISPLAYED = 0;
const PROMPT_ADD_OR_UPDATE = 1;
const PROMPT_NOTNOW = 2;
const PROMPT_NEVER = 3;
/**
* Implements nsIPromptFactory
*
@ -825,7 +817,7 @@ LoginManagerPrompter.prototype = {
* new password.
* @param {string} type
* This is "password-save" or "password-change" depending on the
* original notification type. This is used for telemetry and tests.
* original notification type. This is used for tests.
*/
_showLoginCaptureDoorhanger(login, type) {
let { browser } = this._getNotifyWindow();
@ -855,11 +847,6 @@ LoginManagerPrompter.prototype = {
let promptMsg = type == "password-save" ? this._getLocalizedString(saveMsgNames.prompt, [brandShortName])
: this._getLocalizedString(changeMsgNames.prompt);
let histogramName = type == "password-save" ? "PWMGR_PROMPT_REMEMBER_ACTION"
: "PWMGR_PROMPT_UPDATE_ACTION";
let histogram = Services.telemetry.getHistogramById(histogramName);
histogram.add(PROMPT_DISPLAYED);
let chromeDoc = browser.ownerDocument;
let currentNotification;
@ -986,10 +973,6 @@ LoginManagerPrompter.prototype = {
label: this._getLocalizedString(initialMsgNames.buttonLabel),
accessKey: this._getLocalizedString(initialMsgNames.buttonAccessKey),
callback: () => {
histogram.add(PROMPT_ADD_OR_UPDATE);
if (histogramName == "PWMGR_PROMPT_REMEMBER_ACTION") {
Services.obs.notifyObservers(null, 'LoginStats:NewSavedPassword', null);
}
readDataFromUI();
persistData();
browser.focus();
@ -1001,7 +984,6 @@ LoginManagerPrompter.prototype = {
label: this._getLocalizedString("notifyBarNeverRememberButtonText"),
accessKey: this._getLocalizedString("notifyBarNeverRememberButtonAccessKey"),
callback: () => {
histogram.add(PROMPT_NEVER);
Services.logins.setLoginSavingEnabled(login.hostname, false);
browser.focus();
}

12
toolkit/components/perfmonitoring/AddonWatcher.jsm

@ -19,9 +19,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "console",
"resource://gre/modules/Console.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PerformanceWatcher",
"resource://gre/modules/PerformanceWatcher.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "Telemetry",
"@mozilla.org/base/telemetry;1",
Ci.nsITelemetry);
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "IdleService",
@ -123,15 +120,6 @@ this.AddonWatcher = {
return;
}
// Report immediately to Telemetry, regardless of whether we report to
// the user.
for (let {source: {addonId}, details} of addons) {
Telemetry.getKeyedHistogramById("PERF_MONITORING_SLOW_ADDON_JANK_US").
add(addonId, details.highestJank);
Telemetry.getKeyedHistogramById("PERF_MONITORING_SLOW_ADDON_CPOW_US").
add(addonId, details.highestCPOW);
}
// We expect that users don't care about real-time alerts unless their
// browser is going very, very slowly. Therefore, we use the following
// heuristic:

8
toolkit/components/places/BookmarkHTMLUtils.jsm

@ -220,14 +220,6 @@ this.BookmarkHTMLUtils = Object.freeze({
let exporter = new BookmarkExporter(bookmarks);
yield exporter.exportToFile(aFilePath);
try {
Services.telemetry
.getHistogramById("PLACES_EXPORT_TOHTML_MS")
.add(Date.now() - startTime);
} catch (ex) {
Components.utils.reportError("Unable to report telemetry.");
}
return count;
});
},

8
toolkit/components/places/BookmarkJSONUtils.jsm

@ -144,14 +144,6 @@ this.BookmarkJSONUtils = Object.freeze({
let [bookmarks, count] = yield PlacesBackups.getBookmarksTree();
let startTime = Date.now();
let jsonString = JSON.stringify(bookmarks);
// Report the time taken to convert the tree to JSON.
try {
Services.telemetry
.getHistogramById("PLACES_BACKUPS_TOJSON_MS")
.add(Date.now() - startTime);
} catch (ex) {
Components.utils.reportError("Unable to report telemetry.");
}
let hash = generateHash(jsonString);

8
toolkit/components/places/PlacesBackups.jsm

@ -1,5 +1,4 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* vim: sw=2 ts=2 sts=2 expandtab filetype=javascript
* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
@ -537,13 +536,6 @@ this.PlacesBackups = {
includeItemIds: true
});
try {
Services.telemetry
.getHistogramById("PLACES_BACKUPS_BOOKMARKSTREE_MS")
.add(Date.now() - startTime);
} catch (ex) {
Components.utils.reportError("Unable to report telemetry.");
}
return [root, root.itemsCount];
})
}

9
toolkit/components/places/PlacesCategoriesStarter.js

@ -1,5 +1,4 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* vim: sw=2 ts=2 sts=2 expandtab
* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
@ -10,9 +9,6 @@ const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
// Fired by TelemetryController when async telemetry data should be collected.
const TOPIC_GATHER_TELEMETRY = "gather-telemetry";
// Seconds between maintenance runs.
const MAINTENANCE_INTERVAL_SECONDS = 7 * 86400;
@ -30,7 +26,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesDBUtils",
*/
function PlacesCategoriesStarter()
{
Services.obs.addObserver(this, TOPIC_GATHER_TELEMETRY, false);
Services.obs.addObserver(this, PlacesUtils.TOPIC_SHUTDOWN, false);
// nsINavBookmarkObserver implementation.
@ -63,7 +58,6 @@ PlacesCategoriesStarter.prototype = {
switch (aTopic) {
case PlacesUtils.TOPIC_SHUTDOWN:
Services.obs.removeObserver(this, PlacesUtils.TOPIC_SHUTDOWN);
Services.obs.removeObserver(this, TOPIC_GATHER_TELEMETRY);
let globalObj =
Cu.getGlobalForObject(PlacesCategoriesStarter.prototype);
let descriptor =
@ -72,9 +66,6 @@ PlacesCategoriesStarter.prototype = {
PlacesDBUtils.shutdown();
}
break;
case TOPIC_GATHER_TELEMETRY:
PlacesDBUtils.telemetry();
break;
case "idle-daily":
// Once a week run places.sqlite maintenance tasks.
let lastMaintenance =

186
toolkit/components/places/PlacesDBUtils.jsm

@ -1,5 +1,4 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* vim: sw=2 ts=2 sts=2 expandtab filetype=javascript
* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
@ -51,13 +50,6 @@ this.PlacesDBUtils = {
}
else {
// All tasks have been completed.
// Telemetry the time it took for maintenance, if a start time exists.
if (aTasks._telemetryStart) {
Services.telemetry.getHistogramById("PLACES_IDLE_MAINTENANCE_TIME_MS")
.add(Date.now() - aTasks._telemetryStart);
aTasks._telemetryStart = 0;
}
if (aTasks.callback) {
let scope = aTasks.scope || Cu.getGlobalForObject(aTasks.callback);
aTasks.callback.call(scope, aTasks.messages);
@ -89,7 +81,6 @@ this.PlacesDBUtils = {
, this.checkCoherence
, this._refreshUI
]);
tasks._telemetryStart = Date.now();
tasks.callback = function() {
Services.prefs.setIntPref("places.database.lastMaintenance",
parseInt(Date.now() / 1000));
@ -856,181 +847,6 @@ this.PlacesDBUtils = {
PlacesDBUtils._executeTasks(tasks);
},
/**
* Collects telemetry data and reports it to Telemetry.
*
* @param [optional] aTasks
* Tasks object to execute.
*/
telemetry: function PDBU_telemetry(aTasks)
{
let tasks = new Tasks(aTasks);
// This will be populated with one integer property for each probe result,
// using the histogram name as key.
let probeValues = {};
// The following array contains an ordered list of entries that are
// processed to collect telemetry data. Each entry has these properties:
//
// histogram: Name of the telemetry histogram to update.
// query: This is optional. If present, contains a database command
// that will be executed asynchronously, and whose result will
// be added to the telemetry histogram.
// callback: This is optional. If present, contains a function that must
// return the value that will be added to the telemetry
// histogram. If a query is also present, its result is passed
// as the first argument of the function. If the function
// raises an exception, no data is added to the histogram.
//
// Since all queries are executed in order by the database backend, the
// callbacks can also use the result of previous queries stored in the
// probeValues object.
let probes = [
{ histogram: "PLACES_PAGES_COUNT",
query: "SELECT count(*) FROM moz_places" },
{ histogram: "PLACES_BOOKMARKS_COUNT",
query: `SELECT count(*) FROM moz_bookmarks b
JOIN moz_bookmarks t ON t.id = b.parent
AND t.parent <> :tags_folder
WHERE b.type = :type_bookmark` },
{ histogram: "PLACES_TAGS_COUNT",
query: `SELECT count(*) FROM moz_bookmarks
WHERE parent = :tags_folder` },
{ histogram: "PLACES_KEYWORDS_COUNT",
query: "SELECT count(*) FROM moz_keywords" },
{ histogram: "PLACES_SORTED_BOOKMARKS_PERC",
query: `SELECT IFNULL(ROUND((
SELECT count(*) FROM moz_bookmarks b
JOIN moz_bookmarks t ON t.id = b.parent
AND t.parent <> :tags_folder AND t.parent > :places_root
WHERE b.type = :type_bookmark
) * 100 / (
SELECT count(*) FROM moz_bookmarks b
JOIN moz_bookmarks t ON t.id = b.parent
AND t.parent <> :tags_folder
WHERE b.type = :type_bookmark
)), 0)` },
{ histogram: "PLACES_TAGGED_BOOKMARKS_PERC",
query: `SELECT IFNULL(ROUND((
SELECT count(*) FROM moz_bookmarks b
JOIN moz_bookmarks t ON t.id = b.parent
AND t.parent = :tags_folder
) * 100 / (
SELECT count(*) FROM moz_bookmarks b
JOIN moz_bookmarks t ON t.id = b.parent
AND t.parent <> :tags_folder
WHERE b.type = :type_bookmark
)), 0)` },
{ histogram: "PLACES_DATABASE_FILESIZE_MB",
callback: function () {
let DBFile = Services.dirsvc.get("ProfD", Ci.nsILocalFile);
DBFile.append("places.sqlite");
return parseInt(DBFile.fileSize / BYTES_PER_MEBIBYTE);
}
},
{ histogram: "PLACES_DATABASE_PAGESIZE_B",
query: "PRAGMA page_size /* PlacesDBUtils.jsm PAGESIZE_B */" },
{ histogram: "PLACES_DATABASE_SIZE_PER_PAGE_B",
query: "PRAGMA page_count",
callback: function (aDbPageCount) {
// Note that the database file size would not be meaningful for this
// calculation, because the file grows in fixed-size chunks.
let dbPageSize = probeValues.PLACES_DATABASE_PAGESIZE_B;
let placesPageCount = probeValues.PLACES_PAGES_COUNT;
return Math.round((dbPageSize * aDbPageCount) / placesPageCount);
}
},
{ histogram: "PLACES_ANNOS_BOOKMARKS_COUNT",
query: "SELECT count(*) FROM moz_items_annos" },
{ histogram: "PLACES_ANNOS_PAGES_COUNT",
query: "SELECT count(*) FROM moz_annos" },
{ histogram: "PLACES_MAINTENANCE_DAYSFROMLAST",
callback: function () {
try {
let lastMaintenance = Services.prefs.getIntPref("places.database.lastMaintenance");
let nowSeconds = parseInt(Date.now() / 1000);
return parseInt((nowSeconds - lastMaintenance) / 86400);
} catch (ex) {
return 60;
}
}
},
];
let params = {
tags_folder: PlacesUtils.tagsFolderId,
type_folder: PlacesUtils.bookmarks.TYPE_FOLDER,
type_bookmark: PlacesUtils.bookmarks.TYPE_BOOKMARK,
places_root: PlacesUtils.placesRootId
};
for (let i = 0; i < probes.length; i++) {
let probe = probes[i];
let promiseDone = new Promise((resolve, reject) => {
if (!("query" in probe)) {
resolve([probe]);
return;
}
let stmt = DBConn.createAsyncStatement(probe.query);
for (let param in params) {
if (probe.query.indexOf(":" + param) > 0) {
stmt.params[param] = params[param];
}
}
try {
stmt.executeAsync({
handleError: reject,
handleResult: function (aResultSet) {
let row = aResultSet.getNextRow();
resolve([probe, row.getResultByIndex(0)]);
},
handleCompletion: function () {}
});
} finally {
stmt.finalize();
}
});
// Report the result of the probe through Telemetry.
// The resulting promise cannot reject.
promiseDone.then(
// On success
([aProbe, aValue]) => {
let value = aValue;
try {
if ("callback" in aProbe) {
value = aProbe.callback(value);
}
probeValues[aProbe.histogram] = value;
Services.telemetry.getHistogramById(aProbe.histogram).add(value);
} catch (ex) {
Components.utils.reportError("Error adding value " + value +
" to histogram " + aProbe.histogram +
": " + ex);
}
},
// On failure
this._handleError);
}
PlacesDBUtils._executeTasks(tasks);
},
/**
* Runs a list of tasks, notifying log messages to the callback.
*
@ -1068,7 +884,6 @@ function Tasks(aTasks)
this._log = aTasks.messages;
this.callback = aTasks.callback;
this.scope = aTasks.scope;
this._telemetryStart = aTasks._telemetryStart;
}
}
}
@ -1078,7 +893,6 @@ Tasks.prototype = {
_log: [],
callback: null,
scope: null,
_telemetryStart: 0,
/**
* Adds a task to the top of the list.

4
toolkit/components/places/UnifiedComplete.js

@ -1,5 +1,4 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* vim: sw=2 ts=2 sts=2 expandtab
* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
@ -58,9 +57,6 @@ const QUERYTYPE_AUTOFILL_URL = 2;
// "comment" back into the title and the tag.
const TITLE_TAGS_SEPARATOR = " \u2013 ";
// Telemetry probes.
const TELEMETRY_1ST_RESULT = "PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS";
const TELEMETRY_6_FIRST_RESULTS = "PLACES_AUTOCOMPLETE_6_FIRST_RESULTS_TIME_MS";
// The default frecency value used when inserting matches with unknown frecency.
const FRECENCY_DEFAULT = 1000;

17
toolkit/components/places/nsPlacesAutoComplete.js

@ -81,9 +81,6 @@ const kBrowserUrlbarAutofillPref = "autoFill";
// Whether to search only typed entries.
const kBrowserUrlbarAutofillTypedPref = "autoFill.typed";
// The Telemetry histogram for urlInlineComplete query on domain
const DOMAIN_QUERY_TELEMETRY = "PLACES_AUTOCOMPLETE_URLINLINE_DOMAIN_QUERY_TIME_MS";
////////////////////////////////////////////////////////////////////////////////
//// Globals
@ -553,7 +550,6 @@ nsPlacesAutoComplete.prototype = {
queries.push(query);
// Start executing our queries.
this._telemetryStartTime = Date.now();
this._executeQueries(queries);
// Set up our persistent state for the duration of the search.
@ -810,19 +806,6 @@ nsPlacesAutoComplete.prototype = {
}
result.setSearchResult(Ci.nsIAutoCompleteResult[resultCode]);
this._listener.onSearchResult(this, result);
if (this._telemetryStartTime) {
let elapsed = Date.now() - this._telemetryStartTime;
if (elapsed > 50) {
try {
Services.telemetry
.getHistogramById("PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS")
.add(elapsed);
} catch (ex) {
Components.utils.reportError("Unable to report telemetry.");
}
}
this._telemetryStartTime = null;
}
},
/**

32
toolkit/components/places/nsPlacesExpiration.js

@ -1,5 +1,4 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* vim: sw=2 ts=2 sts=2 expandtab
* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
@ -708,22 +707,12 @@ nsPlacesExpiration.prototype = {
aError.result + "', '" + aError.message + "'");
},
// Number of expiration steps needed to reach a CLEAN status.
_telemetrySteps: 1,
handleCompletion: function PEX_handleCompletion(aReason)
{
if (aReason == Ci.mozIStorageStatementCallback.REASON_FINISHED) {
if (this._mostRecentExpiredVisitDays) {
try {
Services.telemetry
.getHistogramById("PLACES_MOST_RECENT_EXPIRED_VISIT_DAYS")
.add(this._mostRecentExpiredVisitDays);
} catch (ex) {
Components.utils.reportError("Unable to report telemetry.");
} finally {
delete this._mostRecentExpiredVisitDays;
}
delete this._mostRecentExpiredVisitDays;
}
if ("_expectedResultsCount" in this) {
@ -734,25 +723,6 @@ nsPlacesExpiration.prototype = {
this.status = this._expectedResultsCount == 0 ? STATUS.DIRTY
: STATUS.CLEAN;
// Collect or send telemetry data.
if (this.status == STATUS.DIRTY) {
this._telemetrySteps++;
}
else {
// Avoid reporting the common cases where the database is clean, or
// a single step is needed.
if (oldStatus == STATUS.DIRTY) {
try {
Services.telemetry
.getHistogramById("PLACES_EXPIRATION_STEPS_TO_CLEAN2")
.add(this._telemetrySteps);
} catch (ex) {
Components.utils.reportError("Unable to report telemetry.");
}
}
this._telemetrySteps = 1;
}
delete this._expectedResultsCount;
}

13
toolkit/components/printing/content/printUtils.js

@ -198,9 +198,6 @@ var PrintUtils = {
this._sourceBrowser = aListenerObj.getSourceBrowser();
this._originalTitle = this._sourceBrowser.contentTitle;
this._originalURL = this._sourceBrowser.currentURI.spec;