Giter VIP home page Giter VIP logo

raygun4ruby's Introduction

Raygun 4 Ruby Build Status

This is the Ruby adapter for the Raygun error reporter, http://raygun.io.

Installation

Add this line to your application's Gemfile:

gem 'raygun4ruby'

And then execute:

$ bundle

Or install it yourself as:

$ gem install raygun4ruby

Usage

###Rails 3/4

Run:

rails g raygun:install YOUR_API_KEY_HERE

You can find your API key on your Raygun Dashboard

You can then test your Raygun integration by running:

rake raygun:test

You should see an "ItWorksException" appear in your Raygun dashboard. You're ready to zap those errors!

NB: Raygun4Ruby currently requires Ruby >= 1.9

Note that the generator will create a file in config/initializers called "raygun.rb". If you need to do any further configuration or customization of Raygun, that's the place to do it!

Rails 2

Raygun4Ruby doesn't currently support Rails 2. If you'd like Rails 2 support, drop us a line.

###Standalone / Manual Exception Tracking

require 'rubygems'
require 'raygun4ruby'

Raygun.setup do |config|
  config.api_key = "YOUR_RAYGUN_API_KEY"
  config.filter_parameters = [ :password, :card_number, :cvv ] # don't forget to filter out sensitive parameters
end

begin
  # your lovely code here
rescue Exception => e
  Raygun.track_exception(e)
end

(You can also pass a Hash as the second parameter to track_exception. It should look like a Rack Env Hash)

###Custom User Data Custom data can be added to track_exception by passing a custom_data key in the second parameter hash.

begin
  # more lovely code
rescue Exception => e
  Raygun.track_exception(e, custom_data: {my: 'custom data', goes: 'here'})
end

###Ignoring Some Errors

You can ignore certain types of Exception using the ignore option in the setup block, like so:

Raygun.setup do |config|
  config.api_key = "MY_SWEET_API_KEY"
  config.ignore  << ['MyApp::AnExceptionIDontCareAbout']
end

You can also check which exceptions are ignored by default

###Affected User Tracking

Raygun can now track how many users have been affected by an error.

By default, Raygun looks for a method called current_user on your controller, and calls either email, username or id on the object returned by that method.

You can customize those method names in your configuration block:

Raygun.setup do |config|
  config.api_key = "MY_SWEET_API_KEY"
  config.affected_user_method = :my_current_user # `current_user` by default
  config.affected_user_identifier_methods << :login # `[ :email, :username, :id ]` by default - will use the first that works
end

If you're using Rails, most authentication systems will have this method set and you should be good to go.

The count of unique affected users will appear on the error group in the Raygun dashboard. If your user has an email method, and that email has a Gravatars associated, you will also see your user's avatar.

If you wish to keep it anonymous, you could set this identifier to something like SecureRandom.uuid and store that in a cookie, like so:

class ApplicationController < ActionController::Base

  def raygun_user
    cookies.permanent[:raygun_user_identifier] ||= SecureRandom.uuid
  end

end

(Remember to set affected_user_method to :raygun_user in your config block...)

###Resque Error Tracking

Raygun4Ruby also includes a Resque failure backend. You should include it inside your Resque initializer (usually something like config/initializers/load_resque.rb)

require 'resque/failure/multiple'
require 'resque/failure/raygun'
require 'resque/failure/redis'

Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Raygun]
Resque::Failure.backend = Resque::Failure::Multiple

Sidekiq Error Tracking

Raygun4Ruby can track errors from Sidekiq (2.x or 3+). All you need to do is add the line:

  require 'raygun/sidekiq'

Either in your Raygun initializer or wherever else takes your fancy :)

Found a bug?

Oops! Just let us know by opening an Issue on Github.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

raygun4ruby's People

Contributors

cmdrkeen avatar georgephillips avatar gpeng avatar lazyatom avatar nikz avatar ochko avatar simi avatar slashek avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.