Commit c1712312 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'add-tracking-go-to-pipelines' into 'master'

Add tracking to goto link

Closes gitlab-org/growth/product#301

See merge request gitlab-org/gitlab!28378
parents 1cef19ba f17f5b39
...@@ -21,6 +21,8 @@ export default { ...@@ -21,6 +21,8 @@ export default {
}, },
false, false,
), ),
goToTrackValue: 10,
trackEvent: 'click_button',
components: { components: {
GlModal, GlModal,
GlSprintf, GlSprintf,
...@@ -43,12 +45,17 @@ export default { ...@@ -43,12 +45,17 @@ export default {
}, },
data() { data() {
return { return {
tracking: { trackLabel: 'congratulate_first_pipeline',
label: 'congratulate_first_pipeline',
property: this.humanAccess,
},
}; };
}, },
computed: {
tracking() {
return {
label: this.trackLabel,
property: this.humanAccess,
};
},
},
mounted() { mounted() {
this.track(); this.track();
this.disableModalFromRenderingAgain(); this.disableModalFromRenderingAgain();
...@@ -89,7 +96,17 @@ export default { ...@@ -89,7 +96,17 @@ export default {
</template> </template>
</gl-sprintf> </gl-sprintf>
<template #modal-footer> <template #modal-footer>
<a :href="goToPipelinesPath" class="btn btn-success">{{ __('Go to Pipelines') }}</a> <a
ref="goto"
:href="goToPipelinesPath"
class="btn btn-success"
:data-track-property="humanAccess"
:data-track-value="$options.goToTrackValue"
:data-track-event="$options.trackEvent"
:data-track-label="trackLabel"
>
{{ __('Go to Pipelines') }}
</a>
</template> </template>
</gl-modal> </gl-modal>
</template> </template>
...@@ -2,7 +2,7 @@ import pipelineTourSuccess from '~/blob/pipeline_tour_success_modal.vue'; ...@@ -2,7 +2,7 @@ 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 { mockTracking, triggerEvent, unmockTracking } from 'helpers/tracking_helper';
import modalProps from './pipeline_tour_success_mock_data'; import modalProps from './pipeline_tour_success_mock_data';
describe('PipelineTourSuccessModal', () => { describe('PipelineTourSuccessModal', () => {
...@@ -16,6 +16,9 @@ describe('PipelineTourSuccessModal', () => { ...@@ -16,6 +16,9 @@ describe('PipelineTourSuccessModal', () => {
trackingSpy = mockTracking('_category_', undefined, jest.spyOn); trackingSpy = mockTracking('_category_', undefined, jest.spyOn);
wrapper = shallowMount(pipelineTourSuccess, { wrapper = shallowMount(pipelineTourSuccess, {
propsData: modalProps, propsData: modalProps,
stubs: {
GlModal,
},
}); });
cookieSpy = jest.spyOn(Cookies, 'remove'); cookieSpy = jest.spyOn(Cookies, 'remove');
...@@ -41,11 +44,23 @@ describe('PipelineTourSuccessModal', () => { ...@@ -41,11 +44,23 @@ describe('PipelineTourSuccessModal', () => {
}); });
describe('tracking', () => { describe('tracking', () => {
it('send event for basic view of popover', () => { it('send event for basic view of modal', () => {
expect(trackingSpy).toHaveBeenCalledWith(undefined, undefined, { expect(trackingSpy).toHaveBeenCalledWith(undefined, undefined, {
label: 'congratulate_first_pipeline', label: 'congratulate_first_pipeline',
property: modalProps.humanAccess, property: modalProps.humanAccess,
}); });
}); });
it('send an event when go to pipelines is clicked', () => {
trackingSpy = mockTracking('_category_', wrapper.element, jest.spyOn);
const goToBtn = wrapper.find({ ref: 'goto' });
triggerEvent(goToBtn.element);
expect(trackingSpy).toHaveBeenCalledWith('_category_', 'click_button', {
label: 'congratulate_first_pipeline',
property: modalProps.humanAccess,
value: '10',
});
});
}); });
}); });
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