pub struct Context {Show 14 fields
pub hostname: Option<String>,
pub screen: Option<String>,
pub language: Option<String>,
pub url: Option<String>,
pub referrer: Option<String>,
pub title: Option<String>,
pub tag: Option<String>,
pub distinct_id: Option<String>,
pub ip: Option<IpAddr>,
pub user_agent: Option<String>,
pub browser: Option<String>,
pub os: Option<String>,
pub device: Option<String>,
pub timestamp: Option<i64>,
}Expand description
Visitor and page information attached to an analytics event.
Every field is optional. Umami can infer the user agent and IP address from
the HTTP request, but server-side applications should normally forward the
original visitor values with Context::user_agent and Context::ip.
Fields§
§hostname: Option<String>Page hostname, for example example.com.
screen: Option<String>Screen size formatted as WIDTHxHEIGHT.
language: Option<String>Browser or application language, for example en-US.
url: Option<String>Page URL or path.
referrer: Option<String>Referring URL or path.
title: Option<String>Page title.
tag: Option<String>An additional Umami tag.
distinct_id: Option<String>Stable distinct ID used to associate events with a visitor.
ip: Option<IpAddr>Original visitor IP address for server-side tracking.
user_agent: Option<String>Original visitor user agent for server-side tracking.
browser: Option<String>Explicit browser override.
os: Option<String>Explicit operating-system override.
device: Option<String>Explicit device override.
timestamp: Option<i64>Event time as Unix seconds.
Implementations§
Source§impl Context
impl Context
Sourcepub fn screen_value(self, screen: impl Into<String>) -> Self
pub fn screen_value(self, screen: impl Into<String>) -> Self
Sets a preformatted screen value such as 1920x1080.
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 timestamp(self, unix_seconds: i64) -> Self
pub fn timestamp(self, unix_seconds: i64) -> Self
Sets the event time as Unix seconds.
Umami’s ingestion endpoint expects seconds here, unlike reporting API date ranges, which use milliseconds.
Sourcepub fn at(self, time: SystemTime) -> Self
pub fn at(self, time: SystemTime) -> Self
Sets the event time from a SystemTime.