Installation
Warning: This is a community maintained crate, and is still under development. It is not officially supported by PostHog.
Install the posthog-rs crate by adding it to your Cargo.toml.
Next, set up the client with your PostHog project key.
Note: Currently, there is no way to customize the host that events are sent to, and we default to
app.posthog.com
Capturing events
You can send custom events using capture:
Tip: We recommend using a
[object] [verb]format for your event names, where[object]is the entity that the behavior relates to, and[verb]is the behavior itself. For example,project created,user signed up, orinvite sent.
Setting event properties
Optionally, you can also include additional information in the event by setting the properties value:
Batching events
To capture multiple events at once, use batch():
Feature flags
PostHog's feature flags enable you to safely deploy and roll back new features.
Feature flags are not supported yet in our community-maintained Rust SDK. However, you can integrate them into your project by using the PostHog API.