Fix telemetry for manually set language (#400)

This commit is contained in:
Evgeny Pavlov 2022-06-13 13:45:19 -07:00 коммит произвёл GitHub
Родитель 010ffc372e
Коммит 3627b8cf89
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 39 добавлений и 4 удалений

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

@ -84,6 +84,7 @@ class Mediator {
const pageLang = this.languageDetection.pageLanguage;
const navLang = this.languageDetection.navigatorLanguage;
this.recordTelemetry("string", "metadata", "from_lang", pageLang);
this.recordTelemetry("string", "metadata", "detected_lang", pageLang);
this.recordTelemetry("string", "metadata", "to_lang", navLang);
this.recordTelemetry("string", "metadata", "model_version", modelRegistryVersion);
this.recordTelemetry("counter", "service", "lang_mismatch");

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

@ -20,7 +20,8 @@ metadata:
send_in_pings:
- custom
description: |
Translation source language.
Translation source language
(it can be set manually and different from detected_lang).
bugs:
- https://github.com/mozilla-extensions/firefox-translations/issues/42
- https://github.com/mozilla/firefox-translations/issues/27
@ -48,6 +49,22 @@ metadata:
notification_emails:
- anatal-all@mozilla.com
expires: 2022-08-10
detected_lang:
type: string
lifetime: ping
send_in_pings:
- custom
description: |
Translation source language that was automatically detected.
bugs:
- https://github.com/mozilla/firefox-translations/issues/350
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1694813
data_sensitivity:
- interaction
notification_emails:
- anatal-all@mozilla.com
expires: 2022-08-10
extension_version:
type: string
lifetime: ping

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

@ -18,6 +18,12 @@ const telemetrySchema = {
"custom"
]
},
"detected_lang": {
"type": "string",
"send_in_pings": [
"custom"
]
},
"extension_version": {
"type": "string",
"send_in_pings": [

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

@ -85,22 +85,30 @@ class TranslationNotificationManager {
}
}
reportInfobarMetric(type, name, value) {
reportMetric(type, category, name, value) {
/*
* propagate UI event to bgScript
* propagate metric to bgScript
*/
const message = {
command: "recordTelemetry",
tabId: this.tabId,
type,
category: "infobar",
category,
name,
value
};
this.bgScriptListenerCallback(message);
}
reportInfobarMetric(type, name, value) {
/*
* propagate UI event to bgScript
*/
this.reportMetric(type, "infobar", name, value);
}
requestInPageTranslation(from, to, withOutboundTranslation, withQualityEstimation) {
/*

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

@ -166,7 +166,10 @@ window.MozTranslationNotification = class extends MozElements.Notification {
}
fromLanguageChanged() {
const from = this._getSourceLang();
this.translationNotificationManager.reportMetric("string","metadata", "from_lang", from);
this.translationNotificationManager.reportInfobarMetric("event","change_lang");
if (this._getAnonElt("detectedLanguage").value === "userrequest") {
this._getAnonElt("translate").disabled = true;
} else {