rails_spotlight 0.3.9 → 0.4.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/lib/rails_spotlight/channels/handlers/live_console_handler.rb +1 -1
- data/lib/rails_spotlight/channels/handlers/logs_handler.rb +1 -1
- data/lib/rails_spotlight/configuration.rb +2 -3
- data/lib/rails_spotlight/event.rb +21 -8
- data/lib/rails_spotlight/log_interceptor.rb +2 -2
- data/lib/rails_spotlight/version.rb +1 -1
- data/lib/tasks/init.rake +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 519dd5ff60d4420f62fb8fb3528e6fb5c56f2561508bd87bc9c534d4fbdbe047
|
4
|
+
data.tar.gz: 4520ba3597c02eb7c9b088ed3d9d1d8610836b3276da85ac0151a854e1022be6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a81db70a08bf70c5e0199e80e8984a0cbb6ee0be2946406305747491696debd52e26b009dbe346aa8c28559bc0e61689c7201060aec186806c0bc12ef305e97
|
7
|
+
data.tar.gz: c9b75ea3bb8bae547d2af74e7538e7b781f6c0d2d05ea5afe6bf96e64790cb4fe1f8ed01800c0ae6559bd2a75e92dc341480c217df2f45aaf185a42eff4d9a31
|
@@ -13,7 +13,7 @@ module RailsSpotlight
|
|
13
13
|
attr_reader :data
|
14
14
|
|
15
15
|
def call
|
16
|
-
return unless ::RailsSpotlight.config.
|
16
|
+
return unless ::RailsSpotlight.config.live_logs_enabled?
|
17
17
|
return unless data['type'] == TYPE
|
18
18
|
|
19
19
|
for_project = Array(data['project'])
|
@@ -9,9 +9,7 @@ module RailsSpotlight
|
|
9
9
|
'ActiveRecord' => [
|
10
10
|
'ActiveRecord::ConnectionAdapters::AbstractAdapter',
|
11
11
|
'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter',
|
12
|
-
'ActiveRecord::ConnectionAdapters::RealTransaction'
|
13
|
-
'ActiveRecord::SchemaMigration',
|
14
|
-
'ActiveRecord::Transaction'
|
12
|
+
'ActiveRecord::ConnectionAdapters::RealTransaction'
|
15
13
|
],
|
16
14
|
'ActionDispatch' => ['ActionDispatch::Request', 'ActionDispatch::Response']
|
17
15
|
}.freeze
|
@@ -79,6 +77,7 @@ module RailsSpotlight
|
|
79
77
|
|
80
78
|
alias live_console_enabled? live_console_enabled
|
81
79
|
alias live_logs_enabled? live_logs_enabled
|
80
|
+
alias use_action_cable? use_action_cable
|
82
81
|
|
83
82
|
def request_completed_broadcast_enabled
|
84
83
|
@request_completed_broadcast_enabled && use_action_cable && action_cable_present?
|
@@ -34,34 +34,47 @@ module RailsSpotlight
|
|
34
34
|
|
35
35
|
private
|
36
36
|
|
37
|
-
def json_encodable(payload)
|
37
|
+
def json_encodable(payload) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
38
38
|
return {} unless payload.is_a?(Hash)
|
39
39
|
|
40
40
|
transform_hash(payload, deep: true) do |hash, key, value|
|
41
|
-
|
42
|
-
if value_class == 'ActionDispatch::Http::Headers'
|
41
|
+
if value.class.to_s == 'ActionDispatch::Http::Headers'
|
43
42
|
value = value.to_h.select { |k, _| k.upcase == k }
|
44
|
-
elsif
|
43
|
+
elsif value.is_a?(Array) && defined?(ActiveRecord::Relation::QueryAttribute) && value.first.is_a?(ActiveRecord::Relation::QueryAttribute)
|
44
|
+
value = value.map(&method(:map_relation_query_attribute))
|
45
|
+
elsif not_encodable?(value)
|
45
46
|
value = NOT_JSON_ENCODABLE
|
46
47
|
end
|
47
48
|
|
48
49
|
begin
|
49
50
|
value.to_json(methods: [:duration])
|
50
51
|
new_value = value
|
51
|
-
rescue
|
52
|
+
rescue # rubocop:disable Lint/RedundantCopDisableDirective, Style/RescueStandardError
|
52
53
|
new_value = NOT_JSON_ENCODABLE
|
53
54
|
end
|
54
|
-
hash[key] = new_value
|
55
|
+
hash[key] = new_value # encode_value(value)
|
55
56
|
end.with_indifferent_access
|
56
57
|
end
|
57
58
|
|
59
|
+
# ActiveRecord::Relation::QueryAttribute implementation changed in Rails 7.1 it getting binds need to be manually added
|
60
|
+
def map_relation_query_attribute(attr)
|
61
|
+
{
|
62
|
+
name: attr.name,
|
63
|
+
value: attr.value,
|
64
|
+
value_before_type_cast: attr.value_before_type_cast,
|
65
|
+
value_for_database: attr.value_for_database
|
66
|
+
# resign from type and original_attribute for now
|
67
|
+
# type: attr.type,
|
68
|
+
# original_attribute: attr.original_attribute or attr.original_value_for_database,
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
58
72
|
def not_encodable?(value)
|
59
73
|
::RailsSpotlight.config.not_encodable_event_values.any? do |module_name, class_names|
|
60
74
|
next unless defined?(module_name.constantize)
|
61
75
|
|
62
76
|
class_names.any? { |class_name| value.is_a?(class_name.constantize) }
|
63
|
-
rescue # rubocop:disable Lint/
|
64
|
-
false
|
77
|
+
rescue # rubocop:disable Lint/SuppressedException, Style/RescueStandardError
|
65
78
|
end
|
66
79
|
end
|
67
80
|
|
@@ -31,7 +31,7 @@ module RailsSpotlight
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def _skip_logging?(message)
|
34
|
-
return false unless ::RailsSpotlight.config.
|
34
|
+
return false unless ::RailsSpotlight.config.use_action_cable?
|
35
35
|
return false unless message.is_a?(String)
|
36
36
|
|
37
37
|
message.include?(::RailsSpotlight::Channels::SPOTLIGHT_CHANNEL)
|
@@ -42,7 +42,7 @@ module RailsSpotlight
|
|
42
42
|
name = progname.is_a?(String) || progname.is_a?(Symbol) ? progname : nil
|
43
43
|
AppRequest.current.events << Event.new('rsl.notification.log', 0, 0, 0, callsite.merge(message: message, level: level, progname: name)) if AppRequest.current && callsite
|
44
44
|
|
45
|
-
return unless ::RailsSpotlight.config.
|
45
|
+
return unless ::RailsSpotlight.config.use_action_cable?
|
46
46
|
return if message.blank?
|
47
47
|
|
48
48
|
id = AppRequest.current ? AppRequest.current.id : nil # rubocop:disable Style/SafeNavigation
|
data/lib/tasks/init.rake
CHANGED
@@ -16,7 +16,7 @@ namespace :rails_spotlight do # rubocop:disable Metrics/BlockLength
|
|
16
16
|
STORAGE_PATH: <%=Rails.root.join('tmp', 'data', 'rails_spotlight')%>
|
17
17
|
STORAGE_POOL_SIZE: 20
|
18
18
|
LOGGER: <%=Logger.new(Rails.root.join('log', 'rails_spotlight.log'))%>
|
19
|
-
# Prevent from processing and sending some data to the extension
|
19
|
+
# Prevent from processing and sending some data to the extension
|
20
20
|
MIDDLEWARE_SKIPPED_PATHS: []
|
21
21
|
NOT_ENCODABLE_EVENT_VALUES:
|
22
22
|
SKIP_RENDERED_IVARS: []
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_spotlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pawel Niemczyk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack-contrib
|