зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1188966 - Telemetry on the slow add-on watcher. r=blassey
This commit is contained in:
Родитель
fe38a9ae38
Коммит
b12b2c3ccf
|
@ -694,7 +694,33 @@ BrowserGlue.prototype = {
|
|||
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 STATE_WARNING_DISPLAYED = 0;
|
||||
const STATE_USER_PICKED_DISABLE = 1;
|
||||
const STATE_USER_PICKED_IGNORE_FOR_NOW = 2;
|
||||
const STATE_USER_PICKED_IGNORE_FOREVER = 3;
|
||||
const STATE_USER_CLOSED_NOTIFICATION = 4;
|
||||
|
||||
let update = function(response) {
|
||||
Services.telemetry.getHistogramById("SLOW_ADDON_WARNING_STATES").add(response);
|
||||
}
|
||||
|
||||
let complete = false;
|
||||
let start = Date.now();
|
||||
let done = function(response) {
|
||||
// Only report the first reason for closing.
|
||||
if (complete) {
|
||||
return;
|
||||
}
|
||||
complete = true;
|
||||
update(response);
|
||||
Services.telemetry.getHistogramById("SLOW_ADDON_WARNING_RESPONSE_TIME").add(Date.now() - start);
|
||||
};
|
||||
|
||||
update(STATE_WARNING_DISPLAYED);
|
||||
|
||||
if (notification) {
|
||||
notification.label = message;
|
||||
} else {
|
||||
let buttons = [
|
||||
|
@ -702,30 +728,33 @@ BrowserGlue.prototype = {
|
|||
label: win.gNavigatorBundle.getFormattedString("addonwatch.disable.label", [addon.name]),
|
||||
accessKey: "", // workaround for bug 1192901
|
||||
callback: function() {
|
||||
done(STATE_USER_PICKED_DISABLE);
|
||||
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);
|
||||
}
|
||||
}
|
||||
];
|
||||
const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
|
||||
notificationBox.appendNotification(restartMessage, "restart-" + addonId, "",
|
||||
priority, restartButton);
|
||||
if (addon.pendingOperations == addon.PENDING_NONE) {
|
||||
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() {
|
||||
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);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: win.gNavigatorBundle.getString("addonwatch.ignoreSession.label"),
|
||||
accessKey: win.gNavigatorBundle.getString("addonwatch.ignoreSession.accesskey"),
|
||||
callback: function() {
|
||||
done(STATE_USER_PICKED_IGNORE_FOR_NOW);
|
||||
AddonWatcher.ignoreAddonForSession(addonId);
|
||||
}
|
||||
},
|
||||
|
@ -733,14 +762,25 @@ BrowserGlue.prototype = {
|
|||
label: win.gNavigatorBundle.getString("addonwatch.ignorePerm.label"),
|
||||
accessKey: win.gNavigatorBundle.getString("addonwatch.ignorePerm.accesskey"),
|
||||
callback: function() {
|
||||
done(STATE_USER_PICKED_IGNORE_FOREVER);
|
||||
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") {
|
||||
// Other callbacks are called before this one and only the first
|
||||
// call to `done` is taken into account, so if this call to `done`
|
||||
// gets through, this means that the user has closed the notification
|
||||
// manually.
|
||||
done(STATE_USER_CLOSED_NOTIFICATION);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
AddonManager.getAddonByID(addonId, addonCallback);
|
||||
|
|
|
@ -5118,6 +5118,19 @@
|
|||
"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_STATES": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "enumerated",
|
||||
"n_values": 20,
|
||||
"description": "The states the Slow Add-on Warning goes through. 0: Displayed the warning. 1: User clicked on 'Disable add-on'. 2: User clicked 'Ignore add-on for now'. 3: User clicked 'Ignore add-on permanently'. 4: User closed notification. Other values are reserved for future uses."
|
||||
},
|
||||
"SLOW_ADDON_WARNING_RESPONSE_TIME": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"high": "86400000",
|
||||
"n_buckets": 30,
|
||||
"description": "Time elapsed between 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",
|
||||
|
|
Загрузка…
Ссылка в новой задаче