lantern-rails 0.2.2 → 0.3.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: a10d9bbf6c76960298040e88390464ba2d451640e1abfb62bd5e7f8b46dc3aa9
4
- data.tar.gz: 8e86338e7c02d61ef522140726562c5941ab725daf823360d748ab9402da7b8c
3
+ metadata.gz: 9e80b02c09f20e01a8a0b0f4f502708feba44f3d8bffaa9cf0bbded0ee2bf079
4
+ data.tar.gz: 4dba6effb791874dbd11fe35d125b6637668b75792f3fd3c0efe9bf1069e9fcc
5
5
  SHA512:
6
- metadata.gz: 57cfc0136452511b7a42e5799489a09450e39f22828505506f7c1c6150101a901779c01e4adae57c4add0b47e4da22b6deb7bfd88004470358c5da7de93e10c0
7
- data.tar.gz: 55de2b34703ca25621026c177c35a701b0bacb323bb0a5c96f0ba2b74ae64574141c496ff621104d14de382900649b25bfb79e453f4a98b1da9955f276033909
6
+ metadata.gz: 0feab9b70da80d79b7455d28703ce83cc252520ca75988976751efea292d4bd201b8ecd25e133f4050f9a7be32f96a1b54b2fade5539eed629b16299fbe15f2d
7
+ data.tar.gz: 20c7cc314a052d6bc9d12de1b4175bc5b83b8f0670cb06ba4c20505f577bb6837d3c61c43c86f14ef10f7e4e68cf4b3acd4eda3548ec5e41b692780beb125f0c
data/README.md CHANGED
@@ -16,50 +16,24 @@ Then run:
16
16
  bundle install
17
17
  ```
18
18
 
19
- ## Setup
19
+ ## Quick start
20
20
 
21
- 1. Generate an API key at [uselantern.dev](https://uselantern.dev)
22
- 2. Store the key using one of the options below
23
- 3. Create an initializer
24
-
25
- ### Store your API key
26
-
27
- **Option A: Environment variable**
21
+ 1. Sign up for a free API key at [uselantern.dev](https://uselantern.dev)
22
+ 2. Run the installer:
28
23
 
29
24
  ```
30
- LANTERN_API_KEY=lnt_your_key_here
25
+ rails generate lantern:install
31
26
  ```
32
27
 
33
- **Option B: Rails credentials**
28
+ 3. Add your API key to the generated initializer (`config/initializers/lantern.rb`) via environment variable or Rails credentials:
34
29
 
35
30
  ```
36
- bin/rails credentials:edit
37
- ```
38
-
39
- Flat:
40
- ```yaml
41
- lantern_api_key: lnt_your_key_here
42
- ```
43
-
44
- Or nested:
45
- ```yaml
46
- lantern:
47
- api_key: lnt_your_key_here
31
+ LANTERN_API_KEY=lnt_your_key_here
48
32
  ```
49
33
 
50
- ### Create the initializer
51
-
52
- ```ruby
53
- # config/initializers/lantern.rb
54
- Lantern::Rails.configure do |config|
55
- # Match how you stored the key above:
56
- config.api_key = ENV["LANTERN_API_KEY"]
57
- # Or: config.api_key = Rails.application.credentials.lantern_api_key
58
- # Or: config.api_key = Rails.application.credentials.dig(:lantern, :api_key)
59
- end
60
- ```
34
+ 4. Deploy Lantern starts collecting automatically.
61
35
 
62
- That's it. The collector starts automatically when your Rails app boots in production.
36
+ That's it. Open [uselantern.dev](https://uselantern.dev) to see your dashboard.
63
37
 
64
38
  ## Configuration
65
39
 
@@ -0,0 +1,23 @@
1
+ module Lantern
2
+ class InstallGenerator < ::Rails::Generators::Base
3
+ source_root File.expand_path("templates", __dir__)
4
+
5
+ desc "Creates a Lantern initializer with your API key."
6
+
7
+ def copy_initializer
8
+ template "lantern.rb.tt", "config/initializers/lantern.rb"
9
+ end
10
+
11
+ def print_next_steps
12
+ say ""
13
+ say "Lantern installed!", :green
14
+ say ""
15
+ say "Next steps:"
16
+ say " 1. Add your API key to config/initializers/lantern.rb"
17
+ say " Get your free key at: https://uselantern.dev"
18
+ say " 2. Deploy your app — Lantern starts collecting automatically"
19
+ say " 3. Open https://uselantern.dev to see your dashboard"
20
+ say ""
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,11 @@
1
+ Lantern::Rails.configure do |config|
2
+ # Your API key from https://uselantern.dev
3
+ # Sign up for free, add a database, and copy the key here.
4
+ config.api_key = Rails.application.credentials.dig(:lantern, :api_key) || ENV["LANTERN_API_KEY"]
5
+
6
+ # Collection interval in seconds (default: 300 = 5 minutes)
7
+ # config.interval = 300
8
+
9
+ # Environments to collect in (default: production and staging)
10
+ # config.collect_in_environments = %w[production staging]
11
+ end
@@ -11,9 +11,24 @@ module Lantern
11
11
 
12
12
  config.after_initialize do
13
13
  config = Lantern::Rails.configuration
14
- next unless config.valid?
15
- next unless config.enabled
16
- next unless config.collect_in_environments.include?(::Rails.env.to_s)
14
+
15
+ unless config.valid?
16
+ ::Rails.logger.info(
17
+ "[Lantern] No API key configured. Get your free key at https://uselantern.dev " \
18
+ "then run: rails generate lantern:install"
19
+ )
20
+ next
21
+ end
22
+
23
+ unless config.enabled
24
+ ::Rails.logger.info("[Lantern] Disabled via configuration.")
25
+ next
26
+ end
27
+
28
+ unless config.collect_in_environments.include?(::Rails.env.to_s)
29
+ ::Rails.logger.info("[Lantern] Skipping collection in #{::Rails.env} environment.")
30
+ next
31
+ end
17
32
 
18
33
  runner = Lantern::Rails::Runner.new(config)
19
34
 
@@ -1,5 +1,5 @@
1
1
  module Lantern
2
2
  module Rails
3
- VERSION = "0.2.2"
3
+ VERSION = "0.3.0"
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.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Mumbower
@@ -29,6 +29,8 @@ extra_rdoc_files: []
29
29
  files:
30
30
  - LICENSE
31
31
  - README.md
32
+ - lib/generators/lantern/install_generator.rb
33
+ - lib/generators/lantern/templates/lantern.rb.tt
32
34
  - lib/lantern-rails.rb
33
35
  - lib/lantern/rails/collector.rb
34
36
  - lib/lantern/rails/configuration.rb