Commit 4ddf0ad0 authored by Scott Hampton's avatar Scott Hampton

Add usage ping for generic metrics

Add usage ping to track how many people are
using the generic metrics report in the merge
requests.
parent b3eca770
...@@ -44,6 +44,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -44,6 +44,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
push_frontend_feature_flag(:remove_resolve_note, @project, default_enabled: true) push_frontend_feature_flag(:remove_resolve_note, @project, default_enabled: true)
push_frontend_feature_flag(:test_failure_history, @project) push_frontend_feature_flag(:test_failure_history, @project)
push_frontend_feature_flag(:diffs_gradual_load, @project, default_enabled: true) push_frontend_feature_flag(:diffs_gradual_load, @project, default_enabled: true)
push_frontend_feature_flag(:usage_data_group_code_coverage_visit_total, @project, default_enabled: true)
record_experiment_user(:invite_members_version_a) record_experiment_user(:invite_members_version_a)
record_experiment_user(:invite_members_version_b) record_experiment_user(:invite_members_version_b)
......
---
name: usage_data_group_code_coverage_visit_total
introduced_by_url:
rollout_issue_url:
milestone: '13.8'
type: development
group: group::testing
default_enabled: true
<script> <script>
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import { once } from 'lodash';
import { componentNames } from 'ee/reports/components/issue_body'; import { componentNames } from 'ee/reports/components/issue_body';
import api from '~/api';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import SmartVirtualList from '~/vue_shared/components/smart_virtual_list.vue'; import SmartVirtualList from '~/vue_shared/components/smart_virtual_list.vue';
import ReportSection from '~/reports/components/report_section.vue'; import ReportSection from '~/reports/components/report_section.vue';
import ReportItem from '~/reports/components/report_item.vue'; import ReportItem from '~/reports/components/report_item.vue';
...@@ -15,6 +18,7 @@ export default { ...@@ -15,6 +18,7 @@ export default {
ReportItem, ReportItem,
SmartVirtualList, SmartVirtualList,
}, },
mixins: [glFeatureFlagsMixin()],
props: { props: {
endpoint: { endpoint: {
type: String, type: String,
...@@ -59,6 +63,13 @@ export default { ...@@ -59,6 +63,13 @@ export default {
hasMetrics() { hasMetrics() {
return this.metrics.length > 0; return this.metrics.length > 0;
}, },
handleToggleEvent() {
return once(() => {
if (this.glFeatures.usageDataGroupCodeCoverageVisitTotal) {
api.trackRedisHllUserEvent(this.$options.expandEvent);
}
});
},
}, },
created() { created() {
this.setEndpoint(this.endpoint); this.setEndpoint(this.endpoint);
...@@ -67,6 +78,7 @@ export default { ...@@ -67,6 +78,7 @@ export default {
methods: { methods: {
...mapActions(['setEndpoint', 'fetchMetrics']), ...mapActions(['setEndpoint', 'fetchMetrics']),
}, },
expandEvent: 'group_code_coverage_visit_total',
}; };
</script> </script>
<template> <template>
...@@ -76,7 +88,9 @@ export default { ...@@ -76,7 +88,9 @@ export default {
:loading-text="groupedSummaryText" :loading-text="groupedSummaryText"
:error-text="groupedSummaryText" :error-text="groupedSummaryText"
:has-issues="hasMetrics" :has-issues="hasMetrics"
:should-emit-toggle-event="true"
class="mr-widget-border-top grouped-security-reports mr-report" class="mr-widget-border-top grouped-security-reports mr-report"
@toggleEvent="handleToggleEvent"
> >
<div slot="body" class="mr-widget-grouped-section report-block"> <div slot="body" class="mr-widget-grouped-section report-block">
<smart-virtual-list <smart-virtual-list
......
---
title: Capture generic metrics report views via usage ping
merge_request:
author:
type: added
...@@ -3,6 +3,9 @@ import Vuex from 'vuex'; ...@@ -3,6 +3,9 @@ import Vuex from 'vuex';
import MetricsReportsIssueBody from 'ee/vue_shared/metrics_reports/components/metrics_reports_issue_body.vue'; import MetricsReportsIssueBody from 'ee/vue_shared/metrics_reports/components/metrics_reports_issue_body.vue';
import GroupedMetricsReportsApp from 'ee/vue_shared/metrics_reports/grouped_metrics_reports_app.vue'; import GroupedMetricsReportsApp from 'ee/vue_shared/metrics_reports/grouped_metrics_reports_app.vue';
import { getStoreConfig } from 'ee/vue_shared/metrics_reports/store'; import { getStoreConfig } from 'ee/vue_shared/metrics_reports/store';
import Api from '~/api';
jest.mock('~/api.js');
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
...@@ -11,13 +14,18 @@ describe('Grouped metrics reports app', () => { ...@@ -11,13 +14,18 @@ describe('Grouped metrics reports app', () => {
let wrapper; let wrapper;
let mockStore; let mockStore;
const mountComponent = () => { const findExpandButton = () => wrapper.find('[data-testid="report-section-expand-button"]');
const mountComponent = (glFeatures = {}) => {
wrapper = mount(GroupedMetricsReportsApp, { wrapper = mount(GroupedMetricsReportsApp, {
store: mockStore, store: mockStore,
localVue, localVue,
propsData: { propsData: {
endpoint: 'metrics.json', endpoint: 'metrics.json',
}, },
provide: {
glFeatures,
},
}); });
}; };
...@@ -62,6 +70,43 @@ describe('Grouped metrics reports app', () => { ...@@ -62,6 +70,43 @@ describe('Grouped metrics reports app', () => {
}); });
describe('with metrics', () => { describe('with metrics', () => {
describe('when user expands to view metrics', () => {
beforeEach(() => {
mockStore.state.numberOfChanges = 0;
mockStore.state.existingMetrics = [
{
name: 'name',
value: 'value',
},
];
});
describe('with :usage_data_group_code_coverage_visit_total enabled', () => {
beforeEach(() => {
mountComponent({ usageDataGroupCodeCoverageVisitTotal: true });
});
it('tracks group_code_coverage_visit_total metric', () => {
findExpandButton().trigger('click');
expect(Api.trackRedisHllUserEvent).toHaveBeenCalledTimes(1);
expect(Api.trackRedisHllUserEvent).toHaveBeenCalledWith(wrapper.vm.$options.expandEvent);
});
});
describe('with :usage_data_group_code_coverage_visit_total disabled', () => {
beforeEach(() => {
mountComponent({ usageDataGroupCodeCoverageVisitTotal: false });
});
it('does not track group_code_coverage_visit_total metric', () => {
findExpandButton().trigger('click');
expect(Api.trackRedisHllUserEvent).not.toHaveBeenCalled();
});
});
});
describe('with no changes', () => { describe('with no changes', () => {
beforeEach(() => { beforeEach(() => {
mockStore.state.numberOfChanges = 0; mockStore.state.numberOfChanges = 0;
......
...@@ -248,6 +248,11 @@ ...@@ -248,6 +248,11 @@
redis_slot: testing redis_slot: testing
aggregation: weekly aggregation: weekly
feature_flag: usage_data_i_testing_test_case_parsed feature_flag: usage_data_i_testing_test_case_parsed
- name: group_code_coverage_visit_total
category: testing
redis_slot: testing
aggregation: weekly
feature_flag: usage_data_group_code_coverage_visit_total
# Project Management group # Project Management group
- name: g_project_management_issue_title_changed - name: g_project_management_issue_title_changed
category: issues_edit category: issues_edit
......
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