exception_notification 4.4.3 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +1 -1
  3. data/CHANGELOG.rdoc +13 -0
  4. data/Gemfile.lock +352 -0
  5. data/README.md +99 -46
  6. data/docs/notifiers/slack.md +0 -7
  7. data/exception_notification.gemspec +7 -7
  8. data/gemfiles/{rails5_0.gemfile → rails6_1.gemfile} +1 -1
  9. data/gemfiles/{rails4_2.gemfile → rails7_0.gemfile} +1 -1
  10. data/lib/exception_notification/rails/runner_tie.rb +31 -0
  11. data/lib/exception_notification/rails.rb +16 -0
  12. data/lib/exception_notification/rake.rb +60 -0
  13. data/lib/exception_notification/version.rb +1 -1
  14. data/lib/exception_notifier/email_notifier.rb +1 -1
  15. data/lib/exception_notifier/modules/error_grouping.rb +1 -0
  16. data/lib/exception_notifier/modules/formatter.rb +5 -1
  17. data/lib/exception_notifier/slack_notifier.rb +3 -0
  18. data/lib/exception_notifier/sns_notifier.rb +3 -0
  19. data/lib/exception_notifier/teams_notifier.rb +9 -6
  20. data/lib/exception_notifier/views/exception_notifier/_data.html.erb +1 -1
  21. data/lib/exception_notifier/views/exception_notifier/_data.text.erb +1 -1
  22. data/lib/exception_notifier/views/exception_notifier/_session.html.erb +1 -1
  23. data/lib/exception_notifier/views/exception_notifier/_session.text.erb +1 -1
  24. data/lib/exception_notifier.rb +0 -1
  25. data/lib/generators/exception_notification/install_generator.rb +1 -1
  26. data/lib/generators/exception_notification/templates/exception_notification.rb.erb +3 -1
  27. data/test/exception_notification/rake_test.rb +38 -0
  28. data/test/exception_notifier/email_notifier_test.rb +8 -12
  29. data/test/exception_notifier/hipchat_notifier_test.rb +1 -7
  30. data/test/exception_notifier/sidekiq_test.rb +5 -1
  31. data/test/exception_notifier/sns_notifier_test.rb +55 -0
  32. metadata +46 -53
  33. data/examples/sample_app.rb +0 -56
  34. data/examples/sinatra/Gemfile +0 -10
  35. data/examples/sinatra/Gemfile.lock +0 -95
  36. data/examples/sinatra/Procfile +0 -2
  37. data/examples/sinatra/README.md +0 -11
  38. data/examples/sinatra/config.ru +0 -5
  39. data/examples/sinatra/sinatra_app.rb +0 -40
  40. data/gemfiles/rails4_0.gemfile +0 -7
  41. data/gemfiles/rails4_1.gemfile +0 -7
  42. data/gemfiles/rails5_1.gemfile +0 -7
  43. data/lib/exception_notifier/campfire_notifier.rb +0 -41
  44. data/test/exception_notifier/campfire_notifier_test.rb +0 -127
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae2c9d720954788440b1deedc356091324eb5c393801790d6f861c4fe157bdb4
4
- data.tar.gz: 31e91bdeeda86d168e887fa235e31b9810feb37c91317d564eee46c425376011
3
+ metadata.gz: 658719ace4734ac45fc34d877614b17324e4fca5691c5dcd62a7d6bbec8f74a8
4
+ data.tar.gz: 53504d3ff146af281d3667679cec36e8ebb4b55bfa6d916a0e83293bad13f7e9
5
5
  SHA512:
6
- metadata.gz: cbd31aedd92e7fc5064cad2efde830070aa41f2289f3e08f57c63d001046cad20187dd6948c4fd96e6489d3d513ee1d6b32069206cbc3562a82bb17f4b92e314
7
- data.tar.gz: fda70cf9f41a3a57bb83e47bfebbd1c181de0400faa72807474e76b6f2ec69f07ce37ea1ee1a5429e9dfb1b65006a6255765c0bd0677ff53cbf42cd274b5c254
6
+ metadata.gz: 3377beb7f90ebb7a083384c87c20662766a1e4c4cd900d2c6010c82708acb1b16e61922fb5b0c8cdda0fd6c00fac6b92b867672498363a3e513898cc2417ed60
7
+ data.tar.gz: 6aaab695d7f2836993685b1c98ec43aeb204996ee9ba3edb606787e5c5332f63b8a9d165ef821d0525d44ba6a82612ac55a6c9d2b5c874e8d582e9f7e6ef49bf
data/Appraisals CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
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']
3
+ rails_versions = ['~> 5.2.0', '~> 6.0.0', '~> 6.1.0', '~> 7.0.0']
4
4
 
5
5
  rails_versions.each do |rails_version|
6
6
  appraise "rails#{rails_version.slice(/\d+\.\d+/).tr('.', '_')}" do
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,16 @@
1
+ == 4.5.0
2
+
3
+ * enhancements
4
+ * Added Rails 7 compatibility (by @fwininger)
5
+ * Added support for the optional `data` attribute to the SNS notifier (@TomK32)
6
+ * Addressed a deprecation warning for `module_parent_name` which was thrown for users
7
+ using Rails > 6.x (@quorak)
8
+ * Restored the hash separator for `controller#action` in the email notifier (@garethrees)
9
+
10
+ * removals
11
+ * Dropped support for Tinder (gem is no longer maintained) (by @fwininger)
12
+ * Dropped support for Ruby on Rails versions below 5.2
13
+
1
14
  == 4.4.3
2
15
 
3
16
  * big fixes
data/Gemfile.lock ADDED
@@ -0,0 +1,352 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ exception_notification (4.6.0)
5
+ actionmailer (>= 5.2, < 9)
6
+ activesupport (>= 5.2, < 9)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (8.0.2)
12
+ actionpack (= 8.0.2)
13
+ activesupport (= 8.0.2)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (>= 0.6.1)
16
+ zeitwerk (~> 2.6)
17
+ actionmailbox (8.0.2)
18
+ actionpack (= 8.0.2)
19
+ activejob (= 8.0.2)
20
+ activerecord (= 8.0.2)
21
+ activestorage (= 8.0.2)
22
+ activesupport (= 8.0.2)
23
+ mail (>= 2.8.0)
24
+ actionmailer (8.0.2)
25
+ actionpack (= 8.0.2)
26
+ actionview (= 8.0.2)
27
+ activejob (= 8.0.2)
28
+ activesupport (= 8.0.2)
29
+ mail (>= 2.8.0)
30
+ rails-dom-testing (~> 2.2)
31
+ actionpack (8.0.2)
32
+ actionview (= 8.0.2)
33
+ activesupport (= 8.0.2)
34
+ nokogiri (>= 1.8.5)
35
+ rack (>= 2.2.4)
36
+ rack-session (>= 1.0.1)
37
+ rack-test (>= 0.6.3)
38
+ rails-dom-testing (~> 2.2)
39
+ rails-html-sanitizer (~> 1.6)
40
+ useragent (~> 0.16)
41
+ actiontext (8.0.2)
42
+ actionpack (= 8.0.2)
43
+ activerecord (= 8.0.2)
44
+ activestorage (= 8.0.2)
45
+ activesupport (= 8.0.2)
46
+ globalid (>= 0.6.0)
47
+ nokogiri (>= 1.8.5)
48
+ actionview (8.0.2)
49
+ activesupport (= 8.0.2)
50
+ builder (~> 3.1)
51
+ erubi (~> 1.11)
52
+ rails-dom-testing (~> 2.2)
53
+ rails-html-sanitizer (~> 1.6)
54
+ activejob (8.0.2)
55
+ activesupport (= 8.0.2)
56
+ globalid (>= 0.3.6)
57
+ activemodel (8.0.2)
58
+ activesupport (= 8.0.2)
59
+ activerecord (8.0.2)
60
+ activemodel (= 8.0.2)
61
+ activesupport (= 8.0.2)
62
+ timeout (>= 0.4.0)
63
+ activestorage (8.0.2)
64
+ actionpack (= 8.0.2)
65
+ activejob (= 8.0.2)
66
+ activerecord (= 8.0.2)
67
+ activesupport (= 8.0.2)
68
+ marcel (~> 1.0)
69
+ activesupport (8.0.2)
70
+ base64
71
+ benchmark (>= 0.3)
72
+ bigdecimal
73
+ concurrent-ruby (~> 1.0, >= 1.3.1)
74
+ connection_pool (>= 2.2.5)
75
+ drb
76
+ i18n (>= 1.6, < 2)
77
+ logger (>= 1.4.2)
78
+ minitest (>= 5.1)
79
+ securerandom (>= 0.3)
80
+ tzinfo (~> 2.0, >= 2.0.5)
81
+ uri (>= 0.13.1)
82
+ addressable (2.8.7)
83
+ public_suffix (>= 2.0.2, < 7.0)
84
+ appraisal (2.2.0)
85
+ bundler
86
+ rake
87
+ thor (>= 0.14.0)
88
+ ast (2.4.3)
89
+ aws-eventstream (1.3.2)
90
+ aws-partitions (1.1070.0)
91
+ aws-sdk-core (3.220.1)
92
+ aws-eventstream (~> 1, >= 1.3.0)
93
+ aws-partitions (~> 1, >= 1.992.0)
94
+ aws-sigv4 (~> 1.9)
95
+ base64
96
+ jmespath (~> 1, >= 1.6.1)
97
+ aws-sdk-sns (1.97.0)
98
+ aws-sdk-core (~> 3, >= 3.216.0)
99
+ aws-sigv4 (~> 1.5)
100
+ aws-sigv4 (1.11.0)
101
+ aws-eventstream (~> 1, >= 1.0.2)
102
+ base64 (0.2.0)
103
+ benchmark (0.4.0)
104
+ bigdecimal (3.1.9)
105
+ builder (3.3.0)
106
+ carrier-pigeon (0.7.0)
107
+ addressable
108
+ concurrent-ruby (1.3.5)
109
+ connection_pool (2.5.0)
110
+ coveralls (0.8.23)
111
+ json (>= 1.8, < 3)
112
+ simplecov (~> 0.16.1)
113
+ term-ansicolor (~> 1.3)
114
+ thor (>= 0.19.4, < 2.0)
115
+ tins (~> 1.6)
116
+ crass (1.0.6)
117
+ date (3.4.1)
118
+ docile (1.4.1)
119
+ dogapi (1.45.0)
120
+ multi_json
121
+ drb (2.2.1)
122
+ erubi (1.13.1)
123
+ globalid (1.2.1)
124
+ activesupport (>= 6.1)
125
+ hipchat (1.6.0)
126
+ httparty
127
+ mimemagic
128
+ httparty (0.10.2)
129
+ multi_json (~> 1.0)
130
+ multi_xml (>= 0.5.2)
131
+ i18n (1.14.7)
132
+ concurrent-ruby (~> 1.0)
133
+ io-console (0.8.0)
134
+ irb (1.15.1)
135
+ pp (>= 0.6.0)
136
+ rdoc (>= 4.0.0)
137
+ reline (>= 0.4.2)
138
+ jmespath (1.6.2)
139
+ json (2.10.2)
140
+ language_server-protocol (3.17.0.4)
141
+ lint_roller (1.1.0)
142
+ logger (1.6.6)
143
+ loofah (2.24.0)
144
+ crass (~> 1.0.2)
145
+ nokogiri (>= 1.12.0)
146
+ mail (2.8.1)
147
+ mini_mime (>= 0.1.1)
148
+ net-imap
149
+ net-pop
150
+ net-smtp
151
+ marcel (1.0.4)
152
+ mimemagic (0.4.3)
153
+ nokogiri (~> 1)
154
+ rake
155
+ mini_mime (1.1.5)
156
+ minitest (5.25.5)
157
+ mocha (2.7.1)
158
+ ruby2_keywords (>= 0.0.5)
159
+ mock_redis (0.19.0)
160
+ multi_json (1.15.0)
161
+ multi_xml (0.7.1)
162
+ bigdecimal (~> 3.1)
163
+ mustermann (3.0.3)
164
+ ruby2_keywords (~> 0.0.1)
165
+ net-imap (0.5.6)
166
+ date
167
+ net-protocol
168
+ net-pop (0.1.2)
169
+ net-protocol
170
+ net-protocol (0.2.2)
171
+ timeout
172
+ net-smtp (0.5.1)
173
+ net-protocol
174
+ nio4r (2.7.4)
175
+ nokogiri (1.18.5-aarch64-linux-gnu)
176
+ racc (~> 1.4)
177
+ nokogiri (1.18.5-aarch64-linux-musl)
178
+ racc (~> 1.4)
179
+ nokogiri (1.18.5-arm-linux-gnu)
180
+ racc (~> 1.4)
181
+ nokogiri (1.18.5-arm-linux-musl)
182
+ racc (~> 1.4)
183
+ nokogiri (1.18.5-arm64-darwin)
184
+ racc (~> 1.4)
185
+ nokogiri (1.18.5-x86_64-darwin)
186
+ racc (~> 1.4)
187
+ nokogiri (1.18.5-x86_64-linux-gnu)
188
+ racc (~> 1.4)
189
+ nokogiri (1.18.5-x86_64-linux-musl)
190
+ racc (~> 1.4)
191
+ parallel (1.26.3)
192
+ parser (3.3.7.2)
193
+ ast (~> 2.4.1)
194
+ racc
195
+ pp (0.6.2)
196
+ prettyprint
197
+ prettyprint (0.2.0)
198
+ psych (5.2.3)
199
+ date
200
+ stringio
201
+ public_suffix (6.0.1)
202
+ racc (1.8.1)
203
+ rack (3.1.12)
204
+ rack-protection (4.1.1)
205
+ base64 (>= 0.1.0)
206
+ logger (>= 1.6.0)
207
+ rack (>= 3.0.0, < 4)
208
+ rack-session (2.1.0)
209
+ base64 (>= 0.1.0)
210
+ rack (>= 3.0.0)
211
+ rack-test (2.2.0)
212
+ rack (>= 1.3)
213
+ rackup (2.2.1)
214
+ rack (>= 3)
215
+ rails (8.0.2)
216
+ actioncable (= 8.0.2)
217
+ actionmailbox (= 8.0.2)
218
+ actionmailer (= 8.0.2)
219
+ actionpack (= 8.0.2)
220
+ actiontext (= 8.0.2)
221
+ actionview (= 8.0.2)
222
+ activejob (= 8.0.2)
223
+ activemodel (= 8.0.2)
224
+ activerecord (= 8.0.2)
225
+ activestorage (= 8.0.2)
226
+ activesupport (= 8.0.2)
227
+ bundler (>= 1.15.0)
228
+ railties (= 8.0.2)
229
+ rails-dom-testing (2.2.0)
230
+ activesupport (>= 5.0.0)
231
+ minitest
232
+ nokogiri (>= 1.6)
233
+ rails-html-sanitizer (1.6.2)
234
+ loofah (~> 2.21)
235
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
236
+ railties (8.0.2)
237
+ actionpack (= 8.0.2)
238
+ activesupport (= 8.0.2)
239
+ irb (~> 1.13)
240
+ rackup (>= 1.0.0)
241
+ rake (>= 12.2)
242
+ thor (~> 1.0, >= 1.2.2)
243
+ zeitwerk (~> 2.6)
244
+ rainbow (3.1.1)
245
+ rake (13.2.1)
246
+ rdoc (6.12.0)
247
+ psych (>= 4.0.0)
248
+ redis (1.0.7)
249
+ redis-client (0.24.0)
250
+ connection_pool
251
+ redis-namespace (0.4.4)
252
+ redis (~> 1.0.0)
253
+ regexp_parser (2.10.0)
254
+ reline (0.6.0)
255
+ io-console (~> 0.5)
256
+ resque (1.8.5)
257
+ redis (~> 1.0.0)
258
+ redis-namespace (~> 0.4.0)
259
+ sinatra (>= 0.9.2)
260
+ vegas (~> 0.1.2)
261
+ rubocop (1.74.0)
262
+ json (~> 2.3)
263
+ language_server-protocol (~> 3.17.0.2)
264
+ lint_roller (~> 1.1.0)
265
+ parallel (~> 1.10)
266
+ parser (>= 3.3.0.2)
267
+ rainbow (>= 2.2.2, < 4.0)
268
+ regexp_parser (>= 2.9.3, < 3.0)
269
+ rubocop-ast (>= 1.38.0, < 2.0)
270
+ ruby-progressbar (~> 1.7)
271
+ unicode-display_width (>= 2.4.0, < 4.0)
272
+ rubocop-ast (1.41.0)
273
+ parser (>= 3.3.7.2)
274
+ ruby-progressbar (1.13.0)
275
+ ruby2_keywords (0.0.5)
276
+ securerandom (0.4.1)
277
+ sidekiq (8.0.1)
278
+ connection_pool (>= 2.5.0)
279
+ json (>= 2.9.0)
280
+ logger (>= 1.6.2)
281
+ rack (>= 3.1.0)
282
+ redis-client (>= 0.23.2)
283
+ simplecov (0.16.1)
284
+ docile (~> 1.1)
285
+ json (>= 1.8, < 3)
286
+ simplecov-html (~> 0.10.0)
287
+ simplecov-html (0.10.2)
288
+ sinatra (4.1.1)
289
+ logger (>= 1.6.0)
290
+ mustermann (~> 3.0)
291
+ rack (>= 3.0.0, < 4)
292
+ rack-protection (= 4.1.1)
293
+ rack-session (>= 2.0.0, < 3)
294
+ tilt (~> 2.0)
295
+ slack-notifier (2.4.0)
296
+ stringio (3.1.5)
297
+ sync (0.5.0)
298
+ term-ansicolor (1.11.2)
299
+ tins (~> 1.0)
300
+ thor (1.3.2)
301
+ tilt (2.6.0)
302
+ timecop (0.9.10)
303
+ timeout (0.4.3)
304
+ tins (1.38.0)
305
+ bigdecimal
306
+ sync
307
+ tzinfo (2.0.6)
308
+ concurrent-ruby (~> 1.0)
309
+ unicode-display_width (3.1.4)
310
+ unicode-emoji (~> 4.0, >= 4.0.4)
311
+ unicode-emoji (4.0.4)
312
+ uri (1.0.3)
313
+ useragent (0.16.11)
314
+ vegas (0.1.11)
315
+ rack (>= 1.0.0)
316
+ websocket-driver (0.7.7)
317
+ base64
318
+ websocket-extensions (>= 0.1.0)
319
+ websocket-extensions (0.1.5)
320
+ zeitwerk (2.7.2)
321
+
322
+ PLATFORMS
323
+ aarch64-linux-gnu
324
+ aarch64-linux-musl
325
+ arm-linux-gnu
326
+ arm-linux-musl
327
+ arm64-darwin
328
+ x86_64-darwin
329
+ x86_64-linux-gnu
330
+ x86_64-linux-musl
331
+
332
+ DEPENDENCIES
333
+ appraisal (~> 2.2.0)
334
+ aws-sdk-sns (~> 1)
335
+ carrier-pigeon (>= 0.7.0)
336
+ coveralls (~> 0.8.2)
337
+ dogapi (>= 1.23.0)
338
+ exception_notification!
339
+ hipchat (>= 1.0.0)
340
+ httparty (~> 0.10.2)
341
+ mocha (>= 0.13.0)
342
+ mock_redis (~> 0.19.0)
343
+ net-smtp
344
+ rails (>= 5.2, < 9)
345
+ resque (~> 1.8.0)
346
+ rubocop
347
+ sidekiq (>= 5.0.4)
348
+ slack-notifier (>= 1.0.0)
349
+ timecop (~> 0.9.0)
350
+
351
+ BUNDLED WITH
352
+ 2.6.3
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Exception Notification
2
2
 
3
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)
4
+ [![Build Status](https://github.com/smartinez87/exception_notification/actions/workflows/main.yml/badge.svg)](https://github.com/smartinez87/exception_notification/actions/workflows/main.yml)
5
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
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/78a9a12be00a6d305136/maintainability)](https://codeclimate.com/github/smartinez87/exception_notification/maintainability)
7
7
 
@@ -9,7 +9,7 @@
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](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).
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), [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,8 +17,8 @@ There's a great [Railscast about Exception Notification](http://railscasts.com/e
17
17
 
18
18
  ## Requirements
19
19
 
20
- * Ruby 2.3 or greater
21
- * Rails 4.0 or greater, Sinatra or another Rack-based application.
20
+ * Ruby 2.5 or greater
21
+ * Rails 5.2 or greater, Sinatra or another Rack-based application.
22
22
 
23
23
  ## Getting Started
24
24
 
@@ -30,19 +30,56 @@ gem 'exception_notification'
30
30
 
31
31
  ### Rails
32
32
 
33
- ExceptionNotification is used as a rack middleware, or in the environment you want it to run. In most cases you would want ExceptionNotification to run on production. Thus, you can make it work by putting the following lines in your `config/environments/production.rb`:
33
+ In order to install ExceptionNotification as an [engine](https://api.rubyonrails.org/classes/Rails/Engine.html), just run the following command from the terminal:
34
+
35
+ rails g exception_notification:install
36
+
37
+ This generates an initializer file, `config/initializers/exception_notification.rb` with some default configuration, which you should modify as needed.
38
+
39
+ Make sure the gem is not listed solely under the `production` group in your `Gemfile`, since this initializer will be loaded regardless of environment. If you want it to only be enabled in production, you can add this to your configuration:
40
+
41
+ ```ruby
42
+ config.ignore_if do |exception, options|
43
+ not Rails.env.production?
44
+ end
45
+ ```
46
+
47
+ The generated initializer file will include this require:
48
+ ```ruby
49
+ require 'exception_notification/rails'
50
+ ```
51
+
52
+ which automatically adds the ExceptionNotification middleware to the Rails middleware stack. This middleware is what watches for unhandled exceptions from your Rails app (except for [background jobs](#background-jobs)) and notifies you when they occur.
53
+
54
+ The generated file adds an `email` notifier:
55
+
56
+ ```ruby
57
+ config.add_notifier :email, {
58
+ email_prefix: '[ERROR] ',
59
+ sender_address: %{"Notifier" <notifier@example.com>},
60
+ exception_recipients: %w{exceptions@example.com}
61
+ }
62
+ ```
63
+
64
+ **Note**: In order to enable delivery notifications by email, make sure you have [ActionMailer configured](docs/notifiers/email.md#actionmailer-configuration).
65
+
66
+ #### Adding middleware manually
67
+
68
+ Alternatively, if for some reason you don't want to `require 'exception_notification/rails'`, you can manually add the middleware, like this:
34
69
 
35
70
  ```ruby
36
71
  Rails.application.config.middleware.use ExceptionNotification::Rack,
37
72
  email: {
38
- deliver_with: :deliver, # Rails >= 4.2.1 do not need this option since it defaults to :deliver_now
39
73
  email_prefix: '[PREFIX] ',
40
74
  sender_address: %{"notifier" <notifier@example.com>},
41
75
  exception_recipients: %w{exceptions@example.com}
42
76
  }
43
77
  ```
44
78
 
45
- **Note**: In order to enable delivery notifications by email make sure you have [ActionMailer configured](docs/notifiers/email.md#actionmailer-configuration).
79
+ This is the older way of configuring ExceptionNotification (which prior to version 4 was the _only_ way to configure it), and is still the way used in some of the examples.
80
+
81
+ Options passed to the `ExceptionNotification::Rack` middleware in this way are translated to the equivalent configuration options for the `ExceptionNotification.configure` of configuring (compare to the [Rails](#rails) example above).
82
+
46
83
 
47
84
  ### Rack/Sinatra
48
85
 
@@ -84,7 +121,6 @@ Options -> sections" below.
84
121
 
85
122
  ExceptionNotification relies on notifiers to deliver notifications when errors occur in your applications. By default, 8 notifiers are available:
86
123
 
87
- * [Campfire notifier](docs/notifiers/campfire.md)
88
124
  * [Datadog notifier](docs/notifiers/datadog.md)
89
125
  * [Email notifier](docs/notifiers/email.md)
90
126
  * [HipChat notifier](docs/notifiers/hipchat.md)
@@ -102,7 +138,7 @@ But, you also can easily implement your own [custom notifier](docs/notifiers/cus
102
138
 
103
139
  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`.
104
140
 
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.
141
+ Error grouping uses a default formula of `Math.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.
106
142
 
107
143
  The following code shows the available options to configure error grouping:
108
144
 
@@ -203,7 +239,7 @@ Rails.application.config.middleware.use ExceptionNotification::Rack,
203
239
  ignore_notifier_if: {
204
240
  email: ->(env, exception) { !Rails.env.production? },
205
241
  slack: ->(env, exception) { exception.message =~ /^Couldn't find Page with ID=/ }
206
- }
242
+ },
207
243
 
208
244
  email: {
209
245
  sender_address: %{"notifier" <notifier@example.com>},
@@ -229,23 +265,51 @@ Rails' routing middleware uses this strategy, rather than raising an exception,
229
265
 
230
266
  Set to false to trigger notifications when another rack middleware sets the "X-Cascade" header to "pass."
231
267
 
232
- ## Background Notifications
268
+ ## Background Jobs
269
+
270
+ The ExceptionNotification middleware can only detect notifications that occur during web requests (controller actions). If you have any Ruby code that gets run _outside_ of a normal web request (hereafter referred to as a "background job" or "background process"), exceptions must be detected a different way (the middleware won't even be running in this context).
271
+
272
+ Examples of background jobs include jobs triggered from a cron file or from a queue.
233
273
 
234
- If you want to send notifications from a background process like DelayedJob, you should use the `notify_exception` method like this:
274
+ ExceptionNotificatior can be configured to automatically notify of exceptions occurring in most common types of Rails background jobs such as [rake tasks](#rake-tasks). Additionally, it provides optional integrations for some 3rd-party libraries such as [Resque and Sidekiq](#resquesidekiq). And of course you can manually trigger a notification if no integration is provided.
275
+
276
+ ### Rails runner
277
+
278
+ To enable exception notification for your runner commands, add this line to your `config/application.rb` _below_ the `Bundler.require` line (ensuring that `exception_notification` and `rails` gems will have already been required):
279
+
280
+ ```ruby
281
+ require 'exception_notification/rails'
282
+ ```
283
+
284
+ (Requiring it from an initializer is too late, because this depends on the `runner` callback, and that will have already been fired _before_ any initializers run.)
285
+
286
+ ### Rake tasks
287
+
288
+ If you've already added `require 'exception_notification/rails'` to your `config/application.rb` as described [above](#rails-runner), then there's nothing further you need to do. (That Engine has a `rake_tasks` callback which automatically requires the file below.)
289
+
290
+ Alternatively, you can add this line to your `config/initializers/exception_notification.rb`:
291
+
292
+ ```ruby
293
+ require 'exception_notification/rake'
294
+ ```
295
+
296
+ ### Manually notify of exceptions
297
+
298
+ If you want to manually send a notifications from a background process that is not _automatically_ handled by ExceptionNotification, then you need to manually call the `notify_exception` method like this:
235
299
 
236
300
  ```ruby
237
301
  begin
238
- some code...
302
+ # some code...
239
303
  rescue => e
240
304
  ExceptionNotifier.notify_exception(e)
241
305
  end
242
306
  ```
243
307
 
244
- You can include information about the background process that created the error by including a data parameter:
308
+ You can include information about the background process that created the error by including a `data` parameter:
245
309
 
246
310
  ```ruby
247
311
  begin
248
- some code...
312
+ # some code...
249
313
  rescue => e
250
314
  ExceptionNotifier.notify_exception(
251
315
  e,
@@ -254,39 +318,9 @@ rescue => e
254
318
  end
255
319
  ```
256
320
 
257
- ### Manually notify of exception
258
-
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:
260
-
261
- ```ruby
262
- rescue_from Exception, with: :server_error
263
-
264
- def server_error(exception)
265
- # Whatever code that handles the exception
266
-
267
- ExceptionNotifier.notify_exception(
268
- exception,
269
- env: request.env, data: { message: 'was doing something wrong' }
270
- )
271
- end
272
- ```
273
-
274
-
275
- ## Extras
276
-
277
- ### Rails
278
-
279
- Since his first version, ExceptionNotification was just a simple rack middleware. But, the version 4.0.0 introduced the option to use it as a Rails engine. In order to use ExceptionNotification as an engine, just run the following command from the terminal:
280
-
281
- rails g exception_notification:install
282
-
283
- This command generates an initialize file (`config/initializers/exception_notification.rb`) where you can customize your configurations.
284
-
285
- Make sure the gem is not listed solely under the `production` group, since this initializer will be loaded regardless of environment.
286
-
287
321
  ### Resque/Sidekiq
288
322
 
289
- Instead of manually calling background notifications foreach job/worker, you can configure ExceptionNotification to do this automatically. For this, run:
323
+ Instead of manually calling background notifications for each job/worker, you can configure ExceptionNotification to do this automatically. For this, run:
290
324
 
291
325
  rails g exception_notification:install --resque
292
326
 
@@ -296,6 +330,25 @@ or
296
330
 
297
331
  As above, make sure the gem is not listed solely under the `production` group, since this initializer will be loaded regardless of environment.
298
332
 
333
+ ## Manually notify of exceptions from `rescue_from` handler
334
+
335
+ If your controller rescues and handles an error, the middleware won't be able to see that there was an exception, and the notifier will never be run. To manually notify of an error after rescuing it, you can do something like the following:
336
+
337
+ ```ruby
338
+ class SomeController < ApplicationController
339
+ rescue_from Exception, with: :server_error
340
+
341
+ def server_error(exception)
342
+ # Whatever code that handles the exception
343
+
344
+ ExceptionNotifier.notify_exception(
345
+ exception,
346
+ env: request.env, data: { message: 'was doing something wrong' }
347
+ )
348
+ end
349
+ end
350
+ ```
351
+
299
352
  ## Support and tickets
300
353
 
301
354
  Here's the list of [issues](https://github.com/smartinez87/exception_notification/issues) we're currently working on.
@@ -21,7 +21,6 @@ Rails.application.config.middleware.use ExceptionNotification::Rack,
21
21
  },
22
22
  slack: {
23
23
  webhook_url: '[Your webhook url]',
24
- channel: '#exceptions',
25
24
  additional_parameters: {
26
25
  icon_url: 'http://image.jpg',
27
26
  mrkdwn: true
@@ -129,12 +128,6 @@ ExceptionNotifier.notify_exception(
129
128
 
130
129
  The Incoming WebHook URL on slack.
131
130
 
132
- ##### channel
133
-
134
- *String, optional*
135
-
136
- Message will appear in this channel. Defaults to the channel you set as such on slack.
137
-
138
131
  ##### username
139
132
 
140
133
  *String, optional*