From d891db7abf85f48c84f3ab58232d39935c83ef57 Mon Sep 17 00:00:00 2001 From: Thomas Randolph Date: Tue, 8 Aug 2023 16:58:13 -0600 Subject: [PATCH 1/5] Add tracking for when saved replies are used in non-MR places --- .../markdown/comment_templates_dropdown.vue | 12 ++++++++---- .../vue_shared/components/markdown/constants.js | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) 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 b1c6f5e6056f63..f7f5ccdbf31e07 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 47ef7cccbc22ee..7b31c4a59e3c9c 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'; -- GitLab From b7e0d5a5f2b3af2d38faf4e3fa4fac70cf53e38b Mon Sep 17 00:00:00 2001 From: Thomas Randolph Date: Mon, 14 Aug 2023 23:46:09 -0600 Subject: [PATCH 2/5] Test tracking saved replies not in MRs --- .../comment_templates_dropdown_spec.js | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) 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 cd9f27dccbd6e9..11c57fc57688a2 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), + ); }); }); }); -- GitLab From 6f399b87062244c128606dc47a2cf34fc368c68f Mon Sep 17 00:00:00 2001 From: Thomas Randolph Date: Mon, 14 Aug 2023 23:50:25 -0600 Subject: [PATCH 3/5] Add total count metric for saved reply usage not in MRs --- ...code_review_saved_replies_use_in_other.yml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 config/metrics/counts_all/20230815054809_i_code_review_saved_replies_use_in_other.yml 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 00000000000000..0ffa90cf458f9e --- /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 -- GitLab From eb345aec67ec3f1d05e2f52f5a68b79a6d7cdc96 Mon Sep 17 00:00:00 2001 From: Thomas Randolph Date: Tue, 15 Aug 2023 11:21:35 -0600 Subject: [PATCH 4/5] Add unique user metrics for saved reply usage not in MRs --- ...iew_saved_replies_use_in_other_monthly.yml | 25 +++++++++++++++++++ ...view_saved_replies_use_in_other_weekly.yml | 25 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 config/metrics/counts_28d/20230815171559_i_code_review_saved_replies_use_in_other_monthly.yml create mode 100644 config/metrics/counts_7d/20230815171559_i_code_review_saved_replies_use_in_other_weekly.yml 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 00000000000000..d05e2f3fbd2ac1 --- /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/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 00000000000000..3c7560ff3adee3 --- /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 -- GitLab From 5e1da4e186b7a84714c00bf2b03abcdfd31a2b81 Mon Sep 17 00:00:00 2001 From: Thomas Randolph Date: Tue, 15 Aug 2023 11:46:22 -0600 Subject: [PATCH 5/5] Add saved reply usage events to known event lists --- .../20210427102618_code_review_category_monthly_active_users.yml | 1 + .../20210427103119_code_review_group_monthly_active_users.yml | 1 + .../20210427103328_code_review_group_monthly_active_users.yml | 1 + .../20210427103407_code_review_category_monthly_active_users.yml | 1 + 4 files changed, 4 insertions(+) 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 18f4ed248370b6..eeffe48b2565e0 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 796acd20d15b39..36115c9bcc2742 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_7d/20210427103328_code_review_group_monthly_active_users.yml b/config/metrics/counts_7d/20210427103328_code_review_group_monthly_active_users.yml index b7a65d38ab3cb7..f159184503cf5b 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 c7c7e248ea0b1c..0b93ea59c3ca02 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' -- GitLab