Module: PostHog::Rails

Defined in:
lib/posthog/rails.rb,
lib/posthog/rails/railtie.rb,
lib/posthog/rails/active_job.rb,
lib/posthog/rails/configuration.rb,
lib/posthog/rails/error_subscriber.rb,
lib/posthog/rails/parameter_filter.rb,
lib/posthog/rails/capture_exceptions.rb,
lib/posthog/rails/rescued_exception_interceptor.rb

Defined Under Namespace

Modules: ActiveJobExtensions, ParameterFilter Classes: CaptureExceptions, Configuration, ErrorSubscriber, InitConfig, Railtie, RescuedExceptionInterceptor

Constant Summary collapse

VERSION =
PostHog::VERSION
IN_WEB_REQUEST_KEY =

Thread-local key for tracking web request context

:posthog_in_web_request

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject



18
19
20
# File 'lib/posthog/rails.rb', line 18

def config
  @config ||= Configuration.new
end

Class Method Details

.configure {|config| ... } ⇒ Object

Yields:



24
25
26
# File 'lib/posthog/rails.rb', line 24

def configure
  yield config if block_given?
end

.enter_web_requestObject

Mark that we’re in a web request context CaptureExceptions middleware will handle exception capture



30
31
32
# File 'lib/posthog/rails.rb', line 30

def enter_web_request
  Thread.current[IN_WEB_REQUEST_KEY] = true
end

.exit_web_requestObject

Clear web request context (called at end of request)



35
36
37
# File 'lib/posthog/rails.rb', line 35

def exit_web_request
  Thread.current[IN_WEB_REQUEST_KEY] = false
end

.in_web_request?Boolean

Check if we’re currently in a web request context Used by ErrorSubscriber to avoid duplicate captures

Returns:

  • (Boolean)


41
42
43
# File 'lib/posthog/rails.rb', line 41

def in_web_request?
  Thread.current[IN_WEB_REQUEST_KEY] == true
end