
PostHog Rust
https://github.com/posthog/posthog-rs- Category
- Developer Tools
- Rank
- No. 425Tools index
- Pricing
- Open Source
- Type
- TOOL
- Builder
- PostHog
- GitHub
- 62 stars
- Latest release
- 0.25.4
- Date
About
Official PostHog SDK for sending product analytics events from Rust applications.
What it does
It instruments Rust services with identified or anonymous events, then batches delivery through a background worker with retries. It also evaluates feature flags remotely or from cached definitions, attaches flag state to events, and can report errors and panics.
Why it's ranked here
This is a substantial server-side integration rather than a thin HTTP wrapper. It supports asynchronous and blocking applications, local flag evaluation, group targeting, configurable endpoints, delivery compression, and error tracking. The main caveat is that normal event delivery intentionally hides failures from the calling code.
What's good
The event model handles custom properties, groups, historical timestamps, stable identifiers, and anonymous activity without creating person profiles. Flag snapshots can be reused when enriching events, avoiding another flag request. Local evaluation supports cohorts, dependencies, percentage rollouts, multivariate variants, and cached regular expressions.
Tradeoffs
Fire-and-forget capture returns before persistence, so applications must register an error callback when delivery failures matter. Process-global use requires an explicit flush or shutdown before exit. Panic capture is opt-in and process-wide. Additional compression formats require the optional newer capture protocol.
How to use it well
Use it in Rust backends that need analytics, server-side feature decisions, or exception reporting within one instrumentation layer. Prefer queued capture for routine traffic, then flush during orderly shutdown. Use immediate delivery only when durable application progress depends on confirmed ingestion. It does not replace PostHog project administration.
Technical notes+
Cargo.toml packages the library as posthog-rs, uses Rust edition 2018, declares MIT licensing, and enables async-client plus error-tracking by default. src/lib.rs re-exports the client, event, flag, local-evaluation, endpoint, and error-tracking surfaces. src/global.rs stores a process-wide Client in OnceLock; because that static never drops, callers must invoke flush() or shutdown() to drain queued work. src/event.rs serializes event properties, groups, UTC timestamps, and UUIDv7 identifiers. src/local_evaluation.rs provides blocking and async definition pollers backed by shared caches. src/compression.rs always includes gzip, while deflate, Brotli, and Zstandard are gated by capture-v1. src/error.rs maps authentication, billing, rate-limit, request, and server responses into a non-exhaustive error enum.
Observed
- License
- MIT
- Primary language
- Rust
- Packaging
- Published as the posthog-rs Cargo crate
- Interface
- Rust library with blocking and asynchronous client modes
- Default features
- Asynchronous client and error tracking
- Endpoint support
- US and EU ingestion hosts plus custom reverse-proxy hosts
- Workspace structure
- Root crate plus a compliance adapter workspace member
Read from README.md, Cargo.toml, src/lib.rs, src/error.rs, src/event.rs, src/global.rs, src/event_v1.rs, src/constants.rs, src/endpoints.rs, src/compression.rs, src/feature_flags.rs, src/error_tracking.rs, src/local_evaluation.rs.
What it can do
Track user events in Rust applications
Event data and user identifiers → Analytics events sent to PostHog
Identify users for analytics tracking
User ID and optional user properties → User identification data in PostHog
Capture custom properties with events
Event name and custom property key-value pairs → Enriched analytics events with metadata
Send feature flag evaluations
Feature flag key and user context → Feature flag usage analytics
Batch multiple analytics events
Multiple event objects → Batched event payload sent to PostHog API
Configure SDK settings
API key, host URL, and configuration options → Initialized PostHog client instance
Tags
Tech Stack
Media

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