1 unstable release

new 0.1.0 Apr 28, 2025

#4 in #post-hog

32 downloads per month

MIT license

18KB
362 lines

PostHog client library for Rust

This crate provides a client for interacting with PostHog analytics.


posthog514client-rs

A Rust client library for PostHog analytics.

Features

  • Async/await support
  • Type-safe event capture
  • Batch event support
  • Error handling and retries
  • Tracing support

Usage

Add this to your Cargo.toml:

[dependencies]
posthog514client-rs = "0.1.0"

Basic example:

use posthog514client_rs::{PostHogClient, Event};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = PostHogClient::new("your-api-key", "https://app.posthog.com");
    
    client.capture(Event::new("event_name")
        .set_distinct_id("user_123")
        .add_property("key", "value"))
        .await?;
    
    Ok(())
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Dependencies

~7–19MB
~262K SLoC