thinkingdata
Rust SDK for ThinkingData Analytics — API entry (blocking & async)
plus the thinkingdata CLI. All functional logic lives in
thinkingdata-core; this crate re-exports it and adds
the command line client.
The workspace overview, relationship to the official Go SDK, and bilingual data-format guides live in the root README.
Installation
[]
= { = "0.1", = ["blocking"] } # default
# thinkingdata = { version = "0.1", features = ["async"] } # async API
# thinkingdata = { version = "0.1", features = ["full"] } # both
Quick start
Blocking
use thinkingdata::{TDAnalytics, consumer::LogConsumer};
# fn main() -> Result<(), thinkingdata::TDError> {
let consumer = LogConsumer::new("/path/to/log/directory")?;
let ta = TDAnalytics::new(consumer)?;
ta.track("account_id_123", "purchase", serde_json::json!({
"product_name": "Rust SDK",
"price": 99.0,
}))?;
ta.close()?;
# Ok(())
# }
Async
# #[cfg(feature = "async")]
# async fn demo() -> Result<(), thinkingdata::TDError> {
use thinkingdata::{TDAnalyticsAsync, consumer::BatchConsumer};
let consumer = BatchConsumer::new("https://receiver.thinkingdata.io", "your_app_id")?;
let ta = TDAnalyticsAsync::new(consumer)?;
ta.track("account_id_123", "purchase", serde_json::json!({ "price": 99.0 })).await?;
ta.close().await?;
# Ok(())
# }
CLI
The same crate name doubles as the thinkingdata binary. Pick exactly one consumer:
--log-dir, --server-url (+ --app-id), or --debug (+ --app-id).
Commands: track, track-first, track-update, track-overwrite, user-set, user-set-once,
user-add, user-append, user-uniq-append, user-unset, user-del, flush, close.
Documentation
- Workspace README — full API tour and consumers
- Data rules (EN / 中文)
- Official docs: https://docs-v2.thinkingdata.cn/?code=data_format&lan=zh-CN&version=5.0
License
Apache-2.0