Skip to content
代码片段 群组 项目
未验证 提交 a57d3507 编辑于 作者: Ankit Panchal's avatar Ankit Panchal 提交者: GitLab
浏览文件

Migrate some pipeline tracking events to Internal events

上级 22997269
No related branches found
No related tags found
无相关合并请求
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
import { GlTabs, GlTab } from '@gitlab/ui'; import { GlTabs, GlTab } from '@gitlab/ui';
import API from '~/api'; import API from '~/api';
import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/url_utility'; import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/url_utility';
import Tracking from '~/tracking'; import { InternalEvents } from '~/tracking';
import { SNOWPLOW_DATA_SOURCE, SNOWPLOW_LABEL, SNOWPLOW_SCHEMA } from '../constants';
import PipelineCharts from './pipeline_charts.vue'; import PipelineCharts from './pipeline_charts.vue';
export default { export default {
...@@ -25,7 +24,7 @@ export default { ...@@ -25,7 +24,7 @@ export default {
leadTimeTabEvent: 'p_analytics_ci_cd_lead_time', leadTimeTabEvent: 'p_analytics_ci_cd_lead_time',
timeToRestoreServiceTabEvent: 'p_analytics_ci_cd_time_to_restore_service', timeToRestoreServiceTabEvent: 'p_analytics_ci_cd_time_to_restore_service',
changeFailureRateTabEvent: 'p_analytics_ci_cd_change_failure_rate', changeFailureRateTabEvent: 'p_analytics_ci_cd_change_failure_rate',
mixins: [Tracking.mixin()], mixins: [InternalEvents.mixin()],
inject: { inject: {
shouldRenderDoraCharts: { shouldRenderDoraCharts: {
type: Boolean, type: Boolean,
...@@ -78,21 +77,12 @@ export default { ...@@ -78,21 +77,12 @@ export default {
updateHistory({ url: path, title: window.title }); updateHistory({ url: path, title: window.title });
} }
}, },
trackTabClick(event, snowplow = false) { trackTabClick(event, trackWithInternalEvents = false) {
API.trackRedisHllUserEvent(event); if (trackWithInternalEvents) {
this.trackEvent(event);
if (snowplow) { return;
this.track('click_tab', {
label: SNOWPLOW_LABEL,
context: {
schema: SNOWPLOW_SCHEMA,
data: {
event_name: event,
data_source: SNOWPLOW_DATA_SOURCE,
},
},
});
} }
API.trackRedisHllUserEvent(event);
}, },
}, },
}; };
......
...@@ -9,11 +9,7 @@ import Component from '~/projects/pipelines/charts/components/app.vue'; ...@@ -9,11 +9,7 @@ import Component from '~/projects/pipelines/charts/components/app.vue';
import PipelineCharts from '~/projects/pipelines/charts/components/pipeline_charts.vue'; import PipelineCharts from '~/projects/pipelines/charts/components/pipeline_charts.vue';
import API from '~/api'; import API from '~/api';
import { mockTracking } from 'helpers/tracking_helper'; import { mockTracking } from 'helpers/tracking_helper';
import { import { SNOWPLOW_DATA_SOURCE, SNOWPLOW_SCHEMA } from '~/projects/pipelines/charts/constants';
SNOWPLOW_DATA_SOURCE,
SNOWPLOW_LABEL,
SNOWPLOW_SCHEMA,
} from '~/projects/pipelines/charts/constants';
jest.mock('~/lib/utils/url_utility'); jest.mock('~/lib/utils/url_utility');
...@@ -130,9 +126,6 @@ describe('ProjectsPipelinesChartsApp', () => { ...@@ -130,9 +126,6 @@ describe('ProjectsPipelinesChartsApp', () => {
describe('RedisHLL events', () => { describe('RedisHLL events', () => {
it.each` it.each`
testId | event testId | event
${'pipelines-tab'} | ${'p_analytics_ci_cd_pipelines'}
${'deployment-frequency-tab'} | ${'p_analytics_ci_cd_deployment_frequency'}
${'lead-time-tab'} | ${'p_analytics_ci_cd_lead_time'}
${'time-to-restore-service-tab'} | ${'p_analytics_ci_cd_time_to_restore_service'} ${'time-to-restore-service-tab'} | ${'p_analytics_ci_cd_time_to_restore_service'}
${'change-failure-rate-tab'} | ${'p_analytics_ci_cd_change_failure_rate'} ${'change-failure-rate-tab'} | ${'p_analytics_ci_cd_change_failure_rate'}
`('tracks the $event event when clicked', ({ testId, event }) => { `('tracks the $event event when clicked', ({ testId, event }) => {
...@@ -146,6 +139,23 @@ describe('ProjectsPipelinesChartsApp', () => { ...@@ -146,6 +139,23 @@ describe('ProjectsPipelinesChartsApp', () => {
}); });
}); });
describe('Internal Events RedisHLL events', () => {
it.each`
testId | event
${'pipelines-tab'} | ${'p_analytics_ci_cd_pipelines'}
${'deployment-frequency-tab'} | ${'p_analytics_ci_cd_deployment_frequency'}
${'lead-time-tab'} | ${'p_analytics_ci_cd_lead_time'}
`('tracks the $event event when clicked', ({ testId, event }) => {
const trackApiSpy = jest.spyOn(API, 'trackInternalEvent');
expect(trackApiSpy).not.toHaveBeenCalled();
wrapper.findByTestId(testId).vm.$emit('click');
expect(trackApiSpy).toHaveBeenCalledWith(event);
});
});
describe('Snowplow events', () => { describe('Snowplow events', () => {
it.each` it.each`
testId | event testId | event
...@@ -157,8 +167,7 @@ describe('ProjectsPipelinesChartsApp', () => { ...@@ -157,8 +167,7 @@ describe('ProjectsPipelinesChartsApp', () => {
wrapper.findByTestId(testId).vm.$emit('click'); wrapper.findByTestId(testId).vm.$emit('click');
expect(trackingSpy).toHaveBeenCalledWith(undefined, 'click_tab', { expect(trackingSpy).toHaveBeenCalledWith(undefined, event, {
label: SNOWPLOW_LABEL,
context: { context: {
schema: SNOWPLOW_SCHEMA, schema: SNOWPLOW_SCHEMA,
data: { data: {
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册