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
cda516a5
Commit
cda516a5
authored
Sep 01, 2020
by
Mark Lapierre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch '233786-ppi-unique-audit-events-api' into 'master'"
This reverts merge request !39616
parent
1cb266ed
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
0 additions
and
91 deletions
+0
-91
ee/changelogs/unreleased/233786-ppi-unique-audit-events-api.yml
...ngelogs/unreleased/233786-ppi-unique-audit-events-api.yml
+0
-5
ee/lib/api/audit_events.rb
ee/lib/api/audit_events.rb
+0
-1
ee/lib/api/unique_call_tracking.rb
ee/lib/api/unique_call_tracking.rb
+0
-32
ee/lib/ee/api/groups.rb
ee/lib/ee/api/groups.rb
+0
-2
ee/lib/ee/api/projects.rb
ee/lib/ee/api/projects.rb
+0
-2
ee/spec/requests/api/unique_call_tracking_spec.rb
ee/spec/requests/api/unique_call_tracking_spec.rb
+0
-43
lib/gitlab/usage_data_counters/known_events.yml
lib/gitlab/usage_data_counters/known_events.yml
+0
-5
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+0
-1
No files found.
ee/changelogs/unreleased/233786-ppi-unique-audit-events-api.yml
deleted
100644 → 0
View file @
1cb266ed
---
title
:
Add ability to track unique uses of API endpoints
merge_request
:
39616
author
:
type
:
added
ee/lib/api/audit_events.rb
View file @
cda516a5
...
...
@@ -3,7 +3,6 @@
module
API
class
AuditEvents
<
::
Grape
::
API
::
Instance
include
::
API
::
PaginationParams
use
::
API
::
UniqueCallTracking
,
event_name:
'i_compliance_audit_events_api'
,
feature: :track_unique_visits
before
do
authenticated_as_admin!
...
...
ee/lib/api/unique_call_tracking.rb
deleted
100644 → 0
View file @
1cb266ed
# frozen_string_literal: true
module
API
class
UniqueCallTracking
<
Grape
::
Middleware
::
Base
def
visitor_id
return
context
.
session
[
:visitor_id
]
if
context
.
session
[
:visitor_id
].
present?
return
unless
context
.
current_user
uuid
=
SecureRandom
.
uuid
context
.
session
[
:visitor_id
]
=
uuid
uuid
end
def
track_redis_hll_event
(
event_name
,
feature
)
return
unless
feature_enabled?
(
feature
)
return
unless
visitor_id
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
track_event
(
visitor_id
,
event_name
)
end
def
after
track_redis_hll_event
(
@options
[
:event_name
],
@options
[
:feature
])
nil
end
private
def
feature_enabled?
(
feature
=
:track_unique_visits
)
Feature
.
enabled?
(
feature
)
&&
Gitlab
::
CurrentSettings
.
usage_ping_enabled?
end
end
end
ee/lib/ee/api/groups.rb
View file @
cda516a5
...
...
@@ -89,8 +89,6 @@ module EE
end
segment
':id/audit_events'
do
use
::
API
::
UniqueCallTracking
,
event_name:
'i_compliance_audit_events_api'
,
feature: :track_unique_visits
before
do
authorize!
:admin_group
,
user_group
check_audit_events_available!
(
user_group
)
...
...
ee/lib/ee/api/projects.rb
View file @
cda516a5
...
...
@@ -22,8 +22,6 @@ module EE
end
end
segment
':id/audit_events'
do
use
::
API
::
UniqueCallTracking
,
event_name:
'i_compliance_audit_events_api'
,
feature: :track_unique_visits
before
do
authorize!
:admin_project
,
user_project
check_audit_events_available!
(
user_project
)
...
...
ee/spec/requests/api/unique_call_tracking_spec.rb
deleted
100644 → 0
View file @
1cb266ed
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
API
::
UniqueCallTracking
do
describe
'i_compliance_audit_events_api'
,
:clean_gitlab_redis_shared_state
do
let_it_be
(
:current_user
)
{
create
(
:admin
)
}
let_it_be
(
:group
)
{
create
(
:group
,
owner_id:
current_user
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
before
do
project
.
add_user
(
current_user
,
:maintainer
)
end
context
'after calling all audit_events APIs as a single licensed user'
do
before
do
stub_feature_flags
(
track_unique_visits:
true
)
stub_licensed_features
(
admin_audit_log:
true
)
end
subject
do
travel_to
8
.
days
.
ago
do
get
api
(
'/audit_events'
,
current_user
)
get
api
(
"/groups/
#{
group
.
id
}
/audit_events"
,
current_user
)
get
api
(
"/projects/
#{
project
.
id
}
/audit_events"
,
current_user
)
end
end
it
'tracks 3 separate events'
do
expect
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
).
to
receive
(
:track_event
).
exactly
(
3
).
times
.
with
(
an_instance_of
(
String
),
an_instance_of
(
String
))
subject
end
it
'reports one unique event'
do
subject
expect
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
unique_events
(
event_names:
'i_compliance_audit_events_api'
,
start_date:
2
.
months
.
ago
,
end_date:
Date
.
current
)).
to
eq
(
1
)
end
end
end
end
lib/gitlab/usage_data_counters/known_events.yml
View file @
cda516a5
...
...
@@ -16,11 +16,6 @@
category
:
compliance
redis_slot
:
compliance
aggregation
:
weekly
-
name
:
i_compliance_audit_events_api
category
:
compliance
redis_slot
:
compliance
expiry
:
42
aggregation
:
weekly
# Analytics category
-
name
:
g_analytics_contribution
category
:
analytics
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
cda516a5
...
...
@@ -1069,7 +1069,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
'g_compliance_audit_events'
=>
123
,
'i_compliance_credential_inventory'
=>
123
,
'i_compliance_audit_events'
=>
123
,
'i_compliance_audit_events_api'
=>
123
,
'compliance_unique_visits_for_any_target'
=>
543
,
'compliance_unique_visits_for_any_target_monthly'
=>
987
}
...
...
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