Bug 1918702 - Migrate telemetry events to use Glean APIs for security.ui.protections, r=chutten,frontend-codestyle-reviewers.

Differential Revision: https://phabricator.services.mozilla.com/D223616
This commit is contained in:
Florian Quèze 2024-09-27 11:48:58 +00:00
parent 8abbad6b7f
commit ce72f422e3
9 changed files with 360 additions and 70 deletions

View File

@ -9,16 +9,10 @@ export class AboutProtectionsChild extends RemotePageChild {
actorCreated() {
super.actorCreated();
this.exportFunctions(["RPMRecordTelemetryEvent"]);
this.exportFunctions(["RPMRecordGleanEvent"]);
}
RPMRecordTelemetryEvent(category, event, object, value, extra) {
return Services.telemetry.recordEvent(
category,
event,
object,
value,
extra
);
RPMRecordGleanEvent(category, name, extra) {
Glean[category]?.[name]?.record(extra);
}
}

View File

@ -36,7 +36,7 @@ export default class LockwiseCard {
// Attack link to Firefox Lockwise "How it works" page.
const lockwiseReportLink = this.doc.getElementById("lockwise-how-it-works");
lockwiseReportLink.addEventListener("click", () => {
this.doc.sendTelemetryEvent("click", "lw_about_link");
this.doc.sendTelemetryEvent("clickLwAboutLink");
});
}
@ -45,19 +45,14 @@ export default class LockwiseCard {
if (lockwiseCard.classList.contains("has-logins")) {
if (lockwiseCard.classList.contains("breached-logins")) {
this.doc.sendTelemetryEvent(
"click",
"lw_open_button",
"clickLwOpenButton",
"manage_breached_passwords"
);
} else if (lockwiseCard.classList.contains("no-breached-logins")) {
this.doc.sendTelemetryEvent(
"click",
"lw_open_button",
"manage_passwords"
);
this.doc.sendTelemetryEvent("clickLwOpenButton", "manage_passwords");
}
} else if (lockwiseCard.classList.contains("no-logins")) {
this.doc.sendTelemetryEvent("click", "lw_open_button", "save_passwords");
this.doc.sendTelemetryEvent("clickLwOpenButton", "save_passwords");
}
RPMSendAsyncMessage("OpenAboutLogins");
}

View File

@ -33,7 +33,7 @@ export default class MonitorClass {
let monitorAboutLink = this.doc.getElementById("monitor-link");
monitorAboutLink.addEventListener("click", () => {
this.doc.sendTelemetryEvent("click", "mtr_about_link");
this.doc.sendTelemetryEvent("clickMtrAboutLink");
});
const storedEmailLink = this.doc.getElementById(
@ -68,33 +68,17 @@ export default class MonitorClass {
RPMSendAsyncMessage("ClearMonitorCache");
switch (evt.currentTarget.id) {
case "monitor-partial-breaches-link":
this.doc.sendTelemetryEvent(
"click",
"mtr_report_link",
"resolve_breaches"
);
this.doc.sendTelemetryEvent("clickMtrReportLink", "resolve_breaches");
break;
case "monitor-breaches-link":
if (evt.currentTarget.classList.contains("no-breaches-resolved")) {
this.doc.sendTelemetryEvent(
"click",
"mtr_report_link",
"manage_breaches"
);
this.doc.sendTelemetryEvent("clickMtrReportLink", "manage_breaches");
} else {
this.doc.sendTelemetryEvent(
"click",
"mtr_report_link",
"view_report"
);
this.doc.sendTelemetryEvent("clickMtrReportLink", "view_report");
}
break;
case "monitor-stored-emails-link":
this.doc.sendTelemetryEvent(
"click",
"mtr_report_link",
"stored_emails"
);
this.doc.sendTelemetryEvent("clickMtrReportLink", "stored_emails");
break;
case "monitor-known-breaches-link":
const knownBreaches = this.doc.querySelector(
@ -102,16 +86,14 @@ export default class MonitorClass {
);
if (knownBreaches.classList.contains("known-resolved-breaches")) {
this.doc.sendTelemetryEvent(
"click",
"mtr_report_link",
"clickMtrReportLink",
"known_resolved_breaches"
);
} else if (
knownBreaches.classList.contains("known-unresolved-breaches")
) {
this.doc.sendTelemetryEvent(
"click",
"mtr_report_link",
"clickMtrReportLink",
"known_unresolved_breaches"
);
}
@ -124,8 +106,7 @@ export default class MonitorClass {
exposedPasswords.classList.contains("passwords-exposed-all-breaches")
) {
this.doc.sendTelemetryEvent(
"click",
"mtr_report_link",
"clickMtrReportLink",
"exposed_passwords_all_breaches"
);
} else if (
@ -134,8 +115,7 @@ export default class MonitorClass {
)
) {
this.doc.sendTelemetryEvent(
"click",
"mtr_report_link",
"clickMtrReportLink",
"exposed_passwords_unresolved_breaches"
);
}
@ -181,7 +161,7 @@ export default class MonitorClass {
"monitor-header-content-no-account"
);
signUpForMonitorLink.addEventListener("click", () => {
this.doc.sendTelemetryEvent("click", "mtr_signup_button");
this.doc.sendTelemetryEvent("clickMtrSignupButton");
});
}
}

View File

@ -10,9 +10,9 @@ import ProxyCard from "./proxy-card.mjs";
import VPNCard from "./vpn-card.mjs";
let cbCategory = RPMGetStringPref("browser.contentblocking.category");
document.sendTelemetryEvent = (action, object, value = "") => {
// eslint-disable-next-line no-undef
RPMRecordTelemetryEvent("security.ui.protections", action, object, value, {
document.sendTelemetryEvent = (eventName, value = "") => {
RPMRecordGleanEvent("securityUiProtections", eventName, {
value,
category: cbCategory,
});
};
@ -44,12 +44,12 @@ document.addEventListener("DOMContentLoaded", () => {
RPMSendQuery("FetchEntryPoint", {}).then(entrypoint => {
// Send telemetry on arriving on this page
document.sendTelemetryEvent("show", "protection_report", entrypoint);
document.sendTelemetryEvent("showProtectionReport", entrypoint);
});
// We need to send the close telemetry before unload while we still have a connection to RPM.
window.addEventListener("beforeunload", () => {
document.sendTelemetryEvent("close", "protection_report");
document.sendTelemetryEvent("closeProtectionReport");
});
let todayInMs = Date.now();
@ -69,15 +69,10 @@ document.addEventListener("DOMContentLoaded", () => {
if (evt.keyCode == evt.DOM_VK_RETURN || evt.type == "click") {
RPMSendAsyncMessage("OpenContentBlockingPreferences");
if (evt.target.id == "protection-settings") {
document.sendTelemetryEvent(
"click",
"settings_link",
"header-settings"
);
document.sendTelemetryEvent("clickSettingsLink", "header-settings");
} else if (evt.target.id == "manage-protections") {
document.sendTelemetryEvent(
"click",
"settings_link",
"clickSettingsLink",
"custom-card-settings"
);
}
@ -234,7 +229,7 @@ document.addEventListener("DOMContentLoaded", () => {
`browser.contentblocking.report.${type}.url`
);
learnMoreLink.addEventListener("click", () => {
document.sendTelemetryEvent("click", "trackers_about_link", type);
document.sendTelemetryEvent("clickTrackersAboutLink", type);
});
}
@ -402,14 +397,14 @@ document.addEventListener("DOMContentLoaded", () => {
"browser.contentblocking.report.mobile-android.url"
);
androidMobileAppLink.addEventListener("click", () => {
document.sendTelemetryEvent("click", "mobile_app_link", "android");
document.sendTelemetryEvent("clickMobileAppLink", "android");
});
let iosMobileAppLink = document.getElementById("ios-mobile-inline-link");
iosMobileAppLink.href = RPMGetStringPref(
"browser.contentblocking.report.mobile-ios.url"
);
iosMobileAppLink.addEventListener("click", () => {
document.sendTelemetryEvent("click", "mobile_app_link", "ios");
document.sendTelemetryEvent("clickMobileAppLink", "ios");
});
let lockwiseEnabled = RPMGetBoolPref(

View File

@ -22,7 +22,7 @@ export default class VPNCard {
);
vpnLink.addEventListener("click", () => {
this.doc.sendTelemetryEvent("click", "vpn_card_link");
this.doc.sendTelemetryEvent("clickVpnCardLink");
});
let androidVPNAppLink = document.getElementById(
"vpn-google-playstore-link"
@ -31,25 +31,25 @@ export default class VPNCard {
"browser.contentblocking.report.vpn-android.url"
);
androidVPNAppLink.addEventListener("click", () => {
document.sendTelemetryEvent("click", "vpn_app_link_android");
document.sendTelemetryEvent("clickVpnAppLinkAndroid");
});
let iosVPNAppLink = document.getElementById("vpn-app-store-link");
iosVPNAppLink.href = RPMGetStringPref(
"browser.contentblocking.report.vpn-ios.url"
);
iosVPNAppLink.addEventListener("click", () => {
document.sendTelemetryEvent("click", "vpn_app_link_ios");
document.sendTelemetryEvent("clickVpnAppLinkIos");
});
const vpnBanner = this.doc.querySelector(".vpn-banner");
const exitIcon = vpnBanner.querySelector(".exit-icon");
vpnBannerLink.addEventListener("click", () => {
this.doc.sendTelemetryEvent("click", "vpn_banner_link");
this.doc.sendTelemetryEvent("clickVpnBannerLink");
});
// User has closed the vpn banner, hide it.
exitIcon.addEventListener("click", () => {
vpnBanner.classList.add("hidden");
this.doc.sendTelemetryEvent("click", "vpn_banner_close");
this.doc.sendTelemetryEvent("clickVpnBannerClose");
});
this.showVPNCard();
@ -96,7 +96,7 @@ export default class VPNCard {
const vpnBanner = this.doc.querySelector(".vpn-banner");
vpnBanner.classList.remove("hidden");
this.doc.sendTelemetryEvent("show", "vpn_banner");
this.doc.sendTelemetryEvent("showVpnBanner");
// VPN banner only shows on the first visit, flip a pref so it does not show again.
RPMSetPref("browser.contentblocking.report.hide_vpn_banner", true);
}

View File

@ -0,0 +1,324 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Adding a new metric? We have docs for that!
# https://firefox-source-docs.mozilla.org/toolkit/components/glean/user/new_definitions_file.html
---
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
$tags:
- 'Firefox :: Protections UI'
security.ui.protections:
show_protection_report:
type: event
description: >
User arrived on the protection report. This also includes a 'value'
attribute which defaults to 'direct' or will be the value that a
referring website addds to the url. This also indicates if the vpn
banner has been seen.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.show#protection_report.
bugs: &security_ui_protections_show_bugs
- https://bugzil.la/1557050
- https://bugzil.la/1610897
- https://bugzil.la/1643428
- https://bugzil.la/1650468
- https://bugzil.la/1661756
- https://bugzil.la/1678201
- https://bugzil.la/1739287
- https://bugzil.la/1787249
data_reviews: &security_ui_protections_show_data_reviews
- https://bugzil.la/1557050
- https://bugzil.la/1610897
- https://bugzil.la/1643428
- https://bugzil.la/1650468
- https://bugzil.la/1661756
- https://bugzil.la/1678201
- https://bugzil.la/1739287
- https://bugzil.la/1787249
notification_emails: &security_ui_protections_show_emails
- pbz@mozilla.com
- seceng-telemetry@mozilla.com
expires: never
extra_keys: &security_ui_protections_show_extra
value:
description: >
The `value` of the event. Mirrors to the Legacy Telemetry
event's `value` parameter.
type: string
category:
description: >
The category of protections the user is in, standard, strict or custom.
type: string
telemetry_mirror: SecurityUiProtections_Show_ProtectionReport
show_vpn_banner:
type: event
description: >
User arrived on the protection report. This also includes a 'value'
attribute which defaults to 'direct' or will be the value that a
referring website addds to the url. This also indicates if the vpn
banner has been seen.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.show#vpn_banner.
bugs: *security_ui_protections_show_bugs
data_reviews: *security_ui_protections_show_data_reviews
notification_emails: *security_ui_protections_show_emails
expires: never
extra_keys: *security_ui_protections_show_extra
telemetry_mirror: SecurityUiProtections_Show_VpnBanner
close_protection_report:
type: event
description: >
User closed on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.close#protection_report.
bugs:
- https://bugzil.la/1557050
- https://bugzil.la/1610897
- https://bugzil.la/1612091
- https://bugzil.la/1643428
- https://bugzil.la/1678201
- https://bugzil.la/1739287
- https://bugzil.la/1787249
data_reviews:
- https://bugzil.la/1557050
- https://bugzil.la/1610897
- https://bugzil.la/1612091
- https://bugzil.la/1643428
- https://bugzil.la/1678201
- https://bugzil.la/1739287
- https://bugzil.la/1787249
notification_emails:
- pbz@mozilla.com
- seceng-telemetry@mozilla.com
expires: never
extra_keys:
value:
description: >
The `value` of the event. Mirrors to the Legacy Telemetry
event's `value` parameter.
type: string
category:
description: >
The category of protections the user is in, standard, strict or custom.
type: string
telemetry_mirror: SecurityUiProtections_Close_ProtectionReport
click_lw_open_button:
type: event
description: >
User interaction by click events on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.click#lw_open_button.
bugs: &security_ui_protections_click_bugs
- https://bugzil.la/1557050
- https://bugzil.la/1572825
- https://bugzil.la/1610897
- https://bugzil.la/1612088
- https://bugzil.la/1612091
- https://bugzil.la/1637615
- https://bugzil.la/1643428
- https://bugzil.la/1661756
- https://bugzil.la/1678201
- https://bugzil.la/1739287
- https://bugzil.la/1787249
data_reviews: &security_ui_protections_click_data_reviews
- https://bugzil.la/1557050
- https://bugzil.la/1572825
- https://bugzil.la/1610897
- https://bugzil.la/1612088
- https://bugzil.la/1612091
- https://bugzil.la/1637615
- https://bugzil.la/1643428
- https://bugzil.la/1661756
- https://bugzil.la/1678201
- https://bugzil.la/1739287
- https://bugzil.la/1787249
notification_emails: &security_ui_protections_click_emails
- pbz@mozilla.com
- seceng-telemetry@mozilla.com
expires: never
extra_keys: &security_ui_protections_click_extra
value:
description: >
The `value` of the event. Mirrors to the Legacy Telemetry
event's `value` parameter.
type: string
category:
description: >
The category of protections the user is in, standard, strict or custom.
type: string
telemetry_mirror: SecurityUiProtections_Click_LwOpenButton
click_lw_sync_link:
type: event
description: >
User interaction by click events on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.click#lw_sync_link.
bugs: *security_ui_protections_click_bugs
data_reviews: *security_ui_protections_click_data_reviews
notification_emails: *security_ui_protections_click_emails
expires: never
extra_keys: *security_ui_protections_click_extra
telemetry_mirror: SecurityUiProtections_Click_LwSyncLink
click_lw_about_link:
type: event
description: >
User interaction by click events on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.click#lw_about_link.
bugs: *security_ui_protections_click_bugs
data_reviews: *security_ui_protections_click_data_reviews
notification_emails: *security_ui_protections_click_emails
expires: never
extra_keys: *security_ui_protections_click_extra
telemetry_mirror: SecurityUiProtections_Click_LwAboutLink
click_mtr_about_link:
type: event
description: >
User interaction by click events on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.click#mtr_about_link.
bugs: *security_ui_protections_click_bugs
data_reviews: *security_ui_protections_click_data_reviews
notification_emails: *security_ui_protections_click_emails
expires: never
extra_keys: *security_ui_protections_click_extra
telemetry_mirror: SecurityUiProtections_Click_MtrAboutLink
click_mtr_report_link:
type: event
description: >
User interaction by click events on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.click#mtr_report_link.
bugs: *security_ui_protections_click_bugs
data_reviews: *security_ui_protections_click_data_reviews
notification_emails: *security_ui_protections_click_emails
expires: never
extra_keys: *security_ui_protections_click_extra
telemetry_mirror: SecurityUiProtections_Click_MtrReportLink
click_mtr_signup_button:
type: event
description: >
User interaction by click events on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.click#mtr_signup_button.
bugs: *security_ui_protections_click_bugs
data_reviews: *security_ui_protections_click_data_reviews
notification_emails: *security_ui_protections_click_emails
expires: never
extra_keys: *security_ui_protections_click_extra
telemetry_mirror: SecurityUiProtections_Click_MtrSignupButton
click_trackers_about_link:
type: event
description: >
User interaction by click events on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.click#trackers_about_link.
bugs: *security_ui_protections_click_bugs
data_reviews: *security_ui_protections_click_data_reviews
notification_emails: *security_ui_protections_click_emails
expires: never
extra_keys: *security_ui_protections_click_extra
telemetry_mirror: SecurityUiProtections_Click_TrackersAboutLink
click_mobile_app_link:
type: event
description: >
User interaction by click events on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.click#mobile_app_link.
bugs: *security_ui_protections_click_bugs
data_reviews: *security_ui_protections_click_data_reviews
notification_emails: *security_ui_protections_click_emails
expires: never
extra_keys: *security_ui_protections_click_extra
telemetry_mirror: SecurityUiProtections_Click_MobileAppLink
click_settings_link:
type: event
description: >
User interaction by click events on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.click#settings_link.
bugs: *security_ui_protections_click_bugs
data_reviews: *security_ui_protections_click_data_reviews
notification_emails: *security_ui_protections_click_emails
expires: never
extra_keys: *security_ui_protections_click_extra
telemetry_mirror: SecurityUiProtections_Click_SettingsLink
click_vpn_banner_link:
type: event
description: >
User interaction by click events on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.click#vpn_banner_link.
bugs: *security_ui_protections_click_bugs
data_reviews: *security_ui_protections_click_data_reviews
notification_emails: *security_ui_protections_click_emails
expires: never
extra_keys: *security_ui_protections_click_extra
telemetry_mirror: SecurityUiProtections_Click_VpnBannerLink
click_vpn_banner_close:
type: event
description: >
User interaction by click events on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.click#vpn_banner_close.
bugs: *security_ui_protections_click_bugs
data_reviews: *security_ui_protections_click_data_reviews
notification_emails: *security_ui_protections_click_emails
expires: never
extra_keys: *security_ui_protections_click_extra
telemetry_mirror: SecurityUiProtections_Click_VpnBannerClose
click_vpn_card_link:
type: event
description: >
User interaction by click events on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.click#vpn_card_link.
bugs: *security_ui_protections_click_bugs
data_reviews: *security_ui_protections_click_data_reviews
notification_emails: *security_ui_protections_click_emails
expires: never
extra_keys: *security_ui_protections_click_extra
telemetry_mirror: SecurityUiProtections_Click_VpnCardLink
click_vpn_app_link_android:
type: event
description: >
User interaction by click events on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.click#vpn_app_link_android.
bugs: *security_ui_protections_click_bugs
data_reviews: *security_ui_protections_click_data_reviews
notification_emails: *security_ui_protections_click_emails
expires: never
extra_keys: *security_ui_protections_click_extra
telemetry_mirror: SecurityUiProtections_Click_VpnAppLinkAndroid
click_vpn_app_link_ios:
type: event
description: >
User interaction by click events on the protection report.
This event was generated to correspond to the Legacy Telemetry event
security.ui.protections.click#vpn_app_link_ios.
bugs: *security_ui_protections_click_bugs
data_reviews: *security_ui_protections_click_data_reviews
notification_emails: *security_ui_protections_click_emails
expires: never
extra_keys: *security_ui_protections_click_extra
telemetry_mirror: SecurityUiProtections_Click_VpnAppLinkIos

View File

@ -79,6 +79,7 @@ firefox_desktop_metrics = [
"browser/components/pocket/metrics.yaml",
"browser/components/preferences/metrics.yaml",
"browser/components/privatebrowsing/metrics.yaml",
"browser/components/protections/metrics.yaml",
"browser/components/protocolhandler/metrics.yaml",
"browser/components/screenshots/metrics.yaml",
"browser/components/search/metrics.yaml",

View File

@ -248,7 +248,7 @@ export let RemotePageAccessManager = {
"browser.contentblocking.report.fingerprinter.url",
"browser.contentblocking.report.cryptominer.url",
],
RPMRecordTelemetryEvent: ["*"],
RPMRecordGleanEvent: ["securityUiProtections"],
},
"about:shoppingsidebar": {
RPMSetPref: [

View File

@ -27,6 +27,7 @@ module.exports = {
RPMSendAsyncMessage: false,
RPMSendQuery: false,
RPMAddMessageListener: false,
RPMRecordGleanEvent: false,
RPMRecordTelemetryEvent: false,
RPMCheckAlternateHostAvailable: false,
RPMAddToHistogram: false,