pub struct Track { /* private fields */ }Expand description
A fluent analytics track ready to send.
Create tracks through crate::Client or crate::Session. Calling
Track::data serializes eagerly but, like reqwest::RequestBuilder, any
serialization error is reported when Track::send is awaited. This keeps
fluent call sites free of an extra intermediate Result.
Implementations§
Source§impl Track
impl Track
Sourcepub fn distinct_id(self, distinct_id: impl Into<String>) -> Self
pub fn distinct_id(self, distinct_id: impl Into<String>) -> Self
Sets a stable distinct ID.
Sourcepub fn user_agent(self, user_agent: impl Into<String>) -> Self
pub fn user_agent(self, user_agent: impl Into<String>) -> Self
Sets the original visitor user agent.
Sourcepub fn at(self, time: SystemTime) -> Self
pub fn at(self, time: SystemTime) -> Self
Sets the event time from a SystemTime.
Sourcepub fn data(self, data: impl Serialize) -> Self
pub fn data(self, data: impl Serialize) -> Self
Attaches event or session properties from any serializable JSON object.
Umami requires an object at the top level. Nested values, arrays, booleans, numbers, strings, and date strings are supported.
Sourcepub fn clear_data(self) -> Self
pub fn clear_data(self) -> Self
Removes previously attached properties.
Sourcepub fn continue_from(self, response: &TrackResponse) -> Self
pub fn continue_from(self, response: &TrackResponse) -> Self
Reuses the cache value from a previous response.
crate::Session handles this automatically. This method is useful for
stateless clients that persist the response themselves.
Sourcepub async fn send(self) -> Result<TrackResponse>
pub async fn send(self) -> Result<TrackResponse>
Sends this track to Umami.