🚧 Proceed with caution: Bugstr-TS is proof of concept stage, and has not been reviewed by a professional developer 🚧
Minimal browser SDK for sending crash reports as NIP-17 giftwrapped DMs using nostr-tools. Ships:
-
init– configure Bugstr (developer npub, relays, env/release, redaction, confirm hook) -
captureException– build payload, redact, confirm with user, and send via NIP-17 -
Window hooks (error/unhandledrejection) wired automatically after
init
npm install bugstr-tsimport { init, captureException } from "bugstr-ts";
init({
developerPubkey: "npub1...", // target npub for NIP-17 DM
relays: ["wss://relay.damus.io", "wss://nos.lol"],
environment: "development",
release: "dev",
// Optional: beforeSend, confirmSend, redactPatterns
});
// Manual capture
captureException(new Error("bugstr test crash"));- Redaction: cashu tokens, LN invoices, npub/nsec, mint URLs.
- Confirm prompt:
window.confirmif noconfirmSendprovided. - NIP-17 delivery: nip44 seal and giftwrap, publishes to relays in order, stops after first OK.
After calling init, run in devtools:
window.dispatchEvent(new ErrorEvent("error", { error: new Error("bugstr test crash") }));Expect a confirm dialog. On OK, console logs:
Bugstr: user confirmed sendBugstr: send completed (received OK from 1 relay, last=<relay>)And the target npub should receive a NIP-17 DM containing the JSON payload (minified stack).
Redaction check:
window.dispatchEvent(new ErrorEvent("error", { error: new Error("cashuA123 npub1abc lnbc1xyz") }));Payload should show [redacted] in place of secrets.
npm run build– tsup ESM+CJS + typesnpm run test– vitest (unit tests TBD)npm run lint
- Browser-first; relies on
nostr-toolsnip44 andRelay.connect. - Early return/guard clauses used to avoid deep nesting.
For Android utilize https://github.com/alltheseas/bugstr