Commit ed3b8e59 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '335656-wiki-format-tracking' into 'master'

Add Wiki format tracking

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