summaryrefslogtreecommitdiff
path: root/lib/gitlab/usage_data_counters/work_item_activity_unique_counter.rb
blob: a0fd04596fc6f573586ccfe4c769ec4d46cd23d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# frozen_string_literal: true

module Gitlab
  module UsageDataCounters
    module WorkItemActivityUniqueCounter
      WORK_ITEM_CREATED = 'users_creating_work_items'
      WORK_ITEM_TITLE_CHANGED = 'users_updating_work_item_title'
      WORK_ITEM_DATE_CHANGED = 'users_updating_work_item_dates'
      WORK_ITEM_LABELS_CHANGED = 'users_updating_work_item_labels'

      class << self
        def track_work_item_created_action(author:)
          track_unique_action(WORK_ITEM_CREATED, author)
        end

        def track_work_item_title_changed_action(author:)
          track_unique_action(WORK_ITEM_TITLE_CHANGED, author)
        end

        def track_work_item_date_changed_action(author:)
          track_unique_action(WORK_ITEM_DATE_CHANGED, author)
        end

        def track_work_item_labels_changed_action(author:)
          track_unique_action(WORK_ITEM_LABELS_CHANGED, author)
        end

        private

        def track_unique_action(action, author)
          return unless author

          Gitlab::UsageDataCounters::HLLRedisCounter.track_event(action, values: author.id)
        end
      end
    end
  end
end

# rubocop:disable Layout/LineLength
Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter.prepend_mod_with('Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter')
# rubocop:enable Layout/LineLength