Bug 1918702 - Migrate telemetry events to use Glean APIs for security.ui.protectionspopup, r=chutten.

Differential Revision: https://phabricator.services.mozilla.com/D223606
This commit is contained in:
Florian Quèze 2024-09-27 11:48:57 +00:00
parent 81b4f18bb3
commit 8abbad6b7f
2 changed files with 286 additions and 49 deletions

View File

@ -1356,10 +1356,10 @@ let cookieBannerHandling = new (class {
this._cookieBannerSection.toggleAttribute("hasException");
if (hasException) {
await this.#disableCookieBannerHandling();
gProtectionsHandler.recordClick("cookieb_toggle_off");
Glean.securityUiProtectionspopup.clickCookiebToggleOff.record();
} else {
this.#enableCookieBannerHandling();
gProtectionsHandler.recordClick("cookieb_toggle_on");
Glean.securityUiProtectionspopup.clickCookiebToggleOn.record();
}
gProtectionsHandler._hidePopup();
gBrowser.reloadTab(gBrowser.selectedTab);
@ -1718,15 +1718,6 @@ var gProtectionsHandler = {
);
},
recordClick(object, value = null, source = "protectionspopup") {
Services.telemetry.recordEvent(
`security.ui.${source}`,
"click",
object,
value
);
},
shieldHistogramAdd(value) {
if (PrivateBrowsingUtils.isWindowPrivate(window)) {
return;
@ -1774,11 +1765,7 @@ var gProtectionsHandler = {
this._insertProtectionsPanelInfoMessage(event);
if (!event.target.hasAttribute("toast")) {
Services.telemetry.recordEvent(
"security.ui.protectionspopup",
"open",
"protections_popup"
);
Glean.securityUiProtectionspopup.openProtectionsPopup.record();
}
ReportBrokenSite.updateParentMenu(event);
@ -2064,55 +2051,65 @@ var gProtectionsHandler = {
switch (event.target.id) {
case "protections-popup-category-trackers":
gProtectionsHandler.showTrackersSubview(event);
gProtectionsHandler.recordClick("trackers");
Glean.securityUiProtectionspopup.clickTrackers.record();
break;
case "protections-popup-category-socialblock":
gProtectionsHandler.showSocialblockerSubview(event);
gProtectionsHandler.recordClick("social");
Glean.securityUiProtectionspopup.clickSocial.record();
break;
case "protections-popup-category-cookies":
gProtectionsHandler.showCookiesSubview(event);
gProtectionsHandler.recordClick("cookies");
Glean.securityUiProtectionspopup.clickCookies.record();
break;
case "protections-popup-category-cryptominers":
gProtectionsHandler.showCryptominersSubview(event);
gProtectionsHandler.recordClick("cryptominers");
Glean.securityUiProtectionspopup.clickCryptominers.record();
return;
case "protections-popup-category-fingerprinters":
gProtectionsHandler.showFingerprintersSubview(event);
gProtectionsHandler.recordClick("fingerprinters");
Glean.securityUiProtectionspopup.clickFingerprinters.record();
break;
case "protections-popup-settings-button":
gProtectionsHandler.openPreferences();
gProtectionsHandler.recordClick("settings");
Glean.securityUiProtectionspopup.clickSettings.record();
break;
case "protections-popup-show-report-button":
gProtectionsHandler.openProtections(true);
gProtectionsHandler.recordClick("full_report");
Glean.securityUiProtectionspopup.clickFullReport.record();
break;
case "protections-popup-milestones-content":
gProtectionsHandler.openProtections(true);
gProtectionsHandler.recordClick("milestone_message");
Glean.securityUiProtectionspopup.clickMilestoneMessage.record();
break;
case "protections-popup-trackersView-settings-button":
gProtectionsHandler.openPreferences();
gProtectionsHandler.recordClick("subview_settings", "trackers");
Glean.securityUiProtectionspopup.clickSubviewSettings.record({
value: "trackers",
});
break;
case "protections-popup-socialblockView-settings-button":
gProtectionsHandler.openPreferences();
gProtectionsHandler.recordClick("subview_settings", "social");
Glean.securityUiProtectionspopup.clickSubviewSettings.record({
value: "social",
});
break;
case "protections-popup-cookiesView-settings-button":
gProtectionsHandler.openPreferences();
gProtectionsHandler.recordClick("subview_settings", "cookies");
Glean.securityUiProtectionspopup.clickSubviewSettings.record({
value: "cookies",
});
break;
case "protections-popup-fingerprintersView-settings-button":
gProtectionsHandler.openPreferences();
gProtectionsHandler.recordClick("subview_settings", "fingerprinters");
Glean.securityUiProtectionspopup.clickSubviewSettings.record({
value: "fingerprinters",
});
break;
case "protections-popup-cryptominersView-settings-button":
gProtectionsHandler.openPreferences();
gProtectionsHandler.recordClick("subview_settings", "cryptominers");
Glean.securityUiProtectionspopup.clickSubviewSettings.record({
value: "cryptominers",
});
break;
case "protections-popup-cookieBannerView-cancel":
gProtectionsHandler._protectionsPopupMultiView.goBack();
@ -2350,10 +2347,10 @@ var gProtectionsHandler = {
if (newExceptionState) {
this.disableForCurrentPage(false);
this.recordClick("etp_toggle_off");
Glean.securityUiProtectionspopup.clickEtpToggleOff.record();
} else {
this.enableForCurrentPage(false);
this.recordClick("etp_toggle_on");
Glean.securityUiProtectionspopup.clickEtpToggleOn.record();
}
// We need to flush the TP state change immediately without waiting the
@ -2560,19 +2557,6 @@ var gProtectionsHandler = {
}
},
_sendUserEventTelemetry(event, value = null, options = {}) {
// Only send telemetry for non private browsing windows
if (!PrivateBrowsingUtils.isWindowPrivate(window)) {
Services.telemetry.recordEvent(
"security.ui.protectionspopup",
event,
"protectionspopup_cfr",
value,
options
);
}
},
/**
* Dispatch the action defined in the message and user telemetry event.
*/
@ -2596,9 +2580,13 @@ var gProtectionsHandler = {
window.browser
);
this._sendUserEventTelemetry("click", "learn_more_link", {
message: message.id,
});
// Only send telemetry for non private browsing windows
if (!PrivateBrowsingUtils.isWindowPrivate(window)) {
Glean.securityUiProtectionspopup.clickProtectionspopupCfr.record({
value: "learn_more_link",
message: message.id,
});
}
},
/**
@ -2654,8 +2642,13 @@ var gProtectionsHandler = {
learnMoreLink.disabled = !learnMoreLink.disabled;
}
// If the message panel is opened, send impression telemetry
if (panelContainer.hasAttribute("infoMessageShowing")) {
this._sendUserEventTelemetry("open", "impression", {
// if we are in a non private browsing window.
if (
panelContainer.hasAttribute("infoMessageShowing") &&
!PrivateBrowsingUtils.isWindowPrivate(window)
) {
Glean.securityUiProtectionspopup.openProtectionspopupCfr.record({
value: "impression",
message: message.id,
});
}

View File

@ -90,3 +90,247 @@ privacy.sanitize:
- pbz@mozilla.com
expires:
134
security.ui.protectionspopup:
open_protections_popup:
type: event
description: >
How many times the protections panel was opened.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.open#protections_popup.
bugs: &security_ui_protectionspopup_open_bugs
- https://bugzil.la/1560327
- https://bugzil.la/1607488
- https://bugzil.la/1643428
- https://bugzil.la/1678201
- https://bugzil.la/1739287
- https://bugzil.la/1787249
data_reviews: &security_ui_protectionspopup_open_data_reviews
- https://bugzil.la/1560327
- https://bugzil.la/1607488
- https://bugzil.la/1643428
- https://bugzil.la/1678201
- https://bugzil.la/1739287
- https://bugzil.la/1787249
notification_emails: &security_ui_protectionspopup_open_emails
- pbz@mozilla.com
- seceng-telemetry@mozilla.com
expires: never
telemetry_mirror: SecurityUiProtectionspopup_Open_ProtectionsPopup
open_protectionspopup_cfr:
type: event
description: >
How many times the protections panel was opened.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.open#protectionspopup_cfr.
bugs: *security_ui_protectionspopup_open_bugs
data_reviews: *security_ui_protectionspopup_open_data_reviews
notification_emails: *security_ui_protectionspopup_open_emails
expires: never
extra_keys: &security_ui_protectionspopup_open_extra
value:
description: >
The `value` of the event. Mirrors to the Legacy Telemetry
event's `value` parameter.
type: string
message:
description: >
For protectionspopup_cfr, the message ID.
type: string
telemetry_mirror: SecurityUiProtectionspopup_Open_ProtectionspopupCfr
click_etp_toggle_on:
type: event
description: >
User interaction by click events in the protections panel.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.click#etp_toggle_on.
bugs: &security_ui_protectionspopup_click_bugs
- https://bugzil.la/1560327
- https://bugzil.la/1602015
- https://bugzil.la/1607488
- https://bugzil.la/1643428
- https://bugzil.la/1678201
- https://bugzil.la/1739287
- https://bugzil.la/1787249
- https://bugzil.la/1798669
data_reviews: &security_ui_protectionspopup_click_data_reviews
- https://bugzil.la/1560327
- https://bugzil.la/1602015
- https://bugzil.la/1607488
- https://bugzil.la/1643428
- https://bugzil.la/1678201
- https://bugzil.la/1739287
- https://bugzil.la/1787249
- https://bugzil.la/1798669
notification_emails: &security_ui_protectionspopup_click_emails
- pbz@mozilla.com
- tihuang@mozilla.com
- seceng-telemetry@mozilla.com
expires: never
telemetry_mirror: SecurityUiProtectionspopup_Click_EtpToggleOn
click_etp_toggle_off:
type: event
description: >
User interaction by click events in the protections panel.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.click#etp_toggle_off.
bugs: *security_ui_protectionspopup_click_bugs
data_reviews: *security_ui_protectionspopup_click_data_reviews
notification_emails: *security_ui_protectionspopup_click_emails
expires: never
telemetry_mirror: SecurityUiProtectionspopup_Click_EtpToggleOff
click_social:
type: event
description: >
User interaction by click events in the protections panel.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.click#social.
bugs: *security_ui_protectionspopup_click_bugs
data_reviews: *security_ui_protectionspopup_click_data_reviews
notification_emails: *security_ui_protectionspopup_click_emails
expires: never
telemetry_mirror: SecurityUiProtectionspopup_Click_Social
click_cookies:
type: event
description: >
User interaction by click events in the protections panel.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.click#cookies.
bugs: *security_ui_protectionspopup_click_bugs
data_reviews: *security_ui_protectionspopup_click_data_reviews
notification_emails: *security_ui_protectionspopup_click_emails
expires: never
telemetry_mirror: SecurityUiProtectionspopup_Click_Cookies
click_trackers:
type: event
description: >
User interaction by click events in the protections panel.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.click#trackers.
bugs: *security_ui_protectionspopup_click_bugs
data_reviews: *security_ui_protectionspopup_click_data_reviews
notification_emails: *security_ui_protectionspopup_click_emails
expires: never
telemetry_mirror: SecurityUiProtectionspopup_Click_Trackers
click_fingerprinters:
type: event
description: >
User interaction by click events in the protections panel.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.click#fingerprinters.
bugs: *security_ui_protectionspopup_click_bugs
data_reviews: *security_ui_protectionspopup_click_data_reviews
notification_emails: *security_ui_protectionspopup_click_emails
expires: never
telemetry_mirror: SecurityUiProtectionspopup_Click_Fingerprinters
click_cryptominers:
type: event
description: >
User interaction by click events in the protections panel.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.click#cryptominers.
bugs: *security_ui_protectionspopup_click_bugs
data_reviews: *security_ui_protectionspopup_click_data_reviews
notification_emails: *security_ui_protectionspopup_click_emails
expires: never
telemetry_mirror: SecurityUiProtectionspopup_Click_Cryptominers
click_subview_settings:
type: event
description: >
User interaction by click events in the protections panel.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.click#subview_settings.
bugs: *security_ui_protectionspopup_click_bugs
data_reviews: *security_ui_protectionspopup_click_data_reviews
notification_emails: *security_ui_protectionspopup_click_emails
expires: never
extra_keys:
value:
description: >
The `value` of the event. Mirrors to the Legacy Telemetry
event's `value` parameter.
type: string
telemetry_mirror: SecurityUiProtectionspopup_Click_SubviewSettings
click_settings:
type: event
description: >
User interaction by click events in the protections panel.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.click#settings.
bugs: *security_ui_protectionspopup_click_bugs
data_reviews: *security_ui_protectionspopup_click_data_reviews
notification_emails: *security_ui_protectionspopup_click_emails
expires: never
telemetry_mirror: SecurityUiProtectionspopup_Click_Settings
click_full_report:
type: event
description: >
User interaction by click events in the protections panel.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.click#full_report.
bugs: *security_ui_protectionspopup_click_bugs
data_reviews: *security_ui_protectionspopup_click_data_reviews
notification_emails: *security_ui_protectionspopup_click_emails
expires: never
telemetry_mirror: SecurityUiProtectionspopup_Click_FullReport
click_milestone_message:
type: event
description: >
User interaction by click events in the protections panel.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.click#milestone_message.
bugs: *security_ui_protectionspopup_click_bugs
data_reviews: *security_ui_protectionspopup_click_data_reviews
notification_emails: *security_ui_protectionspopup_click_emails
expires: never
telemetry_mirror: SecurityUiProtectionspopup_Click_MilestoneMessage
click_cookieb_toggle_on:
type: event
description: >
User interaction by click events in the protections panel.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.click#cookieb_toggle_on.
bugs: *security_ui_protectionspopup_click_bugs
data_reviews: *security_ui_protectionspopup_click_data_reviews
notification_emails: *security_ui_protectionspopup_click_emails
expires: never
telemetry_mirror: SecurityUiProtectionspopup_Click_CookiebToggleOn
click_cookieb_toggle_off:
type: event
description: >
User interaction by click events in the protections panel.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.click#cookieb_toggle_off.
bugs: *security_ui_protectionspopup_click_bugs
data_reviews: *security_ui_protectionspopup_click_data_reviews
notification_emails: *security_ui_protectionspopup_click_emails
expires: never
telemetry_mirror: SecurityUiProtectionspopup_Click_CookiebToggleOff
click_protectionspopup_cfr:
type: event
description: >
User interaction by click events in the protections panel.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protectionspopup.click#protectionspopup_cfr.
bugs: *security_ui_protectionspopup_click_bugs
data_reviews: *security_ui_protectionspopup_click_data_reviews
notification_emails: *security_ui_protectionspopup_click_emails
expires: never
extra_keys: *security_ui_protectionspopup_open_extra
telemetry_mirror: SecurityUiProtectionspopup_Click_ProtectionspopupCfr