diff options
Diffstat (limited to 'app/assets/javascripts/design_management/utils/tracking.js')
-rw-r--r-- | app/assets/javascripts/design_management/utils/tracking.js | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/app/assets/javascripts/design_management/utils/tracking.js b/app/assets/javascripts/design_management/utils/tracking.js index 49fa306914c..4a39268c38b 100644 --- a/app/assets/javascripts/design_management/utils/tracking.js +++ b/app/assets/javascripts/design_management/utils/tracking.js @@ -1,9 +1,16 @@ import Tracking from '~/tracking'; // Tracking Constants -const DESIGN_TRACKING_CONTEXT_SCHEMA = 'iglu:com.gitlab/design_management_context/jsonschema/1-0-0'; -const DESIGN_TRACKING_PAGE_NAME = 'projects:issues:design'; -const DESIGN_TRACKING_EVENT_NAME = 'view_design'; +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'; export function trackDesignDetailView( referer = '', @@ -11,10 +18,11 @@ export function trackDesignDetailView( designVersion = 1, latestVersion = false, ) { - Tracking.event(DESIGN_TRACKING_PAGE_NAME, DESIGN_TRACKING_EVENT_NAME, { - label: DESIGN_TRACKING_EVENT_NAME, + const eventName = DESIGN_TRACKING_EVENTS.VIEW_DESIGN; + Tracking.event(DESIGN_TRACKING_PAGE_NAME, eventName, { + label: eventName, context: { - schema: DESIGN_TRACKING_CONTEXT_SCHEMA, + schema: DESIGN_TRACKING_CONTEXT_SCHEMAS.VIEW_DESIGN_SCHEMA, data: { 'design-version-number': designVersion, 'design-is-current-version': latestVersion, @@ -24,3 +32,11 @@ export function trackDesignDetailView( }, }); } + +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); +} |