pub struct Event {
pub event: String,
pub distinct_id: String,
pub properties: HashMap<String, Value>,
pub timestamp: Option<String>,
}Expand description
A PostHog analytics event.
Fields§
§event: StringThe event name.
distinct_id: StringThe user’s unique identifier.
properties: HashMap<String, Value>Custom properties attached to the event.
timestamp: Option<String>Optional ISO 8601 timestamp. If not set, PostHog uses server time.
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
Creates a new event with the given name and distinct ID.
§Examples
use better_posthog::Event;
let event = Event::new("page_view", "user_123");Sourcepub fn new_anonymous<S: Into<String>>(event: S) -> Self
pub fn new_anonymous<S: Into<String>>(event: S) -> Self
Creates a new event with a generated UUID v7 as the distinct ID.
§Examples
use better_posthog::Event;
let event = Event::new_anonymous("anonymous_action");Sourcepub fn builder() -> EventBuilder
pub fn builder() -> EventBuilder
Returns a builder for constructing an event.
§Examples
use better_posthog::Event;
let event = Event::builder()
.event("button_click")
.distinct_id("user_456")
.property("button_id", "submit")
.build();Sourcepub fn insert_property<K, V>(&mut self, key: K, value: V)
pub fn insert_property<K, V>(&mut self, key: K, value: V)
Inserts a property into the event.
§Examples
use better_posthog::Event;
let mut event = Event::new("purchase", "user_789");
event.insert_property("amount", 99.99);
event.insert_property("currency", "USD");Trait Implementations§
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnsafeUnpin for Event
impl UnwindSafe for Event
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more