Bug 1188966 - Telemetry on the slow add-on watcher;r?blassey
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -667,62 +667,94 @@ BrowserGlue.prototype = {
}
let brandBundle = win.document.getElementById("bundle_brand");
let brandShortName = brandBundle.getString("brandShortName");
let message = win.gNavigatorBundle.getFormattedString("addonwatch.slow", [addon.name, brandShortName]);
let notificationBox = win.document.getElementById("global-notificationbox");
let notificationId = 'addon-slow:' + addonId;
let notification = notificationBox.getNotificationWithValue(notificationId);
- if(notification) {
+
+ // Monitor the response of users
+ const RESPONSE_DISABLE_ADDON = 0;
+ const RESPONSE_IGNORE_ADDON_TEMPORARILY = 1;
+ const RESPONSE_IGNORE_ADDON_PERMANENTLY = 2;
+ const RESPONSE_CLOSE_DIALOG = 3;
+
+ Services.telemetry.getHistogramById("SLOW_ADDON_WARNING_SHOWN").add();
+
+ let complete = false;
+ let start = Date.now();
+ let done = function(response) {
+ // Only report the first reason for closing.
+ if (complete) {
+ return;
+ }
+ complete = true;
+ Services.telemetry.getHistogramById("SLOW_ADDON_WARNING_USER_RESPONSE").add(response);
+ Services.telemetry.getHistogramById("SLOW_ADDON_WARNING_RESPONSE_TIME").add(Date.now() - start);
+ };
+
+ if (notification) {
notification.label = message;
} else {
let buttons = [
{
label: win.gNavigatorBundle.getFormattedString("addonwatch.disable.label", [addon.name]),
callback: function() {
addon.userDisabled = true;
- if (addon.pendingOperations != addon.PENDING_NONE) {
- let restartMessage = win.gNavigatorBundle.getFormattedString("addonwatch.restart.message", [addon.name, brandShortName]);
- let restartButton = [
- {
- label: win.gNavigatorBundle.getFormattedString("addonwatch.restart.label", [brandShortName]),
- accessKey: win.gNavigatorBundle.getString("addonwatch.restart.accesskey"),
- callback: function() {
- let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
- .getService(Ci.nsIAppStartup);
- appStartup.quit(appStartup.eForceQuit | appStartup.eRestart);
- }
+ if (addon.pendingOperations == addon.PENDING_NONE) {
+ done(RESPONSE_DISABLE_ADDON);
+ return;
+ }
+ let restartMessage = win.gNavigatorBundle.getFormattedString("addonwatch.restart.message", [addon.name, brandShortName]);
+ let restartButton = [
+ {
+ label: win.gNavigatorBundle.getFormattedString("addonwatch.restart.label", [brandShortName]),
+ accessKey: win.gNavigatorBundle.getString("addonwatch.restart.accesskey"),
+ callback: function() {
+ done(RESPONSE_DISABLE_ADDON);
+ let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
+ .getService(Ci.nsIAppStartup);
+ appStartup.quit(appStartup.eForceQuit | appStartup.eRestart);
}
- ];
- const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
- notificationBox.appendNotification(restartMessage, "restart-" + addonId, "",
- priority, restartButton);
- }
+ }
+ ];
+ const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
+ notificationBox.appendNotification(restartMessage, "restart-" + addonId, "",
+ priority, restartButton);
}
},
{
label: win.gNavigatorBundle.getString("addonwatch.ignoreSession.label"),
accessKey: win.gNavigatorBundle.getString("addonwatch.ignoreSession.accesskey"),
callback: function() {
+ done(RESPONSE_IGNORE_ADDON_TEMPORARILY);
AddonWatcher.ignoreAddonForSession(addonId);
}
},
{
label: win.gNavigatorBundle.getString("addonwatch.ignorePerm.label"),
accessKey: win.gNavigatorBundle.getString("addonwatch.ignorePerm.accesskey"),
callback: function() {
+ done(RESPONSE_IGNORE_ADDON_PERMANENTLY);
AddonWatcher.ignoreAddonPermanently(addonId);
}
},
];
const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
- notificationBox.appendNotification(message, notificationId, "",
- priority, buttons);
+ notification = notificationBox.appendNotification(
+ message, notificationId, "",
+ priority, buttons,
+ function(topic) {
+ if (topic == "removed") {
+ done(RESPONSE_CLOSE_NOTIFICATION);
+ }
+ });
}
};
AddonManager.getAddonByID(addonId, addonCallback);
},
// runs on startup, before the first command line handler is invoked
// (i.e. before the first window is opened)
_finalUIStartup: function BG__finalUIStartup() {
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -5024,16 +5024,34 @@
},
"MISBEHAVING_ADDONS_JANK_LEVEL": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 10,
"keyed": true,
"description": "Longest blocking operation performed by the add-on (log2(duration in ms), keyed by add-on, updated every 15s by default)"
},
+ "SLOW_ADDON_WARNING_SHOWN": {
+ "expires_in_version": "never",
+ "kind": "count",
+ "description": "Number of times an the Slow Add-on Warning was shown during a session."
+ },
+ "SLOW_ADDON_WARNING_USER_RESPONSE": {
+ "expires_in_version": "never",
+ "kind": "enumerated",
+ "n_values": 20,
+ "description": "User response to Slow Add-on Warning. 0: Disable add-on, 1: Ignore add-on for now, 2: Ignore add-on permanently, 3: Close notification. Other values are reserved for future uses."
+ },
+ "SLOW_ADDON_WARNING_RESPONSE_TIME": {
+ "expires_in_version": "never",
+ "kind": "exponential",
+ "high": "60000",
+ "n_buckets": 20,
+ "description": "Time before responding to Slow Add-on Warning UI (ms). Not updated if the user doesn't respond at all."
+ },
"SEARCH_COUNTS": {
"expires_in_version": "never",
"kind": "count",
"keyed": true,
"releaseChannelCollection": "opt-out",
"description": "Record the search counts for search engines"
},
"SEARCH_SERVICE_INIT_MS": {