Installation
Install the leanbase-rs crate by adding it to your Cargo.toml.
Next, set up the client with your Leanbase project key.
Blocking client
Our Rust SDK supports both blocking and async clients. The async client is the default and is recommended for most use cases.
If you need to use a synchronous client instead – like we do in our CLI –, you can opt into it by disabling the asynchronous feature on your Cargo.toml file.
In blocking mode, calls to capture and related methods will block until the Leanbas event capture API returns – generally this is on the order of tens of milliseconds, but you may want to thread::spawn a background thread when you send an event.
Capturing events
You can send custom events using capture:
💡 Tip: Use an [object] [verb] format for event names, where object is what the behavior relates to and verb is the action.
Examples: project_created, user_signed_up, invite_sent.
Setting event properties
Optionally, you can include additional information with the event by adding a properties object:
Batching events
To capture multiple events at once, use batch():