Analytics SDK for Rust services and backend applications.
- initialization with a
public_key - automatic
uuidgeneration when one is not provided - support for your own
uuidduring initialization - user attribute create/update flow
- user event delivery
- in-memory storage by default, with pluggable storage support
- Rust-friendly request context helpers
The SDK sends requests to:
https://api.a-track.ioby defaulthttps://<geo>.api.a-track.iowhengeois provided
Authentication/project routing header:
x-a-track-key: <public_key>
Default endpoints:
/init/attributes/event
use a_track_sdk::{ATrackSdk, EventPayload, Options, UserContext, InitPayload};
fn example() -> Result<(), Box<dyn std::error::Error>> {
let mut options = Options::new("pub_xxxxx");
options.geo = Some("fra".to_string());
let mut sdk = ATrackSdk::new(options);
sdk.init(Some(InitPayload {
user: Some(UserContext {
uuid: Some("server-user-42".to_string()),
attributes: None,
}),
..Default::default()
}))?;
sdk.track(EventPayload {
event: "order_created".to_string(),
..Default::default()
})?;
Ok(())
}You can initialize without passing a user uuid, let the SDK generate one, and then read it back:
let result = sdk.init(None)?;
let uuid_from_init = result.uuid.clone();
let current_user = sdk.get_user();
let same_uuid = current_user.map(|user| user.uuid);Later, anywhere else in your code, you can track an event with that explicit uuid:
sdk.track(EventPayload {
event: "job_processed".to_string(),
uuid: Some(uuid_from_init),
..Default::default()
})?;use a_track_sdk::{build_rust_init_payload, Attributes, Options, RequestContextInput, ATrackSdk};
use serde_json::json;
fn example() -> Result<(), Box<dyn std::error::Error>> {
let mut attrs = Attributes::new();
attrs.insert("plan".to_string(), json!("pro"));
let payload = build_rust_init_payload(RequestContextInput {
url: Some("/pricing?source=google".to_string()),
referer: Some("https://google.com".to_string()),
ip_address: Some("134.122.17.144".to_string()),
user_agent: Some("rust-service/1.0".to_string()),
locale: Some("en-US".to_string()),
timezone: Some("America/New_York".to_string()),
uuid: Some("crm-user-42".to_string()),
user_attributes: Some(attrs),
..Default::default()
});
let mut sdk = ATrackSdk::new(Options::new("pub_xxxxx"));
sdk.init(Some(payload))?;
Ok(())
}use serde_json::json;
use a_track_sdk::Attributes;
let mut attrs = Attributes::new();
attrs.insert("plan".to_string(), json!("business"));
attrs.insert("seats".to_string(), json!(12));
sdk.set_attributes(attrs, false)?;set_attributes() sends data to /attributes.
You can also read the current initialized user at any time:
let current_user = sdk.get_user();POST /init
{
"sdkVersion": "0.1.0",
"uuid": "0d54...",
"isNewUser": true,
"mode": "merge",
"context": {},
"attributes": {},
"profile": {}
}POST /attributes
{
"sdkVersion": "0.1.0",
"uuid": "0d54...",
"mode": "merge",
"attributes": {
"plan": "business"
},
"profile": {}
}POST /event
{
"sdkVersion": "0.1.0",
"uuid": "0d54...",
"event": "invoice_paid",
"attributes": {},
"timestamp": "2026-04-08T12:00:00.000Z",
"context": {}
}