Skip to main content

rust_umami/
lib.rs

1//! A small, typed client for Umami's public analytics ingestion API.
2//!
3//! `rust-umami` intentionally focuses on sending analytics. It never logs in,
4//! stores an API key, or calls Umami's reporting and administration APIs.
5//!
6//! # Quick start
7//!
8//! ```no_run
9//! use rust_umami::Client;
10//! use serde_json::json;
11//!
12//! # async fn example() -> rust_umami::Result<()> {
13//! let umami = Client::new(
14//!     "https://analytics.example.com",
15//!     "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
16//! )?;
17//!
18//! umami
19//!     .event("signup")
20//!     .url("/pricing")
21//!     .data(json!({ "plan": "pro" }))
22//!     .send()
23//!     .await?;
24//! # Ok(())
25//! # }
26//! ```
27//!
28//! A [`Client`] is stateless and safe to reuse across visitors. For a sequence
29//! of calls from one visitor, create a [`Session`]; it transparently reuses
30//! Umami's cache value while remaining isolated from other sessions.
31
32#![forbid(unsafe_code)]
33#![warn(missing_docs)]
34
35mod client;
36mod context;
37mod error;
38mod event;
39mod response;
40
41pub use client::{Batch, CLOUD_ENDPOINT, Client, ClientBuilder, Session};
42pub use context::Context;
43pub use error::{ApiError, Error, Result};
44pub use event::{Track, TrackKind};
45pub use response::{BatchError, BatchResponse, TrackResponse};
46
47/// Re-export of `serde_json` for convenient use with [`serde_json::json!`].
48pub use serde_json;