riscfuture-hoptoad_notifier 2.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +218 -0
- data/INSTALL +25 -0
- data/MIT-LICENSE +22 -0
- data/README.rdoc +394 -0
- data/Rakefile +217 -0
- data/SUPPORTED_RAILS_VERSIONS +10 -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 +236 -0
- data/lib/hoptoad_notifier/notice.rb +334 -0
- data/lib/hoptoad_notifier/rack.rb +40 -0
- data/lib/hoptoad_notifier/rails.rb +39 -0
- data/lib/hoptoad_notifier/rails/action_controller_catcher.rb +29 -0
- data/lib/hoptoad_notifier/rails/controller_methods.rb +60 -0
- data/lib/hoptoad_notifier/rails/error_lookup.rb +33 -0
- data/lib/hoptoad_notifier/rails/javascript_notifier.rb +43 -0
- data/lib/hoptoad_notifier/rails3_tasks.rb +91 -0
- data/lib/hoptoad_notifier/railtie.rb +29 -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/javascript_notifier.erb +6 -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 +329 -0
- data/test/configuration_test.rb +209 -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 +457 -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 +197 -0
data/CHANGELOG
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
Version 2.3.6 - 2010-08-30
|
2
|
+
===============================================================================
|
3
|
+
|
4
|
+
Daniel Barron (1):
|
5
|
+
Initializer configuration overrides Railtie configuration if set
|
6
|
+
|
7
|
+
Joshua Clayton (1):
|
8
|
+
Remove rack.request.form_vars
|
9
|
+
|
10
|
+
Tristan Dunn (1):
|
11
|
+
Move Rails JS scenarios into separate feature and correctly support HTTPS when secure is enabled on the notifier.
|
12
|
+
|
13
|
+
|
14
|
+
Version 2.3.5 - 2010-08-13
|
15
|
+
===============================================================================
|
16
|
+
|
17
|
+
Alexey Palazhchenko (1):
|
18
|
+
Actually call #to_hash.
|
19
|
+
|
20
|
+
Joshua Clayton (1):
|
21
|
+
Trace hoptoad:test task when running generator for anything before Rails3
|
22
|
+
|
23
|
+
|
24
|
+
Version 2.3.4 - 2010-08-10
|
25
|
+
===============================================================================
|
26
|
+
|
27
|
+
Tristan Dunn (1):
|
28
|
+
Only include the JS notifier in public environments.
|
29
|
+
|
30
|
+
|
31
|
+
Version 2.3.3 - 2010-08-04
|
32
|
+
===============================================================================
|
33
|
+
|
34
|
+
Tristan Dunn (1):
|
35
|
+
Initial injection of JS notifier.
|
36
|
+
|
37
|
+
|
38
|
+
Version 2.3.2 - 2010-07-06
|
39
|
+
===============================================================================
|
40
|
+
|
41
|
+
Josh Clayton(1):
|
42
|
+
Handle instances when Rack's action_dispach.parameter_filter is nil
|
43
|
+
|
44
|
+
|
45
|
+
Version 2.3.1 - 2010-07-02
|
46
|
+
===============================================================================
|
47
|
+
|
48
|
+
Jason Morrison (2):
|
49
|
+
Use the Rails 3 params filters when available
|
50
|
+
Filter session hash using Hoptoad config.params_filters, in addition to params
|
51
|
+
|
52
|
+
|
53
|
+
Version 2.3.0 - 2010-06-24
|
54
|
+
===============================================================================
|
55
|
+
|
56
|
+
Jason Morrison (5):
|
57
|
+
Add integration test for rails 3.0.0.beta4
|
58
|
+
Added feature: Support the Heroku addon in the generator
|
59
|
+
Add --heroku flag to generator to support ENV['HOPTOAD_API_KEY']
|
60
|
+
Reflect a copy change in rails.feature for --heroku generator flag
|
61
|
+
Support the proxy configuration options when notifying Hoptoad of a deploy (hat tip @gudleik)
|
62
|
+
|
63
|
+
|
64
|
+
Version 2.2.6 - 2010-06-02
|
65
|
+
===============================================================================
|
66
|
+
|
67
|
+
Jason Morrison (1):
|
68
|
+
For Rails 3, just use the Rack middleware instead of specifying a location to insert_after
|
69
|
+
|
70
|
+
|
71
|
+
Version 2.2.5 - 2010-06-02
|
72
|
+
===============================================================================
|
73
|
+
|
74
|
+
Jason Morrison (1):
|
75
|
+
Add documentation for Rails 3.x installation
|
76
|
+
|
77
|
+
|
78
|
+
Version 2.2.4 - 2010-06-02
|
79
|
+
===============================================================================
|
80
|
+
|
81
|
+
Jason Morrison (1):
|
82
|
+
Add a note to README about removing the explicit Catcher #include in ApplicationController
|
83
|
+
|
84
|
+
|
85
|
+
Version 2.2.3 - 2010-06-02
|
86
|
+
===============================================================================
|
87
|
+
|
88
|
+
Summary: Fixed a variety of issues for Rails 3.0.0.beta3,
|
89
|
+
Fixed a bug when using Vlad to deploy instead of Capistrano
|
90
|
+
Give better error output when gem is not installed
|
91
|
+
|
92
|
+
Chad Pytel (2):
|
93
|
+
revise gem unpack instructions step
|
94
|
+
Merge branch 'master' of github.com:thoughtbot/hoptoad_notifier
|
95
|
+
|
96
|
+
Dan Lawless (1):
|
97
|
+
don't append capistrano details to config.deploy.rb when target app uses Vlad
|
98
|
+
|
99
|
+
Jason Morrison (7):
|
100
|
+
LH-556 Clarify sending ENV environment variables
|
101
|
+
Starting to add features for Rails 3
|
102
|
+
Make rails rake tasks depend on gem-making tasks
|
103
|
+
Start to get Rails 3 features to pass
|
104
|
+
require fileutils to reflect rubygems 1.3.6 change
|
105
|
+
Support ENV['CUCUMBER_FORMAT'] in rails cucumber tasks for testing
|
106
|
+
Fix the initializer syntax in the Rails 3 Railtie
|
107
|
+
|
108
|
+
Joe Ferris (11):
|
109
|
+
Got the generator running and a request dispatched to the test endpoint
|
110
|
+
Fixed logging in hoptoad:test rake task
|
111
|
+
Separated Rails 2 and 3 entry
|
112
|
+
Support bundler
|
113
|
+
Rails 3 generator works with an existing api key
|
114
|
+
Extract request info from rack env
|
115
|
+
Detect presence of the plugin
|
116
|
+
Added a capistrano hook for Rails 3
|
117
|
+
Fixed rack/sinatra being broken without active_support
|
118
|
+
Fixes for earlier versions of Rails
|
119
|
+
Fixed Rails 3 generator not to append cap hooks for vlad deploys
|
120
|
+
|
121
|
+
Josh Kalderimis (7):
|
122
|
+
updated railtie to work with the new rails 3 middleware api
|
123
|
+
railtie_name is deprecated
|
124
|
+
updated app_middleware call to use string version as to make sure constant is loaded
|
125
|
+
moved generator using the new rails 3 convention
|
126
|
+
update path to template for Rails 3 generator
|
127
|
+
correction to referencing of the rails application in rails3_tasks
|
128
|
+
add environment_name and project_root back to rails 3 railtie
|
129
|
+
|
130
|
+
Joshua Nichols (1):
|
131
|
+
Handle gem not being installed more gracefully.
|
132
|
+
|
133
|
+
|
134
|
+
Version 2.2.2 - 2010-03-10
|
135
|
+
===============================================================================
|
136
|
+
|
137
|
+
Chad Pytel (1):
|
138
|
+
document proxy support
|
139
|
+
|
140
|
+
Joe Ferris (8):
|
141
|
+
Added upgrade instructions to the README
|
142
|
+
Give a clearer error message when generating a Rails app fails
|
143
|
+
Fail loudly when a gem can't be vendored
|
144
|
+
Debugging rubygems issues
|
145
|
+
Explicitly specify the gem paths
|
146
|
+
Less noisy
|
147
|
+
Restore gem path after vendoring
|
148
|
+
Fixed a typo
|
149
|
+
|
150
|
+
Jon Yurek (1):
|
151
|
+
Added notice about removing hoptoad rake tasks to upgrade gem
|
152
|
+
|
153
|
+
Mike Burns (1):
|
154
|
+
Remove stray file with notes in it
|
155
|
+
|
156
|
+
|
157
|
+
Version 2.2.1 - 2010-03-10
|
158
|
+
===============================================================================
|
159
|
+
|
160
|
+
Jason Morrison (3):
|
161
|
+
LH-629 Ensure notifier is not considered a framework gem
|
162
|
+
Removing things-the-generator-must-do file
|
163
|
+
Add rake cucumber:wip:rails* tasks for work-in-progress features
|
164
|
+
|
165
|
+
|
166
|
+
Version 2.2.0 - 2010-02-18
|
167
|
+
===============================================================================
|
168
|
+
|
169
|
+
Bumping the version from 2.1.4 to 2.2.0 since adding Rack support warrants a minor version.
|
170
|
+
|
171
|
+
Jason Morrison (1):
|
172
|
+
Stringify array elements when making assertions about Notice XML for 1.9 compatibility
|
173
|
+
|
174
|
+
|
175
|
+
Version 2.1.4 - 2010-02-12
|
176
|
+
===============================================================================
|
177
|
+
|
178
|
+
Chad Pytel (2):
|
179
|
+
add more info to README for 1.2.6
|
180
|
+
fix gem unpack line for 1.2.6
|
181
|
+
|
182
|
+
Jason Morrison (2):
|
183
|
+
Adding additional instructions for Rails 1.2.6
|
184
|
+
Typesetting in README.rdoc
|
185
|
+
|
186
|
+
Joe Ferris (11):
|
187
|
+
Separating Rails functionality out more
|
188
|
+
Initial Rack middleware
|
189
|
+
Extract request info from rack env
|
190
|
+
Added integration tests for rescuing
|
191
|
+
Fixed reporting of Rails version
|
192
|
+
Small refactoring
|
193
|
+
Automatically add Rack middleware for Rails apps that support it (catches exceptions from Metal)
|
194
|
+
Added an integration test and docs for rack apps
|
195
|
+
Added integration/readme coverage of Sinatra apps
|
196
|
+
Added docs to HoptoadNotifier::Rack
|
197
|
+
Require rack in tests for older versions of Rails; use active_support instead of activesupport
|
198
|
+
|
199
|
+
Nick Quaranto (3):
|
200
|
+
Fixing the capistrano hook bit in the readme
|
201
|
+
Adding changeling:minor and changeling:patch to automate notifier releases
|
202
|
+
Adding rake changeling:push
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
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,394 @@
|
|
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.)
|
282
|
+
|
283
|
+
See HoptoadNotifier::Notice#initialize in lib/hoptoad_notifier/notice.rb for
|
284
|
+
more details.
|
285
|
+
|
286
|
+
== Filtering
|
287
|
+
|
288
|
+
You can specify a whitelist of errors, that Hoptoad will not report on. Use
|
289
|
+
this feature when you are so apathetic to certain errors that you don't want
|
290
|
+
them even logged.
|
291
|
+
|
292
|
+
This filter will only be applied to automatic notifications, not manual
|
293
|
+
notifications (when #notify is called directly).
|
294
|
+
|
295
|
+
Hoptoad ignores the following exceptions by default:
|
296
|
+
|
297
|
+
ActiveRecord::RecordNotFound
|
298
|
+
ActionController::RoutingError
|
299
|
+
ActionController::InvalidAuthenticityToken
|
300
|
+
ActionController::UnknownAction
|
301
|
+
CGI::Session::CookieStore::TamperedWithCookie
|
302
|
+
|
303
|
+
To ignore errors in addition to those, specify their names in your Hoptoad
|
304
|
+
configuration block.
|
305
|
+
|
306
|
+
HoptoadNotifier.configure do |config|
|
307
|
+
config.api_key = '1234567890abcdef'
|
308
|
+
config.ignore << ActiveRecord::IgnoreThisError
|
309
|
+
end
|
310
|
+
|
311
|
+
To ignore *only* certain errors (and override the defaults), use the
|
312
|
+
#ignore_only attribute.
|
313
|
+
|
314
|
+
HoptoadNotifier.configure do |config|
|
315
|
+
config.api_key = '1234567890abcdef'
|
316
|
+
config.ignore_only = [ActiveRecord::IgnoreThisError]
|
317
|
+
end
|
318
|
+
|
319
|
+
To ignore certain user agents, add in the #ignore_user_agent attribute as a
|
320
|
+
string or regexp:
|
321
|
+
|
322
|
+
HoptoadNotifier.configure do |config|
|
323
|
+
config.api_key = '1234567890abcdef'
|
324
|
+
config.ignore_user_agent << /Ignored/
|
325
|
+
config.ignore_user_agent << 'IgnoredUserAgent'
|
326
|
+
end
|
327
|
+
|
328
|
+
To ignore exceptions based on other conditions, use #ignore_by_filter:
|
329
|
+
|
330
|
+
HoptoadNotifier.configure do |config|
|
331
|
+
config.api_key = '1234567890abcdef'
|
332
|
+
config.ignore_by_filter do |exception_data|
|
333
|
+
true if exception_data[:error_class] == "RuntimeError"
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
To replace sensitive information sent to the Hoptoad service with [FILTERED] use #params_filters:
|
338
|
+
|
339
|
+
HoptoadNotifier.configure do |config|
|
340
|
+
config.api_key = '1234567890abcdef'
|
341
|
+
config.params_filters << "credit_card_number"
|
342
|
+
end
|
343
|
+
|
344
|
+
Note that, when rescuing exceptions within an ActionController method,
|
345
|
+
hoptoad_notifier will reuse filters specified by #filter_parameter_logging.
|
346
|
+
|
347
|
+
== Testing
|
348
|
+
|
349
|
+
When you run your tests, you might notice that the Hoptoad service is recording
|
350
|
+
notices generated using #notify when you don't expect it to. You can
|
351
|
+
use code like this in your test_helper.rb to redefine that method so those
|
352
|
+
errors are not reported while running tests.
|
353
|
+
|
354
|
+
module HoptoadNotifier
|
355
|
+
def self.notify(thing)
|
356
|
+
# do nothing.
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
== Proxy Support
|
361
|
+
|
362
|
+
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.
|
363
|
+
|
364
|
+
HoptoadNotifier.configure do |config|
|
365
|
+
config.proxy_host = ...
|
366
|
+
config.proxy_port = ...
|
367
|
+
config.proxy_user = ...
|
368
|
+
config.proxy_pass = ...
|
369
|
+
|
370
|
+
== Supported Rails versions
|
371
|
+
|
372
|
+
See SUPPORTED_RAILS_VERSIONS for a list of official supported versions of
|
373
|
+
Rails.
|
374
|
+
|
375
|
+
Please open up a support ticket on Tender ( http://help.hoptoadapp.com ) if
|
376
|
+
you're using a version of Rails that is not listed above and the notifier is
|
377
|
+
not working properly.
|
378
|
+
|
379
|
+
== Javascript Notifer
|
380
|
+
|
381
|
+
To automatically include the Javascript node on every page, set the
|
382
|
+
:js_notifier to true:
|
383
|
+
|
384
|
+
HoptoadNotifier.configure do |config|
|
385
|
+
config.js_notifier = true
|
386
|
+
end
|
387
|
+
|
388
|
+
It automatically uses the API key, host, and port specified in the
|
389
|
+
configuration.
|
390
|
+
|
391
|
+
== Thanks
|
392
|
+
|
393
|
+
Thanks to Eugene Bolshakov for the excellent write-up on GOING BEYOND
|
394
|
+
EXCEPTIONS, which we have included above.
|