Commit eb461157 authored by Doug Stull's avatar Doug Stull Committed by Phil Hughes

Add tracking for invite members experiment

- to measure how successful adding invite
  members link is to assignee dropdown
parent 4bd9f816
...@@ -43,10 +43,14 @@ ...@@ -43,10 +43,14 @@
- if experiment_enabled?(:invite_members_version_a) && can_import_members? - if experiment_enabled?(:invite_members_version_a) && can_import_members?
- options[:dropdown_class] += ' dropdown-extended-height' - options[:dropdown_class] += ' dropdown-extended-height'
- options[:footer_content] = true - options[:footer_content] = true
- options[:wrapper_class] = 'js-sidebar-assignee-dropdown'
= dropdown_tag(title, options: options) do = dropdown_tag(title, options: options) do
%ul.dropdown-footer-list %ul.dropdown-footer-list
%li %li
= link_to _('Invite Members'), project_project_members_path(@project), title: _('Invite Members'), :"data-is-link" => true = link_to _('Invite Members'),
project_project_members_path(@project),
title: _('Invite Members'),
data: { 'is-link': true, 'track-event': 'click_invite_members', 'track-label': 'edit_assignee' }
- else - else
= dropdown_tag(title, options: options) = dropdown_tag(title, options: options)
...@@ -2,6 +2,7 @@ import initSidebarBundle from 'ee/sidebar/sidebar_bundle'; ...@@ -2,6 +2,7 @@ import initSidebarBundle from 'ee/sidebar/sidebar_bundle';
import initRelatedIssues from 'ee/related_issues'; import initRelatedIssues from 'ee/related_issues';
import initShow from '~/pages/projects/issues/show'; import initShow from '~/pages/projects/issues/show';
import UserCallout from '~/user_callout'; import UserCallout from '~/user_callout';
import trackShowInviteMemberLink from 'ee/projects/track_invite_members';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
initShow(); initShow();
...@@ -14,4 +15,8 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -14,4 +15,8 @@ document.addEventListener('DOMContentLoaded', () => {
new UserCallout({ className: 'js-epics-sidebar-callout' }); new UserCallout({ className: 'js-epics-sidebar-callout' });
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new UserCallout({ className: 'js-weight-sidebar-callout' }); new UserCallout({ className: 'js-weight-sidebar-callout' });
const assigneeDropdown = document.querySelector('.js-sidebar-assignee-dropdown');
if (assigneeDropdown) trackShowInviteMemberLink(assigneeDropdown);
}); });
...@@ -2,6 +2,7 @@ import initSidebarBundle from 'ee/sidebar/sidebar_bundle'; ...@@ -2,6 +2,7 @@ import initSidebarBundle from 'ee/sidebar/sidebar_bundle';
import { initReviewBar } from '~/batch_comments'; import { initReviewBar } from '~/batch_comments';
import initMrNotes from '~/mr_notes'; import initMrNotes from '~/mr_notes';
import initShow from '~/pages/projects/merge_requests/init_merge_request_show'; import initShow from '~/pages/projects/merge_requests/init_merge_request_show';
import trackShowInviteMemberLink from 'ee/projects/track_invite_members';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
initShow(); initShow();
...@@ -10,4 +11,8 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -10,4 +11,8 @@ document.addEventListener('DOMContentLoaded', () => {
} }
initMrNotes(); initMrNotes();
initReviewBar(); initReviewBar();
const assigneeDropdown = document.querySelector('.js-sidebar-assignee-dropdown');
if (assigneeDropdown) trackShowInviteMemberLink(assigneeDropdown);
}); });
import $ from 'jquery';
import Tracking from '~/tracking';
export default function(assigneeDropdown) {
const trackEvent = 'show_invite_members';
const trackLabel = 'edit_assignee';
$(assigneeDropdown).on('shown.bs.dropdown', () => {
Tracking.event(undefined, trackEvent, {
label: trackLabel,
});
});
}
import $ from 'jquery';
import trackShowInviteMemberLink from 'ee/projects/track_invite_members';
import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
describe('Track user dropdown open', () => {
let trackingSpy;
let selector;
beforeEach(() => {
setFixtures(`
<div class="js-sidebar-assignee-dropdown">
</div>`);
selector = $('.js-sidebar-assignee-dropdown');
trackingSpy = mockTracking('_category_', selector.element, jest.spyOn);
document.body.dataset.page = 'some:page';
trackShowInviteMemberLink(selector);
});
afterEach(() => {
unmockTracking();
});
it('sends a tracking event when the dropdown is opened and contains Invite Members link', () => {
selector.trigger('shown.bs.dropdown');
expect(trackingSpy).toHaveBeenCalledWith(undefined, 'show_invite_members', {
label: 'edit_assignee',
});
});
});
...@@ -56,6 +56,8 @@ describe 'Issue Sidebar' do ...@@ -56,6 +56,8 @@ describe 'Issue Sidebar' do
it 'sees link to invite members' do it 'sees link to invite members' do
page.within '.dropdown-menu-user' do page.within '.dropdown-menu-user' do
expect(page).to have_link('Invite Members', href: project_project_members_path(project)) expect(page).to have_link('Invite Members', href: project_project_members_path(project))
expect(page).to have_selector('[data-track-event="click_invite_members"]')
expect(page).to have_selector("[data-track-label='edit_assignee']")
end end
end end
end end
......
...@@ -112,6 +112,8 @@ describe 'Merge request > User edits assignees sidebar', :js do ...@@ -112,6 +112,8 @@ describe 'Merge request > User edits assignees sidebar', :js do
it 'sees link to invite members' do it 'sees link to invite members' do
page.within '.dropdown-menu-user' do page.within '.dropdown-menu-user' do
expect(page).to have_link('Invite Members', href: project_project_members_path(project)) expect(page).to have_link('Invite Members', href: project_project_members_path(project))
expect(page).to have_selector('[data-track-event="click_invite_members"]')
expect(page).to have_selector("[data-track-label='edit_assignee']")
end 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