Ruby Error Tracking installation
Install with the wizard
Run this command in your project directory to add PostHog to your Ruby project. The wizard detects your framework, installs the SDK, and sets up your first events.
Or set it up manually by following the rest of this guide.
- 1
Install the gem
RequiredAdd the PostHog Ruby gem to your Gemfile:
Gemfile - 2
Configure PostHog
RequiredInitialize the PostHog client with your project token and host:
Ruby - 3
Send events
RecommendedOnce installed, you can manually send events to test your integration:
Ruby - 4
Manually capture exceptions
RequiredUsing Ruby on Rails? The
posthog-railsgem provides automatic exception capture for controllers and background jobs. Select "Ruby on Rails" from the SDK list for setup instructions.To capture exceptions in your Ruby application, use the
capture_exceptionmethod:RubyThe
capture_exceptionmethod accepts the following parameters:Param Type Description exceptionExceptionThe exception object to capture (required) distinct_idStringThe distinct ID of the user (optional) additional_propertiesHashAdditional properties to attach to the exception event (optional) - 5













