Bug 1899602 - Lay the groundwork for enabling Glean and migrate tb.compose_format to Glean. r=babolivier

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

--HG--
extra : rebase_source : 9e0e993586efcdfbeebf515b8569492b1d7ed92a
This commit is contained in:
Magnus Melin 2024-06-19 10:18:01 +03:00
Родитель 08edb89dbd
Коммит 4f6ac90140
8 изменённых файлов: 77 добавлений и 38 удалений

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

@ -829,6 +829,14 @@ MailGlue.prototype = {
Services.prefs.clearUserPref("mail.storybook.openTab");
},
},
// FOG doesn't need to be initialized _too_ early because it has a
// pre-init buffer.
{
name: "initializeFOG",
task: () => {
Services.fog.initializeFOG();
},
},
{
task() {
// Use idleDispatch a second time to run this after the per-window

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

@ -146,35 +146,6 @@ tb.account:
record_in_processes:
- 'main'
tb.compose:
format_html:
bug_numbers:
- 1584889
description: How many times messages were written in HTML composition mode.
release_channel_collection: opt-out
expires: never
products:
- 'thunderbird'
kind: uint
notification_emails:
- "telemetry-client-dev@thunderbird.net"
record_in_processes:
- 'main'
format_plain_text:
bug_numbers:
- 1584889
description: How many times messages were written in plain text composition mode.
release_channel_collection: opt-out
expires: never
products:
- 'thunderbird'
kind: uint
notification_emails:
- "telemetry-client-dev@thunderbird.net"
record_in_processes:
- 'main'
tb.filelink:
uploaded_size:
bug_numbers:

35
mail/metrics.yaml Normal file
Просмотреть файл

@ -0,0 +1,35 @@
# 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:
- 'Thunderbird :: General'
tb:
compose_format:
type: labeled_counter
description:
How many times messages were written in HTML composition mode,
vs. how many were written in plain text composition mode.
Label names are from nsIMsgCompFormat.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1584889
- https://bugzilla.mozilla.org/show_bug.cgi?id=1899602
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1584889
data_sensitivity:
- technical
notification_emails:
- telemetry-client-dev@thunderbird.net
expires: never
labels:
- HTML
- PlainText

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

@ -77,6 +77,10 @@ set_config(
set_config("MOZ_TELEMETRY_EXTRA_SCALAR_FILES", ["/comm/mail/components/telemetry/Scalars.yaml"])
set_config("MOZ_TELEMETRY_EXTRA_EVENT_FILES", ["/comm/mail/components/telemetry/Events.yaml"])
set_config("MOZ_GLEAN_EXTRA_METRICS_FILES", ["comm/mail/metrics.yaml"])
# set_config("MOZ_GLEAN_EXTRA_PINGS_FILES", ["comm/mail/pings.yaml"])
set_config("MOZ_GLEAN_EXTRA_TAGS_FILES", ["comm/mail/tags.yaml"])
include("../build/moz.configure/gecko_source.configure")
include("../mailnews/moz.configure")

0
mail/pings.yaml Normal file
Просмотреть файл

14
mail/tags.yaml Normal file
Просмотреть файл

@ -0,0 +1,14 @@
# 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/.
### This file was AUTOMATICALLY GENERATED by `./mach update-glean-tags`
### TODO: for now edited by hand. See bug 1902986.
### DO NOT edit it by hand.
---
$schema: moz://mozilla.org/schemas/glean/tags/1-0-0
'Thunderbird :: General':
description: The Bugzilla component which applies to this object.

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

@ -60,6 +60,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/GleanMetrics.h"
#include "mozilla/dom/HTMLAnchorElement.h"
#include "mozilla/dom/HTMLImageElement.h"
#include "mozilla/dom/Selection.h"
@ -860,9 +861,9 @@ nsMsgCompose::Initialize(nsIMsgComposeParams* aParams,
#ifndef MOZ_SUITE
if (m_composeHTML) {
Telemetry::ScalarAdd(Telemetry::ScalarID::TB_COMPOSE_FORMAT_HTML, 1);
mozilla::glean::tb::compose_format.Get("HTML"_ns).Add(1);
} else {
Telemetry::ScalarAdd(Telemetry::ScalarID::TB_COMPOSE_FORMAT_PLAIN_TEXT, 1);
mozilla::glean::tb::compose_format.Get("PlainText"_ns).Add(1);
}
Telemetry::Accumulate(Telemetry::TB_COMPOSE_TYPE, type);
#endif

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

@ -9,8 +9,13 @@ ChromeUtils.defineESModuleGetters(this, {
TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs",
});
const HTML_SCALAR = "tb.compose.format_html";
const PLAIN_TEXT_SCALAR = "tb.compose.format_plain_text";
add_setup(function test_setup() {
// FOG needs a profile directory to put its data in.
do_get_profile();
// FOG needs to be initialized in order for data to flow.
Services.fog.initializeFOG();
});
/**
* Check that we're counting HTML or Plain text when composing.
@ -43,16 +48,17 @@ add_task(async function test_compose_format() {
}
// Did we count them correctly?
const scalars = TelemetryTestUtils.getProcessScalars("parent");
const htmlValue = Glean.tb.composeFormat.HTML.testGetValue();
Assert.equal(
scalars[HTML_SCALAR],
htmlValue,
NUM_HTML,
HTML_SCALAR + " must have the correct value."
"tb.compose_format metric should be correct for HTML"
);
const plainTextValue = Glean.tb.composeFormat.PlainText.testGetValue();
Assert.equal(
scalars[PLAIN_TEXT_SCALAR],
plainTextValue,
NUM_PLAIN,
PLAIN_TEXT_SCALAR + " must have the correct value."
"tb.compose_format metric should be correct for PlainText"
);
});