uniform_notifier 1.14.2 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/uniform_notifier/appsignal.rb +5 -2
- data/lib/uniform_notifier/bugsnag.rb +12 -4
- data/lib/uniform_notifier/version.rb +1 -1
- data/spec/uniform_notifier/appsignal_spec.rb +27 -13
- data/spec/uniform_notifier/bugsnag_spec.rb +27 -27
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cbfb1cbe32444a41960c0a9671bac48a43d96722312c1717c0c4e7a2a804433
|
4
|
+
data.tar.gz: 6c82f5aa72805717af977bc454464eaaf6cf2222e96cf6b97581265eb52ec678
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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(
|
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
|
-
|
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
|
@@ -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(
|
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(
|
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
|
-
|
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
|
-
|
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(
|
45
|
-
|
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(
|
62
|
-
|
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) {
|
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
|
21
|
-
|
22
|
-
|
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
|
36
|
+
it 'should notify bugsnag with additional report configuration' do
|
30
37
|
expect(Bugsnag).to receive(:notify).with(
|
31
|
-
UniformNotifier::Exception.new(notification_data
|
32
|
-
|
33
|
-
|
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(
|
47
|
-
|
48
|
-
|
49
|
-
|
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(
|
60
|
-
|
61
|
-
|
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.
|
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:
|
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.
|
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
|