Skip to content
Merged
Show file tree
Hide file tree
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
160 changes: 152 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ureq = { version = "3.0.11", default-features = false, features = [
"json",
"gzip",
] }
uuid = { version = "1.29.0", features = ["v4"] }

[features]
default = ["rustls"]
Expand Down
42 changes: 36 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,36 @@ m.set("user".into(), 0.0);
m.mutate("user".into(), 1.0);
```

## Events

```rust
logdash::create_logdash(logdash::Config::default());

// track that a signed-in user ran an agent
logdash::track(
"agent_run",
&[("agent", "support".into()), ("steps", 4.into()), ("success", true.into())],
Some(&user.id),
);
```

Events show up in the domain's Analytics as goals, with a daily trend.
Pass the user ID for signed-in users, so one person counts once across the website and apps.
Without it, Logdash counts a visitor of that app that changes every day.
Never put personal data in props.

## Flush

Logs, metrics and events are sent in the background.
Call `flush` before your app exits, so nothing queued is lost.

```rust
// wait until the logs, metrics and events queued so far are sent
logdash::flush();
```

Each request fails after 5 seconds without an answer, so `flush` returns even when the API is unreachable.

## Apps

A domain key is shared by all apps of a domain, for example a desktop app, an API and a landing page.
Expand Down Expand Up @@ -84,12 +114,12 @@ To see the logs or metrics, go to your project dashboard

## Configuration

| Parameter | Required | Default | Description |
| --------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |
| `api_key` | no | - | Api key used to authorize against logdash servers. If you don't provide one, logs will be logged into local console only |
| `api_url` | no | - | Custom API host, useful with self-hosted instances |
| `verbose` | no | - | Useful for debugging purposes |
| `app` | no | - | Name of the app sending logs and metrics, for example `desktop`. See [Apps](#apps) |
| Parameter | Required | Default | Description |
| --------- | -------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `api_key` | no | - | Api key used to authorize against logdash servers. If you don't provide one, logs and events will be logged into local console only |
| `api_url` | no | - | Custom API host, useful with self-hosted instances |
| `verbose` | no | - | Useful for debugging purposes |
| `app` | no | - | Name of the app sending logs, metrics and events, for example `desktop`. See [Apps](#apps) |

## License

Expand Down
6 changes: 2 additions & 4 deletions examples/client_from_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ fn main() {
// Send a metric message
m.set("user".into(), 0.0);

// Sleep for 10 seconds to allow the log message to be sent
// This is just for demonstration purposes
// In a real application, you would not want to sleep the thread like this
std::thread::sleep(std::time::Duration::from_secs(10));
// Wait until the log and the metric are sent before the program exits
logdash::flush();
}
6 changes: 2 additions & 4 deletions examples/client_fron_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ fn main() {
// Send a metric message
m.set("user".into(), 0.0);

// Sleep for 10 seconds to allow the log message to be sent
// This is just for demonstration purposes
// In a real application, you would not want to sleep the thread like this
std::thread::sleep(std::time::Duration::from_secs(10));
// Wait until the logs and the metric are sent before the program exits
logdash::flush();
}
Loading
Loading