Module: Rollday::RollbarHelper

Included in:
Middleware
Defined in:
lib/rollday/rollbar_helper.rb

Instance Method Summary collapse

Instance Method Details

#rollbar_level(result) ⇒ Object



8
9
10
11
# File 'lib/rollday/rollbar_helper.rb', line 8

def rollbar_level(result)
  level = Rollday.config.rollbar_level
  level.is_a?(Proc) ? level.(result.status) : level
end

#rollbar_message(result) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/rollday/rollbar_helper.rb', line 13

def rollbar_message(result)
  params = [result.status, result.reason_phrase, result.body, URI(result.env.url).path, URI(result.env.url).host]
  message = Rollday.config.message.(*params)
  return message unless Rollday.config.use_message_exception

  error_klass = Rollday.config.exception_class.(*params)
  error_klass.new(message)
end

#rollbar_scope(result) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rollday/rollbar_helper.rb', line 22

def rollbar_scope(result)
  {
    framework: "Faraday: #{::Faraday::VERSION}; Rollday: #{Rollday::VERSION}",
    host: URI(result.env.url).host,
    method: result.env.method,
    params: params_scope(result),
    path: URI(result.env.url).path,
    body: result.body,
    person: person_scope,
    query: query_scope(result),
    status: result.status,
    status_phrase: result.reason_phrase,
  }
end