Flame Raven Context
Helper class for Sentry reports
via sentry-raven gem
from Flame web applications.
Installation
Add this line to your application's Gemfile:
gem 'flame-raven_context'And then execute:
bundle installOr install it yourself as:
gem install flame-raven_contextUsage
Default loggers:
:puma:server:not_found-
:translations(R18n) -
:validation_errors(Formalism R18n Errors)
You can change them via Flame::RavenContext.loggers reader.
Example from Flame application template:
require 'flame/raven_context'
module MyApplication
## Base controller for any others controllers
class Controller < Flame::Controller
protected
def not_found
unless request.bot?
request_context = Flame::RavenContext.new(:not_found, controller: self)
Raven.capture_message(*request_context.exception_with_context)
end
super
end
def server_error(exception)
request_context = Flame::RavenContext.new(:server, controller: self, exception: exception)
Raven.capture_exception(*request_context.exception_with_context)
super
end
private
## This can be used as `capture_validation_errors form_outcome.errors.translations`
## inside `else` of `if (form_outcome = @form.run).success?` condition.
def capture_validation_errors(errors)
Raven.capture_message(
*Flame::RavenContext.new(
:validation_errors,
controller: self,
form_class: @form.class,
errors: errors
).exception_with_context
)
end
end
endYou can redefine user object for reports via:
module Flame
class RavenContext
private
def user
@controller&.send(:authenticated)&.account
end
end
endDevelopment
After checking out the repo, run bundle install to install dependencies.
Then, run toys rspec to run the tests.
To install this gem onto your local machine, run toys gem install.
To release a new version, run toys gem release %version%.
See how it works here.
Contributing
Bug reports and pull requests are welcome on GitHub.
License
The gem is available as open source under the terms of the MIT License.