diff --git a/ee/app/assets/javascripts/analytics/dashboards/components/metric_table_cell.vue b/ee/app/assets/javascripts/analytics/dashboards/components/metric_table_cell.vue index 06ccd80f6c45180ed25cfcdba2a5f287c068990b..162a64ecc871e21ec5d2cf1c2c9eeda3aa3f61f5 100644 --- a/ee/app/assets/javascripts/analytics/dashboards/components/metric_table_cell.vue +++ b/ee/app/assets/javascripts/analytics/dashboards/components/metric_table_cell.vue @@ -3,7 +3,7 @@ import { GlIcon, GlLink, GlPopover } from '@gitlab/ui'; import { joinPaths } from '~/lib/utils/url_utility'; import { METRIC_TOOLTIPS } from '~/analytics/shared/constants'; import { s__ } from '~/locale'; -import { TABLE_METRICS } from '../constants'; +import { TABLE_METRICS, CLICK_METRIC_DRILLDOWN_LINK_ACTION } from '../constants'; export default { name: 'MetricTableCell', @@ -45,6 +45,19 @@ export default { popoverTarget() { return `${this.requestPath}__${this.identifier}`.replace('/', '_'); }, + trackingProps() { + return { + 'data-track-action': CLICK_METRIC_DRILLDOWN_LINK_ACTION, + 'data-track-label': `${this.identifier}_drilldown`, + }; + }, + linkProps() { + return { + href: this.link, + 'data-testid': 'metric_label', + ...this.trackingProps, + }; + }, }, i18n: { docsLabel: s__('DORA4Metrics|Go to docs'), @@ -53,7 +66,7 @@ export default { </script> <template> <div> - <gl-link :href="link" data-testid="metric_label">{{ metric.label }}</gl-link> + <gl-link v-bind="linkProps">{{ metric.label }}</gl-link> <gl-icon :id="popoverTarget" data-testid="info_icon" diff --git a/ee/app/assets/javascripts/analytics/dashboards/constants.js b/ee/app/assets/javascripts/analytics/dashboards/constants.js index b660a95634e9b17c22a4370ec8b4ce15d2d52c54..ec97e4f7712405a84dbbef3bcc7c5efb92713a84 100644 --- a/ee/app/assets/javascripts/analytics/dashboards/constants.js +++ b/ee/app/assets/javascripts/analytics/dashboards/constants.js @@ -113,3 +113,5 @@ export const YAML_CONFIG_PATH = '.gitlab/analytics/dashboards/value_streams/valu export const YAML_CONFIG_LOAD_ERROR = s__( 'DORA4Metrics|Failed to load YAML config from Project: %{fullPath}', ); + +export const CLICK_METRIC_DRILLDOWN_LINK_ACTION = 'click_link'; diff --git a/ee/config/events/20230627202806_value_stream_dashboard_click_metrics_drilldown.yml b/ee/config/events/20230627202806_value_stream_dashboard_click_metrics_drilldown.yml new file mode 100644 index 0000000000000000000000000000000000000000..26f87ba870ae7cec9c4d50ed84410cfc0940a56d --- /dev/null +++ b/ee/config/events/20230627202806_value_stream_dashboard_click_metrics_drilldown.yml @@ -0,0 +1,23 @@ +--- +description: "Click Value Stream Dashboard metric drill-down link in comparison table" +category: default +action: click_link +label_description: "`[metric_identifier]_drilldown`" +property_description: +value_description: +extra_properties: +identifiers: +- project +- user +- namespace +product_section: dev +product_stage: plan +product_group: group::optimize +milestone: "16.2" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/125047 +distributions: +- ee +tiers: +#- premium +- ultimate + diff --git a/ee/spec/frontend/analytics/dashboards/components/metric_table_cell_spec.js b/ee/spec/frontend/analytics/dashboards/components/metric_table_cell_spec.js index 389ff319d437996f5dac27413ef2a99d355d5168..66e016f72a077e5f3188c2cd3be8f75a7819183d 100644 --- a/ee/spec/frontend/analytics/dashboards/components/metric_table_cell_spec.js +++ b/ee/spec/frontend/analytics/dashboards/components/metric_table_cell_spec.js @@ -1,6 +1,7 @@ import { GlPopover, GlLink } from '@gitlab/ui'; import { mountExtended } from 'helpers/vue_test_utils_helper'; import MetricTableCell from 'ee/analytics/dashboards/components/metric_table_cell.vue'; +import { CLICK_METRIC_DRILLDOWN_LINK_ACTION } from 'ee/analytics/dashboards/constants'; describe('Metric table cell', () => { let wrapper; @@ -60,4 +61,13 @@ describe('Metric table cell', () => { ); expect(findPopoverLink().text()).toBe(MetricTableCell.i18n.docsLabel); }); + + it('adds tracking data attributes to drilldown link', () => { + createWrapper(); + + expect(findMetricLabel().attributes('data-track-action')).toBe( + CLICK_METRIC_DRILLDOWN_LINK_ACTION, + ); + expect(findMetricLabel().attributes('data-track-label')).toBe(`${identifier}_drilldown`); + }); });