Bug 1950394 - Migrate Environment intl fields r=TravisLong

Differential Revision: https://phabricator.services.mozilla.com/D246678
This commit is contained in:
Chris H-C
2025-04-28 14:32:40 +00:00
parent 4f9aab18ac
commit f502b7b0a9
4 changed files with 116 additions and 3 deletions

103
intl/locale/metrics.yaml Normal file
View File

@@ -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

View File

@@ -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",

View File

@@ -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;
}
/**

View File

@@ -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());
}
},