2020-11-24 15:15:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
2021-01-03 14:25:43 +05:30
|
|
|
class UsageData < ::API::Base
|
2020-11-24 15:15:51 +05:30
|
|
|
before { authenticate! }
|
|
|
|
|
|
|
|
namespace 'usage_data' do
|
|
|
|
before do
|
2021-01-03 14:25:43 +05:30
|
|
|
not_found! unless Feature.enabled?(:usage_data_api, default_enabled: true)
|
2020-11-24 15:15:51 +05:30
|
|
|
forbidden!('Invalid CSRF token is provided') unless verified_request?
|
|
|
|
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
|
|
|
|
|
|
|
|
post 'increment_unique_users' do
|
|
|
|
event_name = params[:event]
|
|
|
|
|
|
|
|
increment_unique_values(event_name, current_user.id)
|
|
|
|
|
|
|
|
status :ok
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|