exceptify 1.0.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 (60) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.rdoc +16 -0
  3. data/CODE_OF_CONDUCT.md +22 -0
  4. data/CONTRIBUTING.md +33 -0
  5. data/MIT-LICENSE +23 -0
  6. data/README.md +534 -0
  7. data/RELEASING.md +51 -0
  8. data/Rakefile +25 -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/slack.md +154 -0
  13. data/docs/notifiers/sns.md +37 -0
  14. data/docs/notifiers/teams.md +54 -0
  15. data/docs/notifiers/webhook.md +60 -0
  16. data/exceptify.gemspec +48 -0
  17. data/lib/exceptify/base_notifier.rb +30 -0
  18. data/lib/exceptify/configuration.rb +184 -0
  19. data/lib/exceptify/datadog_notifier.rb +160 -0
  20. data/lib/exceptify/dispatcher.rb +49 -0
  21. data/lib/exceptify/email_notifier.rb +208 -0
  22. data/lib/exceptify/modules/backtrace_cleaner.rb +13 -0
  23. data/lib/exceptify/modules/error_grouping.rb +170 -0
  24. data/lib/exceptify/modules/formatter.rb +119 -0
  25. data/lib/exceptify/notification.rb +71 -0
  26. data/lib/exceptify/notifier.rb +19 -0
  27. data/lib/exceptify/notifier_registry.rb +55 -0
  28. data/lib/exceptify/rack.rb +88 -0
  29. data/lib/exceptify/rails/runner_tie.rb +57 -0
  30. data/lib/exceptify/rails.rb +29 -0
  31. data/lib/exceptify/rake.rb +59 -0
  32. data/lib/exceptify/request_context.rb +35 -0
  33. data/lib/exceptify/resque.rb +25 -0
  34. data/lib/exceptify/sidekiq.rb +15 -0
  35. data/lib/exceptify/slack_notifier.rb +141 -0
  36. data/lib/exceptify/sns_notifier.rb +98 -0
  37. data/lib/exceptify/solid_queue.rb +68 -0
  38. data/lib/exceptify/teams_notifier.rb +209 -0
  39. data/lib/exceptify/version.rb +5 -0
  40. data/lib/exceptify/views/exceptify/_backtrace.html.erb +3 -0
  41. data/lib/exceptify/views/exceptify/_backtrace.text.erb +1 -0
  42. data/lib/exceptify/views/exceptify/_data.html.erb +6 -0
  43. data/lib/exceptify/views/exceptify/_data.text.erb +1 -0
  44. data/lib/exceptify/views/exceptify/_environment.html.erb +10 -0
  45. data/lib/exceptify/views/exceptify/_environment.text.erb +5 -0
  46. data/lib/exceptify/views/exceptify/_request.html.erb +36 -0
  47. data/lib/exceptify/views/exceptify/_request.text.erb +10 -0
  48. data/lib/exceptify/views/exceptify/_session.html.erb +10 -0
  49. data/lib/exceptify/views/exceptify/_session.text.erb +2 -0
  50. data/lib/exceptify/views/exceptify/_title.html.erb +3 -0
  51. data/lib/exceptify/views/exceptify/_title.text.erb +3 -0
  52. data/lib/exceptify/views/exceptify/background_exceptify.html.erb +53 -0
  53. data/lib/exceptify/views/exceptify/background_exceptify.text.erb +14 -0
  54. data/lib/exceptify/views/exceptify/exceptify.html.erb +52 -0
  55. data/lib/exceptify/views/exceptify/exceptify.text.erb +24 -0
  56. data/lib/exceptify/webhook_notifier.rb +63 -0
  57. data/lib/exceptify.rb +177 -0
  58. data/lib/generators/exceptify/install_generator.rb +24 -0
  59. data/lib/generators/exceptify/templates/exceptify.rb.erb +44 -0
  60. metadata +364 -0
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems"
4
+ require "bundler/setup"
5
+ require "irb"
6
+ require "exceptify"
7
+ Bundler::GemHelper.install_tasks
8
+
9
+ require "rake/testtask"
10
+
11
+ task default: [:test]
12
+
13
+ Rake::TestTask.new(:test) do |t|
14
+ t.libs << "lib"
15
+ t.libs << "test"
16
+ t.pattern = "test/**/*_test.rb"
17
+ t.warning = false
18
+ end
19
+
20
+ desc "Start a console with the gem"
21
+ task :console do
22
+ ARGV.clear
23
+ puts "Exceptify #{Exceptify::VERSION} loaded."
24
+ IRB.start
25
+ end
@@ -0,0 +1,42 @@
1
+ ### Custom notifier
2
+
3
+ Simply put, notifiers are objects which respond to `#call(exception, options)` method. Thus, a lambda can be used as a notifier as follow:
4
+
5
+ ```ruby
6
+ Exceptify.add_notifier :custom_notifier_name,
7
+ ->(exception, options) { puts "Something goes wrong: #{exception.message}"}
8
+ ```
9
+
10
+ More advanced users or third-party framework developers, also can create notifiers to be shipped in gems and take advantage of Exceptify'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 Exceptify namespace and its name sufixed by `Notifier`, e.g: Exceptify::SimpleNotifier.
11
+
12
+ #### Example
13
+
14
+ Define the custom notifier:
15
+
16
+ ```ruby
17
+ module Exceptify
18
+ class SimpleNotifier
19
+ def initialize(options)
20
+ # do something with the options...
21
+ end
22
+
23
+ def call(exception, options={})
24
+ # send the notification
25
+ end
26
+ end
27
+ end
28
+ ```
29
+
30
+ Using it:
31
+
32
+ ```ruby
33
+ Rails.application.config.middleware.use Exceptify::Rack,
34
+ email: {
35
+ email_prefix: '[PREFIX] ',
36
+ sender_address: %{"notifier" <notifier@example.com>},
37
+ exception_recipients: %w{exceptions@example.com}
38
+ },
39
+ simple: {
40
+ # simple notifier options
41
+ }
42
+ ```
@@ -0,0 +1,51 @@
1
+ ### Datadog notifier
2
+
3
+ This notifier sends error events to Datadog using the [Dogapi](https://github.com/DataDog/dogapi-rb) gem.
4
+
5
+ #### Usage
6
+
7
+ Just add the [Dogapi](https://github.com/DataDog/dogapi-rb) gem to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'dogapi'
11
+ ```
12
+
13
+ To use datadog notifier, you first need to create a `Dogapi::Client` with your datadog api and application keys, like this:
14
+
15
+ ```ruby
16
+ client = Dogapi::Client.new(api_key, application_key)
17
+ ```
18
+
19
+ You then need to set the `client` option, like this:
20
+
21
+ ```ruby
22
+ Rails.application.config.middleware.use Exceptify::Rack,
23
+ email: {
24
+ email_prefix: "[PREFIX] ",
25
+ sender_address: %{"notifier" <notifier@example.com>},
26
+ exception_recipients: %w{exceptions@example.com}
27
+ },
28
+ datadog: {
29
+ client: client
30
+ }
31
+ ```
32
+
33
+ #### Options
34
+
35
+ ##### client
36
+
37
+ *DogApi::Client, required*
38
+
39
+ The API client to send events to Datadog.
40
+
41
+ ##### title_prefix
42
+
43
+ *String, optional*
44
+
45
+ Prefix for event title in Datadog.
46
+
47
+ ##### tags
48
+
49
+ *Array of Strings, optional*
50
+
51
+ Optional tags for events in Datadog.
@@ -0,0 +1,195 @@
1
+ ### Email notifier
2
+
3
+ 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.
4
+
5
+ After an exception notification has been delivered the rack environment variable `exceptify.delivered` will be set to true.
6
+
7
+ #### ActionMailer configuration
8
+
9
+ 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 Exceptify to run in, put the following code in your `config/environments/production.rb` and/or `config/environments/development.rb`:
10
+
11
+ ```ruby
12
+ config.action_mailer.delivery_method = :sendmail
13
+ # Defaults to:
14
+ # config.action_mailer.sendmail_settings = {
15
+ # location: '/usr/sbin/sendmail',
16
+ # arguments: '-i -t'
17
+ # }
18
+ config.action_mailer.perform_deliveries = true
19
+ config.action_mailer.raise_delivery_errors = true
20
+ ```
21
+
22
+ #### Options
23
+
24
+ ##### sender_address
25
+
26
+ *String, default: %("Exceptify" <notifier@example.com>)*
27
+
28
+ Who the message is from.
29
+
30
+ ##### exception_recipients
31
+
32
+ *String/Array of strings/Proc, default: []*
33
+
34
+ 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.
35
+
36
+ ##### email_prefix
37
+
38
+ *String, default: [ERROR]*
39
+
40
+ The subject's prefix of the message.
41
+
42
+ ##### sections
43
+
44
+ *Array of strings, default: %w(request session environment backtrace)*
45
+
46
+ 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/exceptify` directory (e.g., `_session.rhtml`). Each partial has access to the following variables:
47
+
48
+ ```ruby
49
+ @kontroller # the controller that caused the error
50
+ @request # the current request object
51
+ @exception # the exception that was raised
52
+ @backtrace # a sanitized version of the exception's backtrace
53
+ @data # a hash of optional data values that were passed to the notifier
54
+ @sections # the array of sections to include in the email
55
+ ```
56
+
57
+ You can reorder the sections, or exclude sections completely, by using `sections` option. You can even add new sections that
58
+ 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:
59
+
60
+ ```ruby
61
+ Rails.application.config.middleware.use Exceptify::Rack,
62
+ email: {
63
+ email_prefix: '[PREFIX] ',
64
+ sender_address: %{"notifier" <notifier@example.com>},
65
+ exception_recipients: %w{exceptions@example.com},
66
+ sections: %w{my_section1 my_section2}
67
+ }
68
+ ```
69
+
70
+ Place your custom sections under `./app/views/exceptify/` with the suffix `.text.erb`, e.g. `./app/views/exceptify/_my_section1.text.erb`.
71
+
72
+ 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:
73
+
74
+ ```ruby
75
+ class ApplicationController < ActionController::Base
76
+ before_action :log_additional_data
77
+ ...
78
+ protected
79
+
80
+ def log_additional_data
81
+ request.env['exceptify.exception_data'] = {
82
+ document: @document,
83
+ person: @person
84
+ }
85
+ end
86
+ ...
87
+ end
88
+ ```
89
+
90
+ 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.
91
+
92
+ ##### background_sections
93
+
94
+ *Array of strings, default: %w(backtrace data)*
95
+
96
+ 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:
97
+
98
+ ```ruby
99
+ Rails.application.config.middleware.use Exceptify::Rack,
100
+ email: {
101
+ email_prefix: '[PREFIX] ',
102
+ sender_address: %{"notifier" <notifier@example.com>},
103
+ exception_recipients: %w{exceptions@example.com},
104
+ background_sections: %w{my_section1 my_section2 backtrace data}
105
+ }
106
+ ```
107
+
108
+ ##### email_headers
109
+
110
+ *Hash of strings, default: {}*
111
+
112
+ Additionally, you may want to set customized headers on the outcoming emails. To do so, simply use the `:email_headers` option:
113
+
114
+ ```ruby
115
+ Rails.application.config.middleware.use Exceptify::Rack,
116
+ email: {
117
+ email_prefix: "[PREFIX] ",
118
+ sender_address: %{"notifier" <notifier@example.com>},
119
+ exception_recipients: %w{exceptions@example.com},
120
+ email_headers: { "X-Custom-Header" => "foobar" }
121
+ }
122
+ ```
123
+
124
+ ##### verbose_subject
125
+
126
+ *Boolean, default: true*
127
+
128
+ If enabled, include the exception message in the subject. Use `verbose_subject: false` to exclude it.
129
+
130
+ ##### normalize_subject
131
+
132
+ *Boolean, default: false*
133
+
134
+ If enabled, remove numbers from subject so they thread as a single one. Use `normalize_subject: true` to enable it.
135
+
136
+ ##### include_controller_and_action_names_in_subject
137
+
138
+ *Boolean, default: true*
139
+
140
+ If enabled, include the controller and action names in the subject. Use `include_controller_and_action_names_in_subject: false` to exclude them.
141
+
142
+ ##### email_format
143
+
144
+ *Symbol, default: :text*
145
+
146
+ By default, Exceptify sends emails in plain text. To send multipart notifications (aka HTML emails), use `email_format: :html`.
147
+
148
+ ##### delivery_method
149
+
150
+ *Symbol, default: :smtp*
151
+
152
+ By default, Exceptify sends emails using the ActionMailer configuration of the application. In order to send emails by another delivery method, use the `delivery_method` option:
153
+
154
+ ```ruby
155
+ Rails.application.config.middleware.use Exceptify::Rack,
156
+ email: {
157
+ email_prefix: '[PREFIX] ',
158
+ sender_address: %{"notifier" <notifier@example.com>},
159
+ exception_recipients: %w{exceptions@example.com},
160
+ delivery_method: :postmark,
161
+ postmark_settings: {
162
+ api_key: ENV['POSTMARK_API_KEY']
163
+ }
164
+ }
165
+ ```
166
+
167
+ 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:
168
+
169
+ ```ruby
170
+ Rails.application.config.middleware.use Exceptify::Rack,
171
+ email: {
172
+ email_prefix: '[PREFIX] ',
173
+ sender_address: %{"notifier" <notifier@example.com>},
174
+ exception_recipients: %w{exceptions@example.com},
175
+ delivery_method: :smtp,
176
+ smtp_settings: {
177
+ user_name: 'bob',
178
+ password: 'password',
179
+ }
180
+ }
181
+ ```
182
+
183
+ 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).
184
+
185
+ ##### mailer_parent
186
+
187
+ *String, default: ActionMailer::Base*
188
+
189
+ The parent mailer which the Exceptify mailer inherits from.
190
+
191
+ ##### deliver_with
192
+
193
+ *Symbol, default: :deliver_now
194
+
195
+ The method name to send emalis using ActionMailer.
@@ -0,0 +1,154 @@
1
+ ### Slack notifier
2
+
3
+ This notifier sends notifications to a slack channel using the slack-notifier gem.
4
+
5
+ #### Usage
6
+
7
+ Just add the [slack-notifier](https://github.com/stevenosloan/slack-notifier) gem to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'slack-notifier'
11
+ ```
12
+
13
+ To configure it, you need to set at least the 'webhook_url' option, like this:
14
+
15
+ ```ruby
16
+ Rails.application.config.middleware.use Exceptify::Rack,
17
+ email: {
18
+ email_prefix: '[PREFIX] ',
19
+ sender_address: %{"notifier" <notifier@example.com>},
20
+ exception_recipients: %w{exceptions@example.com}
21
+ },
22
+ slack: {
23
+ webhook_url: '[Your webhook url]',
24
+ additional_parameters: {
25
+ icon_url: 'http://image.jpg',
26
+ mrkdwn: true
27
+ }
28
+ }
29
+ ```
30
+
31
+ The slack notification will include any data saved under `env['exceptify.exception_data']`.
32
+
33
+ An example of how to send the server name to Slack in Rails (put this code in application_controller.rb):
34
+
35
+ ```ruby
36
+ before_action :set_notification
37
+
38
+ def set_notification
39
+ request.env['exceptify.exception_data'] = { 'server' => request.env['SERVER_NAME'] }
40
+ # can be any key-value pairs
41
+ end
42
+ ```
43
+
44
+ If you find this too verbose, you can determine to exclude certain information by doing the following:
45
+
46
+ ```ruby
47
+ Rails.application.config.middleware.use Exceptify::Rack,
48
+ slack: {
49
+ webhook_url: '[Your webhook url]',
50
+ channel: '#exceptions',
51
+ additional_parameters: {
52
+ icon_url: 'http://image.jpg',
53
+ mrkdwn: true
54
+ },
55
+ ignore_data_if: lambda {|key, value|
56
+ "#{key}" == 'key_to_ignore' || value.is_a?(ClassToBeIgnored)
57
+ }
58
+ }
59
+ ```
60
+
61
+ Any evaluation to `true` will cause the key / value pair not be be sent along to Slack.
62
+
63
+
64
+ the `slack-notifier` gem allows to override the channel default value, if you ever
65
+ need to send a notification to a different slack channel. Simply add the
66
+ `channel` option when calling `.notify_exception`
67
+
68
+ ```ruby
69
+ Exceptify.notify_exception(
70
+ exception,
71
+ env: request.env,
72
+ channel: '#my-custom-channel', # Make sure the channel name starts with `#`
73
+ data: {
74
+ error: error_variable,
75
+ server: server_name
76
+ }
77
+ )
78
+ ```
79
+
80
+ If you ever need to add more `slack-notifier` specific options, and
81
+ particularly to the `#ping` method of the slack notifier, you can use
82
+ the `pre_callback` option when defining the middleware.
83
+ ```ruby
84
+ pre_callback: proc { |opts, _notifier, _backtrace, _message, message_opts|
85
+ message_opts[:channel] = opts[:channel] if opts.key?(:channel)
86
+ }
87
+
88
+ ```
89
+ - `message_opts` is the hash you want to append to if you need to add an option.
90
+ - `options` is the hash containing the values when you call
91
+ `Exceptify.notify_exception`
92
+
93
+ An example implementation would be:
94
+ ```ruby
95
+ config.middleware.use Exceptify::Rack,
96
+ slack: {
97
+ webhook_url: '[Your webhook url]',
98
+ pre_callback: proc { |opts, _notifier, _backtrace, _message, message_opts|
99
+ message_opts[:ping_option] = opts[:ping_option] if
100
+ opts.key?(:ping_option)
101
+ }
102
+ },
103
+ error_grouping: true
104
+ ```
105
+ Then when calling from within your application code:
106
+ ```ruby
107
+ Exceptify.notify_exception(
108
+ exception,
109
+ env: request.env,
110
+ ping_option: 'value',
111
+ # this will be passed to the slack notifier's `#ping`
112
+ # method, as a parameter. The `:pre_callback` hook will catch it
113
+ # and do that for you.
114
+ # Helpful, if the API evolves, you only need to update
115
+ # the `slack-notifier` gem
116
+ data: {
117
+ error: error_variable,
118
+ server: server_name
119
+ }
120
+ )
121
+
122
+ ```
123
+ #### Options
124
+
125
+ ##### webhook_url
126
+
127
+ *String, required*
128
+
129
+ The Incoming WebHook URL on slack.
130
+
131
+ ##### username
132
+
133
+ *String, optional*
134
+
135
+ Username of the bot. Defaults to the name you set as such on slack
136
+
137
+ ##### custom_hook
138
+
139
+ *String, optional*
140
+
141
+ Custom hook name. See [slack-notifier](https://github.com/stevenosloan/slack-notifier#custom-hook-name) for
142
+ more information. Default: 'incoming-webhook'
143
+
144
+ ##### additional_parameters
145
+
146
+ *Hash of strings, optional*
147
+
148
+ 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: '{}'
149
+
150
+ ##### additional_fields
151
+
152
+ *Array of Hashes, optional*
153
+
154
+ Contains additional fields that will be added to the attachement. See [Slack documentation](https://api.slack.com/docs/message-attachments).
@@ -0,0 +1,37 @@
1
+ ### Amazon SNS Notifier
2
+
3
+ Notify all exceptions Amazon - Simple Notification Service: [SNS](https://aws.amazon.com/sns/).
4
+
5
+ #### Usage
6
+
7
+ Add the [aws-sdk-sns](https://github.com/aws/aws-sdk-ruby/tree/master/gems/aws-sdk-sns) gem to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'aws-sdk-sns', '~> 1.5'
11
+ ```
12
+
13
+ To configure it, you **need** to set 3 required options for aws: `region`, `access_key_id` and `secret_access_key`, and one more option for sns: `topic_arn`.
14
+
15
+ ```ruby
16
+ Rails.application.config.middleware.use Exceptify::Rack,
17
+ sns: {
18
+ region: 'us-east-x',
19
+ access_key_id: 'access_key_id',
20
+ secret_access_key: 'secret_access_key',
21
+ topic_arn: 'arn:aws:sns:us-east-x:XXXX:my-topic'
22
+ }
23
+ ```
24
+
25
+ ##### sns_prefix
26
+ *String, optional *
27
+
28
+ Prefix in the notification subject, by default: "[Error]"
29
+
30
+ ##### backtrace_lines
31
+ *Integer, optional *
32
+
33
+ Number of backtrace lines to be displayed in the notification message. By default: 10
34
+
35
+ #### Note:
36
+ * You may need to update your previous `aws-sdk-*` gems in order to setup `aws-sdk-sns` correctly.
37
+ * If you need any further information about the available regions or any other SNS related topic consider: [SNS faqs](https://aws.amazon.com/sns/faqs/)
@@ -0,0 +1,54 @@
1
+ ### Teams notifier
2
+
3
+ Post notification in a Microsoft Teams channel via [Incoming Webhook Connector](https://docs.microsoft.com/en-us/outlook/actionable-messages/actionable-messages-via-connectors)
4
+ Just add the [HTTParty](https://github.com/jnunemaker/httparty) gem to your `Gemfile`:
5
+
6
+ ```ruby
7
+ gem 'httparty'
8
+ ```
9
+
10
+ To configure it, you **need** to set the `webhook_url` option.
11
+ If you are using GitLab for issue tracking, you can specify `git_url` as follows to add a *Create issue* button in your notification.
12
+ By default this will use your Rails application name to match the git repository. If yours differs, you can specify `app_name`.
13
+ By that same notion, you may also set a `jira_url` to get a button that will send you to the New Issue screen in Jira.
14
+
15
+ ```ruby
16
+ Rails.application.config.middleware.use Exceptify::Rack,
17
+ email: {
18
+ email_prefix: "[PREFIX] ",
19
+ sender_address: %{"notifier" <notifier@example.com>},
20
+ exception_recipients: %w{exceptions@example.com}
21
+ },
22
+ teams: {
23
+ webhook_url: 'https://outlook.office.com/webhook/your-guid/IncomingWebhook/team-guid',
24
+ git_url: 'https://your-gitlab.com/Group/Project',
25
+ jira_url: 'https://your-jira.com'
26
+ }
27
+ ```
28
+
29
+ #### Options
30
+
31
+ ##### webhook_url
32
+
33
+ *String, required*
34
+
35
+ The Incoming WebHook URL on Teams.
36
+
37
+ ##### git_url
38
+
39
+ *String, optional*
40
+
41
+ Url of your gitlab or github with your organisation name for issue creation link (Eg: `github.com/aschen`). Defaults to nil and doesn't add link to the notification.
42
+
43
+ ##### jira_url
44
+
45
+ *String, optional*
46
+
47
+ Url of your Jira instance, adds button for Create Issue screen. Defaults to nil and doesn't add a button to the card.
48
+
49
+ ##### app_name
50
+
51
+ *String, optional*
52
+
53
+ Your application name used for git issue creation link. Defaults to `Rails.application.class.module_parent_name.underscore` for Rails versions >= 6;
54
+ `Rails.application.class.parent_name.underscore` otherwise.
@@ -0,0 +1,60 @@
1
+ ### WebHook notifier
2
+
3
+ This notifier ships notifications over the HTTP protocol.
4
+
5
+ #### Usage
6
+
7
+ Just add the [HTTParty](https://github.com/jnunemaker/httparty) gem to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'httparty'
11
+ ```
12
+
13
+ To configure it, you need to set the `url` option, like this:
14
+
15
+ ```ruby
16
+ Rails.application.config.middleware.use Exceptify::Rack,
17
+ email: {
18
+ email_prefix: '[PREFIX] ',
19
+ sender_address: %{"notifier" <notifier@example.com>},
20
+ exception_recipients: %w{exceptions@example.com}
21
+ },
22
+ webhook: {
23
+ url: 'http://domain.com:5555/hubot/path'
24
+ }
25
+ ```
26
+
27
+ By default, the WebhookNotifier will call the URLs using the POST method. But, you can change this using the `http_method` option.
28
+
29
+ ```ruby
30
+ Rails.application.config.middleware.use Exceptify::Rack,
31
+ email: {
32
+ email_prefix: '[PREFIX] ',
33
+ sender_address: %{"notifier" <notifier@example.com>},
34
+ exception_recipients: %w{exceptions@example.com}
35
+ },
36
+ webhook: {
37
+ url: 'http://domain.com:5555/hubot/path',
38
+ http_method: :get
39
+ }
40
+ ```
41
+
42
+ 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:
43
+
44
+ ```ruby
45
+ Rails.application.config.middleware.use Exceptify::Rack,
46
+ email: {
47
+ email_prefix: '[PREFIX] ',
48
+ sender_address: %{"notifier" <notifier@example.com>},
49
+ exception_recipients: %w{exceptions@example.com}
50
+ },
51
+ webhook: {
52
+ url: 'http://domain.com:5555/hubot/path',
53
+ basic_auth: {
54
+ username: 'alice',
55
+ password: 'password'
56
+ }
57
+ }
58
+ ```
59
+
60
+ For more HTTParty options, check out the [documentation](https://github.com/jnunemaker/httparty).
data/exceptify.gemspec ADDED
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("lib/exceptify/version", __dir__)
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "exceptify"
7
+ s.version = Exceptify::VERSION
8
+ s.authors = ["lukin.io"]
9
+ s.summary = "Exception notification for Ruby applications"
10
+ s.homepage = "https://github.com/lukin-io/exceptify"
11
+ s.license = "MIT"
12
+ s.metadata = {
13
+ "bug_tracker_uri" => "https://github.com/lukin-io/exceptify/issues",
14
+ "changelog_uri" => "https://github.com/lukin-io/exceptify/blob/main/CHANGELOG.rdoc",
15
+ "source_code_uri" => "https://github.com/lukin-io/exceptify"
16
+ }
17
+
18
+ s.required_ruby_version = ">= 3.4.4"
19
+
20
+ s.files = Dir[
21
+ "lib/**/*",
22
+ "docs/**/*",
23
+ "MIT-LICENSE",
24
+ "exceptify.gemspec",
25
+ "Rakefile",
26
+ "*.md",
27
+ "*.rdoc"
28
+ ].reject { |f| File.directory?(f) }
29
+ s.require_path = "lib"
30
+
31
+ s.add_dependency("actionmailer", ">= 7.1", "< 9")
32
+ s.add_dependency("activesupport", ">= 7.1", "< 9")
33
+ s.add_dependency("cgi", "~> 0.5")
34
+
35
+ s.add_development_dependency "aws-sdk-sns", "~> 1"
36
+ s.add_development_dependency "dogapi", ">= 1.23.0", "< 2"
37
+ s.add_development_dependency "httparty", "~> 0.10.2"
38
+ s.add_development_dependency "mocha", ">= 2.7.1", "< 4"
39
+ s.add_development_dependency "mock_redis", "~> 0.19.0"
40
+ s.add_development_dependency "net-smtp", "~> 0.5"
41
+ s.add_development_dependency "ostruct", "~> 0.6"
42
+ s.add_development_dependency "rails", ">= 8.0.2", "< 9"
43
+ s.add_development_dependency "resque", "~> 1.8.0"
44
+ s.add_development_dependency "sidekiq", ">= 7.1.0", "< 9"
45
+ s.add_development_dependency "slack-notifier", ">= 1.0.0", "< 3"
46
+ s.add_development_dependency "standard", "~> 1.54"
47
+ s.add_development_dependency "timecop", "~> 0.9.0"
48
+ end