Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: delete redundant async #23

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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();

```

2 changes: 1 addition & 1 deletion src/client/async_client.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ pub struct Client {
client: HttpClient,
}

pub async fn client<C: Into<ClientOptions>>(options: C) -> Client {
pub fn client<C: Into<ClientOptions>>(options: C) -> Client {
let options = options.into();
let client = HttpClient::builder()
.timeout(Duration::from_secs(options.request_timeout_seconds))
5 changes: 3 additions & 2 deletions src/global.rs
Original file line number Diff line number Diff line change
@@ -6,12 +6,13 @@ static GLOBAL_CLIENT: OnceLock<Client> = OnceLock::new();
static GLOBAL_DISABLE: OnceLock<bool> = OnceLock::new();

#[cfg(feature = "async-client")]
pub async fn init_global_client<C: Into<ClientOptions>>(options: C) -> Result<(), Error> {
pub fn init_global_client<C: Into<ClientOptions>>(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)