uniform_notifier 1.14.2 → 1.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1920cf91de7d2884a04afe7b4bb3f47b5aaf05fffb71e014631fbc1a1eb7c1bd
4
- data.tar.gz: 8798d5ba9cb5ddc6bed1a05895ec4bd85c03aa690df1aa9dba5eb1abb45b7619
3
+ metadata.gz: 8cbfb1cbe32444a41960c0a9671bac48a43d96722312c1717c0c4e7a2a804433
4
+ data.tar.gz: 6c82f5aa72805717af977bc454464eaaf6cf2222e96cf6b97581265eb52ec678
5
5
  SHA512:
6
- metadata.gz: 0d6382aff6ad0043e90d3f82853367f480c46c84780df5928d073b8acd64055e5dfbc6c58e468f4115325adf980c907c10d0d1b87f4c5db7deeda9fe37fceb8e
7
- data.tar.gz: b3de13ddb6ca896814f325d14deff64c7353af2117a32441c604235ae1abac1855bb42826d64188fa8ee71c0179a6313332df7dd85b6682f9d19473c8b11f651
6
+ metadata.gz: 6870a31994f2d3592c30f145c76efedb4cb773053231732d4a2e369ced6ff013f37c673df7279d90bd4067dfd6029073b55fc24b957936519033abae809aef94
7
+ data.tar.gz: '09a5bb04b7966baf30a5af2b207dd7e33c2450e8058ebf16efe23ce7f024f3330e49ceaf07b3c1571fb0b316e1fffa1ce62673431f2145ac2762fe2b55e19b16'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Next Release
2
2
 
3
+ # 1.15.0 (03/21/2022)
4
+
5
+ * Fix bugsnag notifications
6
+ * Improve appsignal message
7
+
3
8
  # 1.14.2 (03/24/2021)
4
9
 
5
10
  * Fix `capture_exception` signature
@@ -11,7 +16,7 @@
11
16
  # 1.14.0 (02/26/2021)
12
17
 
13
18
  * Add AppSignal integration
14
- * Fix UniformNotifier::Raise.active? when .rails= receives a false value
19
+ * Fix `UniformNotifier::Raise.active?` when `.rails=` receives a false value
15
20
 
16
21
  ## 1.13.0 (10/05/2019)
17
22
 
@@ -12,13 +12,16 @@ class UniformNotifier
12
12
  def _out_of_channel_notify(data)
13
13
  opt = UniformNotifier.appsignal.is_a?(Hash) ? UniformNotifier.appsignal : {}
14
14
 
15
- exception = Exception.new(data[:title])
15
+ exception = Exception.new("#{data[:title]}\n#{data[:body]}")
16
16
  exception.set_backtrace(data[:backtrace]) if data[:backtrace]
17
17
 
18
18
  tags = opt.fetch(:tags, {}).merge(data.fetch(:tags, {}))
19
19
  namespace = data[:namespace] || opt[:namespace]
20
20
 
21
- Appsignal.send_error(*[exception, tags, namespace].compact)
21
+ Appsignal.send_error(exception) do |transaction|
22
+ transaction.set_tags(tags)
23
+ transaction.set_namespace(namespace)
24
+ end
22
25
  end
23
26
  end
24
27
  end
@@ -10,12 +10,20 @@ class UniformNotifier
10
10
  protected
11
11
 
12
12
  def _out_of_channel_notify(data)
13
- opt = {}
14
- opt = UniformNotifier.bugsnag if UniformNotifier.bugsnag.is_a?(Hash)
15
-
16
13
  exception = Exception.new(data[:title])
17
14
  exception.set_backtrace(data[:backtrace]) if data[:backtrace]
18
- Bugsnag.notify(exception, opt.merge(grouping_hash: data[:body] || data[:title], notification: data))
15
+
16
+ return nil if data.empty?
17
+
18
+ Bugsnag.notify(exception) do |report|
19
+ report.severity = "warning"
20
+ report.add_tab(:bullet, data)
21
+ report.grouping_hash = data[:body] || data[:title]
22
+
23
+ if UniformNotifier.bugsnag.is_a?(Proc)
24
+ UniformNotifier.bugsnag.call(report)
25
+ end
26
+ end
19
27
  end
20
28
  end
21
29
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class UniformNotifier
4
- VERSION = '1.14.2'
4
+ VERSION = '1.15.0'
5
5
  end
@@ -12,39 +12,50 @@ RSpec.describe UniformNotifier::AppsignalNotifier do
12
12
  end
13
13
 
14
14
  it 'should notify appsignal with keyword title' do
15
- expect(Appsignal).to receive(:send_error).with(UniformNotifier::Exception.new('notify appsignal'), {})
15
+ expect(Appsignal).to receive(:send_error).with(UniformNotifier::Exception.new("notify appsignal\n"))
16
16
 
17
17
  UniformNotifier.appsignal = true
18
18
  expect(UniformNotifier::AppsignalNotifier.out_of_channel_notify(title: 'notify appsignal'))
19
19
  end
20
20
 
21
21
  it 'should notify appsignal with first argument title' do
22
- expect(Appsignal).to receive(:send_error).with(UniformNotifier::Exception.new('notify appsignal'), {})
22
+ expect(Appsignal).to receive(:send_error).with(
23
+ UniformNotifier::Exception.new("notify appsignal\n")
24
+ )
23
25
 
24
26
  UniformNotifier.appsignal = true
25
27
  UniformNotifier::AppsignalNotifier.out_of_channel_notify('notify appsignal')
26
28
  end
27
29
 
28
30
  it 'should notify appsignal with tags' do
29
- expect(Appsignal).to receive(:send_error).with(UniformNotifier::Exception.new('notify appsignal'), { foo: :bar })
31
+ transaction = double('Appsignal::Transaction', set_namespace: nil)
32
+ expect(transaction).to receive(:set_tags).with({ foo: :bar })
33
+ expect(Appsignal).to receive(:send_error).with(
34
+ UniformNotifier::Exception.new("notify appsignal\n")
35
+ ).and_yield(transaction)
30
36
 
31
37
  UniformNotifier.appsignal = true
32
38
  UniformNotifier::AppsignalNotifier.out_of_channel_notify(title: 'notify appsignal', tags: { foo: :bar })
33
39
  end
34
40
 
35
41
  it 'should notify appsignal with default namespace' do
36
- expect(Appsignal).to receive(:send_error).with(UniformNotifier::Exception.new('notify appsignal'), {}, 'web')
42
+ transaction = double('Appsignal::Transaction', set_tags: nil)
43
+ expect(transaction).to receive(:set_namespace).with('web')
44
+ expect(Appsignal).to receive(:send_error).with(
45
+ UniformNotifier::Exception.new("notify appsignal\n")
46
+ ).and_yield(transaction)
37
47
 
38
48
  UniformNotifier.appsignal = { namespace: 'web' }
39
49
  UniformNotifier::AppsignalNotifier.out_of_channel_notify('notify appsignal')
40
50
  end
41
51
 
42
52
  it 'should notify appsignal with overridden namespace' do
53
+ transaction = double('Appsignal::Transaction')
54
+ expect(transaction).to receive(:set_tags).with({ foo: :bar })
55
+ expect(transaction).to receive(:set_namespace).with('background')
43
56
  expect(Appsignal).to receive(:send_error).with(
44
- UniformNotifier::Exception.new('notify appsignal'),
45
- { foo: :bar },
46
- 'background'
47
- )
57
+ UniformNotifier::Exception.new("notify appsignal\nbody")
58
+ ).and_yield(transaction)
48
59
 
49
60
  UniformNotifier.appsignal = { namespace: 'web' }
50
61
  UniformNotifier::AppsignalNotifier.out_of_channel_notify(
@@ -52,16 +63,18 @@ RSpec.describe UniformNotifier::AppsignalNotifier do
52
63
  tags: {
53
64
  foo: :bar
54
65
  },
55
- namespace: 'background'
66
+ namespace: 'background',
67
+ body: 'body',
56
68
  )
57
69
  end
58
70
 
59
71
  it 'should notify appsignal with merged tags' do
72
+ transaction = double('Appsignal::Transaction')
73
+ expect(transaction).to receive(:set_tags).with({ user: 'Bob', hostname: 'frontend2', site: 'first' })
74
+ expect(transaction).to receive(:set_namespace).with('background')
60
75
  expect(Appsignal).to receive(:send_error).with(
61
- UniformNotifier::Exception.new('notify appsignal'),
62
- { user: 'Bob', hostname: 'frontend2', site: 'first' },
63
- 'background'
64
- )
76
+ UniformNotifier::Exception.new("notify appsignal\nbody")
77
+ ).and_yield(transaction)
65
78
 
66
79
  UniformNotifier.appsignal = { namespace: 'web', tags: { hostname: 'frontend1', user: 'Bob' } }
67
80
  UniformNotifier::AppsignalNotifier.out_of_channel_notify(
@@ -70,6 +83,7 @@ RSpec.describe UniformNotifier::AppsignalNotifier do
70
83
  hostname: 'frontend2',
71
84
  site: 'first'
72
85
  },
86
+ body: 'body',
73
87
  namespace: 'background'
74
88
  )
75
89
  end
@@ -8,47 +8,51 @@ end
8
8
 
9
9
  RSpec.describe UniformNotifier::BugsnagNotifier do
10
10
  let(:notification_data) { {} }
11
+ let(:report) { double('Bugsnag::Report') }
12
+ before do
13
+ allow(report).to receive(:severity=)
14
+ allow(report).to receive(:add_tab)
15
+ allow(report).to receive(:grouping_hash=)
16
+ end
11
17
  it 'should not notify bugsnag' do
12
18
  expect(Bugsnag).not_to receive(:notify)
13
19
  UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
14
20
  end
15
21
  context 'with string notification' do
16
- let(:notification_data) { { user: 'user', title: 'notify bugsnag', url: 'URL', body: 'something' } }
22
+ let(:notification_data) { 'notify bugsnag' }
17
23
 
18
24
  it 'should notify bugsnag' do
19
25
  expect(Bugsnag).to receive(:notify).with(
20
- UniformNotifier::Exception.new(notification_data[:title]),
21
- grouping_hash: notification_data[:body],
22
- notification: notification_data
23
- )
26
+ UniformNotifier::Exception.new(notification_data)
27
+ ).and_yield(report)
28
+ expect(report).to receive(:severity=).with('warning')
29
+ expect(report).to receive(:add_tab).with(:bullet, title: notification_data)
30
+ expect(report).to receive(:grouping_hash=).with(notification_data)
24
31
 
25
32
  UniformNotifier.bugsnag = true
26
33
  UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
27
34
  end
28
35
 
29
- it 'should notify bugsnag with option' do
36
+ it 'should notify bugsnag with additional report configuration' do
30
37
  expect(Bugsnag).to receive(:notify).with(
31
- UniformNotifier::Exception.new(notification_data[:title]),
32
- foo: :bar,
33
- grouping_hash: notification_data[:body],
34
- notification: notification_data
35
- )
38
+ UniformNotifier::Exception.new(notification_data)
39
+ ).and_yield(report)
40
+ expect(report).to receive(:meta_data=).with(foo: :bar)
36
41
 
37
- UniformNotifier.bugsnag = { foo: :bar }
42
+ UniformNotifier.bugsnag = ->(report) { report.meta_data = { foo: :bar } }
38
43
  UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
39
44
  end
40
45
  end
41
46
  context 'with hash notification' do
42
- let(:notification_data) { 'notify bugsnag' }
47
+ let(:notification_data) { { user: 'user', title: 'notify bugsnag', url: 'URL', body: 'something' } }
43
48
 
44
49
  it 'should notify bugsnag' do
45
50
  expect(Bugsnag).to receive(:notify).with(
46
- UniformNotifier::Exception.new('notify bugsnag'),
47
- grouping_hash: 'notify bugsnag',
48
- notification: {
49
- title: 'notify bugsnag'
50
- }
51
- )
51
+ UniformNotifier::Exception.new(notification_data[:title])
52
+ ).and_yield(report)
53
+ expect(report).to receive(:severity=).with('warning')
54
+ expect(report).to receive(:add_tab).with(:bullet, notification_data)
55
+ expect(report).to receive(:grouping_hash=).with(notification_data[:body])
52
56
 
53
57
  UniformNotifier.bugsnag = true
54
58
  UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
@@ -56,15 +60,11 @@ RSpec.describe UniformNotifier::BugsnagNotifier do
56
60
 
57
61
  it 'should notify bugsnag with option' do
58
62
  expect(Bugsnag).to receive(:notify).with(
59
- UniformNotifier::Exception.new('notify bugsnag'),
60
- foo: :bar,
61
- grouping_hash: 'notify bugsnag',
62
- notification: {
63
- title: 'notify bugsnag'
64
- }
65
- )
63
+ UniformNotifier::Exception.new(notification_data[:title])
64
+ ).and_yield(report)
65
+ expect(report).to receive(:meta_data=).with(foo: :bar)
66
66
 
67
- UniformNotifier.bugsnag = { foo: :bar }
67
+ UniformNotifier.bugsnag = ->(report) { report.meta_data = { foo: :bar } }
68
68
  UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
69
69
  end
70
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uniform_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.2
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-23 00:00:00.000000000 Z
11
+ date: 2022-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  requirements: []
157
- rubygems_version: 3.1.4
157
+ rubygems_version: 3.3.7
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: uniform notifier for rails logger, customized logger, javascript alert, javascript