Class: PostHog::Rails::Railtie

Inherits:
Rails::Railtie
  • Object
show all
Defined in:
lib/posthog/rails/railtie.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.rails_version_above_7?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


161
162
163
# File 'lib/posthog/rails/railtie.rb', line 161

def self.rails_version_above_7?
  ::Rails.version.to_f >= 7.0
end

.register_error_subscribervoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



149
150
151
152
153
154
155
156
157
# File 'lib/posthog/rails/railtie.rb', line 149

def self.register_error_subscriber
  return unless PostHog::Rails.config&.auto_capture_exceptions

  subscriber = PostHog::Rails::ErrorSubscriber.new
  ::Rails.error.subscribe(subscriber)
rescue StandardError => e
  PostHog::Logging.logger.warn("Failed to register error subscriber: #{e.message}")
  PostHog::Logging.logger.warn("Backtrace: #{e.backtrace&.first(5)&.join("\n")}")
end

Instance Method Details

#insert_middleware_after(app, target, middleware) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



131
132
133
134
135
136
# File 'lib/posthog/rails/railtie.rb', line 131

def insert_middleware_after(app, target, middleware)
  # During initialization, app.config.middleware is a MiddlewareStackProxy
  # which only supports recording operations (insert_after, use, etc.)
  # and does NOT support query methods like include?.
  app.config.middleware.insert_after(target, middleware)
end

#insert_middleware_before(app, target, middleware) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



140
141
142
143
144
145
# File 'lib/posthog/rails/railtie.rb', line 140

def insert_middleware_before(app, target, middleware)
  # During initialization, app.config.middleware is a MiddlewareStackProxy
  # which only supports recording operations (insert_before, use, etc.)
  # and does NOT support query methods like include?.
  app.config.middleware.insert_before(target, middleware)
end