pub struct Event { /* private fields */ }Expand description
An Event represents an interaction a user has with your app or
website. Examples include button clicks, pageviews, query completions, and signups.
See the PostHog documentation
for a detailed explanation of PostHog Events.
Implementations§
Source§impl Event
impl Event
Sourcepub fn new<S: Into<String>>(event: S, distinct_id: S) -> Self
pub fn new<S: Into<String>>(event: S, distinct_id: S) -> Self
Capture a new identified Event. Unless you have a distinct ID you can
associate with a user, you probably want to use [new_anon] instead.
Sourcepub fn new_anon<S: Into<String>>(event: S) -> Self
pub fn new_anon<S: Into<String>>(event: S) -> Self
Capture a new anonymous event. See https://posthog.com/docs/data/anonymous-vs-identified-events#how-to-capture-anonymous-events
Sourcepub fn insert_prop<K: Into<String>, P: Serialize>(
&mut self,
key: K,
prop: P,
) -> Result<(), Error>
pub fn insert_prop<K: Into<String>, P: Serialize>( &mut self, key: K, prop: P, ) -> Result<(), Error>
Add a property to the event
Errors if prop fails to serialize
Sourcepub fn add_group(&mut self, group_name: &str, group_id: &str)
pub fn add_group(&mut self, group_name: &str, group_id: &str)
Capture this as a group event. See https://posthog.com/docs/product-analytics/group-analytics#how-to-capture-group-events Note that group events cannot be personless, and will be automatically upgraded to include person profile processing if they were anonymous. This might lead to “empty” person profiles being created.
Sourcepub fn set_timestamp<Tz>(
&mut self,
timestamp: DateTime<Tz>,
) -> Result<(), Error>where
Tz: TimeZone,
pub fn set_timestamp<Tz>(
&mut self,
timestamp: DateTime<Tz>,
) -> Result<(), Error>where
Tz: TimeZone,
Set the event timestamp, for events that happened in the past.
Errors if the timestamp is in the future.
Sourcepub fn set_uuid(&mut self, uuid: Uuid)
pub fn set_uuid(&mut self, uuid: Uuid)
Override the auto-generated UUID for this event. Useful for deduplication when re-importing historical data.
Sourcepub fn with_flags(&mut self, flags: &FeatureFlagEvaluations) -> &mut Self
pub fn with_flags(&mut self, flags: &FeatureFlagEvaluations) -> &mut Self
Attach the flag state captured by a FeatureFlagEvaluations snapshot
to this event. Adds $feature/<key> for every evaluated flag plus a
sorted $active_feature_flags list of enabled keys, mirroring what
send_feature_flags would otherwise fetch — but without making an
extra /flags request.