BigW Consortium Gitlab

sentry.rb 612 Bytes
Newer Older
1 2
module Gitlab
  module Sentry
3 4
    extend Gitlab::CurrentSettings

5 6 7 8 9 10 11
    def self.enabled?
      Rails.env.production? && current_application_settings.sentry_enabled?
    end

    def self.context(current_user = nil)
      return unless self.enabled?

12 13
      Raven.tags_context(locale: I18n.locale)

14 15 16 17
      if current_user
        Raven.user_context(
          id: current_user.id,
          email: current_user.email,
18
          username: current_user.username
19 20 21 22 23 24 25 26 27 28 29 30 31
        )
      end
    end

    def self.program_context
      if Sidekiq.server?
        'sidekiq'
      else
        'rails'
      end
    end
  end
end