infield 0.3.0 → 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: 325524018c44e26d8fe8513f38604197def031b5582285f63c7c928b8c8d4b84
4
- data.tar.gz: 3b04d9d84e329c69c0c5b3bb822253943f9d0ba12a5ce3d78721b25e12657d87
3
+ metadata.gz: bcc989dc4411ecacc35b71a9f831b51c7a985e550872393e68cbed78530b33cd
4
+ data.tar.gz: 9e681a218059596455a77728f371e30a016810eb3aaf608a6c0af8aa3236a9b2
5
5
  SHA512:
6
- metadata.gz: f9179b0602fe9f755169b59af4a0e1ff10a62de52ac0c1cafaa96ac4653badd9a771b3cd3be5c73c35c12ddaf121a066c702c68b390d2ca123b687b8195bfee7
7
- data.tar.gz: 0624c57b8417151e01dfdb1de57a10ab2b69656e565443f31ad848c584fcd4bb2a894dea8b3a661c38000ecf38ef9878c0922d95f13e2c663b2d840b336106c7
6
+ metadata.gz: c361f23afc866c66338b633a7aefcf0714a0e4ec2ef5f8cccf568105751379207840eca47224ab1bf2339c16fa53e7038536ff97fba6822db9a5ed35622b57b5
7
+ data.tar.gz: 8010fcb20eb0c8f1168c1405f6f37f6e1cf8f6aaad08053cbffa493b0e43f8989f0aef0de1082f5377f9cbec823308f8672fc3cf291a37dcb155e79033b740e5
data/README.md CHANGED
@@ -18,10 +18,6 @@ Then in `config/application.rb`:
18
18
  repo_environment_id: ENV['INFIELD_REPO_ENVIRONMENT_ID'])
19
19
  end
20
20
 
21
- And in any environment you want to profile from:
22
-
23
- config.active_support.deprecation = :notify
24
-
25
21
  ## Configuration options
26
22
 
27
23
  The infield gem batches requests and sends them asyncronously. You can configure the following options to `Infield.run` (defaults shown here):
@@ -44,6 +44,23 @@ module Infield
44
44
  end
45
45
  end
46
46
 
47
+ def post_deprecation_warnings(tasks)
48
+ messages = tasks.map { |w| { message: w.message, callstack: w.callstack.map(&:to_s) } }
49
+
50
+ uri = infield_api_uri
51
+ Net::HTTP.start(uri.host, uri.port, use_ssl: (uri.scheme == 'https')) do |http|
52
+ http.post('/api/raw_deprecation_warnings',
53
+ { raw_deprecation_warnings: {
54
+ repo_environment_id: Infield.repo_environment_id,
55
+ environment: Infield.environment,
56
+ messages: messages
57
+ }
58
+ }.to_json,
59
+ { 'Content-Type' => 'application/json', 'Authorization' => "bearer #{Infield.api_key}" })
60
+ end
61
+ rescue *HTTP_ERRORS => e
62
+ end
63
+
47
64
  private
48
65
 
49
66
  def process_queue
@@ -62,17 +79,6 @@ module Infield
62
79
  def infield_api_uri
63
80
  URI.parse(Infield.infield_api_url)
64
81
  end
65
-
66
- def post_deprecation_warnings(tasks)
67
- messages = tasks.map { |w| { message: w.message } }
68
- uri = infield_api_uri
69
- Net::HTTP.start(uri.host, uri.port, use_ssl: (uri.scheme == 'https')) do |http|
70
- http.post('/api/raw_deprecation_warnings',
71
- default_api_params.merge(messages: messages).to_json,
72
- { 'Content-Type' => 'application/json', 'Authorization' => "bearer #{Infield.api_key}" })
73
- end
74
- rescue *HTTP_ERRORS => e
75
- end
76
82
  end
77
83
  end
78
84
 
data/lib/infield/rails.rb CHANGED
@@ -3,8 +3,19 @@
3
3
  module Infield
4
4
  class Railtie < Rails::Railtie
5
5
  initializer 'infield.deprecation_warnings', after: 'active_support.deprecation_behavior' do |_app|
6
- ActiveSupport::Notifications.subscribe('deprecation.rails') do |_name, _start, _finish, _id, payload|
7
- Infield::DeprecationWarning.log(payload[:message], validated: true)
6
+ infield_lambda = lambda do |message, callstack, *args|
7
+ Infield::DeprecationWarning.log(message, callstack: callstack, validated: true)
8
+ end
9
+
10
+ # Rails >= 7.0 makes it so that there are named deprecators that can have their own behavior
11
+ if Rails.application.respond_to?(:deprecators)
12
+ Rails.application.deprecators.each do |deprecator|
13
+ current = Array(deprecator.behavior)
14
+ deprecator.behavior = [infield_lambda, *current].uniq
15
+ end
16
+ else
17
+ current_behaviors = Array(ActiveSupport::Deprecation.behavior)
18
+ ActiveSupport::Deprecation.behavior = [infield_lambda, *current_behaviors].uniq
8
19
  end
9
20
  end
10
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Infield
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infield
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Infield
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-09 00:00:00.000000000 Z
11
+ date: 2025-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webmock