jordan-brough-hoptoad_notifier 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +161 -0
- data/INSTALL +25 -0
- data/MIT-LICENSE +22 -0
- data/README.rdoc +384 -0
- data/Rakefile +217 -0
- data/SUPPORTED_RAILS_VERSIONS +9 -0
- data/TESTING.rdoc +8 -0
- data/generators/hoptoad/hoptoad_generator.rb +63 -0
- data/generators/hoptoad/lib/insert_commands.rb +34 -0
- data/generators/hoptoad/lib/rake_commands.rb +24 -0
- data/generators/hoptoad/templates/capistrano_hook.rb +6 -0
- data/generators/hoptoad/templates/hoptoad_notifier_tasks.rake +25 -0
- data/generators/hoptoad/templates/initializer.rb +6 -0
- data/lib/hoptoad_notifier.rb +148 -0
- data/lib/hoptoad_notifier/backtrace.rb +99 -0
- data/lib/hoptoad_notifier/capistrano.rb +20 -0
- data/lib/hoptoad_notifier/configuration.rb +232 -0
- data/lib/hoptoad_notifier/notice.rb +318 -0
- data/lib/hoptoad_notifier/rack.rb +40 -0
- data/lib/hoptoad_notifier/rails.rb +37 -0
- data/lib/hoptoad_notifier/rails/action_controller_catcher.rb +29 -0
- data/lib/hoptoad_notifier/rails/controller_methods.rb +63 -0
- data/lib/hoptoad_notifier/rails/error_lookup.rb +33 -0
- data/lib/hoptoad_notifier/rails3_tasks.rb +90 -0
- data/lib/hoptoad_notifier/railtie.rb +23 -0
- data/lib/hoptoad_notifier/sender.rb +63 -0
- data/lib/hoptoad_notifier/tasks.rb +97 -0
- data/lib/hoptoad_notifier/version.rb +3 -0
- data/lib/hoptoad_tasks.rb +44 -0
- data/lib/rails/generators/hoptoad/hoptoad_generator.rb +69 -0
- data/lib/templates/rescue.erb +91 -0
- data/rails/init.rb +1 -0
- data/script/integration_test.rb +38 -0
- data/test/backtrace_test.rb +118 -0
- data/test/catcher_test.rb +324 -0
- data/test/configuration_test.rb +208 -0
- data/test/helper.rb +239 -0
- data/test/hoptoad_tasks_test.rb +152 -0
- data/test/logger_test.rb +85 -0
- data/test/notice_test.rb +443 -0
- data/test/notifier_test.rb +222 -0
- data/test/rack_test.rb +58 -0
- data/test/rails_initializer_test.rb +36 -0
- data/test/sender_test.rb +123 -0
- metadata +205 -0
data/CHANGELOG
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
Version 2.3.0 - 2010-06-24
|
2
|
+
===============================================================================
|
3
|
+
|
4
|
+
Jason Morrison (5):
|
5
|
+
Add integration test for rails 3.0.0.beta4
|
6
|
+
Added feature: Support the Heroku addon in the generator
|
7
|
+
Add --heroku flag to generator to support ENV['HOPTOAD_API_KEY']
|
8
|
+
Reflect a copy change in rails.feature for --heroku generator flag
|
9
|
+
Support the proxy configuration options when notifying Hoptoad of a deploy (hat tip @gudleik)
|
10
|
+
|
11
|
+
|
12
|
+
Version 2.2.6 - 2010-06-02
|
13
|
+
===============================================================================
|
14
|
+
|
15
|
+
Jason Morrison (1):
|
16
|
+
For Rails 3, just use the Rack middleware instead of specifying a location to insert_after
|
17
|
+
|
18
|
+
|
19
|
+
Version 2.2.5 - 2010-06-02
|
20
|
+
===============================================================================
|
21
|
+
|
22
|
+
Jason Morrison (1):
|
23
|
+
Add documentation for Rails 3.x installation
|
24
|
+
|
25
|
+
|
26
|
+
Version 2.2.4 - 2010-06-02
|
27
|
+
===============================================================================
|
28
|
+
|
29
|
+
Jason Morrison (1):
|
30
|
+
Add a note to README about removing the explicit Catcher #include in ApplicationController
|
31
|
+
|
32
|
+
|
33
|
+
Version 2.2.3 - 2010-06-02
|
34
|
+
===============================================================================
|
35
|
+
|
36
|
+
Summary: Fixed a variety of issues for Rails 3.0.0.beta3,
|
37
|
+
Fixed a bug when using Vlad to deploy instead of Capistrano
|
38
|
+
Give better error output when gem is not installed
|
39
|
+
|
40
|
+
Chad Pytel (2):
|
41
|
+
revise gem unpack instructions step
|
42
|
+
Merge branch 'master' of github.com:thoughtbot/hoptoad_notifier
|
43
|
+
|
44
|
+
Dan Lawless (1):
|
45
|
+
don't append capistrano details to config.deploy.rb when target app uses Vlad
|
46
|
+
|
47
|
+
Jason Morrison (7):
|
48
|
+
LH-556 Clarify sending ENV environment variables
|
49
|
+
Starting to add features for Rails 3
|
50
|
+
Make rails rake tasks depend on gem-making tasks
|
51
|
+
Start to get Rails 3 features to pass
|
52
|
+
require fileutils to reflect rubygems 1.3.6 change
|
53
|
+
Support ENV['CUCUMBER_FORMAT'] in rails cucumber tasks for testing
|
54
|
+
Fix the initializer syntax in the Rails 3 Railtie
|
55
|
+
|
56
|
+
Joe Ferris (11):
|
57
|
+
Got the generator running and a request dispatched to the test endpoint
|
58
|
+
Fixed logging in hoptoad:test rake task
|
59
|
+
Separated Rails 2 and 3 entry
|
60
|
+
Support bundler
|
61
|
+
Rails 3 generator works with an existing api key
|
62
|
+
Extract request info from rack env
|
63
|
+
Detect presence of the plugin
|
64
|
+
Added a capistrano hook for Rails 3
|
65
|
+
Fixed rack/sinatra being broken without active_support
|
66
|
+
Fixes for earlier versions of Rails
|
67
|
+
Fixed Rails 3 generator not to append cap hooks for vlad deploys
|
68
|
+
|
69
|
+
Josh Kalderimis (7):
|
70
|
+
updated railtie to work with the new rails 3 middleware api
|
71
|
+
railtie_name is deprecated
|
72
|
+
updated app_middleware call to use string version as to make sure constant is loaded
|
73
|
+
moved generator using the new rails 3 convention
|
74
|
+
update path to template for Rails 3 generator
|
75
|
+
correction to referencing of the rails application in rails3_tasks
|
76
|
+
add environment_name and project_root back to rails 3 railtie
|
77
|
+
|
78
|
+
Joshua Nichols (1):
|
79
|
+
Handle gem not being installed more gracefully.
|
80
|
+
|
81
|
+
|
82
|
+
Version 2.2.2 - 2010-03-10
|
83
|
+
===============================================================================
|
84
|
+
|
85
|
+
Chad Pytel (1):
|
86
|
+
document proxy support
|
87
|
+
|
88
|
+
Joe Ferris (8):
|
89
|
+
Added upgrade instructions to the README
|
90
|
+
Give a clearer error message when generating a Rails app fails
|
91
|
+
Fail loudly when a gem can't be vendored
|
92
|
+
Debugging rubygems issues
|
93
|
+
Explicitly specify the gem paths
|
94
|
+
Less noisy
|
95
|
+
Restore gem path after vendoring
|
96
|
+
Fixed a typo
|
97
|
+
|
98
|
+
Jon Yurek (1):
|
99
|
+
Added notice about removing hoptoad rake tasks to upgrade gem
|
100
|
+
|
101
|
+
Mike Burns (1):
|
102
|
+
Remove stray file with notes in it
|
103
|
+
|
104
|
+
|
105
|
+
Version 2.2.1 - 2010-03-10
|
106
|
+
===============================================================================
|
107
|
+
|
108
|
+
Jason Morrison (3):
|
109
|
+
LH-629 Ensure notifier is not considered a framework gem
|
110
|
+
Removing things-the-generator-must-do file
|
111
|
+
Add rake cucumber:wip:rails* tasks for work-in-progress features
|
112
|
+
|
113
|
+
|
114
|
+
Version 2.2.0 - 2010-02-18
|
115
|
+
===============================================================================
|
116
|
+
|
117
|
+
Bumping the version from 2.1.4 to 2.2.0 since adding Rack support warrants a minor version.
|
118
|
+
|
119
|
+
Jason Morrison (1):
|
120
|
+
Stringify array elements when making assertions about Notice XML for 1.9 compatibility
|
121
|
+
|
122
|
+
|
123
|
+
Version 2.1.4 - 2010-02-12
|
124
|
+
===============================================================================
|
125
|
+
|
126
|
+
Chad Pytel (2):
|
127
|
+
add more info to README for 1.2.6
|
128
|
+
fix gem unpack line for 1.2.6
|
129
|
+
|
130
|
+
Jason Morrison (2):
|
131
|
+
Adding additional instructions for Rails 1.2.6
|
132
|
+
Typesetting in README.rdoc
|
133
|
+
|
134
|
+
Joe Ferris (11):
|
135
|
+
Separating Rails functionality out more
|
136
|
+
Initial Rack middleware
|
137
|
+
Extract request info from rack env
|
138
|
+
Added integration tests for rescuing
|
139
|
+
Fixed reporting of Rails version
|
140
|
+
Small refactoring
|
141
|
+
Automatically add Rack middleware for Rails apps that support it (catches exceptions from Metal)
|
142
|
+
Added an integration test and docs for rack apps
|
143
|
+
Added integration/readme coverage of Sinatra apps
|
144
|
+
Added docs to HoptoadNotifier::Rack
|
145
|
+
Require rack in tests for older versions of Rails; use active_support instead of activesupport
|
146
|
+
|
147
|
+
Nick Quaranto (3):
|
148
|
+
Fixing the capistrano hook bit in the readme
|
149
|
+
Adding changeling:minor and changeling:patch to automate notifier releases
|
150
|
+
Adding rake changeling:push
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
data/INSTALL
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
=== Configuration
|
2
|
+
|
3
|
+
You should have something like this in config/initializers/hoptoad.rb.
|
4
|
+
|
5
|
+
HoptoadNotifier.configure do |config|
|
6
|
+
config.api_key = '1234567890abcdef'
|
7
|
+
end
|
8
|
+
|
9
|
+
(Please note that this configuration should be in a global configuration, and
|
10
|
+
is *not* environment-specific. Hoptoad is smart enough to know what errors are
|
11
|
+
caused by what environments, so your staging errors don't get mixed in with
|
12
|
+
your production errors.)
|
13
|
+
|
14
|
+
You can test that Hoptoad is working in your production environment by using
|
15
|
+
this rake task (from RAILS_ROOT):
|
16
|
+
|
17
|
+
rake hoptoad:test
|
18
|
+
|
19
|
+
If everything is configured properly, that task will send a notice to Hoptoad
|
20
|
+
which will be visible immediately.
|
21
|
+
|
22
|
+
NOTE FOR RAILS 1.2.* USERS:
|
23
|
+
|
24
|
+
You will need to copy the hoptoad_notifier_tasks.rake file into your
|
25
|
+
RAILS_ROOT/lib/tasks directory in order for the rake hoptoad:test task to work.
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2007, Tammer Saleh, Thoughtbot, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,384 @@
|
|
1
|
+
= HoptoadNotifier
|
2
|
+
|
3
|
+
This is the notifier gem for integrating apps with Hoptoad.
|
4
|
+
|
5
|
+
When an uncaught exception occurs, HoptoadNotifier will POST the relevant data
|
6
|
+
to the Hoptoad server specified in your environment.
|
7
|
+
|
8
|
+
== Help
|
9
|
+
|
10
|
+
* {IRC}[irc://irc.freenode.net/thoughtbot]
|
11
|
+
* {mailing list}[http://groups.google.com/group/hoptoad-notifier-dev]
|
12
|
+
|
13
|
+
== Rails Installation
|
14
|
+
|
15
|
+
=== Remove exception_notifier
|
16
|
+
|
17
|
+
in your ApplicationController, REMOVE this line:
|
18
|
+
|
19
|
+
include ExceptionNotifiable
|
20
|
+
|
21
|
+
In your config/environment* files, remove all references to ExceptionNotifier
|
22
|
+
|
23
|
+
Remove the vendor/plugins/exception_notifier directory.
|
24
|
+
|
25
|
+
=== Remove hoptoad_notifier plugin
|
26
|
+
|
27
|
+
Remove the vendor/plugins/hoptoad_notifier directory before installing the gem, or run:
|
28
|
+
|
29
|
+
script/plugin remove hoptoad_notifier
|
30
|
+
|
31
|
+
=== Rails 3.x
|
32
|
+
|
33
|
+
Add the hoptoad_notifier gem to your Gemfile. In Gemfile:
|
34
|
+
|
35
|
+
gem 'hoptoad_notifier'
|
36
|
+
|
37
|
+
Then from your project's RAILS_ROOT, run:
|
38
|
+
|
39
|
+
bundle install
|
40
|
+
script/rails generate hoptoad --api-key your_key_here
|
41
|
+
|
42
|
+
That's it!
|
43
|
+
|
44
|
+
=== Rails 2.x
|
45
|
+
|
46
|
+
Add the hoptoad_notifier gem to your app. In config/environment.rb:
|
47
|
+
|
48
|
+
config.gem 'hoptoad_notifier'
|
49
|
+
|
50
|
+
Then from your project's RAILS_ROOT, run:
|
51
|
+
|
52
|
+
rake gems:install
|
53
|
+
rake gems:unpack GEM=hoptoad_notifier
|
54
|
+
script/generate hoptoad --api-key your_key_here
|
55
|
+
|
56
|
+
As always, if you choose not to vendor the hoptoad_notifier gem, make sure
|
57
|
+
every server you deploy to has the gem installed or your application won't start.
|
58
|
+
|
59
|
+
=== Rails 1.2.6
|
60
|
+
|
61
|
+
Install the hoptoad_notifier gem:
|
62
|
+
|
63
|
+
gem install hoptoad_notifier
|
64
|
+
|
65
|
+
Once installed, you should vendor the hoptoad_notifier gem:
|
66
|
+
|
67
|
+
mkdir vendor/gems
|
68
|
+
cd vendor/gems
|
69
|
+
gem unpack hoptoad_notifier
|
70
|
+
|
71
|
+
And then add the following to the Rails::Initializer.run do |config|
|
72
|
+
block in environment.rb so that the vendored gem is loaded.
|
73
|
+
|
74
|
+
# Add the vendor/gems/*/lib directories to the LOAD_PATH
|
75
|
+
config.load_paths += Dir.glob(File.join(RAILS_ROOT, 'vendor', 'gems', '*', 'lib'))
|
76
|
+
|
77
|
+
Next add something like this at the bottom of your config/environment.rb:
|
78
|
+
|
79
|
+
require 'hoptoad_notifier'
|
80
|
+
require 'hoptoad_notifier/rails'
|
81
|
+
HoptoadNotifier.configure do |config|
|
82
|
+
config.api_key = 'your_key_here'
|
83
|
+
end
|
84
|
+
|
85
|
+
You will also need to copy the hoptoad_notifier_tasks.rake file into your
|
86
|
+
RAILS_ROOT/lib/tasks directory in order for the rake hoptoad:test task to work:
|
87
|
+
|
88
|
+
cp vendor/gems/hoptoad_notifier-*/generators/hoptoad/templates/hoptoad_notifier_tasks.rake lib/tasks
|
89
|
+
|
90
|
+
As always, if you choose not to vendor the hoptoad_notifier gem, make sure
|
91
|
+
every server you deploy to has the gem installed or your application won't start.
|
92
|
+
|
93
|
+
=== Upgrading From Earlier Versions of Hoptoad
|
94
|
+
|
95
|
+
If you're currently using the plugin version (if you have a
|
96
|
+
vendor/plugins/hoptoad_notifier directory, you are), you'll need to perform a
|
97
|
+
few extra steps when upgrading to the gem version.
|
98
|
+
|
99
|
+
Add the hoptoad_notifier gem to your app. In config/environment.rb:
|
100
|
+
|
101
|
+
config.gem 'hoptoad_notifier'
|
102
|
+
|
103
|
+
Remove the plugin:
|
104
|
+
|
105
|
+
rm -rf vendor/plugins/hoptoad_notifier
|
106
|
+
|
107
|
+
Make sure the following line DOES NOT appear in your ApplicationController file:
|
108
|
+
|
109
|
+
include HoptoadNotifier::Catcher
|
110
|
+
|
111
|
+
If it does, remove it. The new catcher is automatically included by the gem
|
112
|
+
version of Hoptoad.
|
113
|
+
|
114
|
+
Before running the hoptoad generator, you need to find your project's API key.
|
115
|
+
Log in to your account at hoptoadapp.com, and click on the "Projects" button.
|
116
|
+
Then, find your project in the list, and click on its name. In the left-hand
|
117
|
+
column, you'll see an "Edit this project" button. Click on that to get your
|
118
|
+
project's API. (If you accidentally use your personal API auth_token, you won't
|
119
|
+
be able to install the gem.)
|
120
|
+
|
121
|
+
Then from your project's RAILS_ROOT, run:
|
122
|
+
|
123
|
+
rake gems:install
|
124
|
+
script/generate hoptoad --api-key your_key_here
|
125
|
+
|
126
|
+
Once installed, you should vendor the hoptoad_notifier gem.
|
127
|
+
|
128
|
+
rake gems:unpack GEM=hoptoad_notifier
|
129
|
+
|
130
|
+
As always, if you choose not to vendor the hoptoad_notifier gem, make sure
|
131
|
+
every server you deploy to has the gem installed or your application won't
|
132
|
+
start.
|
133
|
+
|
134
|
+
== Upgrading from Earlier Versions of the Hoptoad Gem (with config.gem)
|
135
|
+
|
136
|
+
If you're currently using the gem version of the hoptoad_notifier and have
|
137
|
+
a version of Rails that uses config.gem (in the 2.x series), there is
|
138
|
+
a step or two that you need to do to upgrade. First, you need to remove
|
139
|
+
the old version of the gem from vendor/gems:
|
140
|
+
|
141
|
+
rm -rf vendor/gems/hoptoad_notifier-X.X.X
|
142
|
+
|
143
|
+
Then you must remove the hoptoad_notifier_tasks.rake file from lib:
|
144
|
+
|
145
|
+
rm lib/tasks/hoptoad_notifier_tasks.rake
|
146
|
+
|
147
|
+
You can them continue to install normally. If you don't remove the rake file,
|
148
|
+
you will be unable to unpack this gem (Rails will think it's part of the
|
149
|
+
framework).
|
150
|
+
|
151
|
+
=== Testing it out
|
152
|
+
|
153
|
+
You can test that Hoptoad is working in your production environment by using
|
154
|
+
this rake task (from RAILS_ROOT):
|
155
|
+
|
156
|
+
rake hoptoad:test
|
157
|
+
|
158
|
+
If everything is configured properly, that task will send a notice to Hoptoad
|
159
|
+
which will be visible immediately.
|
160
|
+
|
161
|
+
== Rack
|
162
|
+
|
163
|
+
In order to use hoptoad_notifier in a non-Rails rack app, just load the
|
164
|
+
hoptoad_notifier, configure your API key, and use the HoptoadNotifier::Rack
|
165
|
+
middleware:
|
166
|
+
|
167
|
+
require 'rack'
|
168
|
+
require 'hoptoad_notifier'
|
169
|
+
|
170
|
+
HoptoadNotifier.configure do |config|
|
171
|
+
config.api_key = 'my_api_key'
|
172
|
+
end
|
173
|
+
|
174
|
+
app = Rack::Builder.app do
|
175
|
+
use HoptoadNotifier::Rack
|
176
|
+
run lambda { |env| raise "Rack down" }
|
177
|
+
end
|
178
|
+
|
179
|
+
== Sinatra
|
180
|
+
|
181
|
+
Using hoptoad_notifier in a Sinatra app is just like a Rack app, but you have
|
182
|
+
to disable Sinatra's error rescuing functionality:
|
183
|
+
|
184
|
+
require 'sinatra/base'
|
185
|
+
require 'hoptoad_notifier'
|
186
|
+
|
187
|
+
HoptoadNotifier.configure do |config|
|
188
|
+
config.api_key = 'my_api_key'
|
189
|
+
end
|
190
|
+
|
191
|
+
class MyApp < Sinatra::Default
|
192
|
+
use HoptoadNotifier::Rack
|
193
|
+
enable :raise_errors
|
194
|
+
|
195
|
+
get "/" do
|
196
|
+
raise "Sinatra has left the building"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
== Usage
|
201
|
+
|
202
|
+
For the most part, Hoptoad works for itself. Once you've included the notifier
|
203
|
+
in your ApplicationController (which is now done automatically by the gem),
|
204
|
+
all errors will be rescued by the #rescue_action_in_public provided by the gem.
|
205
|
+
|
206
|
+
If you want to log arbitrary things which you've rescued yourself from a
|
207
|
+
controller, you can do something like this:
|
208
|
+
|
209
|
+
...
|
210
|
+
rescue => ex
|
211
|
+
notify_hoptoad(ex)
|
212
|
+
flash[:failure] = 'Encryptions could not be rerouted, try again.'
|
213
|
+
end
|
214
|
+
...
|
215
|
+
|
216
|
+
The #notify_hoptoad call will send the notice over to Hoptoad for later
|
217
|
+
analysis. While in your controllers you use the notify_hoptoad method, anywhere
|
218
|
+
else in your code, use HoptoadNotifier.notify.
|
219
|
+
|
220
|
+
To perform custom error processing after Hoptoad has been notified, define the
|
221
|
+
instance method #rescue_action_in_public_without_hoptoad(exception) in your
|
222
|
+
controller.
|
223
|
+
|
224
|
+
== Tracking deployments in Hoptoad
|
225
|
+
|
226
|
+
Paying Hoptoad plans support the ability to track deployments of your application in Hoptoad.
|
227
|
+
By notifying Hoptoad of your application deployments, all errors are resolved when a deploy occurs,
|
228
|
+
so that you'll be notified again about any errors that reoccur after a deployment.
|
229
|
+
|
230
|
+
Additionally, it's possible to review the errors in Hoptoad that occurred before and after a deploy.
|
231
|
+
|
232
|
+
When Hoptoad is installed as a gem, you need to add
|
233
|
+
|
234
|
+
require 'hoptoad_notifier/capistrano'
|
235
|
+
|
236
|
+
to your deploy.rb
|
237
|
+
|
238
|
+
== Going beyond exceptions
|
239
|
+
|
240
|
+
You can also pass a hash to notify_hoptoad method and store whatever you want,
|
241
|
+
not just an exception. And you can also use it anywhere, not just in
|
242
|
+
controllers:
|
243
|
+
|
244
|
+
begin
|
245
|
+
params = {
|
246
|
+
# params that you pass to a method that can throw an exception
|
247
|
+
}
|
248
|
+
my_unpredicable_method(params)
|
249
|
+
rescue => e
|
250
|
+
HoptoadNotifier.notify(
|
251
|
+
:error_class => "Special Error",
|
252
|
+
:error_message => "Special Error: #{e.message}",
|
253
|
+
:parameters => params
|
254
|
+
)
|
255
|
+
end
|
256
|
+
|
257
|
+
While in your controllers you use the notify_hoptoad method, anywhere else in
|
258
|
+
your code, use HoptoadNotifier.notify. Hoptoad will get all the information
|
259
|
+
about the error itself. As for a hash, these are the keys you should pass:
|
260
|
+
|
261
|
+
* :error_class - Use this to group similar errors together. When Hoptoad catches an exception it sends the class name of that exception object.
|
262
|
+
* :error_message - This is the title of the error you see in the errors list. For exceptions it is "#{exception.class.name}: #{exception.message}"
|
263
|
+
* :parameters - While there are several ways to send additional data to Hoptoad, passing a Hash as :parameters as in the example above is the most common use case. When Hoptoad catches an exception in a controller, the actual HTTP client request parameters are sent using this key.
|
264
|
+
|
265
|
+
Hoptoad merges the hash you pass with these default options:
|
266
|
+
|
267
|
+
{
|
268
|
+
:api_key => HoptoadNotifier.api_key,
|
269
|
+
:error_message => 'Notification',
|
270
|
+
:backtrace => caller,
|
271
|
+
:parameters => {},
|
272
|
+
:session => {}
|
273
|
+
}
|
274
|
+
|
275
|
+
You can override any of those parameters.
|
276
|
+
|
277
|
+
=== Sending shell environment variables when "Going beyond exceptions"
|
278
|
+
|
279
|
+
One common request we see is to send shell environment variables along with
|
280
|
+
manual exception notification. We recommend sending them along with CGI data
|
281
|
+
or Rack environment (:cgi_data or :rack_env keys, respectively.) In Rails
|
282
|
+
you may define a 'hoptoad_extra_cgi_data' method on any controller that returns
|
283
|
+
a hashof extra CGI data to pass.
|
284
|
+
|
285
|
+
See HoptoadNotifier::Notice#initialize in lib/hoptoad_notifier/notice.rb for
|
286
|
+
more details.
|
287
|
+
|
288
|
+
== Filtering
|
289
|
+
|
290
|
+
You can specify a whitelist of errors, that Hoptoad will not report on. Use
|
291
|
+
this feature when you are so apathetic to certain errors that you don't want
|
292
|
+
them even logged.
|
293
|
+
|
294
|
+
This filter will only be applied to automatic notifications, not manual
|
295
|
+
notifications (when #notify is called directly).
|
296
|
+
|
297
|
+
Hoptoad ignores the following exceptions by default:
|
298
|
+
|
299
|
+
ActiveRecord::RecordNotFound
|
300
|
+
ActionController::RoutingError
|
301
|
+
ActionController::InvalidAuthenticityToken
|
302
|
+
ActionController::UnknownAction
|
303
|
+
CGI::Session::CookieStore::TamperedWithCookie
|
304
|
+
|
305
|
+
To ignore errors in addition to those, specify their names in your Hoptoad
|
306
|
+
configuration block.
|
307
|
+
|
308
|
+
HoptoadNotifier.configure do |config|
|
309
|
+
config.api_key = '1234567890abcdef'
|
310
|
+
config.ignore << ActiveRecord::IgnoreThisError
|
311
|
+
end
|
312
|
+
|
313
|
+
To ignore *only* certain errors (and override the defaults), use the
|
314
|
+
#ignore_only attribute.
|
315
|
+
|
316
|
+
HoptoadNotifier.configure do |config|
|
317
|
+
config.api_key = '1234567890abcdef'
|
318
|
+
config.ignore_only = [ActiveRecord::IgnoreThisError]
|
319
|
+
end
|
320
|
+
|
321
|
+
To ignore certain user agents, add in the #ignore_user_agent attribute as a
|
322
|
+
string or regexp:
|
323
|
+
|
324
|
+
HoptoadNotifier.configure do |config|
|
325
|
+
config.api_key = '1234567890abcdef'
|
326
|
+
config.ignore_user_agent << /Ignored/
|
327
|
+
config.ignore_user_agent << 'IgnoredUserAgent'
|
328
|
+
end
|
329
|
+
|
330
|
+
To ignore exceptions based on other conditions, use #ignore_by_filter:
|
331
|
+
|
332
|
+
HoptoadNotifier.configure do |config|
|
333
|
+
config.api_key = '1234567890abcdef'
|
334
|
+
config.ignore_by_filter do |exception_data|
|
335
|
+
true if exception_data[:error_class] == "RuntimeError"
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
To replace sensitive information sent to the Hoptoad service with [FILTERED] use #params_filters:
|
340
|
+
|
341
|
+
HoptoadNotifier.configure do |config|
|
342
|
+
config.api_key = '1234567890abcdef'
|
343
|
+
config.params_filters << "credit_card_number"
|
344
|
+
end
|
345
|
+
|
346
|
+
Note that, when rescuing exceptions within an ActionController method,
|
347
|
+
hoptoad_notifier will reuse filters specified by #filter_params_logging.
|
348
|
+
|
349
|
+
== Testing
|
350
|
+
|
351
|
+
When you run your tests, you might notice that the Hoptoad service is recording
|
352
|
+
notices generated using #notify when you don't expect it to. You can
|
353
|
+
use code like this in your test_helper.rb to redefine that method so those
|
354
|
+
errors are not reported while running tests.
|
355
|
+
|
356
|
+
module HoptoadNotifier
|
357
|
+
def self.notify(thing)
|
358
|
+
# do nothing.
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
== Proxy Support
|
363
|
+
|
364
|
+
The notifier supports using a proxy, if your server is not able to directly reach the Hoptoad servers. To configure the proxy settings, added the following information to your Hoptoad configuration block.
|
365
|
+
|
366
|
+
HoptoadNotifier.configure do |config|
|
367
|
+
config.proxy_host = ...
|
368
|
+
config.proxy_port = ...
|
369
|
+
config.proxy_user = ...
|
370
|
+
config.proxy_pass = ...
|
371
|
+
|
372
|
+
== Supported Rails versions
|
373
|
+
|
374
|
+
See SUPPORTED_RAILS_VERSIONS for a list of official supported versions of
|
375
|
+
Rails.
|
376
|
+
|
377
|
+
Please open up a support ticket on Tender ( http://help.hoptoadapp.com ) if
|
378
|
+
you're using a version of Rails that is not listed above and the notifier is
|
379
|
+
not working properly.
|
380
|
+
|
381
|
+
== Thanks
|
382
|
+
|
383
|
+
Thanks to Eugene Bolshakov for the excellent write-up on GOING BEYOND
|
384
|
+
EXCEPTIONS, which we have included above.
|