blob: a9e8d9bf0cb21b1e6ed9342ebfb776350f55c503 (
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
|
# frozen_string_literal: true
module Gitlab
module UsageDataCounters
module JetBrainsBundledPluginActivityUniqueCounter
JETBRAINS_BUNDLED_API_REQUEST_ACTION = 'i_editor_extensions_user_jetbrains_bundled_api_request'
JETBRAINS_BUNDLED_USER_AGENT_REGEX = /\AIntelliJ-GitLab-Plugin/
class << self
def track_api_request_when_trackable(user_agent:, user:)
user_agent&.match?(JETBRAINS_BUNDLED_USER_AGENT_REGEX) &&
track_unique_action_by_user(JETBRAINS_BUNDLED_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
|