mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1036908 - Log search suggestion selections from about:home. r=mak
This commit is contained in:
parent
a69eb963ba
commit
fe4298b751
@ -298,16 +298,28 @@ function ensureSnippetsMapThen(aCallback)
|
||||
|
||||
function onSearchSubmit(aEvent)
|
||||
{
|
||||
let searchTerms = document.getElementById("searchText").value;
|
||||
let searchText = document.getElementById("searchText");
|
||||
let searchTerms = searchText.value;
|
||||
let engineName = document.documentElement.getAttribute("searchEngineName");
|
||||
|
||||
if (engineName && searchTerms.length > 0) {
|
||||
// Send an event that will perform a search and Firefox Health Report will
|
||||
// record that a search from about:home has occurred.
|
||||
let eventData = JSON.stringify({
|
||||
|
||||
let eventData = {
|
||||
engineName: engineName,
|
||||
searchTerms: searchTerms
|
||||
});
|
||||
};
|
||||
|
||||
if (searchText.hasAttribute("selection-index")) {
|
||||
eventData.selection = {
|
||||
index: searchText.getAttribute("selection-index"),
|
||||
kind: searchText.getAttribute("selection-kind")
|
||||
};
|
||||
}
|
||||
|
||||
eventData = JSON.stringify(eventData);
|
||||
|
||||
let event = new CustomEvent("AboutHomeSearchEvent", {detail: eventData});
|
||||
document.dispatchEvent(event);
|
||||
}
|
||||
|
@ -3122,9 +3122,13 @@ const BrowserSearch = {
|
||||
* @param source
|
||||
* (string) Where the search originated from. See the FHR
|
||||
* SearchesProvider for allowed values.
|
||||
* @param selection [optional]
|
||||
* ({index: The selected index, kind: "key" or "mouse"}) If
|
||||
* the search was a suggested search, this indicates where the
|
||||
* item was in the suggestion list and how the user selected it.
|
||||
*/
|
||||
recordSearchInHealthReport: function (engine, source) {
|
||||
BrowserUITelemetry.countSearchEvent(source);
|
||||
recordSearchInHealthReport: function (engine, source, selection) {
|
||||
BrowserUITelemetry.countSearchEvent(source, null, selection);
|
||||
#ifdef MOZ_SERVICES_HEALTHREPORT
|
||||
let reporter = Cc["@mozilla.org/datareporting/service;1"]
|
||||
.getService()
|
||||
|
@ -179,6 +179,13 @@ SearchSuggestionUIController.prototype = {
|
||||
case event.DOM_VK_RETURN:
|
||||
if (this.selectedIndex >= 0) {
|
||||
this.input.value = this.suggestionAtIndex(this.selectedIndex);
|
||||
this.input.setAttribute("selection-index", this.selectedIndex);
|
||||
this.input.setAttribute("selection-kind", "key");
|
||||
} else {
|
||||
// If we didn't select anything, make sure to remove the attributes
|
||||
// in case they were populated last time.
|
||||
this.input.removeAttribute("selection-index");
|
||||
this.input.removeAttribute("selection-kind");
|
||||
}
|
||||
this._stickyInputValue = this.input.value;
|
||||
this._hideSuggestions();
|
||||
@ -228,6 +235,8 @@ SearchSuggestionUIController.prototype = {
|
||||
let suggestion = this.suggestionAtIndex(idx);
|
||||
this._stickyInputValue = suggestion;
|
||||
this.input.value = suggestion;
|
||||
this.input.setAttribute("selection-index", idx);
|
||||
this.input.setAttribute("selection-kind", "mouse");
|
||||
this._hideSuggestions();
|
||||
if (this.onClick) {
|
||||
this.onClick.call(null);
|
||||
|
@ -71,6 +71,17 @@ object with the following properties:
|
||||
- ``move`` counts the number of times an item is moved somewhere else (but not to the palette);
|
||||
- ``remove`` counts the number of times an item is removed to the palette;
|
||||
- ``reset`` counts the number of times the 'restore defaults' button is used;
|
||||
- ``search`` is an object tracking searches of various types, keyed off the search
|
||||
location, storing a number indicating how often the respective type of search
|
||||
has happened.
|
||||
- There are also two special keys that mean slightly different things.
|
||||
- ``urlbar-keyword`` records searches that would have been an invalid-protocol
|
||||
error, but are now keyword searches. They are also counted in the ``urlbar``
|
||||
keyword (along with all the other urlbar searches).
|
||||
- ``selection`` searches records selections of search suggestions. They include
|
||||
the source, the index of the selection, and the kind of selection (mouse or
|
||||
enter key). Selection searches are also counted in their sources.
|
||||
|
||||
|
||||
|
||||
``UITour``
|
||||
|
@ -191,7 +191,7 @@ let AboutHome = {
|
||||
|
||||
let engine = Services.search.currentEngine;
|
||||
#ifdef MOZ_SERVICES_HEALTHREPORT
|
||||
window.BrowserSearch.recordSearchInHealthReport(engine, "abouthome");
|
||||
window.BrowserSearch.recordSearchInHealthReport(engine, "abouthome", data.selection);
|
||||
#endif
|
||||
// Trigger a search through nsISearchEngine.getSubmission()
|
||||
let submission = engine.getSubmission(data.searchTerms, null, "homepage");
|
||||
|
@ -554,11 +554,14 @@ this.BrowserUITelemetry = {
|
||||
this._countEvent(["customize", aEventType]);
|
||||
},
|
||||
|
||||
countSearchEvent: function(source, query) {
|
||||
countSearchEvent: function(source, query, selection) {
|
||||
this._countEvent(["search", source]);
|
||||
if ((/^[a-zA-Z]+:[^\/\\]/).test(query)) {
|
||||
this._countEvent(["search", "urlbar-keyword"]);
|
||||
}
|
||||
if (selection) {
|
||||
this._countEvent(["search", "selection", source, selection.index, selection.kind]);
|
||||
}
|
||||
},
|
||||
|
||||
_durations: {
|
||||
|
@ -206,7 +206,7 @@ this.ContentSearch = {
|
||||
]);
|
||||
let browserWin = msg.target.ownerDocument.defaultView;
|
||||
let engine = Services.search.getEngineByName(data.engineName);
|
||||
browserWin.BrowserSearch.recordSearchInHealthReport(engine, data.whence);
|
||||
browserWin.BrowserSearch.recordSearchInHealthReport(engine, data.whence, data.selection);
|
||||
let submission = engine.getSubmission(data.searchString, "", data.whence);
|
||||
browserWin.loadURI(submission.uri.spec, null, submission.postData);
|
||||
return Promise.resolve();
|
||||
|
Loading…
Reference in New Issue
Block a user