posthog-rails 3.16.0 → 3.16.1

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: 3c51754943601dbb009cc9716c8c12da1efa7e363d69518c7e416315113f92bc
4
- data.tar.gz: c50976aa271a002b8a24f7bf1cb905d5f8fcfe2f00fda0eb1ff9009142b525ec
3
+ metadata.gz: 44157c9a21df891144651b960ef47e0509447c0029f195bf7b6c6541c6161643
4
+ data.tar.gz: 12b7bc3788737a7937055171018c7c7223eac6def2e1a92d79f486b11b0a7416
5
5
  SHA512:
6
- metadata.gz: 5c7a7e3fe38ff16dcdfe1ececce1928d3c9d79825180c922c15f9ab047df8b81e5fd338367095160ee8960d3725ca9ff30e7b83fad12957ae6d00720f3a3680e
7
- data.tar.gz: f174fd1bd044c1b681afbb1e06d3521ccc4c129c2bb6b4ae9d5feb86f0e818d88fee1b50c4fff9c5ceaca0b0c52e7f1f1e4469bfb0324e6d8f0829f9bf072953
6
+ metadata.gz: c4c0c7c9a800b995d6e1cb94d37e9c96fe02979351302bb121833cdc0fa5d39d17e44596eb035c3cb3a69382363080d8888d1cc126afa3d53ffcd6ccd257353e
7
+ data.tar.gz: f040d3d016adb9729315426030071fcc1f15c0a2c9b9d4091e828e5fe1878fe51ff92660c4e28fe4cdd6b5eb561974dd1e44f10a3aaa9146fa36ace5f0a05629
@@ -70,6 +70,7 @@ module PostHog
70
70
  properties,
71
71
  mechanism: { 'type' => 'active_job', 'handled' => false }
72
72
  )
73
+ PostHog::Rails.mark_active_job_exception_captured(exception)
73
74
  rescue StandardError => e
74
75
  # Don't let PostHog errors break job processing
75
76
  PostHog::Logging.logger.error("Failed to capture job exception: #{e.message}")
@@ -23,6 +23,8 @@ module PostHog
23
23
  # Skip if in a web request - CaptureExceptions middleware will handle it
24
24
  # with richer context (URL, params, controller, etc.)
25
25
  return if PostHog::Rails.in_web_request?
26
+ return if PostHog::Rails.config&.auto_instrument_active_job &&
27
+ PostHog::Rails.active_job_exception_captured?(error)
26
28
 
27
29
  distinct_id = context[:user_id] || context[:distinct_id]
28
30
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module PostHog
4
4
  module Rails
5
- VERSION = '3.16.0'
5
+ VERSION = '3.16.1'
6
6
  end
7
7
  end
data/lib/posthog/rails.rb CHANGED
@@ -20,6 +20,9 @@ module PostHog
20
20
  module Rails
21
21
  # Thread-local key for tracking web request context
22
22
  IN_WEB_REQUEST_KEY = :posthog_in_web_request
23
+ ACTIVE_JOB_CAPTURED_EXCEPTION_IVAR = :@posthog_active_job_exception_captured
24
+
25
+ private_constant :ACTIVE_JOB_CAPTURED_EXCEPTION_IVAR
23
26
 
24
27
  class << self
25
28
  # @return [PostHog::Rails::Configuration] Rails integration configuration.
@@ -60,6 +63,28 @@ module PostHog
60
63
  def in_web_request?
61
64
  Thread.current[IN_WEB_REQUEST_KEY] == true
62
65
  end
66
+
67
+ # Mark an exception as already captured by the ActiveJob integration.
68
+ # Used by ErrorSubscriber to avoid duplicate captures when Rails reports
69
+ # the same re-raised job exception via Rails.error.
70
+ # @api private
71
+ # @param exception [Exception]
72
+ # @return [void]
73
+ def mark_active_job_exception_captured(exception)
74
+ exception.instance_variable_set(ACTIVE_JOB_CAPTURED_EXCEPTION_IVAR, true)
75
+ rescue StandardError
76
+ nil
77
+ end
78
+
79
+ # Check whether an exception was already captured by ActiveJobExtensions.
80
+ # @api private
81
+ # @param exception [Exception]
82
+ # @return [Boolean]
83
+ def active_job_exception_captured?(exception)
84
+ exception.instance_variable_get(ACTIVE_JOB_CAPTURED_EXCEPTION_IVAR) == true
85
+ rescue StandardError
86
+ false
87
+ end
63
88
  end
64
89
  end
65
90
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posthog-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.16.0
4
+ version: 3.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PostHog
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - '='
31
31
  - !ruby/object:Gem::Version
32
- version: 3.16.0
32
+ version: 3.17.0
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 3.16.0
39
+ version: 3.17.0
40
40
  description: Automatic exception tracking and instrumentation for Ruby on Rails applications
41
41
  using PostHog
42
42
  email: engineering@posthog.com