From 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 17 Dec 2020 11:59:07 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-7-stable-ee --- .../design_management/pages/design/index.vue | 13 +++++++--- .../design_management/utils/tracking.js | 29 +++++++++++++++++----- 2 files changed, 32 insertions(+), 10 deletions(-) (limited to 'app/assets/javascripts/design_management') diff --git a/app/assets/javascripts/design_management/pages/design/index.vue b/app/assets/javascripts/design_management/pages/design/index.vue index e07279ba39d..fb86568c304 100644 --- a/app/assets/javascripts/design_management/pages/design/index.vue +++ b/app/assets/javascripts/design_management/pages/design/index.vue @@ -4,6 +4,7 @@ import { GlLoadingIcon, GlAlert } from '@gitlab/ui'; import { ApolloMutation } from 'vue-apollo'; import createFlash from '~/flash'; import { fetchPolicies } from '~/lib/graphql'; +import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import allVersionsMixin from '../../mixins/all_versions'; import Toolbar from '../../components/toolbar/index.vue'; import DesignDestroyer from '../../components/design_destroyer.vue'; @@ -37,7 +38,7 @@ import { TOGGLE_TODO_ERROR, designDeletionError, } from '../../utils/error_messages'; -import { trackDesignDetailView } from '../../utils/tracking'; +import { trackDesignDetailView, usagePingDesignDetailView } from '../../utils/tracking'; import { DESIGNS_ROUTE_NAME } from '../../router/constants'; import { ACTIVE_DISCUSSION_SOURCE_TYPES, DESIGN_DETAIL_LAYOUT_CLASSLIST } from '../../constants'; @@ -55,7 +56,7 @@ export default { GlAlert, DesignSidebar, }, - mixins: [allVersionsMixin], + mixins: [allVersionsMixin, glFeatureFlagsMixin()], props: { id: { type: String, @@ -150,7 +151,7 @@ export default { }, mounted() { Mousetrap.bind('esc', this.closeDesign); - this.trackEvent(); + this.trackPageViewEvent(); // Set active discussion immediately. // This will ensure that, if a note is specified in the URL hash, @@ -274,7 +275,7 @@ export default { query: this.$route.query, }); }, - trackEvent() { + trackPageViewEvent() { // TODO: This needs to be made aware of referers, or if it's rendered in a different context than a Issue trackDesignDetailView( 'issue-design-collection', @@ -282,6 +283,10 @@ export default { this.$route.query.version || this.latestVersionId, this.isLatestVersion, ); + + if (this.glFeatures.usageDataDesignAction) { + usagePingDesignDetailView(); + } }, updateActiveDiscussion(id, source = ACTIVE_DISCUSSION_SOURCE_TYPES.discussion) { this.$apollo.mutate({ diff --git a/app/assets/javascripts/design_management/utils/tracking.js b/app/assets/javascripts/design_management/utils/tracking.js index 4a39268c38b..37296f5b4ff 100644 --- a/app/assets/javascripts/design_management/utils/tracking.js +++ b/app/assets/javascripts/design_management/utils/tracking.js @@ -1,24 +1,34 @@ import Tracking from '~/tracking'; +import Api from '~/api'; -// Tracking Constants +// Snowplow tracking constants const DESIGN_TRACKING_CONTEXT_SCHEMAS = { 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', CREATE_DESIGN: 'create_design', UPDATE_DESIGN: 'update_design', }; -export const DESIGN_TRACKING_PAGE_NAME = 'projects:issues:design'; +export const DESIGN_USAGE_PING_EVENT_TYPES = { + DESIGN_ACTION: 'design_action', +}; +/** + * Track "design detail" view in Snowplow + */ export function trackDesignDetailView( referer = '', owner = '', designVersion = 1, latestVersion = false, ) { - const eventName = DESIGN_TRACKING_EVENTS.VIEW_DESIGN; + const eventName = DESIGN_SNOWPLOW_EVENT_TYPES.VIEW_DESIGN; + Tracking.event(DESIGN_TRACKING_PAGE_NAME, eventName, { label: eventName, context: { @@ -34,9 +44,16 @@ export function trackDesignDetailView( } 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() { - 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 + */ +export function usagePingDesignDetailView() { + Api.trackRedisHllUserEvent(DESIGN_USAGE_PING_EVENT_TYPES.DESIGN_ACTION); } -- cgit v1.2.1