mailgun_catcher 0.4.0 → 1.1.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.
- checksums.yaml +4 -4
- data/README.md +18 -0
- data/app/controllers/mailgun_catcher/webhooks_controller.rb +1 -1
- data/lib/mailgun_catcher/engine.rb +1 -1
- data/lib/mailgun_catcher/event.rb +10 -2
- data/lib/mailgun_catcher/notifier/bugsnag.rb +31 -0
- data/lib/mailgun_catcher/version.rb +1 -1
- data/lib/mailgun_catcher.rb +8 -2
- metadata +11 -12
- data/lib/mailgun_catcher/event_error.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 254612ef50a083486d1790e91871e18592fc03e209b40df1cc8db6aa71367ddb
|
4
|
+
data.tar.gz: 9225aa2c1886e575554b16096e1165383077ce9a806dd4bdec9b44b272e5cc72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7aa0bf694f071b0782cf2d42c0a3434e25da8434912aeadffde7d138a28ccda8b7c5f014ae1ad30ae61c759e833760293a9afa2d6752036ad3ef0cb020b76911
|
7
|
+
data.tar.gz: 25da9866a38460ca6f75d021e312951010717144f6765d5d2d574b11a01ed5fb40c13576a8956b1685625245157a4356b157d37d97a1cbb0e4b1c40350534337
|
data/README.md
CHANGED
@@ -27,6 +27,24 @@ This will allow you change the default webhook route from `/webhooks` to `/custo
|
|
27
27
|
Configure webhook on mailgun:
|
28
28
|

|
29
29
|
|
30
|
+
## Notifiers
|
31
|
+
Library supports event dispatching via notifier. Notifier is any object that responds to `notify` message. By default, events are notified on Bugsnag service, but you can provide your own notifier implementation by configuring `MailgunCatcher.config.notifier`.
|
32
|
+
|
33
|
+
### Configuring custom notifier
|
34
|
+
```ruby
|
35
|
+
class MailgunNotifier
|
36
|
+
def notify(event)
|
37
|
+
puts event
|
38
|
+
end
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
register custom notifier implementation through initializer
|
43
|
+
```ruby
|
44
|
+
MailgunCatcher.setup do |config|
|
45
|
+
config.notifiers = ["MailgunCatcher::Notifier::Bugsnag", "MailgunNotifier"]
|
46
|
+
end
|
47
|
+
```
|
30
48
|
|
31
49
|
## Contributing
|
32
50
|
Contribution directions go here.
|
@@ -6,20 +6,28 @@ module MailgunCatcher
|
|
6
6
|
@params = params.to_unsafe_h
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
|
9
|
+
def notify
|
10
|
+
notifiers.each { |notifier| notifier.notify(self) }
|
11
11
|
end
|
12
12
|
|
13
13
|
def error_message
|
14
14
|
"[#{severity}] [#{reason}] #{recipient}: #{delivery_status}"
|
15
15
|
end
|
16
16
|
|
17
|
+
def grouping_error_message
|
18
|
+
"[#{severity}] [#{reason}] #{recipient}"
|
19
|
+
end
|
20
|
+
|
17
21
|
def event_data
|
18
22
|
params.fetch('event-data', {})
|
19
23
|
end
|
20
24
|
|
21
25
|
private
|
22
26
|
|
27
|
+
def notifiers
|
28
|
+
MailgunCatcher.config.notifiers.map { |notifier| notifier.constantize.new }
|
29
|
+
end
|
30
|
+
|
23
31
|
def delivery_status
|
24
32
|
return delivery_status_message if delivery_status_message.present?
|
25
33
|
return delivery_status_description if delivery_status_description.present?
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module MailgunCatcher
|
2
|
+
module Notifier
|
3
|
+
class Bugsnag
|
4
|
+
def notify(event)
|
5
|
+
error_event = EventError.new(event)
|
6
|
+
::Bugsnag.notify(error_event)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class EventError < StandardError
|
11
|
+
attr_reader :event
|
12
|
+
|
13
|
+
def initialize(event)
|
14
|
+
@event = event
|
15
|
+
super(event.error_message)
|
16
|
+
end
|
17
|
+
|
18
|
+
def bugsnag_meta_data
|
19
|
+
{ event_details: event.event_data }
|
20
|
+
end
|
21
|
+
|
22
|
+
def bugsnag_context
|
23
|
+
'mailgun'
|
24
|
+
end
|
25
|
+
|
26
|
+
def bugsnag_grouping_hash
|
27
|
+
event.grouping_error_message
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/mailgun_catcher.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
require 'dry-configurable'
|
2
2
|
require 'mailgun_catcher/engine'
|
3
3
|
require 'mailgun_catcher/event'
|
4
|
-
require 'mailgun_catcher/
|
4
|
+
require 'mailgun_catcher/notifier/bugsnag'
|
5
5
|
|
6
6
|
module MailgunCatcher
|
7
|
-
|
7
|
+
extend Dry::Configurable
|
8
|
+
|
9
|
+
setting(:notifiers, default: ["MailgunCatcher::Notifier::Bugsnag"])
|
10
|
+
|
11
|
+
def self.setup
|
12
|
+
yield config
|
13
|
+
end
|
8
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailgun_catcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stjepan Hadjić
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bugsnag
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: dry-configurable
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '0.12'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '0.12'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,14 +68,14 @@ files:
|
|
68
68
|
- lib/mailgun_catcher.rb
|
69
69
|
- lib/mailgun_catcher/engine.rb
|
70
70
|
- lib/mailgun_catcher/event.rb
|
71
|
-
- lib/mailgun_catcher/
|
71
|
+
- lib/mailgun_catcher/notifier/bugsnag.rb
|
72
72
|
- lib/mailgun_catcher/version.rb
|
73
73
|
homepage: https://github.com/infinum/rails-infinum-mailgun_catcher
|
74
74
|
licenses:
|
75
75
|
- MIT
|
76
76
|
metadata:
|
77
77
|
allowed_push_host: https://rubygems.org
|
78
|
-
post_install_message:
|
78
|
+
post_install_message:
|
79
79
|
rdoc_options: []
|
80
80
|
require_paths:
|
81
81
|
- lib
|
@@ -90,9 +90,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
|
-
|
94
|
-
|
95
|
-
signing_key:
|
93
|
+
rubygems_version: 3.3.3
|
94
|
+
signing_key:
|
96
95
|
specification_version: 4
|
97
96
|
summary: Engine for mailgun hooks
|
98
97
|
test_files: []
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module MailgunCatcher
|
2
|
-
class EventError < StandardError
|
3
|
-
attr_reader :event
|
4
|
-
|
5
|
-
def initialize(event)
|
6
|
-
@event = event
|
7
|
-
super(event.error_message)
|
8
|
-
end
|
9
|
-
|
10
|
-
def bugsnag_meta_data
|
11
|
-
{ event_details: event.event_data }
|
12
|
-
end
|
13
|
-
|
14
|
-
def bugsnag_context
|
15
|
-
'mailgun'
|
16
|
-
end
|
17
|
-
|
18
|
-
def bugsnag_grouping_hash
|
19
|
-
event.error_message
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|