mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1035337 - Introduce API to record when the infobar is hidden due to "Never translate this language/site". r=felipe
--HG-- extra : rebase_source : 04dd1e060efad6160997194ba1b128c7f8a5db36 extra : histedit_source : be5f46896497e1bef1aa5ace5850793c4556527d
This commit is contained in:
parent
5e375bd157
commit
a01e57440c
@ -298,6 +298,20 @@ let TranslationHealthReport = {
|
||||
this._withProvider(provider => provider.recordMissedTranslationOpportunity(language));
|
||||
},
|
||||
|
||||
/**
|
||||
* Record an automatically rejected translation offer in the health
|
||||
* report. A translation offer is automatically rejected when a user
|
||||
* has previously clicked "Never translate this language" or "Never
|
||||
* translate this site", which results in the infobar not being shown for
|
||||
* the translation opportunity.
|
||||
*
|
||||
* These translation opportunities should still be recorded in addition to
|
||||
* recording the automatic rejection of the offer.
|
||||
*/
|
||||
recordAutoRejectedTranslationOffer: function () {
|
||||
this._withProvider(provider => provider.recordAutoRejectedTranslationOffer());
|
||||
},
|
||||
|
||||
/**
|
||||
* Record a translation in the health report.
|
||||
* @param langFrom
|
||||
@ -413,6 +427,7 @@ TranslationMeasurement1.prototype = Object.freeze({
|
||||
showOriginalContent: DAILY_COUNTER_FIELD,
|
||||
detectLanguageEnabled: DAILY_LAST_NUMERIC_FIELD,
|
||||
showTranslationUI: DAILY_LAST_NUMERIC_FIELD,
|
||||
autoRejectedTranslationOffer: DAILY_COUNTER_FIELD,
|
||||
},
|
||||
|
||||
shouldIncludeField: function (field) {
|
||||
@ -511,6 +526,15 @@ TranslationProvider.prototype = Object.freeze({
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
recordAutoRejectedTranslationOffer: function (date=new Date()) {
|
||||
let m = this.getMeasurement(TranslationMeasurement1.prototype.name,
|
||||
TranslationMeasurement1.prototype.version);
|
||||
|
||||
return this._enqueueTelemetryStorageTask(function* recordTask() {
|
||||
yield m.incrementDailyCounter("autoRejectedTranslationOffer", date);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
recordTranslation: function (langFrom, langTo, numCharacters, date=new Date()) {
|
||||
let m = this.getMeasurement(TranslationMeasurement1.prototype.name,
|
||||
TranslationMeasurement1.prototype.version);
|
||||
|
@ -232,6 +232,11 @@ add_task(function* test_show_original() {
|
||||
yield test_simple_counter("recordShowOriginalContent", "showOriginalContent");
|
||||
});
|
||||
|
||||
add_task(function* test_show_original() {
|
||||
yield test_simple_counter("recordAutoRejectedTranslationOffer",
|
||||
"autoRejectedTranslationOffer");
|
||||
});
|
||||
|
||||
add_task(function* test_collect_daily() {
|
||||
let storage = yield Metrics.Storage("translation");
|
||||
let provider = new TranslationProvider();
|
||||
@ -291,6 +296,8 @@ add_task(function* test_healthreporter_json() {
|
||||
|
||||
yield provider.recordDeniedTranslationOffer();
|
||||
|
||||
yield provider.recordAutoRejectedTranslationOffer();
|
||||
|
||||
yield provider.recordShowOriginalContent();
|
||||
|
||||
yield reporter.collectMeasurements();
|
||||
@ -329,6 +336,9 @@ add_task(function* test_healthreporter_json() {
|
||||
Assert.ok("deniedTranslationOffer" in translations);
|
||||
Assert.equal(translations["deniedTranslationOffer"], 1);
|
||||
|
||||
Assert.ok("autoRejectedTranslationOffer" in translations);
|
||||
Assert.equal(translations["autoRejectedTranslationOffer"], 1);
|
||||
|
||||
Assert.ok("showOriginalContent" in translations);
|
||||
Assert.equal(translations["showOriginalContent"], 1);
|
||||
} finally {
|
||||
@ -357,6 +367,8 @@ add_task(function* test_healthreporter_json2() {
|
||||
|
||||
yield provider.recordDeniedTranslationOffer();
|
||||
|
||||
yield provider.recordAutoRejectedTranslationOffer();
|
||||
|
||||
yield provider.recordShowOriginalContent();
|
||||
|
||||
yield reporter.collectMeasurements();
|
||||
@ -378,6 +390,7 @@ add_task(function* test_healthreporter_json2() {
|
||||
Assert.ok(!("detectedLanguageChangedBefore" in translations));
|
||||
Assert.ok(!("detectedLanguageChangedAfter" in translations));
|
||||
Assert.ok(!("deniedTranslationOffer" in translations));
|
||||
Assert.ok(!("autoRejectedTranslationOffer" in translations));
|
||||
Assert.ok(!("showOriginalContent" in translations));
|
||||
} finally {
|
||||
reporter._shutdown();
|
||||
|
@ -1630,6 +1630,10 @@ deniedTranslationOffer
|
||||
Integer count of the number of times the user opted-out offered
|
||||
page translation, either by the Not Now button or by the notification's
|
||||
close button in the "offer" state.
|
||||
autoRejectedTranlationOffer
|
||||
Integer count of the number of times the user is not offered page
|
||||
translation because they had previously clicked "Never translate this
|
||||
language" or "Never translate this site".
|
||||
showOriginalContent
|
||||
Integer count of the number of times the user activated the Show Original
|
||||
command.
|
||||
@ -1672,6 +1676,7 @@ Example
|
||||
"detectedLanguageChangedAfter": 2,
|
||||
"targetLanguageChanged": 0,
|
||||
"deniedTranslationOffer": 3,
|
||||
"autoRejectedTranlationOffer": 1,
|
||||
"showOriginalContent": 2,
|
||||
"translationOpportunityCountsByLanguage": {
|
||||
"fr": 100,
|
||||
|
Loading…
Reference in New Issue
Block a user