thinkingdata 0.2.0

Rust SDK for ThinkingData Analytics (TE): API entry (blocking & async) plus the `thinkingdata` CLI. Functional logic lives in thinkingdata-core.
Documentation

thinkingdata

Crates.io Documentation CI License Rust

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

[dependencies]
thinkingdata = { version = "0.2", features = ["blocking"] }  # default
# thinkingdata = { version = "0.2", features = ["async"] }   # async API
# thinkingdata = { version = "0.2", 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).

thinkingdata --log-dir /tmp/ta-logs track \
    --account-id acc_1 --event-name purchase \
    --properties '{"price": 9.9, "product_name": "book"}'

thinkingdata --server-url https://receiver.thinkingdata.io --app-id YOUR_APP_ID \
    track --account-id acc_1 --event-name login

thinkingdata --server-url https://receiver.thinkingdata.io --app-id YOUR_APP_ID --debug \
    user-set --account-id acc_1 --properties '{"vip": true}'

Commands: track, track-first, track-update, track-overwrite, user-set, user-set-once, user-add, user-append, user-uniq-append, user-unset, user-del. Every command flushes and closes the consumer before exiting, so buffered data is always delivered.

Documentation

License

Apache-2.0