Commit c84960b2 authored by Doug Stull's avatar Doug Stull

Add tracking on modal show for pipeline success

- needed for feature to be complete.
parent 7b2cd340
...@@ -3,6 +3,9 @@ import { GlModal, GlSprintf, GlLink } from '@gitlab/ui'; ...@@ -3,6 +3,9 @@ import { GlModal, GlSprintf, GlLink } from '@gitlab/ui';
import { sprintf, s__, __ } from '~/locale'; import { sprintf, s__, __ } from '~/locale';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import { glEmojiTag } from '~/emoji'; import { glEmojiTag } from '~/emoji';
import Tracking from '~/tracking';
const trackingMixin = Tracking.mixin();
export default { export default {
beginnerLink: beginnerLink:
...@@ -23,6 +26,7 @@ export default { ...@@ -23,6 +26,7 @@ export default {
GlSprintf, GlSprintf,
GlLink, GlLink,
}, },
mixins: [trackingMixin],
props: { props: {
goToPipelinesPath: { goToPipelinesPath: {
type: String, type: String,
...@@ -32,11 +36,29 @@ export default { ...@@ -32,11 +36,29 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
humanAccess: {
type: String,
required: true,
},
},
data() {
return {
tracking: {
label: 'congratulate_first_pipeline',
property: this.humanAccess,
},
};
}, },
mounted() { mounted() {
this.trackOnShow();
this.disableModalFromRenderingAgain(); this.disableModalFromRenderingAgain();
}, },
methods: { methods: {
trackOnShow() {
if (!this.popoverDismissed) {
this.track();
}
},
disableModalFromRenderingAgain() { disableModalFromRenderingAgain() {
Cookies.remove(this.commitCookie); Cookies.remove(this.commitCookie);
}, },
......
const modalProps = {
goToPipelinesPath: 'some_pipeline_path',
commitCookie: 'some_cookie',
humanAccess: 'maintainer',
};
export default modalProps;
...@@ -2,19 +2,16 @@ import pipelineTourSuccess from '~/blob/pipeline_tour_success_modal.vue'; ...@@ -2,19 +2,16 @@ import pipelineTourSuccess from '~/blob/pipeline_tour_success_modal.vue';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import { GlSprintf, GlModal } from '@gitlab/ui'; import { GlSprintf, GlModal } from '@gitlab/ui';
import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
import modalProps from './pipeline_tour_success_mock_data';
describe('PipelineTourSuccessModal', () => { describe('PipelineTourSuccessModal', () => {
let wrapper; let wrapper;
let cookieSpy; let cookieSpy;
const goToPipelinesPath = 'some_pipeline_path';
const commitCookie = 'some_cookie';
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(pipelineTourSuccess, { wrapper = shallowMount(pipelineTourSuccess, {
propsData: { propsData: modalProps,
goToPipelinesPath,
commitCookie,
},
}); });
cookieSpy = jest.spyOn(Cookies, 'remove'); cookieSpy = jest.spyOn(Cookies, 'remove');
...@@ -35,6 +32,29 @@ describe('PipelineTourSuccessModal', () => { ...@@ -35,6 +32,29 @@ describe('PipelineTourSuccessModal', () => {
it('calls to remove cookie', () => { it('calls to remove cookie', () => {
wrapper.vm.disableModalFromRenderingAgain(); wrapper.vm.disableModalFromRenderingAgain();
expect(cookieSpy).toHaveBeenCalledWith(commitCookie); expect(cookieSpy).toHaveBeenCalledWith(modalProps.commitCookie);
});
describe('tracking', () => {
let trackingSpy;
beforeEach(() => {
trackingSpy = mockTracking('_category_', wrapper.element, jest.spyOn);
});
afterEach(() => {
unmockTracking();
});
it('send event for basic view of popover', () => {
document.body.dataset.page = 'projects:blob:show';
wrapper.vm.trackOnShow();
expect(trackingSpy).toHaveBeenCalledWith(undefined, undefined, {
label: 'congratulate_first_pipeline',
property: modalProps.humanAccess,
});
});
}); });
}); });
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