activerabbit-ai 0.6.0 → 0.6.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: f74f9015abfef72171776a4ffc3b2773ba9c065b988d9e4f8ee23e9cdd2b282e
4
- data.tar.gz: 4b28180c68924cc06116b19b21bc9b33f0d97f8ac3ed4caa68072c8efdff9fcd
3
+ metadata.gz: c71eb72533f7d6588444722f3ca8502230006f75bd12cee11b7f585e0a00aa1a
4
+ data.tar.gz: e187bb60976eda2eccd743589737240f40930897f6063c9ff6b061e517786135
5
5
  SHA512:
6
- metadata.gz: 0fb79f1162dc1648c9ffe8d6cc05e813b20f3674143acbf935ecc657c7e1273a4ba35a8f873bf87e1e4e491f579b22568d0f45898de1106947ad41973b7317a9
7
- data.tar.gz: f2bb325c0780e79160b6acbc4e6e10f98ca427459b58448562166d8c88cb5776e38c10fe3620d713945585ef0206f3a9465a04bdbec26c78ec47e0f78c1ba011
6
+ metadata.gz: 97ffc354514d50a73b8f32dd086e6d2a095bea00e0ce095464c7ea0a389fc8b1304359125a798abfabf4f456095aec51f3a086a2f6cb1d4c0d3eb5367d1744f0
7
+ data.tar.gz: dafed4a9c5c2de391bdc1527de3092340a093afdde7cc336a04c533c7d4898d5fad4987992fa3861dbbf806dd792eaa8e2a1037cc0a00133e235cd86747a4e3e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.6.2] - 2026-01-26
6
+
7
+ ### Fixed
8
+ - **ActionMailer deliver_later RuntimeError**: Fixed critical bug where `deliver_later` would raise `RuntimeError: You've accessed the message before asking to deliver it later`
9
+ - The patch was incorrectly accessing `message.subject` and `message.to` before calling `super`
10
+ - Rails requires that `message` is NOT accessed before `deliver_later` because only mailer method arguments are passed to the job
11
+ - Now only tracks safe metadata: `@mailer_class`, `@action`, and argument types
12
+ - Added error handling to ensure tracking failures don't break email delivery
13
+
14
+ ### Added
15
+ - **ActionMailer patch tests**: 18 comprehensive tests for the ActionMailer integration
16
+ - Verifies `deliver_later` does NOT access the message object
17
+ - Verifies `deliver_now` correctly tracks message details
18
+ - Tests error handling and edge cases
19
+
20
+ ## [0.6.1] - 2026-01-09
21
+
22
+ ### Fixed
23
+ - **Docker/Production path detection**: Fixed `in_app_frame?` to correctly detect app frames in Docker containers and production environments with absolute paths like `/app/app/controllers/...`
24
+
5
25
  ## [0.6.0] - 2026-01-09
6
26
 
7
27
  ### Added
@@ -14,7 +14,8 @@ module ActiveRabbit
14
14
  ActiveRabbit::Client.track_event(
15
15
  "email_sent",
16
16
  {
17
- mailer: self.class.name,
17
+ mailer_class: @mailer_class.name,
18
+ action: @action,
18
19
  message_id: (message.message_id rescue nil),
19
20
  subject: (message.subject rescue nil),
20
21
  to: (Array(message.to).first rescue nil),
@@ -24,11 +25,26 @@ module ActiveRabbit
24
25
  end
25
26
  end
26
27
 
27
- def deliver_later
28
- ActiveRabbit::Client.track_event(
29
- "email_enqueued",
30
- { mailer: self.class.name, subject: (message.subject rescue nil), to: (Array(message.to).first rescue nil) }
31
- ) if ActiveRabbit::Client.configured?
28
+ def deliver_later(...)
29
+ # IMPORTANT: Do NOT access `message` here!
30
+ # Rails raises RuntimeError if you access the message before deliver_later
31
+ # because only mailer method arguments are passed to the job.
32
+ # We can only safely access metadata that doesn't touch the message object.
33
+ if ActiveRabbit::Client.configured?
34
+ begin
35
+ ActiveRabbit::Client.track_event(
36
+ "email_enqueued",
37
+ {
38
+ mailer_class: @mailer_class.name,
39
+ action: @action,
40
+ args: @args&.map { |a| a.class.name }
41
+ }
42
+ )
43
+ rescue => e
44
+ # Don't let tracking failures break email delivery
45
+ Rails.logger.error "[ActiveRabbit] Failed to track email_enqueued: #{e.message}" if defined?(Rails) && Rails.logger
46
+ end
47
+ end
32
48
  super
33
49
  end
34
50
  end
@@ -156,16 +156,30 @@ module ActiveRabbit
156
156
  def in_app_frame?(file)
157
157
  return false if blank?(file)
158
158
 
159
- # In-app if it's in app/, lib/, or similar app directories
160
- # and NOT in gems or ruby stdlib
161
- (file.start_with?("app/") ||
162
- file.start_with?("lib/") ||
163
- file.start_with?("config/") ||
164
- (file.include?("/app/") && !file.include?("/gems/"))) &&
165
- !file.include?("/gems/") &&
166
- !file.include?("/ruby/") &&
167
- !file.include?("/rubygems/") &&
168
- !file.include?("/.bundle/")
159
+ # Exclude gem/library paths first (these are never in-app)
160
+ return false if file.include?("/gems/")
161
+ return false if file.include?("/bundle/")
162
+ return false if file.include?("/.bundle/")
163
+ return false if file.include?("/rubygems/")
164
+ # Exclude Ruby stdlib but not app paths that happen to have "ruby" in them
165
+ return false if file =~ %r{/ruby/\d+\.\d+\.\d+/}
166
+
167
+ # In-app patterns (common Rails app structures)
168
+ # Relative paths
169
+ return true if file.start_with?("app/")
170
+ return true if file.start_with?("lib/")
171
+ return true if file.start_with?("config/")
172
+
173
+ # Absolute paths in Docker/production (e.g., /app/app/controllers/...)
174
+ # Match paths that contain /app/ followed by typical app directories
175
+ return true if file =~ %r{/app/(controllers|models|services|jobs|views|helpers|mailers|workers|channels)/}
176
+ return true if file =~ %r{/lib/[^/]+\.rb$}
177
+ return true if file =~ %r{/config/}
178
+
179
+ # Generic: path contains /app/ but not in excluded paths (already checked above)
180
+ return true if file.include?("/app/") && file.end_with?(".rb")
181
+
182
+ false
169
183
  end
170
184
 
171
185
  def classify_frame(file)
@@ -1,5 +1,5 @@
1
1
  module ActiveRabbit
2
2
  module Client
3
- VERSION = "0.6.0"
3
+ VERSION = "0.6.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerabbit-ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Shapalov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-01-10 00:00:00.000000000 Z
11
+ date: 2026-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -81,7 +81,6 @@ files:
81
81
  - README.md
82
82
  - Rakefile
83
83
  - TESTING_GUIDE.md
84
- - activerabbit-ai-0.4.5.gem
85
84
  - check_api_data.rb
86
85
  - examples/rails_app_testing.rb
87
86
  - examples/rails_integration.rb
Binary file