| Crates.io | sentrystr |
| lib.rs | sentrystr |
| version | 0.1.2 |
| created_at | 2025-09-21 21:33:03.532716+00 |
| updated_at | 2025-09-22 21:20:28.359041+00 |
| description | Core library for publishing Sentry-like events to Nostr network |
| homepage | |
| repository | https://github.com/9qeklajc/sentrystr |
| max_upload_size | |
| id | 1849222 |
| size | 100,953 |
A decentralized error tracking and alerting system using the Nostr protocol.
SentryStr provides a Rust library for publishing structured error events and logs to the Nostr network, enabling decentralized monitoring and alerting. It offers a familiar API similar to traditional error tracking services like Sentry, but leverages the censorship-resistant and decentralized nature of Nostr.
Add this to your Cargo.toml:
[dependencies]
sentrystr = "0.1.0"
Basic usage:
use sentrystr::{Config, Event, Level, NostrSentryClient};
use nostr::Keys;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Setup
let keys = Keys::generate();
let relays = vec!["wss://relay.damus.io".to_string()];
let config = Config::new(keys.secret_key().display_secret().to_string(), relays);
// Create client
let client = NostrSentryClient::new(config).await?;
// Send events
let event = Event::new()
.with_message("Something went wrong")
.with_level(Level::Error);
client.capture_event(event).await?;
client.capture_error("Database connection failed").await?;
client.capture_message("System started").await?;
Ok(())
}
Debug: Detailed diagnostic informationInfo: General informational messagesWarning: Warning messages for potentially harmful situationsError: Error events that might still allow the application to continueFatal: Very severe error events that might cause the application to abortSet up encrypted direct message notifications for critical errors:
use sentrystr::{Config, DirectMessageBuilder, NostrSentryClient};
use nostr::prelude::*;
use nostr_sdk::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Setup main client
let keys = Keys::generate();
let relays = vec!["wss://relay.damus.io".to_string()];
let config = Config::new(keys.secret_key().display_secret().to_string(), relays.clone());
let mut client = NostrSentryClient::new(config).await?;
// Setup direct messaging
let dm_keys = Keys::generate();
let dm_client = Client::new(dm_keys.clone());
dm_client.add_relay("wss://relay.damus.io").await?;
dm_client.connect().await;
let recipient = Keys::generate().public_key();
let dm_sender = DirectMessageBuilder::new()
.with_client(dm_client)
.with_keys(dm_keys)
.with_recipient(recipient)
.with_min_level(Level::Error)
.with_nip17(true)
.build()?;
client.set_direct_messaging(dm_sender);
// Now errors will also send DMs
client.capture_error("Critical system failure").await?;
Ok(())
}
Add custom fields to your events:
use sentrystr::{Event, Level};
use serde_json::json;
let event = Event::new()
.with_message("User authentication failed")
.with_level(Level::Warning)
.with_field("user_id", json!("12345"))
.with_field("ip_address", json!("192.168.1.1"))
.with_field("user_agent", json!("Mozilla/5.0..."));
tracing ecosystemMIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.