2018-09-25 23:45:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-24 11:17:15 -04:00
|
|
|
class Projects::CycleAnalyticsController < Projects::ApplicationController
|
2016-09-20 09:20:48 -04:00
|
|
|
include ActionView::Helpers::DateHelper
|
2016-09-21 00:27:14 -04:00
|
|
|
include ActionView::Helpers::TextHelper
|
2016-11-07 04:08:18 -05:00
|
|
|
include CycleAnalyticsParams
|
2020-07-17 14:09:20 -04:00
|
|
|
include GracefulTimeoutHandling
|
2022-08-19 05:11:29 -04:00
|
|
|
include ProductAnalyticsTracking
|
2021-11-12 22:09:49 -05:00
|
|
|
extend ::Gitlab::Utils::Override
|
2016-09-17 02:38:23 -04:00
|
|
|
|
2016-08-26 06:54:30 -04:00
|
|
|
before_action :authorize_read_cycle_analytics!
|
2021-11-12 22:09:49 -05:00
|
|
|
before_action :load_value_stream, only: :show
|
2016-08-26 06:54:30 -04:00
|
|
|
|
2022-08-19 05:11:29 -04:00
|
|
|
track_custom_event :show,
|
|
|
|
name: 'p_analytics_valuestream',
|
|
|
|
action: 'perform_analytics_usage_action',
|
|
|
|
label: 'redis_hll_counters.analytics.analytics_total_unique_counts_monthly',
|
|
|
|
destinations: %i[redis_hll snowplow]
|
2020-06-22 11:09:27 -04:00
|
|
|
|
2020-10-08 14:08:32 -04:00
|
|
|
feature_category :planning_analytics
|
2022-05-13 11:07:43 -04:00
|
|
|
urgency :low
|
2020-10-08 14:08:32 -04:00
|
|
|
|
2021-07-15 14:09:37 -04:00
|
|
|
before_action do
|
|
|
|
push_licensed_feature(:cycle_analytics_for_groups) if project.licensed_feature_available?(:cycle_analytics_for_groups)
|
|
|
|
end
|
|
|
|
|
2016-08-24 11:17:15 -04:00
|
|
|
def show
|
2021-06-14 08:10:13 -04:00
|
|
|
@cycle_analytics = Analytics::CycleAnalytics::ProjectLevel.new(project: @project, options: options(cycle_analytics_project_params))
|
2021-11-12 22:09:49 -05:00
|
|
|
@request_params ||= ::Gitlab::Analytics::CycleAnalytics::RequestParams.new(all_cycle_analytics_params)
|
2016-11-22 08:29:25 -05:00
|
|
|
|
2016-09-08 05:33:38 -04:00
|
|
|
respond_to do |format|
|
2019-08-14 12:12:12 -04:00
|
|
|
format.html do
|
|
|
|
Gitlab::UsageDataCounters::CycleAnalyticsCounter.count(:views)
|
|
|
|
|
|
|
|
render :show
|
|
|
|
end
|
|
|
|
format.json do
|
|
|
|
render json: cycle_analytics_json
|
|
|
|
end
|
2016-09-08 05:33:38 -04:00
|
|
|
end
|
2016-08-26 06:48:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-11-12 22:09:49 -05:00
|
|
|
override :all_cycle_analytics_params
|
|
|
|
def all_cycle_analytics_params
|
|
|
|
super.merge({ project: @project, value_stream: @value_stream })
|
|
|
|
end
|
|
|
|
|
|
|
|
def load_value_stream
|
|
|
|
@value_stream = Analytics::CycleAnalytics::ProjectValueStream.build_default_value_stream(@project)
|
|
|
|
end
|
|
|
|
|
2016-11-22 05:46:02 -05:00
|
|
|
def cycle_analytics_json
|
|
|
|
{
|
|
|
|
summary: @cycle_analytics.summary,
|
2016-11-22 08:29:25 -05:00
|
|
|
stats: @cycle_analytics.stats,
|
|
|
|
permissions: @cycle_analytics.permissions(user: current_user)
|
2016-09-20 09:20:48 -04:00
|
|
|
}
|
2016-11-21 09:39:43 -05:00
|
|
|
end
|
2022-08-19 05:11:29 -04:00
|
|
|
|
|
|
|
def tracking_namespace_source
|
|
|
|
project.namespace
|
|
|
|
end
|
|
|
|
|
|
|
|
def tracking_project_source
|
|
|
|
project
|
|
|
|
end
|
2016-08-24 11:17:15 -04:00
|
|
|
end
|