mailgun_catcher 0.4.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4950b0b8430f9797b020c74c2a62fc5c7db17f6a39c520f32b895bd451d239a
4
- data.tar.gz: ac0f4b782594fc1026f0b6aa945f43411e1acbd5f9ebc0caf38ac6b88488cc85
3
+ metadata.gz: 254612ef50a083486d1790e91871e18592fc03e209b40df1cc8db6aa71367ddb
4
+ data.tar.gz: 9225aa2c1886e575554b16096e1165383077ce9a806dd4bdec9b44b272e5cc72
5
5
  SHA512:
6
- metadata.gz: 18b6c9916a4ad74d1597a6282f8ac05c7539b893bbb53d5f485e1230e151950dc93a8b884fccacdc4f11c1c705e41f485cd697f5a9ad3e3a38a060f2b44edede
7
- data.tar.gz: e4547b571e43c57de17ae9a33b0a381944b6a0adf42fb89e927d84cb4d5983e233f4c8db1c3cf5d1e008a0a45169d781ed4851dc31435404f8fe15f234dfff05
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
  ![](http://take.ms/HZRmm)
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.
@@ -1,7 +1,7 @@
1
1
  module MailgunCatcher
2
2
  class WebhooksController < MailgunCatcher::ApplicationController
3
3
  def create
4
- MailgunCatcher::Event.new(params).notify_bugsnag
4
+ MailgunCatcher::Event.new(params).notify
5
5
  head :ok
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@ module MailgunCatcher
2
2
  class Engine < ::Rails::Engine
3
3
  extend Dry::Configurable
4
4
 
5
- setting :webhooks_path, 'webhooks'
5
+ setting :webhooks_path, default: 'webhooks'
6
6
 
7
7
  isolate_namespace MailgunCatcher
8
8
  end
@@ -6,20 +6,28 @@ module MailgunCatcher
6
6
  @params = params.to_unsafe_h
7
7
  end
8
8
 
9
- def notify_bugsnag
10
- Bugsnag.notify(EventError.new(self))
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
@@ -1,3 +1,3 @@
1
1
  module MailgunCatcher
2
- VERSION = '0.4.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -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/event_error'
4
+ require 'mailgun_catcher/notifier/bugsnag'
5
5
 
6
6
  module MailgunCatcher
7
- # Your code goes here...
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: 0.4.0
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: 2019-03-05 00:00:00.000000000 Z
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/event_error.rb
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
- rubyforge_project:
94
- rubygems_version: 2.7.6
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