Repository is archived
No commit activity in last 3 years
No release in over 3 years
Helper class for Sentry reports via `sentry-raven` 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.2.1
~> 0.4.0
~> 3.9
~> 0.91.0
~> 0.19.0
~> 0.11.0

Runtime

 Project Readme

Flame Raven Context

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

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 install

Or install it yourself as:

gem install flame-raven_context

Usage

Default loggers:

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
end

You can redefine user object for reports via:

module Flame
  class RavenContext
    private

    def user
      @controller&.send(:authenticated)&.account
    end
  end
end

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.