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

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

      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