pub struct Client { /* private fields */ }Expand description
A Client facilitates interactions with the PostHog API over HTTP.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn capture(&self, event: Event) -> Result<(), Error>
pub async fn capture(&self, event: Event) -> Result<(), Error>
Capture the provided event, sending it to PostHog.
Sourcepub async fn capture_batch(&self, events: Vec<Event>) -> Result<(), Error>
pub async fn capture_batch(&self, events: Vec<Event>) -> Result<(), Error>
Capture a collection of events with a single request. This function may be more performant than capturing a list of events individually.
Sourcepub async fn get_feature_flags<S: Into<String>>(
&self,
distinct_id: S,
groups: Option<HashMap<String, String>>,
person_properties: Option<HashMap<String, Value>>,
group_properties: Option<HashMap<String, HashMap<String, Value>>>,
) -> Result<(HashMap<String, FlagValue>, HashMap<String, Value>), Error>
pub async fn get_feature_flags<S: Into<String>>( &self, distinct_id: S, groups: Option<HashMap<String, String>>, person_properties: Option<HashMap<String, Value>>, group_properties: Option<HashMap<String, HashMap<String, Value>>>, ) -> Result<(HashMap<String, FlagValue>, HashMap<String, Value>), Error>
Get all feature flags for a user
Sourcepub async fn get_feature_flag<K: Into<String>, D: Into<String>>(
&self,
key: K,
distinct_id: D,
groups: Option<HashMap<String, String>>,
person_properties: Option<HashMap<String, Value>>,
group_properties: Option<HashMap<String, HashMap<String, Value>>>,
) -> Result<Option<FlagValue>, Error>
pub async fn get_feature_flag<K: Into<String>, D: Into<String>>( &self, key: K, distinct_id: D, groups: Option<HashMap<String, String>>, person_properties: Option<HashMap<String, Value>>, group_properties: Option<HashMap<String, HashMap<String, Value>>>, ) -> Result<Option<FlagValue>, Error>
Get a specific feature flag value for a user
Sourcepub async fn is_feature_enabled<K: Into<String>, D: Into<String>>(
&self,
key: K,
distinct_id: D,
groups: Option<HashMap<String, String>>,
person_properties: Option<HashMap<String, Value>>,
group_properties: Option<HashMap<String, HashMap<String, Value>>>,
) -> Result<bool, Error>
pub async fn is_feature_enabled<K: Into<String>, D: Into<String>>( &self, key: K, distinct_id: D, groups: Option<HashMap<String, String>>, person_properties: Option<HashMap<String, Value>>, group_properties: Option<HashMap<String, HashMap<String, Value>>>, ) -> Result<bool, Error>
Check if a feature flag is enabled for a user
Sourcepub async fn get_feature_flag_payload<K: Into<String>, D: Into<String>>(
&self,
key: K,
distinct_id: D,
) -> Result<Option<Value>, Error>
pub async fn get_feature_flag_payload<K: Into<String>, D: Into<String>>( &self, key: K, distinct_id: D, ) -> Result<Option<Value>, Error>
Get a feature flag payload for a user
Sourcepub fn evaluate_feature_flag_locally(
&self,
flag: &FeatureFlag,
distinct_id: &str,
person_properties: &HashMap<String, Value>,
) -> Result<FlagValue, Error>
pub fn evaluate_feature_flag_locally( &self, flag: &FeatureFlag, distinct_id: &str, person_properties: &HashMap<String, Value>, ) -> Result<FlagValue, Error>
Evaluate a feature flag locally (requires feature flags to be loaded)
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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