Skip to main content

Track

Struct Track 

Source
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

Source

pub fn kind(&self) -> TrackKind

Returns this track’s collection kind.

Source

pub fn context(self, context: Context) -> Self

Replaces the inherited visitor/page context.

Source

pub fn hostname(self, hostname: impl Into<String>) -> Self

Sets the page hostname.

Source

pub fn screen(self, width: u32, height: u32) -> Self

Sets the screen dimensions.

Source

pub fn language(self, language: impl Into<String>) -> Self

Sets the visitor language.

Source

pub fn url(self, url: impl Into<String>) -> Self

Sets or overrides the page URL/path.

Source

pub fn referrer(self, referrer: impl Into<String>) -> Self

Sets the referring URL/path.

Source

pub fn title(self, title: impl Into<String>) -> Self

Sets the page title.

Source

pub fn tag(self, tag: impl Into<String>) -> Self

Sets an Umami tag.

Source

pub fn distinct_id(self, distinct_id: impl Into<String>) -> Self

Sets a stable distinct ID.

Source

pub fn ip(self, ip: IpAddr) -> Self

Sets the original visitor IP address.

Source

pub fn user_agent(self, user_agent: impl Into<String>) -> Self

Sets the original visitor user agent.

Source

pub fn browser(self, browser: impl Into<String>) -> Self

Overrides Umami’s browser detection.

Source

pub fn os(self, os: impl Into<String>) -> Self

Overrides Umami’s operating-system detection.

Source

pub fn device(self, device: impl Into<String>) -> Self

Overrides Umami’s device detection.

Source

pub fn timestamp(self, unix_seconds: i64) -> Self

Sets the event time as Unix seconds.

Source

pub fn at(self, time: SystemTime) -> Self

Sets the event time from a SystemTime.

Source

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.

Source

pub fn clear_data(self) -> Self

Removes previously attached properties.

Source

pub fn lcp(self, milliseconds: f64) -> Self

Sets Largest Contentful Paint in milliseconds.

Source

pub fn inp(self, milliseconds: f64) -> Self

Sets Interaction to Next Paint in milliseconds.

Source

pub fn cls(self, score: f64) -> Self

Sets Cumulative Layout Shift.

Source

pub fn fcp(self, milliseconds: f64) -> Self

Sets First Contentful Paint in milliseconds.

Source

pub fn ttfb(self, milliseconds: f64) -> Self

Sets Time to First Byte in milliseconds.

Source

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.

Source

pub async fn send(self) -> Result<TrackResponse>

Sends this track to Umami.

Trait Implementations§

Source§

impl Debug for Track

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Track

§

impl !UnwindSafe for Track

§

impl Freeze for Track

§

impl Send for Track

§

impl Sync for Track

§

impl Unpin for Track

§

impl UnsafeUnpin for Track

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more