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
7a78f64c
Commit
7a78f64c
authored
Aug 20, 2020
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename TrackUniqueActions -> TrackUniqueEvents
parent
844dc3e0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
28 deletions
+28
-28
app/services/event_create_service.rb
app/services/event_create_service.rb
+3
-3
doc/development/telemetry/usage_ping.md
doc/development/telemetry/usage_ping.md
+3
-3
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+7
-7
lib/gitlab/usage_data_counters/track_unique_events.rb
lib/gitlab/usage_data_counters/track_unique_events.rb
+2
-2
spec/lib/gitlab/usage_data_counters/track_unique_events_spec.rb
...ib/gitlab/usage_data_counters/track_unique_events_spec.rb
+2
-2
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+1
-1
spec/services/event_create_service_spec.rb
spec/services/event_create_service_spec.rb
+10
-10
No files found.
app/services/event_create_service.rb
View file @
7a78f64c
...
...
@@ -109,7 +109,7 @@ class EventCreateService
def
wiki_event
(
wiki_page_meta
,
author
,
action
,
fingerprint
)
raise
IllegalActionError
,
action
unless
Event
::
WIKI_ACTIONS
.
include?
(
action
)
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
.
track_event
(
event_action:
action
,
event_target:
wiki_page_meta
.
class
,
author_id:
author
.
id
)
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
.
track_event
(
event_action:
action
,
event_target:
wiki_page_meta
.
class
,
author_id:
author
.
id
)
duplicate
=
Event
.
for_wiki_meta
(
wiki_page_meta
).
for_fingerprint
(
fingerprint
).
first
return
duplicate
if
duplicate
.
present?
...
...
@@ -154,7 +154,7 @@ class EventCreateService
result
=
Event
.
insert_all
(
attribute_sets
,
returning:
%w[id]
)
tuples
.
each
do
|
record
,
status
,
_
|
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
.
track_event
(
event_action:
status
,
event_target:
record
.
class
,
author_id:
current_user
.
id
)
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
.
track_event
(
event_action:
status
,
event_target:
record
.
class
,
author_id:
current_user
.
id
)
end
result
...
...
@@ -172,7 +172,7 @@ class EventCreateService
new_event
end
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
.
track_event
(
event_action: :pushed
,
event_target:
Project
,
author_id:
current_user
.
id
)
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
.
track_event
(
event_action: :pushed
,
event_target:
Project
,
author_id:
current_user
.
id
)
Users
::
LastPushEventService
.
new
(
current_user
)
.
cache_last_push_event
(
event
)
...
...
doc/development/telemetry/usage_ping.md
View file @
7a78f64c
...
...
@@ -236,7 +236,7 @@ Recommendations:
Examples of implementation:
-
[
`Gitlab::UsageDataCounters::TrackUnique
Action
s`
](
https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data_counters/track_unique_actions.rb
)
-
[
`Gitlab::UsageDataCounters::TrackUnique
Event
s`
](
https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data_counters/track_unique_actions.rb
)
-
[
`Gitlab::Analytics::UniqueVisits`
](
https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/analytics/unique_visits.rb
)
Example of usage:
...
...
@@ -247,10 +247,10 @@ redis_usage_data(Gitlab::UsageDataCounters::WikiPageCounter)
redis_usage_data
{
::
Gitlab
::
UsageCounters
::
PodLogs
.
usage_totals
[
:total
]
}
# Redis HLL counter
counter
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
counter
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
redis_usage_data
do
counter
.
count_unique_events
(
event_action:
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
::
PUSH_ACTION
,
event_action:
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
::
PUSH_ACTION
,
date_from:
time_period
[
:created_at
].
first
,
date_to:
time_period
[
:created_at
].
last
)
...
...
lib/gitlab/usage_data.rb
View file @
7a78f64c
...
...
@@ -604,27 +604,27 @@ module Gitlab
end
def
action_monthly_active_users
(
time_period
)
counter
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
counter
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
project_count
=
redis_usage_data
do
counter
.
count_unique
(
event_action:
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
::
PUSH_ACTION
,
counter
.
count_unique
_events
(
event_action:
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
::
PUSH_ACTION
,
date_from:
time_period
[
:created_at
].
first
,
date_to:
time_period
[
:created_at
].
last
)
end
design_count
=
redis_usage_data
do
counter
.
count_unique
(
event_action:
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
::
DESIGN_ACTION
,
counter
.
count_unique
_events
(
event_action:
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
::
DESIGN_ACTION
,
date_from:
time_period
[
:created_at
].
first
,
date_to:
time_period
[
:created_at
].
last
)
end
wiki_count
=
redis_usage_data
do
counter
.
count_unique
(
event_action:
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
::
WIKI_ACTION
,
counter
.
count_unique
_events
(
event_action:
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
::
WIKI_ACTION
,
date_from:
time_period
[
:created_at
].
first
,
date_to:
time_period
[
:created_at
].
last
)
...
...
lib/gitlab/usage_data_counters/track_unique_
action
s.rb
→
lib/gitlab/usage_data_counters/track_unique_
event
s.rb
View file @
7a78f64c
...
...
@@ -2,7 +2,7 @@
module
Gitlab
module
UsageDataCounters
module
TrackUnique
Action
s
module
TrackUnique
Event
s
KEY_EXPIRY_LENGTH
=
29
.
days
WIKI_ACTION
=
:wiki_action
...
...
@@ -38,7 +38,7 @@ module Gitlab
Gitlab
::
Redis
::
HLL
.
add
(
key:
target_key
,
value:
author_id
,
expiry:
KEY_EXPIRY_LENGTH
)
end
def
count_unique
(
event_action
:,
date_from
:,
date_to
:)
def
count_unique
_events
(
event_action
:,
date_from
:,
date_to
:)
keys
=
(
date_from
.
to_date
..
date_to
.
to_date
).
map
{
|
date
|
key
(
event_action
,
date
)
}
Gitlab
::
Redis
::
HLL
.
count
(
keys:
keys
)
...
...
spec/lib/gitlab/usage_data_counters/track_unique_
action
s_spec.rb
→
spec/lib/gitlab/usage_data_counters/track_unique_
event
s_spec.rb
View file @
7a78f64c
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
RSpec
.
describe
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
,
:clean_gitlab_redis_shared_state
do
RSpec
.
describe
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
,
:clean_gitlab_redis_shared_state
do
subject
(
:track_unique_events
)
{
described_class
}
let
(
:time
)
{
Time
.
zone
.
now
}
...
...
@@ -12,7 +12,7 @@ RSpec.describe Gitlab::UsageDataCounters::TrackUniqueActions, :clean_gitlab_redi
end
def
count_unique
(
params
)
track_unique_events
.
count_unique
(
params
)
track_unique_events
.
count_unique
_events
(
params
)
end
context
'tracking an event'
do
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
7a78f64c
...
...
@@ -912,7 +912,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
let
(
:time
)
{
Time
.
zone
.
now
}
before
do
counter
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
counter
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
project
=
Event
::
TARGET_TYPES
[
:project
]
wiki
=
Event
::
TARGET_TYPES
[
:wiki
]
design
=
Event
::
TARGET_TYPES
[
:design
]
...
...
spec/services/event_create_service_spec.rb
View file @
7a78f64c
...
...
@@ -202,11 +202,11 @@ RSpec.describe EventCreateService do
end
it
'records the event in the event counter'
do
counter_class
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
counter_class
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
tracking_params
=
{
event_action:
counter_class
::
WIKI_ACTION
,
date_from:
Date
.
yesterday
,
date_to:
Date
.
today
}
expect
{
create_event
}
.
to
change
{
counter_class
.
count_unique
(
tracking_params
)
}
.
to
change
{
counter_class
.
count_unique
_events
(
tracking_params
)
}
.
by
(
1
)
end
end
...
...
@@ -243,11 +243,11 @@ RSpec.describe EventCreateService do
it_behaves_like
'service for creating a push event'
,
PushEventPayloadService
it
'records the event in the event counter'
do
counter_class
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
counter_class
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
tracking_params
=
{
event_action:
counter_class
::
PUSH_ACTION
,
date_from:
Date
.
yesterday
,
date_to:
Date
.
today
}
expect
{
subject
}
.
to
change
{
counter_class
.
count_unique
(
tracking_params
)
}
.
to
change
{
counter_class
.
count_unique
_events
(
tracking_params
)
}
.
from
(
0
).
to
(
1
)
end
end
...
...
@@ -266,11 +266,11 @@ RSpec.describe EventCreateService do
it_behaves_like
'service for creating a push event'
,
BulkPushEventPayloadService
it
'records the event in the event counter'
do
counter_class
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
counter_class
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
tracking_params
=
{
event_action:
counter_class
::
PUSH_ACTION
,
date_from:
Date
.
yesterday
,
date_to:
Date
.
today
}
expect
{
subject
}
.
to
change
{
counter_class
.
count_unique
(
tracking_params
)
}
.
to
change
{
counter_class
.
count_unique
_events
(
tracking_params
)
}
.
from
(
0
).
to
(
1
)
end
end
...
...
@@ -320,11 +320,11 @@ RSpec.describe EventCreateService do
end
it
'records the event in the event counter'
do
counter_class
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
counter_class
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
tracking_params
=
{
event_action:
counter_class
::
DESIGN_ACTION
,
date_from:
Date
.
yesterday
,
date_to:
Date
.
today
}
expect
{
result
}
.
to
change
{
counter_class
.
count_unique
(
tracking_params
)
}
.
to
change
{
counter_class
.
count_unique
_events
(
tracking_params
)
}
.
from
(
0
).
to
(
1
)
end
end
...
...
@@ -347,11 +347,11 @@ RSpec.describe EventCreateService do
end
it
'records the event in the event counter'
do
counter_class
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Action
s
counter_class
=
Gitlab
::
UsageDataCounters
::
TrackUnique
Event
s
tracking_params
=
{
event_action:
counter_class
::
DESIGN_ACTION
,
date_from:
Date
.
yesterday
,
date_to:
Date
.
today
}
expect
{
result
}
.
to
change
{
counter_class
.
count_unique
(
tracking_params
)
}
.
to
change
{
counter_class
.
count_unique
_events
(
tracking_params
)
}
.
from
(
0
).
to
(
1
)
end
end
...
...
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