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 +4 -4
- data/lib/posthog/rails/active_job.rb +1 -0
- data/lib/posthog/rails/error_subscriber.rb +2 -0
- data/lib/posthog/rails/version.rb +1 -1
- data/lib/posthog/rails.rb +25 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 44157c9a21df891144651b960ef47e0509447c0029f195bf7b6c6541c6161643
|
|
4
|
+
data.tar.gz: 12b7bc3788737a7937055171018c7c7223eac6def2e1a92d79f486b11b0a7416
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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
|