2016-08-24 23:06:16 -04:00
|
|
|
module Gitlab
|
|
|
|
module Sentry
|
2017-08-31 05:47:03 -04:00
|
|
|
extend Gitlab::CurrentSettings
|
|
|
|
|
2016-08-24 23:06:16 -04:00
|
|
|
def self.enabled?
|
|
|
|
Rails.env.production? && current_application_settings.sentry_enabled?
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.context(current_user = nil)
|
|
|
|
return unless self.enabled?
|
|
|
|
|
2017-07-20 02:53:57 -04:00
|
|
|
Raven.tags_context(locale: I18n.locale)
|
|
|
|
|
2016-08-24 23:06:16 -04:00
|
|
|
if current_user
|
|
|
|
Raven.user_context(
|
|
|
|
id: current_user.id,
|
|
|
|
email: current_user.email,
|
2017-05-03 07:27:17 -04:00
|
|
|
username: current_user.username
|
2016-08-24 23:06:16 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.program_context
|
|
|
|
if Sidekiq.server?
|
|
|
|
'sidekiq'
|
|
|
|
else
|
|
|
|
'rails'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|