Commit 9694b8b3 authored by Tom Quirk's avatar Tom Quirk

Export tracking constants for design management

parent 3638b00f
...@@ -5,16 +5,18 @@ import api from '~/api'; ...@@ -5,16 +5,18 @@ import api from '~/api';
const DESIGN_TRACKING_CONTEXT_SCHEMAS = { const DESIGN_TRACKING_CONTEXT_SCHEMAS = {
VIEW_DESIGN_SCHEMA: 'iglu:com.gitlab/design_management_context/jsonschema/1-0-0', VIEW_DESIGN_SCHEMA: 'iglu:com.gitlab/design_management_context/jsonschema/1-0-0',
}; };
const DESIGN_TRACKING_EVENTS = {
export const DESIGN_TRACKING_PAGE_NAME = 'projects:issues:design';
export const DESIGN_SNOWPLOW_EVENT_TYPES = {
VIEW_DESIGN: 'view_design', VIEW_DESIGN: 'view_design',
CREATE_DESIGN: 'create_design', CREATE_DESIGN: 'create_design',
UPDATE_DESIGN: 'update_design', UPDATE_DESIGN: 'update_design',
}; };
// Usage ping tracking constants export const DESIGN_USAGE_PING_EVENT_TYPES = {
const DESIGN_ACTION = 'design_action'; DESIGN_ACTION: 'design_action',
};
export const DESIGN_TRACKING_PAGE_NAME = 'projects:issues:design';
/** /**
* Track "design detail" view in Snowplow * Track "design detail" view in Snowplow
...@@ -25,7 +27,7 @@ export function trackDesignDetailView( ...@@ -25,7 +27,7 @@ export function trackDesignDetailView(
designVersion = 1, designVersion = 1,
latestVersion = false, latestVersion = false,
) { ) {
const eventName = DESIGN_TRACKING_EVENTS.VIEW_DESIGN; const eventName = DESIGN_SNOWPLOW_EVENT_TYPES.VIEW_DESIGN;
Tracking.event(DESIGN_TRACKING_PAGE_NAME, eventName, { Tracking.event(DESIGN_TRACKING_PAGE_NAME, eventName, {
label: eventName, label: eventName,
...@@ -42,16 +44,16 @@ export function trackDesignDetailView( ...@@ -42,16 +44,16 @@ export function trackDesignDetailView(
} }
export function trackDesignCreate() { export function trackDesignCreate() {
return Tracking.event(DESIGN_TRACKING_PAGE_NAME, DESIGN_TRACKING_EVENTS.CREATE_DESIGN); return Tracking.event(DESIGN_TRACKING_PAGE_NAME, DESIGN_SNOWPLOW_EVENT_TYPES.CREATE_DESIGN);
} }
export function trackDesignUpdate() { export function trackDesignUpdate() {
return Tracking.event(DESIGN_TRACKING_PAGE_NAME, DESIGN_TRACKING_EVENTS.UPDATE_DESIGN); return Tracking.event(DESIGN_TRACKING_PAGE_NAME, DESIGN_SNOWPLOW_EVENT_TYPES.UPDATE_DESIGN);
} }
/** /**
* Track "design detail" view via usage ping * Track "design detail" view via usage ping
*/ */
export function usagePingDesignDetailView() { export function usagePingDesignDetailView() {
api.trackRedisHllUserEvent(DESIGN_ACTION); api.trackRedisHllUserEvent(DESIGN_USAGE_PING_EVENT_TYPES.DESIGN_ACTION);
} }
...@@ -31,7 +31,10 @@ import { ...@@ -31,7 +31,10 @@ import {
moveDesignMutationResponseWithErrors, moveDesignMutationResponseWithErrors,
} from '../mock_data/apollo_mock'; } from '../mock_data/apollo_mock';
import moveDesignMutation from '~/design_management/graphql/mutations/move_design.mutation.graphql'; import moveDesignMutation from '~/design_management/graphql/mutations/move_design.mutation.graphql';
import { DESIGN_TRACKING_PAGE_NAME } from '~/design_management/utils/tracking'; import {
DESIGN_TRACKING_PAGE_NAME,
DESIGN_SNOWPLOW_EVENT_TYPES,
} from '~/design_management/utils/tracking';
jest.mock('~/flash.js'); jest.mock('~/flash.js');
const mockPageEl = { const mockPageEl = {
...@@ -509,14 +512,20 @@ describe('Design management index page', () => { ...@@ -509,14 +512,20 @@ describe('Design management index page', () => {
wrapper.vm.onUploadDesignDone(designUploadMutationCreatedResponse); wrapper.vm.onUploadDesignDone(designUploadMutationCreatedResponse);
expect(trackingSpy).toHaveBeenCalledTimes(1); expect(trackingSpy).toHaveBeenCalledTimes(1);
expect(trackingSpy).toHaveBeenCalledWith(DESIGN_TRACKING_PAGE_NAME, 'create_design'); expect(trackingSpy).toHaveBeenCalledWith(
DESIGN_TRACKING_PAGE_NAME,
DESIGN_SNOWPLOW_EVENT_TYPES.CREATE_DESIGN,
);
}); });
it('tracks design modification', () => { it('tracks design modification', () => {
wrapper.vm.onUploadDesignDone(designUploadMutationUpdatedResponse); wrapper.vm.onUploadDesignDone(designUploadMutationUpdatedResponse);
expect(trackingSpy).toHaveBeenCalledTimes(1); expect(trackingSpy).toHaveBeenCalledTimes(1);
expect(trackingSpy).toHaveBeenCalledWith(DESIGN_TRACKING_PAGE_NAME, 'update_design'); expect(trackingSpy).toHaveBeenCalledWith(
DESIGN_TRACKING_PAGE_NAME,
DESIGN_SNOWPLOW_EVENT_TYPES.UPDATE_DESIGN,
);
}); });
}); });
}); });
......
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