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 {
},
false,
),
goToTrackValue: 10,
trackEvent: 'click_button',
components: {
GlModal,
GlSprintf,
......@@ -43,12 +45,17 @@ export default {
},
data() {
return {
tracking: {
label: 'congratulate_first_pipeline',
property: this.humanAccess,
},
trackLabel: 'congratulate_first_pipeline',
};
},
computed: {
tracking() {
return {
label: this.trackLabel,
property: this.humanAccess,
};
},
},
mounted() {
this.track();
this.disableModalFromRenderingAgain();
......@@ -88,8 +95,18 @@ export default {
</gl-link>
</template>
</gl-sprintf>
<template #modal-footer>
<a :href="goToPipelinesPath" class="btn btn-success">{{ __('Go to Pipelines') }}</a>
<template slot="modal-footer">
<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>
</gl-modal>
</template>
......@@ -2,7 +2,7 @@ import pipelineTourSuccess from '~/blob/pipeline_tour_success_modal.vue';
import { shallowMount } from '@vue/test-utils';
import Cookies from 'js-cookie';
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';
describe('PipelineTourSuccessModal', () => {
......@@ -41,11 +41,24 @@ describe('PipelineTourSuccessModal', () => {
});
describe('tracking', () => {
it('send event for basic view of popover', () => {
it('send event for basic view of modal', () => {
expect(trackingSpy).toHaveBeenCalledWith(undefined, undefined, {
label: 'congratulate_first_pipeline',
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