Commit 7340161a authored by Markus Koller's avatar Markus Koller

Merge branch 'rk/fix-snowplow-design-tracking' into 'master'

Changed Event Structure for Design Tracking

See merge request gitlab-org/gitlab!36061
parents 1c95ebb6 0651ebae
import Tracking from '~/tracking'; import Tracking from '~/tracking';
function assembleDesignPayload(payloadArr) {
return {
value: {
'internal-object-refrerer': payloadArr[0],
'design-collection-owner': payloadArr[1],
'design-version-number': payloadArr[2],
'design-is-current-version': payloadArr[3],
},
};
}
// Tracking Constants // 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_PAGE_NAME = 'projects:issues:design';
const DESIGN_TRACKING_EVENT_NAME = 'view_design';
// eslint-disable-next-line import/prefer-default-export // eslint-disable-next-line import/prefer-default-export
export function trackDesignDetailView( export function trackDesignDetailView(
...@@ -21,8 +12,16 @@ export function trackDesignDetailView( ...@@ -21,8 +12,16 @@ export function trackDesignDetailView(
designVersion = 1, designVersion = 1,
latestVersion = false, latestVersion = false,
) { ) {
Tracking.event(DESIGN_TRACKING_PAGE_NAME, 'design_viewed', { Tracking.event(DESIGN_TRACKING_PAGE_NAME, DESIGN_TRACKING_EVENT_NAME, {
label: 'design_viewed', label: DESIGN_TRACKING_EVENT_NAME,
...assembleDesignPayload([referer, owner, designVersion, latestVersion]), context: {
schema: DESIGN_TRACKING_CONTEXT_SCHEMA,
data: {
'design-version-number': designVersion,
'design-is-current-version': latestVersion,
'internal-object-referrer': referer,
'design-collection-owner': owner,
},
},
}); });
} }
import Tracking from '~/tracking'; import Tracking from '~/tracking';
function assembleDesignPayload(payloadArr) {
return {
value: {
'internal-object-refrerer': payloadArr[0],
'design-collection-owner': payloadArr[1],
'design-version-number': payloadArr[2],
'design-is-current-version': payloadArr[3],
},
};
}
// Tracking Constants // 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_PAGE_NAME = 'projects:issues:design';
const DESIGN_TRACKING_EVENT_NAME = 'view_design';
// eslint-disable-next-line import/prefer-default-export // eslint-disable-next-line import/prefer-default-export
export function trackDesignDetailView( export function trackDesignDetailView(
...@@ -21,8 +12,16 @@ export function trackDesignDetailView( ...@@ -21,8 +12,16 @@ export function trackDesignDetailView(
designVersion = 1, designVersion = 1,
latestVersion = false, latestVersion = false,
) { ) {
Tracking.event(DESIGN_TRACKING_PAGE_NAME, 'design_viewed', { Tracking.event(DESIGN_TRACKING_PAGE_NAME, DESIGN_TRACKING_EVENT_NAME, {
label: 'design_viewed', label: DESIGN_TRACKING_EVENT_NAME,
...assembleDesignPayload([referer, owner, designVersion, latestVersion]), context: {
schema: DESIGN_TRACKING_CONTEXT_SCHEMA,
data: {
'design-version-number': designVersion,
'design-is-current-version': latestVersion,
'internal-object-referrer': referer,
'design-collection-owner': owner,
},
},
}); });
} }
...@@ -8,7 +8,7 @@ function getTrackingSpy(key) { ...@@ -8,7 +8,7 @@ function getTrackingSpy(key) {
describe('Tracking Events', () => { describe('Tracking Events', () => {
describe('trackDesignDetailView', () => { describe('trackDesignDetailView', () => {
const eventKey = 'projects:issues:design'; const eventKey = 'projects:issues:design';
const eventName = 'design_viewed'; const eventName = 'view_design';
it('trackDesignDetailView fires a tracking event when called', () => { it('trackDesignDetailView fires a tracking event when called', () => {
const trackingSpy = getTrackingSpy(eventKey); const trackingSpy = getTrackingSpy(eventKey);
...@@ -20,11 +20,14 @@ describe('Tracking Events', () => { ...@@ -20,11 +20,14 @@ describe('Tracking Events', () => {
eventName, eventName,
expect.objectContaining({ expect.objectContaining({
label: eventName, label: eventName,
value: { context: {
'internal-object-refrerer': '', schema: expect.any(String),
'design-collection-owner': '', data: {
'design-version-number': 1, 'design-version-number': 1,
'design-is-current-version': false, 'design-is-current-version': false,
'internal-object-referrer': '',
'design-collection-owner': '',
},
}, },
}), }),
); );
...@@ -40,11 +43,14 @@ describe('Tracking Events', () => { ...@@ -40,11 +43,14 @@ describe('Tracking Events', () => {
eventName, eventName,
expect.objectContaining({ expect.objectContaining({
label: eventName, label: eventName,
value: { context: {
'internal-object-refrerer': 'from-a-test', schema: expect.any(String),
'design-collection-owner': 'test', data: {
'design-version-number': 100, 'design-version-number': 100,
'design-is-current-version': true, 'design-is-current-version': true,
'internal-object-referrer': 'from-a-test',
'design-collection-owner': 'test',
},
}, },
}), }),
); );
......
...@@ -8,7 +8,7 @@ function getTrackingSpy(key) { ...@@ -8,7 +8,7 @@ function getTrackingSpy(key) {
describe('Tracking Events', () => { describe('Tracking Events', () => {
describe('trackDesignDetailView', () => { describe('trackDesignDetailView', () => {
const eventKey = 'projects:issues:design'; const eventKey = 'projects:issues:design';
const eventName = 'design_viewed'; const eventName = 'view_design';
it('trackDesignDetailView fires a tracking event when called', () => { it('trackDesignDetailView fires a tracking event when called', () => {
const trackingSpy = getTrackingSpy(eventKey); const trackingSpy = getTrackingSpy(eventKey);
...@@ -20,11 +20,14 @@ describe('Tracking Events', () => { ...@@ -20,11 +20,14 @@ describe('Tracking Events', () => {
eventName, eventName,
expect.objectContaining({ expect.objectContaining({
label: eventName, label: eventName,
value: { context: {
'internal-object-refrerer': '', schema: expect.any(String),
'design-collection-owner': '', data: {
'design-version-number': 1, 'design-version-number': 1,
'design-is-current-version': false, 'design-is-current-version': false,
'internal-object-referrer': '',
'design-collection-owner': '',
},
}, },
}), }),
); );
...@@ -40,11 +43,14 @@ describe('Tracking Events', () => { ...@@ -40,11 +43,14 @@ describe('Tracking Events', () => {
eventName, eventName,
expect.objectContaining({ expect.objectContaining({
label: eventName, label: eventName,
value: { context: {
'internal-object-refrerer': 'from-a-test', schema: expect.any(String),
'design-collection-owner': 'test', data: {
'design-version-number': 100, 'design-version-number': 100,
'design-is-current-version': true, 'design-is-current-version': true,
'internal-object-referrer': 'from-a-test',
'design-collection-owner': 'test',
},
}, },
}), }),
); );
......
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