2019-07-17 19:45:35 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module UsageDataCounters
|
2020-11-13 13:09:11 -05:00
|
|
|
class WebIdeCounter < BaseCounter
|
|
|
|
KNOWN_EVENTS = %w[commits views merge_requests previews terminals pipelines].freeze
|
2020-05-05 23:09:33 -04:00
|
|
|
PREFIX = 'web_ide'
|
2019-07-17 19:45:35 -04:00
|
|
|
|
|
|
|
class << self
|
|
|
|
def increment_commits_count
|
2020-11-13 13:09:11 -05:00
|
|
|
count('commits')
|
2019-07-17 19:45:35 -04:00
|
|
|
end
|
2019-07-19 07:11:27 -04:00
|
|
|
|
|
|
|
def increment_merge_requests_count
|
2020-11-13 13:09:11 -05:00
|
|
|
count('merge_requests')
|
2019-07-19 07:11:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def increment_views_count
|
2020-11-13 13:09:11 -05:00
|
|
|
count('views')
|
2019-07-19 07:11:27 -04:00
|
|
|
end
|
2019-07-20 21:26:19 -04:00
|
|
|
|
2020-05-11 14:09:55 -04:00
|
|
|
def increment_terminals_count
|
2020-11-13 13:09:11 -05:00
|
|
|
count('terminals')
|
2020-05-11 14:09:55 -04:00
|
|
|
end
|
|
|
|
|
2020-05-13 20:07:47 -04:00
|
|
|
def increment_pipelines_count
|
2020-11-13 13:09:11 -05:00
|
|
|
count('pipelines')
|
2020-05-13 20:07:47 -04:00
|
|
|
end
|
|
|
|
|
2019-11-06 04:06:23 -05:00
|
|
|
def increment_previews_count
|
|
|
|
return unless Gitlab::CurrentSettings.web_ide_clientside_preview_enabled?
|
|
|
|
|
2020-11-13 13:09:11 -05:00
|
|
|
count('previews')
|
2020-05-05 23:09:33 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def redis_key(event)
|
2020-11-13 13:09:11 -05:00
|
|
|
require_known_event(event)
|
2020-05-05 23:09:33 -04:00
|
|
|
|
2020-11-13 13:09:11 -05:00
|
|
|
"#{prefix}_#{event}_count".upcase
|
2019-07-20 21:26:19 -04:00
|
|
|
end
|
2019-07-17 19:45:35 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|