1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# frozen_string_literal: true
module Projects::ErrorTrackingHelper
def error_tracking_data(current_user, project)
error_tracking_enabled = !!project.error_tracking_setting&.enabled?
{
'index-path' => project_error_tracking_index_path(project, format: :json),
'user-can-enable-error-tracking' => can?(current_user, :admin_operations, project).to_s,
'enable-error-tracking-link' => project_settings_operations_path(project),
'error-tracking-enabled' => error_tracking_enabled.to_s,
'integrated-error-tracking-enabled' => integrated_tracking_enabled?(project).to_s,
'project-path' => project.full_path,
'list-path' => project_error_tracking_index_path(project),
'illustration-path' => image_path('illustrations/cluster_popover.svg'),
'show-integrated-tracking-disabled-alert' => show_integrated_tracking_disabled_alert?(project).to_s
}
end
def error_details_data(project, issue_id)
opts = [project, issue_id, { format: :json }]
{
'issue-id' => issue_id,
'project-path' => project.full_path,
'issue-update-path' => update_project_error_tracking_index_path(*opts),
'project-issues-path' => project_issues_path(project),
'issue-stack-trace-path' => stack_trace_project_error_tracking_index_path(*opts),
'integrated-error-tracking-enabled' => integrated_tracking_enabled?(project).to_s
}
end
private
# Should show the alert if the FF was turned off after the integrated client has been configured.
def show_integrated_tracking_disabled_alert?(project)
return false if ::Feature.enabled?(:integrated_error_tracking, project)
integrated_client_enabled?(project)
end
def integrated_tracking_enabled?(project)
::Feature.enabled?(:integrated_error_tracking, project) && integrated_client_enabled?(project)
end
def integrated_client_enabled?(project)
setting ||= project.error_tracking_setting ||
project.build_error_tracking_setting
setting.integrated_enabled?
end
end
|