[gnome-shell/T27795: 93/138] viewSelector: Record metric when user initiates a desktop search
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/T27795: 93/138] viewSelector: Record metric when user initiates a desktop search
- Date: Tue, 1 Oct 2019 23:37:08 +0000 (UTC)
commit e10d68e07ad7bc8b4431dcc28beccbfd801b7c1d
Author: Mario Sanchez Prada <mario endlessm com>
Date: Thu Jun 15 15:13:31 2017 +0100
viewSelector: Record metric when user initiates a desktop search
js/ui/viewSelector.js | 43 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 881affea00..a8f77158c7 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -1,7 +1,8 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported ViewSelector */
-const { Clutter, Gio, GLib, GObject, Meta, Shell, St } = imports.gi;
+const { EosMetrics, Clutter, Gio,
+ GLib, GObject, Meta, Shell, St } = imports.gi;
const Signals = imports.signals;
const AppDisplay = imports.ui.appDisplay;
@@ -21,6 +22,20 @@ var PINCH_GESTURE_THRESHOLD = 0.7;
const SEARCH_ACTIVATION_TIMEOUT = 50;
+const SEARCH_METRIC_INACTIVITY_TIMEOUT_SECONDS = 3;
+
+// Occurs when a user initiates a search from the desktop. The payload, with
+// type `(us)`, consists of an enum value from the DesktopSearchProvider enum
+// telling what kind of search was requested; followed by the search query.
+const EVENT_DESKTOP_SEARCH = 'b02266bc-b010-44b2-ae0f-8f116ffa50eb';
+
+// Represents the various search providers that can be used for searching from
+// the desktop. Keep in sync with the corresponding enum in
+//
https://github.com/endlessm/eos-analytics/tree/master/src/main/java/com/endlessm/postprocessing/query/SearchQuery.java.
+const DesktopSearchProvider = {
+ MY_COMPUTER: 0,
+};
+
var ViewPage = {
WINDOWS: 1,
APPS: 2
@@ -326,6 +341,7 @@ class ViewsDisplayContainer extends St.Widget {
var ViewsDisplay = class {
constructor() {
this._enterSearchTimeoutId = 0;
+ this._localSearchMetricTimeoutId = 0;
this._appDisplay = new AppDisplay.AppDisplay()
@@ -365,6 +381,12 @@ var ViewsDisplay = class {
this.actor = new ViewsDisplayContainer(this.entry, this._appDisplay, this._searchResults);
}
+ _recordDesktopSearchMetric(query, searchProvider) {
+ let eventRecorder = EosMetrics.EventRecorder.get_default();
+ let auxiliaryPayload = new GLib.Variant('(us)', [searchProvider, query]);
+ eventRecorder.record_event(EVENT_DESKTOP_SEARCH, auxiliaryPayload);
+ }
+
_updateSpinner() {
this.entry.setSpinning(this._searchResults.searchInProgress);
}
@@ -418,6 +440,25 @@ var ViewsDisplay = class {
_onSearchTermsChanged() {
let terms = this.entry.getSearchTerms();
this._searchResults.setTerms(terms);
+
+ // Since the search is live, only record a metric a few seconds after
+ // the user has stopped typing. Don't record one if the user deleted
+ // what they wrote and left it at that.
+ if (this._localSearchMetricTimeoutId > 0)
+ GLib.source_remove(this._localSearchMetricTimeoutId);
+
+ this._localSearchMetricTimeoutId = GLib.timeout_add_seconds(
+ GLib.PRIORITY_DEFAULT,
+ SEARCH_METRIC_INACTIVITY_TIMEOUT_SECONDS,
+ () => {
+ let query = terms.join(' ');
+ if (query !== '')
+ this._recordDesktopSearchMetric(query,
+ DesktopSearchProvider.MY_COMPUTER);
+ this._localSearchMetricTimeoutId = 0;
+ return GLib.SOURCE_REMOVE;
+ }
+ );
}
_resetSearch() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]