diff --git a/intl/locale/metrics.yaml b/intl/locale/metrics.yaml new file mode 100644 index 000000000000..3fd6f44c80b3 --- /dev/null +++ b/intl/locale/metrics.yaml @@ -0,0 +1,103 @@ +# 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: + - 'Core :: Internationalization' + +intl: + requested_locales: + type: string_list + lifetime: application + description: | + The Locales that are being requested. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1950394 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1950394 + data_sensitivity: + - technical + notification_emails: + - flod@mozilla.com + expires: never + + available_locales: + type: string_list + lifetime: application + description: | + The Locales that are available for use. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1950394 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1950394 + data_sensitivity: + - technical + notification_emails: + - flod@mozilla.com + expires: never + + app_locales: + type: string_list + lifetime: application + description: | + The negotiated Locales that are being used. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1950394 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1950394 + data_sensitivity: + - technical + notification_emails: + - flod@mozilla.com + expires: never + + system_locales: + type: string_list + lifetime: application + description: | + The Locales for the OS. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1950394 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1950394 + data_sensitivity: + - technical + notification_emails: + - flod@mozilla.com + expires: never + + regional_prefs_locales: + type: string_list + lifetime: application + description: | + The regional preferences for the OS. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1950394 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1950394 + data_sensitivity: + - technical + notification_emails: + - flod@mozilla.com + expires: never + + accept_languages: + type: string_list + lifetime: application + description: | + The languages for the Accept-Languages header. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1950394 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1950394 + data_sensitivity: + - technical + notification_emails: + - flod@mozilla.com + expires: never + diff --git a/toolkit/components/glean/metrics_index.py b/toolkit/components/glean/metrics_index.py index e1a63afd319d..89c3c4ef03ff 100644 --- a/toolkit/components/glean/metrics_index.py +++ b/toolkit/components/glean/metrics_index.py @@ -49,6 +49,7 @@ gecko_metrics = [ "extensions/permissions/metrics.yaml", "gfx/metrics.yaml", "image/decoders/metrics.yaml", + "intl/locale/metrics.yaml", "ipc/metrics.yaml", "js/xpconnect/metrics.yaml", "layout/base/metrics.yaml", diff --git a/toolkit/components/telemetry/app/TelemetryEnvironment.sys.mjs b/toolkit/components/telemetry/app/TelemetryEnvironment.sys.mjs index 90e8711f6806..9363388c7f7e 100644 --- a/toolkit/components/telemetry/app/TelemetryEnvironment.sys.mjs +++ b/toolkit/components/telemetry/app/TelemetryEnvironment.sys.mjs @@ -82,8 +82,8 @@ export var Policy = { var gActiveExperimentStartupBuffer = new Map(); // For Powering arewegleanyet.com (See bug 1944592) -// Legacy Count: 115 -// Glean Count: 111 +// Legacy Count: 118 +// Glean Count: 117 var gGlobalEnvironment; function getGlobal() { @@ -479,7 +479,7 @@ function getRegionalPrefsLocales() { } function getIntlSettings() { - return { + let intl = { requestedLocales: Services.locale.requestedLocales, availableLocales: Services.locale.availableLocales, appLocales: Services.locale.appLocalesAsBCP47, @@ -490,6 +490,13 @@ function getIntlSettings() { .data.split(",") .map(str => str.trim()), }; + Glean.intl.requestedLocales.set(intl.requestedLocales); + Glean.intl.availableLocales.set(intl.availableLocales); + Glean.intl.appLocales.set(intl.appLocales); + Glean.intl.systemLocales.set(intl.systemLocales); + Glean.intl.regionalPrefsLocales.set(intl.regionalPrefsLocales); + Glean.intl.acceptLanguages.set(intl.acceptLanguages); + return intl; } /** diff --git a/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs b/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs index 001fc4a52452..c08daea84141 100644 --- a/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs +++ b/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs @@ -431,6 +431,7 @@ export var TelemetryEnvironmentTesting = { for (let field of fields) { lazy.Assert.ok(Array.isArray(intl[field]), `${field} is an array`); + lazy.Assert.deepEqual(intl[field], Glean.intl[field].testGetValue()); } // These fields may be null if they aren't ready yet. This is mostly to deal @@ -441,6 +442,7 @@ export var TelemetryEnvironmentTesting = { let isArray = Array.isArray(intl[field]); let isNull = intl[field] === null; lazy.Assert.ok(isArray || isNull, `${field} is an array or null`); + lazy.Assert.deepEqual(intl[field], Glean.intl[field].testGetValue()); } },