debian-mirror-gitlab/app/assets/javascripts/design_management/utils/tracking.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-05-24 23:13:21 +05:30
import Tracking from '~/tracking';
// 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',
};
const DESIGN_TRACKING_EVENTS = {
VIEW_DESIGN: 'view_design',
CREATE_DESIGN: 'create_design',
UPDATE_DESIGN: 'update_design',
};
export const DESIGN_TRACKING_PAGE_NAME = 'projects:issues:design';
2020-05-24 23:13:21 +05:30
export function trackDesignDetailView(
referer = '',
owner = '',
designVersion = 1,
latestVersion = false,
) {
2021-01-03 14:25:43 +05:30
const eventName = DESIGN_TRACKING_EVENTS.VIEW_DESIGN;
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() {
return Tracking.event(DESIGN_TRACKING_PAGE_NAME, DESIGN_TRACKING_EVENTS.CREATE_DESIGN);
}
export function trackDesignUpdate() {
return Tracking.event(DESIGN_TRACKING_PAGE_NAME, DESIGN_TRACKING_EVENTS.UPDATE_DESIGN);
}