Commit a4a02d02 authored by Doug Stull's avatar Doug Stull

Add tracking to goto link

- for tracking
parent 7c701bb5
...@@ -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();
...@@ -88,8 +95,18 @@ export default { ...@@ -88,8 +95,18 @@ export default {
</gl-link> </gl-link>
</template> </template>
</gl-sprintf> </gl-sprintf>
<template #modal-footer> <template slot="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', () => {
...@@ -41,11 +41,24 @@ describe('PipelineTourSuccessModal', () => { ...@@ -41,11 +41,24 @@ 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