zenbox 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
data/INSTALL ADDED
@@ -0,0 +1,15 @@
1
+ === Configuration
2
+
3
+ You should have something like this in config/initializers/contextify.rb.
4
+
5
+ Contextify.configure do |config|
6
+ config.api_key = '1234567890abcdef'
7
+ end
8
+
9
+
10
+ You can test that Contextify is working in your production environment by using
11
+ this rake task (from RAILS_ROOT):
12
+
13
+ rake contextify:test
14
+
15
+ If everything is configured properly, that task will send sample data to Contextify.
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012, Bushido 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.md ADDED
@@ -0,0 +1,465 @@
1
+ Contextify
2
+ ========
3
+
4
+ This is the notifier gem for integrating apps with [Contextify](http://contextify.io).
5
+
6
+ When an uncaught exception occurs, Contextify will POST the relevant data
7
+ to the Contextify server specified in your environment.
8
+
9
+ Help
10
+ ----
11
+
12
+ For help with using Contextify and this notifier visit [our support site](http://help.contextify.io).
13
+
14
+ For discussion of Contextify development check out the [mailing list](http://groups.google.com/group/hoptoad-notifier-dev).
15
+
16
+ For SSL verification see the [Resources](https://github.com/contextify/contextify/blob/master/resources/README.md).
17
+
18
+ Rails Installation
19
+ ------------------
20
+
21
+ ### Rails 3.x
22
+
23
+ Add the contextify gem to your Gemfile. In Gemfile:
24
+
25
+ gem "contextify"
26
+
27
+ Then from your project's RAILS_ROOT, and in your development environment, run:
28
+
29
+ bundle install
30
+ rails generate contextify --api-key your_key_here
31
+
32
+ That's it!
33
+
34
+ The generator creates a file under `config/initializers/contextify.rb` configuring Contextify with your API key. This file should be checked into your version control system so that it is deployed to your staging and production environments.
35
+
36
+ ### Rails 2.x
37
+
38
+ Add the contextify gem to your app. In config/environment.rb:
39
+
40
+ config.gem 'contextify'
41
+
42
+ or if you are using bundler:
43
+
44
+ gem 'contextify', :require => 'contextify/rails'
45
+
46
+ Then from your project's RAILS_ROOT, and in your development environment, run:
47
+
48
+ rake gems:install
49
+ rake gems:unpack GEM=contextify
50
+ script/generate contextify --api-key your_key_here
51
+
52
+ As always, if you choose not to vendor the contextify gem, make sure
53
+ every server you deploy to has the gem installed or your application won't start.
54
+
55
+ The generator creates a file under `config/initializers/contextify.rb` configuring Contextify with your API key. This file should be checked into your version control system so that it is deployed to your staging and production environments.
56
+
57
+ ### Upgrading From Earlier Versions of Contextify
58
+
59
+ If you're currently using the plugin version (if you have a
60
+ vendor/plugins/hoptoad_notifier directory, you are), you'll need to perform a
61
+ few extra steps when upgrading to the gem version.
62
+
63
+ Add the contextify gem to your app. In config/environment.rb:
64
+
65
+ config.gem 'contextify'
66
+
67
+ Remove the plugin:
68
+
69
+ rm -rf vendor/plugins/hoptoad_notifier
70
+
71
+ Make sure the following line DOES NOT appear in your ApplicationController file:
72
+
73
+ include HoptoadNotifier::Catcher
74
+
75
+ If it does, remove it. The new catcher is automatically included by the gem
76
+ version of Contextify.
77
+
78
+ Before running the contextify generator, you need to find your project's API key.
79
+ Log in to your account at contextify.io, and click on the "Projects" button.
80
+ Then, find your project in the list, and click on its name. In the left-hand
81
+ column, you'll see an "Edit this project" button. Click on that to get your
82
+ project's API key. If you accidentally use your personal API api_key,
83
+ you will get API key not found errors, and exceptions will not be stored
84
+ by the Contextify service.
85
+
86
+ Then from your project's RAILS_ROOT, run:
87
+
88
+ rake gems:install
89
+ script/generate contextify --api-key your_key_here
90
+
91
+ Once installed, you should vendor the contextify gem.
92
+
93
+ rake gems:unpack GEM=contextify
94
+
95
+ As always, if you choose not to vendor the contextify gem, make sure
96
+ every server you deploy to has the gem installed or your application won't
97
+ start.
98
+
99
+ ### Upgrading from Earlier Versions of the Hoptoad Gem (with config.gem)
100
+
101
+ If you're currently using the gem version of the hoptoad_notifier and have
102
+ a version of Rails that uses config.gem (in the 2.x series), there is
103
+ a step or two that you need to do to upgrade. First, you need to remove
104
+ the old version of the gem from vendor/gems:
105
+
106
+ rm -rf vendor/gems/hoptoad_notifier-X.X.X
107
+
108
+ Then you must remove the hoptoad_notifier_tasks.rake file from lib:
109
+
110
+ rm lib/tasks/hoptoad_notifier_tasks.rake
111
+
112
+ You can then continue to install normally. If you don't remove the rake file,
113
+ you will be unable to unpack this gem (Rails will think it's part of the
114
+ framework).
115
+
116
+
117
+
118
+ You can test that Contextify is working in your production environment by using
119
+ this rake task (from RAILS_ROOT):
120
+
121
+ rake contextify:test
122
+
123
+ If everything is configured properly, that task will send a notice to Contextify
124
+ which will be visible immediately.
125
+
126
+ ### Removing hoptoad_notifier
127
+
128
+ in your ApplicationController, REMOVE this line:
129
+
130
+ include HoptoadNotifiable
131
+
132
+ In your config/environment* files, remove all references to HoptoadNotifier
133
+
134
+ Remove the vendor/plugins/hoptoad_notifier directory.
135
+
136
+ ### Remove hoptoad_notifier plugin
137
+
138
+ Remove the vendor/plugins/hoptoad_notifier directory before installing the gem, or run:
139
+
140
+ script/plugin remove hoptoad_notifier
141
+
142
+ Non-rails apps using Bundler
143
+ ----------------------------
144
+ There is an undocumented dependency in `activesupport` where the `i18n` gem is
145
+ required only if the core classes extensions are used (`active_support/core_ext`).
146
+ This can lead to a confusing `LoadError` exception when using Contextify. Until
147
+ this is fixed in `activesupport` the workaround is to add `i18n` to the Gemfile
148
+ for your Sinatra/Rack/pure ruby application:
149
+
150
+ gem 'i18n'
151
+ gem 'contextify'
152
+
153
+ Rack
154
+ ----
155
+
156
+ In order to use contextify in a non-Rails rack app, just load
157
+ contextify, configure your API key, and use the Contextify::Rack
158
+ middleware:
159
+
160
+ require 'rack'
161
+ require 'contextify'
162
+
163
+ Contextify.configure do |config|
164
+ config.api_key = 'my_api_key'
165
+ end
166
+
167
+ app = Rack::Builder.app do
168
+ run lambda { |env| raise "Rack down" }
169
+ end
170
+
171
+ use Contextify::Rack
172
+ run app
173
+
174
+ Sinatra
175
+ -------
176
+
177
+ Using contextify in a Sinatra app is just like a Rack app:
178
+
179
+ require 'sinatra'
180
+ require 'contextify'
181
+
182
+ Contextify.configure do |config|
183
+ config.api_key = 'my API key'
184
+ end
185
+
186
+ use Contextify::Rack
187
+
188
+ get '/' do
189
+ raise "Sinatra has left the building"
190
+ end
191
+
192
+ Usage
193
+ -----
194
+
195
+ For the most part, Contextify works for itself.
196
+
197
+ It intercepts the exception middleware calls, sends notifications and continues the middleware call chain.
198
+
199
+ If you want to log arbitrary things which you've rescued yourself from a
200
+ controller, you can do something like this:
201
+
202
+ ...
203
+ rescue => ex
204
+ notify_contextify(ex)
205
+ flash[:failure] = 'Encryptions could not be rerouted, try again.'
206
+ end
207
+ ...
208
+
209
+ The `#notify_contextify` call will send the notice over to Contextify for later
210
+ analysis. While in your controllers you use the `notify_contextify` method, anywhere
211
+ else in your code, use `Contextify.notify`.
212
+
213
+ To perform custom error processing after Contextify has been notified, define the
214
+ instance method `#rescue_action_in_public_without_contextify(exception)` in your
215
+ controller.
216
+
217
+ Informing the User
218
+ ------------------
219
+
220
+ The contextify gem is capable of telling the user information about the error that just happened
221
+ via the user_information option. They can give this error number in bug reports, for example.
222
+ By default, if your 500.html contains the text
223
+
224
+ <!-- AIRBRAKE ERROR -->
225
+
226
+ then that comment will be replaced with the text "Contextify Error [errnum]". You can modify the text
227
+ of the informer by setting `config.user_information`. Contextify will replace "{{ error_id }}" with the
228
+ ID of the error that is returned from Contextify.
229
+
230
+ Contextify.configure do |config|
231
+ ...
232
+ config.user_information = "<p>Tell the devs that it was <strong>{{ error_id }}</strong>'s fault.</p>"
233
+ end
234
+
235
+ You can also turn the middleware that handles this completely off by setting `config.user_information` to false.
236
+
237
+ Note that this feature is reading the error id from `env['contextify.error_id']`. When the exception is caught
238
+ automatically in a controller, Contextify sets that value. If you're, however, calling the Contextify methods like
239
+ `Contextify#notify` or `Contextify#notify_or_ignore`, please make sure you set that value. So the proper way of calling the
240
+ "manual" methods would be `env['contextify.error_id'] = Contextify.notify_or_ignore(...)`.
241
+
242
+ Tracking deployments in Contextify
243
+ --------------------------------
244
+
245
+ Paying Contextify plans support the ability to track deployments of your application in Contextify.
246
+ By notifying Contextify of your application deployments, all errors are resolved when a deploy occurs,
247
+ so that you'll be notified again about any errors that reoccur after a deployment.
248
+
249
+ Additionally, it's possible to review the errors in Contextify that occurred before and after a deploy.
250
+
251
+ When Contextify is installed as a gem, you need to add
252
+
253
+ require 'contextify/capistrano'
254
+
255
+ to your deploy.rb
256
+
257
+ If you don't use Capistrano, then you can use the following rake task from your
258
+ deployment process to notify Contextify:
259
+
260
+ rake contextify:deploy TO=#{rails_env} REVISION=#{current_revision} REPO=#{repository} USER=#{local_user}
261
+
262
+ Going beyond exceptions
263
+ -----------------------
264
+
265
+ You can also pass a hash to `Contextify.notify` method and store whatever you want,
266
+ not just an exception. And you can also use it anywhere, not just in
267
+ controllers:
268
+
269
+ begin
270
+ params = {
271
+ # params that you pass to a method that can throw an exception
272
+ }
273
+ my_unpredicable_method(params)
274
+ rescue => e
275
+ Contextify.notify(
276
+ :error_class => "Special Error",
277
+ :error_message => "Special Error: #{e.message}",
278
+ :parameters => params
279
+ )
280
+ end
281
+
282
+ While in your controllers you use the `notify_contextify` method, anywhere else in
283
+ your code, use `Contextify.notify`. Contextify will get all the information
284
+ about the error itself. As for a hash, these are the keys you should pass:
285
+
286
+ * `:error_class` - Use this to group similar errors together. When Contextify catches an exception it sends the class name of that exception object.
287
+ * `:error_message` - This is the title of the error you see in the errors list. For exceptions it is "#{exception.class.name}: #{exception.message}"
288
+ * `:parameters` - While there are several ways to send additional data to Contextify, passing a Hash as :parameters as in the example above is the most common use case. When Contextify catches an exception in a controller, the actual HTTP client request parameters are sent using this key.
289
+
290
+ Contextify merges the hash you pass with these default options:
291
+
292
+ {
293
+ :api_key => Contextify.api_key,
294
+ :error_message => 'Notification',
295
+ :backtrace => caller,
296
+ :parameters => {},
297
+ :session => {}
298
+ }
299
+
300
+ You can override any of those parameters.
301
+
302
+ ### Sending shell environment variables when "Going beyond exceptions"
303
+
304
+ One common request we see is to send shell environment variables along with
305
+ manual exception notification. We recommend sending them along with CGI data
306
+ or Rack environment (:cgi_data or :rack_env keys, respectively.)
307
+
308
+ See Contextify::Notice#initialize in lib/contextify/notice.rb for
309
+ more details.
310
+
311
+ Filtering
312
+ ---------
313
+
314
+ You can specify a whitelist of errors that Contextify will not report on. Use
315
+ this feature when you are so apathetic to certain errors that you don't want
316
+ them even logged.
317
+
318
+ This filter will only be applied to automatic notifications, not manual
319
+ notifications (when #notify is called directly).
320
+
321
+ Contextify ignores the following exceptions by default:
322
+
323
+ ActiveRecord::RecordNotFound
324
+ ActionController::RoutingError
325
+ ActionController::InvalidAuthenticityToken
326
+ CGI::Session::CookieStore::TamperedWithCookie
327
+ ActionController::UnknownAction
328
+ AbstractController::ActionNotFound
329
+ Mongoid::Errors::DocumentNotFound
330
+
331
+
332
+ To ignore errors in addition to those, specify their names in your Contextify
333
+ configuration block.
334
+
335
+ Contextify.configure do |config|
336
+ config.api_key = '1234567890abcdef'
337
+ config.ignore << "ActiveRecord::IgnoreThisError"
338
+ end
339
+
340
+ To ignore *only* certain errors (and override the defaults), use the #ignore_only attribute.
341
+
342
+ Contextify.configure do |config|
343
+ config.api_key = '1234567890abcdef'
344
+ config.ignore_only = ["ActiveRecord::IgnoreThisError"] # or [] to ignore no exceptions.
345
+ end
346
+
347
+ To ignore certain user agents, add in the #ignore_user_agent attribute as a
348
+ string or regexp:
349
+
350
+ Contextify.configure do |config|
351
+ config.api_key = '1234567890abcdef'
352
+ config.ignore_user_agent << /Ignored/
353
+ config.ignore_user_agent << 'IgnoredUserAgent'
354
+ end
355
+
356
+ To ignore exceptions based on other conditions, use #ignore_by_filter:
357
+
358
+ Contextify.configure do |config|
359
+ config.api_key = '1234567890abcdef'
360
+ config.ignore_by_filter do |exception_data|
361
+ true if exception_data[:error_class] == "RuntimeError"
362
+ end
363
+ end
364
+
365
+ To replace sensitive information sent to the Contextify service with [FILTERED] use #params_filters:
366
+
367
+ Contextify.configure do |config|
368
+ config.api_key = '1234567890abcdef'
369
+ config.params_filters << "credit_card_number"
370
+ end
371
+
372
+ Note that, when rescuing exceptions within an ActionController method,
373
+ contextify will reuse filters specified by #filter_parameter_logging.
374
+
375
+ Testing
376
+ -------
377
+
378
+ When you run your tests, you might notice that the Contextify service is recording
379
+ notices generated using #notify when you don't expect it to. You can
380
+ use code like this in your test_helper.rb or spec_helper.rb files to redefine
381
+ that method so those errors are not reported while running tests.
382
+
383
+ module Contextify
384
+ def self.notify(exception, opts = {})
385
+ # do nothing.
386
+ end
387
+ end
388
+
389
+ Proxy Support
390
+ -------------
391
+
392
+ The notifier supports using a proxy, if your server is not able to directly reach the Contextify servers. To configure the proxy settings, added the following information to your Contextify configuration block.
393
+
394
+ Contextify.configure do |config|
395
+ config.proxy_host = proxy.host.com
396
+ config.proxy_port = 4038
397
+ config.proxy_user = foo # optional
398
+ config.proxy_pass = bar # optional
399
+
400
+ Supported Rails versions
401
+ ------------------------
402
+
403
+ See SUPPORTED_RAILS_VERSIONS for a list of official supported versions of
404
+ Rails.
405
+
406
+ Please open up a support ticket ( http://help.contextify.io ) or submit a new github issue
407
+ if you're using a version of Rails that is listed above and the notifier is
408
+ not working properly.
409
+
410
+ Javascript Notifer
411
+ ------------------
412
+
413
+ To automatically include the Javascript node on every page, use this helper method from your layouts:
414
+
415
+ <%= contextify_javascript_notifier %>
416
+
417
+ It's important to insert this very high in the markup, above all other javascript. Example:
418
+
419
+ <!DOCTYPE html>
420
+ <html>
421
+ <head>
422
+ <meta charset="utf8">
423
+ <%= contextify_javascript_notifier %>
424
+ <!-- more javascript -->
425
+ </head>
426
+ <body>
427
+ ...
428
+ </body>
429
+ </html>
430
+
431
+ This helper will automatically use the API key, host, and port specified in the configuration.
432
+
433
+ The Javascript notifier tends to send much more notifications than the base Rails project.
434
+ If you want to receive them into a separate Contextify project, specify its
435
+ API key in the `js_api_key` option.
436
+
437
+ config.js_api_key = 'another-projects-api-key'
438
+
439
+ To test the Javascript notifier in development environment, overwrite (temporarily) the development_environments option:
440
+
441
+ Contextify.configure do |config|
442
+ # ...
443
+ config.development_environments = []
444
+ end
445
+
446
+ Development
447
+ -----------
448
+
449
+ See TESTING.md for instructions on how to run the tests.
450
+
451
+ Credits
452
+ -------
453
+
454
+ ![thoughtbot](http://thoughtbot.com/images/tm/logo.png)
455
+
456
+ Contextify is maintained and funded by [contextify.io](http://contextify.io)
457
+
458
+ Thank you to all [the contributors](https://github.com/contextify/contextify/contributors)!
459
+
460
+ The names and logos for Contextify, thoughtbot are trademarks of their respective holders.
461
+
462
+ License
463
+ -------
464
+
465
+ Contextify is Copyright © 2008-2012 Contextify. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.