2021-02-22 17:27:13 +05:30
|
|
|
import Api from '~/api';
|
2021-03-11 19:13:27 +05:30
|
|
|
import Tracking from '~/tracking';
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
// Snowplow tracking constants
|
2021-01-03 14:25:43 +05:30
|
|
|
const DESIGN_TRACKING_CONTEXT_SCHEMAS = {
|
|
|
|
VIEW_DESIGN_SCHEMA: 'iglu:com.gitlab/design_management_context/jsonschema/1-0-0',
|
|
|
|
};
|
2021-02-22 17:27:13 +05:30
|
|
|
|
|
|
|
export const DESIGN_TRACKING_PAGE_NAME = 'projects:issues:design';
|
|
|
|
|
|
|
|
export const DESIGN_SNOWPLOW_EVENT_TYPES = {
|
2021-01-03 14:25:43 +05:30
|
|
|
VIEW_DESIGN: 'view_design',
|
|
|
|
CREATE_DESIGN: 'create_design',
|
|
|
|
UPDATE_DESIGN: 'update_design',
|
|
|
|
};
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
export const DESIGN_USAGE_PING_EVENT_TYPES = {
|
|
|
|
DESIGN_ACTION: 'design_action',
|
|
|
|
};
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
/**
|
|
|
|
* Track "design detail" view in Snowplow
|
|
|
|
*/
|
2020-05-24 23:13:21 +05:30
|
|
|
export function trackDesignDetailView(
|
|
|
|
referer = '',
|
|
|
|
owner = '',
|
|
|
|
designVersion = 1,
|
|
|
|
latestVersion = false,
|
|
|
|
) {
|
2021-02-22 17:27:13 +05:30
|
|
|
const eventName = DESIGN_SNOWPLOW_EVENT_TYPES.VIEW_DESIGN;
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
Tracking.event(DESIGN_TRACKING_PAGE_NAME, eventName, {
|
|
|
|
label: eventName,
|
2020-07-28 23:09:34 +05:30
|
|
|
context: {
|
2021-01-03 14:25:43 +05:30
|
|
|
schema: DESIGN_TRACKING_CONTEXT_SCHEMAS.VIEW_DESIGN_SCHEMA,
|
2020-07-28 23:09:34 +05:30
|
|
|
data: {
|
|
|
|
'design-version-number': designVersion,
|
|
|
|
'design-is-current-version': latestVersion,
|
|
|
|
'internal-object-referrer': referer,
|
|
|
|
'design-collection-owner': owner,
|
|
|
|
},
|
|
|
|
},
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
|
|
|
}
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
export function trackDesignCreate() {
|
2021-02-22 17:27:13 +05:30
|
|
|
return Tracking.event(DESIGN_TRACKING_PAGE_NAME, DESIGN_SNOWPLOW_EVENT_TYPES.CREATE_DESIGN);
|
2021-01-03 14:25:43 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
export function trackDesignUpdate() {
|
2021-02-22 17:27:13 +05:30
|
|
|
return Tracking.event(DESIGN_TRACKING_PAGE_NAME, DESIGN_SNOWPLOW_EVENT_TYPES.UPDATE_DESIGN);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Track "design detail" view via usage ping
|
|
|
|
*/
|
|
|
|
export function usagePingDesignDetailView() {
|
|
|
|
Api.trackRedisHllUserEvent(DESIGN_USAGE_PING_EVENT_TYPES.DESIGN_ACTION);
|
2021-01-03 14:25:43 +05:30
|
|
|
}
|