Commit 5adcf589 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/343123/postMergeTracking' into 'master'

Added Redis HLL tracking to post merge actions

See merge request gitlab-org/gitlab!74387
parents d18cae2c 89fb46fe
...@@ -23,8 +23,8 @@ export default function initMrNotes() { ...@@ -23,8 +23,8 @@ export default function initMrNotes() {
initNotesApp(); initNotesApp();
document.addEventListener('merged:UpdateActions', () => { document.addEventListener('merged:UpdateActions', () => {
initRevertCommitModal(); initRevertCommitModal('i_code_review_post_merge_submit_revert_modal');
initCherryPickCommitModal(); initCherryPickCommitModal('i_code_review_post_merge_submit_cherry_pick_modal');
}); });
requestIdleCallback(() => { requestIdleCallback(() => {
......
<script> <script>
import { GlModal, GlForm, GlFormCheckbox, GlSprintf, GlFormGroup } from '@gitlab/ui'; import { GlModal, GlForm, GlFormCheckbox, GlSprintf, GlFormGroup } from '@gitlab/ui';
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import api from '~/api';
import { BV_SHOW_MODAL } from '~/lib/utils/constants'; import { BV_SHOW_MODAL } from '~/lib/utils/constants';
import csrf from '~/lib/utils/csrf'; import csrf from '~/lib/utils/csrf';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
...@@ -40,6 +41,11 @@ export default { ...@@ -40,6 +41,11 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
primaryActionEventName: {
type: String,
required: false,
default: null,
},
}, },
data() { data() {
return { return {
...@@ -83,6 +89,10 @@ export default { ...@@ -83,6 +89,10 @@ export default {
this.$root.$emit(BV_SHOW_MODAL, this.modalId); this.$root.$emit(BV_SHOW_MODAL, this.modalId);
}, },
handlePrimary() { handlePrimary() {
if (this.primaryActionEventName) {
api.trackRedisHllUserEvent(this.primaryActionEventName);
}
this.$refs.form.$el.submit(); this.$refs.form.$el.submit();
}, },
resetModalHandler() { resetModalHandler() {
......
...@@ -9,7 +9,7 @@ import { ...@@ -9,7 +9,7 @@ import {
} from './constants'; } from './constants';
import createStore from './store'; import createStore from './store';
export default function initInviteMembersModal() { export default function initInviteMembersModal(primaryActionEventName) {
const el = document.querySelector('.js-cherry-pick-commit-modal'); const el = document.querySelector('.js-cherry-pick-commit-modal');
if (!el) { if (!el) {
return false; return false;
...@@ -52,6 +52,7 @@ export default function initInviteMembersModal() { ...@@ -52,6 +52,7 @@ export default function initInviteMembersModal() {
openModal: OPEN_CHERRY_PICK_MODAL, openModal: OPEN_CHERRY_PICK_MODAL,
modalId: CHERRY_PICK_MODAL_ID, modalId: CHERRY_PICK_MODAL_ID,
isCherryPick: true, isCherryPick: true,
primaryActionEventName,
}, },
}), }),
}); });
......
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
} from './constants'; } from './constants';
import createStore from './store'; import createStore from './store';
export default function initInviteMembersModal() { export default function initInviteMembersModal(primaryActionEventName) {
const el = document.querySelector('.js-revert-commit-modal'); const el = document.querySelector('.js-revert-commit-modal');
if (!el) { if (!el) {
return false; return false;
...@@ -49,6 +49,7 @@ export default function initInviteMembersModal() { ...@@ -49,6 +49,7 @@ export default function initInviteMembersModal() {
i18n: { ...I18N_REVERT_MODAL, ...I18N_MODAL }, i18n: { ...I18N_REVERT_MODAL, ...I18N_MODAL },
openModal: OPEN_REVERT_MODAL, openModal: OPEN_REVERT_MODAL,
modalId: REVERT_MODAL_ID, modalId: REVERT_MODAL_ID,
primaryActionEventName,
}, },
}), }),
}); });
......
<script> <script>
/* eslint-disable @gitlab/vue-require-i18n-strings */ /* eslint-disable @gitlab/vue-require-i18n-strings */
import { GlLoadingIcon, GlButton, GlTooltipDirective, GlIcon } from '@gitlab/ui'; import { GlLoadingIcon, GlButton, GlTooltipDirective, GlIcon } from '@gitlab/ui';
import api from '~/api';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
import { OPEN_REVERT_MODAL, OPEN_CHERRY_PICK_MODAL } from '~/projects/commit/constants'; import { OPEN_REVERT_MODAL, OPEN_CHERRY_PICK_MODAL } from '~/projects/commit/constants';
...@@ -83,6 +84,8 @@ export default { ...@@ -83,6 +84,8 @@ export default {
removeSourceBranch() { removeSourceBranch() {
this.isMakingRequest = true; this.isMakingRequest = true;
api.trackRedisHllUserEvent('i_code_review_post_merge_delete_branch');
this.service this.service
.removeSourceBranch() .removeSourceBranch()
.then((res) => res.data) .then((res) => res.data)
...@@ -103,9 +106,13 @@ export default { ...@@ -103,9 +106,13 @@ export default {
}); });
}, },
openRevertModal() { openRevertModal() {
api.trackRedisHllUserEvent('i_code_review_post_merge_click_revert');
modalEventHub.$emit(OPEN_REVERT_MODAL); modalEventHub.$emit(OPEN_REVERT_MODAL);
}, },
openCherryPickModal() { openCherryPickModal() {
api.trackRedisHllUserEvent('i_code_review_post_merge_click_cherry_pick');
modalEventHub.$emit(OPEN_CHERRY_PICK_MODAL); modalEventHub.$emit(OPEN_CHERRY_PICK_MODAL);
}, },
}, },
......
...@@ -68,6 +68,11 @@ ...@@ -68,6 +68,11 @@
- 'i_code_review_user_searches_diff' - 'i_code_review_user_searches_diff'
- 'i_code_review_user_resolve_thread_in_issue' - 'i_code_review_user_resolve_thread_in_issue'
- 'i_code_review_widget_nothing_merge_click_new_file' - 'i_code_review_widget_nothing_merge_click_new_file'
- 'i_code_review_post_merge_delete_branch'
- 'i_code_review_post_merge_click_revert'
- 'i_code_review_post_merge_click_cherry_pick'
- 'i_code_review_post_merge_submit_revert_modal'
- 'i_code_review_post_merge_submit_cherry_pick_modal'
- name: code_review_category_monthly_active_users - name: code_review_category_monthly_active_users
operator: OR operator: OR
source: redis source: redis
...@@ -128,6 +133,11 @@ ...@@ -128,6 +133,11 @@
- 'i_code_review_user_searches_diff' - 'i_code_review_user_searches_diff'
- 'i_code_review_user_resolve_thread_in_issue' - 'i_code_review_user_resolve_thread_in_issue'
- 'i_code_review_widget_nothing_merge_click_new_file' - 'i_code_review_widget_nothing_merge_click_new_file'
- 'i_code_review_post_merge_delete_branch'
- 'i_code_review_post_merge_click_revert'
- 'i_code_review_post_merge_click_cherry_pick'
- 'i_code_review_post_merge_submit_revert_modal'
- 'i_code_review_post_merge_submit_cherry_pick_modal'
- name: code_review_extension_category_monthly_active_users - name: code_review_extension_category_monthly_active_users
operator: OR operator: OR
source: redis source: redis
......
---
key_path: redis_hll_counters.code_review.i_code_review_post_merge_delete_branch_monthly
description: Count of users who click the delete source branch button after merge
product_section: dev
product_stage: create
product_group: group::code review
product_category: code_review
value_type: number
status: active
milestone: '14.5'
introduced_by_url:
time_frame: 28d
data_source: redis_hll
instrumentation_class: RedisHLLMetric
options:
events:
- i_code_review_post_merge_delete_branch
data_category: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.code_review.i_code_review_post_merge_click_revert_monthly
description: Count of users who click the revert button in the merge requet widget
product_section: dev
product_stage: create
product_group: group::code review
product_category: code_review
value_type: number
status: active
milestone: '14.5'
introduced_by_url:
time_frame: 28d
data_source: redis_hll
instrumentation_class: RedisHLLMetric
options:
events:
- i_code_review_post_merge_click_revert
data_category: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.code_review.i_code_review_post_merge_click_cherry_pick_monthly
description: Count of users who click the cherry pick button in the merge requet widget
product_section: dev
product_stage: create
product_group: group::code review
product_category: code_review
value_type: number
status: active
milestone: '14.5'
introduced_by_url:
time_frame: 28d
data_source: redis_hll
instrumentation_class: RedisHLLMetric
options:
events:
- i_code_review_post_merge_click_cherry_pick
data_category: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.code_review.i_code_review_post_merge_submit_revert_modal_monthly
description: Count of users who submit the post merge revert modal
product_section: dev
product_stage: create
product_group: group::code review
product_category: code_review
value_type: number
status: active
milestone: '14.5'
introduced_by_url:
time_frame: 28d
data_source: redis_hll
instrumentation_class: RedisHLLMetric
options:
events:
- i_code_review_post_merge_submit_revert_modal
data_category: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.code_review.i_code_review_post_merge_submit_cherry_pick_modal_monthly
description: Count of users who submit the post merge revert modal
product_section: dev
product_stage: create
product_group: group::code review
product_category: code_review
value_type: number
status: active
milestone: '14.5'
introduced_by_url:
time_frame: 28d
data_source: redis_hll
instrumentation_class: RedisHLLMetric
options:
events:
- i_code_review_post_merge_submit_cherry_pick_modal
data_category: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.code_review.i_code_review_post_merge_delete_branch_weekly
description: Count of users who click the delete source branch button after merge
product_section: dev
product_stage: create
product_group: group::code review
product_category: code_review
value_type: number
status: active
milestone: '14.5'
introduced_by_url:
time_frame: 7d
data_source: redis_hll
instrumentation_class: RedisHLLMetric
options:
events:
- i_code_review_post_merge_delete_branch
data_category: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.code_review.i_code_review_post_merge_click_revert_weekly
description: Count of users who click the revert button in the merge requet widget
product_section: dev
product_stage: create
product_group: group::code review
product_category: code_review
value_type: number
status: active
milestone: '14.5'
introduced_by_url:
time_frame: 7d
data_source: redis_hll
instrumentation_class: RedisHLLMetric
options:
events:
- i_code_review_post_merge_click_revert
data_category: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.code_review.i_code_review_post_merge_click_cherry_pick_weekly
description: Count of users who click the cherry pick button in the merge requet widget
product_section: dev
product_stage: create
product_group: group::code review
product_category: code_review
value_type: number
status: active
milestone: '14.5'
introduced_by_url:
time_frame: 7d
data_source: redis_hll
instrumentation_class: RedisHLLMetric
options:
events:
- i_code_review_post_merge_click_cherry_pick
data_category: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.code_review.i_code_review_post_merge_submit_revert_modal_weekly
description: Count of users who submit the post merge revert modal
product_section: dev
product_stage: create
product_group: group::code review
product_category: code_review
value_type: number
status: active
milestone: '14.5'
introduced_by_url:
time_frame: 7d
data_source: redis_hll
instrumentation_class: RedisHLLMetric
options:
events:
- i_code_review_post_merge_submit_revert_modal
data_category: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.code_review.i_code_review_post_merge_submit_cherry_pick_modal_weekly
description: Count of users who submit the post merge revert modal
product_section: dev
product_stage: create
product_group: group::code review
product_category: code_review
value_type: number
status: active
milestone: '14.5'
introduced_by_url:
time_frame: 7d
data_source: redis_hll
instrumentation_class: RedisHLLMetric
options:
events:
- i_code_review_post_merge_submit_cherry_pick_modal
data_category: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
...@@ -253,3 +253,23 @@ ...@@ -253,3 +253,23 @@
redis_slot: code_review redis_slot: code_review
category: code_review category: code_review
aggregation: weekly aggregation: weekly
- name: i_code_review_post_merge_delete_branch
redis_slot: code_review
category: code_review
aggregation: weekly
- name: i_code_review_post_merge_click_revert
redis_slot: code_review
category: code_review
aggregation: weekly
- name: i_code_review_post_merge_click_cherry_pick
redis_slot: code_review
category: code_review
aggregation: weekly
- name: i_code_review_post_merge_submit_revert_modal
redis_slot: code_review
category: code_review
aggregation: weekly
- name: i_code_review_post_merge_submit_cherry_pick_modal
redis_slot: code_review
category: code_review
aggregation: weekly
...@@ -3,6 +3,7 @@ import { within } from '@testing-library/dom'; ...@@ -3,6 +3,7 @@ import { within } from '@testing-library/dom';
import { shallowMount, mount, createWrapper } from '@vue/test-utils'; import { shallowMount, mount, createWrapper } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import api from '~/api';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { BV_SHOW_MODAL } from '~/lib/utils/constants'; import { BV_SHOW_MODAL } from '~/lib/utils/constants';
import BranchesDropdown from '~/projects/commit/components/branches_dropdown.vue'; import BranchesDropdown from '~/projects/commit/components/branches_dropdown.vue';
...@@ -12,6 +13,8 @@ import eventHub from '~/projects/commit/event_hub'; ...@@ -12,6 +13,8 @@ import eventHub from '~/projects/commit/event_hub';
import createStore from '~/projects/commit/store'; import createStore from '~/projects/commit/store';
import mockData from '../mock_data'; import mockData from '../mock_data';
jest.mock('~/api');
describe('CommitFormModal', () => { describe('CommitFormModal', () => {
let wrapper; let wrapper;
let store; let store;
...@@ -167,4 +170,16 @@ describe('CommitFormModal', () => { ...@@ -167,4 +170,16 @@ describe('CommitFormModal', () => {
expect(findTargetProject().attributes('value')).toBe('_changed_project_value_'); expect(findTargetProject().attributes('value')).toBe('_changed_project_value_');
}); });
}); });
it('action primary button triggers Redis HLL tracking api call', async () => {
createComponent(mount, {}, {}, { primaryActionEventName: 'test_event' });
await wrapper.vm.$nextTick();
jest.spyOn(findForm().element, 'submit');
getByText(mockData.modalPropsData.i18n.actionPrimaryText).trigger('click');
expect(api.trackRedisHllUserEvent).toHaveBeenCalledWith('test_event');
});
}); });
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