Commit 8cc902d9 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch '240731-analytics-for-clicking-search-results' into 'master'

Add snowplow analytics for clicking search result

Closes #240731

See merge request gitlab-org/gitlab!40230
parents 4caf2b75 1409112e
......@@ -11,6 +11,7 @@
- commit = commit.present(current_user: current_user)
- commit_status = commit.status_for(ref)
- collapsible = local_assigns.fetch(:collapsible, true)
- link_data_attrs = local_assigns.fetch(:link_data_attrs, {})
- link = commit_path(project, commit, merge_request: merge_request)
......@@ -26,7 +27,7 @@
- if view_details && merge_request
= link_to commit.title, project_commit_path(project, commit.id, merge_request_iid: merge_request.iid), class: ["commit-row-message item-title js-onboarding-commit-item", ("font-italic" if commit.message.empty?)]
- else
= link_to_markdown_field(commit, :title, link, class: "commit-row-message item-title js-onboarding-commit-item #{"font-italic" if commit.message.empty?}")
= link_to_markdown_field(commit, :title, link, class: "commit-row-message item-title js-onboarding-commit-item #{"font-italic" if commit.message.empty?}", data: link_data_attrs)
%span.commit-row-message.d-inline.d-sm-none
·
= commit.short_id
......
.blob-result{ data: { qa_selector: 'result_item_content' } }
.file-holder
.js-file-title.file-title{ data: { qa_selector: 'file_title_content' } }
= link_to blob_link do
= link_to blob_link, data: {track_event: 'click_text', track_label: 'blob_path', track_property: 'search_result'} do
%i.fa.fa-file
%strong
= search_blob_title(project, path)
......
= render 'projects/commits/commit', project: commit.project, commit: commit, ref: nil, show_project_name: @project.nil?
= render 'projects/commits/commit', project: commit.project, commit: commit, ref: nil, show_project_name: @project.nil?, link_data_attrs: {track_event: 'click_text', track_label: 'commit_title', track_property: 'search_result'}
.search-result-row
%h4
= confidential_icon(issue)
= link_to project_issue_path(issue.project, issue) do
= link_to project_issue_path(issue.project, issue), data: {track_event: 'click_text', track_label: 'issue_title', track_property: 'search_result'} do
%span.term.str-truncated= issue.title
- if issue.closed?
%span.badge.badge-danger.gl-ml-2= _("Closed")
......
.search-result-row
%h4
= link_to project_merge_request_path(merge_request.target_project, merge_request) do
= link_to project_merge_request_path(merge_request.target_project, merge_request), data: {track_event: 'click_text', track_label: 'merge_request_title', track_property: 'search_result'} do
%span.term.str-truncated= merge_request.title
- if merge_request.merged?
%span.badge.badge-primary.gl-ml-2= _("Merged")
......
.search-result-row
%h4
= link_to project_milestone_path(milestone.project, milestone) do
= link_to project_milestone_path(milestone.project, milestone), data: {track_event: 'click_text', track_label: 'milestone_title', track_property: 'search_result'} do
%span.term.str-truncated= milestone.title
- if milestone.description.present?
......
......@@ -18,7 +18,7 @@
- else
%span #{note.noteable_type.titleize} ##{noteable_identifier}
·
= link_to note.noteable.title, note_url
= link_to note.noteable.title, note_url, data: {track_event: 'click_text', track_label: 'noteable_title', track_property: 'search_result'}
.note-search-result
.term
......
......@@ -3,13 +3,16 @@
require 'spec_helper'
RSpec.describe 'search/_results' do
let(:search_objects) { Issue.page(1).per(2) }
let(:scope) { 'issues' }
before do
controller.params[:action] = 'show'
create_list(:issue, 3)
@search_objects = Issue.page(1).per(2)
@scope = 'issues'
@search_objects = search_objects
@scope = scope
@search_term = 'foo'
end
......@@ -30,4 +33,28 @@ RSpec.describe 'search/_results' do
expect(rendered).not_to have_content(/Showing .* of .*/)
end
end
context 'rendering all types of search results' do
let_it_be(:project) { create(:project, :repository, :wiki_repo) }
let_it_be(:issue) { create(:issue, project: project, title: '*') }
let_it_be(:merge_request) { create(:merge_request, title: '*', source_project: project, target_project: project) }
let_it_be(:milestone) { create(:milestone, title: '*', project: project) }
let_it_be(:note) { create(:discussion_note_on_issue, project: project, note: '*') }
let_it_be(:wiki_blob) { create(:wiki_page, project: project, content: '*') }
let_it_be(:user) { create(:admin) }
%w[issues blobs notes wiki_blobs merge_requests milestones].each do |search_scope|
context "when scope is #{search_scope}" do
let(:scope) { search_scope }
let(:search_objects) { Gitlab::ProjectSearchResults.new(user, '*', project: project).objects(scope) }
it 'renders the click text event tracking attributes' do
render
expect(rendered).to have_selector('[data-track-event=click_text]')
expect(rendered).to have_selector('[data-track-property=search_result]')
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment