Bug 1805717: Introduce search_mode property. r=mak,jteow

Differential Revision: https://phabricator.services.mozilla.com/D164794
This commit is contained in:
Daisuke Akatsuka
2022-12-20 07:10:11 +00:00
parent 75d6d575cc
commit 4b4fa32e15
9 changed files with 406 additions and 10 deletions

View File

@@ -957,6 +957,7 @@ class TelemetryEvent {
searchWords,
provider: details.provider,
searchSource: details.searchSource,
searchMode: details.searchMode,
selectedElement: details.element,
selIndex: details.selIndex,
selType: details.selType,
@@ -1040,6 +1041,7 @@ class TelemetryEvent {
reason,
searchWords,
searchSource,
searchMode,
selectedElement,
selIndex,
selType,
@@ -1057,14 +1059,17 @@ class TelemetryEvent {
sap = "urlbar_addonpage";
}
searchMode = searchMode ?? this._controller.input.searchMode;
// Distinguish user typed search strings from persisted search terms.
const interaction = this.#getInteractionType(
method,
startEventInfo,
searchSource,
searchWords
searchWords,
searchMode
);
const search_mode = this.#getSearchMode(searchMode);
const currentResults = queryContext?.results ?? [];
const numResults = currentResults.length;
const groups = currentResults
@@ -1080,6 +1085,7 @@ class TelemetryEvent {
eventInfo = {
sap,
interaction,
search_mode,
n_chars: numChars,
n_words: numWords,
n_results: numResults,
@@ -1100,6 +1106,7 @@ class TelemetryEvent {
eventInfo = {
sap,
interaction,
search_mode,
n_chars: numChars,
n_words: numWords,
n_results: numResults,
@@ -1111,6 +1118,7 @@ class TelemetryEvent {
reason,
sap,
interaction,
search_mode,
n_chars: numChars,
n_words: numWords,
n_results: numResults,
@@ -1131,8 +1139,14 @@ class TelemetryEvent {
}
}
#getInteractionType(method, startEventInfo, searchSource, searchWords) {
if (this._controller.input.searchMode?.entry === "topsites_newtab") {
#getInteractionType(
method,
startEventInfo,
searchSource,
searchWords,
searchMode
) {
if (searchMode?.entry === "topsites_newtab") {
return "topsite_search";
}
@@ -1171,6 +1185,21 @@ class TelemetryEvent {
return interaction;
}
#getSearchMode(searchMode) {
if (!searchMode) {
return "";
}
if (searchMode.engineName) {
return "search_engine";
}
const source = lazy.UrlbarUtils.LOCAL_SEARCH_MODES.find(
m => m.source == searchMode.source
)?.telemetryLabel;
return source ?? "unknown";
}
_parseSearchString(searchString) {
let numChars = searchString.length.toString();
let searchWords = searchString