uniform_notifier 1.13.2 → 1.14.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/CHANGELOG.md +3 -0
- data/README.md +10 -1
- data/lib/uniform_notifier.rb +3 -0
- data/lib/uniform_notifier/appsignal.rb +23 -0
- data/lib/uniform_notifier/version.rb +1 -1
- data/spec/uniform_notifier/appsignal_spec.rb +69 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e0dc90eb392f340e5bcb87c74e7f5ff5abdfe056c2f9a477349ed21806c981c
|
4
|
+
data.tar.gz: da95631ac719cf684e878f377cd93ab1678ed6d5d18ba63c22b3f04d77224386
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73a4d1e31f1604646b28f703ab865b6644413e42d41096c5e983d7fbbb0ae8a6ea1b2d14c88ffea7c15007d431aebedefd948d4365e265a3f074efd166ccc3a6
|
7
|
+
data.tar.gz: '08c69d23ee80f460409ab2edd5949a7beff96799afc5aa5ea8adb89536969fb9c1defa096ac24a652551280ff0b1a8b86c85ddde5443c7ade8f04c459ee42a30'
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
Status](https://secure.travis-ci.org/flyerhzm/uniform_notifier.svg)](http://travis-ci.org/flyerhzm/uniform_notifier)
|
5
5
|
[](https://awesomecode.io/repos/flyerhzm/uniform_notifier)
|
6
6
|
|
7
|
-
uniform_notifier is extracted from [bullet][0], it gives you the ability to send notification through rails logger, customized logger, javascript alert, javascript console, growl, xmpp, airbrake and
|
7
|
+
uniform_notifier is extracted from [bullet][0], it gives you the ability to send notification through rails logger, customized logger, javascript alert, javascript console, growl, xmpp, airbrake, honeybadger and AppSignal.
|
8
8
|
|
9
9
|
## Install
|
10
10
|
|
@@ -40,6 +40,10 @@ if you want to notify by bugsnag, you should install bugsnag first
|
|
40
40
|
|
41
41
|
gem install bugsnag
|
42
42
|
|
43
|
+
if you want to notify by AppSignal, you should install AppSignal first
|
44
|
+
|
45
|
+
gem install appsignal
|
46
|
+
|
43
47
|
if you want to notify by slack, you should install slack-notifier first
|
44
48
|
|
45
49
|
gem install slack-notifier
|
@@ -83,6 +87,11 @@ UniformNotifier.airbrake = true
|
|
83
87
|
# airbrake with options
|
84
88
|
UniformNotifier.airbrake = { :error_class => Exception }
|
85
89
|
|
90
|
+
# AppSignal
|
91
|
+
UniformNotifier.appsignal = true
|
92
|
+
# AppSignal with options
|
93
|
+
UniformNotifier.appsignal = { :namespace => "Background", :tags => { :hostname => "frontend1" } }
|
94
|
+
|
86
95
|
# Honeybadger
|
87
96
|
#
|
88
97
|
# Reporting live data from development is disabled by default. Ensure
|
data/lib/uniform_notifier.rb
CHANGED
@@ -13,6 +13,7 @@ require 'uniform_notifier/airbrake'
|
|
13
13
|
require 'uniform_notifier/sentry'
|
14
14
|
require 'uniform_notifier/rollbar'
|
15
15
|
require 'uniform_notifier/bugsnag'
|
16
|
+
require 'uniform_notifier/appsignal'
|
16
17
|
require 'uniform_notifier/slack'
|
17
18
|
require 'uniform_notifier/raise'
|
18
19
|
require 'uniform_notifier/terminal_notifier'
|
@@ -32,6 +33,7 @@ class UniformNotifier
|
|
32
33
|
slack
|
33
34
|
raise
|
34
35
|
sentry
|
36
|
+
appsignal
|
35
37
|
terminal_notifier
|
36
38
|
].freeze
|
37
39
|
|
@@ -49,6 +51,7 @@ class UniformNotifier
|
|
49
51
|
Raise,
|
50
52
|
Slack,
|
51
53
|
SentryNotifier,
|
54
|
+
AppsignalNotifier,
|
52
55
|
TerminalNotifier
|
53
56
|
].freeze
|
54
57
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UniformNotifier
|
4
|
+
class AppsignalNotifier < Base
|
5
|
+
def self.active?
|
6
|
+
!!UniformNotifier.appsignal
|
7
|
+
end
|
8
|
+
|
9
|
+
protected
|
10
|
+
|
11
|
+
def self._out_of_channel_notify(data)
|
12
|
+
opt = UniformNotifier.appsignal.is_a?(Hash) ? UniformNotifier.appsignal : {}
|
13
|
+
|
14
|
+
exception = Exception.new(data[:title])
|
15
|
+
exception.set_backtrace(data[:backtrace]) if data[:backtrace]
|
16
|
+
|
17
|
+
tags = opt.fetch(:tags, {}).merge(data.fetch(:tags, {}))
|
18
|
+
namespace = data[:namespace] || opt[:namespace]
|
19
|
+
|
20
|
+
Appsignal.send_error(*[exception, tags, namespace].compact)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
class Appsignal
|
6
|
+
# mock AppSignal
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec.describe UniformNotifier::AppsignalNotifier do
|
10
|
+
it 'should not notify appsignal' do
|
11
|
+
expect(UniformNotifier::AppsignalNotifier.out_of_channel_notify(title: 'notify appsignal')).to be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should notify appsignal with keyword title' do
|
15
|
+
expect(Appsignal).to receive(:send_error)
|
16
|
+
.with(UniformNotifier::Exception.new('notify appsignal'), {})
|
17
|
+
|
18
|
+
UniformNotifier.appsignal = true
|
19
|
+
expect(UniformNotifier::AppsignalNotifier.out_of_channel_notify(title: 'notify appsignal'))
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should notify appsignal with first argument title' do
|
23
|
+
expect(Appsignal).to receive(:send_error)
|
24
|
+
.with(UniformNotifier::Exception.new('notify appsignal'), {})
|
25
|
+
|
26
|
+
UniformNotifier.appsignal = true
|
27
|
+
UniformNotifier::AppsignalNotifier.out_of_channel_notify('notify appsignal')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should notify appsignal with tags' do
|
31
|
+
expect(Appsignal).to receive(:send_error)
|
32
|
+
.with(UniformNotifier::Exception.new('notify appsignal'), { foo: :bar })
|
33
|
+
|
34
|
+
UniformNotifier.appsignal = true
|
35
|
+
UniformNotifier::AppsignalNotifier.out_of_channel_notify(title: 'notify appsignal', tags: { foo: :bar})
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should notify appsignal with default namespace' do
|
39
|
+
expect(Appsignal).to receive(:send_error)
|
40
|
+
.with(UniformNotifier::Exception.new('notify appsignal'), {}, 'web')
|
41
|
+
|
42
|
+
UniformNotifier.appsignal = { namespace: 'web' }
|
43
|
+
UniformNotifier::AppsignalNotifier.out_of_channel_notify('notify appsignal')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should notify appsignal with overridden namespace' do
|
47
|
+
expect(Appsignal).to receive(:send_error)
|
48
|
+
.with(UniformNotifier::Exception.new('notify appsignal'), { foo: :bar }, 'background')
|
49
|
+
|
50
|
+
UniformNotifier.appsignal = { namespace: 'web' }
|
51
|
+
UniformNotifier::AppsignalNotifier.out_of_channel_notify(
|
52
|
+
title: 'notify appsignal',
|
53
|
+
tags: { foo: :bar },
|
54
|
+
namespace: 'background'
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should notify appsignal with merged tags' do
|
59
|
+
expect(Appsignal).to receive(:send_error)
|
60
|
+
.with(UniformNotifier::Exception.new('notify appsignal'), { user: 'Bob', hostname: 'frontend2', site: 'first' }, 'background')
|
61
|
+
|
62
|
+
UniformNotifier.appsignal = { namespace: 'web', tags: { hostname: 'frontend1', user: 'Bob' } }
|
63
|
+
UniformNotifier::AppsignalNotifier.out_of_channel_notify(
|
64
|
+
title: 'notify appsignal',
|
65
|
+
tags: { hostname: 'frontend2', site: 'first' },
|
66
|
+
namespace: 'background'
|
67
|
+
)
|
68
|
+
end
|
69
|
+
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.14.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-
|
11
|
+
date: 2021-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- Rakefile
|
98
98
|
- lib/uniform_notifier.rb
|
99
99
|
- lib/uniform_notifier/airbrake.rb
|
100
|
+
- lib/uniform_notifier/appsignal.rb
|
100
101
|
- lib/uniform_notifier/base.rb
|
101
102
|
- lib/uniform_notifier/bugsnag.rb
|
102
103
|
- lib/uniform_notifier/customized_logger.rb
|
@@ -115,6 +116,7 @@ files:
|
|
115
116
|
- lib/uniform_notifier/xmpp.rb
|
116
117
|
- spec/spec_helper.rb
|
117
118
|
- spec/uniform_notifier/airbrake_spec.rb
|
119
|
+
- spec/uniform_notifier/appsignal_spec.rb
|
118
120
|
- spec/uniform_notifier/base_spec.rb
|
119
121
|
- spec/uniform_notifier/bugsnag_spec.rb
|
120
122
|
- spec/uniform_notifier/customized_logger_spec.rb
|
@@ -160,6 +162,7 @@ summary: uniform notifier for rails logger, customized logger, javascript alert,
|
|
160
162
|
test_files:
|
161
163
|
- spec/spec_helper.rb
|
162
164
|
- spec/uniform_notifier/airbrake_spec.rb
|
165
|
+
- spec/uniform_notifier/appsignal_spec.rb
|
163
166
|
- spec/uniform_notifier/base_spec.rb
|
164
167
|
- spec/uniform_notifier/bugsnag_spec.rb
|
165
168
|
- spec/uniform_notifier/customized_logger_spec.rb
|