Commit cbf4c4c6 authored by John Mason's avatar John Mason Committed by Dylan Griffith

Track git blame clicks from code search results

Changelog: changed
parent 3235302b
......@@ -10,7 +10,13 @@
.line-numbers
.gl-display-flex
%span.diff-line-num.gl-pl-3
%a.has-tooltip{ href: "#{blame_link}#L#{i}", id: "blame-L#{i}", 'data-line-number' => i, title: _('View blame') }
%a.has-tooltip{ href: "#{blame_link}#L#{i}",
id: "blame-L#{i}",
data: { "line_number" => i,
"track_action" => 'click_link',
"track_label" => 'git_blame',
"track_property" => 'search_result' },
title: _('View blame') }
= sprite_icon('git')
%span.diff-line-num.flex-grow-1.gl-pr-3
%a{ href: "#{blob_link}#L#{i}", id: "blob-L#{i}", 'data-line-number' => i, class: 'gl-display-flex! gl-align-items-center gl-justify-content-end' }
......
......@@ -96,6 +96,31 @@ RSpec.describe 'search/_results' do
end
end
describe 'git blame click tracking' do
let(:scope) { 'blobs' }
let(:search_objects) { Gitlab::ProjectSearchResults.new(user, 'testing', project: project).objects(scope) }
context 'when admin mode is enabled', :enable_admin_mode do
it 'renders the click link event tracking attributes' do
render
expect(rendered).to have_selector('[data-track-action=click_link]')
expect(rendered).to have_selector('[data-track-label=git_blame]')
expect(rendered).to have_selector('[data-track-property=search_result]')
end
end
context 'when admin mode is disabled' do
it 'does not render the click link event tracking attributes' do
render
expect(rendered).not_to have_selector('[data-track-action=click_link]')
expect(rendered).not_to have_selector('[data-track-label=git_blame]')
expect(rendered).not_to have_selector('[data-track-property=search_result]')
end
end
end
%w[blobs notes wiki_blobs milestones].each do |search_scope|
context "when scope is #{search_scope}" do
let(:scope) { search_scope }
......
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