Commit ce61a775 authored by alinamihaila's avatar alinamihaila

Add usage_data_api feature

parent 7219ac55
---
name: usage_data_api
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/41301
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/235459
group: group::telemetry
type: development
default_enabled: true
......@@ -14,6 +14,10 @@ module API
end
namespace 'usage_data' do
before do
not_found! unless Feature.enabled?(:usage_data_api, default_enabled: true)
end
desc 'Track usage data events' do
detail 'This feature was introduced in GitLab 13.4.'
end
......@@ -22,6 +26,7 @@ module API
requires :name, type: String, desc: 'The event name it should be tracked'
requires :values, type: Array, desc: 'The values counted'
end
post 'increment_unique_values' do
event_name = params[:name]
values = params[:values]
......
......@@ -10,6 +10,16 @@ RSpec.describe API::UsageData do
let(:known_event) { 'g_compliance_dashboard' }
let(:unknown_event) { 'unknown' }
context 'usage_data_api feature not enabled' do
it 'retruns not_found' do
stub_feature_flags(usage_data_api: false)
post api(endpoint, user), params: { values: [user.id] }
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'without authentication' do
it 'returns 401 response' do
post api(endpoint), params: { values: [user.id] }
......@@ -18,7 +28,11 @@ RSpec.describe API::UsageData do
end
end
context 'without authentication' do
context 'with authentication' do
before do
stub_feature_flags(usage_data_api: true)
end
context 'when name is missing from params' do
it 'returns bad request' do
post api(endpoint, user), params: { values: [user.id] }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment