Bug 1225336 - Add telemetry about web notification display/messages. r=wchen,kitcambridge p=vladan

This commit is contained in:
Matthew Noorenberghe 2015-12-01 22:40:17 -08:00
parent 192a118ebc
commit 29d2fd424d
3 changed files with 33 additions and 0 deletions

View File

@ -1161,6 +1161,7 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
AssertIsOnMainThread();
if (!strcmp("alertdisablecallback", aTopic)) {
Telemetry::Accumulate(Telemetry::WEB_NOTIFICATION_MENU, 1);
if (XRE_IsParentProcess()) {
return Notification::RemovePermission(mPrincipal);
}
@ -1170,7 +1171,10 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
ContentChild::GetSingleton()->SendDisableNotifications(
IPC::Principal(mPrincipal));
return NS_OK;
} else if (!strcmp("alertclickcallback", aTopic)) {
Telemetry::Accumulate(Telemetry::WEB_NOTIFICATION_CLICKED, 1);
} else if (!strcmp("alertsettingscallback", aTopic)) {
Telemetry::Accumulate(Telemetry::WEB_NOTIFICATION_MENU, 2);
if (XRE_IsParentProcess()) {
return Notification::OpenSettings(mPrincipal);
}
@ -1182,6 +1186,11 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
} else if (!strcmp("alertshow", aTopic) ||
!strcmp("alertfinished", aTopic)) {
Unused << NS_WARN_IF(NS_FAILED(AdjustPushQuota(aTopic)));
if (!strcmp("alertshow", aTopic)) {
// Record notifications actually shown (e.g. don't count if DND is on).
Telemetry::Accumulate(Telemetry::WEB_NOTIFICATION_SHOWN, 1);
}
}
return mObserver->Observe(aSubject, aTopic, aData);

View File

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

View File

@ -10062,6 +10062,28 @@
"kind": "flag",
"description": "Flag activated whenever a youtube flash embed is seen during a session."
},
"WEB_NOTIFICATION_CLICKED": {
"alert_emails": ["firefox-dev@mozilla.org"],
"bug_numbers": [1225336],
"expires_in_version": "50",
"kind": "count",
"description": "Count of times a web notification was clicked"
},
"WEB_NOTIFICATION_MENU": {
"alert_emails": ["firefox-dev@mozilla.org"],
"bug_numbers": [1225336],
"expires_in_version": "50",
"kind": "enumerated",
"n_values": 5,
"description": "Count of times a contextual menu item was used from a Notification (0: DND, 1: Disable, 2: Settings)"
},
"WEB_NOTIFICATION_SHOWN": {
"alert_emails": ["firefox-dev@mozilla.org"],
"bug_numbers": [1225336],
"expires_in_version": "50",
"kind": "count",
"description": "Count of times a Notification was rendered (accounting for XUL DND). A system backend may put the notification directly into the tray if its own DND is on."
},
"WEBFONT_DOWNLOAD_TIME": {
"alert_emails": ["jdaggett@mozilla.com"],
"expires_in_version": "never",