getsentry / sentry-rust

Official Sentry SDK for Rust
https://sentry.io/
Apache License 2.0
620 stars 153 forks source link

WASM Support PR #682

Open omarabid opened 2 months ago

omarabid commented 2 months ago

I have Sentry working with WASM (on Cloudflare workers) with a custom Transport implementation. However, for it to compile with Sentry a few changes had to be made. These are minor changes and I am wondering if you guys are open to accept a PR with these changes. I describe them below.

  1. Replace std::time with web_time
  2. Remove unwrap on SessionFlusher essentially making it fail silently. Threads are not supported in Wasm and the flushing mechanism will have to be implemented by the Transport itself. For CloudFlare workers, for example, this is done using wait_until which spawns a child process to send the envelope.

Overall, the changes are minor and can be gated behind a "wasm" feature. Integrations will have to be changed/upgraded individually but this could be a starting point.