Commit 8cfdade4 authored by Phil Hughes's avatar Phil Hughes

Merge branch '216677-track-static-site-editor-initializations' into 'master'

Data: Track number of times the Static Site Editor is initialized

See merge request gitlab-org/gitlab!34215
parents 7d1b05db eb8d4f30
...@@ -18,3 +18,4 @@ export const DEFAULT_HEADING = s__('StaticSiteEditor|Static site editor'); ...@@ -18,3 +18,4 @@ export const DEFAULT_HEADING = s__('StaticSiteEditor|Static site editor');
export const TRACKING_ACTION_CREATE_COMMIT = 'create_commit'; export const TRACKING_ACTION_CREATE_COMMIT = 'create_commit';
export const TRACKING_ACTION_CREATE_MERGE_REQUEST = 'create_merge_request'; export const TRACKING_ACTION_CREATE_MERGE_REQUEST = 'create_merge_request';
export const TRACKING_ACTION_INITIALIZE_EDITOR = 'initialize_editor';
...@@ -7,7 +7,8 @@ import appDataQuery from '../graphql/queries/app_data.query.graphql'; ...@@ -7,7 +7,8 @@ import appDataQuery from '../graphql/queries/app_data.query.graphql';
import sourceContentQuery from '../graphql/queries/source_content.query.graphql'; import sourceContentQuery from '../graphql/queries/source_content.query.graphql';
import submitContentChangesMutation from '../graphql/mutations/submit_content_changes.mutation.graphql'; import submitContentChangesMutation from '../graphql/mutations/submit_content_changes.mutation.graphql';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { LOAD_CONTENT_ERROR } from '../constants'; import Tracking from '~/tracking';
import { LOAD_CONTENT_ERROR, TRACKING_ACTION_INITIALIZE_EDITOR } from '../constants';
import { SUCCESS_ROUTE } from '../router/constants'; import { SUCCESS_ROUTE } from '../router/constants';
export default { export default {
...@@ -59,6 +60,9 @@ export default { ...@@ -59,6 +60,9 @@ export default {
return Boolean(this.sourceContent); return Boolean(this.sourceContent);
}, },
}, },
mounted() {
Tracking.event(document.body.dataset.page, TRACKING_ACTION_INITIALIZE_EDITOR);
},
methods: { methods: {
onDismissError() { onDismissError() {
this.submitChangesError = null; this.submitChangesError = null;
......
---
title: Track when Static Site Editor is initialized
merge_request: 34215
author:
type: added
...@@ -7,6 +7,8 @@ import InvalidContentMessage from '~/static_site_editor/components/invalid_conte ...@@ -7,6 +7,8 @@ import InvalidContentMessage from '~/static_site_editor/components/invalid_conte
import SubmitChangesError from '~/static_site_editor/components/submit_changes_error.vue'; import SubmitChangesError from '~/static_site_editor/components/submit_changes_error.vue';
import submitContentChangesMutation from '~/static_site_editor/graphql/mutations/submit_content_changes.mutation.graphql'; import submitContentChangesMutation from '~/static_site_editor/graphql/mutations/submit_content_changes.mutation.graphql';
import { SUCCESS_ROUTE } from '~/static_site_editor/router/constants'; import { SUCCESS_ROUTE } from '~/static_site_editor/router/constants';
import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
import { TRACKING_ACTION_INITIALIZE_EDITOR } from '~/static_site_editor/constants';
import { import {
projectId as project, projectId as project,
...@@ -17,6 +19,7 @@ import { ...@@ -17,6 +19,7 @@ import {
username, username,
savedContentMeta, savedContentMeta,
submitChangesError, submitChangesError,
trackingCategory,
} from '../mock_data'; } from '../mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -29,6 +32,7 @@ describe('static_site_editor/pages/home', () => { ...@@ -29,6 +32,7 @@ describe('static_site_editor/pages/home', () => {
let $apollo; let $apollo;
let $router; let $router;
let mutateMock; let mutateMock;
let trackingSpy;
const buildApollo = (queries = {}) => { const buildApollo = (queries = {}) => {
mutateMock = jest.fn(); mutateMock = jest.fn();
...@@ -76,10 +80,14 @@ describe('static_site_editor/pages/home', () => { ...@@ -76,10 +80,14 @@ describe('static_site_editor/pages/home', () => {
beforeEach(() => { beforeEach(() => {
buildApollo(); buildApollo();
buildRouter(); buildRouter();
document.body.dataset.page = trackingCategory;
trackingSpy = mockTracking(document.body.dataset.page, undefined, jest.spyOn);
}); });
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
unmockTracking();
wrapper = null; wrapper = null;
$apollo = null; $apollo = null;
}); });
...@@ -208,4 +216,12 @@ describe('static_site_editor/pages/home', () => { ...@@ -208,4 +216,12 @@ describe('static_site_editor/pages/home', () => {
expect($router.push).toHaveBeenCalledWith(SUCCESS_ROUTE); expect($router.push).toHaveBeenCalledWith(SUCCESS_ROUTE);
}); });
}); });
it('tracks when editor is initialized on the mounted lifecycle hook', () => {
buildWrapper();
expect(trackingSpy).toHaveBeenCalledWith(
document.body.dataset.page,
TRACKING_ACTION_INITIALIZE_EDITOR,
);
});
}); });
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