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
5366574c
Commit
5366574c
authored
Feb 01, 2022
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab master
parents
3eb2430a
8391e8a3
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
205 additions
and
8 deletions
+205
-8
.rubocop.yml
.rubocop.yml
+1
-0
app/assets/images/auth_buttons/auth0_64.png
app/assets/images/auth_buttons/auth0_64.png
+0
-0
app/controllers/graphql_controller.rb
app/controllers/graphql_controller.rb
+6
-0
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+12
-6
config/feature_flags/development/jobs_tab_vue.yml
config/feature_flags/development/jobs_tab_vue.yml
+1
-1
config/feature_flags/development/usage_data_i_code_review_user_jetbrains_api_request.yml
...t/usage_data_i_code_review_user_jetbrains_api_request.yml
+8
-0
config/initializers_before_autoloader/004_zeitwerk.rb
config/initializers_before_autoloader/004_zeitwerk.rb
+1
-0
config/metrics/aggregates/code_review.yml
config/metrics/aggregates/code_review.yml
+2
-0
config/metrics/counts_28d/20220121140644_user_jetbrains_api_request_monthly.yml
...28d/20220121140644_user_jetbrains_api_request_monthly.yml
+26
-0
config/metrics/counts_7d/20220121140634_user_jetbrains_api_request_weekly.yml
...s_7d/20220121140634_user_jetbrains_api_request_weekly.yml
+26
-0
lib/api/api.rb
lib/api/api.rb
+4
-0
lib/gitlab/usage_data_counters/jetbrains_plugin_activity_unique_counter.rb
...data_counters/jetbrains_plugin_activity_unique_counter.rb
+28
-0
lib/gitlab/usage_data_counters/known_events/code_review_events.yml
...b/usage_data_counters/known_events/code_review_events.yml
+5
-0
qa/qa.rb
qa/qa.rb
+2
-1
spec/controllers/graphql_controller_spec.rb
spec/controllers/graphql_controller_spec.rb
+20
-0
spec/lib/gitlab/usage_data_counters/jetbrains_plugin_activity_unique_counter_spec.rb
...counters/jetbrains_plugin_activity_unique_counter_spec.rb
+63
-0
No files found.
.rubocop.yml
View file @
5366574c
...
...
@@ -168,6 +168,7 @@ Naming/FileName:
-
GitLab
-
JavaScript
-
VSCode
-
JetBrains
# default ones:
-
CLI
-
DSL
...
...
app/assets/images/auth_buttons/auth0_64.png
View replaced file @
3eb2430a
View file @
5366574c
1.77 KB
|
W:
|
H:
2.81 KB
|
W:
|
H:
2-up
Swipe
Onion skin
app/controllers/graphql_controller.rb
View file @
5366574c
...
...
@@ -31,6 +31,7 @@ class GraphqlController < ApplicationController
before_action
:authorize_access_api!
before_action
:set_user_last_activity
before_action
:track_vs_code_usage
before_action
:track_jetbrains_usage
before_action
:disable_query_limiting
before_action
:limit_query_size
...
...
@@ -137,6 +138,11 @@ class GraphqlController < ApplicationController
.
track_api_request_when_trackable
(
user_agent:
request
.
user_agent
,
user:
current_user
)
end
def
track_jetbrains_usage
Gitlab
::
UsageDataCounters
::
JetBrainsPluginActivityUniqueCounter
.
track_api_request_when_trackable
(
user_agent:
request
.
user_agent
,
user:
current_user
)
end
def
execute_multiplex
GitlabSchema
.
multiplex
(
multiplex_queries
,
context:
context
)
end
...
...
app/helpers/projects_helper.rb
View file @
5366574c
...
...
@@ -62,23 +62,29 @@ module ProjectsHelper
name:
author
.
name
}
author_html
=
[]
inject_classes
=
[
"author-link"
]
if
opts
[
:name
]
inject_classes
.
concat
([
"js-user-link"
,
opts
[
:extra_class
],
opts
[
:mobile_classes
]])
else
inject_classes
.
append
(
"has-tooltip"
)
end
inject_classes
=
inject_classes
.
compact
.
join
(
" "
)
author_html
=
[]
# Build avatar image tag
author_html
<<
link_to_member_avatar
(
author
,
opts
)
if
opts
[
:avatar
]
# Build name span tag
author_html
<<
author_content_tag
(
author
,
opts
)
if
opts
[
:name
]
author_html
<<
capture
(
&
block
)
if
block
author_html
=
author_html
.
join
.
html_safe
if
opts
[
:name
]
link_to
(
author_html
,
user_path
(
author
),
class:
"author-link js-user-link
#{
"
#{
opts
[
:extra_class
]
}
"
if
opts
[
:extra_class
]
}
#{
"
#{
opts
[
:mobile_classes
]
}
"
if
opts
[
:mobile_classes
]
}
"
,
data:
data_attrs
).
html_safe
link_to
(
author_html
,
user_path
(
author
),
class:
inject_classes
,
data:
data_attrs
).
html_safe
else
title
=
opts
[
:title
].
sub
(
":name"
,
sanitize
(
author
.
name
))
link_to
(
author_html
,
user_path
(
author
),
class:
"author-link has-tooltip"
,
title:
title
,
data:
{
container:
'body'
,
qa_selector:
'assignee_link'
}).
html_safe
link_to
(
author_html
,
user_path
(
author
),
class:
inject_classes
,
title:
title
,
data:
{
container:
'body'
,
qa_selector:
'assignee_link'
}).
html_safe
end
end
...
...
config/feature_flags/development/jobs_tab_vue.yml
View file @
5366574c
...
...
@@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/347371
milestone
:
'
14.6'
type
:
development
group
:
group::pipeline execution
default_enabled
:
fals
e
default_enabled
:
tru
e
config/feature_flags/development/usage_data_i_code_review_user_jetbrains_api_request.yml
0 → 100644
View file @
5366574c
---
name
:
usage_data_i_code_review_user_jetbrains_api_request
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/78713
rollout_issue_url
:
milestone
:
'
14.8'
type
:
development
group
:
group::code review
default_enabled
:
true
config/initializers_before_autoloader/004_zeitwerk.rb
View file @
5366574c
...
...
@@ -39,6 +39,7 @@ Rails.autoloaders.each do |autoloader|
'hangouts_chat_http_override'
=>
'HangoutsChatHTTPOverride'
,
'chunked_io'
=>
'ChunkedIO'
,
'http_io'
=>
'HttpIO'
,
'jetbrains_plugin_activity_unique_counter'
=>
'JetBrainsPluginActivityUniqueCounter'
,
'json_formatter'
=>
'JSONFormatter'
,
'json_web_token'
=>
'JSONWebToken'
,
'as_json'
=>
'AsJSON'
,
...
...
config/metrics/aggregates/code_review.yml
View file @
5366574c
...
...
@@ -73,6 +73,7 @@
-
'
i_code_review_post_merge_click_cherry_pick'
-
'
i_code_review_post_merge_submit_revert_modal'
-
'
i_code_review_post_merge_submit_cherry_pick_modal'
-
'
i_code_review_user_jetbrains_api_request'
-
name
:
code_review_category_monthly_active_users
operator
:
OR
source
:
redis
...
...
@@ -144,3 +145,4 @@
time_frame
:
[
7d
,
28d
]
events
:
-
'
i_code_review_user_vs_code_api_request'
-
'
i_code_review_user_jetbrains_api_request'
config/metrics/counts_28d/20220121140644_user_jetbrains_api_request_monthly.yml
0 → 100644
View file @
5366574c
---
key_path
:
redis_hll_counters.code_review.i_code_review_user_jetbrains_api_request_monthly
description
:
Count of unique users per month who use GitLab plugin for JetBrains
product_section
:
dev
product_stage
:
create
product_group
:
group::code review
product_category
:
editor_extension
value_type
:
number
status
:
active
milestone
:
"
14.8"
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/78713
time_frame
:
28d
data_source
:
redis_hll
data_category
:
optional
instrumentation_class
:
RedisHLLMetric
options
:
events
:
-
i_code_review_user_jetbrains_api_request
performance_indicator_type
:
[]
distribution
:
-
ce
-
ee
tier
:
-
free
-
premium
-
ultimate
config/metrics/counts_7d/20220121140634_user_jetbrains_api_request_weekly.yml
0 → 100644
View file @
5366574c
---
key_path
:
redis_hll_counters.code_review.i_code_review_user_jetbrains_api_request_weekly
description
:
Count of unique users per month who use GitLab plugin for JetBrains
product_section
:
dev
product_stage
:
create
product_group
:
group::code review
product_category
:
editor_extension
value_type
:
number
status
:
active
milestone
:
"
14.8"
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/78713
time_frame
:
7d
data_source
:
redis_hll
data_category
:
optional
instrumentation_class
:
RedisHLLMetric
options
:
events
:
-
i_code_review_user_jetbrains_api_request
performance_indicator_type
:
[]
distribution
:
-
ce
-
ee
tier
:
-
free
-
premium
-
ultimate
lib/api/api.rb
View file @
5366574c
...
...
@@ -76,6 +76,10 @@ module API
Gitlab
::
UsageDataCounters
::
VSCodeExtensionActivityUniqueCounter
.
track_api_request_when_trackable
(
user_agent:
request
&
.
user_agent
,
user:
@current_user
)
end
after
do
Gitlab
::
UsageDataCounters
::
JetBrainsPluginActivityUniqueCounter
.
track_api_request_when_trackable
(
user_agent:
request
&
.
user_agent
,
user:
@current_user
)
end
# The locale is set to the current user's locale when `current_user` is loaded
after
{
Gitlab
::
I18n
.
use_default_locale
}
...
...
lib/gitlab/usage_data_counters/jetbrains_plugin_activity_unique_counter.rb
0 → 100644
View file @
5366574c
# frozen_string_literal: true
module
Gitlab
module
UsageDataCounters
module
JetBrainsPluginActivityUniqueCounter
JETBRAINS_API_REQUEST_ACTION
=
'i_code_review_user_jetbrains_api_request'
JETBRAINS_USER_AGENT_REGEX
=
/\Agitlab-jetbrains-plugin/
.
freeze
class
<<
self
def
track_api_request_when_trackable
(
user_agent
:,
user
:)
user_agent
&
.
match?
(
JETBRAINS_USER_AGENT_REGEX
)
&&
track_unique_action_by_user
(
JETBRAINS_API_REQUEST_ACTION
,
user
)
end
private
def
track_unique_action_by_user
(
action
,
user
)
return
unless
user
track_unique_action
(
action
,
user
.
id
)
end
def
track_unique_action
(
action
,
value
)
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
track_usage_event
(
action
,
value
)
end
end
end
end
end
lib/gitlab/usage_data_counters/known_events/code_review_events.yml
View file @
5366574c
...
...
@@ -127,6 +127,11 @@
redis_slot
:
code_review
category
:
code_review
aggregation
:
weekly
-
name
:
i_code_review_user_jetbrains_api_request
redis_slot
:
code_review
category
:
code_review
aggregation
:
weekly
feature_flag
:
usage_data_i_code_review_user_jetbrains_api_request
-
name
:
i_code_review_user_create_mr_from_issue
redis_slot
:
code_review
category
:
code_review
...
...
qa/qa.rb
View file @
5366574c
...
...
@@ -51,7 +51,8 @@ module QA
"smtp"
=>
"SMTP"
,
"otp"
=>
"OTP"
,
"jira_api"
=>
"JiraAPI"
,
"registry_tls"
=>
"RegistryTLS"
"registry_tls"
=>
"RegistryTLS"
,
"jetbrains"
=>
"JetBrains"
)
loader
.
setup
...
...
spec/controllers/graphql_controller_spec.rb
View file @
5366574c
...
...
@@ -124,6 +124,16 @@ RSpec.describe GraphqlController do
post
:execute
end
it
'calls the track jetbrains api when trackable method'
do
agent
=
'gitlab-jetbrains-plugin/0.0.1 intellij-idea/2021.2.4 java/11.0.13 mac-os-x/aarch64/12.1'
request
.
env
[
'HTTP_USER_AGENT'
]
=
agent
expect
(
Gitlab
::
UsageDataCounters
::
JetBrainsPluginActivityUniqueCounter
)
.
to
receive
(
:track_api_request_when_trackable
).
with
(
user_agent:
agent
,
user:
user
)
post
:execute
end
end
context
'when user uses an API token'
do
...
...
@@ -151,6 +161,16 @@ RSpec.describe GraphqlController do
subject
end
it
'calls the track jetbrains api when trackable method'
do
agent
=
'gitlab-jetbrains-plugin/0.0.1 intellij-idea/2021.2.4 java/11.0.13 mac-os-x/aarch64/12.1'
request
.
env
[
'HTTP_USER_AGENT'
]
=
agent
expect
(
Gitlab
::
UsageDataCounters
::
JetBrainsPluginActivityUniqueCounter
)
.
to
receive
(
:track_api_request_when_trackable
).
with
(
user_agent:
agent
,
user:
user
)
subject
end
end
context
'when user is not logged in'
do
...
...
spec/lib/gitlab/usage_data_counters/jetbrains_plugin_activity_unique_counter_spec.rb
0 → 100644
View file @
5366574c
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
shared_examples
'a tracked jetbrains unique action'
do
|
event
|
before
do
stub_application_setting
(
usage_ping_enabled:
true
)
end
def
count_unique
(
date_from
:,
date_to
:)
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
unique_events
(
event_names:
action
,
start_date:
date_from
,
end_date:
date_to
)
end
it
'tracks when the user agent is from jetbrains'
do
aggregate_failures
do
user_agent
=
{
user_agent:
'gitlab-jetbrains-plugin/0.0.1 intellij-idea/2021.2.4 java/11.0.13 mac-os-x/aarch64/12.1'
}
expect
(
track_action
(
user:
user1
,
**
user_agent
)).
to
be_truthy
expect
(
track_action
(
user:
user1
,
**
user_agent
)).
to
be_truthy
expect
(
track_action
(
user:
user2
,
**
user_agent
)).
to
be_truthy
expect
(
count_unique
(
date_from:
time
-
1
.
week
,
date_to:
time
+
1
.
week
)).
to
eq
(
2
)
end
end
it
'does not track when the user agent is not from jetbrains'
do
aggregate_failures
do
user_agent
=
{
user_agent:
'normal_user_agent'
}
expect
(
track_action
(
user:
user1
,
**
user_agent
)).
to
be_falsey
expect
(
track_action
(
user:
user1
,
**
user_agent
)).
to
be_falsey
expect
(
track_action
(
user:
user2
,
**
user_agent
)).
to
be_falsey
expect
(
count_unique
(
date_from:
time
-
1
.
week
,
date_to:
time
+
1
.
week
)).
to
eq
(
0
)
end
end
it
'does not track if user agent is not present'
do
expect
(
track_action
(
user:
nil
,
user_agent:
nil
)).
to
be_nil
end
it
'does not track if user is not present'
do
user_agent
=
{
user_agent:
'gitlab-jetbrains-plugin/0.0.1 intellij-idea/2021.2.4 java/11.0.13 mac-os-x/aarch64/12.1'
}
expect
(
track_action
(
user:
nil
,
**
user_agent
)).
to
be_nil
end
end
RSpec
.
describe
Gitlab
::
UsageDataCounters
::
JetBrainsPluginActivityUniqueCounter
,
:clean_gitlab_redis_shared_state
do
let
(
:user1
)
{
build
(
:user
,
id:
1
)
}
let
(
:user2
)
{
build
(
:user
,
id:
2
)
}
let
(
:time
)
{
Time
.
current
}
context
'when tracking a jetbrains api request'
do
it_behaves_like
'a tracked jetbrains unique action'
do
let
(
:action
)
{
described_class
::
JETBRAINS_API_REQUEST_ACTION
}
def
track_action
(
params
)
described_class
.
track_api_request_when_trackable
(
**
params
)
end
end
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