Bug 1324167 - Create telemetry probes to track which preference categories are opened. r=gijs privacy-review=bsmedberg
MozReview-Commit-ID: 39UhphnkKkC
--- a/browser/components/preferences/in-content/advanced.js
+++ b/browser/components/preferences/in-content/advanced.js
@@ -114,16 +114,26 @@ var gAdvancedPane = {
* tab can be persisted between openings of the preferences window.
*/
tabSelectionChanged: function()
{
if (!this._inited)
return;
var advancedPrefs = document.getElementById("advancedPrefs");
var preference = document.getElementById("browser.preferences.advanced.selectedTabIndex");
+
+ // tabSelectionChanged gets called twice due to the selectedIndex being set
+ // by both the selectedItem and selectedPanel callstacks. This guard is used
+ // to prevent double-counting in Telemetry.
+ if (preference.valueFromPreferences != advancedPrefs.selectedIndex) {
+ Services.telemetry
+ .getHistogramById("FX_PREFERENCES_CATEGORY_OPENED")
+ .add(telemetryBucketForCategory("advanced"));
+ }
+
preference.valueFromPreferences = advancedPrefs.selectedIndex;
},
// GENERAL TAB
/*
* Preferences:
*
--- a/browser/components/preferences/in-content/preferences.js
+++ b/browser/components/preferences/in-content/preferences.js
@@ -118,16 +118,46 @@ function init_dynamic_padding() {
}
`;
let mediaStyle = document.createElementNS('http://www.w3.org/1999/xhtml', 'html:style');
mediaStyle.setAttribute('type', 'text/css');
mediaStyle.appendChild(document.createCDATASection(mediaRule));
document.documentElement.appendChild(mediaStyle);
}
+function telemetryBucketForCategory(category) {
+ switch (category) {
+ case "general":
+ case "search":
+ case "content":
+ case "applications":
+ case "privacy":
+ case "security":
+ case "sync":
+ return category;
+ case "advanced":
+ let advancedPaneTabs = document.getElementById("advancedPrefs");
+ switch (advancedPaneTabs.selectedTab.id) {
+ case "generalTab":
+ return "advancedGeneral";
+ case "dataChoicesTab":
+ return "advancedDataChoices";
+ case "networkTab":
+ return "advancedNetwork";
+ case "updateTab":
+ return "advancedUpdates";
+ case "encryptionTab":
+ return "advancedCerts";
+ }
+ // fall-through for unknown.
+ default:
+ return "unknown";
+ }
+}
+
function onHashChange() {
gotoPref();
}
function gotoPref(aCategory) {
let categories = document.getElementById("categories");
const kDefaultCategoryInternalName = categories.firstElementChild.value;
let hash = document.location.hash;
@@ -146,28 +176,32 @@ function gotoPref(aCategory) {
try {
init_category_if_required(category);
} catch (ex) {
Cu.reportError("Error initializing preference category " + category + ": " + ex);
throw ex;
}
- let newHash = internalPrefCategoryNameToFriendlyName(category);
+ let friendlyName = internalPrefCategoryNameToFriendlyName(category);
if (gLastHash || category != kDefaultCategoryInternalName) {
- document.location.hash = newHash;
+ document.location.hash = friendlyName;
}
// Need to set the gLastHash before setting categories.selectedItem since
// the categories 'select' event will re-enter the gotoPref codepath.
gLastHash = category;
categories.selectedItem = item;
window.history.replaceState(category, document.title);
search(category, "data-category");
let mainContent = document.querySelector(".main-content");
mainContent.scrollTop = 0;
+
+ Services.telemetry
+ .getHistogramById("FX_PREFERENCES_CATEGORY_OPENED")
+ .add(telemetryBucketForCategory(friendlyName));
}
function search(aQuery, aAttribute) {
let elements = document.getElementById("mainPrefPane").children;
for (let element of elements) {
let attributeValue = element.getAttribute(aAttribute);
element.hidden = (attributeValue != aQuery);
}
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -5245,16 +5245,25 @@
"bug_numbers": [1276694],
"alert_emails": ["gijs@mozilla.com"],
"expires_in_version": "53",
"keyed": true,
"kind": "boolean",
"releaseChannelCollection": "opt-out",
"description": "Whether the browser we migrated from was the browser with the most recent data. Keyed by that browser's identifier (e.g. 'ie', 'edge', 'safari', etc.)."
},
+ "FX_PREFERENCES_CATEGORY_OPENED": {
+ "bug_numbers": [1324167],
+ "alert_emails": ["jaws@mozilla.com"],
+ "expires_in_version": "56",
+ "kind": "categorical",
+ "labels": ["unknown", "general", "search", "content", "applications", "privacy", "security", "sync", "advancedGeneral", "advancedDataChoices", "advancedNetwork", "advancedUpdates", "advancedCerts"],
+ "releaseChannelCollection": "opt-out",
+ "description": "Count how often each preference category is opened."
+ },
"INPUT_EVENT_RESPONSE_MS": {
"alert_emails": ["perf-telemetry-alerts@mozilla.com"],
"bug_numbers": [1235908],
"expires_in_version": "never",
"kind": "exponential",
"high": 10000,
"n_buckets": 50,
"description": "Time (ms) from the Input event being created to the end of it being handled"