-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
docs(sentry-javascript): Add @sentry/wasm page #2923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ea7fd3a
docs(sentry-javascript): Add @sentry/wasm page
kamilogorek 693c398
Update src/platforms/javascript/guides/wasm/index.mdx
kamilogorek 1c779e6
Update src/platforms/javascript/guides/wasm/index.mdx
kamilogorek 52ac585
Update src/platforms/javascript/guides/wasm/index.mdx
kamilogorek 31a1298
Added keywords and compilation details
kamilogorek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| --- | ||
| title: Wasm | ||
| sdk: sentry.javascript.wasm | ||
| description: "Learn how to use Sentry's Wasm integration and how it automatically reports errors and exceptions in your Wasm module." | ||
| keywords: ["wasm", "webassembly"] | ||
| --- | ||
|
|
||
| Sentry's Wasm integration enhances the Browser SDK, and allows it to provide more detailed debug information not only for the error itself, but also for the entire module it was executed from. It includes things like Debug IDs, Debug Files, Code IDs, Code Files and memory addresses. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need its own Getting Started page? Far easier to simply use the guidelines here - https://docs.sentry.io/contributing/approach/write-getting-started/ |
||
|
|
||
| ### Install | ||
|
|
||
| Install `@sentry/browser` and `@sentry/wasm` using `yarn` or `npm`: | ||
|
|
||
| ```bash | ||
| # Using yarn | ||
| yarn add @sentry/browser @sentry/wasm | ||
|
|
||
| # Using npm | ||
| npm install --save @sentry/browser @sentry/wasm | ||
| ``` | ||
|
|
||
| and afterwards use it like this: | ||
|
|
||
| ```javascript | ||
| import * as Sentry from "@sentry/browser"; | ||
| import { Wasm as WasmIntegration } from "@sentry/wasm"; | ||
|
|
||
| Sentry.init({ | ||
| dsn: "___PUBLIC_DSN___", | ||
| integrations: [new WasmIntegration()], | ||
| }); | ||
|
|
||
| // Now, whenever any code from WebAssembly module will throw an error, | ||
| // it'll get captured and it'll contain all the necessary information. | ||
|
|
||
| function executeInternalWasmStuff() { | ||
| throw new Error('whoops'); | ||
| } | ||
|
|
||
| const { instance } = await WebAssembly.instantiateStreaming(fetch('very-complex-module.wasm'), { | ||
| env: { | ||
| external_func: executeInternalWasmStuff, | ||
| }, | ||
| }); | ||
|
|
||
| instance.exports.internal_func(); | ||
| ``` | ||
|
|
||
| If you are curious how Wasm modules look from the inside, here's a quick example written in Rust: | ||
|
|
||
| ```rust | ||
| #![no_std] | ||
|
|
||
| #[panic_handler] | ||
| fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| loop {} | ||
| } | ||
|
|
||
| extern "C" { | ||
| pub fn external_func(); | ||
| } | ||
|
|
||
| #[no_mangle] | ||
| pub fn internal_func() { | ||
| unsafe { | ||
| external_func(); | ||
| } | ||
| } | ||
| ``` | ||
kamilogorek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| For more details on how to compile Rust to Wasm, see [Compiling from Rust to WebAssembly](https://developer.mozilla.org/en-US/docs/WebAssembly/Rust_to_wasm) MDN documentation. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.