Commit c5df989a authored by Jing Wang's avatar Jing Wang Committed by Chromium LUCI CQ

Add NotAllowed and InsufficientData metrics for assistive features.

Bug: 1156385
Test: passed unit tests and browser tests.
Change-Id: Iae354b3c46757441ff1cf7f52cd715f831a0213e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2577113Reviewed-by: default avatarJohn Palmer <jopalmer@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Commit-Queue: Jing Wang <jiwan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835879}
parent 8e6a549a
...@@ -130,6 +130,10 @@ void RecordAssistiveUserPrefForEmoji(bool value) { ...@@ -130,6 +130,10 @@ void RecordAssistiveUserPrefForEmoji(bool value) {
base::UmaHistogramBoolean("InputMethod.Assistive.UserPref.Emoji", value); base::UmaHistogramBoolean("InputMethod.Assistive.UserPref.Emoji", value);
} }
void RecordAssistiveNotAllowed(AssistiveType type) {
base::UmaHistogramEnumeration("InputMethod.Assistive.NotAllowed", type);
}
void RecordAssistiveCoverage(AssistiveType type) { void RecordAssistiveCoverage(AssistiveType type) {
base::UmaHistogramEnumeration("InputMethod.Assistive.Coverage", type); base::UmaHistogramEnumeration("InputMethod.Assistive.Coverage", type);
} }
...@@ -338,8 +342,11 @@ bool AssistiveSuggester::OnKeyEvent(const ui::KeyEvent& event) { ...@@ -338,8 +342,11 @@ bool AssistiveSuggester::OnKeyEvent(const ui::KeyEvent& event) {
void AssistiveSuggester::RecordAssistiveMatchMetricsForAction( void AssistiveSuggester::RecordAssistiveMatchMetricsForAction(
AssistiveType action) { AssistiveType action) {
RecordAssistiveMatch(action); RecordAssistiveMatch(action);
if (!IsActionEnabled(action)) if (!IsActionEnabled(action)) {
RecordAssistiveDisabled(action); RecordAssistiveDisabled(action);
} else if (!IsAllowedUrlOrAppForEmojiSuggestion()) {
RecordAssistiveNotAllowed(action);
}
} }
void AssistiveSuggester::RecordAssistiveMatchMetrics(const base::string16& text, void AssistiveSuggester::RecordAssistiveMatchMetrics(const base::string16& text,
......
...@@ -493,12 +493,22 @@ IN_PROC_BROWSER_TEST_F(NativeInputMethodEngineTest, ...@@ -493,12 +493,22 @@ IN_PROC_BROWSER_TEST_F(NativeInputMethodEngineTest,
PersonalInfoDisabledReasonkUrlOrAppNotAllowed) { PersonalInfoDisabledReasonkUrlOrAppNotAllowed) {
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
histogram_tester.ExpectUniqueSample(
"InputMethod.Assistive.Disabled.PersonalInfo",
DisabledReason::kUrlOrAppNotAllowed, 0);
histogram_tester.ExpectUniqueSample("InputMethod.Assistive.NotAllowed",
chromeos::AssistiveType::kPersonalName,
0);
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
ui_test_utils::SendToOmniboxAndSubmit(browser(), "my name is "); ui_test_utils::SendToOmniboxAndSubmit(browser(), "my name is ");
histogram_tester.ExpectUniqueSample( histogram_tester.ExpectUniqueSample(
"InputMethod.Assistive.Disabled.PersonalInfo", "InputMethod.Assistive.Disabled.PersonalInfo",
DisabledReason::kUrlOrAppNotAllowed, 1); DisabledReason::kUrlOrAppNotAllowed, 1);
histogram_tester.ExpectUniqueSample("InputMethod.Assistive.NotAllowed",
chromeos::AssistiveType::kPersonalName,
1);
} }
IN_PROC_BROWSER_TEST_F(NativeInputMethodEngineTest, SuggestEmoji) { IN_PROC_BROWSER_TEST_F(NativeInputMethodEngineTest, SuggestEmoji) {
......
...@@ -93,6 +93,10 @@ void RecordTimeToDismiss(base::TimeDelta delta) { ...@@ -93,6 +93,10 @@ void RecordTimeToDismiss(base::TimeDelta delta) {
delta); delta);
} }
void RecordAssistiveInsufficientData(AssistiveType type) {
base::UmaHistogramEnumeration("InputMethod.Assistive.InsufficientData", type);
}
} // namespace } // namespace
AssistiveType ProposePersonalInfoAssistiveAction(const base::string16& text) { AssistiveType ProposePersonalInfoAssistiveAction(const base::string16& text) {
...@@ -253,8 +257,12 @@ bool PersonalInfoSuggester::Suggest(const base::string16& text) { ...@@ -253,8 +257,12 @@ bool PersonalInfoSuggester::Suggest(const base::string16& text) {
return matched; return matched;
} else { } else {
suggestion_ = GetSuggestion(text); suggestion_ = GetSuggestion(text);
if (!suggestion_.empty()) if (suggestion_.empty()) {
if (proposed_action_type_ != AssistiveType::kGenericAction)
RecordAssistiveInsufficientData(proposed_action_type_);
} else {
ShowSuggestion(suggestion_, 0); ShowSuggestion(suggestion_, 0);
}
return suggestion_shown_; return suggestion_shown_;
} }
} }
......
...@@ -293,6 +293,26 @@ TEST_F(PersonalInfoSuggesterTest, SuggestNames) { ...@@ -293,6 +293,26 @@ TEST_F(PersonalInfoSuggesterTest, SuggestNames) {
suggestion_handler_->VerifySuggestion(full_name_, 0); suggestion_handler_->VerifySuggestion(full_name_, 0);
} }
TEST_F(PersonalInfoSuggesterTest, SuggestNamesButInsufficientData) {
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures(
/*enabled_features=*/{chromeos::features::kAssistPersonalInfoName},
/*disabled_features=*/{});
autofill::AutofillProfile autofill_profile(base::GenerateGUID(),
autofill::test::kEmptyOrigin);
personal_data_->AddProfile(autofill_profile);
base::HistogramTester histogram_tester;
histogram_tester.ExpectUniqueSample("InputMethod.Assistive.InsufficientData",
chromeos::AssistiveType::kPersonalName,
0);
suggester_->Suggest(base::UTF8ToUTF16("my name is "));
histogram_tester.ExpectUniqueSample("InputMethod.Assistive.InsufficientData",
chromeos::AssistiveType::kPersonalName,
1);
}
TEST_F(PersonalInfoSuggesterTest, DoNotSuggestNamesWhenFlagIsDisabled) { TEST_F(PersonalInfoSuggesterTest, DoNotSuggestNamesWhenFlagIsDisabled) {
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures( feature_list.InitWithFeatures(
......
...@@ -121,6 +121,17 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -121,6 +121,17 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary> </summary>
</histogram> </histogram>
<histogram name="InputMethod.Assistive.InsufficientData"
enum="IMEAssistiveAction" expires_after="2021-05-16">
<owner>jiwan@google.com</owner>
<owner>essential-inputs-team@google.com</owner>
<summary>
The number of times each assistive action could be triggered but there is
insufficient data to generate the suggestion. Recorded when we failed to
generate suggestions because of insufficient data.
</summary>
</histogram>
<histogram name="InputMethod.Assistive.Match" enum="IMEAssistiveAction" <histogram name="InputMethod.Assistive.Match" enum="IMEAssistiveAction"
expires_after="2021-05-16"> expires_after="2021-05-16">
<owner>jiwan@google.com</owner> <owner>jiwan@google.com</owner>
...@@ -134,6 +145,18 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -134,6 +145,18 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary> </summary>
</histogram> </histogram>
<histogram name="InputMethod.Assistive.NotAllowed" enum="IMEAssistiveAction"
expires_after="2021-05-16">
<owner>jiwan@google.com</owner>
<owner>essential-inputs-team@google.com</owner>
<summary>
The number of times each assistive action could be triggered but is blocked
because the text is not in the allowed websites or apps. Recorded when the
assistive action is blocked because the text is not in the allowed websites
or apps.
</summary>
</histogram>
<histogram name="InputMethod.Assistive.Success" enum="IMEAssistiveAction" <histogram name="InputMethod.Assistive.Success" enum="IMEAssistiveAction"
expires_after="2021-05-16"> expires_after="2021-05-16">
<owner>jiwan@google.com</owner> <owner>jiwan@google.com</owner>
......
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