2020-09-10 12:08:54 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
2020-10-15 00:08:42 +00:00
|
|
|
class UsageData < ::API::Base
|
2020-09-10 12:08:54 +00:00
|
|
|
before { authenticate! }
|
|
|
|
|
2020-12-31 15:10:32 +00:00
|
|
|
feature_category :usage_ping
|
2020-10-30 18:08:56 +00:00
|
|
|
|
2020-09-10 12:08:54 +00:00
|
|
|
namespace 'usage_data' do
|
|
|
|
before do
|
2020-10-15 15:08:45 +00:00
|
|
|
not_found! unless Feature.enabled?(:usage_data_api, default_enabled: true)
|
2020-09-11 12:08:50 +00:00
|
|
|
forbidden!('Invalid CSRF token is provided') unless verified_request?
|
2020-09-10 12:08:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Track usage data events' do
|
|
|
|
detail 'This feature was introduced in GitLab 13.4.'
|
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
|
|
|
requires :event, type: String, desc: 'The event name that should be tracked'
|
|
|
|
end
|
|
|
|
|
2020-11-19 15:09:13 +00:00
|
|
|
post 'increment_counter' do
|
|
|
|
event_name = params[:event]
|
|
|
|
|
|
|
|
increment_counter(event_name)
|
|
|
|
|
|
|
|
status :ok
|
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
|
|
|
requires :event, type: String, desc: 'The event name that should be tracked'
|
|
|
|
end
|
|
|
|
|
2020-09-10 12:08:54 +00:00
|
|
|
post 'increment_unique_users' do
|
|
|
|
event_name = params[:event]
|
|
|
|
|
|
|
|
increment_unique_values(event_name, current_user.id)
|
|
|
|
|
|
|
|
status :ok
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|