#report #forms #replace #bug #panic-hook #web #reporting

web_panic_report

A panic hook which replaces an HTML element with a bug report form

2 releases

0.1.1 Mar 17, 2024
0.1.0 Mar 17, 2024

#4 in #panic-hook

Download history 131/week @ 2024-03-11 119/week @ 2024-03-18 36/week @ 2024-04-01

286 downloads per month

MIT/Apache

85KB
88 lines

Web Panic Report

A panic hook which replaces an HTML element with a bug report form.

Discord MIT/Apache 2.0 Build status dependency status Crates.io Docs

[!WARNING] The goal of this project is NOT to provide a full-fledge error reporting and analytics, only to help provide a framework to report panic conditions.

Quickstart to run demo:

# Make sure the Rust toolchain supports the wasm32 target
rustup target add wasm32-unknown-unknown

# Install `wasm-server-runner` for the example
cargo install wasm-server-runner

WASM_SERVER_RUNNER_CUSTOM_INDEX_HTML=examples/index.html cargo run --target wasm32-unknown-unknown --example simple

There is also a web demo available here.

Demo

Usage

[!IMPORTANT] On release mode, debug symbols are stripped. You will need to enable them manually if you want useful stack traces for production builds.

Add the following to your Cargo.toml

[profile.release]
debug = true

Ensure your web page is served with a container element that will be replaced with the bug report form.

<body>
  <div id="my-container" style="width: 400px; height: 400px;">
    /** Content that is replaced here on panic, like a game canvas */
  </div>
</body>

Then, set the panic hook at the beginning of your program on web.

fn main() {
    #[cfg(target_arch = "wasm32")]
    web_panic_report::set_hook_with("my-container", |panic_info| {
        // Send the panic info to your backend here.
        // This is triggered when the user clicks "Send Report"
    });
}

Alternatives

Community

All VGX projects and development happens in the VGX Discord. The discord is open to the public.

Contributions are welcome by pull request. The Rust code of conduct applies.

License

Licensed under either of

at your option

The files in subdirectories of the examples/assets directory are licensed solely under their respective licenses, available in the LICENSE file in their directories.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~6.5–9MB
~171K SLoC