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
d9438d1a
Commit
d9438d1a
authored
Jan 22, 2021
by
Mario de la Ossa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track monthly active users for QuickActions
Anonymously track how many unique users are using QuickActions
parent
4e1d6192
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
619 additions
and
1 deletion
+619
-1
app/services/quick_actions/interpret_service.rb
app/services/quick_actions/interpret_service.rb
+9
-0
changelogs/unreleased/292391-quickactions-usage-ping.yml
changelogs/unreleased/292391-quickactions-usage-ping.yml
+5
-0
config/feature_flags/development/usage_data_track_quickactions.yml
...ature_flags/development/usage_data_track_quickactions.yml
+8
-0
lib/gitlab/usage_data_counters/known_events/quickactions.yml
lib/gitlab/usage_data_counters/known_events/quickactions.yml
+326
-0
lib/gitlab/usage_data_counters/quick_action_activity_unique_counter.rb
...age_data_counters/quick_action_activity_unique_counter.rb
+88
-0
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
.../lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
+2
-1
spec/lib/gitlab/usage_data_counters/quick_action_activity_unique_counter_spec.rb
...ata_counters/quick_action_activity_unique_counter_spec.rb
+163
-0
spec/services/quick_actions/interpret_service_spec.rb
spec/services/quick_actions/interpret_service_spec.rb
+18
-0
No files found.
app/services/quick_actions/interpret_service.rb
View file @
d9438d1a
...
...
@@ -164,6 +164,7 @@ module QuickActions
next
unless
definition
definition
.
execute
(
self
,
arg
)
usage_ping_tracking
(
name
,
arg
)
end
end
...
...
@@ -178,6 +179,14 @@ module QuickActions
ext
.
references
(
type
)
end
# rubocop: enable CodeReuse/ActiveRecord
def
usage_ping_tracking
(
quick_action_name
,
arg
)
Gitlab
::
UsageDataCounters
::
QuickActionActivityUniqueCounter
.
track_unique_action
(
quick_action_name
,
args:
arg
&
.
strip
,
user:
current_user
)
end
end
end
...
...
changelogs/unreleased/292391-quickactions-usage-ping.yml
0 → 100644
View file @
d9438d1a
---
title
:
Track monthly active users for QuickActions
merge_request
:
52398
author
:
type
:
added
config/feature_flags/development/usage_data_track_quickactions.yml
0 → 100644
View file @
d9438d1a
---
name
:
usage_data_track_quickactions
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/52398
rollout_issue_url
:
milestone
:
'
13.9'
type
:
development
group
:
group::project management
default_enabled
:
false
lib/gitlab/usage_data_counters/known_events/quickactions.yml
0 → 100644
View file @
d9438d1a
---
-
name
:
i_quickactions_approve
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_assign_single
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_assign_multiple
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_assign_self
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_assign_reviewer
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_award
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_board_move
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_child_epic
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_clear_weight
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_clone
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_close
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_confidential
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_copy_metadata_merge_request
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_copy_metadata_issue
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_create_merge_request
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_done
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_draft
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_due
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_duplicate
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_epic
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_estimate
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_iteration
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_label
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_lock
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_merge
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_milestone
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_move
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_parent_epic
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_promote
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_publish
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_reassign
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_reassign_reviewer
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_rebase
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_relabel
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_relate
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_remove_child_epic
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_remove_due_date
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_remove_epic
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_remove_estimate
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_remove_iteration
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_remove_milestone
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_remove_parent_epic
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_remove_time_spent
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_remove_zoom
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_reopen
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_shrug
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_spend_subtract
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_spend_add
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_submit_review
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_subscribe
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_tableflip
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_tag
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_target_branch
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_title
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_todo
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_unassign_specific
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_unassign_all
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_unassign_reviewer
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_unlabel_specific
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_unlabel_all
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_unlock
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_unsubscribe
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_weight
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_wip
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
-
name
:
i_quickactions_zoom
category
:
quickactions
redis_slot
:
quickactions
aggregation
:
weekly
feature_flag
:
usage_data_track_quickactions
lib/gitlab/usage_data_counters/quick_action_activity_unique_counter.rb
0 → 100644
View file @
d9438d1a
# frozen_string_literal: true
module
Gitlab
module
UsageDataCounters
module
QuickActionActivityUniqueCounter
class
<<
self
# Tracks the quick action with name `name`.
# `args` is expected to be a single string, will be split internally when necessary.
def
track_unique_action
(
name
,
args
:,
user
:)
return
unless
Feature
.
enabled?
(
:usage_data_track_quickactions
,
default_enabled: :yaml
)
return
unless
user
args
||=
''
name
=
prepare_name
(
name
,
args
)
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
track_event
(
:"i_quickactions_
#{
name
}
"
,
values:
user
.
id
)
end
private
def
prepare_name
(
name
,
args
)
case
name
when
'assign'
event_name_for_assign
(
args
)
when
'copy_metadata'
event_name_for_copy_metadata
(
args
)
when
'remove_reviewer'
'unassign_reviewer'
when
'request_review'
,
'reviewer'
'assign_reviewer'
when
'spend'
event_name_for_spend
(
args
)
when
'unassign'
event_name_for_unassign
(
args
)
when
'unlabel'
,
'remove_label'
event_name_for_unlabel
(
args
)
else
name
end
end
def
event_name_for_assign
(
args
)
args
=
args
.
split
if
args
.
count
==
1
&&
args
.
first
==
'me'
'assign_self'
elsif
args
.
count
==
1
'assign_single'
else
'assign_multiple'
end
end
def
event_name_for_copy_metadata
(
args
)
if
args
.
start_with?
(
'#'
)
'copy_metadata_issue'
else
'copy_metadata_merge_request'
end
end
def
event_name_for_spend
(
args
)
if
args
.
start_with?
(
'-'
)
'spend_subtract'
else
'spend_add'
end
end
def
event_name_for_unassign
(
args
)
if
args
.
present?
'unassign_specific'
else
'unassign_all'
end
end
def
event_name_for_unlabel
(
args
)
if
args
.
present?
'unlabel_specific'
else
'unlabel_all'
end
end
end
end
end
end
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
View file @
d9438d1a
...
...
@@ -39,7 +39,8 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
'snippets'
,
'code_review'
,
'terraform'
,
'ci_templates'
'ci_templates'
,
'quickactions'
)
end
end
...
...
spec/lib/gitlab/usage_data_counters/quick_action_activity_unique_counter_spec.rb
0 → 100644
View file @
d9438d1a
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Gitlab
::
UsageDataCounters
::
QuickActionActivityUniqueCounter
,
:clean_gitlab_redis_shared_state
do
let
(
:user
)
{
build
(
:user
,
id:
1
)
}
let
(
:note
)
{
build
(
:note
,
author:
user
)
}
let
(
:args
)
{
nil
}
shared_examples_for
'a tracked quick action unique event'
do
specify
do
expect
{
3
.
times
{
subject
}
}
.
to
change
{
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
unique_events
(
event_names:
action
,
start_date:
2
.
weeks
.
ago
,
end_date:
2
.
weeks
.
from_now
)
}
.
by
(
1
)
end
end
subject
{
described_class
.
track_unique_action
(
quickaction_name
,
args:
args
,
user:
user
)
}
describe
'.track_unique_action'
do
let
(
:quickaction_name
)
{
'approve'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_approve'
}
end
end
context
'tracking assigns'
do
let
(
:quickaction_name
)
{
'assign'
}
context
'single assignee'
do
let
(
:args
)
{
'@one'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_assign_single'
}
end
end
context
'multiple assignees'
do
let
(
:args
)
{
'@one @two'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_assign_multiple'
}
end
end
context
'assigning "me"'
do
let
(
:args
)
{
'me'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_assign_self'
}
end
end
context
'assigning a reviewer'
do
let
(
:quickaction_name
)
{
'assign_reviewer'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_assign_reviewer'
}
end
end
context
'assigning a reviewer with request review alias'
do
let
(
:quickaction_name
)
{
'request_review'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_assign_reviewer'
}
end
end
end
context
'tracking copy_metadata'
do
let
(
:quickaction_name
)
{
'copy_metadata'
}
context
'for issues'
do
let
(
:args
)
{
'#123'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_copy_metadata_issue'
}
end
end
context
'for merge requests'
do
let
(
:args
)
{
'!123'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_copy_metadata_merge_request'
}
end
end
end
context
'tracking spend'
do
let
(
:quickaction_name
)
{
'spend'
}
context
'adding time'
do
let
(
:args
)
{
'1d'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_spend_add'
}
end
end
context
'removing time'
do
let
(
:args
)
{
'-1d'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_spend_subtract'
}
end
end
end
context
'tracking unassign'
do
let
(
:quickaction_name
)
{
'unassign'
}
context
'unassigning everyone'
do
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_unassign_all'
}
end
end
context
'unassigning specific users'
do
let
(
:args
)
{
'@hello'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_unassign_specific'
}
end
end
end
context
'tracking unlabel'
do
context
'called as unlabel'
do
let
(
:quickaction_name
)
{
'unlabel'
}
context
'removing all labels'
do
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_unlabel_all'
}
end
end
context
'removing specific labels'
do
let
(
:args
)
{
'~wow'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_unlabel_specific'
}
end
end
end
context
'called as remove_label'
do
let
(
:quickaction_name
)
{
'remove_label'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_unlabel_all'
}
end
end
end
end
spec/services/quick_actions/interpret_service_spec.rb
View file @
d9438d1a
...
...
@@ -1793,6 +1793,24 @@ RSpec.describe QuickActions::InterpretService do
expect
(
text
).
to
eq
(
" - list
\n\n
test"
)
end
it
'tracks MAU for commands'
do
content
=
"/shrug test
\n
/assign me
\n
/milestone %4"
expect
(
Gitlab
::
UsageDataCounters
::
QuickActionActivityUniqueCounter
)
.
to
receive
(
:track_unique_action
)
.
with
(
'shrug'
,
args:
'test'
,
user:
developer
)
expect
(
Gitlab
::
UsageDataCounters
::
QuickActionActivityUniqueCounter
)
.
to
receive
(
:track_unique_action
)
.
with
(
'assign'
,
args:
'me'
,
user:
developer
)
expect
(
Gitlab
::
UsageDataCounters
::
QuickActionActivityUniqueCounter
)
.
to
receive
(
:track_unique_action
)
.
with
(
'milestone'
,
args:
'%4'
,
user:
developer
)
service
.
execute
(
content
,
issue
)
end
context
'/create_merge_request command'
do
let
(
:branch_name
)
{
'1-feature'
}
let
(
:content
)
{
"/create_merge_request
#{
branch_name
}
"
}
...
...
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