Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/usage_data_counters')
-rw-r--r--lib/gitlab/usage_data_counters/ci_template_unique_counter.rb9
-rw-r--r--lib/gitlab/usage_data_counters/gitlab_cli_activity_unique_counter.rb28
-rw-r--r--lib/gitlab/usage_data_counters/hll_redis_counter.rb13
-rw-r--r--lib/gitlab/usage_data_counters/known_events/ci_templates.yml12
-rw-r--r--lib/gitlab/usage_data_counters/known_events/code_review_events.yml18
-rw-r--r--lib/gitlab/usage_data_counters/known_events/common.yml8
-rw-r--r--lib/gitlab/usage_data_counters/known_events/epic_events.yml30
-rw-r--r--lib/gitlab/usage_data_counters/known_events/error_tracking.yml2
8 files changed, 95 insertions, 25 deletions
diff --git a/lib/gitlab/usage_data_counters/ci_template_unique_counter.rb b/lib/gitlab/usage_data_counters/ci_template_unique_counter.rb
index b8de7de848d..cf3caf3f0c7 100644
--- a/lib/gitlab/usage_data_counters/ci_template_unique_counter.rb
+++ b/lib/gitlab/usage_data_counters/ci_template_unique_counter.rb
@@ -6,13 +6,18 @@ module Gitlab::UsageDataCounters
KNOWN_EVENTS_FILE_PATH = File.expand_path('known_events/ci_templates.yml', __dir__)
class << self
- def track_unique_project_event(project_id:, template:, config_source:)
+ def track_unique_project_event(project:, template:, config_source:, user:)
expanded_template_name = expand_template_name(template)
return unless expanded_template_name
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(
- ci_template_event_name(expanded_template_name, config_source), values: project_id
+ ci_template_event_name(expanded_template_name, config_source), values: project.id
)
+
+ namespace = project.namespace
+ if Feature.enabled?(:route_hll_to_snowplow, namespace, default_enabled: :yaml)
+ Gitlab::Tracking.event(name, 'ci_templates_unique', namespace: namespace, user: user, project: project)
+ end
end
def ci_templates(relative_base = 'lib/gitlab/ci/templates')
diff --git a/lib/gitlab/usage_data_counters/gitlab_cli_activity_unique_counter.rb b/lib/gitlab/usage_data_counters/gitlab_cli_activity_unique_counter.rb
new file mode 100644
index 00000000000..8a57a0331b8
--- /dev/null
+++ b/lib/gitlab/usage_data_counters/gitlab_cli_activity_unique_counter.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module UsageDataCounters
+ module GitLabCliActivityUniqueCounter
+ GITLAB_CLI_API_REQUEST_ACTION = 'i_code_review_user_gitlab_cli_api_request'
+ GITLAB_CLI_USER_AGENT_REGEX = /GitLab\sCLI$/.freeze
+
+ class << self
+ def track_api_request_when_trackable(user_agent:, user:)
+ user_agent&.match?(GITLAB_CLI_USER_AGENT_REGEX) && track_unique_action_by_user(GITLAB_CLI_API_REQUEST_ACTION, user)
+ end
+
+ private
+
+ def track_unique_action_by_user(action, user)
+ return unless user
+
+ track_unique_action(action, user.id)
+ end
+
+ def track_unique_action(action, value)
+ Gitlab::UsageDataCounters::HLLRedisCounter.track_usage_event(action, value)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/usage_data_counters/hll_redis_counter.rb b/lib/gitlab/usage_data_counters/hll_redis_counter.rb
index 474ab9a4dd9..3b34cd77cf5 100644
--- a/lib/gitlab/usage_data_counters/hll_redis_counter.rb
+++ b/lib/gitlab/usage_data_counters/hll_redis_counter.rb
@@ -81,6 +81,12 @@ module Gitlab
track(values, event_name, context: context, time: time)
end
+ # Count unique events for a given time range.
+ #
+ # event_names - The list of the events to count.
+ # start_date - The start date of the time range.
+ # end_date - The end date of the time range.
+ # context - Event context, plan level tracking. Available if set when tracking.
def unique_events(event_names:, start_date:, end_date:, context: '')
count_unique_events(event_names: event_names, start_date: start_date, end_date: end_date, context: context) do |events|
raise SlotMismatch, events unless events_in_same_slot?(events)
@@ -100,6 +106,13 @@ module Gitlab
known_events.select { |event| event[:category] == category.to_s }.map { |event| event[:name] }
end
+ # Recent 7 or 28 days unique events data for events defined in /lib/gitlab/usage_data_counters/known_events/
+ #
+ # - For metrics for which we store a key per day, we have the last 7 days or last 28 days of data.
+ # - For metrics for which we store a key per week, we have the last complete week or last 4 complete weeks
+ # daily or weekly information is in the file we have for events definition /lib/gitlab/usage_data_counters/known_events/
+ # - Most of the metrics have weekly aggregation. We recommend this as it generates fewer keys in Redis to store.
+ # - The aggregation used doesn't affect data granulation.
def unique_events_data
categories.each_with_object({}) do |category, category_results|
events_names = events_for_category(category)
diff --git a/lib/gitlab/usage_data_counters/known_events/ci_templates.yml b/lib/gitlab/usage_data_counters/known_events/ci_templates.yml
index a39fa7aca4f..f179f6d679d 100644
--- a/lib/gitlab/usage_data_counters/known_events/ci_templates.yml
+++ b/lib/gitlab/usage_data_counters/known_events/ci_templates.yml
@@ -219,6 +219,10 @@
category: ci_templates
redis_slot: ci_templates
aggregation: weekly
+- name: p_ci_templates_themekit
+ category: ci_templates
+ redis_slot: ci_templates
+ aggregation: weekly
- name: p_ci_templates_terraform
category: ci_templates
redis_slot: ci_templates
@@ -615,3 +619,11 @@
category: ci_templates
redis_slot: ci_templates
aggregation: weekly
+- name: p_ci_templates_liquibase
+ category: ci_templates
+ redis_slot: ci_templates
+ aggregation: weekly
+- name: p_ci_templates_matlab
+ category: ci_templates
+ redis_slot: ci_templates
+ aggregation: weekly
diff --git a/lib/gitlab/usage_data_counters/known_events/code_review_events.yml b/lib/gitlab/usage_data_counters/known_events/code_review_events.yml
index 42c51ec3921..df2864bba89 100644
--- a/lib/gitlab/usage_data_counters/known_events/code_review_events.yml
+++ b/lib/gitlab/usage_data_counters/known_events/code_review_events.yml
@@ -132,6 +132,11 @@
category: code_review
aggregation: weekly
feature_flag: usage_data_i_code_review_user_jetbrains_api_request
+- name: i_code_review_user_gitlab_cli_api_request
+ redis_slot: code_review
+ category: code_review
+ aggregation: weekly
+ feature_flag: usage_data_i_code_review_user_gitlab_cli_api_request
- name: i_code_review_user_create_mr_from_issue
redis_slot: code_review
category: code_review
@@ -173,62 +178,50 @@
redis_slot: code_review
category: code_review
aggregation: weekly
- feature_flag: diff_settings_usage_data
- name: i_code_review_click_single_file_mode_setting
redis_slot: code_review
category: code_review
aggregation: weekly
- feature_flag: diff_settings_usage_data
- name: i_code_review_click_file_browser_setting
redis_slot: code_review
category: code_review
aggregation: weekly
- feature_flag: diff_settings_usage_data
- name: i_code_review_click_whitespace_setting
redis_slot: code_review
category: code_review
aggregation: weekly
- feature_flag: diff_settings_usage_data
- name: i_code_review_diff_view_inline
redis_slot: code_review
category: code_review
aggregation: weekly
- feature_flag: diff_settings_usage_data
- name: i_code_review_diff_view_parallel
redis_slot: code_review
category: code_review
aggregation: weekly
- feature_flag: diff_settings_usage_data
- name: i_code_review_file_browser_tree_view
redis_slot: code_review
category: code_review
aggregation: weekly
- feature_flag: diff_settings_usage_data
- name: i_code_review_file_browser_list_view
redis_slot: code_review
category: code_review
aggregation: weekly
- feature_flag: diff_settings_usage_data
- name: i_code_review_diff_show_whitespace
redis_slot: code_review
category: code_review
aggregation: weekly
- feature_flag: diff_settings_usage_data
- name: i_code_review_diff_hide_whitespace
redis_slot: code_review
category: code_review
aggregation: weekly
- feature_flag: diff_settings_usage_data
- name: i_code_review_diff_single_file
redis_slot: code_review
category: code_review
aggregation: weekly
- feature_flag: diff_settings_usage_data
- name: i_code_review_diff_multiple_files
redis_slot: code_review
category: code_review
aggregation: weekly
- feature_flag: diff_settings_usage_data
- name: i_code_review_user_load_conflict_ui
redis_slot: code_review
category: code_review
@@ -241,7 +234,6 @@
redis_slot: code_review
category: code_review
aggregation: weekly
- feature_flag: usage_data_diff_searches
- name: i_code_review_total_suggestions_applied
redis_slot: code_review
category: code_review
diff --git a/lib/gitlab/usage_data_counters/known_events/common.yml b/lib/gitlab/usage_data_counters/known_events/common.yml
index fdf4bc58525..0d89a5181ec 100644
--- a/lib/gitlab/usage_data_counters/known_events/common.yml
+++ b/lib/gitlab/usage_data_counters/known_events/common.yml
@@ -25,25 +25,21 @@
redis_slot: edit
expiry: 29
aggregation: daily
- feature_flag: track_editor_edit_actions
- name: g_edit_by_sfe
category: ide_edit
redis_slot: edit
expiry: 29
aggregation: daily
- feature_flag: track_editor_edit_actions
- name: g_edit_by_sse
category: ide_edit
redis_slot: edit
expiry: 29
aggregation: daily
- feature_flag: track_editor_edit_actions
- name: g_edit_by_snippet_ide
category: ide_edit
redis_slot: edit
expiry: 29
aggregation: daily
- feature_flag: track_editor_edit_actions
- name: i_search_total
category: search
redis_slot: search
@@ -343,22 +339,18 @@
redis_slot: secure
category: secure
aggregation: weekly
- feature_flag: users_expanding_widgets_usage_data
- name: users_expanding_testing_code_quality_report
redis_slot: testing
category: testing
aggregation: weekly
- feature_flag: users_expanding_widgets_usage_data
- name: users_expanding_testing_accessibility_report
redis_slot: testing
category: testing
aggregation: weekly
- feature_flag: users_expanding_widgets_usage_data
- name: users_expanding_testing_license_compliance_report
redis_slot: testing
category: testing
aggregation: weekly
- feature_flag: users_expanding_widgets_usage_data
- name: users_visiting_testing_license_compliance_full_report
redis_slot: testing
category: testing
diff --git a/lib/gitlab/usage_data_counters/known_events/epic_events.yml b/lib/gitlab/usage_data_counters/known_events/epic_events.yml
index 62b0d6dea86..82787b7bf29 100644
--- a/lib/gitlab/usage_data_counters/known_events/epic_events.yml
+++ b/lib/gitlab/usage_data_counters/known_events/epic_events.yml
@@ -188,3 +188,33 @@
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
+
+- name: g_project_management_epic_related_added
+ category: epics_usage
+ redis_slot: project_management
+ aggregation: daily
+ feature_flag: track_epics_activity
+
+- name: g_project_management_epic_related_removed
+ category: epics_usage
+ redis_slot: project_management
+ aggregation: daily
+ feature_flag: track_epics_activity
+
+- name: g_project_management_epic_blocking_added
+ category: epics_usage
+ redis_slot: project_management
+ aggregation: daily
+ feature_flag: track_epics_activity
+
+- name: g_project_management_epic_blocking_removed
+ category: epics_usage
+ redis_slot: project_management
+ aggregation: daily
+ feature_flag: track_epics_activity
+
+- name: g_project_management_epic_blocked_added
+ category: epics_usage
+ redis_slot: project_management
+ aggregation: daily
+ feature_flag: track_epics_activity
diff --git a/lib/gitlab/usage_data_counters/known_events/error_tracking.yml b/lib/gitlab/usage_data_counters/known_events/error_tracking.yml
index a56e0a6d370..d80b711f8eb 100644
--- a/lib/gitlab/usage_data_counters/known_events/error_tracking.yml
+++ b/lib/gitlab/usage_data_counters/known_events/error_tracking.yml
@@ -3,9 +3,7 @@
category: error_tracking
redis_slot: error_tracking
aggregation: weekly
- feature_flag: track_error_tracking_activity
- name: error_tracking_view_list
category: error_tracking
redis_slot: error_tracking
aggregation: weekly
- feature_flag: track_error_tracking_activity