use thinkingdata_core::consumer::BatchConsumer;
use thinkingdata_core::{TDAnalytics, TDError};
fn main() -> Result<(), TDError> {
let mut args = std::env::args().skip(1);
let server_url = args
.next()
.unwrap_or_else(|| "https://receiver.thinkingdata.io".to_string());
let app_id = args.next().unwrap_or_else(|| "YOUR_APP_ID".to_string());
let consumer = BatchConsumer::new(&server_url, &app_id)?;
let ta = TDAnalytics::new(consumer)?;
ta.set_super_properties(serde_json::json!({ "channel": "rust-example" }))?;
for i in 0..25 {
ta.track(
"account_id_123",
"batch_event",
serde_json::json!({
"index": i,
"#ip": "10.0.0.1",
}),
)?;
}
ta.close()?;
println!("uploaded 25 events to {server_url}");
Ok(())
}