summaryrefslogtreecommitdiff
path: root/lib/gitlab/sentry.rb
blob: 4a22fc80f75bd08240d7a1128b8a7a20554de116 (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
module Gitlab
  module Sentry
    def self.enabled?
      Rails.env.production? && Gitlab::CurrentSettings.sentry_enabled?
    end

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

      Raven.tags_context(locale: I18n.locale)

      if current_user
        Raven.user_context(
          id: current_user.id,
          email: current_user.email,
          username: current_user.username
        )
      end
    end

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