blob: 93ded59900d5375da267f701e57204fe3d4a9b81 (
plain)
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
|
# frozen_string_literal: true
module WithPerformanceBar
extend ActiveSupport::Concern
included do
before_action :set_peek_enabled_for_current_request
end
private
def set_peek_enabled_for_current_request
Gitlab::SafeRequestStore.fetch(:peek_enabled) { cookie_or_default_value }
end
# Needed for Peek's routing to work;
# Peek::ResultsController#restrict_non_access calls this method.
def peek_enabled?
Gitlab::PerformanceBar.enabled_for_request?
end
def cookie_or_default_value
return false unless Gitlab::PerformanceBar.enabled_for_user?(current_user)
if cookies[:perf_bar_enabled].present?
cookies[:perf_bar_enabled] == 'true'
else
cookies[:perf_bar_enabled] = 'true' if Rails.env.development?
end
end
end
|