2020-09-10 08:08:54 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
2020-10-14 20:08:42 -04:00
|
|
|
class UsageData < ::API::Base
|
2020-09-10 08:08:54 -04:00
|
|
|
before { authenticate! }
|
|
|
|
|
2020-10-30 14:08:56 -04:00
|
|
|
feature_category :collection
|
|
|
|
|
2020-09-10 08:08:54 -04:00
|
|
|
namespace 'usage_data' do
|
|
|
|
before do
|
2020-10-15 11:08:45 -04:00
|
|
|
not_found! unless Feature.enabled?(:usage_data_api, default_enabled: true)
|
2020-09-11 08:08:50 -04:00
|
|
|
forbidden!('Invalid CSRF token is provided') unless verified_request?
|
2020-09-10 08:08:54 -04: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 10:09:13 -05: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 08:08:54 -04:00
|
|
|
post 'increment_unique_users' do
|
|
|
|
event_name = params[:event]
|
|
|
|
|
|
|
|
increment_unique_values(event_name, current_user.id)
|
|
|
|
|
|
|
|
status :ok
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|