Commit 3b29c4ab authored by Doug Stull's avatar Doug Stull Committed by Heinrich Lee Yu

Add distinct tracking value for invite members version b

- to allow tracking funnel exactness for experimentation.
parent 0defe75d
......@@ -23,6 +23,14 @@ module InviteMembersHelper
end
end
def show_invite_members_track_event
if directly_invite_members?
'show_invite_members'
elsif indirectly_invite_members?
'show_invite_members_version_b'
end
end
def invite_group_members?(group)
experiment_enabled?(:invite_members_empty_group_version_a) && Ability.allowed?(current_user, :admin_group_member, group)
end
......
......@@ -43,6 +43,9 @@
- options[:dropdown_class] += ' dropdown-extended-height'
- options[:footer_content] = true
- options[:wrapper_class] = 'js-sidebar-assignee-dropdown'
- options[:toggle_class] += ' js-invite-members-track'
- data['track-event'] = show_invite_members_track_event
- options[:data].merge!(data)
- invite_text = _('Invite Members')
- track_label = 'edit_assignee'
......
......@@ -2,8 +2,8 @@ import $ from 'jquery';
import Tracking from '~/tracking';
export default function initTrackInviteMembers(assigneeDropdown) {
const trackEvent = 'show_invite_members';
const trackLabel = 'edit_assignee';
const { trackEvent } = assigneeDropdown.querySelector('.js-invite-members-track').dataset;
$(assigneeDropdown).on('shown.bs.dropdown', () => {
Tracking.event(undefined, trackEvent, {
......
......@@ -4,18 +4,23 @@ import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
describe('Track user dropdown open', () => {
let trackingSpy;
let selector;
let dropdownElement;
beforeEach(() => {
setFixtures(`
<div class="js-sidebar-assignee-dropdown">
</div>`);
document.body.innerHTML = `
<div id="dummy-wrapper-element">
<div class="js-sidebar-assignee-dropdown">
<div class="js-invite-members-track" data-track-event="_track_event_">
</div>
</div>
</div>
`;
selector = $('.js-sidebar-assignee-dropdown');
trackingSpy = mockTracking('_category_', selector.element, jest.spyOn);
dropdownElement = document.querySelector('.js-sidebar-assignee-dropdown');
trackingSpy = mockTracking('_category_', dropdownElement, jest.spyOn);
document.body.dataset.page = 'some:page';
trackShowInviteMemberLink(selector);
trackShowInviteMemberLink(dropdownElement);
});
afterEach(() => {
......@@ -23,9 +28,9 @@ describe('Track user dropdown open', () => {
});
it('sends a tracking event when the dropdown is opened and contains Invite Members link', () => {
selector.trigger('shown.bs.dropdown');
$(dropdownElement).trigger('shown.bs.dropdown');
expect(trackingSpy).toHaveBeenCalledWith(undefined, 'show_invite_members', {
expect(trackingSpy).toHaveBeenCalledWith(undefined, '_track_event_', {
label: 'edit_assignee',
});
});
......
......@@ -11,6 +11,21 @@ RSpec.describe InviteMembersHelper do
helper.extend(Gitlab::Experimentation::ControllerConcern)
end
describe '#show_invite_members_track_event' do
it 'shows values when can directly invite members' do
allow(helper).to receive(:directly_invite_members?).and_return(true)
expect(helper.show_invite_members_track_event).to eq 'show_invite_members'
end
it 'shows values when can indirectly invite members' do
allow(helper).to receive(:directly_invite_members?).and_return(false)
allow(helper).to receive(:indirectly_invite_members?).and_return(true)
expect(helper.show_invite_members_track_event).to eq 'show_invite_members_version_b'
end
end
context 'with project' do
before do
assign(:project, project)
......
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