Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ce61a775
Commit
ce61a775
authored
Sep 09, 2020
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add usage_data_api feature
parent
7219ac55
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
config/feature_flags/development/usage_data_api.yml
config/feature_flags/development/usage_data_api.yml
+7
-0
lib/api/usage_data.rb
lib/api/usage_data.rb
+5
-0
spec/requests/api/usage_data_spec.rb
spec/requests/api/usage_data_spec.rb
+15
-1
No files found.
config/feature_flags/development/usage_data_api.yml
0 → 100644
View file @
ce61a775
---
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
lib/api/usage_data.rb
View file @
ce61a775
...
...
@@ -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
]
...
...
spec/requests/api/usage_data_spec.rb
View file @
ce61a775
...
...
@@ -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
]
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment