Add the new UMA key 'Translate.LocalesOnDisabledByPrefs'.

This logs the user locale when the Translate feature is disabled by the user. This allows us to investigate the correlation between the user locale and the usage rates of the Translate.

I'll commit this CL after https://chromiumcodereview.appspot.com/15311006/ is committed.

BUG=242142

Review URL: https://chromiumcodereview.appspot.com/15970002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203113 0039d316-1c4b-4281-b951-d872f2087c98
parent 983a57bd
......@@ -392,6 +392,8 @@ void TranslateManager::InitiateTranslation(WebContents* web_contents,
if (!prefs->GetBoolean(prefs::kEnableTranslate)) {
TranslateManagerMetrics::ReportInitiationStatus(
TranslateManagerMetrics::INITIATION_STATUS_DISABLED_BY_PREFS);
const std::string& locale = g_browser_process->GetApplicationLocale();
TranslateManagerMetrics::ReportLocalesOnDisabledByPrefs(locale);
return;
}
......
......@@ -23,6 +23,8 @@ const char kTranslateServerReportedUnsupportedLanguage[] =
"Translate.ServerReportedUnsupportedLanguage";
const char kTranslateUnsupportedLanguageAtInitiation[] =
"Translate.UnsupportedLanguageAtInitiation";
const char kTranslateLocalesOnDisabledByPrefs[] =
"Translate.LocalesOnDisabledByPrefs";
struct MetricsEntry {
TranslateManagerMetrics::MetricsNameIndex index;
......@@ -39,6 +41,8 @@ const MetricsEntry kMetricsEntries[] = {
kTranslateServerReportedUnsupportedLanguage },
{ TranslateManagerMetrics::UMA_UNSUPPORTED_LANGUAGE_AT_INITIATION,
kTranslateUnsupportedLanguageAtInitiation },
{ TranslateManagerMetrics::UMA_LOCALES_ON_DISABLED_BY_PREFS,
kTranslateLocalesOnDisabledByPrefs },
};
COMPILE_ASSERT(arraysize(kMetricsEntries) == TranslateManagerMetrics::UMA_MAX,
......@@ -68,6 +72,11 @@ void ReportUnsupportedLanguageAtInitiation(const std::string& language) {
language_code);
}
void ReportLocalesOnDisabledByPrefs(const std::string& locale) {
UMA_HISTOGRAM_SPARSE_SLOWLY(kTranslateLocalesOnDisabledByPrefs,
LanguageUsageMetrics::ToLanguageCode(locale));
}
const char* GetMetricsName(MetricsNameIndex index) {
for (size_t i = 0; i < arraysize(kMetricsEntries); ++i) {
if (kMetricsEntries[i].index == index)
......
......@@ -16,6 +16,7 @@ enum MetricsNameIndex {
UMA_LANGUAGE_DETECTION_ERROR,
UMA_SERVER_REPORTED_UNSUPPORTED_LANGUAGE,
UMA_UNSUPPORTED_LANGUAGE_AT_INITIATION,
UMA_LOCALES_ON_DISABLED_BY_PREFS,
UMA_MAX,
};
......@@ -49,6 +50,8 @@ void ReportUnsupportedLanguage();
void ReportUnsupportedLanguageAtInitiation(const std::string& language);
void ReportLocalesOnDisabledByPrefs(const std::string& locale);
// Provides UMA entry names for unit tests.
const char* GetMetricsName(MetricsNameIndex index);
......
......@@ -169,3 +169,13 @@ TEST(TranslateManagerMetricsTest, ReportedUnsupportedLanguageAtInitiation) {
TranslateManagerMetrics::ReportUnsupportedLanguageAtInitiation("en");
EXPECT_EQ(1, recorder.GetCount(ENGLISH));
}
TEST(TranslateManagerMetricsTest, ReportedLocalesOnDisabledByPrefs) {
const int ENGLISH = 25966;
MetricsRecorder recorder(TranslateManagerMetrics::GetMetricsName(
TranslateManagerMetrics::UMA_LOCALES_ON_DISABLED_BY_PREFS));
EXPECT_EQ(0, recorder.GetTotalCount());
TranslateManagerMetrics::ReportLocalesOnDisabledByPrefs("en");
EXPECT_EQ(1, recorder.GetCount(ENGLISH));
}
......@@ -9407,6 +9407,15 @@ other types of suffix sets.
</summary>
</histogram>
<histogram name="Translate.LocalesOnDisabledByPrefs" enum="LanguageCode">
<summary>
Logs the user locale when the Translate feature is disabled by the user.
This is recorded each time a webpage is loaded and prefs for translation is
checked. This allows us to investigate the correlation between the user
locale and the usage rates of the Translate.
</summary>
</histogram>
<histogram name="Translate.PageScheme" enum="TranslateScheme">
<summary>Counts translation target page schemes.</summary>
</histogram>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment