action_reporter 1.4.1 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +20 -1
- data/action_reporter.gemspec +13 -13
- data/lib/action_reporter/audited_reporter.rb +19 -5
- data/lib/action_reporter/honeybadger_reporter.rb +1 -1
- data/lib/action_reporter/paper_trail_reporter.rb +2 -2
- data/lib/action_reporter/scout_apm_reporter.rb +5 -1
- data/lib/action_reporter/sentry_reporter.rb +1 -1
- data/lib/action_reporter.rb +33 -6
- 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: 310122c609e9af5d1ea9196fa5596a5c3b2d21b951c347a35983fb6ccbf47fe3
|
4
|
+
data.tar.gz: c9beb3493e8b36bd7c8da57850da96e1fb4e4465c4f9293c2f4a8262fdf79a91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b660e58bb8fba800eaebba9566e22df001e4b8111883bc917078c72c95ef19e5cad38557109ff8a397d56b5503c416122abccb8219d22169fdbf9222a592e596
|
7
|
+
data.tar.gz: 3eed255cb5337162b9785f5c89205de4eb9f1942f6bf7a6c7282080f63ef9b1bf84bb0288a784f12f4b4e7b36a580de1d4cda7eb74e5f8d8fe72f3d7bbbf38c7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# 1.5.1
|
2
|
+
|
3
|
+
* Fix Audited current user setter to use `audited_user`
|
4
|
+
|
5
|
+
# 1.5.0
|
6
|
+
|
7
|
+
* BREAKING: Rename `audited_user` to `current_user`
|
8
|
+
* Add `current_request_uuid` and `current_remote_addr` getters and setters
|
9
|
+
* Memoize `current_user`, `current_request_uuid`, and `current_remote_addr`
|
10
|
+
|
1
11
|
# 1.4.1
|
2
12
|
|
3
13
|
* Add paper_trail support
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/action_reporter.svg)](https://badge.fury.io/rb/action_reporter) [![Test Status](https://github.com/amkisko/action_reporter.rb/actions/workflows/test.yml/badge.svg)](https://github.com/amkisko/action_reporter.rb/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/amkisko/action_reporter.rb/graph/badge.svg?token=JCV2A7NWTE)](https://codecov.io/gh/amkisko/action_reporter.rb)
|
4
4
|
|
5
|
+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f4bef9a52eac43a5a0f6d8c1b58cc6af)](https://app.codacy.com/gh/amkisko/action_reporter.rb/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/f4bef9a52eac43a5a0f6d8c1b58cc6af)](https://app.codacy.com/gh/amkisko/action_reporter.rb/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
|
6
|
+
|
5
7
|
Ruby wrapper for multiple reporting services.
|
6
8
|
|
7
9
|
Supported services:
|
@@ -50,11 +52,28 @@ ActionReporter.enabled_reporters = [
|
|
50
52
|
Then you can use it in your code:
|
51
53
|
|
52
54
|
```ruby
|
53
|
-
ActionReporter.
|
55
|
+
ActionReporter.current_user = current_user
|
56
|
+
ActionReporter.current_request_uuid = request.env['action_dispatch.request_id']
|
57
|
+
ActionReporter.current_remote_addr = request.env['action_dispatch.remote_ip']
|
54
58
|
ActionReporter.context(entry_id: entry.id)
|
55
59
|
ActionReporter.notify('Something went wrong', context: { record: record })
|
56
60
|
```
|
57
61
|
|
62
|
+
## Hook debugger to notify method
|
63
|
+
|
64
|
+
Apply patch on initializer level or before running the main code:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
module ActionReporter
|
68
|
+
class RailsReporter < Base
|
69
|
+
def notify(error, context: {})
|
70
|
+
super
|
71
|
+
binding.pry
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
58
77
|
## Contributing
|
59
78
|
|
60
79
|
Bug reports and pull requests are welcome on GitHub at https://github.com/amkisko/action_reporter.rb
|
data/action_reporter.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "action_reporter"
|
3
|
-
gem.version = File.read(File.expand_path(
|
3
|
+
gem.version = File.read(File.expand_path("../lib/action_reporter.rb", __FILE__)).match(/VERSION\s*=\s*'(.*?)'/)[1]
|
4
4
|
|
5
5
|
gem.license = "MIT"
|
6
6
|
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
|
|
21
21
|
"rubygems_mfa_required" => "true"
|
22
22
|
}
|
23
23
|
|
24
|
-
gem.files = Dir.glob("lib/**/*.rb") + Dir.glob("bin/**/*") + %w
|
24
|
+
gem.files = Dir.glob("lib/**/*.rb") + Dir.glob("bin/**/*") + %w[CHANGELOG.md LICENSE.md README.md action_reporter.gemspec]
|
25
25
|
|
26
26
|
# s.bindir = "bin"
|
27
27
|
# s.executables = ["action_reporter"]
|
@@ -29,17 +29,17 @@ Gem::Specification.new do |gem|
|
|
29
29
|
gem.required_ruby_version = ">= 2.5.0"
|
30
30
|
gem.require_path = "lib"
|
31
31
|
|
32
|
-
gem.add_runtime_dependency
|
32
|
+
gem.add_runtime_dependency "rails", "> 5"
|
33
33
|
|
34
|
-
gem.add_development_dependency
|
35
|
-
gem.add_development_dependency
|
36
|
-
gem.add_development_dependency
|
37
|
-
gem.add_development_dependency
|
38
|
-
gem.add_development_dependency
|
34
|
+
gem.add_development_dependency "audited", "~> 5"
|
35
|
+
gem.add_development_dependency "honeybadger", "~> 5"
|
36
|
+
gem.add_development_dependency "sentry-ruby", "~> 5"
|
37
|
+
gem.add_development_dependency "scout_apm", "~> 5"
|
38
|
+
gem.add_development_dependency "paper_trail", "~> 15"
|
39
39
|
|
40
|
-
gem.add_development_dependency
|
41
|
-
gem.add_development_dependency
|
42
|
-
gem.add_development_dependency
|
43
|
-
gem.add_development_dependency
|
44
|
-
gem.add_development_dependency
|
40
|
+
gem.add_development_dependency "rspec", "~> 3"
|
41
|
+
gem.add_development_dependency "webmock", "~> 3"
|
42
|
+
gem.add_development_dependency "pry", "~> 0.14"
|
43
|
+
gem.add_development_dependency "simplecov", "~> 0.21"
|
44
|
+
gem.add_development_dependency "simplecov-cobertura", "~> 2"
|
45
45
|
end
|
@@ -6,22 +6,36 @@ module ActionReporter
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def context(args)
|
9
|
-
Audited.store[:current_remote_address] = args[:remote_addr] if args[
|
10
|
-
:remote_addr
|
11
|
-
].present?
|
12
9
|
end
|
13
10
|
|
14
11
|
def reset_context
|
15
12
|
Audited.store.delete(:current_remote_address)
|
13
|
+
Audited.store.delete(:current_request_uuid)
|
16
14
|
Audited.store.delete(:audited_user)
|
17
15
|
end
|
18
16
|
|
19
|
-
def
|
17
|
+
def current_user
|
20
18
|
Audited.store[:audited_user]
|
21
19
|
end
|
22
20
|
|
23
|
-
def
|
21
|
+
def current_user=(user)
|
24
22
|
Audited.store[:audited_user] = user
|
25
23
|
end
|
24
|
+
|
25
|
+
def current_request_uuid
|
26
|
+
Audited.store[:current_request_uuid]
|
27
|
+
end
|
28
|
+
|
29
|
+
def current_request_uuid=(request_uuid)
|
30
|
+
Audited.store[:current_request_uuid] = request_uuid
|
31
|
+
end
|
32
|
+
|
33
|
+
def current_remote_addr
|
34
|
+
Audited.store[:current_remote_address]
|
35
|
+
end
|
36
|
+
|
37
|
+
def current_remote_addr=(remote_addr)
|
38
|
+
Audited.store[:current_remote_address] = remote_addr
|
39
|
+
end
|
26
40
|
end
|
27
41
|
end
|
@@ -12,11 +12,11 @@ module ActionReporter
|
|
12
12
|
PaperTrail.request.whodunnit = nil
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def current_user
|
16
16
|
PaperTrail.request.whodunnit
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def current_user=(user)
|
20
20
|
PaperTrail.request.whodunnit = user
|
21
21
|
end
|
22
22
|
end
|
@@ -13,8 +13,12 @@ module ActionReporter
|
|
13
13
|
scoutapm_context_class.add(new_context)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def current_user=(user)
|
17
17
|
scoutapm_context_class.add_user(user_global_id: user&.to_global_id&.to_s)
|
18
18
|
end
|
19
|
+
|
20
|
+
def ignore_transaction!
|
21
|
+
scoutapm_context_class.ignore_transaction!
|
22
|
+
end
|
19
23
|
end
|
20
24
|
end
|
data/lib/action_reporter.rb
CHANGED
@@ -10,7 +10,7 @@ require 'action_reporter/paper_trail_reporter'
|
|
10
10
|
module ActionReporter
|
11
11
|
module_function
|
12
12
|
|
13
|
-
VERSION = '1.
|
13
|
+
VERSION = '1.5.1'.freeze
|
14
14
|
|
15
15
|
AVAILABLE_REPORTERS = [
|
16
16
|
ActionReporter::RailsReporter,
|
@@ -55,15 +55,42 @@ module ActionReporter
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
59
|
-
|
58
|
+
def current_user
|
59
|
+
@current_user
|
60
60
|
end
|
61
61
|
|
62
|
-
def
|
62
|
+
def current_user=(user)
|
63
|
+
@current_user = user
|
63
64
|
enabled_reporters.each do |reporter|
|
64
|
-
next unless reporter.respond_to?(:
|
65
|
+
next unless reporter.respond_to?(:current_user=)
|
65
66
|
|
66
|
-
reporter.
|
67
|
+
reporter.current_user = user
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def current_request_uuid
|
72
|
+
@current_request_uuid
|
73
|
+
end
|
74
|
+
|
75
|
+
def current_request_uuid=(request_uuid)
|
76
|
+
@current_request_uuid = request_uuid
|
77
|
+
enabled_reporters.each do |reporter|
|
78
|
+
next unless reporter.respond_to?(:current_request_uuid=)
|
79
|
+
|
80
|
+
reporter.current_request_uuid = request_uuid
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def current_remote_addr
|
85
|
+
@current_remote_addr
|
86
|
+
end
|
87
|
+
|
88
|
+
def current_remote_addr=(remote_addr)
|
89
|
+
@current_remote_addr = remote_addr
|
90
|
+
enabled_reporters.each do |reporter|
|
91
|
+
next unless reporter.respond_to?(:current_remote_addr=)
|
92
|
+
|
93
|
+
reporter.current_remote_addr = remote_addr
|
67
94
|
end
|
68
95
|
end
|
69
96
|
|
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.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Makarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
209
|
- !ruby/object:Gem::Version
|
210
210
|
version: '0'
|
211
211
|
requirements: []
|
212
|
-
rubygems_version: 3.
|
212
|
+
rubygems_version: 3.5.11
|
213
213
|
signing_key:
|
214
214
|
specification_version: 4
|
215
215
|
summary: See description
|