Commit 89fb46fe authored by Phil Hughes's avatar Phil Hughes

Added Redis HLL tracking to post merge actions

Adds tracking events to the buttons in the merged widget
state component.

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/343123
parent 7b03b44b
......@@ -23,8 +23,8 @@ export default function initMrNotes() {
initNotesApp();
document.addEventListener('merged:UpdateActions', () => {
initRevertCommitModal();
initCherryPickCommitModal();
initRevertCommitModal('i_code_review_post_merge_submit_revert_modal');
initCherryPickCommitModal('i_code_review_post_merge_submit_cherry_pick_modal');
});
requestIdleCallback(() => {
......
<script>
import { GlModal, GlForm, GlFormCheckbox, GlSprintf, GlFormGroup } from '@gitlab/ui';
import { mapActions, mapState } from 'vuex';
import api from '~/api';
import { BV_SHOW_MODAL } from '~/lib/utils/constants';
import csrf from '~/lib/utils/csrf';
import eventHub from '../event_hub';
......@@ -40,6 +41,11 @@ export default {
required: false,
default: false,
},
primaryActionEventName: {
type: String,
required: false,
default: null,
},
},
data() {
return {
......@@ -83,6 +89,10 @@ export default {
this.$root.$emit(BV_SHOW_MODAL, this.modalId);
},
handlePrimary() {
if (this.primaryActionEventName) {
api.trackRedisHllUserEvent(this.primaryActionEventName);
}
this.$refs.form.$el.submit();
},
resetModalHandler() {
......
......@@ -9,7 +9,7 @@ import {
} from './constants';
import createStore from './store';
export default function initInviteMembersModal() {
export default function initInviteMembersModal(primaryActionEventName) {
const el = document.querySelector('.js-cherry-pick-commit-modal');
if (!el) {
return false;
......@@ -52,6 +52,7 @@ export default function initInviteMembersModal() {
openModal: OPEN_CHERRY_PICK_MODAL,
modalId: CHERRY_PICK_MODAL_ID,
isCherryPick: true,
primaryActionEventName,
},
}),
});
......
......@@ -10,7 +10,7 @@ import {
} from './constants';
import createStore from './store';
export default function initInviteMembersModal() {
export default function initInviteMembersModal(primaryActionEventName) {
const el = document.querySelector('.js-revert-commit-modal');
if (!el) {
return false;
......@@ -49,6 +49,7 @@ export default function initInviteMembersModal() {
i18n: { ...I18N_REVERT_MODAL, ...I18N_MODAL },
openModal: OPEN_REVERT_MODAL,
modalId: REVERT_MODAL_ID,
primaryActionEventName,
},
}),
});
......
<script>
/* eslint-disable @gitlab/vue-require-i18n-strings */
import { GlLoadingIcon, GlButton, GlTooltipDirective, GlIcon } from '@gitlab/ui';
import api from '~/api';
import createFlash from '~/flash';
import { s__, __ } from '~/locale';
import { OPEN_REVERT_MODAL, OPEN_CHERRY_PICK_MODAL } from '~/projects/commit/constants';
......@@ -83,6 +84,8 @@ export default {
removeSourceBranch() {
this.isMakingRequest = true;
api.trackRedisHllUserEvent('i_code_review_post_merge_delete_branch');
this.service
.removeSourceBranch()
.then((res) => res.data)
......@@ -103,9 +106,13 @@ export default {
});
},
openRevertModal() {
api.trackRedisHllUserEvent('i_code_review_post_merge_click_revert');
modalEventHub.$emit(OPEN_REVERT_MODAL);
},
openCherryPickModal() {
api.trackRedisHllUserEvent('i_code_review_post_merge_click_cherry_pick');
modalEventHub.$emit(OPEN_CHERRY_PICK_MODAL);
},
},
......
......@@ -68,6 +68,11 @@
- 'i_code_review_user_searches_diff'
- 'i_code_review_user_resolve_thread_in_issue'
- '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
operator: OR
source: redis
......@@ -128,6 +133,11 @@
- 'i_code_review_user_searches_diff'
- 'i_code_review_user_resolve_thread_in_issue'
- '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
operator: OR
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 @@
redis_slot: code_review
category: code_review
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';
import { shallowMount, mount, createWrapper } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import api from '~/api';
import axios from '~/lib/utils/axios_utils';
import { BV_SHOW_MODAL } from '~/lib/utils/constants';
import BranchesDropdown from '~/projects/commit/components/branches_dropdown.vue';
......@@ -12,6 +13,8 @@ import eventHub from '~/projects/commit/event_hub';
import createStore from '~/projects/commit/store';
import mockData from '../mock_data';
jest.mock('~/api');
describe('CommitFormModal', () => {
let wrapper;
let store;
......@@ -167,4 +170,16 @@ describe('CommitFormModal', () => {
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