lantern-rails 0.2.0 → 0.2.2

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: 93b5aad3eb2484e765586589b5cb3e7cbd931d25fb20d1e249e21b521b336d91
4
- data.tar.gz: f8739f45b42a61c0ece6db30ae517dba6c30fe9ed4382ef315342a00c4cecfcb
3
+ metadata.gz: a10d9bbf6c76960298040e88390464ba2d451640e1abfb62bd5e7f8b46dc3aa9
4
+ data.tar.gz: 8e86338e7c02d61ef522140726562c5941ab725daf823360d748ab9402da7b8c
5
5
  SHA512:
6
- metadata.gz: 89caa7f682946b0143c7bc2f2917c4070549bb0d178ea87c3574a0a6324d3289aa8feb100dcadf42ee300443876cec5d8c2101ab0ec291383f461d56b7a6579f
7
- data.tar.gz: 2e1536b62d7292e113279e807bc61d59a166052a37cb9b8b8d834c6a733f0a24f0f3393db28e21598766e60ab4b2fbebfe2fb578c77fc91185114d31761595a2
6
+ metadata.gz: 57cfc0136452511b7a42e5799489a09450e39f22828505506f7c1c6150101a901779c01e4adae57c4add0b47e4da22b6deb7bfd88004470358c5da7de93e10c0
7
+ data.tar.gz: 55de2b34703ca25621026c177c35a701b0bacb323bb0a5c96f0ba2b74ae64574141c496ff621104d14de382900649b25bfb79e453f4a98b1da9955f276033909
@@ -2,11 +2,10 @@ module Lantern
2
2
  module Rails
3
3
  class Railtie < ::Rails::Railtie
4
4
  initializer "lantern.request_tracker" do |app|
5
- config = Lantern::Rails.configuration
6
- next unless config.valid?
7
- next unless config.enabled
8
- next unless config.collect_in_environments.include?(::Rails.env.to_s)
9
-
5
+ # Insert middleware unconditionally — it checks config at runtime
6
+ # and no-ops if Lantern isn't configured. This avoids the frozen
7
+ # middleware stack issue in Rails 8.1 while ensuring the API key
8
+ # (set in app initializers) is available when requests arrive.
10
9
  app.middleware.use Lantern::Rails::RequestTracker, Lantern::Rails.query_aggregator
11
10
  end
12
11
 
@@ -10,6 +10,9 @@ module Lantern
10
10
  end
11
11
 
12
12
  def call(env)
13
+ # No-op if Lantern isn't configured or not enabled for this environment
14
+ return @app.call(env) unless enabled?
15
+
13
16
  # Only track actual controller requests, skip assets/healthchecks
14
17
  return @app.call(env) unless trackable_request?(env)
15
18
 
@@ -49,6 +52,14 @@ module Lantern
49
52
 
50
53
  private
51
54
 
55
+ def enabled?
56
+ return @enabled if defined?(@enabled)
57
+
58
+ config = Lantern::Rails.configuration
59
+ @enabled = config.valid? && config.enabled &&
60
+ config.collect_in_environments.include?(::Rails.env.to_s)
61
+ end
62
+
52
63
  def trackable_request?(env)
53
64
  # Skip asset pipeline, action cable, health checks
54
65
  path = env["PATH_INFO"].to_s
@@ -1,5 +1,5 @@
1
1
  module Lantern
2
2
  module Rails
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lantern-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Mumbower