Bug 1800775 - Add telemetry probes to the 3-pane tab. r=aleca

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

--HG--
extra : amend_source : 86fad7f27ccd01c70f370df02e9780830dc6265b
This commit is contained in:
Geoff Lankow 2022-11-17 21:18:47 +11:00
Родитель 2325683a8d
Коммит 6f930416f0
9 изменённых файлов: 474 добавлений и 27 удалений

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

@ -429,6 +429,12 @@ var gFolderTreeView = {
// is disabled since we don't require a full restart.
this._activeModes = this._activeModes.filter(mode => mode in this._modes);
// If we end up with an empty array, add the default mode.
if (!this._activeModes.length) {
this._activeModes.push(kDefaultMode);
this._updateMenuItems(kDefaultMode);
}
// Store the current mode as a tree attribute.
this._treeElement.setAttribute("mode", this._activeModes);
// Build the folder pane.

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

@ -749,6 +749,22 @@ var mailTabType = {
} else {
messagePaneToggleKey.setAttribute("disabled", "true");
}
// If all panes are legal report which ones are visible. Doing it this way
// means the telemetry reflects the state of the last folder tab that was
// shown, but not if the state changed since it was shown.
if (aLegalStates.folder && aLegalStates.thread && aLegalStates.message) {
Services.telemetry.keyedScalarSet(
"tb.ui.configuration.pane_visibility",
"folderPane",
aVisibleStates.folder
);
Services.telemetry.keyedScalarSet(
"tb.ui.configuration.pane_visibility",
"messagePane",
aVisibleStates.message
);
}
},
showTab(aTab) {

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

@ -11,6 +11,7 @@ prefs =
subsuite = thunderbird
support-files = files/**
[browser_3paneTelemetry.js]
[browser_browserRequestWindow.js]
[browser_formPickers.js]
tags = webextensions

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

@ -0,0 +1,146 @@
/* 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/. */
var { MailServices } = ChromeUtils.import(
"resource:///modules/MailServices.jsm"
);
var { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);
var folders = {};
add_setup(async function() {
MailServices.accounts.createLocalMailAccount();
let account = MailServices.accounts.accounts[0];
let rootFolder = account.incomingServer.rootFolder;
for (let type of ["Drafts", "SentMail", "Templates", "Junk", "Archive"]) {
rootFolder.createSubfolder(type, null);
folders[type] = rootFolder.getChildNamed(type);
folders[type].setFlag(Ci.nsMsgFolderFlags[type]);
}
rootFolder.createSubfolder("just a folder", null);
folders.Other = rootFolder.getChildNamed("just a folder");
});
add_task(async function testFolderOpen() {
Services.telemetry.clearScalars();
window.gFolderTreeView.selectFolder(folders.Other);
let scalarName = "tb.mails.folder_opened";
let scalars = TelemetryTestUtils.getProcessScalars("parent", true);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "Other", 1);
window.gFolderTreeView.selectFolder(folders.Templates);
window.gFolderTreeView.selectFolder(folders.Other);
scalars = TelemetryTestUtils.getProcessScalars("parent", true);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "Other", 2);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "Templates", 1);
window.gFolderTreeView.selectFolder(folders.Junk);
window.gFolderTreeView.selectFolder(folders.Other);
scalars = TelemetryTestUtils.getProcessScalars("parent", true);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "Other", 3);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "Templates", 1);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "Junk", 1);
window.gFolderTreeView.selectFolder(folders.Junk);
window.gFolderTreeView.selectFolder(folders.Templates);
window.gFolderTreeView.selectFolder(folders.Archive);
window.gFolderTreeView.selectFolder(folders.Other);
scalars = TelemetryTestUtils.getProcessScalars("parent", true);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "Other", 4);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "Templates", 2);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "Archive", 1);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "Junk", 2);
});
add_task(async function testPaneVisibility() {
window.gFolderTreeView.selectFolder(folders.Other);
// Make the folder pane and message pane visible initially.
if (!window.gFolderDisplay.folderPaneVisible) {
goDoCommand("cmd_toggleFolderPane");
}
if (!window.gMessageDisplay.visible) {
goDoCommand("cmd_toggleMessagePane");
}
// The scalar is updated by switching to the folder tab, so open another tab.
window.openContentTab("about:mozilla");
Services.telemetry.clearScalars();
let tabmail = document.getElementById("tabmail");
tabmail.switchToTab(0);
let scalarName = "tb.ui.configuration.pane_visibility";
let scalars = TelemetryTestUtils.getProcessScalars("parent", true);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "folderPane", true);
TelemetryTestUtils.assertKeyedScalar(
scalars,
scalarName,
"messagePane",
true
);
// Hide the folder pane.
goDoCommand("cmd_toggleFolderPane");
tabmail.switchToTab(1);
tabmail.switchToTab(0);
scalars = TelemetryTestUtils.getProcessScalars("parent", true);
TelemetryTestUtils.assertKeyedScalar(
scalars,
scalarName,
"folderPane",
false
);
TelemetryTestUtils.assertKeyedScalar(
scalars,
scalarName,
"messagePane",
true
);
// Hide the message pane.
goDoCommand("cmd_toggleMessagePane");
tabmail.switchToTab(1);
tabmail.switchToTab(0);
scalars = TelemetryTestUtils.getProcessScalars("parent", true);
TelemetryTestUtils.assertKeyedScalar(
scalars,
scalarName,
"folderPane",
false
);
TelemetryTestUtils.assertKeyedScalar(
scalars,
scalarName,
"messagePane",
false
);
// Show both panes again.
goDoCommand("cmd_toggleFolderPane");
goDoCommand("cmd_toggleMessagePane");
tabmail.switchToTab(1);
tabmail.switchToTab(0);
scalars = TelemetryTestUtils.getProcessScalars("parent", true);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "folderPane", true);
TelemetryTestUtils.assertKeyedScalar(
scalars,
scalarName,
"messagePane",
true
);
// Close the extra tab.
tabmail.closeOtherTabs(0);
});

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

@ -798,7 +798,8 @@ MailGlue.prototype = {
reportAddressBookTypes();
reportAccountSizes();
await reportCalendars();
reportBooleanPreferences();
reportPreferences();
reportUIConfiguration();
},
];
@ -951,6 +952,22 @@ function reportAccountTypes() {
* Report size on disk and messages count of each type of folder to telemetry.
*/
function reportAccountSizes() {
let keys = [
"Inbox",
"Drafts",
"Trash",
"SentMail",
"Templates",
"Junk",
"Archive",
"Queue",
];
for (let key of keys) {
Services.telemetry.keyedScalarSet("tb.account.total_messages", key, 0);
}
Services.telemetry.keyedScalarSet("tb.account.total_messages", "Other", 0);
Services.telemetry.keyedScalarSet("tb.account.total_messages", "Total", 0);
for (let server of lazy.MailServices.accounts.allServers) {
if (
server instanceof Ci.nsIPop3IncomingServer &&
@ -962,37 +979,31 @@ function reportAccountSizes() {
for (let folder of server.rootFolder.descendants) {
let key =
[
"Inbox",
"Drafts",
"Trash",
"SentMail",
"Templates",
"Junk",
"Archive",
"Queue",
].find(x => folder.getFlag(Ci.nsMsgFolderFlags[x])) || "Other";
keys.find(x => folder.getFlag(Ci.nsMsgFolderFlags[x])) || "Other";
let totalMessages = folder.getTotalMessages(false);
if (totalMessages > 0) {
Services.telemetry.keyedScalarAdd(
"tb.account.size_on_disk",
key,
folder.sizeOnDisk
);
Services.telemetry.keyedScalarAdd(
"tb.account.total_messages",
key,
folder.getTotalMessages(false)
);
Services.telemetry.keyedScalarAdd(
"tb.account.size_on_disk",
"Total",
folder.sizeOnDisk
totalMessages
);
Services.telemetry.keyedScalarAdd(
"tb.account.total_messages",
"Total",
folder.getTotalMessages(false)
totalMessages
);
}
let sizeOnDisk = folder.sizeOnDisk;
if (sizeOnDisk > 0) {
Services.telemetry.keyedScalarAdd(
"tb.account.size_on_disk",
key,
sizeOnDisk
);
Services.telemetry.keyedScalarAdd(
"tb.account.size_on_disk",
"Total",
sizeOnDisk
);
}
}
@ -1087,7 +1098,7 @@ async function reportCalendars() {
}
}
function reportBooleanPreferences() {
function reportPreferences() {
let booleanPrefs = [
// General
"browser.cache.disk.smart_size.enabled",
@ -1197,6 +1208,14 @@ function reportBooleanPreferences() {
"calendar.alarms.showmissed",
];
let integerPrefs = [
// Mail UI
"mail.pane_config.dynamic",
"mail.ui.display.dateformat.default",
"mail.ui.display.dateformat.thisweek",
"mail.ui.display.dateformat.today",
];
// Platform-specific preferences
if (AppConstants.platform === "win") {
booleanPrefs.push("mail.biff.show_tray_icon", "mail.minimizeToTray");
@ -1245,6 +1264,55 @@ function reportBooleanPreferences() {
prefValue
);
}
for (let prefName of integerPrefs) {
let prefValue = Services.prefs.getIntPref(prefName, 0);
Services.telemetry.keyedScalarSet(
"tb.preferences.integer",
prefName,
prefValue
);
}
}
function reportUIConfiguration() {
let docURL = "chrome://messenger/content/messenger.xhtml";
let folderTreeMode = Services.xulStore.getValue(docURL, "folderTree", "mode");
if (folderTreeMode) {
let folderTreeCompact = Services.xulStore.getValue(
docURL,
"folderTree",
"compact"
);
if (folderTreeCompact === "true") {
folderTreeMode += " (compact)";
}
Services.telemetry.scalarSet(
"tb.ui.configuration.folder_tree_modes",
folderTreeMode
);
}
let headerLayout = Services.xulStore.getValue(
docURL,
"messageHeader",
"layout"
);
if (headerLayout) {
headerLayout = JSON.parse(headerLayout);
for (let [key, value] of Object.entries(headerLayout)) {
if (key == "buttonStyle") {
value = { default: 0, "only-icons": 1, "only-text": 2 }[value];
}
Services.telemetry.keyedScalarSet(
"tb.ui.configuration.message_header",
key,
value
);
}
}
}
/**
@ -1256,5 +1324,6 @@ var MailTelemetryForTests = {
reportAccountSizes,
reportAddressBookTypes,
reportCalendars,
reportBooleanPreferences,
reportPreferences,
reportUIConfiguration,
};

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

@ -302,11 +302,37 @@ tb.mails:
record_in_processes:
- 'main'
folder_opened:
bug_numbers:
- 1800775
description: How many times folders of each type are opened.
release_channel_collection: opt-out
expires: never
products:
- 'thunderbird'
kind: uint
keyed: true
keys:
- Inbox
- Drafts
- Trash
- SentMail
- Templates
- Junk
- Archive
- Queue
- Virtual
- Other
notification_emails:
- "telemetry-client-dev@thunderbird.net"
record_in_processes:
- 'main'
tb.preferences:
boolean:
bug_numbers:
- 1757993
description: Values of checkboxes or boolean radio buttons.
description: Values of boolean preferences.
release_channel_collection: opt-out
expires: never
products:
@ -318,6 +344,21 @@ tb.preferences:
record_in_processes:
- 'main'
integer:
bug_numbers:
- 1800775
description: Values of integer preferences.
release_channel_collection: opt-out
expires: never
products:
- 'thunderbird'
keyed: true
kind: uint
notification_emails:
- "telemetry-client-dev@thunderbird.net"
record_in_processes:
- 'main'
tb.websearch:
usage:
bug_numbers:
@ -396,6 +437,60 @@ tb.calendar:
record_in_processes:
- 'main'
tb.ui.configuration:
folder_tree_modes:
bug_numbers:
- 1800775
description: Configuration of the folder tree.
release_channel_collection: opt-out
expires: never
products:
- 'thunderbird'
kind: string
notification_emails:
- "telemetry-client-dev@thunderbird.net"
record_in_processes:
- 'main'
pane_visibility:
bug_numbers:
- 1800775
description: Configuration of the folder and message panes.
release_channel_collection: opt-out
expires: never
products:
- 'thunderbird'
kind: boolean
keyed: true
keys:
- folderPane
- messagePane
notification_emails:
- "telemetry-client-dev@thunderbird.net"
record_in_processes:
- 'main'
message_header:
bug_numbers:
- 1800775
description: Configuration of the message header display.
release_channel_collection: opt-out
expires: never
products:
- 'thunderbird'
kind: uint
keyed: true
keys:
- subjectLarge
- buttonStyle
- hideLabels
- showAvatar
- showFullAddress
notification_emails:
- "telemetry-client-dev@thunderbird.net"
record_in_processes:
- 'main'
tb.ui.interaction:
calendar:
bug_numbers:

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

@ -794,6 +794,24 @@ DBViewWrapper.prototype = {
return;
}
let typeForTelemetry =
[
"Inbox",
"Drafts",
"Trash",
"SentMail",
"Templates",
"Junk",
"Archive",
"Queue",
"Virtual",
].find(x => aFolder.getFlag(Ci.nsMsgFolderFlags[x])) || "Other";
Services.telemetry.keyedScalarAdd(
"tb.mails.folder_opened",
typeForTelemetry,
1
);
this.beginViewUpdate();
let msgDatabase;
try {

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

@ -18,6 +18,12 @@ var {
} = ChromeUtils.import(
"resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
);
var { MailTelemetryForTests } = ChromeUtils.import(
"resource:///modules/MailGlue.jsm"
);
var { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);
var rootFolder;
var unreadFolder;
@ -65,6 +71,8 @@ add_setup(async function() {
// Show the Folder Pane header toolbar.
mc.e("folderPaneHeader").removeAttribute("collapsed");
Services.telemetry.clearScalars();
});
/**
@ -73,7 +81,11 @@ add_setup(async function() {
* @param {string} aMode - The name of the expected mode.
*/
async function assert_mode_selected(aMode) {
Assert.ok(tree.activeModes.includes(aMode));
if (aMode != "compact") {
// "compact" isn't really a mode, we're just using this function because
// it tests everything we want to test.
Assert.ok(tree.activeModes.includes(aMode));
}
// We need to open the menu because only then the right mode is set in them.
if (["linux", "win"].includes(AppConstants.platform)) {
@ -271,18 +283,62 @@ async function subtest_toggle_smart_folders(show) {
}
}
/**
* Toggle the compact mode.
*/
async function subtest_toggle_compact(compact) {
let mode = "compact";
select_mode_in_menu(mode);
if (compact) {
await assert_mode_selected(mode);
} else {
await assert_mode_not_selected(mode);
}
}
/**
* Check that the current mode(s) are accurately recorded in telemetry.
* Note that `reportUIConfiguration` usually only runs at start-up.
*/
function check_scalars(expected) {
MailTelemetryForTests.reportUIConfiguration();
let scalarName = "tb.ui.configuration.folder_tree_modes";
let scalars = TelemetryTestUtils.getProcessScalars("parent");
if (expected) {
TelemetryTestUtils.assertScalar(scalars, scalarName, expected);
} else {
TelemetryTestUtils.assertScalarUnset(scalars, scalarName);
}
}
/**
* Toggle folder modes through different means and sequences.
*/
add_task(async function test_toggling_modes() {
check_scalars();
await subtest_toggle_all_folders(true);
await subtest_toggle_smart_folders(true);
check_scalars("all,smart");
await subtest_toggle_unread_folders(true);
await subtest_toggle_favorite_folders(true);
await subtest_toggle_recent_folders(true);
check_scalars("all,smart,unread,favorite,recent");
await subtest_toggle_compact(true);
check_scalars("all,smart,unread,favorite,recent (compact)");
await subtest_toggle_unread_folders(false);
check_scalars("all,smart,favorite,recent (compact)");
await subtest_toggle_compact(false);
check_scalars("all,smart,favorite,recent");
await subtest_toggle_favorite_folders(false);
check_scalars("all,smart,recent");
await subtest_toggle_all_folders(false);
await subtest_toggle_recent_folders(false);
await subtest_toggle_smart_folders(false);
@ -290,6 +346,7 @@ add_task(async function test_toggling_modes() {
// Confirm that the all folders mode is visible even after all the modes have
// been deselected in order to ensure that the Folder Pane is never empty.
await assert_mode_selected("all");
check_scalars("all");
});
registerCleanupFunction(function() {

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

@ -6,12 +6,20 @@
* Test the message header customization features.
*/
var { MailTelemetryForTests } = ChromeUtils.import(
"resource:///modules/MailGlue.jsm"
);
var { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);
var gFolder;
add_setup(async function() {
Services.xulStore.removeDocument(
"chrome://messenger/content/messenger.xhtml"
);
Services.telemetry.clearScalars();
let account = createAccount();
gFolder = await createSubfolder(account.incomingServer.rootFolder, "test0");
@ -85,6 +93,11 @@ add_task(async function test_customize_toolbar_buttons() {
"The message header buttons aren't showing only text"
);
MailTelemetryForTests.reportUIConfiguration();
let scalarName = "tb.ui.configuration.message_header";
let scalars = TelemetryTestUtils.getProcessScalars("parent", true);
TelemetryTestUtils.assertScalarUnset(scalars, scalarName);
let popup = document.getElementById("otherActionsPopup");
let popupShown = BrowserTestUtils.waitForEvent(popup, "popupshown");
EventUtils.synthesizeMouseAtCenter(moreBtn, {});
@ -262,6 +275,19 @@ add_task(async function test_customize_toolbar_buttons() {
"The customization data was saved"
);
MailTelemetryForTests.reportUIConfiguration();
scalars = TelemetryTestUtils.getProcessScalars("parent", true);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "subjectLarge", 1);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "buttonStyle", 1);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "hideLabels", 1);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "showAvatar", 1);
TelemetryTestUtils.assertKeyedScalar(
scalars,
scalarName,
"showFullAddress",
1
);
popupShown = BrowserTestUtils.waitForEvent(popup, "popupshown");
EventUtils.synthesizeMouseAtCenter(moreBtn, {});
await popupShown;
@ -311,4 +337,17 @@ add_task(async function test_customize_toolbar_buttons() {
"The first label has a min-width value"
);
await assertVisibility(firstLabel, true, "The labels column is visible");
MailTelemetryForTests.reportUIConfiguration();
scalars = TelemetryTestUtils.getProcessScalars("parent", true);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "subjectLarge", 0);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "buttonStyle", 0);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "hideLabels", 0);
TelemetryTestUtils.assertKeyedScalar(scalars, scalarName, "showAvatar", 0);
TelemetryTestUtils.assertKeyedScalar(
scalars,
scalarName,
"showFullAddress",
0
);
});