2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
class Projects::CycleAnalyticsController < Projects::ApplicationController
|
|
|
|
include ActionView::Helpers::DateHelper
|
|
|
|
include ActionView::Helpers::TextHelper
|
2017-08-17 22:00:37 +05:30
|
|
|
include CycleAnalyticsParams
|
2020-10-24 23:57:45 +05:30
|
|
|
include GracefulTimeoutHandling
|
2022-10-11 01:57:18 +05:30
|
|
|
include ProductAnalyticsTracking
|
2023-06-20 00:43:36 +05:30
|
|
|
include Gitlab::Utils::StrongMemoize
|
2021-12-11 22:18:48 +05:30
|
|
|
extend ::Gitlab::Utils::Override
|
2016-09-29 09:46:39 +05:30
|
|
|
|
|
|
|
before_action :authorize_read_cycle_analytics!
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
track_event :show,
|
2022-10-11 01:57:18 +05:30
|
|
|
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-07-28 23:09:34 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
feature_category :planning_analytics
|
2022-07-16 23:28:13 +05:30
|
|
|
urgency :low
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
before_action do
|
|
|
|
push_licensed_feature(:cycle_analytics_for_groups) if project.licensed_feature_available?(:cycle_analytics_for_groups)
|
2023-05-27 22:25:52 +05:30
|
|
|
push_licensed_feature(:group_level_analytics_dashboard) if project.licensed_feature_available?(:group_level_analytics_dashboard)
|
|
|
|
push_frontend_feature_flag(:group_analytics_dashboards_page, @project.namespace)
|
2023-06-20 00:43:36 +05:30
|
|
|
|
|
|
|
if project.licensed_feature_available?(:cycle_analytics_for_projects)
|
|
|
|
push_licensed_feature(:cycle_analytics_for_projects)
|
|
|
|
push_frontend_feature_flag(:vsa_group_and_project_parity, @project)
|
|
|
|
end
|
2021-09-30 23:02:18 +05:30
|
|
|
end
|
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
def show
|
2021-09-04 01:27:46 +05:30
|
|
|
@cycle_analytics = Analytics::CycleAnalytics::ProjectLevel.new(project: @project, options: options(cycle_analytics_project_params))
|
2021-12-11 22:18:48 +05:30
|
|
|
@request_params ||= ::Gitlab::Analytics::CycleAnalytics::RequestParams.new(all_cycle_analytics_params)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
respond_to do |format|
|
2019-10-12 21:52:04 +05:30
|
|
|
format.html do
|
|
|
|
Gitlab::UsageDataCounters::CycleAnalyticsCounter.count(:views)
|
|
|
|
|
|
|
|
render :show
|
|
|
|
end
|
|
|
|
format.json do
|
|
|
|
render json: cycle_analytics_json
|
|
|
|
end
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
override :all_cycle_analytics_params
|
|
|
|
def all_cycle_analytics_params
|
2023-06-20 00:43:36 +05:30
|
|
|
super.merge({ namespace: @project.project_namespace, value_stream: value_stream })
|
2021-12-11 22:18:48 +05:30
|
|
|
end
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
def value_stream
|
|
|
|
Analytics::CycleAnalytics::ValueStream.build_default_value_stream(@project.project_namespace)
|
2021-12-11 22:18:48 +05:30
|
|
|
end
|
2023-06-20 00:43:36 +05:30
|
|
|
strong_memoize_attr :value_stream
|
2021-12-11 22:18:48 +05:30
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
def cycle_analytics_json
|
|
|
|
{
|
2017-08-17 22:00:37 +05:30
|
|
|
summary: @cycle_analytics.summary,
|
|
|
|
stats: @cycle_analytics.stats,
|
|
|
|
permissions: @cycle_analytics.permissions(user: current_user)
|
2016-09-29 09:46:39 +05:30
|
|
|
}
|
|
|
|
end
|
2022-10-11 01:57:18 +05:30
|
|
|
|
|
|
|
def tracking_namespace_source
|
|
|
|
project.namespace
|
|
|
|
end
|
|
|
|
|
|
|
|
def tracking_project_source
|
|
|
|
project
|
|
|
|
end
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|
2023-06-20 00:43:36 +05:30
|
|
|
|
|
|
|
Projects::CycleAnalyticsController.prepend_mod
|