Commit 13283fbd authored by Donald Cook's avatar Donald Cook

Added snowplow tracking to change direction

parent 63c0654e
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { GlIcon } from '@gitlab/ui'; import { GlIcon } from '@gitlab/ui';
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
import { __ } from '~/locale'; import { __ } from '~/locale';
import Tracking from '~/tracking';
import { ASC, DESC } from '../constants'; import { ASC, DESC } from '../constants';
const SORT_OPTIONS = [ const SORT_OPTIONS = [
...@@ -14,6 +15,7 @@ export default { ...@@ -14,6 +15,7 @@ export default {
components: { components: {
GlIcon, GlIcon,
}, },
mixins: [Tracking.mixin()],
computed: { computed: {
...mapGetters(['sortDirection']), ...mapGetters(['sortDirection']),
selectedOption() { selectedOption() {
...@@ -31,6 +33,7 @@ export default { ...@@ -31,6 +33,7 @@ export default {
} }
this.setDiscussionSortDirection(direction); this.setDiscussionSortDirection(direction);
this.track('change_discussion_sort_direction', { property: direction });
}, },
isDropdownItemActive(sortDir) { isDropdownItemActive(sortDir) {
return sortDir === this.sortDirection; return sortDir === this.sortDirection;
......
...@@ -3,6 +3,7 @@ import Vuex from 'vuex'; ...@@ -3,6 +3,7 @@ import Vuex from 'vuex';
import SortDiscussion from '~/notes/components/sort_discussion.vue'; import SortDiscussion from '~/notes/components/sort_discussion.vue';
import createStore from '~/notes/stores'; import createStore from '~/notes/stores';
import { ASC, DESC } from '~/notes/constants'; import { ASC, DESC } from '~/notes/constants';
import Tracking from '~/tracking';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
...@@ -22,6 +23,7 @@ describe('Sort Discussion component', () => { ...@@ -22,6 +23,7 @@ describe('Sort Discussion component', () => {
beforeEach(() => { beforeEach(() => {
store = createStore(); store = createStore();
jest.spyOn(Tracking, 'event');
}); });
afterEach(() => { afterEach(() => {
...@@ -37,6 +39,9 @@ describe('Sort Discussion component', () => { ...@@ -37,6 +39,9 @@ describe('Sort Discussion component', () => {
wrapper.find('.js-newest-first').trigger('click'); wrapper.find('.js-newest-first').trigger('click');
expect(store.dispatch).toHaveBeenCalledWith('setDiscussionSortDirection', DESC); expect(store.dispatch).toHaveBeenCalledWith('setDiscussionSortDirection', DESC);
expect(Tracking.event).toHaveBeenCalledWith(undefined, 'change_discussion_sort_direction', {
property: DESC,
});
}); });
}); });
...@@ -58,6 +63,9 @@ describe('Sort Discussion component', () => { ...@@ -58,6 +63,9 @@ describe('Sort Discussion component', () => {
wrapper.find('.js-oldest-first').trigger('click'); wrapper.find('.js-oldest-first').trigger('click');
expect(store.dispatch).toHaveBeenCalledWith('setDiscussionSortDirection', ASC); expect(store.dispatch).toHaveBeenCalledWith('setDiscussionSortDirection', ASC);
expect(Tracking.event).toHaveBeenCalledWith(undefined, 'change_discussion_sort_direction', {
property: ASC,
});
}); });
it('applies the active class to the correct button in the dropdown', () => { it('applies the active class to the correct button in the dropdown', () => {
......
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