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
2a131ae6
Commit
2a131ae6
authored
3 years ago
by
Pavel Shutsin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add separate tab tracking for devops adoption
We need to have devops_score and devops_adoption separated
parent
c30fc3d8
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
187 additions
and
22 deletions
+187
-22
app/controllers/admin/dev_ops_report_controller.rb
app/controllers/admin/dev_ops_report_controller.rb
+6
-2
app/helpers/analytics/unique_visits_helper.rb
app/helpers/analytics/unique_visits_helper.rb
+1
-1
config/feature_flags/development/usage_data_i_analytics_dev_ops_adoption.yml
...s/development/usage_data_i_analytics_dev_ops_adoption.yml
+8
-0
doc/development/usage_ping/dictionary.md
doc/development/usage_ping/dictionary.md
+24
-0
ee/app/assets/javascripts/analytics/devops_report/tabs.js
ee/app/assets/javascripts/analytics/devops_report/tabs.js
+9
-1
ee/app/controllers/ee/admin/dev_ops_report_controller.rb
ee/app/controllers/ee/admin/dev_ops_report_controller.rb
+9
-0
ee/changelogs/unreleased/324226-separate-tracking-for-devops-adoption-page.yml
...sed/324226-separate-tracking-for-devops-adoption-page.yml
+5
-0
ee/config/metrics/counts_28d/20210401092244_i_analytics_dev_ops_adoption_monthly.yml
...d/20210401092244_i_analytics_dev_ops_adoption_monthly.yml
+19
-0
ee/config/metrics/counts_7d/20210401092244_i_analytics_dev_ops_adoption_weekly.yml
...7d/20210401092244_i_analytics_dev_ops_adoption_weekly.yml
+19
-0
ee/spec/controllers/admin/dev_ops_report_controller_spec.rb
ee/spec/controllers/admin/dev_ops_report_controller_spec.rb
+17
-0
ee/spec/frontend/analytics/devops_report/tabs_spec.js
ee/spec/frontend/analytics/devops_report/tabs_spec.js
+37
-0
lib/gitlab/analytics/unique_visits.rb
lib/gitlab/analytics/unique_visits.rb
+2
-2
lib/gitlab/usage_data_counters/known_events/common.yml
lib/gitlab/usage_data_counters/known_events/common.yml
+5
-0
spec/controllers/admin/dev_ops_report_controller_spec.rb
spec/controllers/admin/dev_ops_report_controller_spec.rb
+7
-1
spec/lib/gitlab/analytics/unique_visits_spec.rb
spec/lib/gitlab/analytics/unique_visits_spec.rb
+11
-11
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+1
-0
spec/support/shared_examples/controllers/unique_visits_shared_examples.rb
...red_examples/controllers/unique_visits_shared_examples.rb
+7
-4
No files found.
app/controllers/admin/dev_ops_report_controller.rb
View file @
2a131ae6
# frozen_string_literal: true
class
Admin::DevOpsReportController
<
Admin
::
ApplicationController
include
Analytics
::
UniqueVisitsHelper
include
RedisTracking
helper_method
:show_adoption?
track_
unique_visits
:show
,
target_id:
'i_analytics_dev_ops_score'
track_
redis_hll_event
:show
,
name:
'i_analytics_dev_ops_score'
,
if:
->
{
should_track_devops_score?
}
feature_category
:devops_reports
...
...
@@ -18,6 +18,10 @@ class Admin::DevOpsReportController < Admin::ApplicationController
def
show_adoption?
false
end
def
should_track_devops_score?
true
end
end
Admin
::
DevOpsReportController
.
prepend_if_ee
(
'EE::Admin::DevOpsReportController'
)
This diff is collapsed.
Click to expand it.
app/helpers/analytics/unique_visits_helper.rb
View file @
2a131ae6
...
...
@@ -16,7 +16,7 @@ module Analytics
def
track_visit
(
target_id
)
return
unless
visitor_id
Gitlab
::
Analytics
::
UniqueVisits
.
new
.
track_visit
(
visitor_id
,
target
_id
)
Gitlab
::
Analytics
::
UniqueVisits
.
new
.
track_visit
(
target_id
,
values:
visitor
_id
)
end
class_methods
do
...
...
This diff is collapsed.
Click to expand it.
config/feature_flags/development/usage_data_i_analytics_dev_ops_adoption.yml
0 → 100644
View file @
2a131ae6
---
name
:
usage_data_i_analytics_dev_ops_adoption
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57104
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/326450
milestone
:
'
13.11'
type
:
development
group
:
group::optimize
default_enabled
:
true
This diff is collapsed.
Click to expand it.
doc/development/usage_ping/dictionary.md
View file @
2a131ae6
...
...
@@ -7364,6 +7364,30 @@ Status: `data_available`
Tiers:
### `redis_hll_counters.analytics.i_analytics_dev_ops_adoption_monthly`
Counts visits to DevOps Adoption page per month
[
YAML definition
](
https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210401092244_i_analytics_dev_ops_adoption_monthly.yml
)
Group:
`group::optimize`
Status:
`implemented`
Tiers:
`premium`
,
`ultimate`
### `redis_hll_counters.analytics.i_analytics_dev_ops_adoption_weekly`
Counts visits to DevOps Adoption page per week
[
YAML definition
](
https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210401092244_i_analytics_dev_ops_adoption_weekly.yml
)
Group:
`group::optimize`
Status:
`implemented`
Tiers:
`premium`
,
`ultimate`
### `redis_hll_counters.analytics.i_analytics_dev_ops_score_monthly`
Missing description
...
...
This diff is collapsed.
Click to expand it.
ee/app/assets/javascripts/analytics/devops_report/tabs.js
View file @
2a131ae6
import
Api
from
'
~/api
'
;
import
{
historyPushState
}
from
'
~/lib/utils/common_utils
'
;
import
{
mergeUrlParams
}
from
'
~/lib/utils/url_utility
'
;
const
DEVOPS_ADOPTION_PANE
=
'
devops-adoption
'
;
const
DEVOPS_ADOPTION_PANE_TAB_CLICK_EVENT
=
'
i_analytics_dev_ops_adoption
'
;
const
tabClickHandler
=
(
e
)
=>
{
const
{
hash
}
=
e
.
currentTarget
;
const
tab
=
hash
===
`#
${
DEVOPS_ADOPTION_PANE
}
`
?
DEVOPS_ADOPTION_PANE
:
null
;
let
tab
=
null
;
if
(
hash
===
`#
${
DEVOPS_ADOPTION_PANE
}
`
)
{
tab
=
DEVOPS_ADOPTION_PANE
;
Api
.
trackRedisHllUserEvent
(
DEVOPS_ADOPTION_PANE_TAB_CLICK_EVENT
);
}
const
newUrl
=
mergeUrlParams
({
tab
},
window
.
location
.
href
);
historyPushState
(
newUrl
);
};
...
...
This diff is collapsed.
Click to expand it.
ee/app/controllers/ee/admin/dev_ops_report_controller.rb
View file @
2a131ae6
...
...
@@ -3,6 +3,15 @@
module
EE
module
Admin
module
DevOpsReportController
extend
ActiveSupport
::
Concern
prepended
do
track_redis_hll_event
:show
,
name:
'i_analytics_dev_ops_adoption'
,
if:
->
{
params
[
:tab
]
==
'devops-adoption'
}
end
def
should_track_devops_score?
params
[
:tab
]
!=
'devops-adoption'
end
def
show_adoption?
feature_already_in_use
=
::
Analytics
::
DevopsAdoption
::
Segment
.
any?
...
...
This diff is collapsed.
Click to expand it.
ee/changelogs/unreleased/324226-separate-tracking-for-devops-adoption-page.yml
0 → 100644
View file @
2a131ae6
---
title
:
Add separate tab tracking for devops adoption
merge_request
:
57104
author
:
type
:
added
This diff is collapsed.
Click to expand it.
ee/config/metrics/counts_28d/20210401092244_i_analytics_dev_ops_adoption_monthly.yml
0 → 100644
View file @
2a131ae6
---
# See Usage Ping metrics dictionary docs https://docs.gitlab.com/ee/development/usage_ping/metrics_dictionary.html
key_path
:
redis_hll_counters.analytics.i_analytics_dev_ops_adoption_monthly
description
:
Counts visits to DevOps Adoption page per month
product_section
:
dev
product_stage
:
manage
product_group
:
group::optimize
product_category
:
devops_reports
value_type
:
number
status
:
implemented
milestone
:
"
13.11"
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57104
time_frame
:
28d
data_source
:
redis_hll
distribution
:
-
ee
tier
:
-
premium
-
ultimate
This diff is collapsed.
Click to expand it.
ee/config/metrics/counts_7d/20210401092244_i_analytics_dev_ops_adoption_weekly.yml
0 → 100644
View file @
2a131ae6
---
# See Usage Ping metrics dictionary docs https://docs.gitlab.com/ee/development/usage_ping/metrics_dictionary.html
key_path
:
redis_hll_counters.analytics.i_analytics_dev_ops_adoption_weekly
description
:
Counts visits to DevOps Adoption page per week
product_section
:
dev
product_stage
:
manage
product_group
:
group::optimize
product_category
:
devops_reports
value_type
:
number
status
:
implemented
milestone
:
"
13.11"
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57104
time_frame
:
7d
data_source
:
redis_hll
distribution
:
-
ee
tier
:
-
premium
-
ultimate
This diff is collapsed.
Click to expand it.
ee/spec/controllers/admin/dev_ops_report_controller_spec.rb
View file @
2a131ae6
...
...
@@ -30,4 +30,21 @@ RSpec.describe Admin::DevOpsReportController do
end
end
end
describe
'#show'
do
let
(
:user
)
{
create
(
:admin
)
}
before
do
sign_in
(
user
)
end
context
'when devops_adoption tab selected'
do
it
'tracks devops_adoption usage event'
do
expect
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
)
.
to
receive
(
:track_event
).
with
(
'i_analytics_dev_ops_adoption'
,
values:
kind_of
(
String
))
get
:show
,
params:
{
tab:
'devops-adoption'
},
format: :html
end
end
end
end
This diff is collapsed.
Click to expand it.
ee/spec/frontend/analytics/devops_report/tabs_spec.js
0 → 100644
View file @
2a131ae6
import
initTabs
from
'
ee/analytics/devops_report/tabs
'
;
import
Api
from
'
~/api
'
;
jest
.
mock
(
'
~/api.js
'
);
jest
.
mock
(
'
~/lib/utils/common_utils
'
);
describe
(
'
tabs
'
,
()
=>
{
beforeEach
(()
=>
{
setFixtures
(
`
<div>
<div class="js-devops-tab-item">
<a href="#devops-score" data-testid='score-tab'>Score</a>
</div>
<div class="js-devops-tab-item">
<a href="#devops-adoption" data-testid='devops-adoption-tab'>Adoption</a>
</div>
</div`
);
initTabs
();
});
afterEach
(()
=>
{});
describe
(
'
tracking
'
,
()
=>
{
it
(
'
tracks event when adoption tab is clicked
'
,
()
=>
{
document
.
querySelector
(
'
[data-testid="devops-adoption-tab"]
'
).
click
();
expect
(
Api
.
trackRedisHllUserEvent
).
toHaveBeenCalledWith
(
'
i_analytics_dev_ops_adoption
'
);
});
it
(
'
does not track an event when score tab is clicked
'
,
()
=>
{
document
.
querySelector
(
'
[data-testid="score-tab"]
'
).
click
();
expect
(
Api
.
trackRedisHllUserEvent
).
not
.
toHaveBeenCalled
();
});
});
});
This diff is collapsed.
Click to expand it.
lib/gitlab/analytics/unique_visits.rb
View file @
2a131ae6
...
...
@@ -3,8 +3,8 @@
module
Gitlab
module
Analytics
class
UniqueVisits
def
track_visit
(
visitor_id
,
target_id
,
time
=
Time
.
zone
.
now
)
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
track_event
(
target_id
,
values:
visitor_id
,
time:
time
)
def
track_visit
(
*
args
,
**
kwargs
)
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
track_event
(
*
args
,
**
kwargs
)
end
# Returns number of unique visitors for given targets in given time frame
...
...
This diff is collapsed.
Click to expand it.
lib/gitlab/usage_data_counters/known_events/common.yml
View file @
2a131ae6
...
...
@@ -91,6 +91,11 @@
redis_slot
:
analytics
aggregation
:
weekly
feature_flag
:
track_unique_visits
-
name
:
i_analytics_dev_ops_adoption
category
:
analytics
redis_slot
:
analytics
aggregation
:
weekly
feature_flag
:
track_unique_visits
-
name
:
g_analytics_merge_request
category
:
analytics
redis_slot
:
analytics
...
...
This diff is collapsed.
Click to expand it.
spec/controllers/admin/dev_ops_report_controller_spec.rb
View file @
2a131ae6
...
...
@@ -5,7 +5,13 @@ require 'spec_helper'
RSpec
.
describe
Admin
::
DevOpsReportController
do
describe
'show_adoption?'
do
it
'is always false'
do
expect
(
controller
.
show_adoption?
).
to
be
false
expect
(
controller
.
show_adoption?
).
to
be_falsey
end
end
describe
'should_track_devops_score?'
do
it
'is always true'
do
expect
(
controller
.
should_track_devops_score?
).
to
be_truthy
end
end
...
...
This diff is collapsed.
Click to expand it.
spec/lib/gitlab/analytics/unique_visits_spec.rb
View file @
2a131ae6
...
...
@@ -24,18 +24,18 @@ RSpec.describe Gitlab::Analytics::UniqueVisits, :clean_gitlab_redis_shared_state
describe
'#track_visit'
do
it
'tracks the unique weekly visits for targets'
do
unique_visits
.
track_visit
(
visitor1_id
,
target1_id
,
7
.
days
.
ago
)
unique_visits
.
track_visit
(
visitor1_id
,
target1_id
,
7
.
days
.
ago
)
unique_visits
.
track_visit
(
visitor2_id
,
target1_id
,
7
.
days
.
ago
)
unique_visits
.
track_visit
(
target1_id
,
values:
visitor1_id
,
time:
7
.
days
.
ago
)
unique_visits
.
track_visit
(
target1_id
,
values:
visitor1_id
,
time:
7
.
days
.
ago
)
unique_visits
.
track_visit
(
target1_id
,
values:
visitor2_id
,
time:
7
.
days
.
ago
)
unique_visits
.
track_visit
(
visitor2_id
,
target2_id
,
7
.
days
.
ago
)
unique_visits
.
track_visit
(
visitor1_id
,
target2_id
,
8
.
days
.
ago
)
unique_visits
.
track_visit
(
visitor1_id
,
target2_id
,
15
.
days
.
ago
)
unique_visits
.
track_visit
(
target2_id
,
values:
visitor2_id
,
time:
7
.
days
.
ago
)
unique_visits
.
track_visit
(
target2_id
,
values:
visitor1_id
,
time:
8
.
days
.
ago
)
unique_visits
.
track_visit
(
target2_id
,
values:
visitor1_id
,
time:
15
.
days
.
ago
)
unique_visits
.
track_visit
(
visitor3_id
,
target4_id
,
7
.
days
.
ago
)
unique_visits
.
track_visit
(
target4_id
,
values:
visitor3_id
,
time:
7
.
days
.
ago
)
unique_visits
.
track_visit
(
visitor3_id
,
target5_id
,
15
.
days
.
ago
)
unique_visits
.
track_visit
(
visitor2_id
,
target5_id
,
15
.
days
.
ago
)
unique_visits
.
track_visit
(
target5_id
,
values:
visitor3_id
,
time:
15
.
days
.
ago
)
unique_visits
.
track_visit
(
target5_id
,
values:
visitor2_id
,
time:
15
.
days
.
ago
)
expect
(
unique_visits
.
unique_visits_for
(
targets:
target1_id
)).
to
eq
(
2
)
expect
(
unique_visits
.
unique_visits_for
(
targets:
target2_id
)).
to
eq
(
1
)
...
...
@@ -61,7 +61,7 @@ RSpec.describe Gitlab::Analytics::UniqueVisits, :clean_gitlab_redis_shared_state
end
it
'sets the keys in Redis to expire automatically after 12 weeks'
do
unique_visits
.
track_visit
(
visitor1_id
,
target
1_id
)
unique_visits
.
track_visit
(
target1_id
,
values:
visitor
1_id
)
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
redis
.
scan_each
(
match:
"{
#{
target1_id
}
}-*"
).
each
do
|
key
|
...
...
@@ -74,7 +74,7 @@ RSpec.describe Gitlab::Analytics::UniqueVisits, :clean_gitlab_redis_shared_state
invalid_target_id
=
"x_invalid"
expect
do
unique_visits
.
track_visit
(
visitor1_id
,
invalid_target
_id
)
unique_visits
.
track_visit
(
invalid_target_id
,
values:
visitor1
_id
)
end
.
to
raise_error
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
::
UnknownEvent
)
end
end
...
...
This diff is collapsed.
Click to expand it.
spec/lib/gitlab/usage_data_spec.rb
View file @
2a131ae6
...
...
@@ -1291,6 +1291,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
'p_analytics_repo'
=>
123
,
'i_analytics_cohorts'
=>
123
,
'i_analytics_dev_ops_score'
=>
123
,
'i_analytics_dev_ops_adoption'
=>
123
,
'i_analytics_instance_statistics'
=>
123
,
'p_analytics_merge_request'
=>
123
,
'g_analytics_merge_request'
=>
123
,
...
...
This diff is collapsed.
Click to expand it.
spec/support/shared_examples/controllers/unique_visits_shared_examples.rb
View file @
2a131ae6
...
...
@@ -4,27 +4,30 @@ RSpec.shared_examples 'tracking unique visits' do |method|
let
(
:request_params
)
{
{}
}
it
'tracks unique visit if the format is HTML'
do
expect_any_instance_of
(
Gitlab
::
Analytics
::
UniqueVisits
).
to
receive
(
:track_visit
).
with
(
instance_of
(
String
),
target_id
)
expect
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
)
.
to
receive
(
:track_event
).
with
(
target_id
,
values:
kind_of
(
String
))
get
method
,
params:
request_params
,
format: :html
end
it
'tracks unique visit if DNT is not enabled'
do
expect_any_instance_of
(
Gitlab
::
Analytics
::
UniqueVisits
).
to
receive
(
:track_visit
).
with
(
instance_of
(
String
),
target_id
)
expect
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
)
.
to
receive
(
:track_event
).
with
(
target_id
,
values:
kind_of
(
String
))
request
.
headers
[
'DNT'
]
=
'0'
get
method
,
params:
request_params
,
format: :html
end
it
'does not track unique visit if DNT is enabled'
do
expect
_any_instance_of
(
Gitlab
::
Analytics
::
UniqueVisits
).
not_to
receive
(
:track_visi
t
)
expect
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
).
not_to
receive
(
:track_even
t
)
request
.
headers
[
'DNT'
]
=
'1'
get
method
,
params:
request_params
,
format: :html
end
it
'does not track unique visit if the format is JSON'
do
expect
_any_instance_of
(
Gitlab
::
Analytics
::
UniqueVisits
).
not_to
receive
(
:track_visi
t
)
expect
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
).
not_to
receive
(
:track_even
t
)
get
method
,
params:
request_params
,
format: :json
end
...
...
This diff is collapsed.
Click to expand it.
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