https://github.com/alexwayfer/flame-sentry_context
Helper class for Sentry reports from Flame web applications
https://github.com/alexwayfer/flame-sentry_context
Last synced: 5 months ago
JSON representation
Helper class for Sentry reports from Flame web applications
- Host: GitHub
- URL: https://github.com/alexwayfer/flame-sentry_context
- Owner: AlexWayfer
- License: mit
- Created: 2022-09-04T12:06:10.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-26T16:51:06.000Z (about 1 year ago)
- Last Synced: 2025-04-09T22:08:37.284Z (about 1 year ago)
- Language: Ruby
- Size: 65.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Flame Sentry Context
[](https://cirrus-ci.com/github/AlexWayfer/flame-sentry_context)
[](https://codecov.io/gh/AlexWayfer/flame-sentry_context)
[](https://codeclimate.com/github/AlexWayfer/flame-sentry_context)
[](https://inch-ci.org/github/AlexWayfer/flame-sentry_context)
[](https://github.com/AlexWayfer/flame-sentry_context/blob/main/LICENSE.txt)
[](https://rubygems.org/gems/flame-sentry_context)
Helper class for [Sentry](https://sentry.io/) reports
via [`sentry-ruby` gem](https://rubygems.org/gems/sentry-ruby)
from [Flame](https://github.com/AlexWayfer/flame) web applications.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'flame-sentry_context'
```
And then execute:
```shell
bundle install
```
Or install it yourself as:
```shell
gem install flame-sentry_context
```
## Usage
Default loggers:
* [`:puma`](https://puma.io/)
* `:server`
* `:not_found`
* `:translations` ([R18n](https://github.com/r18n/r18n))
* `:validation_errors` ([Formalism R18n Errors](https://github.com/AlexWayfer/formalism-r18n_errors))
You can change them via `Flame::SentryContext.loggers` reader.
Example from [Flame application template](https://github.com/AlexWayfer/flame-cli/tree/main/template):
```ruby
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:
```ruby
## 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](https://github.com/AlexWayfer/gem_toys#release).
## Contributing
Bug reports and pull requests are welcome on [GitHub](https://github.com/AlexWayfer/flame-sentry_context).
## License
The gem is available as open source under the terms of the
[MIT License](https://opensource.org/licenses/MIT).