Bug 1603545 - Add telemetry for app menu protections button r=nhnt11

Differential Revision: https://phabricator.services.mozilla.com/D58044

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Erica Wright 2020-01-09 15:57:02 +00:00
Родитель 327eb8bbbd
Коммит 1966f381fa
8 изменённых файлов: 62 добавлений и 51 удалений

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

@ -1338,6 +1338,7 @@ pref("sidebar.position_start", true);
pref("security.identitypopup.recordEventTelemetry", true);
pref("security.protectionspopup.recordEventTelemetry", true);
pref("security.app_menu.recordEventTelemetry", true);
// Block insecure active content on https pages
pref("security.mixed_content.block_active_content", true);

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

@ -1491,9 +1491,9 @@ var gProtectionsHandler = {
);
},
recordClick(object, value = null) {
recordClick(object, value = null, source = "protectionspopup") {
Services.telemetry.recordEvent(
"security.ui.protectionspopup",
`security.ui.${source}`,
"click",
object,
value

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

@ -14,6 +14,11 @@ ChromeUtils.defineModuleGetter(
"resource://gre/modules/ContentBlockingAllowList.jsm"
);
ChromeUtils.import(
"resource://testing-common/CustomizableUITestUtils.jsm",
this
);
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
@ -655,3 +660,30 @@ add_task(async function testQuickSwitchTabAfterTogglingTPSwitch() {
// Finally, clear the tracking database.
await TrackingDBService.clearAll();
});
// Test that the "Privacy Protections" button in the app menu loads about:protections
// and has appropriate telemetry
add_task(async function testProtectionsButton() {
let gCUITestUtils = new CustomizableUITestUtils(window);
await BrowserTestUtils.withNewTab(gBrowser, async function(browser) {
await gCUITestUtils.openMainMenu();
let loaded = TestUtils.waitForCondition(
() => gBrowser.currentURI.spec == "about:protections",
"Should open about:protections"
);
document.getElementById("appMenu-protection-report-button").click();
await loaded;
// When the graph is built it means any messaging has finished,
// we can close the tab.
await SpecialPowers.spawn(browser, [], async function() {
await ContentTaskUtils.waitForCondition(() => {
let bars = content.document.querySelectorAll(".graph-bar");
return bars.length;
}, "The graph has been built");
});
});
checkClickTelemetry("open_full_report", undefined, "app_menu");
});

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

@ -75,13 +75,13 @@ async function closeProtectionsPanel() {
await popuphiddenPromise;
}
function checkClickTelemetry(objectName, value) {
function checkClickTelemetry(objectName, value, source = "protectionspopup") {
let events = Services.telemetry.snapshotEvents(
Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS
).parent;
let buttonEvents = events.filter(
e =>
e[1] == "security.ui.protectionspopup" &&
e[1] == `security.ui.${source}` &&
e[2] == "click" &&
e[3] == objectName &&
e[4] === value

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

@ -1,46 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
ChromeUtils.import(
"resource://testing-common/CustomizableUITestUtils.jsm",
this
);
add_task(async function setup() {
// Hide protections cards so as not to trigger more async messaging
// when landing on the page.
SpecialPowers.pushPrefEnv({
set: [
["browser.contentblocking.report.monitor.enabled", false],
["browser.contentblocking.report.lockwise.enabled", false],
["browser.contentblocking.report.proxy.enabled", false],
],
});
});
// Test that the "Privacy Protections" button in the app menu loads about:protections
add_task(async function testProtectionsButton() {
let cuiTestUtils = new CustomizableUITestUtils(window);
await BrowserTestUtils.withNewTab(gBrowser, async function(browser) {
await cuiTestUtils.openMainMenu();
let loaded = TestUtils.waitForCondition(
() => gBrowser.currentURI.spec == "about:protections",
"Should open about:protections"
);
document.getElementById("appMenu-protection-report-button").click();
await loaded;
// When the graph is built it means any messaging has finished,
// we can close the tab.
await SpecialPowers.spawn(browser, [], async function() {
await ContentTaskUtils.waitForCondition(() => {
let bars = content.document.querySelectorAll(".graph-bar");
return bars.length;
}, "The graph has been built");
});
});
});

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

@ -1661,6 +1661,10 @@ BrowserGlue.prototype = {
"security.protectionspopup.recordEventTelemetry"
)
);
Services.telemetry.setEventRecordingEnabled(
"security.ui.app_menu",
Services.prefs.getBoolPref("security.app_menu.recordEventTelemetry")
);
let tpEnabled = Services.prefs.getBoolPref(
"privacy.trackingprotection.enabled"

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

@ -251,7 +251,7 @@
<toolbaritem>
<toolbarbutton id="appMenu-protection-report-button"
class="subviewbutton subviewbutton-iconic"
oncommand="gProtectionsHandler.openProtections();"
oncommand="gProtectionsHandler.openProtections(); gProtectionsHandler.recordClick('open_full_report', null, 'app_menu');"
data-l10n-id="appmenuitem-protection-report-tooltip">
<image id="appMenu-protection-report-icon" class="toolbarbutton-icon"/>
<label id="appMenu-protection-report-text"

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

@ -1597,6 +1597,26 @@ security.ui.protections:
extra_keys:
category: The category of protections the user is in, standard, strict or custom.
security.ui.app_menu:
click:
bug_numbers:
- 1603545
description: >
Privacy and Security click events on app menu.
objects: [
"open_full_report",
]
expiry_version: "76"
record_in_processes:
- main
release_channel_collection: opt-out
notification_emails:
- chsiang@mozilla.com
- ewright@mozilla.com
- seceng-telemetry@mozilla.com
products:
- firefox
security.ui.protectionspopup:
open:
objects: ["protections_popup"]