Flame Sentry Context
Helper class for Sentry reports
via sentry-ruby
gem
from Flame web applications.
Installation
Add this line to your application's Gemfile:
gem 'flame-sentry_context'
And then execute:
bundle install
Or install it yourself as:
gem install flame-sentry_context
Usage
Default loggers:
:puma
:server
:not_found
-
:translations
(R18n) -
:validation_errors
(Formalism R18n Errors)
You can change them via Flame::SentryContext.loggers
reader.
Example from Flame application template:
require 'flame/sentry_context'
module MyApplication
## Base controller for any others controllers
class Controller < Flame::Controller
protected
def not_found
unless request.bot?
Flame::SentryContext.new(:not_found, controller: self).capture_message
end
super
end
def server_error(exception)
Flame::SentryContext.new(:server, controller: self).capture_exception(exception)
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)
Flame::SentryContext.new(
:validation_errors,
controller: self,
form_class: @form.class,
errors: errors
).capture_message
end
end
end
You can pass :user
into initialization or redefine user
getter globally via:
## By default it's `nil`
Flame::SentryContext.user_block = -> { @controller&.send(:authenticated)&.account }
Development
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.