Commit 8a6726cc authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Count of incident details views

parent d1eb3b42
...@@ -310,7 +310,7 @@ export default { ...@@ -310,7 +310,7 @@ export default {
category="primary" category="primary"
variant="success" variant="success"
:href="newIncidentPath" :href="newIncidentPath"
@click="redirecting = true" @click="navigateToCreateNewIncident"
> >
{{ $options.i18n.createIncidentBtnLabel }} {{ $options.i18n.createIncidentBtnLabel }}
</gl-button> </gl-button>
......
...@@ -34,6 +34,13 @@ export const INCIDENT_STATUS_TABS = [ ...@@ -34,6 +34,13 @@ export const INCIDENT_STATUS_TABS = [
}, },
]; ];
export const DEFAULT_PAGE_SIZE = 20;
export const TH_CREATED_AT_TEST_ID = { 'data-testid': 'incident-management-created-at-sort' };
export const TH_SEVERITY_TEST_ID = { 'data-testid': 'incident-management-severity-sort' };
export const TH_INCIDENT_SLA_TEST_ID = { 'data-testid': 'incident-management-sla' };
export const TH_PUBLISHED_TEST_ID = { 'data-testid': 'incident-management-published-sort' };
export const INCIDENT_DETAILS_PATH = 'incident';
/** /**
* Tracks snowplow event when user clicks create new incident * Tracks snowplow event when user clicks create new incident
*/ */
...@@ -43,16 +50,17 @@ export const trackIncidentCreateNewOptions = { ...@@ -43,16 +50,17 @@ export const trackIncidentCreateNewOptions = {
}; };
/** /**
* Tracks snowplow event when user views incident list * Tracks snowplow event when user views incidents list
*/ */
export const trackIncidentListViewsOptions = { export const trackIncidentListViewsOptions = {
category: 'Incident Management', category: 'Incident Management',
action: 'view_incidents_list', action: 'view_incidents_list',
}; };
export const DEFAULT_PAGE_SIZE = 20; /**
export const TH_CREATED_AT_TEST_ID = { 'data-testid': 'incident-management-created-at-sort' }; * Tracks snowplow event when user views incident details
export const TH_SEVERITY_TEST_ID = { 'data-testid': 'incident-management-severity-sort' }; */
export const TH_INCIDENT_SLA_TEST_ID = { 'data-testid': 'incident-management-sla' }; export const trackIncidentDetailsViewsOptions = {
export const TH_PUBLISHED_TEST_ID = { 'data-testid': 'incident-management-published-sort' }; category: 'Incident Management',
export const INCIDENT_DETAILS_PATH = 'incident'; action: 'view_incident_details',
};
...@@ -5,8 +5,10 @@ import HighlightBar from './highlight_bar.vue'; ...@@ -5,8 +5,10 @@ import HighlightBar from './highlight_bar.vue';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import AlertDetailsTable from '~/vue_shared/components/alert_details_table.vue'; import AlertDetailsTable from '~/vue_shared/components/alert_details_table.vue';
import Tracking from '~/tracking';
import getAlert from './graphql/queries/get_alert.graphql'; import getAlert from './graphql/queries/get_alert.graphql';
import { trackIncidentDetailsViewsOptions } from '~/incidents/constants';
export default { export default {
components: { components: {
...@@ -46,6 +48,15 @@ export default { ...@@ -46,6 +48,15 @@ export default {
return this.$apollo.queries.alert.loading; return this.$apollo.queries.alert.loading;
}, },
}, },
mounted() {
this.trackPageViews();
},
methods: {
trackPageViews() {
const { category, action } = trackIncidentDetailsViewsOptions;
Tracking.event(category, action);
},
},
}; };
</script> </script>
......
---
title: Snowplow tracking of Incident details views
merge_request: 45011
author:
type: added
...@@ -10,6 +10,8 @@ import { ...@@ -10,6 +10,8 @@ import {
TH_CREATED_AT_TEST_ID, TH_CREATED_AT_TEST_ID,
TH_SEVERITY_TEST_ID, TH_SEVERITY_TEST_ID,
TH_PUBLISHED_TEST_ID, TH_PUBLISHED_TEST_ID,
trackIncidentCreateNewOptions,
trackIncidentListViewsOptions,
} from '~/incidents/constants'; } from '~/incidents/constants';
import mockIncidents from '../mocks/incidents.json'; import mockIncidents from '../mocks/incidents.json';
...@@ -291,4 +293,25 @@ describe('Incidents List', () => { ...@@ -291,4 +293,25 @@ describe('Incidents List', () => {
expect(columnHeader().attributes('aria-sort')).toBe(nextSort); expect(columnHeader().attributes('aria-sort')).toBe(nextSort);
}); });
}); });
describe('Snowplow tracking', () => {
beforeEach(() => {
mountComponent({
data: { incidents: { list: mockIncidents }, incidentsCount: {} },
loading: false,
});
});
it('should track incident list views', () => {
const { category, action } = trackIncidentListViewsOptions;
expect(Tracking.event).toHaveBeenCalledWith(category, action);
});
it('should track incident creation events', async () => {
findCreateIncidentBtn().vm.$emit('click');
await wrapper.vm.$nextTick();
const { category, action } = trackIncidentCreateNewOptions;
expect(Tracking.event).toHaveBeenCalledWith(category, action);
});
});
}); });
...@@ -6,6 +6,8 @@ import { descriptionProps } from '../../mock_data'; ...@@ -6,6 +6,8 @@ import { descriptionProps } from '../../mock_data';
import DescriptionComponent from '~/issue_show/components/description.vue'; import DescriptionComponent from '~/issue_show/components/description.vue';
import HighlightBar from '~/issue_show/components/incidents/highlight_bar.vue'; import HighlightBar from '~/issue_show/components/incidents/highlight_bar.vue';
import AlertDetailsTable from '~/vue_shared/components/alert_details_table.vue'; import AlertDetailsTable from '~/vue_shared/components/alert_details_table.vue';
import Tracking from '~/tracking';
import { trackIncidentDetailsViewsOptions } from '~/incidents/constants';
const mockAlert = { const mockAlert = {
__typename: 'AlertManagementAlert', __typename: 'AlertManagementAlert',
...@@ -97,4 +99,16 @@ describe('Incident Tabs component', () => { ...@@ -97,4 +99,16 @@ describe('Incident Tabs component', () => {
expect(findDescriptionComponent().props()).toMatchObject(descriptionProps); expect(findDescriptionComponent().props()).toMatchObject(descriptionProps);
}); });
}); });
describe('Snowplow tracking', () => {
beforeEach(() => {
jest.spyOn(Tracking, 'event');
mountComponent();
});
it('should track incident details views', () => {
const { category, action } = trackIncidentDetailsViewsOptions;
expect(Tracking.event).toHaveBeenCalledWith(category, action);
});
});
}); });
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