Commit 4746cc37 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'jnnkl-update-license-compliance-tracking-event' into 'master'

Added tracking counter to mr_license_compliance_widget

See merge request gitlab-org/gitlab!77512
parents 1827fbf6 dbe8e684
<script> <script>
import { GlLink, GlIcon, GlButton } from '@gitlab/ui';
import { mapState, mapGetters, mapActions } from 'vuex'; import { mapState, mapGetters, mapActions } from 'vuex';
import { GlLink, GlIcon, GlButton } from '@gitlab/ui';
import api from '~/api'; import api from '~/api';
import { componentNames, iconComponentNames } from 'ee/reports/components/issue_body'; import { componentNames, iconComponentNames } from 'ee/reports/components/issue_body';
import { LICENSE_MANAGEMENT } from 'ee/vue_shared/license_compliance/store/constants'; import { LICENSE_MANAGEMENT } from 'ee/vue_shared/license_compliance/store/constants';
...@@ -114,6 +114,7 @@ export default { ...@@ -114,6 +114,7 @@ export default {
methods: { methods: {
trackVisitedPath(trackAction) { trackVisitedPath(trackAction) {
api.trackRedisHllUserEvent(trackAction); api.trackRedisHllUserEvent(trackAction);
api.trackRedisCounterEvent(trackAction);
}, },
...mapActions(LICENSE_MANAGEMENT, [ ...mapActions(LICENSE_MANAGEMENT, [
'setAPISettings', 'setAPISettings',
......
...@@ -118,22 +118,30 @@ describe('License Report MR Widget', () => { ...@@ -118,22 +118,30 @@ describe('License Report MR Widget', () => {
}); });
describe('snowplow', () => { describe('snowplow', () => {
let trackEventSpy; let trackUserEventSpy;
let trackCounterEventSpy;
beforeEach(() => { beforeEach(() => {
mountComponent(); mountComponent();
trackUserEventSpy = jest.spyOn(api, 'trackRedisHllUserEvent').mockImplementation(() => {});
trackEventSpy = jest.spyOn(api, 'trackRedisHllUserEvent').mockImplementation(() => {}); trackCounterEventSpy = jest
.spyOn(api, 'trackRedisCounterEvent')
.mockImplementation(() => {});
}); });
afterEach(() => { afterEach(() => {
trackEventSpy.mockRestore(); trackUserEventSpy.mockRestore();
trackCounterEventSpy.mockRestore();
}); });
it('tracks users_visiting_testing_license_compliance_full_report', () => { it('tracks users_visiting_testing_license_compliance_full_report', () => {
wrapper.find('[data-testid="full-report-button"]').vm.$emit('click'); wrapper.find('[data-testid="full-report-button"]').vm.$emit('click');
expect(trackEventSpy).toHaveBeenCalledWith( expect(trackUserEventSpy).toHaveBeenCalledWith(
'users_visiting_testing_license_compliance_full_report',
);
expect(trackCounterEventSpy).toHaveBeenCalledWith(
'users_visiting_testing_license_compliance_full_report', 'users_visiting_testing_license_compliance_full_report',
); );
}); });
...@@ -141,7 +149,11 @@ describe('License Report MR Widget', () => { ...@@ -141,7 +149,11 @@ describe('License Report MR Widget', () => {
it('tracks users_visiting_testing_manage_license_compliance', () => { it('tracks users_visiting_testing_manage_license_compliance', () => {
wrapper.find('[data-testid="manage-licenses-button"]').vm.$emit('click'); wrapper.find('[data-testid="manage-licenses-button"]').vm.$emit('click');
expect(trackEventSpy).toHaveBeenCalledWith( expect(trackUserEventSpy).toHaveBeenCalledWith(
'users_visiting_testing_manage_license_compliance',
);
expect(trackCounterEventSpy).toHaveBeenCalledWith(
'users_visiting_testing_manage_license_compliance', 'users_visiting_testing_manage_license_compliance',
); );
}); });
......
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