
PostHog Ruby
https://github.com/posthog/posthog-ruby- Category
- Developer Tools
- Rank
- No. 431Tools index
- Pricing
- Open Source
- Type
- TOOL
- Builder
- posthog
- GitHub
- 36 stars
- Latest release
- posthog-ruby-v3.23.7
- Date
About
Official PostHog SDK for Ruby — send product analytics events from Ruby applications.
What it does
PostHog Ruby turns application activity into structured PostHog messages, then queues and batches them for HTTP delivery. It also handles identity and group records, aliases, exception capture, and feature flag evaluation. Delivery can run in a background worker or synchronously for forking environments.
Why it's ranked here
This is a credible choice for Ruby backends because it covers both event delivery and feature flags with production-minded controls. Batching, gzip compression, retry backoff, bounded queues, persistent connections, error callbacks, and explicit shutdown behavior address practical server concerns. Rails-aware logging and dedicated framework documentation strengthen the fit.
What's good
The delivery path is unusually explicit. Events receive validated identifiers and normalized timestamps, then enter size-limited batches. Retryable server errors, timeouts, and rate limits trigger backoff, including support for server-provided retry timing. Teams can filter or modify events before sending, choose synchronous delivery, flush pending work, and use local feature flag definitions with distributed caching.
Tradeoffs
The default asynchronous path requires lifecycle care: applications must flush or shut down cleanly, and multiple clients sharing an API key can drop events. Remote feature flag evaluation and flag retries can block the calling thread. Asynchronous flag loading may initially return no local result or fall back remotely. Usage examples live outside the repository, so offline discovery is limited.
How to use it well
Use it in a long-running Ruby or Rails service that needs backend events, identity updates, group data, exception capture, and server-side feature flags. Create one reusable client per API key, configure error handling, and flush during orderly shutdown. Choose synchronous delivery for forking job systems. It does not provide the analytics service itself or replace separate client-side instrumentation.
Technical notes+
lib/posthog/client.rb owns queueing, sync mode, worker lifecycle, feature flag polling, callbacks, and singleton warnings. lib/posthog/send_worker.rb builds bounded batches on a background thread and resets transport state after a fork. lib/posthog/transport.rb uses Net::HTTP with persistent connections, gzip, mutex protection, retry backoff, and Retry-After parsing. Limits and intervals live in lib/posthog/defaults.rb; lib/posthog/field_parser.rb validates fields, generates UUIDs, converts dates, and constructs capture, identify, group, and alias payloads. lib/posthog/logging.rb selects Rails logging when available.
Observed
- License
- MIT
- Primary language
- Ruby
- Install surface
- RubyGems and Bundler gem dependency surface
- Interface
- Ruby library
- Framework support
- Dedicated Ruby on Rails documentation is linked
- Transport
- HTTPS batch API client built on Ruby Net::HTTP
- Release tooling
- Private pnpm workspace uses Changesets for release metadata
Read from README.md, Gemfile, package.json, lib/posthog.rb, lib/posthog/utils.rb, lib/posthog/client.rb, lib/posthog/logging.rb, lib/posthog/version.rb, lib/posthog/defaults.rb, lib/posthog/response.rb, lib/posthog/transport.rb, lib/posthog/noop_worker.rb, lib/posthog/send_worker.rb, lib/posthog/feature_flag.rb, lib/posthog/field_parser.rb.
What it can do
Send product analytics events
Ruby application code and user interaction data → Analytics events transmitted to PostHog
Track user behavior
User actions and identifiers → Tracked behavioral data in PostHog dashboard
Capture custom events
Event names and properties from Ruby code → Custom event data stored in PostHog
Identify users
User ID and user properties → User profiles created/updated in PostHog
Set user properties
User attributes and metadata → Updated user property data in PostHog
Track page views
Page URLs and user session data → Page view analytics in PostHog
Tags
Tech Stack
Media

Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.