Bug 1560327 - [Protections Panel] Implement telemetry event recording. r=johannh

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nihanth Subramanya 2019-08-20 13:49:28 +00:00
Родитель 5ac210ec83
Коммит 50145120e7
6 изменённых файлов: 160 добавлений и 16 удалений

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

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

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

@ -1549,6 +1549,15 @@ var gProtectionsHandler = {
);
},
recordClick(object, value = null) {
Services.telemetry.recordEvent(
"security.ui.protectionspopup",
"click",
object,
value
);
},
shieldHistogramAdd(value) {
if (PrivateBrowsingUtils.isWindowPrivate(window)) {
return;
@ -1598,6 +1607,14 @@ var gProtectionsHandler = {
// Insert the info message if needed. This will be shown once and then
// remain collapsed.
ToolbarPanelHub.insertProtectionPanelMessage(event);
if (!event.target.hasAttribute("toast")) {
Services.telemetry.recordEvent(
"security.ui.protectionspopup",
"open",
"protections_popup"
);
}
}
},
@ -1965,8 +1982,10 @@ var gProtectionsHandler = {
if (newExceptionState) {
this.disableForCurrentPage();
this.recordClick("etp_toggle_off");
} else {
this.enableForCurrentPage();
this.recordClick("etp_toggle_on");
}
delete this._TPSwitchCommanding;

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

@ -9,10 +9,23 @@ ChromeUtils.defineModuleGetter(
"resource://gre/modules/ContentBlockingAllowList.jsm"
);
function checkClickTelemetry(objectName, value) {
let events = Services.telemetry.snapshotEvents(
Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS
).parent;
let buttonEvents = events.filter(
e =>
e[1] == "security.ui.protectionspopup" &&
e[2] == "click" &&
e[3] == objectName &&
(!value || e[4] == value)
);
is(buttonEvents.length, 1, `recorded ${objectName} telemetry event`);
}
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.protections_panel.enabled", true],
// Set the auto hide timing to 100ms for blocking the test less.
["browser.protections_panel.toast.timeout", 100],
// Hide protections cards so as not to trigger more async messaging
@ -22,6 +35,12 @@ add_task(async function setup() {
["browser.contentblocking.report.proxy.enabled", false],
],
});
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
registerCleanupFunction(() => {
Services.telemetry.canRecordExtended = oldCanRecord;
});
});
add_task(async function testToggleSwitch() {
@ -30,6 +49,16 @@ add_task(async function testToggleSwitch() {
"https://example.com"
);
await openProtectionsPanel();
let events = Services.telemetry.snapshotEvents(
Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS
).parent;
let buttonEvents = events.filter(
e =>
e[1] == "security.ui.protectionspopup" &&
e[2] == "open" &&
e[3] == "protections_popup"
);
is(buttonEvents.length, 1, "recorded telemetry for opening the popup");
// Check the visibility of the "Site not working?" link.
ok(
@ -59,6 +88,7 @@ add_task(async function testToggleSwitch() {
);
await popuphiddenPromise;
checkClickTelemetry("etp_toggle_off");
// We need to wait toast's popup shown and popup hidden events. It won't fire
// the popup shown event if we open the protections panel while the toast is
@ -106,6 +136,7 @@ add_task(async function testToggleSwitch() {
);
await browserLoadedPromise;
checkClickTelemetry("etp_toggle_on");
ContentBlockingAllowList.remove(tab.linkedBrowser);
BrowserTestUtils.removeTab(tab);
@ -138,6 +169,7 @@ add_task(async function testSettingsButton() {
let newTab = await newTabPromise;
ok(true, "about:preferences has been opened successfully");
checkClickTelemetry("settings");
BrowserTestUtils.removeTab(newTab);
BrowserTestUtils.removeTab(tab);
@ -184,6 +216,8 @@ add_task(async function testShowFullReportButton() {
}, "The graph has been built");
});
checkClickTelemetry("full_report");
BrowserTestUtils.removeTab(newTab);
BrowserTestUtils.removeTab(tab);
});
@ -370,3 +404,35 @@ add_task(async function testTrackingProtectionIcon() {
ContentBlockingAllowList.remove(tab.linkedBrowser);
BrowserTestUtils.removeTab(tab);
});
add_task(async function testSubViewTelemetry() {
let items = [
["protections-popup-category-tracking-protection", "trackers"],
["protections-popup-category-socialblock", "social"],
["protections-popup-category-cookies", "cookies"],
["protections-popup-category-cryptominers", "cryptominers"],
["protections-popup-category-fingerprinters", "fingerprinters"],
].map(item => [document.getElementById(item[0]), item[1]]);
for (let [item, telemetryId] of items) {
await BrowserTestUtils.withNewTab("http://www.example.com", async () => {
await openProtectionsPanel();
item.classList.remove("notFound"); // Force visible for test
let viewShownEvent = BrowserTestUtils.waitForEvent(
gProtectionsHandler._protectionsPopupMultiView,
"ViewShown"
);
item.click();
let panelView = (await viewShownEvent).originalTarget;
checkClickTelemetry(telemetryId);
let prefsTabPromise = BrowserTestUtils.waitForNewTab(
gBrowser,
"about:preferences#privacy"
);
panelView.querySelector(".panel-footer > button").click();
let prefsTab = await prefsTabPromise;
BrowserTestUtils.removeTab(prefsTab);
checkClickTelemetry("subview_settings", telemetryId);
});
}
});

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

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

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

@ -45,7 +45,7 @@
aria-level="2">&protections.etpOFF.header;</label>
<label id="protections-popup-tp-switch-breakage-link"
class="text-link"
onclick="gProtectionsHandler.showSiteNotWorkingView();">&protections.siteNotWorking.label;</label>
onclick="gProtectionsHandler.showSiteNotWorkingView(); gProtectionsHandler.recordClick('sitenotworking_link');">&protections.siteNotWorking.label;</label>
</vbox>
<vbox class="protections-popup-tp-switch-box">
<toolbarbutton id="protections-popup-tp-switch"
@ -63,21 +63,21 @@
<vbox id="protections-popup-content" flex="1">
<vbox id="protections-popup-category-list">
<toolbarbutton id="protections-popup-category-tracking-protection"
onclick="gProtectionsHandler.showTrackersSubview(event);"
onclick="gProtectionsHandler.showTrackersSubview(event); gProtectionsHandler.recordClick('trackers');"
class="protections-popup-category" align="center"
wrap="true">
<image class="protections-popup-category-icon tracking-protection-icon"/>
<label flex="1" class="protections-popup-category-label">&contentBlocking.trackingProtection4.label;</label>
</toolbarbutton>
<toolbarbutton id="protections-popup-category-socialblock"
onclick="gProtectionsHandler.showSocialblockerSubview(event);"
onclick="gProtectionsHandler.showSocialblockerSubview(event); gProtectionsHandler.recordClick('social');"
class="protections-popup-category" align="center">
<image class="protections-popup-category-icon socialblock-icon"/>
<label flex="1"
class="protections-popup-category-label">&contentBlocking.socialblock.label;</label>
</toolbarbutton>
<toolbarbutton id="protections-popup-category-cookies"
onclick="gProtectionsHandler.showCookiesSubview(event);"
onclick="gProtectionsHandler.showCookiesSubview(event); gProtectionsHandler.recordClick('cookies');"
class="protections-popup-category" align="center"
wrap="true">
<image class="protections-popup-category-icon thirdpartycookies-icon"/>
@ -88,14 +88,14 @@
hidden="true"></label>
</toolbarbutton>
<toolbarbutton id="protections-popup-category-cryptominers"
onclick="gProtectionsHandler.showCryptominersSubview(event);"
onclick="gProtectionsHandler.showCryptominersSubview(event); gProtectionsHandler.recordClick('cryptominers');"
class="protections-popup-category" align="center"
wrap="true">
<image class="protections-popup-category-icon cryptominers-icon"/>
<label flex="1" class="protections-popup-category-label">&contentBlocking.cryptominers.label;</label>
</toolbarbutton>
<toolbarbutton id="protections-popup-category-fingerprinters"
onclick="gProtectionsHandler.showFingerprintersSubview(event);"
onclick="gProtectionsHandler.showFingerprintersSubview(event); gProtectionsHandler.recordClick('fingerprinters');"
class="protections-popup-category" align="center"
wrap="true">
<image class="protections-popup-category-icon fingerprinters-icon"/>
@ -121,14 +121,14 @@
<vbox id="protections-popup-footer" class="protections-popup-section">
<toolbarbutton id="protections-popup-settings-button"
class="protections-popup-footer-button"
oncommand="gProtectionsHandler.openPreferences();">
oncommand="gProtectionsHandler.openPreferences(); gProtectionsHandler.recordClick('settings');">
<image class="protections-popup-footer-icon protections-popup-settings-icon"/>
<label class="protections-popup-footer-button-label" flex="1">&protections.settings.label;</label>
</toolbarbutton>
<stack id="protections-popup-show-report-stack">
<toolbarbutton id="protections-popup-show-report-button"
class="protections-popup-footer-button"
oncommand="gProtectionsHandler.openProtections(true);">
oncommand="gProtectionsHandler.openProtections(true); gProtectionsHandler.recordClick('full_report');">
<image class="protections-popup-footer-icon protections-popup-show-report-icon"/>
<label class="protections-popup-footer-button-label" flex="1">&protections.report.label;</label>
</toolbarbutton>
@ -177,7 +177,7 @@
</label>
<label id="protections-popup-siteNotWorkingView-siteStillBroken">&protections.siteNotWorkingView.siteStillBroken.label;</label>
<label id="protections-popup-siteNotWorkingView-sendReport"
onclick="gProtectionsHandler.showSendReportView();"
onclick="gProtectionsHandler.showSendReportView(); gProtectionsHandler.recordClick('send_report_link');"
class="text-link">&protections.siteNotWorkingView.sendReport.label;</label>
</vbox>
</panelview>
@ -199,7 +199,7 @@
<button id="protections-popup-trackersView-settings-button"
label="&contentBlocking.manageSettings2.label;"
accesskey="&contentBlocking.manageSettings.accesskey;"
oncommand="gProtectionsHandler.openPreferences();"/>
oncommand="gProtectionsHandler.openPreferences(); gProtectionsHandler.recordClick('subview_settings', 'trackers');"/>
</vbox>
</panelview>
@ -216,7 +216,7 @@
<button id="protections-popup-socialblockView-settings-button"
label="&contentBlocking.manageSettings2.label;"
accesskey="&contentBlocking.manageSettings.accesskey;"
oncommand="gProtectionsHandler.openPreferences();"/>
oncommand="gProtectionsHandler.openPreferences(); gProtectionsHandler.recordClick('subview_settings', 'social');"/>
</vbox>
</panelview>
@ -233,7 +233,7 @@
<button id="protections-popup-cookiesView-settings-button"
label="&contentBlocking.manageSettings2.label;"
accesskey="&contentBlocking.manageSettings.accesskey;"
oncommand="gProtectionsHandler.openPreferences();"/>
oncommand="gProtectionsHandler.openPreferences(); gProtectionsHandler.recordClick('subview_settings', 'cookies');"/>
</vbox>
</panelview>
@ -250,7 +250,7 @@
<button id="protections-popup-fingerprintersView-settings-button"
label="&contentBlocking.manageSettings2.label;"
accesskey="&contentBlocking.manageSettings.accesskey;"
oncommand="gProtectionsHandler.openPreferences();"/>
oncommand="gProtectionsHandler.openPreferences(); gProtectionsHandler.recordClick('subview_settings', 'fingerprinters');"/>
</vbox>
</panelview>
@ -267,7 +267,7 @@
<button id="protections-popup-cryptominersView-settings-button"
label="&contentBlocking.manageSettings2.label;"
accesskey="&contentBlocking.manageSettings.accesskey;"
oncommand="gProtectionsHandler.openPreferences();"/>
oncommand="gProtectionsHandler.openPreferences(); gProtectionsHandler.recordClick('subview_settings', 'cryptominers');"/>
</vbox>
</panelview>
@ -300,7 +300,7 @@
<button id="protections-popup-sendReportView-submit"
default="true"
label="&contentBlocking.breakageReportView.sendReport.label;"
oncommand="gProtectionsHandler.onSendReportClicked();"/>
oncommand="gProtectionsHandler.onSendReportClicked(); gProtectionsHandler.recordClick('send_report_submit');"/>
</vbox>
</panelview>
</panelmultiview>

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

@ -1602,6 +1602,57 @@ security.ui.identitypopup:
- main
products:
- firefox
security.ui.protectionspopup:
open:
objects: ["protections_popup"]
bug_numbers:
- 1560327
description: >
How many times the protections panel was opened.
expiry_version: "75"
notification_emails:
- nhnt11@mozilla.com
- jhofmann@mozilla.com
- chsiang@mozilla.com
- seceng-telemetry@mozilla.com
release_channel_collection: opt-out
record_in_processes:
- main
products:
- firefox
click:
objects: [
"etp_toggle_on",
"etp_toggle_off",
"sitenotworking_link",
"send_report_link",
"send_report_submit",
"social",
"cookies",
"trackers",
"fingerprinters",
"cryptominers",
"subview_settings",
"settings",
"full_report",
]
bug_numbers:
- 1560327
description: >
User interaction by click events in the protections panel.
expiry_version: "75"
notification_emails:
- nhnt11@mozilla.com
- jhofmann@mozilla.com
- chsiang@mozilla.com
- seceng-telemetry@mozilla.com
release_channel_collection: opt-out
record_in_processes:
- main
products:
- firefox
uptake.remotecontent.result:
uptake:
description: >