Commit 7a5fe638 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch...

Merge branch '199458-track-jump-to-next-unresolved-thread-buttons-usage-in-merge-requests' into 'master'

Use Snowplow to track clicks on "Jump To Next" MR buttons

See merge request gitlab-org/gitlab!26319
parents 22848ab2 ff4ee180
...@@ -77,6 +77,9 @@ export default { ...@@ -77,6 +77,9 @@ export default {
v-gl-tooltip v-gl-tooltip
title="Jump to next unresolved thread" title="Jump to next unresolved thread"
class="btn btn-default discussion-next-btn" class="btn btn-default discussion-next-btn"
data-track-event="click_button"
data-track-label="mr_next_unresolved_thread"
data-track-property="click_next_unresolved_thread_top"
@click="jumpToNextDiscussion" @click="jumpToNextDiscussion"
> >
<icon name="comment-next" /> <icon name="comment-next" />
......
...@@ -28,6 +28,9 @@ export default { ...@@ -28,6 +28,9 @@ export default {
v-gl-tooltip v-gl-tooltip
class="btn btn-default discussion-next-btn" class="btn btn-default discussion-next-btn"
:title="s__('MergeRequests|Jump to next unresolved thread')" :title="s__('MergeRequests|Jump to next unresolved thread')"
data-track-event="click_button"
data-track-label="mr_next_unresolved_thread"
data-track-property="click_next_unresolved_thread"
@click="jumpToNextRelativeDiscussion(fromDiscussionId)" @click="jumpToNextRelativeDiscussion(fromDiscussionId)"
> >
<icon name="comment-next" /> <icon name="comment-next" />
......
---
title: Added tracking to merge request jump to next thread buttons
merge_request: 26319
author: Martin Hobert
type: added
...@@ -7,6 +7,9 @@ exports[`JumpToNextDiscussionButton matches the snapshot 1`] = ` ...@@ -7,6 +7,9 @@ exports[`JumpToNextDiscussionButton matches the snapshot 1`] = `
> >
<button <button
class="btn btn-default discussion-next-btn" class="btn btn-default discussion-next-btn"
data-track-event="click_button"
data-track-label="mr_next_unresolved_thread"
data-track-property="click_next_unresolved_thread"
title="Jump to next unresolved thread" title="Jump to next unresolved thread"
> >
<icon-stub <icon-stub
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import JumpToNextDiscussionButton from '~/notes/components/discussion_jump_to_next_button.vue'; import JumpToNextDiscussionButton from '~/notes/components/discussion_jump_to_next_button.vue';
import { mockTracking } from '../../helpers/tracking_helper';
describe('JumpToNextDiscussionButton', () => { describe('JumpToNextDiscussionButton', () => {
let wrapper;
const fromDiscussionId = 'abc123'; const fromDiscussionId = 'abc123';
let wrapper;
let trackingSpy;
let jumpFn;
beforeEach(() => { beforeEach(() => {
jumpFn = jest.fn();
wrapper = shallowMount(JumpToNextDiscussionButton, { wrapper = shallowMount(JumpToNextDiscussionButton, {
propsData: { fromDiscussionId }, propsData: { fromDiscussionId },
}); });
wrapper.setMethods({ jumpToNextRelativeDiscussion: jumpFn });
trackingSpy = mockTracking('_category_', wrapper.element, jest.spyOn);
}); });
afterEach(() => { afterEach(() => {
...@@ -20,9 +27,17 @@ describe('JumpToNextDiscussionButton', () => { ...@@ -20,9 +27,17 @@ describe('JumpToNextDiscussionButton', () => {
}); });
it('calls jumpToNextRelativeDiscussion when clicked', () => { it('calls jumpToNextRelativeDiscussion when clicked', () => {
const jumpToNextRelativeDiscussion = jest.fn();
wrapper.setMethods({ jumpToNextRelativeDiscussion });
wrapper.find({ ref: 'button' }).trigger('click'); wrapper.find({ ref: 'button' }).trigger('click');
expect(jumpToNextRelativeDiscussion).toHaveBeenCalledWith(fromDiscussionId);
expect(jumpFn).toHaveBeenCalledWith(fromDiscussionId);
});
it('sends the correct tracking event when clicked', () => {
wrapper.find({ ref: 'button' }).trigger('click');
expect(trackingSpy).toHaveBeenCalledWith('_category_', 'click_button', {
label: 'mr_next_unresolved_thread',
property: 'click_next_unresolved_thread',
});
}); });
}); });
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