class Rack::Indicium::Sentry

Public Class Methods

new(app) click to toggle source
# File lib/rack/indicium/sentry.rb, line 6
def initialize(app)
  @app = app

  if defined?(Raven)
    @sentry_client = Raven
  else
    warn "%s: Raven not definied, can't send JWT headers to Sentry." % self.class.to_s
  end
end

Public Instance Methods

call(env) click to toggle source
# File lib/rack/indicium/sentry.rb, line 16
def call(env)
  check_for_jwt(env) if enabled?
  @app.call(env)
end
check_for_jwt(env) click to toggle source
# File lib/rack/indicium/sentry.rb, line 21
def check_for_jwt(env)
  context = {
    "jwt.raw" => env["jwt.raw"],
    "jwt.header" => env["jwt.header"],
    "jwt.payload" => env["jwt.payload"],
  }
  client.extra_context(context)
end
client() click to toggle source
# File lib/rack/indicium/sentry.rb, line 30
def client
  @sentry_client
end
enabled?() click to toggle source
# File lib/rack/indicium/sentry.rb, line 34
def enabled?
  !!@sentry_client
end