2019-09-30 21:07:59 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module UsageDataCounters
|
2021-01-29 00:20:46 +05:30
|
|
|
class WebIdeCounter < BaseCounter
|
|
|
|
KNOWN_EVENTS = %w[commits views merge_requests previews terminals pipelines].freeze
|
2020-05-24 23:13:21 +05:30
|
|
|
PREFIX = 'web_ide'
|
2019-09-30 21:07:59 +05:30
|
|
|
|
|
|
|
class << self
|
|
|
|
def increment_commits_count
|
2021-01-29 00:20:46 +05:30
|
|
|
count('commits')
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
2019-10-12 21:52:04 +05:30
|
|
|
|
|
|
|
def increment_merge_requests_count
|
2021-01-29 00:20:46 +05:30
|
|
|
count('merge_requests')
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
def increment_views_count
|
2021-01-29 00:20:46 +05:30
|
|
|
count('views')
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
def increment_terminals_count
|
2021-01-29 00:20:46 +05:30
|
|
|
count('terminals')
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
def increment_pipelines_count
|
2021-01-29 00:20:46 +05:30
|
|
|
count('pipelines')
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
def increment_previews_count
|
|
|
|
return unless Gitlab::CurrentSettings.web_ide_clientside_preview_enabled?
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
count('previews')
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def redis_key(event)
|
2021-01-29 00:20:46 +05:30
|
|
|
require_known_event(event)
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
"#{prefix}_#{event}_count".upcase
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|