Commit ca701d32 authored by David O'Regan's avatar David O'Regan Committed by Kushal Pandya

Add Wiki format tracking

parent 366d0e49
......@@ -16,9 +16,11 @@ import { __, s__, sprintf } from '~/locale';
import Tracking from '~/tracking';
import MarkdownField from '~/vue_shared/components/markdown/field.vue';
import {
WIKI_CONTENT_EDITOR_TRACKING_LABEL,
CONTENT_EDITOR_LOADED_ACTION,
SAVED_USING_CONTENT_EDITOR_ACTION,
WIKI_CONTENT_EDITOR_TRACKING_LABEL,
WIKI_FORMAT_LABEL,
WIKI_FORMAT_UPDATED_ACTION,
} from '../constants';
const trackingMixin = Tracking.mixin({
......@@ -219,6 +221,8 @@ export default {
this.trackFormSubmit();
}
this.trackWikiFormat();
// Wait until form field values are refreshed
await this.$nextTick();
......@@ -304,6 +308,14 @@ export default {
}
},
trackWikiFormat() {
this.track(WIKI_FORMAT_UPDATED_ACTION, {
label: WIKI_FORMAT_LABEL,
value: this.format,
extra: { project_path: this.pageInfo.path, old_format: this.pageInfo.format },
});
},
dismissContentEditorAlert() {
this.isContentEditorAlertDismissed = true;
},
......
export const WIKI_CONTENT_EDITOR_TRACKING_LABEL = 'wiki_content_editor';
export const CONTENT_EDITOR_LOADED_ACTION = 'content_editor_loaded';
export const SAVED_USING_CONTENT_EDITOR_ACTION = 'saved_using_content_editor';
export const WIKI_CONTENT_EDITOR_TRACKING_LABEL = 'wiki_content_editor';
export const WIKI_FORMAT_LABEL = 'wiki_format';
export const WIKI_FORMAT_UPDATED_ACTION = 'wiki_format_updated';
......@@ -8,9 +8,11 @@ import waitForPromises from 'helpers/wait_for_promises';
import ContentEditor from '~/content_editor/components/content_editor.vue';
import WikiForm from '~/pages/shared/wikis/components/wiki_form.vue';
import {
WIKI_CONTENT_EDITOR_TRACKING_LABEL,
CONTENT_EDITOR_LOADED_ACTION,
SAVED_USING_CONTENT_EDITOR_ACTION,
WIKI_CONTENT_EDITOR_TRACKING_LABEL,
WIKI_FORMAT_LABEL,
WIKI_FORMAT_UPDATED_ACTION,
} from '~/pages/shared/wikis/constants';
import MarkdownField from '~/vue_shared/components/markdown/field.vue';
......@@ -65,7 +67,6 @@ describe('WikiForm', () => {
const pageInfoPersisted = {
...pageInfoNew,
persisted: true,
title: 'My page',
content: ' My page content ',
format: 'markdown',
......@@ -177,7 +178,7 @@ describe('WikiForm', () => {
await wrapper.vm.$nextTick();
expect(wrapper.text()).toContain(titleHelpText);
expect(findTitleHelpLink().attributes().href).toEqual(titleHelpLink);
expect(findTitleHelpLink().attributes().href).toBe(titleHelpLink);
},
);
......@@ -186,7 +187,7 @@ describe('WikiForm', () => {
await wrapper.vm.$nextTick();
expect(findMarkdownHelpLink().attributes().href).toEqual(
expect(findMarkdownHelpLink().attributes().href).toBe(
'/help/user/markdown#wiki-specific-markdown',
);
});
......@@ -220,8 +221,8 @@ describe('WikiForm', () => {
expect(e.preventDefault).not.toHaveBeenCalled();
});
it('does not trigger tracking event', async () => {
expect(trackingSpy).not.toHaveBeenCalled();
it('triggers wiki format tracking event', async () => {
expect(trackingSpy).toHaveBeenCalledTimes(1);
});
it('does not trim page content', () => {
......@@ -273,7 +274,7 @@ describe('WikiForm', () => {
({ persisted, redirectLink }) => {
createWrapper(persisted);
expect(findCancelButton().attributes().href).toEqual(redirectLink);
expect(findCancelButton().attributes().href).toBe(redirectLink);
},
);
});
......@@ -438,7 +439,7 @@ describe('WikiForm', () => {
});
});
it('triggers tracking event on form submit', async () => {
it('triggers tracking events on form submit', async () => {
triggerFormSubmit();
await wrapper.vm.$nextTick();
......@@ -446,6 +447,15 @@ describe('WikiForm', () => {
expect(trackingSpy).toHaveBeenCalledWith(undefined, SAVED_USING_CONTENT_EDITOR_ACTION, {
label: WIKI_CONTENT_EDITOR_TRACKING_LABEL,
});
expect(trackingSpy).toHaveBeenCalledWith(undefined, WIKI_FORMAT_UPDATED_ACTION, {
label: WIKI_FORMAT_LABEL,
value: findFormat().element.value,
extra: {
old_format: pageInfoPersisted.format,
project_path: pageInfoPersisted.path,
},
});
});
it('updates content from content editor on form submit', async () => {
......
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