Commit ccb349c7 authored by Clement Ho's avatar Clement Ho

Merge branch '57318-track-discussion-thread-usage-on-gitlab-com-with-snowplow-ee' into 'master'

Added Snowplow tracking to notes

Closes gitlab-ce#57318

See merge request gitlab-org/gitlab-ee!10104
parents 74e4ace8 38d0d9df
...@@ -50,6 +50,13 @@ export const dasherize = str => str.replace(/[_\s]+/g, '-'); ...@@ -50,6 +50,13 @@ export const dasherize = str => str.replace(/[_\s]+/g, '-');
*/ */
export const slugifyWithHyphens = str => str.toLowerCase().replace(/\s+/g, '-'); export const slugifyWithHyphens = str => str.toLowerCase().replace(/\s+/g, '-');
/**
* Replaces whitespaces with underscore and converts to lower case
* @param {String} str
* @returns {String}
*/
export const slugifyWithUnderscore = str => str.toLowerCase().replace(/\s+/g, '_');
/** /**
* Truncates given text * Truncates given text
* *
......
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
capitalizeFirstCharacter, capitalizeFirstCharacter,
convertToCamelCase, convertToCamelCase,
splitCamelCase, splitCamelCase,
slugifyWithUnderscore,
} from '../../lib/utils/text_utility'; } from '../../lib/utils/text_utility';
import * as constants from '../constants'; import * as constants from '../constants';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
...@@ -129,6 +130,9 @@ export default { ...@@ -129,6 +130,9 @@ export default {
? 'merge request' ? 'merge request'
: 'issue'; : 'issue';
}, },
trackingLabel() {
return slugifyWithUnderscore(`${this.commentButtonTitle} button`);
},
}, },
watch: { watch: {
note(newNote) { note(newNote) {
...@@ -370,6 +374,8 @@ append-right-10 comment-type-dropdown js-comment-type-dropdown droplab-dropdown" ...@@ -370,6 +374,8 @@ append-right-10 comment-type-dropdown js-comment-type-dropdown droplab-dropdown"
class="btn btn-success js-comment-button js-comment-submit-button class="btn btn-success js-comment-button js-comment-submit-button
qa-comment-button" qa-comment-button"
type="submit" type="submit"
:data-track-label="trackingLabel"
data-track-event="click_button"
@click.prevent="handleSave()" @click.prevent="handleSave()"
> >
{{ __(commentButtonTitle) }} {{ __(commentButtonTitle) }}
......
import Vue from 'vue'; import Vue from 'vue';
import { isEE } from '~/lib/utils/common_utils';
import initNoteStats from 'ee_else_ce/event_tracking/notes';
import notesApp from './components/notes_app.vue'; import notesApp from './components/notes_app.vue';
import initDiscussionFilters from './discussion_filters'; import initDiscussionFilters from './discussion_filters';
import createStore from './stores'; import createStore from './stores';
...@@ -38,6 +40,11 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -38,6 +40,11 @@ document.addEventListener('DOMContentLoaded', () => {
notesData: JSON.parse(notesDataset.notesData), notesData: JSON.parse(notesDataset.notesData),
}; };
}, },
mounted() {
if (isEE) {
initNoteStats();
}
},
render(createElement) { render(createElement) {
return createElement('notes-app', { return createElement('notes-app', {
props: { props: {
......
import Stats from 'ee/stats';
export default () => {
document.querySelector('.main-notes-list').addEventListener('click', event => {
const isReplyButtonClick = event.path.find(
el => el.classList && el.classList.contains('js-reply-button'),
);
if (isReplyButtonClick) {
Stats.trackEvent(document.body.dataset.page, 'click_button', {
label: 'reply_comment_button',
property: '',
value: '',
});
}
});
Stats.bindTrackableContainer('.js-main-target-form');
};
---
title: Added Snowplow tracking to notes
merge_request: 10104
author:
type: added
...@@ -144,6 +144,12 @@ describe('text_utility', () => { ...@@ -144,6 +144,12 @@ describe('text_utility', () => {
}); });
}); });
describe('slugifyWithUnderscore', () => {
it('should replaces whitespaces with underscore and convert to lower case', () => {
expect(textUtils.slugifyWithUnderscore('My Input String')).toEqual('my_input_string');
});
});
describe('truncateNamespace', () => { describe('truncateNamespace', () => {
it(`should return the root namespace if the namespace only includes one level`, () => { it(`should return the root namespace if the namespace only includes one level`, () => {
expect(textUtils.truncateNamespace('a / b')).toBe('a'); expect(textUtils.truncateNamespace('a / b')).toBe('a');
......
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