Hoptoad Notifier: Rack and automatic Metal support

If you’re not sending your application errors to our hosted service Hoptoad, take a few minutes and try it out for free today!

The newest version of the official Hoptoad Notifier, 2.2, was released to Gemcutter today, and brings with it support for Rack, automatic notification of exceptions occurring in Rails Metal endpoints, and some Rails 1.2.6 fixes.

Rack support

From the README:

In order to use hoptoadnotifier in a non-Rails rack app, just load the hoptoadnotifier, configure your API key, and use the HoptoadNotifier::Rack middleware:

require 'rack'
require 'hoptoad_notifier'

HoptoadNotifier.configure do |config|
  config.api_key = 'my_api_key'

app = Rack::Builder.app do
  use HoptoadNotifier::Rack
  run lambda { |env| raise "Rack down" }

This makes the notifier usable in any Rack-based application, including Merb or Sinatra. The README also includes an example for using the Rack notifier in Sinatra.

Atticus mans a very fashionable wine rack

Automatic metal notification

The Hoptoad::Rails module also uses this Rack support to provide automatic Hoptoad notification from within your Rails Metal applications:

if defined?(::Rails.configuration) && ::Rails.configuration.respond_to?(:middleware)
  ::Rails.configuration.middleware.insert_after 'ActionController::Failsafe',

This means that any exceptions during requests handled by metal endpoints in your Rails application will automatically be sent to Hoptoad, just like requests that are handled by ActionController.

Atticus does metal

You can read about the other changes in 2.2 (including fixes for Rails 1.2.6) in the CHANGELOG.

Hound automatically reviews Ruby, JavaScript, and CoffeeScript code in your GitHub pull requests and comments on style violations. It is free for open source repos and $12/month per private repo.