Bug 1690390, add a flag to limit telemetry collection for notification bars to just selected changes as we only want to measure shown state for the subframe crash one, r=mstriemer

Differential Revision: https://phabricator.services.mozilla.com/D125735
This commit is contained in:
Neil Deakin 2021-09-17 09:05:00 +00:00
Родитель d3c5d06270
Коммит 9fc3821798
3 изменённых файлов: 88 добавлений и 3 удалений

Просмотреть файл

@ -91,6 +91,77 @@ add_task(async function showNotification() {
notif3.dismiss();
verifyTelemetry("dismiss notification for box 3", 1, 1, 1, 1, 1, 1, 1);
let notif4 = box1.appendNotification(
"infobar-testtwo-value",
{
label: "Additional message for tab 1",
priority: box1.PRIORITY_INFO_HIGH,
telemetry: TELEMETRY_BASE + "testone",
telemetryFilter: ["shown"],
},
[
{
label: "Button1",
},
]
);
verifyTelemetry("show first filtered notification", 2, 1, 1, 1, 1, 1, 1);
notif4.buttonContainer.lastElementChild.click();
notif4.dismiss();
verifyTelemetry("dismiss first filtered notification", 2, 1, 1, 1, 1, 1, 1);
let notif5 = box1.appendNotification(
"infobar-testtwo-value",
{
label: "Dimissed additional message for tab 1",
priority: box1.PRIORITY_INFO_HIGH,
telemetry: TELEMETRY_BASE + "testone",
telemetryFilter: ["dismissed"],
},
[
{
label: "Button1",
},
]
);
verifyTelemetry("show second filtered notification", 2, 1, 1, 1, 1, 1, 1);
notif5.buttonContainer.lastElementChild.click();
notif5.dismiss();
verifyTelemetry("dismiss second filtered notification", 2, 1, 1, 1, 2, 1, 1);
let notif6 = box1.appendNotification(
"infobar-testtwo-value",
{
label: "Dimissed additional message for tab 1",
priority: box1.PRIORITY_INFO_HIGH,
telemetry: TELEMETRY_BASE + "testone",
telemetryFilter: ["button1-pressed", "dismissed"],
},
[
{
label: "Button1",
telemetry: "button1-pressed",
},
]
);
verifyTelemetry("show third filtered notification", 2, 1, 1, 1, 2, 1, 1);
notif6.buttonContainer.lastElementChild.click();
verifyTelemetry(
"click button in third filtered notification",
2,
1,
2,
1,
2,
1,
1
);
notif6.dismiss();
verifyTelemetry("dismiss third filtered notification", 2, 1, 2, 1, 3, 1, 1);
BrowserTestUtils.removeTab(tab1);
BrowserTestUtils.removeTab(tab2);
BrowserTestUtils.removeTab(tab3);

Просмотреть файл

@ -432,6 +432,7 @@ var TabCrashHandler = {
image: TABCRASHED_ICON_URI,
priority: notificationBox.PRIORITY_INFO_MEDIUM,
telemetry: "notificationbar.crash_subframe_ui",
telemetryFilter: ["shown"],
eventCallback: eventName => {
if (eventName == "disconnected") {
let existingItem = this.notificationsMap.get(childID);

Просмотреть файл

@ -104,7 +104,11 @@
* Specifies the telemetry key to use that triggers when the notification
* is shown, dismissed and an action taken. This telemetry is a keyed scalar with keys for:
* 'shown', 'dismissed' and 'action'. If a button specifies a separate key,
* then 'action' is replaced by values specific to each button.
* then 'action' is replaced by values specific to each button. The value telemetryFilter
* can be used to filter out each type.
* telemetryFilter
* If assigned, then an array of the telemetry types to send telemetry for. If not set,
* then all telemetry is sent.
* aButtons
* Array of objects defining action buttons:
* {
@ -206,6 +210,9 @@
if (aNotification.telemetry) {
newitem.telemetry = aNotification.telemetry;
if (aNotification.telemetryFilter) {
newitem.telemetryFilter = aNotification.telemetryFilter;
}
}
newitem.priority = aNotification.priority;
@ -532,7 +539,10 @@
}
_doTelemetry(type) {
if (this.telemetry) {
if (
this.telemetry &&
(!this.telemetryFilter || this.telemetryFilter.includes(type))
) {
Services.telemetry.keyedScalarAdd(this.telemetry, type, 1);
}
}
@ -621,7 +631,10 @@
}
_doTelemetry(type) {
if (this.telemetry) {
if (
this.telemetry &&
(!this.telemetryFilter || this.telemetryFilter.includes(type))
) {
Services.telemetry.keyedScalarAdd(this.telemetry, type, 1);
}
}