Merge branch '12502-add-view-stats-to-cycle-analytics' into 'master'
Track views of cycle analytics show page See merge request gitlab-org/gitlab-ce!31717
This commit is contained in:
commit
51f40bf971
7 changed files with 47 additions and 2 deletions
|
@ -14,8 +14,14 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController
|
|||
@cycle_analytics_no_data = @cycle_analytics.no_stats?
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render json: cycle_analytics_json }
|
||||
format.html do
|
||||
Gitlab::UsageDataCounters::CycleAnalyticsCounter.count(:views)
|
||||
|
||||
render :show
|
||||
end
|
||||
format.json do
|
||||
render json: cycle_analytics_json
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Track page views for cycle analytics show page
|
||||
merge_request: 31717
|
||||
author:
|
||||
type: added
|
|
@ -143,6 +143,7 @@ module Gitlab
|
|||
Gitlab::UsageDataCounters::NoteCounter,
|
||||
Gitlab::UsageDataCounters::SnippetCounter,
|
||||
Gitlab::UsageDataCounters::SearchCounter,
|
||||
Gitlab::UsageDataCounters::CycleAnalyticsCounter,
|
||||
Gitlab::UsageDataCounters::SourceCodeCounter
|
||||
]
|
||||
end
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Gitlab::UsageDataCounters
|
||||
class CycleAnalyticsCounter < BaseCounter
|
||||
KNOWN_EVENTS = %w[views].freeze
|
||||
PREFIX = 'cycle_analytics'
|
||||
end
|
||||
end
|
|
@ -11,6 +11,20 @@ describe Projects::CycleAnalyticsController do
|
|||
project.add_maintainer(user)
|
||||
end
|
||||
|
||||
context "counting page views for 'show'" do
|
||||
it 'increases the counter' do
|
||||
expect(Gitlab::UsageDataCounters::CycleAnalyticsCounter).to receive(:count).with(:views)
|
||||
|
||||
get(:show,
|
||||
params: {
|
||||
namespace_id: project.namespace,
|
||||
project_id: project
|
||||
})
|
||||
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe 'cycle analytics not set up flag' do
|
||||
context 'with no data' do
|
||||
it 'is true' do
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::UsageDataCounters::CycleAnalyticsCounter do
|
||||
it_behaves_like 'a redis usage counter', 'CycleAnalytics', :views
|
||||
|
||||
it_behaves_like 'a redis usage counter with totals', :cycle_analytics, views: 3
|
||||
end
|
|
@ -59,6 +59,7 @@ describe Gitlab::UsageData do
|
|||
avg_cycle_analytics
|
||||
influxdb_metrics_enabled
|
||||
prometheus_metrics_enabled
|
||||
cycle_analytics_views
|
||||
))
|
||||
|
||||
expect(subject).to include(
|
||||
|
@ -72,6 +73,7 @@ describe Gitlab::UsageData do
|
|||
web_ide_commits: a_kind_of(Integer),
|
||||
web_ide_merge_requests: a_kind_of(Integer),
|
||||
navbar_searches: a_kind_of(Integer),
|
||||
cycle_analytics_views: a_kind_of(Integer),
|
||||
source_code_pushes: a_kind_of(Integer)
|
||||
)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue