Class: ToadHopper

Inherits:
Object
  • Object
show all
Includes:
ERB::Util
Defined in:
lib/toadhopper.rb

Overview

Posts errors to the Hoptoad API

Defined Under Namespace

Classes: Response

Constant Summary collapse

VERSION =
"0.9.3"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ ToadHopper

Returns a new instance of ToadHopper.



14
15
16
# File 'lib/toadhopper.rb', line 14

def initialize(api_key)
  @api_key = api_key
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



12
13
14
# File 'lib/toadhopper.rb', line 12

def api_key
  @api_key
end

Instance Method Details

#filters=(*filters) ⇒ Object

Sets patterns to [FILTER] out sensitive data such as /password/, /email/ and /credit_card_number/



19
20
21
# File 'lib/toadhopper.rb', line 19

def filters=(*filters)
  @filters = filters.flatten
end

#post!(error, options = {}, http_headers = {}) ⇒ Response

Posts an exception to hoptoad.

Examples:

ToadHopper('apikey').post! error,
                           {:action => 'show', :controller => 'Users'},
                           {'X-Hoptoad-Client-Name' => 'My Awesome Notifier'}

Parameters:

  • error (Exception)

    the error to post

  • options (Hash) (defaults to: {})
  • http_headers (Hash) (defaults to: {})

    extra HTTP headers to be sent in the post to the API

Options Hash (options):

  • url (String)

    The url for the request, required to post but not useful in a console environment

  • component (String)

    Normally this is your Controller name in an MVC framework

  • action (String)

    Normally the action for your request in an MVC framework

  • request (#params)

    An object that response to #params and returns a hash

  • notifier_name (String)

    Say you’re a different notifier than ToadHopper

  • notifier_version (String)

    Specify the version of your custom notifier

  • notifier_url (String)

    Specify the project URL of your custom notifier

  • session (Hash)

    A hash of the user session in a web request

  • framework_env (String)

    The framework environment your app is running under

  • backtrace (Array)

    Normally not needed, parsed automatically from the provided exception parameter

  • environment (Hash)

    You MUST scrub your environment if you plan to use this, please do not use it though. :)

  • project_root (String)

    The root directory of your app

Returns:



54
55
56
57
# File 'lib/toadhopper.rb', line 54

def post!(error, options={}, http_headers={})
  options[:notifier_name] ||= 'ToadHopper'
  post_document(document_for(error, options), {'X-Hoptoad-Client-Name' => options[:notifier_name]})
end