diff --git a/README.md b/README.md index a5feac0..fcf9848 100644 --- a/README.md +++ b/README.md @@ -10,17 +10,16 @@ Add `posthog-rs` to your `Cargo.toml`. ```toml [dependencies] -posthog_rs = "0.2.0" +posthog-rs = "0.3.5" ``` ```rust -let client = crate::client(env!("POSTHOG_API_KEY")); +let client = posthog_rs:client(env!("POSTHOG_API_KEY")); -let mut event = Event::new("test", "1234"); +let mut event = posthog_rs::Event::new("test", "1234"); event.insert_prop("key1", "value1").unwrap(); event.insert_prop("key2", vec!["a", "b"]).unwrap(); client.capture(event).unwrap(); - ``` diff --git a/src/client/async_client.rs b/src/client/async_client.rs index aa5b26d..b98e2ad 100644 --- a/src/client/async_client.rs +++ b/src/client/async_client.rs @@ -11,7 +11,7 @@ pub struct Client { client: HttpClient, } -pub async fn client>(options: C) -> Client { +pub fn client>(options: C) -> Client { let options = options.into(); let client = HttpClient::builder() .timeout(Duration::from_secs(options.request_timeout_seconds)) diff --git a/src/global.rs b/src/global.rs index 7b998dc..8236dce 100644 --- a/src/global.rs +++ b/src/global.rs @@ -6,12 +6,13 @@ static GLOBAL_CLIENT: OnceLock = OnceLock::new(); static GLOBAL_DISABLE: OnceLock = OnceLock::new(); #[cfg(feature = "async-client")] -pub async fn init_global_client>(options: C) -> Result<(), Error> { +pub fn init_global_client>(options: C) -> Result<(), Error> { if is_disabled() { return Ok(()); } - let client = client(options).await; + let client = client(options); + GLOBAL_CLIENT .set(client) .map_err(|_| Error::AlreadyInitialized)