Bug 1202196 Add UI Telemetry for search history items.r=mfinkle

This commit is contained in:
Allison Naaktgeboren 2015-09-15 18:58:52 -07:00
parent e5b5818a44
commit 62bd879168

View File

@ -98,8 +98,7 @@ class SearchEngineRow extends AnimatedHeightLayout {
if (v == mUserEnteredView) {
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.SUGGESTION, "user");
} else {
final String extras = "engine." + (String) v.getTag();
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.SUGGESTION, extras);
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.SUGGESTION, (String) v.getTag());
}
mSearchListener.onSearch(mSearchEngine, suggestion);
}
@ -184,7 +183,7 @@ class SearchEngineRow extends AnimatedHeightLayout {
mEditSuggestionListener = listener;
}
private void bindSuggestionView(String suggestion, boolean animate, int recycledSuggestionCount, Integer previousSuggestionChildIndex, boolean isUserSavedSearch){
private void bindSuggestionView(String suggestion, boolean animate, int recycledSuggestionCount, Integer previousSuggestionChildIndex, boolean isUserSavedSearch, String telemetryTag){
final View suggestionItem;
// Reuse suggestion views from recycled view, if possible.
@ -197,8 +196,7 @@ class SearchEngineRow extends AnimatedHeightLayout {
suggestionItem.setOnClickListener(mClickListener);
suggestionItem.setOnLongClickListener(mLongClickListener);
// Store the position of the suggestion for telemetry.
suggestionItem.setTag(String.valueOf(previousSuggestionChildIndex));
suggestionItem.setTag(telemetryTag);
mSuggestionView.addView(suggestionItem);
}
@ -227,9 +225,13 @@ class SearchEngineRow extends AnimatedHeightLayout {
try {
if (c.moveToFirst()) {
final int searchColumn = c.getColumnIndexOrThrow(SearchHistory.QUERY);
final int historyStartIndex = suggestionCounter;
do {
final String savedSearch = c.getString(searchColumn);
bindSuggestionView(savedSearch, animate, recycledSuggestionCount, suggestionCounter, true);
// suggestionCounter counts all suggestions (from history and the search engine)
// but we want the relative position of the history item in telemetry
String telemetryTag = "history." + (suggestionCounter - historyStartIndex);
bindSuggestionView(savedSearch, animate, recycledSuggestionCount, suggestionCounter, true, telemetryTag);
++suggestionCounter;
} while (c.moveToNext());
}
@ -266,12 +268,13 @@ class SearchEngineRow extends AnimatedHeightLayout {
}
}
int suggestionCounter = 0;
// Apply Search Engine's suggestions
for (String suggestion : mSearchEngine.getSuggestions()) {
if (suggestionCounter == limit) {
break;
}
bindSuggestionView(suggestion, animate, recycledSuggestionCount, suggestionCounter, false);
// Since the search engine suggestions are listed first, we can use suggestionCounter to get their relative positions for telemetry
String telemetryTag = "engine." + suggestionCounter;
bindSuggestionView(suggestion, animate, recycledSuggestionCount, suggestionCounter, false, telemetryTag);
++suggestionCounter;
}