action_reporter 1.1.1 → 1.2.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: 782ac4706a6c326b0b4376d4bcd902fb25350ff4d2ec42369dad26b4675ec7d8
4
- data.tar.gz: 52e2c210596eaa631ddb4fe01d19cac231b408ed502a822f61943e4dfc2833e4
3
+ metadata.gz: a55d0da65743cb598db1ca915e69704f6fd3871921b015193d6445eaf5f1702b
4
+ data.tar.gz: 469868c0928f40fbefaabf40a797ce86d3b3aaa16c2f283faaee8dc2ee4a4ee5
5
5
  SHA512:
6
- metadata.gz: 3db4b3c08aa5b1753c97c915ea4a4951d4c3243dbbc4f1ded006f5721d0201c6056fdfedd6e8f57c113ca4708ef36b26bab476407787cf7686ac9b7c451f6ada
7
- data.tar.gz: 5e597c0cb00f1fb4554c75a5cbc7c478a941de950d19fc3eff02cb3462c694c20886b92464cd825bc0619e7bcad02c42e41cd3df43c61a6a1aead335ed20b601
6
+ metadata.gz: 9a280cc47e2b244299dd1279e480b1b65454e810f99ad675f5abfefe4b93dc8b80ed2e84816f28222c11d10977384d5c41fb5c23bcbe53f67d517c28b68dbddb
7
+ data.tar.gz: b80979582abbedc6db34ba723a8f225200e37c3e2fe5bf5eddd05a4d4301aef0a442fcd97002ac94dc6f4d4fa7cdb383e591afad2108039cb8f80881eb7aeaf6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 1.2.0
2
+
3
+ * Major fixes for class resolvers
4
+ * Implemented ActionReporter::Error class
5
+ * Improved test coverage
6
+
1
7
  # 1.1.1
2
8
 
3
9
  * Update check-in logic
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "action_reporter"
3
- s.version = "1.1.1"
3
+ s.version = "1.2.0"
4
4
 
5
5
  s.license = "MIT"
6
6
 
@@ -1,10 +1,12 @@
1
1
  module ActionReporter
2
2
  class Base
3
3
  def self.class_accessor(class_name)
4
- return unless Object.const_defined?(class_name)
4
+ method_name = class_name.gsub("::", "_").downcase + "_class"
5
+ define_method(method_name) do
6
+ raise Error.new("#{class_name} is not defined") unless Object.const_defined?(class_name)
5
7
 
6
- const_name = class_name.gsub("::", "")
7
- const_set(const_name, Object.const_get(class_name))
8
+ Object.const_get(class_name)
9
+ end
8
10
  end
9
11
 
10
12
  def transform_context(context)
@@ -23,7 +25,7 @@ module ActionReporter
23
25
  elsif identifier.respond_to?(:to_s)
24
26
  identifier.to_s
25
27
  else
26
- raise ArgumentError, "Unknown check-in identifier: #{identifier.inspect}"
28
+ raise ArgumentError.new("Unknown check-in identifier: #{identifier.inspect}")
27
29
  end
28
30
  end
29
31
 
@@ -0,0 +1,3 @@
1
+ module ActionReporter
2
+ class Error < StandardError; end
3
+ end
@@ -4,21 +4,25 @@ module ActionReporter
4
4
 
5
5
  def notify(error, context: {})
6
6
  new_context = transform_context(context)
7
- Honeybadger.notify(error, context: new_context)
7
+ honeybadger_class.notify(error, context: new_context)
8
8
  end
9
9
 
10
10
  def context(args)
11
11
  new_context = transform_context(args)
12
- Honeybadger.context(new_context)
12
+ honeybadger_class.context(new_context)
13
13
  end
14
14
 
15
15
  def reset_context
16
- Honeybadger.context.clear!
16
+ honeybadger_class.context.clear!
17
17
  end
18
18
 
19
19
  def check_in(identifier)
20
20
  check_in_id = resolve_check_in_id(identifier)
21
- Honeybadger.check_in(check_in_id)
21
+ honeybadger_class.check_in(check_in_id)
22
+ end
23
+
24
+ def audited_user=(user)
25
+ honeybadger_class.context(user_global_id: user.to_global_id.to_s) if user
22
26
  end
23
27
  end
24
28
  end
@@ -4,19 +4,19 @@ module ActionReporter
4
4
 
5
5
  def notify(error, context: {})
6
6
  new_context = transform_context(context)
7
- Rails.logger.info(
7
+ rails_class.logger.info(
8
8
  "Reporter notification: #{error.inspect}, #{new_context.inspect}"
9
9
  )
10
10
  end
11
11
 
12
12
  def context(args)
13
13
  new_context = transform_context(args)
14
- Rails.logger.info("Reporter context: #{new_context.inspect}")
14
+ rails_class.logger.info("Reporter context: #{new_context.inspect}")
15
15
  end
16
16
 
17
17
  def check_in(identifier)
18
18
  check_in_id = resolve_check_in_id(identifier)
19
- Rails.logger.info("Reporter check-in: #{check_in_id}")
19
+ rails_class.logger.info("Reporter check-in: #{check_in_id}")
20
20
  end
21
21
  end
22
22
  end
@@ -5,12 +5,16 @@ module ActionReporter
5
5
 
6
6
  def notify(error, context: {})
7
7
  self.context(context)
8
- ScoutApmError.capture(error)
8
+ scoutapm_error_class.capture(error)
9
9
  end
10
10
 
11
11
  def context(args)
12
12
  new_context = transform_context(args)
13
- ScoutApmContext.add(new_context)
13
+ scoutapm_context_class.add(new_context)
14
+ end
15
+
16
+ def audited_user=(user)
17
+ scoutapm_context_class.add_user(user_global_id: user&.to_global_id&.to_s)
14
18
  end
15
19
  end
16
20
  end
@@ -3,23 +3,27 @@ module ActionReporter
3
3
  class_accessor "Sentry"
4
4
 
5
5
  def notify(error, context: {})
6
- Sentry.with_scope do |temp_scope|
6
+ sentry_class.with_scope do |temp_scope|
7
7
  temp_scope.set_context("context", transform_context(context))
8
8
 
9
9
  if error.is_a?(StandardError)
10
- Sentry.capture_exception(error)
10
+ sentry_class.capture_exception(error)
11
11
  else
12
- Sentry.capture_message(error)
12
+ sentry_class.capture_message(error)
13
13
  end
14
14
  end
15
15
  end
16
16
 
17
17
  def context(args)
18
- Sentry.get_current_scope.set_context("context", transform_context(args))
18
+ sentry_class.get_current_scope.set_context("context", transform_context(args))
19
+ end
20
+
21
+ def reset_context
22
+ sentry_class.get_current_scope.set_context("context", {})
19
23
  end
20
24
 
21
25
  def audited_user=(user)
22
- Sentry.set_user(global_id: user.to_global_id.to_s) if user
26
+ sentry_class.set_user(user_global_id: user&.to_global_id&.to_s)
23
27
  end
24
28
  end
25
29
  end
@@ -1,3 +1,3 @@
1
1
  module ActionReporter
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Makarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-18 00:00:00.000000000 Z
11
+ date: 2023-04-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby wrapper for multiple reporting services
14
14
  email:
@@ -24,6 +24,7 @@ files:
24
24
  - lib/action_reporter.rb
25
25
  - lib/action_reporter/audited_reporter.rb
26
26
  - lib/action_reporter/base.rb
27
+ - lib/action_reporter/error.rb
27
28
  - lib/action_reporter/honeybadger_reporter.rb
28
29
  - lib/action_reporter/rails_reporter.rb
29
30
  - lib/action_reporter/scout_apm_reporter.rb