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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 424dc49d083eaf39eed2a0002d0af46890c14f6e136ed947851b24b5699427ca
4
- data.tar.gz: 6a0e5a013d96b14096ac5bb6a8bd5b0145020fec98eca7caf0666d73cb818672
3
+ metadata.gz: 519dd5ff60d4420f62fb8fb3528e6fb5c56f2561508bd87bc9c534d4fbdbe047
4
+ data.tar.gz: 4520ba3597c02eb7c9b088ed3d9d1d8610836b3276da85ac0151a854e1022be6
5
5
  SHA512:
6
- metadata.gz: bd59938d44b40b303bc507953c4f381a845093e1c9e4817f23e72341fdf0cfdfb2b975aaccaa93b375ebb36ef5eec6589ee2abf1848fc1f94734a4c171ebb4ee
7
- data.tar.gz: d843e22748532f89d3901d914272a8a830a5277ac141f7aa724efc545327f7f3145b153ac5779a3163fc04d6594acecdefa89a982735c143b63f443cdc4d12e5
6
+ metadata.gz: 5a81db70a08bf70c5e0199e80e8984a0cbb6ee0be2946406305747491696debd52e26b009dbe346aa8c28559bc0e61689c7201060aec186806c0bc12ef305e97
7
+ data.tar.gz: c9b75ea3bb8bae547d2af74e7538e7b781f6c0d2d05ea5afe6bf96e64790cb4fe1f8ed01800c0ae6559bd2a75e92dc341480c217df2f45aaf185a42eff4d9a31
@@ -15,7 +15,7 @@ module RailsSpotlight
15
15
  attr_reader :data
16
16
 
17
17
  def call
18
- return unless ::RailsSpotlight.config.live_console_enabled?
18
+ return unless ::RailsSpotlight.config.live_logs_enabled?
19
19
  return unless data['type'] == TYPE
20
20
 
21
21
  command = data['command']
@@ -13,7 +13,7 @@ module RailsSpotlight
13
13
  attr_reader :data
14
14
 
15
15
  def call
16
- return unless ::RailsSpotlight.config.live_console_enabled?
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
- value_class = value.class.to_s
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 value_class == 'SystemStackError' || not_encodable?(value)
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 StandardError, SystemStackError
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/RescueException, Lint/RedundantCopDisableDirective, Style/RescueStandardError
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.live_console_enabled?
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.live_console_enabled?
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsSpotlight
4
- VERSION = '0.3.9'
4
+ VERSION = '0.4.0'
5
5
  end
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.3.9
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-10 00:00:00.000000000 Z
11
+ date: 2024-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack-contrib