2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-21 10:59:13 -04:00
|
|
|
module WithPerformanceBar
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
include Peek::Rblineprof::CustomControllerHelpers
|
|
|
|
end
|
|
|
|
|
|
|
|
def peek_enabled?
|
|
|
|
return false unless Gitlab::PerformanceBar.enabled?(current_user)
|
|
|
|
|
2018-09-20 15:32:54 -04:00
|
|
|
Gitlab::SafeRequestStore.fetch(:peek_enabled) { cookie_or_default_value }
|
2018-01-16 13:13:31 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def cookie_or_default_value
|
|
|
|
if cookies[:perf_bar_enabled].present?
|
|
|
|
cookies[:perf_bar_enabled] == 'true'
|
|
|
|
else
|
|
|
|
cookies[:perf_bar_enabled] = 'true' if Rails.env.development?
|
2017-06-21 10:59:13 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|