exception_notification 4.2.1 → 4.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +5 -5
  2. data/Appraisals +4 -3
  3. data/CHANGELOG.rdoc +57 -1
  4. data/CONTRIBUTING.md +21 -2
  5. data/Gemfile +3 -1
  6. data/README.md +105 -780
  7. data/Rakefile +4 -2
  8. data/docs/notifiers/campfire.md +50 -0
  9. data/docs/notifiers/custom.md +42 -0
  10. data/docs/notifiers/datadog.md +51 -0
  11. data/docs/notifiers/email.md +195 -0
  12. data/docs/notifiers/google_chat.md +31 -0
  13. data/docs/notifiers/hipchat.md +66 -0
  14. data/docs/notifiers/irc.md +97 -0
  15. data/docs/notifiers/mattermost.md +115 -0
  16. data/docs/notifiers/slack.md +161 -0
  17. data/docs/notifiers/sns.md +37 -0
  18. data/docs/notifiers/teams.md +54 -0
  19. data/docs/notifiers/webhook.md +60 -0
  20. data/examples/sample_app.rb +56 -0
  21. data/examples/sinatra/Gemfile +8 -6
  22. data/examples/sinatra/config.ru +3 -1
  23. data/examples/sinatra/sinatra_app.rb +19 -11
  24. data/exception_notification.gemspec +30 -23
  25. data/gemfiles/rails4_0.gemfile +1 -2
  26. data/gemfiles/rails4_1.gemfile +1 -2
  27. data/gemfiles/rails4_2.gemfile +1 -2
  28. data/gemfiles/rails5_0.gemfile +1 -2
  29. data/gemfiles/rails5_1.gemfile +7 -0
  30. data/gemfiles/rails5_2.gemfile +7 -0
  31. data/gemfiles/rails6_0.gemfile +7 -0
  32. data/lib/exception_notification.rb +3 -0
  33. data/lib/exception_notification/rack.rb +30 -23
  34. data/lib/exception_notification/rails.rb +3 -0
  35. data/lib/exception_notification/resque.rb +10 -10
  36. data/lib/exception_notification/sidekiq.rb +10 -12
  37. data/lib/exception_notification/version.rb +5 -0
  38. data/lib/exception_notifier.rb +79 -11
  39. data/lib/exception_notifier/base_notifier.rb +10 -5
  40. data/lib/exception_notifier/campfire_notifier.rb +14 -9
  41. data/lib/exception_notifier/datadog_notifier.rb +156 -0
  42. data/lib/exception_notifier/email_notifier.rb +78 -87
  43. data/lib/exception_notifier/google_chat_notifier.rb +44 -0
  44. data/lib/exception_notifier/hipchat_notifier.rb +16 -10
  45. data/lib/exception_notifier/irc_notifier.rb +38 -31
  46. data/lib/exception_notifier/mattermost_notifier.rb +54 -131
  47. data/lib/exception_notifier/modules/backtrace_cleaner.rb +2 -2
  48. data/lib/exception_notifier/modules/error_grouping.rb +87 -0
  49. data/lib/exception_notifier/modules/formatter.rb +121 -0
  50. data/lib/exception_notifier/notifier.rb +9 -6
  51. data/lib/exception_notifier/slack_notifier.rb +71 -40
  52. data/lib/exception_notifier/sns_notifier.rb +86 -0
  53. data/lib/exception_notifier/teams_notifier.rb +200 -0
  54. data/lib/exception_notifier/views/exception_notifier/_backtrace.html.erb +1 -1
  55. data/lib/exception_notifier/views/exception_notifier/_environment.text.erb +1 -1
  56. data/lib/exception_notifier/views/exception_notifier/_request.text.erb +1 -1
  57. data/lib/exception_notifier/views/exception_notifier/background_exception_notification.text.erb +9 -9
  58. data/lib/exception_notifier/views/exception_notifier/exception_notification.html.erb +2 -4
  59. data/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb +2 -2
  60. data/lib/exception_notifier/webhook_notifier.rb +17 -14
  61. data/lib/generators/exception_notification/install_generator.rb +11 -5
  62. data/lib/generators/exception_notification/templates/{exception_notification.rb → exception_notification.rb.erb} +13 -11
  63. data/test/exception_notification/rack_test.rb +90 -4
  64. data/test/exception_notification/resque_test.rb +54 -0
  65. data/test/exception_notifier/campfire_notifier_test.rb +59 -38
  66. data/test/exception_notifier/datadog_notifier_test.rb +153 -0
  67. data/test/exception_notifier/email_notifier_test.rb +279 -145
  68. data/test/exception_notifier/google_chat_notifier_test.rb +185 -0
  69. data/test/exception_notifier/hipchat_notifier_test.rb +105 -64
  70. data/test/exception_notifier/irc_notifier_test.rb +48 -30
  71. data/test/exception_notifier/mattermost_notifier_test.rb +218 -55
  72. data/test/exception_notifier/modules/error_grouping_test.rb +167 -0
  73. data/test/exception_notifier/modules/formatter_test.rb +152 -0
  74. data/test/exception_notifier/sidekiq_test.rb +9 -17
  75. data/test/exception_notifier/slack_notifier_test.rb +84 -62
  76. data/test/exception_notifier/sns_notifier_test.rb +123 -0
  77. data/test/exception_notifier/teams_notifier_test.rb +92 -0
  78. data/test/exception_notifier/webhook_notifier_test.rb +52 -48
  79. data/test/exception_notifier_test.rb +220 -37
  80. data/test/support/exception_notifier_helper.rb +14 -0
  81. data/test/{dummy/app → support}/views/exception_notifier/_new_bkg_section.html.erb +0 -0
  82. data/test/{dummy/app → support}/views/exception_notifier/_new_bkg_section.text.erb +0 -0
  83. data/test/{dummy/app → support}/views/exception_notifier/_new_section.html.erb +0 -0
  84. data/test/{dummy/app → support}/views/exception_notifier/_new_section.text.erb +0 -0
  85. data/test/test_helper.rb +14 -13
  86. metadata +154 -162
  87. data/test/dummy/.gitignore +0 -4
  88. data/test/dummy/Rakefile +0 -7
  89. data/test/dummy/app/controllers/application_controller.rb +0 -3
  90. data/test/dummy/app/controllers/posts_controller.rb +0 -30
  91. data/test/dummy/app/helpers/application_helper.rb +0 -2
  92. data/test/dummy/app/helpers/posts_helper.rb +0 -2
  93. data/test/dummy/app/models/post.rb +0 -2
  94. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  95. data/test/dummy/app/views/posts/_form.html.erb +0 -0
  96. data/test/dummy/app/views/posts/new.html.erb +0 -0
  97. data/test/dummy/app/views/posts/show.html.erb +0 -0
  98. data/test/dummy/config.ru +0 -4
  99. data/test/dummy/config/application.rb +0 -42
  100. data/test/dummy/config/boot.rb +0 -6
  101. data/test/dummy/config/database.yml +0 -22
  102. data/test/dummy/config/environment.rb +0 -17
  103. data/test/dummy/config/environments/development.rb +0 -25
  104. data/test/dummy/config/environments/production.rb +0 -50
  105. data/test/dummy/config/environments/test.rb +0 -35
  106. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  107. data/test/dummy/config/initializers/inflections.rb +0 -10
  108. data/test/dummy/config/initializers/mime_types.rb +0 -5
  109. data/test/dummy/config/initializers/secret_token.rb +0 -8
  110. data/test/dummy/config/initializers/session_store.rb +0 -8
  111. data/test/dummy/config/locales/en.yml +0 -5
  112. data/test/dummy/config/routes.rb +0 -3
  113. data/test/dummy/db/migrate/20110729022608_create_posts.rb +0 -15
  114. data/test/dummy/db/schema.rb +0 -24
  115. data/test/dummy/db/seeds.rb +0 -7
  116. data/test/dummy/lib/tasks/.gitkeep +0 -0
  117. data/test/dummy/public/404.html +0 -26
  118. data/test/dummy/public/422.html +0 -26
  119. data/test/dummy/public/500.html +0 -26
  120. data/test/dummy/public/favicon.ico +0 -0
  121. data/test/dummy/public/images/rails.png +0 -0
  122. data/test/dummy/public/index.html +0 -239
  123. data/test/dummy/public/javascripts/application.js +0 -2
  124. data/test/dummy/public/javascripts/controls.js +0 -965
  125. data/test/dummy/public/javascripts/dragdrop.js +0 -974
  126. data/test/dummy/public/javascripts/effects.js +0 -1123
  127. data/test/dummy/public/javascripts/prototype.js +0 -6001
  128. data/test/dummy/public/javascripts/rails.js +0 -191
  129. data/test/dummy/public/robots.txt +0 -5
  130. data/test/dummy/public/stylesheets/.gitkeep +0 -0
  131. data/test/dummy/public/stylesheets/scaffold.css +0 -56
  132. data/test/dummy/script/rails +0 -6
  133. data/test/dummy/test/functional/posts_controller_test.rb +0 -218
  134. data/test/dummy/test/test_helper.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6de21b765af1465df6205f174cbab7e10b403048
4
- data.tar.gz: cade5525679b528aded7b1ad6369e97f40b58947
2
+ SHA256:
3
+ metadata.gz: ae2c9d720954788440b1deedc356091324eb5c393801790d6f861c4fe157bdb4
4
+ data.tar.gz: 31e91bdeeda86d168e887fa235e31b9810feb37c91317d564eee46c425376011
5
5
  SHA512:
6
- metadata.gz: fe4b7770171a25a7e131d97c922e5c518531f71add293ce42359eb9f2fc84ea7330f2f935657cbf4dc13fa4a8ba2d3d492397469555d665d12d36c52603a82fd
7
- data.tar.gz: 92774d00ec26d97246ca9d4e6334f3aac06f04c5242a555eb3a5bd5addfd8a8485bdd72787b0d304146c50e79a7ff4500aaf2a08aca744be963f3a779221b193
6
+ metadata.gz: cbd31aedd92e7fc5064cad2efde830070aa41f2289f3e08f57c63d001046cad20187dd6948c4fd96e6489d3d513ee1d6b32069206cbc3562a82bb17f4b92e314
7
+ data.tar.gz: fda70cf9f41a3a57bb83e47bfebbd1c181de0400faa72807474e76b6f2ec69f07ce37ea1ee1a5429e9dfb1b65006a6255765c0bd0677ff53cbf42cd274b5c254
data/Appraisals CHANGED
@@ -1,8 +1,9 @@
1
- rails_versions = ['~> 4.0.5', '~> 4.1.1', '~> 4.2.0', '~> 5.0.0']
1
+ # frozen_string_literal: true
2
+
3
+ rails_versions = ['~> 4.0.5', '~> 4.1.1', '~> 4.2.0', '~> 5.0.0', '~> 5.1.0', '~> 5.2.0', '~> 6.0.0']
2
4
 
3
5
  rails_versions.each do |rails_version|
4
- appraise "rails#{rails_version.slice(/\d+\.\d+/).gsub('.', '_')}" do
6
+ appraise "rails#{rails_version.slice(/\d+\.\d+/).tr('.', '_')}" do
5
7
  gem 'rails', rails_version
6
- gem "sqlite3"
7
8
  end
8
9
  end
@@ -1,3 +1,59 @@
1
+ == 4.4.3
2
+
3
+ * big fixes
4
+ * Remove using configured default from address from custom mailer_parent class
5
+
6
+ == 4.4.2 (yanked)
7
+
8
+ * bug fixes
9
+ * Fix `sender_address` being overwritten
10
+
11
+ == 4.4.1
12
+
13
+ * enhancements
14
+ * Enhance `ignore_if` option to allow by-notifier customization (by @fursich)
15
+ * Ignore extended modules of ignored exceptions (by @elengine)
16
+ * Add `exception_data` to Mattermost notifier (by @camillof)
17
+
18
+ * bug fixes
19
+ * Fix Rubocop offenses (by @nicolasferraro)
20
+
21
+ == 4.4.0
22
+
23
+ * enhancements
24
+ * Rails 6 compatibility (by @shanecav)
25
+ * Add Datadog notifier (by @ajain0184)
26
+ * Use backtrace cleaner for Slack notifications (by @pomier)
27
+ * Add slack channel name override option (by @chaadow)
28
+ * Addition of sample application for testing purposes (by @ampeigonet)
29
+
30
+ * bug fixes
31
+ * Fix error in Resque failure backend (by @EmilioCristalli)
32
+ * Remove sqlite dependency (by @EmilioCristalli)
33
+ * Configure ignore_crawlers from Rails initializer (by @EmilioCristalli)
34
+
35
+ == 4.3.0
36
+
37
+ * enhancements
38
+ * Add Microsoft Teams Notifier (by @phaelin)
39
+ * Add SNS notifier (by @FLarra)
40
+ * Add Google Chats notifier (by @renatolond)
41
+ * Align output of section-headers consistently (by @kronn)
42
+ * ExceptionNotifier.notify_exception receives block & pass it to each notifier (by @pocke)
43
+ * Update Travis to latest rubies (by @lostapathy)
44
+
45
+ * bug fixes
46
+ * Replace all before_filter to before_action on readme (by @pastullo)
47
+ * Fix error when using error grouping outside of rails (by @garethcokell)
48
+ * Fix missing MissingController Mattermost class (by @n-rodriguez)
49
+
50
+ == 4.2.2
51
+
52
+ * enhancements
53
+ * Error grouping (by @Martin91)
54
+ * Additional fields for Slack support (by @schurig)
55
+ * Enterprise HipChat support (by @seanhuber)
56
+
1
57
  == 4.2.1
2
58
 
3
59
  * enhancements
@@ -124,7 +180,7 @@
124
180
  * Add normalize_subject option to remove numbers from email so that they thread (by @jjb)
125
181
  * Allow the user to provide a custom message and hash of data (by @jjb)
126
182
  * Add support for configurable background sections and a data partial (by @jeffrafter)
127
- * Include timestamp of exception in notification body
183
+ * Include timestamp of exception in notification body
128
184
  * Add support for rack based session management (by @phoet)
129
185
  * Add ignore_crawlers option to ignore exceptions generated by crawlers
130
186
  * Add verbode_subject option to exclude exception message from subject (by @amishyn)
@@ -18,6 +18,24 @@ need contributors to follow:
18
18
  like OS version, gem versions, etc...
19
19
  * Even better, provide a failing test case for it.
20
20
 
21
+ To help you add information to an issue, you can use the sample_app.
22
+ Steps to use sample_app:
23
+
24
+ 1) Add your configuration to (ex. with webhook):
25
+ ```ruby
26
+ config.middleware.use ExceptionNotification::Rack,
27
+ # -----------------------------------
28
+ # Change this with your configuration
29
+ # https://github.com/smartinez87/exception_notification#notifiers
30
+ webhook: {
31
+ url: 'http://domain.com:5555/hubot/path'
32
+ }
33
+ # -----------------------------------
34
+ ```
35
+
36
+ 2) Run `ruby examples/sample_app.rb`
37
+ If exception notification is working OK, the test should pass and trigger a notification as configured above. If it's not, you can copy the information printed on the terminal related to exception notification and report an issue with more info!
38
+
21
39
  ## Pull Requests
22
40
 
23
41
  If you've gone the extra mile and have a patch that fixes the issue, you
@@ -30,8 +48,9 @@ should submit a Pull Request!
30
48
  bundle
31
49
  cd test/dummy
32
50
  bundle
33
- bundle exec rake db:reset
34
- bundle exec rake db:test:prepare
51
+ bundle exec rake db:reset db:test:prepare
52
+ cd ../..
53
+ bundle exec rake test
35
54
  ```
36
55
  * Create a topic branch from where you want to base your work.
37
56
  * Add a test for your change. Only refactoring and documentation changes
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # Exception Notification
2
2
 
3
- [![Gem Version](https://fury-badge.herokuapp.com/rb/exception_notification.png)](http://badge.fury.io/rb/exception_notification)
4
- [![Travis](https://api.travis-ci.org/smartinez87/exception_notification.png)](http://travis-ci.org/smartinez87/exception_notification)
5
- [![Coverage Status](https://coveralls.io/repos/smartinez87/exception_notification/badge.png?branch=master)](https://coveralls.io/r/smartinez87/exception_notification)
6
- [![Code Climate](https://codeclimate.com/github/smartinez87/exception_notification.png)](https://codeclimate.com/github/smartinez87/exception_notification)
3
+ [![Gem Version](https://badge.fury.io/rb/exception_notification.svg)](https://badge.fury.io/rb/exception_notification)
4
+ [![Build Status](https://travis-ci.org/smartinez87/exception_notification.svg?branch=master)](https://travis-ci.org/smartinez87/exception_notification)
5
+ [![Coverage Status](https://coveralls.io/repos/github/smartinez87/exception_notification/badge.svg?branch=master)](https://coveralls.io/github/smartinez87/exception_notification?branch=master)
6
+ [![Maintainability](https://api.codeclimate.com/v1/badges/78a9a12be00a6d305136/maintainability)](https://codeclimate.com/github/smartinez87/exception_notification/maintainability)
7
7
 
8
8
  **THIS README IS FOR THE MASTER BRANCH AND REFLECTS THE WORK CURRENTLY EXISTING ON THE MASTER BRANCH. IF YOU ARE WISHING TO USE A NON-MASTER BRANCH OF EXCEPTION NOTIFICATION, PLEASE CONSULT THAT BRANCH'S README AND NOT THIS ONE.**
9
9
 
10
10
  ---
11
11
 
12
- The Exception Notification gem provides a set of [notifiers](#notifiers) for sending notifications when errors occur in a Rack/Rails application. The built-in notifiers can deliver notifications by [email](#email-notifier), [Campfire](#campfire-notifier), [HipChat](#hipchat-notifier), [Slack](#slack-notifier), [Mattermost](#mattermost-notifier), [IRC](#irc-notifier) or via custom [WebHooks](#webhook-notifier).
12
+ The Exception Notification gem provides a set of [notifiers](#notifiers) for sending notifications when errors occur in a Rack/Rails application. The built-in notifiers can deliver notifications by [email](docs/notifiers/email.md), [Campfire](docs/notifiers/campfire.md), [HipChat](docs/notifiers/hipchat.md), [Slack](docs/notifiers/slack.md), [Mattermost](docs/notifiers/mattermost.md), [Teams](docs/notifiers/teams.md), [IRC](docs/notifiers/irc.md), [Amazon SNS](docs/notifiers/sns.md), [Google Chat](docs/notifiers/google_chat.md), [Datadog](docs/notifiers/datadog.md) or via custom [WebHooks](docs/notifiers/webhook.md).
13
13
 
14
14
  There's a great [Railscast about Exception Notification](http://railscasts.com/episodes/104-exception-notifications-revised) you can see that may help you getting started.
15
15
 
@@ -17,11 +17,9 @@ There's a great [Railscast about Exception Notification](http://railscasts.com/e
17
17
 
18
18
  ## Requirements
19
19
 
20
- * Ruby 2.0 or greater
20
+ * Ruby 2.3 or greater
21
21
  * Rails 4.0 or greater, Sinatra or another Rack-based application.
22
22
 
23
- For previous releases, please checkout [this](#versions).
24
-
25
23
  ## Getting Started
26
24
 
27
25
  Add the following line to your application's Gemfile:
@@ -36,15 +34,15 @@ ExceptionNotification is used as a rack middleware, or in the environment you wa
36
34
 
37
35
  ```ruby
38
36
  Rails.application.config.middleware.use ExceptionNotification::Rack,
39
- :email => {
40
- :deliver_with => :deliver, # Rails >= 4.2.1 do not need this option since it defaults to :deliver_now
41
- :email_prefix => "[PREFIX] ",
42
- :sender_address => %{"notifier" <notifier@example.com>},
43
- :exception_recipients => %w{exceptions@example.com}
37
+ email: {
38
+ deliver_with: :deliver, # Rails >= 4.2.1 do not need this option since it defaults to :deliver_now
39
+ email_prefix: '[PREFIX] ',
40
+ sender_address: %{"notifier" <notifier@example.com>},
41
+ exception_recipients: %w{exceptions@example.com}
44
42
  }
45
43
  ```
46
44
 
47
- **Note**: In order to enable delivery notifications by email make sure you have [ActionMailer configured](#actionmailer-configuration).
45
+ **Note**: In order to enable delivery notifications by email make sure you have [ActionMailer configured](docs/notifiers/email.md#actionmailer-configuration).
48
46
 
49
47
  ### Rack/Sinatra
50
48
 
@@ -56,11 +54,13 @@ Save the current user in the `request` using a controller callback.
56
54
 
57
55
  ```ruby
58
56
  class ApplicationController < ActionController::Base
59
- before_filter :prepare_exception_notifier
57
+ before_action :prepare_exception_notifier
58
+
60
59
  private
60
+
61
61
  def prepare_exception_notifier
62
62
  request.env["exception_notifier.exception_data"] = {
63
- :current_user => current_user
63
+ current_user: current_user
64
64
  }
65
65
  end
66
66
  end
@@ -82,732 +82,48 @@ Options -> sections" below.
82
82
 
83
83
  ## Notifiers
84
84
 
85
- ExceptionNotification relies on notifiers to deliver notifications when errors occur in your applications. By default, six notifiers are available:
85
+ ExceptionNotification relies on notifiers to deliver notifications when errors occur in your applications. By default, 8 notifiers are available:
86
86
 
87
- * [Campfire notifier](#campfire-notifier)
88
- * [Email notifier](#email-notifier)
89
- * [HipChat notifier](#hipchat-notifier)
90
- * [IRC notifier](#irc-notifier)
91
- * [Slack notifier](#slack-notifier)
92
- * [Mattermost notifier](#mattermost-notifier)
93
- * [WebHook notifier](#webhook-notifier)
87
+ * [Campfire notifier](docs/notifiers/campfire.md)
88
+ * [Datadog notifier](docs/notifiers/datadog.md)
89
+ * [Email notifier](docs/notifiers/email.md)
90
+ * [HipChat notifier](docs/notifiers/hipchat.md)
91
+ * [IRC notifier](docs/notifiers/irc.md)
92
+ * [Slack notifier](docs/notifiers/slack.md)
93
+ * [Mattermost notifier](docs/notifiers/mattermost.md)
94
+ * [Teams notifier](docs/notifiers/teams.md)
95
+ * [Amazon SNS](docs/notifiers/sns.md)
96
+ * [Google Chat notifier](docs/notifiers/google_chat.md)
97
+ * [WebHook notifier](docs/notifiers/webhook.md)
94
98
 
95
- But, you also can easily implement your own [custom notifier](#custom-notifier).
99
+ But, you also can easily implement your own [custom notifier](docs/notifiers/custom.md).
96
100
 
97
- ### Campfire notifier
101
+ ## Error Grouping
98
102
 
99
- This notifier sends notifications to your Campfire room.
103
+ In general, ExceptionNotification will send a notification when every error occurs, which may result in a problem: if your site has a high throughput and a particular error is raised frequently, you will receive too many notifications. During a short period of time, your mail box may be filled with thousands of exception mails, or your mail server may even become slow. To prevent this, you can choose to group errors by setting the `:error_grouping` option to `true`.
100
104
 
101
- #### Usage
102
-
103
- Just add the [tinder](https://github.com/collectiveidea/tinder) gem to your `Gemfile`:
104
-
105
- ```ruby
106
- gem 'tinder'
107
- ```
105
+ Error grouping uses a default formula of `log2(errors_count)` to determine whether to send the notification, based on the accumulated error count for each specific exception. This makes the notifier only send a notification when the count is: 1, 2, 4, 8, 16, 32, 64, 128, ..., (2**n). You can use `:notification_trigger` to override this default formula.
108
106
 
109
- To configure it, you need to set the `subdomain`, `token` and `room_name` options, like this:
107
+ The following code shows the available options to configure error grouping:
110
108
 
111
109
  ```ruby
112
110
  Rails.application.config.middleware.use ExceptionNotification::Rack,
113
- :email => {
114
- :email_prefix => "[PREFIX] ",
115
- :sender_address => %{"notifier" <notifier@example.com>},
116
- :exception_recipients => %w{exceptions@example.com}
111
+ ignore_exceptions: ['ActionView::TemplateError'] + ExceptionNotifier.ignored_exceptions,
112
+ email: {
113
+ email_prefix: '[PREFIX] ',
114
+ sender_address: %{"notifier" <notifier@example.com>},
115
+ exception_recipients: %w{exceptions@example.com}
117
116
  },
118
- :campfire => {
119
- :subdomain => 'my_subdomain',
120
- :token => 'my_token',
121
- :room_name => 'my_room'
122
- }
123
- ```
124
-
125
- #### Options
126
-
127
- ##### subdomain
128
-
129
- *String, required*
130
-
131
- Your subdomain at Campfire.
132
-
133
- ##### room_name
134
-
135
- *String, required*
136
-
137
- The Campfire room where the notifications must be published to.
138
-
139
- ##### token
140
-
141
- *String, required*
142
-
143
- The API token to allow access to your Campfire account.
144
-
145
-
146
- For more options to set Campfire, like _ssl_, check [here](https://github.com/collectiveidea/tinder/blob/master/lib/tinder/campfire.rb#L17).
147
-
148
- ### Email notifier
149
-
150
- The Email notifier sends notifications by email. The notifications/emails sent includes information about the current request, session, and environment, and also gives a backtrace of the exception.
151
-
152
- After an exception notification has been delivered the rack environment variable `exception_notifier.delivered` will be set to true.
153
-
154
- #### ActionMailer configuration
155
-
156
- For the email to be sent, there must be a default ActionMailer `delivery_method` setting configured. If you do not have one, you can use the following code (assuming your app server machine has `sendmail`). Depending on the environment you want ExceptionNotification to run in, put the following code in your `config/environments/production.rb` and/or `config/environments/development.rb`:
157
-
158
- ```ruby
159
- config.action_mailer.delivery_method = :sendmail
160
- # Defaults to:
161
- # config.action_mailer.sendmail_settings = {
162
- # :location => '/usr/sbin/sendmail',
163
- # :arguments => '-i -t'
164
- # }
165
- config.action_mailer.perform_deliveries = true
166
- config.action_mailer.raise_delivery_errors = true
167
- ```
168
-
169
- #### Options
170
-
171
- ##### sender_address
172
-
173
- *String, default: %("Exception Notifier" <exception.notifier@example.com>)*
174
-
175
- Who the message is from.
176
-
177
- ##### exception_recipients
178
-
179
- *String/Array of strings/Proc, default: []*
180
-
181
- Who the message is destined for, can be a string of addresses, an array of addresses, or it can be a proc that returns a string of addresses or an array of addresses. The proc will be evaluated when the mail is sent.
182
-
183
- ##### email_prefix
184
-
185
- *String, default: [ERROR]*
186
-
187
- The subject's prefix of the message.
188
-
189
- ##### sections
190
-
191
- *Array of strings, default: %w(request session environment backtrace)*
192
-
193
- By default, the notification email includes four parts: request, session, environment, and backtrace (in that order). You can customize how each of those sections are rendered by placing a partial named for that part in your `app/views/exception_notifier` directory (e.g., `_session.rhtml`). Each partial has access to the following variables:
194
-
195
- ```ruby
196
- @kontroller # the controller that caused the error
197
- @request # the current request object
198
- @exception # the exception that was raised
199
- @backtrace # a sanitized version of the exception's backtrace
200
- @data # a hash of optional data values that were passed to the notifier
201
- @sections # the array of sections to include in the email
202
- ```
203
-
204
- You can reorder the sections, or exclude sections completely, by using `sections` option. You can even add new sections that
205
- describe application-specific data--just add the section's name to the list (wherever you'd like), and define the corresponding partial. Like the following example with two new added sections:
206
-
207
- ```ruby
208
- Rails.application.config.middleware.use ExceptionNotification::Rack,
209
- :email => {
210
- :email_prefix => "[PREFIX] ",
211
- :sender_address => %{"notifier" <notifier@example.com>},
212
- :exception_recipients => %w{exceptions@example.com},
213
- :sections => %w{my_section1 my_section2}
214
- }
215
- ```
216
-
217
- Place your custom sections under `./app/views/exception_notifier/` with the suffix `.text.erb`, e.g. `./app/views/exception_notifier/_my_section1.text.erb`.
218
-
219
- If your new section requires information that isn't available by default, make sure it is made available to the email using the `exception_data` macro:
220
-
221
- ```ruby
222
- class ApplicationController < ActionController::Base
223
- before_filter :log_additional_data
224
- ...
225
- protected
226
- def log_additional_data
227
- request.env["exception_notifier.exception_data"] = {
228
- :document => @document,
229
- :person => @person
230
- }
231
- end
232
- ...
233
- end
234
- ```
235
-
236
- In the above case, `@document` and `@person` would be made available to the email renderer, allowing your new section(s) to access and display them. See the existing sections defined by the plugin for examples of how to write your own.
237
-
238
- ##### background_sections
239
-
240
- *Array of strings, default: %w(backtrace data)*
241
-
242
- When using [background notifications](#background-notifications) some variables are not available in the views, like `@kontroller` and `@request`. Thus, you may want to include different sections for background notifications:
243
-
244
- ```ruby
245
- Rails.application.config.middleware.use ExceptionNotification::Rack,
246
- :email => {
247
- :email_prefix => "[PREFIX] ",
248
- :sender_address => %{"notifier" <notifier@example.com>},
249
- :exception_recipients => %w{exceptions@example.com},
250
- :background_sections => %w{my_section1 my_section2 backtrace data}
251
- }
252
- ```
253
-
254
- ##### email_headers
255
-
256
- *Hash of strings, default: {}*
257
-
258
- Additionally, you may want to set customized headers on the outcoming emails. To do so, simply use the `:email_headers` option:
259
-
260
- ```ruby
261
- Rails.application.config.middleware.use ExceptionNotification::Rack,
262
- :email => {
263
- :email_prefix => "[PREFIX] ",
264
- :sender_address => %{"notifier" <notifier@example.com>},
265
- :exception_recipients => %w{exceptions@example.com},
266
- :email_headers => { "X-Custom-Header" => "foobar" }
267
- }
268
- ```
269
-
270
- ##### verbose_subject
271
-
272
- *Boolean, default: true*
273
-
274
- If enabled, include the exception message in the subject. Use `:verbose_subject => false` to exclude it.
275
-
276
- ##### normalize_subject
277
-
278
- *Boolean, default: false*
279
-
280
- If enabled, remove numbers from subject so they thread as a single one. Use `:normalize_subject => true` to enable it.
281
-
282
- ##### email_format
283
-
284
- *Symbol, default: :text*
285
-
286
- By default, ExceptionNotification sends emails in plain text, in order to sends multipart notifications (aka HTML emails) use `:email_format => :html`.
287
-
288
- ##### delivery_method
289
-
290
- *Symbol, default: :smtp*
291
-
292
- By default, ExceptionNotification sends emails using the ActionMailer configuration of the application. In order to send emails by another delivery method, use the `delivery_method` option:
293
-
294
- ```ruby
295
- Rails.application.config.middleware.use ExceptionNotification::Rack,
296
- :email => {
297
- :email_prefix => "[PREFIX] ",
298
- :sender_address => %{"notifier" <notifier@example.com>},
299
- :exception_recipients => %w{exceptions@example.com},
300
- :delivery_method => :postmark,
301
- :postmark_settings => {
302
- :api_key => ENV["POSTMARK_API_KEY"]
303
- }
304
- }
305
- ```
306
-
307
- Besides the `delivery_method` option, you also can customize the mailer settings by passing a hash under an option named `DELIVERY_METHOD_settings`. Thus, you can use override specific SMTP settings for notifications using:
308
-
309
- ```ruby
310
- Rails.application.config.middleware.use ExceptionNotification::Rack,
311
- :email => {
312
- :email_prefix => "[PREFIX] ",
313
- :sender_address => %{"notifier" <notifier@example.com>},
314
- :exception_recipients => %w{exceptions@example.com},
315
- :delivery_method => :smtp,
316
- :smtp_settings => {
317
- :user_name => "bob",
318
- :password => "password",
319
- }
320
- }
321
- ```
322
-
323
- A complete list of `smtp_settings` options can be found in the [ActionMailer Configuration documentation](http://api.rubyonrails.org/classes/ActionMailer/Base.html#class-ActionMailer::Base-label-Configuration+options).
324
-
325
- ##### mailer_parent
326
-
327
- *String, default: ActionMailer::Base*
328
-
329
- The parent mailer which ExceptionNotification mailer inherit from.
330
-
331
- ##### deliver_with
332
-
333
- *Symbol, default: :deliver_now
334
-
335
- The method name to send emalis using ActionMailer.
336
-
337
- ### HipChat notifier
338
-
339
- This notifier sends notifications to your Hipchat room.
340
-
341
- #### Usage
342
-
343
- Just add the [hipchat](https://github.com/hipchat/hipchat-rb) gem to your `Gemfile`:
344
-
345
- ```ruby
346
- gem 'hipchat'
347
- ```
348
-
349
- To configure it, you need to set the `token` and `room_name` options, like this:
350
-
351
- ```ruby
352
- Rails.application.config.middleware.use ExceptionNotification::Rack,
353
- :email => {
354
- :email_prefix => "[PREFIX] ",
355
- :sender_address => %{"notifier" <notifier@example.com>},
356
- :exception_recipients => %w{exceptions@example.com}
357
- },
358
- :hipchat => {
359
- :api_token => 'my_token',
360
- :room_name => 'my_room'
361
- }
362
- ```
363
-
364
- #### Options
365
-
366
- ##### room_name
367
-
368
- *String, required*
369
-
370
- The HipChat room where the notifications must be published to.
371
-
372
- ##### api_token
373
-
374
- *String, required*
375
-
376
- The API token to allow access to your HipChat account.
377
-
378
- ##### notify
379
-
380
- *Boolean, optional*
381
-
382
- Notify users. Default : false.
383
-
384
- ##### color
385
-
386
- *String, optional*
387
-
388
- Color of the message. Default : 'red'.
389
-
390
- ##### from
391
-
392
- *String, optional, maximum length : 15*
393
-
394
- Message will appear from this nickname. Default : 'Exception'.
395
-
396
- For all options & possible values see [Hipchat API](https://www.hipchat.com/docs/api/method/rooms/message).
397
-
398
- ### IRC notifier
399
-
400
- This notifier sends notifications to an IRC channel using the carrier-pigeon gem.
401
-
402
- #### Usage
403
-
404
- Just add the [carrier-pigeon](https://github.com/portertech/carrier-pigeon) gem to your `Gemfile`:
405
-
406
- ```ruby
407
- gem 'carrier-pigeon'
408
- ```
409
-
410
- To configure it, you need to set at least the 'domain' option, like this:
411
-
412
- ```ruby
413
- Rails.application.config.middleware.use ExceptionNotification::Rack,
414
- :email => {
415
- :email_prefix => "[PREFIX] ",
416
- :sender_address => %{"notifier" <notifier@example.com>},
417
- :exception_recipients => %w{exceptions@example.com}
418
- },
419
- :irc => {
420
- :domain => 'irc.example.com'
421
- }
422
- ```
423
-
424
- There are several other options, which are described below. For example, to use ssl and a password, add a prefix, post to the '#log' channel, and include recipients in the message (so that they will be notified), your configuration might look like this:
425
-
426
- ```ruby
427
- Rails.application.config.middleware.use ExceptionNotification::Rack,
428
- :irc => {
429
- :domain => 'irc.example.com',
430
- :nick => 'BadNewsBot',
431
- :password => 'secret',
432
- :port => 6697,
433
- :channel => '#log',
434
- :ssl => true,
435
- :prefix => '[Exception Notification]',
436
- :recipients => ['peter', 'michael', 'samir']
437
- }
438
-
439
- ```
440
-
441
- #### Options
442
-
443
- ##### domain
444
-
445
- *String, required*
446
-
447
- The domain name of your IRC server.
448
-
449
- ##### nick
450
-
451
- *String, optional*
452
-
453
- The message will appear from this nick. Default : 'ExceptionNotifierBot'.
454
-
455
- ##### password
456
-
457
- *String, optional*
458
-
459
- Password for your IRC server.
460
-
461
- ##### port
462
-
463
- *String, optional*
464
-
465
- Port your IRC server is listening on. Default : 6667.
466
-
467
- ##### channel
468
-
469
- *String, optional*
470
-
471
- Message will appear in this channel. Default : '#log'.
472
-
473
- ##### notice
474
-
475
- *Boolean, optional*
476
-
477
- Send a notice. Default : false.
478
-
479
- ##### ssl
480
-
481
- *Boolean, optional*
482
-
483
- Whether to use SSL. Default : false.
484
-
485
- ##### join
486
-
487
- *Boolean, optional*
488
-
489
- Join a channel. Default : false.
490
-
491
- ##### recipients
492
-
493
- *Array of strings, optional*
494
-
495
- Nicks to include in the message. Default: []
496
-
497
- ### Slack notifier
498
-
499
- This notifier sends notifications to a slack channel using the slack-notifier gem.
500
-
501
- #### Usage
502
-
503
- Just add the [slack-notifier](https://github.com/stevenosloan/slack-notifier) gem to your `Gemfile`:
504
-
505
- ```ruby
506
- gem 'slack-notifier'
507
- ```
508
-
509
- To configure it, you need to set at least the 'webhook_url' option, like this:
510
-
511
- ```ruby
512
- Rails.application.config.middleware.use ExceptionNotification::Rack,
513
- :email => {
514
- :email_prefix => "[PREFIX] ",
515
- :sender_address => %{"notifier" <notifier@example.com>},
516
- :exception_recipients => %w{exceptions@example.com}
517
- },
518
- :slack => {
519
- :webhook_url => "[Your webhook url]",
520
- :channel => "#exceptions",
521
- :additional_parameters => {
522
- :icon_url => "http://image.jpg",
523
- :mrkdwn => true
524
- }
525
- }
526
- ```
527
-
528
- The slack notification will include any data saved under `env["exception_notifier.exception_data"]`.
529
-
530
- An example of how to send the server name to Slack in Rails (put this code in application_controller.rb):
531
-
532
- ```ruby
533
- before_filter :set_notification
534
-
535
- def set_notification
536
- request.env['exception_notifier.exception_data'] = {"server" => request.env['SERVER_NAME']}
537
- # can be any key-value pairs
538
- end
539
- ```
540
-
541
- If you find this too verbose, you can determine to exclude certain information by doing the following:
542
-
543
- ```ruby
544
- Rails.application.config.middleware.use ExceptionNotification::Rack,
545
- :slack => {
546
- :webhook_url => "[Your webhook url]",
547
- :channel => "#exceptions",
548
- :additional_parameters => {
549
- :icon_url => "http://image.jpg",
550
- :mrkdwn => true
551
- },
552
- :ignore_data_if => lambda {|key, value|
553
- "#{key}" == 'key_to_ignore' || value.is_a?(ClassToBeIgnored)
554
- }
555
- }
556
- ```
557
-
558
- Any evaluation to `true` will cause the key / value pair not be be sent along to Slack.
559
-
560
- #### Options
561
-
562
- ##### webhook_url
563
-
564
- *String, required*
565
-
566
- The Incoming WebHook URL on slack.
567
-
568
- ##### channel
569
-
570
- *String, optional*
571
-
572
- Message will appear in this channel. Defaults to the channel you set as such on slack.
573
-
574
- ##### username
575
-
576
- *String, optional*
577
-
578
- Username of the bot. Defaults to the name you set as such on slack
579
-
580
- ##### custom_hook
581
-
582
- *String, optional*
583
-
584
- Custom hook name. See [slack-notifier](https://github.com/stevenosloan/slack-notifier#custom-hook-name) for
585
- more information. Default: 'incoming-webhook'
586
-
587
- ##### additional_parameters
588
-
589
- *Hash of strings, optional*
590
-
591
- Contains additional payload for a message (e.g avatar, attachments, etc). See [slack-notifier](https://github.com/stevenosloan/slack-notifier#additional-parameters) for more information.. Default: '{}'
592
-
593
- ## Mattermost notifier
594
-
595
- Post notification in a mattermost channel via [incoming webhook](http://docs.mattermost.com/developer/webhooks-incoming.html)
596
-
597
- Just add the [HTTParty](https://github.com/jnunemaker/httparty) gem to your `Gemfile`:
598
-
599
- ```ruby
600
- gem 'httparty'
601
- ```
602
-
603
- To configure it, you **need** to set the `webhook_url` option.
604
- You can also specify an other channel with `channel` option.
605
-
606
- ```ruby
607
- Rails.application.config.middleware.use ExceptionNotification::Rack,
608
- :email => {
609
- :email_prefix => "[PREFIX] ",
610
- :sender_address => %{"notifier" <notifier@example.com>},
611
- :exception_recipients => %w{exceptions@example.com}
612
- },
613
- :mattermost => {
614
- :webhook_url => 'http://your-mattermost.com/hooks/blablabla',
615
- :channel => 'my-channel'
616
- }
617
- ```
618
-
619
- If you are using Github or Gitlab for issues tracking, you can specify `git_url` as follow to add a *Create issue* link in you notification.
620
- By default this will use your Rails application name to match the git repository. If yours differ you can specify `app_name`.
621
-
622
-
623
- ```ruby
624
- Rails.application.config.middleware.use ExceptionNotification::Rack,
625
- :email => {
626
- :email_prefix => "[PREFIX] ",
627
- :sender_address => %{"notifier" <notifier@example.com>},
628
- :exception_recipients => %w{exceptions@example.com}
629
- },
630
- :mattermost => {
631
- :webhook_url => 'http://your-mattermost.com/hooks/blablabla',
632
- :git_url => 'github.com/aschen'
633
- }
634
- ```
635
-
636
- You can also specify the bot name and avatar with `username` and `avatar` options.
637
-
638
- ```ruby
639
- Rails.application.config.middleware.use ExceptionNotification::Rack,
640
- :email => {
641
- :email_prefix => "[PREFIX] ",
642
- :sender_address => %{"notifier" <notifier@example.com>},
643
- :exception_recipients => %w{exceptions@example.com}
644
- },
645
- :mattermost => {
646
- :webhook_url => 'http://your-mattermost.com/hooks/blablabla',
647
- :avatar => 'http://example.com/your-image.png',
648
- :username => 'Fail bot'
649
- }
650
- ```
651
-
652
- Finally since the notifier use HTTParty, you can include all HTTParty options, like basic_auth for example.
653
-
654
- ```ruby
655
- Rails.application.config.middleware.use ExceptionNotification::Rack,
656
- :email => {
657
- :email_prefix => "[PREFIX] ",
658
- :sender_address => %{"notifier" <notifier@example.com>},
659
- :exception_recipients => %w{exceptions@example.com}
660
- },
661
- :mattermost => {
662
- :webhook_url => 'http://your-mattermost.com/hooks/blablabla',
663
- :basic_auth => {
664
- :username => 'clara',
665
- :password => 'password'
666
- }
667
- }
668
- ```
669
-
670
- #### Options
671
-
672
- ##### webhook_url
673
-
674
- *String, required*
675
-
676
- The Incoming WebHook URL on mattermost.
677
-
678
- ##### channel
679
-
680
- *String, optional*
681
-
682
- Message will appear in this channel. Defaults to the channel you set as such on mattermost.
683
-
684
- ##### username
685
-
686
- *String, optional*
687
-
688
- Username of the bot. Defaults to "Incoming Webhook"
689
-
690
- ##### avatar
691
-
692
- *String, optional*
693
-
694
- Avatar of the bot. Defaults to incoming webhook icon.
695
-
696
- ##### git_url
697
-
698
- *String, optional*
699
-
700
- Url of your gitlab or github with your organisation name for issue creation link (Eg: `github.com/aschen`). Defaults to nil and don't add link to the notification.
701
-
702
- ##### app_name
703
-
704
- *String, optional*
705
-
706
- Your application name used for issue creation link. Defaults to ``` Rails.application.class.parent_name.underscore```.
707
-
708
-
709
- ### WebHook notifier
710
-
711
- This notifier ships notifications over the HTTP protocol.
712
-
713
- #### Usage
714
-
715
- Just add the [HTTParty](https://github.com/jnunemaker/httparty) gem to your `Gemfile`:
716
-
717
- ```ruby
718
- gem 'httparty'
719
- ```
720
-
721
- To configure it, you need to set the `url` option, like this:
722
-
723
- ```ruby
724
- Rails.application.config.middleware.use ExceptionNotification::Rack,
725
- :email => {
726
- :email_prefix => "[PREFIX] ",
727
- :sender_address => %{"notifier" <notifier@example.com>},
728
- :exception_recipients => %w{exceptions@example.com}
729
- },
730
- :webhook => {
731
- :url => 'http://domain.com:5555/hubot/path'
732
- }
733
- ```
734
-
735
- By default, the WebhookNotifier will call the URLs using the POST method. But, you can change this using the `http_method` option.
736
-
737
- ```ruby
738
- Rails.application.config.middleware.use ExceptionNotification::Rack,
739
- :email => {
740
- :email_prefix => "[PREFIX] ",
741
- :sender_address => %{"notifier" <notifier@example.com>},
742
- :exception_recipients => %w{exceptions@example.com}
743
- },
744
- :webhook => {
745
- :url => 'http://domain.com:5555/hubot/path',
746
- :http_method => :get
747
- }
748
- ```
749
-
750
- Besides the `url` and `http_method` options, all the other options are passed directly to HTTParty. Thus, if the HTTP server requires authentication, you can include the following options:
751
-
752
- ```ruby
753
- Rails.application.config.middleware.use ExceptionNotification::Rack,
754
- :email => {
755
- :email_prefix => "[PREFIX] ",
756
- :sender_address => %{"notifier" <notifier@example.com>},
757
- :exception_recipients => %w{exceptions@example.com}
758
- },
759
- :webhook => {
760
- :url => 'http://domain.com:5555/hubot/path',
761
- :basic_auth => {
762
- :username => 'alice',
763
- :password => 'password'
764
- }
765
- }
766
- ```
767
-
768
- For more HTTParty options, check out the [documentation](https://github.com/jnunemaker/httparty).
769
-
770
- ### Custom notifier
771
-
772
- Simply put, notifiers are objects which respond to `#call(exception, options)` method. Thus, a lambda can be used as a notifier as follow:
773
-
774
- ```ruby
775
- ExceptionNotifier.add_notifier :custom_notifier_name,
776
- ->(exception, options) { puts "Something goes wrong: #{exception.message}"}
777
- ```
778
-
779
- More advanced users or third-party framework developers, also can create notifiers to be shipped in gems and take advantage of ExceptionNotification's Notifier API to standardize the [various](https://github.com/airbrake/airbrake) [solutions](https://www.honeybadger.io) [out](http://www.exceptional.io) [there](https://bugsnag.com). For this, beyond the `#call(exception, options)` method, the notifier class MUST BE defined under the ExceptionNotifier namespace and its name sufixed by `Notifier`, e.g: ExceptionNotifier::SimpleNotifier.
780
-
781
- #### Example
782
-
783
- Define the custom notifier:
784
-
785
- ```ruby
786
- module ExceptionNotifier
787
- class SimpleNotifier
788
- def initialize(options)
789
- # do something with the options...
790
- end
791
-
792
- def call(exception, options={})
793
- # send the notification
794
- end
795
- end
796
- end
797
- ```
798
-
799
- Using it:
800
-
801
- ```ruby
802
- Rails.application.config.middleware.use ExceptionNotification::Rack,
803
- :email => {
804
- :email_prefix => "[PREFIX] ",
805
- :sender_address => %{"notifier" <notifier@example.com>},
806
- :exception_recipients => %w{exceptions@example.com}
807
- },
808
- :simple => {
809
- # simple notifier options
810
- }
117
+ error_grouping: true,
118
+ # error_grouping_period: 5.minutes, # the time before an error is regarded as fixed
119
+ # error_grouping_cache: Rails.cache, # for other applications such as Sinatra, use one instance of ActiveSupport::Cache::Store
120
+ #
121
+ # notification_trigger: specify a callback to determine when a notification should be sent,
122
+ # the callback will be invoked with two arguments:
123
+ # exception: the exception raised
124
+ # count: accumulated errors count for this exception
125
+ #
126
+ # notification_trigger: lambda { |exception, count| count % 10 == 0 }
811
127
  ```
812
128
 
813
129
  ## Ignore Exceptions
@@ -820,6 +136,8 @@ You can choose to ignore certain exceptions, which will make ExceptionNotificati
820
136
 
821
137
  * `:ignore_if` - Custom (i.e. ignore exceptions that satisfy some condition)
822
138
 
139
+ * `:ignore_notifer_if` - Custom (i.e. let each notifier ignore exceptions if by-notifier condition is satisfied)
140
+
823
141
 
824
142
  ### :ignore_exceptions
825
143
 
@@ -829,12 +147,12 @@ Ignore specified exception types. To achieve that, you should use the `:ignore_e
829
147
 
830
148
  ```ruby
831
149
  Rails.application.config.middleware.use ExceptionNotification::Rack,
832
- :ignore_exceptions => ['ActionView::TemplateError'] + ExceptionNotifier.ignored_exceptions,
833
- :email => {
834
- :email_prefix => "[PREFIX] ",
835
- :sender_address => %{"notifier" <notifier@example.com>},
836
- :exception_recipients => %w{exceptions@example.com}
837
- }
150
+ ignore_exceptions: ['ActionView::TemplateError'] + ExceptionNotifier.ignored_exceptions,
151
+ email: {
152
+ email_prefix: '[PREFIX] ',
153
+ sender_address: %{"notifier" <notifier@example.com>},
154
+ exception_recipients: %w{exceptions@example.com}
155
+ }
838
156
  ```
839
157
 
840
158
  The above will make ExceptionNotifier ignore a *TemplateError* exception, plus the ones ignored by default.
@@ -847,32 +165,58 @@ In some cases you may want to avoid getting notifications from exceptions made b
847
165
 
848
166
  ```ruby
849
167
  Rails.application.config.middleware.use ExceptionNotification::Rack,
850
- :ignore_crawlers => %w{Googlebot bingbot},
851
- :email => {
852
- :email_prefix => "[PREFIX] ",
853
- :sender_address => %{"notifier" <notifier@example.com>},
854
- :exception_recipients => %w{exceptions@example.com}
855
- }
168
+ ignore_crawlers: %w{Googlebot bingbot},
169
+ email: {
170
+ email_prefix: '[PREFIX] ',
171
+ sender_address: %{"notifier" <notifier@example.com>},
172
+ exception_recipients: %w{exceptions@example.com}
173
+ }
856
174
  ```
857
175
 
858
176
  ### :ignore_if
859
177
 
860
178
  *Lambda, default: nil*
861
179
 
862
- Last but not least, you can ignore exceptions based on a condition. Take a look:
180
+ You can ignore exceptions based on a condition. Take a look:
863
181
 
864
182
  ```ruby
865
183
  Rails.application.config.middleware.use ExceptionNotification::Rack,
866
- :ignore_if => ->(env, exception) { exception.message =~ /^Couldn't find Page with ID=/ },
867
- :email => {
868
- :email_prefix => "[PREFIX] ",
869
- :sender_address => %{"notifier" <notifier@example.com>},
870
- :exception_recipients => %w{exceptions@example.com},
871
- }
184
+ ignore_if: ->(env, exception) { exception.message =~ /^Couldn't find Page with ID=/ },
185
+ email: {
186
+ email_prefix: '[PREFIX] ',
187
+ sender_address: %{"notifier" <notifier@example.com>},
188
+ exception_recipients: %w{exceptions@example.com},
189
+ }
872
190
  ```
873
191
 
874
192
  You can make use of both the environment and the exception inside the lambda to decide wether to avoid or not sending the notification.
875
193
 
194
+ ### :ignore_notifier_if
195
+
196
+ * Hash of Lambda, default: nil*
197
+
198
+ In case you want a notifier to ignore certain exceptions, but don't want other notifiers to skip them, you can set by-notifier ignore options.
199
+ By setting below, each notifier will ignore exceptions when its corresponding condition is met.
200
+
201
+ ```ruby
202
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
203
+ ignore_notifier_if: {
204
+ email: ->(env, exception) { !Rails.env.production? },
205
+ slack: ->(env, exception) { exception.message =~ /^Couldn't find Page with ID=/ }
206
+ }
207
+
208
+ email: {
209
+ sender_address: %{"notifier" <notifier@example.com>},
210
+ exception_recipients: %w{exceptions@example.com}
211
+ },
212
+ slack: {
213
+ webhook_url: '[Your webhook url]',
214
+ channel: '#exceptions',
215
+ }
216
+ ```
217
+
218
+ To customize each condition, you can make use of environment and the exception object inside the lambda.
219
+
876
220
  ## Rack X-Cascade Header
877
221
 
878
222
  Some rack apps (Rails in particular) utilize the "X-Cascade" header to pass the request-handling responsibility to the next middleware in the stack.
@@ -902,9 +246,11 @@ You can include information about the background process that created the error
902
246
  ```ruby
903
247
  begin
904
248
  some code...
905
- rescue => exception
906
- ExceptionNotifier.notify_exception(exception,
907
- :data => {:worker => worker.to_s, :queue => queue, :payload => payload})
249
+ rescue => e
250
+ ExceptionNotifier.notify_exception(
251
+ e,
252
+ data: { worker: worker.to_s, queue: queue, payload: payload}
253
+ )
908
254
  end
909
255
  ```
910
256
 
@@ -913,13 +259,15 @@ end
913
259
  If your controller action manually handles an error, the notifier will never be run. To manually notify of an error you can do something like the following:
914
260
 
915
261
  ```ruby
916
- rescue_from Exception, :with => :server_error
262
+ rescue_from Exception, with: :server_error
917
263
 
918
264
  def server_error(exception)
919
265
  # Whatever code that handles the exception
920
266
 
921
- ExceptionNotifier.notify_exception(exception,
922
- :env => request.env, :data => {:message => "was doing something wrong"})
267
+ ExceptionNotifier.notify_exception(
268
+ exception,
269
+ env: request.env, data: { message: 'was doing something wrong' }
270
+ )
923
271
  end
924
272
  ```
925
273
 
@@ -948,29 +296,6 @@ or
948
296
 
949
297
  As above, make sure the gem is not listed solely under the `production` group, since this initializer will be loaded regardless of environment.
950
298
 
951
- ## Versions
952
-
953
- For v4.2.1, see this tag:
954
-
955
- http://github.com/smartinez87/exception_notification/tree/v4.2.1
956
-
957
- For v4.2.0, see this tag:
958
-
959
- http://github.com/smartinez87/exception_notification/tree/v4.2.0
960
-
961
- For previous releases, visit:
962
-
963
- https://github.com/smartinez87/exception_notification/tags
964
-
965
- If you are running Rails 2.3 then see the branch for that:
966
-
967
- http://github.com/smartinez87/exception_notification/tree/2-3-stable
968
-
969
- If you are running pre-rack Rails then see this tag:
970
-
971
- http://github.com/smartinez87/exception_notification/tree/pre-2-3
972
-
973
-
974
299
  ## Support and tickets
975
300
 
976
301
  Here's the list of [issues](https://github.com/smartinez87/exception_notification/issues) we're currently working on.