posthog-rails 3.25.0 → 3.26.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 62688682822ecffd3e7668d9a4b292e7e889310fafcba3620ac20d42fcd52eea
|
|
4
|
+
data.tar.gz: 9881804df38ee8b592706cb9d0fe7674a830cb2fd2bdd99b41b2801ec71ec3fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f4eef09ec66390025914f6bcdd1a5376eba61a42590d6f2216e6ed28136613e75af1ac8d2b22c7f47c186233f90a02246f6f26ec2489202969f2b5e051de750a
|
|
7
|
+
data.tar.gz: 1b5619fac23a9481a63029640cb3ea0d2272af67f4e4ee7b20b4ace058a33c2d0b33f6b5d01739e7bd5b8d23cb0d808b89110467d32d3ae313bf73eeaf285ef3
|
|
@@ -49,7 +49,8 @@ PostHog::Rails.configure do |config|
|
|
|
49
49
|
# config.current_user_resolver = proc { |controller| controller.current_user }
|
|
50
50
|
|
|
51
51
|
# Additional exception classes to exclude from reporting
|
|
52
|
-
# These are added to the default excluded exceptions
|
|
52
|
+
# These are added to the default excluded exceptions. Subclasses of a listed
|
|
53
|
+
# class are excluded too, and so is any exception whose cause chain contains one.
|
|
53
54
|
# config.excluded_exceptions = [
|
|
54
55
|
# # 'MyCustom404Error',
|
|
55
56
|
# # 'MyCustomValidationError'
|
|
@@ -178,7 +178,6 @@ module PostHog
|
|
|
178
178
|
config = PostHog::Rails.config
|
|
179
179
|
return unless config&.auto_instrument_active_job && config.report_active_job_retries && exception
|
|
180
180
|
return unless PostHog.initialized? && PostHog.client.enabled?
|
|
181
|
-
return if excluded_posthog_retry?(exception, config)
|
|
182
181
|
|
|
183
182
|
Internal::Context.with_context(
|
|
184
183
|
@posthog_execution_context || posthog_job_context, fresh: true, enrich_current_span: false
|
|
@@ -189,20 +188,9 @@ module PostHog
|
|
|
189
188
|
PostHog::Logging.logger.error("Failed to capture job retry: #{e.class}")
|
|
190
189
|
end
|
|
191
190
|
|
|
192
|
-
def excluded_posthog_retry?(exception, config)
|
|
193
|
-
seen = {}.compare_by_identity
|
|
194
|
-
current = exception
|
|
195
|
-
while current && seen.size < PostHog::ExceptionCapture::MAX_CHAINED_EXCEPTIONS && !seen.key?(current)
|
|
196
|
-
return true unless config.should_capture_exception?(current)
|
|
197
|
-
|
|
198
|
-
seen[current] = true
|
|
199
|
-
current = current.respond_to?(:cause) ? current.cause : nil
|
|
200
|
-
end
|
|
201
|
-
false
|
|
202
|
-
end
|
|
203
|
-
|
|
204
191
|
def capture_job_exception(exception, retry_failure: false)
|
|
205
192
|
return unless PostHog::Rails.config&.auto_instrument_active_job
|
|
193
|
+
return unless PostHog::Rails.config&.should_capture_exception?(exception)
|
|
206
194
|
|
|
207
195
|
# Build distinct_id from job arguments if possible
|
|
208
196
|
distinct_id = if @posthog_execution_context
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
# Copyright (c) 2020 Sentry
|
|
5
5
|
# Licensed under the MIT License: https://github.com/getsentry/sentry-ruby/blob/master/LICENSE
|
|
6
6
|
|
|
7
|
+
require 'posthog/exception_capture'
|
|
8
|
+
|
|
7
9
|
module PostHog
|
|
8
10
|
module Rails
|
|
9
11
|
class Configuration
|
|
@@ -23,7 +25,8 @@ module PostHog
|
|
|
23
25
|
# Defaults to false.
|
|
24
26
|
attr_accessor :report_active_job_retries
|
|
25
27
|
|
|
26
|
-
# @return [Array<String>] Exception class names to ignore in addition to the defaults.
|
|
28
|
+
# @return [Array<String>] Exception class names to ignore in addition to the defaults. Subclasses are
|
|
29
|
+
# ignored too, and so is any exception whose cause chain contains a listed class.
|
|
27
30
|
attr_accessor :excluded_exceptions
|
|
28
31
|
|
|
29
32
|
# @return [Boolean] Whether to use PostHog tracing headers for request-scoped identity/session context.
|
|
@@ -117,8 +120,10 @@ module PostHog
|
|
|
117
120
|
# @param exception [Exception] The exception to check.
|
|
118
121
|
# @return [Boolean] Whether the exception should be captured.
|
|
119
122
|
def should_capture_exception?(exception)
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
excluded = all_excluded_exceptions
|
|
124
|
+
exception_chain(exception).none? do |error|
|
|
125
|
+
error.class.ancestors.any? { |ancestor| excluded.include?(ancestor.name) }
|
|
126
|
+
end
|
|
122
127
|
end
|
|
123
128
|
|
|
124
129
|
private
|
|
@@ -126,6 +131,15 @@ module PostHog
|
|
|
126
131
|
def all_excluded_exceptions
|
|
127
132
|
default_excluded_exceptions + excluded_exceptions
|
|
128
133
|
end
|
|
134
|
+
|
|
135
|
+
def exception_chain(exception)
|
|
136
|
+
chain = []
|
|
137
|
+
while exception.is_a?(Exception) && chain.size < ExceptionCapture::MAX_CHAINED_EXCEPTIONS
|
|
138
|
+
chain << exception
|
|
139
|
+
exception = exception.cause
|
|
140
|
+
end
|
|
141
|
+
chain
|
|
142
|
+
end
|
|
129
143
|
end
|
|
130
144
|
end
|
|
131
145
|
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.
|
|
4
|
+
version: 3.26.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.
|
|
32
|
+
version: 3.32.2
|
|
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.32.
|
|
39
|
+
version: 3.32.2
|
|
40
40
|
description: Automatic exception tracking and instrumentation for Ruby on Rails applications
|
|
41
41
|
using PostHog
|
|
42
42
|
email: engineering@posthog.com
|