mailgun_catcher 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -1
- data/app/controllers/mailgun_catcher/webhooks_controller.rb +1 -1
- data/config/routes.rb +1 -1
- data/lib/mailgun_catcher.rb +9 -2
- data/lib/mailgun_catcher/engine.rb +4 -0
- 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
- metadata +28 -15
- 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: dacfa3890b0f1b49041cfcc6d749170d864471977c402a7bf3e8973a8ef287bf
|
4
|
+
data.tar.gz: b547f7780d0d99c576197568564cec4dad806bc62c858ee7c7370506b59f5074
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7354b7c497078d2e64cf1b197e6f9a7ba0f95e85ceff64a2be66c8947baf5549b71af32f8abdc4cac69498678f5a45be9197483ba0d0c3150024bff46d43e504
|
7
|
+
data.tar.gz: 237dc959296bd08b553f052dce12935c7788be43332c400c590ed00ad2fd835ca6569529f31c3e64c032d185ea34b5df4c1e1754ad10a545809fece5e63e9c55
|
data/README.md
CHANGED
@@ -18,9 +18,33 @@ Add to routes:
|
|
18
18
|
mount MailgunCatcher::Engine, at: "/mailgun_catcher"
|
19
19
|
```
|
20
20
|
|
21
|
-
|
21
|
+
To configure an exact path for the webhooks controller create an initializer (`mailgun_catcher.rb`) with the following content:
|
22
|
+
```ruby
|
23
|
+
MailgunCatcher::Engine.config.webhooks_path = 'custom_path'
|
24
|
+
```
|
25
|
+
This will allow you change the default webhook route from `/webhooks` to `/custom_path`.
|
26
|
+
|
27
|
+
Configure webhook on mailgun:
|
22
28
|
![](http://take.ms/HZRmm)
|
23
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
|
+
```
|
24
48
|
|
25
49
|
## Contributing
|
26
50
|
Contribution directions go here.
|
data/config/routes.rb
CHANGED
data/lib/mailgun_catcher.rb
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
+
require 'dry-configurable'
|
1
2
|
require 'mailgun_catcher/engine'
|
2
3
|
require 'mailgun_catcher/event'
|
3
|
-
require 'mailgun_catcher/
|
4
|
+
require 'mailgun_catcher/notifier/bugsnag'
|
4
5
|
|
5
6
|
module MailgunCatcher
|
6
|
-
|
7
|
+
extend Dry::Configurable
|
8
|
+
|
9
|
+
setting(:notifiers, ["MailgunCatcher::Notifier::Bugsnag"])
|
10
|
+
|
11
|
+
def self.setup
|
12
|
+
yield config
|
13
|
+
end
|
7
14
|
end
|
@@ -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
|
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: 0.
|
4
|
+
version: 1.0.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: 2020-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bugsnag
|
@@ -24,21 +24,35 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dry-configurable
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rails
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - ">"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '4'
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - ">"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
-
description: Engine for
|
54
|
+
version: '4'
|
55
|
+
description: Engine for mailgun hooks
|
42
56
|
email:
|
43
57
|
- d4be4st@gmail.com
|
44
58
|
executables: []
|
@@ -54,14 +68,14 @@ files:
|
|
54
68
|
- lib/mailgun_catcher.rb
|
55
69
|
- lib/mailgun_catcher/engine.rb
|
56
70
|
- lib/mailgun_catcher/event.rb
|
57
|
-
- lib/mailgun_catcher/
|
71
|
+
- lib/mailgun_catcher/notifier/bugsnag.rb
|
58
72
|
- lib/mailgun_catcher/version.rb
|
59
|
-
homepage: https://github.com/infinum/rails-infinum-
|
73
|
+
homepage: https://github.com/infinum/rails-infinum-mailgun_catcher
|
60
74
|
licenses:
|
61
75
|
- MIT
|
62
76
|
metadata:
|
63
77
|
allowed_push_host: https://rubygems.org
|
64
|
-
post_install_message:
|
78
|
+
post_install_message:
|
65
79
|
rdoc_options: []
|
66
80
|
require_paths:
|
67
81
|
- lib
|
@@ -76,9 +90,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
90
|
- !ruby/object:Gem::Version
|
77
91
|
version: '0'
|
78
92
|
requirements: []
|
79
|
-
|
80
|
-
|
81
|
-
signing_key:
|
93
|
+
rubygems_version: 3.0.3
|
94
|
+
signing_key:
|
82
95
|
specification_version: 4
|
83
|
-
summary: Engine for
|
96
|
+
summary: Engine for mailgun hooks
|
84
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
|