mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 977774 - Metric for tracking opts out of Instant Translation. r=felipe.
This commit is contained in:
parent
981b5e8a09
commit
31c04c3ee5
@ -311,6 +311,13 @@ let TranslationHealthReport = {
|
||||
this._withProvider(provider => provider.recordLanguageChange(beforeFirstTranslation));
|
||||
},
|
||||
|
||||
/**
|
||||
* Record a denied translation offer.
|
||||
*/
|
||||
recordDeniedTranslationOffer: function () {
|
||||
this._withProvider(provider => provider.recordDeniedTranslationOffer());
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieve the translation provider and pass it to the given function.
|
||||
*
|
||||
@ -369,6 +376,7 @@ TranslationMeasurement1.prototype = Object.freeze({
|
||||
pageTranslatedCountsByLanguage: DAILY_LAST_TEXT_FIELD,
|
||||
detectedLanguageChangedBefore: DAILY_COUNTER_FIELD,
|
||||
detectedLanguageChangedAfter: DAILY_COUNTER_FIELD,
|
||||
deniedTranslationOffer: DAILY_COUNTER_FIELD,
|
||||
detectLanguageEnabled: DAILY_LAST_NUMERIC_FIELD,
|
||||
showTranslationUI: DAILY_LAST_NUMERIC_FIELD,
|
||||
},
|
||||
@ -505,6 +513,15 @@ TranslationProvider.prototype = Object.freeze({
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
recordDeniedTranslationOffer: function () {
|
||||
let m = this.getMeasurement(TranslationMeasurement1.prototype.name,
|
||||
TranslationMeasurement1.prototype.version);
|
||||
|
||||
return this._enqueueTelemetryStorageTask(function* recordTask() {
|
||||
yield m.incrementDailyCounter("deniedTranslationOffer");
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
collectDailyData: function () {
|
||||
let m = this.getMeasurement(TranslationMeasurement1.prototype.name,
|
||||
TranslationMeasurement1.prototype.version);
|
||||
|
@ -196,6 +196,28 @@ add_task(function* test_record_translation() {
|
||||
yield storage.close();
|
||||
});
|
||||
|
||||
add_task(function* test_denied_translation_offer() {
|
||||
let storage = yield Metrics.Storage("translation");
|
||||
let provider = new TranslationProvider();
|
||||
yield provider.init(storage);
|
||||
let now = new Date();
|
||||
|
||||
yield provider.recordDeniedTranslationOffer();
|
||||
yield provider.recordDeniedTranslationOffer();
|
||||
|
||||
let m = provider.getMeasurement("translation", 1);
|
||||
let values = yield m.getValues();
|
||||
Assert.equal(values.days.size, 1);
|
||||
Assert.ok(values.days.hasDay(now));
|
||||
let day = values.days.getDay(now);
|
||||
|
||||
Assert.ok(day.has("deniedTranslationOffer"));
|
||||
Assert.equal(day.get("deniedTranslationOffer"), 2);
|
||||
|
||||
yield provider.shutdown();
|
||||
yield storage.close();
|
||||
});
|
||||
|
||||
add_task(function* test_collect_daily() {
|
||||
let storage = yield Metrics.Storage("translation");
|
||||
let provider = new TranslationProvider();
|
||||
@ -253,6 +275,8 @@ add_task(function* test_healthreporter_json() {
|
||||
yield provider.recordTranslationOpportunity("es", now);
|
||||
yield provider.recordTranslation("es", "en", 1000, now);
|
||||
|
||||
yield provider.recordDeniedTranslationOffer();
|
||||
|
||||
yield reporter.collectMeasurements();
|
||||
let payload = yield reporter.getJSONPayload(true);
|
||||
let today = reporter._formatDate(now);
|
||||
@ -285,6 +309,9 @@ add_task(function* test_healthreporter_json() {
|
||||
Assert.equal(translations["detectedLanguageChangedBefore"], 1);
|
||||
Assert.ok("detectedLanguageChangedAfter" in translations);
|
||||
Assert.equal(translations["detectedLanguageChangedAfter"], 1);
|
||||
|
||||
Assert.ok("deniedTranslationOffer" in translations);
|
||||
Assert.equal(translations["deniedTranslationOffer"], 1);
|
||||
} finally {
|
||||
reporter._shutdown();
|
||||
}
|
||||
@ -309,6 +336,8 @@ add_task(function* test_healthreporter_json2() {
|
||||
yield provider.recordTranslationOpportunity("es", now);
|
||||
yield provider.recordTranslation("es", "en", 1000, now);
|
||||
|
||||
yield provider.recordDeniedTranslationOffer();
|
||||
|
||||
yield reporter.collectMeasurements();
|
||||
let payload = yield reporter.getJSONPayload(true);
|
||||
let today = reporter._formatDate(now);
|
||||
@ -327,6 +356,7 @@ add_task(function* test_healthreporter_json2() {
|
||||
Assert.ok(!("pageTranslatedCountsByLanguage" in translations));
|
||||
Assert.ok(!("detectedLanguageChangedBefore" in translations));
|
||||
Assert.ok(!("detectedLanguageChangedAfter" in translations));
|
||||
Assert.ok(!("deniedTranslationOffer" in translations));
|
||||
} finally {
|
||||
reporter._shutdown();
|
||||
}
|
||||
|
@ -1556,6 +1556,10 @@ detectedLanguageChangedBefore
|
||||
detectedLanguageChangedAfter
|
||||
Integer count of the number of times the user manually adjusted the detected
|
||||
language after having first translated the page.
|
||||
deniedTranslationOffer
|
||||
Integer count of the numbers 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.
|
||||
|
||||
Additional daily counts broken down by language are reported in the following
|
||||
properties:
|
||||
@ -1592,6 +1596,7 @@ Example
|
||||
"charactersTranslatedCount": "1126",
|
||||
"detectedLanguageChangedBefore": 1,
|
||||
"detectedLanguageChangedAfter": 2,
|
||||
"deniedTranslationOffer": 3
|
||||
"translationOpportunityCountsByLanguage": {
|
||||
"fr": 100,
|
||||
"es": 34
|
||||
|
Loading…
Reference in New Issue
Block a user