summaryrefslogtreecommitdiff
path: root/lib/api/usage_data.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/usage_data.rb')
-rw-r--r--lib/api/usage_data.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/api/usage_data.rb b/lib/api/usage_data.rb
new file mode 100644
index 00000000000..a1512197ee1
--- /dev/null
+++ b/lib/api/usage_data.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+module API
+ class UsageData < Grape::API::Instance
+ before { authenticate! }
+
+ namespace 'usage_data' do
+ before do
+ not_found! unless Feature.enabled?(:usage_data_api)
+ 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