Commit 17114e5f authored by Tom Quirk's avatar Tom Quirk

Add design_action usage ping to view tracking

parent eb411321
...@@ -4,6 +4,7 @@ import { GlLoadingIcon, GlAlert } from '@gitlab/ui'; ...@@ -4,6 +4,7 @@ import { GlLoadingIcon, GlAlert } from '@gitlab/ui';
import { ApolloMutation } from 'vue-apollo'; import { ApolloMutation } from 'vue-apollo';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { fetchPolicies } from '~/lib/graphql'; import { fetchPolicies } from '~/lib/graphql';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import allVersionsMixin from '../../mixins/all_versions'; import allVersionsMixin from '../../mixins/all_versions';
import Toolbar from '../../components/toolbar/index.vue'; import Toolbar from '../../components/toolbar/index.vue';
import DesignDestroyer from '../../components/design_destroyer.vue'; import DesignDestroyer from '../../components/design_destroyer.vue';
...@@ -37,7 +38,7 @@ import { ...@@ -37,7 +38,7 @@ import {
TOGGLE_TODO_ERROR, TOGGLE_TODO_ERROR,
designDeletionError, designDeletionError,
} from '../../utils/error_messages'; } from '../../utils/error_messages';
import { trackDesignDetailView } from '../../utils/tracking'; import { trackDesignDetailView, usagePingDesignDetailView } from '../../utils/tracking';
import { DESIGNS_ROUTE_NAME } from '../../router/constants'; import { DESIGNS_ROUTE_NAME } from '../../router/constants';
import { ACTIVE_DISCUSSION_SOURCE_TYPES, DESIGN_DETAIL_LAYOUT_CLASSLIST } from '../../constants'; import { ACTIVE_DISCUSSION_SOURCE_TYPES, DESIGN_DETAIL_LAYOUT_CLASSLIST } from '../../constants';
...@@ -55,7 +56,7 @@ export default { ...@@ -55,7 +56,7 @@ export default {
GlAlert, GlAlert,
DesignSidebar, DesignSidebar,
}, },
mixins: [allVersionsMixin], mixins: [allVersionsMixin, glFeatureFlagsMixin()],
props: { props: {
id: { id: {
type: String, type: String,
...@@ -150,7 +151,7 @@ export default { ...@@ -150,7 +151,7 @@ export default {
}, },
mounted() { mounted() {
Mousetrap.bind('esc', this.closeDesign); Mousetrap.bind('esc', this.closeDesign);
this.trackEvent(); this.trackPageViewEvent();
// Set active discussion immediately. // Set active discussion immediately.
// This will ensure that, if a note is specified in the URL hash, // This will ensure that, if a note is specified in the URL hash,
...@@ -274,7 +275,7 @@ export default { ...@@ -274,7 +275,7 @@ export default {
query: this.$route.query, 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 // TODO: This needs to be made aware of referers, or if it's rendered in a different context than a Issue
trackDesignDetailView( trackDesignDetailView(
'issue-design-collection', 'issue-design-collection',
...@@ -282,6 +283,10 @@ export default { ...@@ -282,6 +283,10 @@ export default {
this.$route.query.version || this.latestVersionId, this.$route.query.version || this.latestVersionId,
this.isLatestVersion, this.isLatestVersion,
); );
if (this.glFeatures.usageDataDesignAction) {
usagePingDesignDetailView();
}
}, },
updateActiveDiscussion(id, source = ACTIVE_DISCUSSION_SOURCE_TYPES.discussion) { updateActiveDiscussion(id, source = ACTIVE_DISCUSSION_SOURCE_TYPES.discussion) {
this.$apollo.mutate({ this.$apollo.mutate({
......
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import api from '~/api';
// Tracking Constants // Snowplow tracking constants
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',
}; };
...@@ -10,8 +11,14 @@ const DESIGN_TRACKING_EVENTS = { ...@@ -10,8 +11,14 @@ const DESIGN_TRACKING_EVENTS = {
UPDATE_DESIGN: 'update_design', UPDATE_DESIGN: 'update_design',
}; };
// Usage ping tracking constants
const DESIGN_ACTION = 'design_action';
export const DESIGN_TRACKING_PAGE_NAME = 'projects:issues:design'; export const DESIGN_TRACKING_PAGE_NAME = 'projects:issues:design';
/**
* Track "design detail" view in Snowplow
*/
export function trackDesignDetailView( export function trackDesignDetailView(
referer = '', referer = '',
owner = '', owner = '',
...@@ -19,6 +26,7 @@ export function trackDesignDetailView( ...@@ -19,6 +26,7 @@ export function trackDesignDetailView(
latestVersion = false, latestVersion = false,
) { ) {
const eventName = DESIGN_TRACKING_EVENTS.VIEW_DESIGN; const eventName = DESIGN_TRACKING_EVENTS.VIEW_DESIGN;
Tracking.event(DESIGN_TRACKING_PAGE_NAME, eventName, { Tracking.event(DESIGN_TRACKING_PAGE_NAME, eventName, {
label: eventName, label: eventName,
context: { context: {
...@@ -40,3 +48,10 @@ export function trackDesignCreate() { ...@@ -40,3 +48,10 @@ export function trackDesignCreate() {
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_TRACKING_EVENTS.UPDATE_DESIGN);
} }
/**
* Track "design detail" view via usage ping
*/
export function usagePingDesignDetailView() {
api.trackRedisHllUserEvent(DESIGN_ACTION);
}
---
title: Capture design detail views via usage ping
merge_request: 46751
author:
type: added
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