diff --git a/app/assets/javascripts/vue_shared/components/markdown/comment_templates_dropdown.vue b/app/assets/javascripts/vue_shared/components/markdown/comment_templates_dropdown.vue index b1c6f5e6056f63eca06d1c921ea4252b8717f943..f7f5ccdbf31e070463b3a43cf44d1bb493aa1471 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/comment_templates_dropdown.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/comment_templates_dropdown.vue @@ -4,7 +4,11 @@ import fuzzaldrinPlus from 'fuzzaldrin-plus'; import { getDerivedMergeRequestInformation } from '~/diffs/utils/merge_request'; import { InternalEvents } from '~/tracking'; import savedRepliesQuery from './saved_replies.query.graphql'; -import { TRACKING_SAVED_REPLIES_USE, TRACKING_SAVED_REPLIES_USE_IN_MR } from './constants'; +import { + TRACKING_SAVED_REPLIES_USE, + TRACKING_SAVED_REPLIES_USE_IN_MR, + TRACKING_SAVED_REPLIES_USE_IN_OTHER, +} from './constants'; export default { apollo: { @@ -61,9 +65,9 @@ export default { if (savedReply) { this.$emit('select', savedReply.content); this.track_event(TRACKING_SAVED_REPLIES_USE); - if (isInMr) { - this.track_event(TRACKING_SAVED_REPLIES_USE_IN_MR); - } + this.track_event( + isInMr ? TRACKING_SAVED_REPLIES_USE_IN_MR : TRACKING_SAVED_REPLIES_USE_IN_OTHER, + ); } }, }, diff --git a/app/assets/javascripts/vue_shared/components/markdown/constants.js b/app/assets/javascripts/vue_shared/components/markdown/constants.js index 47ef7cccbc22eebfb230196aa316f32901d1c912..7b31c4a59e3c9c6861539852d843a9043ddf0c0c 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/constants.js +++ b/app/assets/javascripts/vue_shared/components/markdown/constants.js @@ -1,2 +1,3 @@ export const TRACKING_SAVED_REPLIES_USE = 'i_code_review_saved_replies_use'; export const TRACKING_SAVED_REPLIES_USE_IN_MR = 'i_code_review_saved_replies_use_in_mr'; +export const TRACKING_SAVED_REPLIES_USE_IN_OTHER = 'i_code_review_saved_replies_use_in_other'; diff --git a/config/metrics/counts_28d/20210427102618_code_review_category_monthly_active_users.yml b/config/metrics/counts_28d/20210427102618_code_review_category_monthly_active_users.yml index 18f4ed248370b679867d3222c9c82dd7f282e3e3..eeffe48b2565e0ef12dbe813c6d6f53b9817d1c2 100644 --- a/config/metrics/counts_28d/20210427102618_code_review_category_monthly_active_users.yml +++ b/config/metrics/counts_28d/20210427102618_code_review_category_monthly_active_users.yml @@ -142,3 +142,4 @@ options: - 'i_code_review_saved_replies_create' - 'i_code_review_saved_replies_use' - 'i_code_review_saved_replies_use_in_mr' + - 'i_code_review_saved_replies_use_in_other' diff --git a/config/metrics/counts_28d/20210427103119_code_review_group_monthly_active_users.yml b/config/metrics/counts_28d/20210427103119_code_review_group_monthly_active_users.yml index 796acd20d15b39c67a0c6b697b7e5be77f6ab832..36115c9bcc2742f20ea90e196a7f8eade195c73d 100644 --- a/config/metrics/counts_28d/20210427103119_code_review_group_monthly_active_users.yml +++ b/config/metrics/counts_28d/20210427103119_code_review_group_monthly_active_users.yml @@ -147,3 +147,4 @@ options: - 'i_code_review_saved_replies_create' - 'i_code_review_saved_replies_use' - 'i_code_review_saved_replies_use_in_mr' + - 'i_code_review_saved_replies_use_in_other' diff --git a/config/metrics/counts_28d/20230815171559_i_code_review_saved_replies_use_in_other_monthly.yml b/config/metrics/counts_28d/20230815171559_i_code_review_saved_replies_use_in_other_monthly.yml new file mode 100644 index 0000000000000000000000000000000000000000..d05e2f3fbd2ac1114549bc31be3f0b7ec60e429e --- /dev/null +++ b/config/metrics/counts_28d/20230815171559_i_code_review_saved_replies_use_in_other_monthly.yml @@ -0,0 +1,25 @@ +--- +key_path: redis_hll_counters.code_review.i_code_review_saved_replies_use_in_other_monthly +description: Count of unique users who used the saved replies feature over a month +product_section: dev +product_stage: create +product_group: code_review +value_type: number +status: active +milestone: "16.3" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/128822 +time_frame: 28d +data_source: redis_hll +data_category: optional +instrumentation_class: RedisHLLMetric +performance_indicator_type: [] +distribution: +- ce +- ee +tier: +- free +- premium +- ultimate +options: + events: + - i_code_review_saved_replies_use_in_other diff --git a/config/metrics/counts_7d/20210427103328_code_review_group_monthly_active_users.yml b/config/metrics/counts_7d/20210427103328_code_review_group_monthly_active_users.yml index b7a65d38ab3cb75694bae0d5b033ef89c647d723..f159184503cf5b93298740dfa57af21dd2fb796b 100644 --- a/config/metrics/counts_7d/20210427103328_code_review_group_monthly_active_users.yml +++ b/config/metrics/counts_7d/20210427103328_code_review_group_monthly_active_users.yml @@ -145,3 +145,4 @@ options: - 'i_code_review_saved_replies_create' - 'i_code_review_saved_replies_use' - 'i_code_review_saved_replies_use_in_mr' + - 'i_code_review_saved_replies_use_in_other' diff --git a/config/metrics/counts_7d/20210427103407_code_review_category_monthly_active_users.yml b/config/metrics/counts_7d/20210427103407_code_review_category_monthly_active_users.yml index c7c7e248ea0b1cd144a45e26f79a4246bd6a4790..0b93ea59c3ca02425045ac4336abf416db125bbb 100644 --- a/config/metrics/counts_7d/20210427103407_code_review_category_monthly_active_users.yml +++ b/config/metrics/counts_7d/20210427103407_code_review_category_monthly_active_users.yml @@ -140,3 +140,4 @@ options: - 'i_code_review_saved_replies_create' - 'i_code_review_saved_replies_use' - 'i_code_review_saved_replies_use_in_mr' + - 'i_code_review_saved_replies_use_in_other' diff --git a/config/metrics/counts_7d/20230815171559_i_code_review_saved_replies_use_in_other_weekly.yml b/config/metrics/counts_7d/20230815171559_i_code_review_saved_replies_use_in_other_weekly.yml new file mode 100644 index 0000000000000000000000000000000000000000..3c7560ff3adee3ca93a72813cf6c7d9f0cfcac7e --- /dev/null +++ b/config/metrics/counts_7d/20230815171559_i_code_review_saved_replies_use_in_other_weekly.yml @@ -0,0 +1,25 @@ +--- +key_path: redis_hll_counters.code_review.i_code_review_saved_replies_use_in_other_weekly +description: Count of unique users who used the saved replies feature over a week +product_section: dev +product_stage: create +product_group: code_review +value_type: number +status: active +milestone: "16.3" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/128822 +time_frame: 7d +data_source: redis_hll +data_category: optional +instrumentation_class: RedisHLLMetric +performance_indicator_type: [] +distribution: +- ce +- ee +tier: +- free +- premium +- ultimate +options: + events: + - i_code_review_saved_replies_use_in_other diff --git a/config/metrics/counts_all/20230815054809_i_code_review_saved_replies_use_in_other.yml b/config/metrics/counts_all/20230815054809_i_code_review_saved_replies_use_in_other.yml new file mode 100644 index 0000000000000000000000000000000000000000..0ffa90cf458f9eea69e964ba2c9d1a6141ce80d9 --- /dev/null +++ b/config/metrics/counts_all/20230815054809_i_code_review_saved_replies_use_in_other.yml @@ -0,0 +1,25 @@ +--- +key_path: counts.i_code_review_saved_replies_use_in_other +description: Total count of times a saved reply is selected when not in an MR +product_section: dev +product_stage: create +product_group: code_review +value_type: number +status: active +milestone: "16.3" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/128822 +time_frame: all +data_source: redis +data_category: optional +instrumentation_class: RedisMetric +performance_indicator_type: [] +distribution: +- ce +- ee +tier: +- free +- premium +- ultimate +options: + event: use_in_other + prefix: i_code_review_saved_replies diff --git a/spec/frontend/vue_shared/components/markdown/comment_templates_dropdown_spec.js b/spec/frontend/vue_shared/components/markdown/comment_templates_dropdown_spec.js index cd9f27dccbd6e901875f67dfba472c2aafa74414..11c57fc57688a2b535b1bb1826057d2ceba8c994 100644 --- a/spec/frontend/vue_shared/components/markdown/comment_templates_dropdown_spec.js +++ b/spec/frontend/vue_shared/components/markdown/comment_templates_dropdown_spec.js @@ -12,6 +12,7 @@ import savedRepliesQuery from '~/vue_shared/components/markdown/saved_replies.qu import { TRACKING_SAVED_REPLIES_USE, TRACKING_SAVED_REPLIES_USE_IN_MR, + TRACKING_SAVED_REPLIES_USE_IN_OTHER, } from '~/vue_shared/components/markdown/constants'; let wrapper; @@ -87,6 +88,12 @@ describe('Comment templates dropdown', () => { }); describe('tracking', () => { + it('always sends two tracking events', async () => { + await selectSavedReply(); + + expect(trackingSpy).toHaveBeenCalledTimes(2); + }); + it('tracks overall usage', async () => { await selectSavedReply(); @@ -108,7 +115,6 @@ describe('Comment templates dropdown', () => { TRACKING_SAVED_REPLIES_USE_IN_MR, expect.any(Object), ); - expect(trackingSpy).toHaveBeenCalledTimes(2); }); it('is not sent when not in an MR', async () => { @@ -121,7 +127,32 @@ describe('Comment templates dropdown', () => { TRACKING_SAVED_REPLIES_USE_IN_MR, expect.any(Object), ); - expect(trackingSpy).toHaveBeenCalledTimes(1); + }); + }); + + describe('non-MR usage event', () => { + it('is sent when not in an MR', async () => { + window.location.toString.mockReturnValue('this/looks/like/a/-/issues/1'); + + await selectSavedReply(); + + expect(trackingSpy).toHaveBeenCalledWith( + expect.any(String), + TRACKING_SAVED_REPLIES_USE_IN_OTHER, + expect.any(Object), + ); + }); + + it('is not sent when in an MR', async () => { + window.location.toString.mockReturnValue('this/looks/like/a/-/merge_requests/1'); + + await selectSavedReply(); + + expect(trackingSpy).not.toHaveBeenCalledWith( + expect.any(String), + TRACKING_SAVED_REPLIES_USE_IN_OTHER, + expect.any(Object), + ); }); }); });