Class: PostHog::Rails::Configuration
- Inherits:
-
Object
- Object
- PostHog::Rails::Configuration
- Defined in:
- lib/posthog/rails/configuration.rb
Instance Attribute Summary collapse
-
#auto_capture_exceptions ⇒ Boolean
Whether to automatically capture exceptions from Rails.
-
#auto_instrument_active_job ⇒ Boolean
Whether to automatically instrument ActiveJob.
-
#capture_user_context ⇒ Boolean
Whether to capture the current user context in exceptions.
-
#current_user_method ⇒ Symbol
Method name to call on controller to get the current user.
-
#excluded_exceptions ⇒ Array<String>
Exception class names to ignore in addition to the defaults.
-
#report_rescued_exceptions ⇒ Boolean
Whether to capture exceptions that Rails rescues (e.g., with rescue_from).
-
#use_tracing_headers ⇒ Boolean
Whether to use PostHog tracing headers for request-scoped identity/session context.
-
#user_id_method ⇒ Symbol?
Method name to call on the user object to get distinct_id.
Instance Method Summary collapse
-
#default_excluded_exceptions ⇒ Array<String>
Default exceptions that Rails apps typically don’t want to track.
- #initialize ⇒ PostHog::Rails::Configuration constructor
-
#should_capture_exception?(exception) ⇒ Boolean
Whether the exception should be captured.
Constructor Details
#initialize ⇒ PostHog::Rails::Configuration
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/posthog/rails/configuration.rb', line 33 def initialize @auto_capture_exceptions = false @report_rescued_exceptions = false @auto_instrument_active_job = false @excluded_exceptions = [] @use_tracing_headers = true @capture_user_context = true @current_user_method = :current_user @user_id_method = nil end |
Instance Attribute Details
#auto_capture_exceptions ⇒ Boolean
Returns Whether to automatically capture exceptions from Rails. Defaults to false.
7 8 9 |
# File 'lib/posthog/rails/configuration.rb', line 7 def auto_capture_exceptions @auto_capture_exceptions end |
#auto_instrument_active_job ⇒ Boolean
Returns Whether to automatically instrument ActiveJob. Defaults to false.
13 14 15 |
# File 'lib/posthog/rails/configuration.rb', line 13 def auto_instrument_active_job @auto_instrument_active_job end |
#capture_user_context ⇒ Boolean
Returns Whether to capture the current user context in exceptions. Defaults to true.
23 24 25 |
# File 'lib/posthog/rails/configuration.rb', line 23 def capture_user_context @capture_user_context end |
#current_user_method ⇒ Symbol
Returns Method name to call on controller to get the current user. Defaults to :current_user.
26 27 28 |
# File 'lib/posthog/rails/configuration.rb', line 26 def current_user_method @current_user_method end |
#excluded_exceptions ⇒ Array<String>
Returns Exception class names to ignore in addition to the defaults.
16 17 18 |
# File 'lib/posthog/rails/configuration.rb', line 16 def excluded_exceptions @excluded_exceptions end |
#report_rescued_exceptions ⇒ Boolean
Returns Whether to capture exceptions that Rails rescues (e.g., with rescue_from). Defaults to false.
10 11 12 |
# File 'lib/posthog/rails/configuration.rb', line 10 def report_rescued_exceptions @report_rescued_exceptions end |
#use_tracing_headers ⇒ Boolean
Returns Whether to use PostHog tracing headers for request-scoped identity/session context. Defaults to true.
20 21 22 |
# File 'lib/posthog/rails/configuration.rb', line 20 def use_tracing_headers @use_tracing_headers end |
#user_id_method ⇒ Symbol?
Returns Method name to call on the user object to get distinct_id. When nil, tries: posthog_distinct_id, distinct_id, id, pk, uuid in order.
30 31 32 |
# File 'lib/posthog/rails/configuration.rb', line 30 def user_id_method @user_id_method end |
Instance Method Details
#default_excluded_exceptions ⇒ Array<String>
Default exceptions that Rails apps typically don’t want to track.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/posthog/rails/configuration.rb', line 47 def default_excluded_exceptions [ 'AbstractController::ActionNotFound', 'ActionController::BadRequest', 'ActionController::InvalidAuthenticityToken', 'ActionController::InvalidCrossOriginRequest', 'ActionController::MethodNotAllowed', 'ActionController::NotImplemented', 'ActionController::ParameterMissing', 'ActionController::RoutingError', 'ActionController::UnknownFormat', 'ActionController::UnknownHttpMethod', 'ActionDispatch::Http::Parameters::ParseError', 'ActiveRecord::RecordNotFound', 'ActiveRecord::RecordNotUnique' ] end |
#should_capture_exception?(exception) ⇒ Boolean
Returns Whether the exception should be captured.
67 68 69 70 |
# File 'lib/posthog/rails/configuration.rb', line 67 def should_capture_exception?(exception) exception_name = exception.class.name !all_excluded_exceptions.include?(exception_name) end |