summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2019-07-29 09:58:58 +0000
committerPaul Slaughter <pslaughter@gitlab.com>2019-07-29 09:58:58 +0000
commit26e9efc011c49b6918d4cc345a3328cabf22e2a7 (patch)
tree15076bcd7636cc4efc1421853245196a12fc2bdc /app
parent77926ea02512d836c61a30e3986902e2d8e7f886 (diff)
downloadgitlab-ce-26e9efc011c49b6918d4cc345a3328cabf22e2a7.tar.gz
Added navbar searches usage ping counter
Added usage ping counter when the user makes a search through the navbar search component.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/search_controller.rb8
-rw-r--r--app/views/layouts/_search.html.haml1
2 files changed, 9 insertions, 0 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index 8c674be58c5..13741548687 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -31,6 +31,8 @@ class SearchController < ApplicationController
render_commits if @scope == 'commits'
eager_load_user_status if @scope == 'users'
+ increment_navbar_searches_counter
+
check_single_commit_result
end
@@ -70,4 +72,10 @@ class SearchController < ApplicationController
redirect_to project_commit_path(@project, only_commit) if found_by_commit_sha
end
end
+
+ def increment_navbar_searches_counter
+ return if params[:nav_source] != 'navbar'
+
+ Gitlab::UsageDataCounters::SearchCounter.increment_navbar_searches_count
+ end
end
diff --git a/app/views/layouts/_search.html.haml b/app/views/layouts/_search.html.haml
index c62dce880c0..9cac8266eaf 100644
--- a/app/views/layouts/_search.html.haml
+++ b/app/views/layouts/_search.html.haml
@@ -45,5 +45,6 @@
- if @snippet || @snippets
= hidden_field_tag :snippets, true
= hidden_field_tag :repository_ref, @ref
+ = hidden_field_tag :nav_source, 'navbar'
= button_tag 'Go' if ENV['RAILS_ENV'] == 'test'
.search-autocomplete-opts.hide{ :'data-autocomplete-path' => search_autocomplete_path, :'data-autocomplete-project-id' => @project.try(:id), :'data-autocomplete-project-ref' => @ref }