No release in over a year
Helper class for Sentry reports via `sentry-ruby` gem from Flame web applications.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 0.12.0
~> 3.9
~> 1.2
~> 0.21.2
~> 0.13.0

Runtime

>= 4.0, < 6
 Project Readme

Flame Sentry Context

Cirrus CI - Base Branch Build Status Codecov branch Code Climate Inline docs License Gem

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:

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.