Skip to content

Commit 3df94f4

Browse files
chargomesentrivana
authored andcommitted
docs(bun): Improve bun documentation (#10576)
1 parent 195ae15 commit 3df94f4

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

docs/platforms/javascript/common/index.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ Sentry supports multiple versions of React Router. See the <PlatformLink to="/co
8989

9090
<PlatformContent includePath="getting-started-sourcemaps" />
9191

92+
<PlatformSection supported={["javascript.bun"]}>
93+
94+
## Use
95+
96+
<PlatformContent includePath="getting-started-use" />
97+
98+
</PlatformSection>
99+
100+
92101
## Verify
93102

94103
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
You can pass an `Error` object to `captureException()` to have it captured as an event. It's also possible to pass non-`Error` objects and strings, but be aware that the resulting events in Sentry may be missing a stack trace.
2+
3+
```javascript
4+
import * as Sentry from "@sentry/bun";
5+
6+
try {
7+
aFunctionThatMightFail();
8+
} catch (e) {
9+
Sentry.captureException(e);
10+
}
11+
```
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
<SignInNote />
22

3-
```javascript {"onboardingOptions": {"performance": "5-9"}}
3+
Sentry should be initialized as early in your app as possible. It is essential that you call `Sentry.init` before you require any other modules in your application—otherwise, auto-instrumentation of these modules will _not_ work.
4+
5+
Once this is done, Sentry's Bun SDK captures unhandled exceptions as well as tracing data for your application.
6+
7+
You need to create a file named `instrument.js` that imports and initializes Sentry:
8+
9+
```javascript {filename: instrument.js} {"onboardingOptions": {"performance": "7-11"}}
410
import * as Sentry from "@sentry/bun";
511

12+
// Ensure to call this before importing any other modules!
613
Sentry.init({
714
dsn: "___PUBLIC_DSN___",
8-
15+
916
// Add Performance Monitoring by setting tracesSampleRate
1017
// Set tracesSampleRate to 1.0 to capture 100% of transactions
1118
// We recommend adjusting this value in production
1219
tracesSampleRate: 1.0,
1320
});
1421
```
1522

16-
Once configured, you can capture exceptions manually, as the following example shows.
23+
Once you set a `tracesSampleRate`, performance instrumentation is automatically enabled for you. See <PlatformLink to="/tracing/instrumentation/automatic-instrumentation">Automatic Instrumentation</PlatformLink> to learn about all the things that the SDK automatically instruments for you.
24+
25+
You can also manually capture performance data - see <PlatformLink to="/tracing/instrumentation/custom-instrumentation">Custom Instrumentation</PlatformLink> for details.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
You need to import the `instrument.js` file before importing any other modules in your application. This is necessary to ensure that Sentry can automatically instrument all modules in your application:
2+
3+
```javascript {filename: app.js}
4+
// Import this first!
5+
import "./instrument";
6+
7+
// Now import other modules
8+
import http from "http";
9+
10+
// Your application code goes here
11+
```

0 commit comments

Comments
 (0)