Class: PostHog::Rails::Configuration
- Inherits:
-
Object
- Object
- PostHog::Rails::Configuration
- Defined in:
- lib/posthog/rails/configuration.rb
Instance Attribute Summary collapse
-
#auto_capture_exceptions ⇒ Object
Whether to automatically capture exceptions from Rails.
-
#auto_instrument_active_job ⇒ Object
Whether to automatically instrument ActiveJob.
-
#capture_user_context ⇒ Object
Whether to capture the current user context in exceptions.
-
#current_user_method ⇒ Object
Method name to call on controller to get user ID (default: :current_user).
-
#excluded_exceptions ⇒ Object
List of exception classes to ignore (in addition to default).
-
#report_rescued_exceptions ⇒ Object
Whether to capture exceptions that Rails rescues (e.g., with rescue_from).
-
#user_id_method ⇒ Object
Method name to call on user object to get distinct_id (default: auto-detect) When nil, tries: posthog_distinct_id, distinct_id, id, pk, uuid in order.
Instance Method Summary collapse
-
#default_excluded_exceptions ⇒ Object
Default exceptions that Rails apps typically don’t want to track.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #should_capture_exception?(exception) ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
28 29 30 31 32 33 34 35 36 |
# File 'lib/posthog/rails/configuration.rb', line 28 def initialize @auto_capture_exceptions = false @report_rescued_exceptions = false @auto_instrument_active_job = false @excluded_exceptions = [] @capture_user_context = true @current_user_method = :current_user @user_id_method = nil end |
Instance Attribute Details
#auto_capture_exceptions ⇒ Object
Whether to automatically capture exceptions from Rails
7 8 9 |
# File 'lib/posthog/rails/configuration.rb', line 7 def auto_capture_exceptions @auto_capture_exceptions end |
#auto_instrument_active_job ⇒ Object
Whether to automatically instrument ActiveJob
13 14 15 |
# File 'lib/posthog/rails/configuration.rb', line 13 def auto_instrument_active_job @auto_instrument_active_job end |
#capture_user_context ⇒ Object
Whether to capture the current user context in exceptions
19 20 21 |
# File 'lib/posthog/rails/configuration.rb', line 19 def capture_user_context @capture_user_context end |
#current_user_method ⇒ Object
Method name to call on controller to get user ID (default: :current_user)
22 23 24 |
# File 'lib/posthog/rails/configuration.rb', line 22 def current_user_method @current_user_method end |
#excluded_exceptions ⇒ Object
List of exception classes to ignore (in addition to default)
16 17 18 |
# File 'lib/posthog/rails/configuration.rb', line 16 def excluded_exceptions @excluded_exceptions end |
#report_rescued_exceptions ⇒ Object
Whether to capture exceptions that Rails rescues (e.g., with rescue_from)
10 11 12 |
# File 'lib/posthog/rails/configuration.rb', line 10 def report_rescued_exceptions @report_rescued_exceptions end |
#user_id_method ⇒ Object
Method name to call on user object to get distinct_id (default: auto-detect) When nil, tries: posthog_distinct_id, distinct_id, id, pk, uuid in order
26 27 28 |
# File 'lib/posthog/rails/configuration.rb', line 26 def user_id_method @user_id_method end |
Instance Method Details
#default_excluded_exceptions ⇒ Object
Default exceptions that Rails apps typically don’t want to track
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/posthog/rails/configuration.rb', line 39 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
57 58 59 60 |
# File 'lib/posthog/rails/configuration.rb', line 57 def should_capture_exception?(exception) exception_name = exception.class.name !all_excluded_exceptions.include?(exception_name) end |