Skip to content

Commit 61a3703

Browse files
author
Luca Forstner
authored
[v9] Update docs for v9 (#12588)
1 parent d358ca4 commit 61a3703

File tree

18 files changed

+835
-115
lines changed

18 files changed

+835
-115
lines changed

docs/platforms/javascript/common/configuration/integrations/debug.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ description: "Allows you to inspect the contents of a processed event and hint o
55

66
{/* TODO(v9): Remove this page and all references to it */}
77

8-
<Alert title="Deprecation Notice">
8+
<Alert level="warning" title="Deprecation Notice">
99

10-
The `Debug` Integration is deprecated and will be removed in the next major version of the SDK.
10+
The `Debug` Integration was removed in version 9 of the SDK.
1111
To log outgoing events, we recommend using <PlatformLink to="/configuration/options/#beforeSend">beforeSend</PlatformLink> in `Sentry.init()`.
1212

1313
</Alert>

docs/platforms/javascript/common/configuration/integrations/sessiontiming.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ description: "Adds session timing data to events. (deprecated)"
55

66
{/* TODO(v9): Remove this page and all references to it */}
77

8-
<Alert title="Deprecation Notice">
8+
<Alert level="warning" title="Deprecation Notice">
99

10-
The `SessionTiming` Integration is deprecated and will be removed in the next major version of the SDK.
10+
The `SessionTiming` Integration was removed in version 9 of the SDK.
1111
To capture session durations alongside events, we recommend using <PlatformLink to="/enriching-events/context/">Context</PlatformLink>.
1212

1313
</Alert>

docs/platforms/javascript/common/configuration/options.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,9 @@ This function is called with a transaction event object, and can return a modifi
347347

348348
<SdkOption name="beforeSendSpan" type='(span: SpanJSON) => SpanJSON | null'>
349349

350-
<Include name="platforms/configuration/options/warn-before-send-span.mdx" />
351-
352-
This function is called with a serialized span object, and can return a modified span object, or `null` to skip sending the span. This might be useful for manually stripping PII from spans or to remove individual spans from the span tree.
353-
This function is only called for child spans of the root span. If you want to modify or drop the root span, including all of its child spans, use [`beforeSendTransaction`](#beforeSendTransaction) instead.
350+
This function is called with a serialized span object, and can return a modified span object. This might be useful for manually stripping PII from spans.
351+
This function is only called for root spans and all children.
352+
If you want to drop the root span, including all of its child spans, use [`beforeSendTransaction`](#beforeSendTransaction) instead.
354353

355354
</SdkOption>
356355

docs/platforms/javascript/common/install/esm.mdx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,3 @@ Sentry.init({
7474
registerEsmLoaderHooks: false,
7575
});
7676
```
77-
78-
{/* TODO(v9): This will become the default behavior and registerEsmLoaderHooks will no longer accept an object. So I guess we should remove this section when v9 ships. */}
79-
80-
If you are starting Sentry via `--import`, you can instruct `import-in-the-middle`
81-
to only wrap packages that Sentry specifically instruments. To do this, you can
82-
set the `onlyIncludeInstrumentedModules` to `true`:
83-
84-
```javascript {tabTitle:ESM} {filename: instrument.mjs} {4-6}
85-
import * as Sentry from "@sentry/node";
86-
87-
Sentry.init({
88-
registerEsmLoaderHooks: {
89-
onlyIncludeInstrumentedModules: true,
90-
},
91-
});
92-
```
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
title: ESM (MJS)
3+
sidebar_order: 10
4+
description: "Learn about running Sentry in an ESM application."
5+
supported:
6+
- javascript.node
7+
- javascript.connect
8+
- javascript.express
9+
- javascript.fastify
10+
- javascript.hapi
11+
- javascript.koa
12+
- javascript.nestjs
13+
noindex: true
14+
---
15+
16+
<Alert>
17+
Are you unsure if you should use this installation method? Review our
18+
[installation methods](../).
19+
</Alert>
20+
21+
When running your application in ESM mode, you can't use `require()` to load modules. Instead, you have to use the `--import` command line options to load a module before the application starts.
22+
23+
You need to create a file named `instrument.mjs` that imports and initializes Sentry:
24+
25+
```javascript {tabTitle:ESM} {filename: instrument.mjs}
26+
import * as Sentry from "@sentry/node";
27+
28+
// Ensure to call this before importing any other modules!
29+
Sentry.init({
30+
dsn: "___PUBLIC_DSN___",
31+
32+
// Add Tracing by setting tracesSampleRate
33+
// We recommend adjusting this value in production
34+
tracesSampleRate: 1.0,
35+
});
36+
```
37+
38+
Adjust the Node.js call for your application to use the [--import](https://nodejs.org/api/cli.html#--importmodule) parameter and point it at `instrument.js`, which contains your `Sentry.init()` code:
39+
40+
```bash
41+
# Note: This is only available for Node v18.19.0 onwards.
42+
node --import ./instrument.mjs app.mjs
43+
```
44+
45+
If it is not possible for you to pass the `--import` flag to the Node.js binary, you can alternatively use the `NODE_OPTIONS` environment variable as follows:
46+
47+
```bash
48+
NODE_OPTIONS="--import ./instrument.mjs" npm run start
49+
```
50+
51+
We do not support ESM in Node versions before 18.19.0.
52+
53+
## Troubleshooting instrumentation
54+
55+
By default, all packages are wrapped under the hood by
56+
[import-in-the-middle](https://www.npmjs.com/package/import-in-the-middle) to
57+
aid instrumenting them.
58+
59+
If `import-in-the-middle` encounters problems wrapping a package, you may see
60+
syntax errors at runtime or logged errors in your console:
61+
62+
```logs
63+
SyntaxError: The requested module '...' does not provide an export named '...'
64+
(node:3368) Error: 'import-in-the-middle' failed to wrap 'file://../../path/to/file.js'
65+
```
66+
67+
To confirm that these errors are caused by `import-in-the-middle`,
68+
disable it by setting `registerEsmLoaderHooks` to false. Note, this will also
69+
disable tracing instrumentation:
70+
71+
```javascript {tabTitle:ESM} {filename: instrument.mjs} {4}
72+
import * as Sentry from "@sentry/node";
73+
74+
Sentry.init({
75+
registerEsmLoaderHooks: false,
76+
});
77+
```
78+
79+
If you are starting Sentry via `--import`, you can instruct `import-in-the-middle`
80+
to only wrap packages that Sentry specifically instruments. To do this, you can
81+
set the `onlyIncludeInstrumentedModules` to `true`:
82+
83+
```javascript {tabTitle:ESM} {filename: instrument.mjs} {4-6}
84+
import * as Sentry from "@sentry/node";
85+
86+
Sentry.init({
87+
registerEsmLoaderHooks: {
88+
onlyIncludeInstrumentedModules: true,
89+
},
90+
});
91+
```

docs/platforms/javascript/common/migration/v8-to-v9.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ notSupported:
88
- javascript.electron
99
---
1010

11+
<PlatformSection supported={["javascript"]}>
12+
<Alert title="Using a framework?" level="info">
13+
14+
Make sure to select your framework in the dropdown in the top left corner of the page.
15+
16+
</Alert>
17+
</PlatformSection>
18+
1119
Version 9 of the Sentry JavaScript SDK primarily introduces API cleanup and version support changes.
1220

1321
This update contains behavioral changes that will not be caught by type checkers, linters, or tests, so we recommend carefully reading through the entire migration guide instead of relying on automatic tooling.

docs/platforms/javascript/common/troubleshooting/supported-browsers.mdx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ notSupported:
1616
- javascript.nestjs
1717
---
1818

19+
Sentry's latest JavaScript SDKs require ES2020 compatibility. The minimum supported browser versions are:
20+
21+
- Chrome 80
22+
- Edge 80
23+
- Safari 14, iOS Safari 14.4
24+
- Firefox 74
25+
- Opera 67
26+
- Samsung Internet 13.0
27+
28+
In addition, the Sentry JavaScript SDKs require the `fetch` API to be available.
29+
If you need to support browser-like environments that do not have `fetch` available, you should include a polyfill for the fetch API.
30+
31+
## Supporting earlier JavaScript versions
32+
33+
The Sentry JavaScript SDK uses ES2020 syntax and functionality to provide the best possible user experience and lowest bundle size.
34+
If you want to support earlier versions, you need to transpile your code using a transpiler like Babel, SWC, or TypeScript, and add polyfills.
35+
36+
## 8.x Browser support
37+
1938
Sentry's JavaScript SDKs require ES2018 compatibility plus support for [`globalThis`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis). The minimum supported browser versions are:
2039

2140
- Chrome 71
@@ -25,12 +44,6 @@ Sentry's JavaScript SDKs require ES2018 compatibility plus support for [`globalT
2544
- Opera 58
2645
- Samsung Internet 10
2746

28-
In addition, the Sentry JavaScript SDKs require the `fetch` API to be available. If you need to support browser-like environments that do not have `fetch` available, you should include a polyfill for the fetch API.
29-
30-
## Support for IE11 / ES5
31-
32-
The Sentry JavaScript SDK uses ES2018 syntax and functionality to provide the best possible user experience and lowest bundle size. If you want to support IE11 (or other environments that do not support ES6), you need to transpile your code using a bundler like webpack, Vite, Rollup, etc and add polyfills for ES5 functionality.
33-
3447
## 7.x Browser support
3548

3649
`7.x` of the Sentry JavaScript SDKs use ES6 syntax, along with a few other ES6+ language features, such as object spread. If you are down-compiling your code in order to target older browsers that don't support such syntax, you'll need to include the Sentry SDK in that process.

docs/platforms/javascript/guides/react/features/tanstack-router.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ title: TanStack Router
33
description: "Learn about Sentry's TanStack Router integration."
44
---
55

6-
_(Available in version 8.7.0 and above)_
7-
8-
TanStack Router support is included in the `@sentry/react` package since version `8.7.0` and is only compatible with version `1.34.5` of ` `@tanstack/router` and above.
6+
The TanStack Router integration is included in the `@sentry/react` package and is compatible with version `1.64.0` of `@tanstack/react-router` and above.
97

108
<Alert title="Note">
119

docs/platforms/javascript/guides/remix/manual-setup.mdx

Lines changed: 15 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ pnpm add @sentry/remix
3636

3737
To use this SDK, initialize Sentry in your Remix project for both the client and server.
3838

39-
4039
### Client-side Configuration
4140

4241
```typescript {tabTitle:Client} {filename: entry.client.tsx} {"onboardingOptions": {"performance": "8-12,16-23", "session-replay": "13-14,24-28"}}
@@ -79,7 +78,7 @@ Sentry.init({
7978

8079
To capture errors from [ErrorBoundary](https://remix.run/docs/en/main/route/error-boundary), you should define your own `ErrorBoundary` in `root.tsx` and use `Sentry.captureRemixErrorBoundaryError` inside of it. You can also create route-specific error capturing behavior by defining `ErrorBoundary` in your route components. The `ErrorBoundary` you define in `root.tsx` will be used as a fallback for all routes.
8180

82-
```typescript {filename: root.tsx}
81+
```tsx {filename: root.tsx}
8382
import { captureRemixErrorBoundaryError } from "@sentry/remix";
8483

8584
export const ErrorBoundary: V2_ErrorBoundaryComponent = () => {
@@ -91,14 +90,9 @@ export const ErrorBoundary: V2_ErrorBoundaryComponent = () => {
9190
};
9291
```
9392

94-
To catch React component errors (in Remix v1) and routing transactions (in all Remix versions), wrap your Remix root with `withSentry`.
95-
96-
<Alert>
97-
98-
If you use Remix v1 with the `v2_errorBoundary` future flag, you must also configure your `ErrorBoundary`.
99-
</Alert>
93+
To capture performance data, wrap your Remix root with `withSentry`.
10094

101-
```typescript {filename: root.tsx}
95+
```tsx {filename: root.tsx}
10296
import {
10397
Links,
10498
LiveReload,
@@ -130,15 +124,9 @@ function App() {
130124
export default withSentry(App);
131125
```
132126

133-
<Alert>
134-
135-
If you use Remix v2, `wrapWithErrorBoundary` is disabled by default. You still need to wrap your root component with `withSentry` to capture routing transactions.
136-
137-
</Alert>
138-
139127
You can disable or configure `ErrorBoundary` using a second parameter to `withSentry`.
140128

141-
```typescript
129+
```tsx
142130
withSentry(App, {
143131
wrapWithErrorBoundary: false,
144132
});
@@ -152,7 +140,6 @@ withSentry(App, {
152140
});
153141
```
154142

155-
156143
### Server-side Configuration
157144

158145
Create an instrumentation file (named here as `instrument.server.mjs`) in your project. Add your initialization code in this file for the server-side SDK.
@@ -169,18 +156,15 @@ Sentry.init({
169156
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
170157
tracesSampleRate: 1.0,
171158

172-
// To use Sentry OpenTelemetry auto-instrumentation
173-
// default: false
174-
autoInstrumentRemix: true,
175-
176159
// Optionally capture action formData attributes with errors.
177160
// This requires `sendDefaultPii` set to true as well.
178161
captureActionFormDataKeys: {
179162
key_x: true,
180163
key_y: true,
181164
},
165+
182166
// To capture action formData attributes.
183-
sendDefaultPii: true
167+
sendDefaultPii: true,
184168
});
185169
```
186170

@@ -199,43 +183,29 @@ Sentry's Remix SDK will automatically record your [`action`](https://remix.run/d
199183
#### Server-side Errors
200184

201185
To capture server-side errors automatically, instrument the [`handleError`](https://remix.run/docs/en/main/file-conventions/entry.server#handleerror) function in your server entry point.
186+
Wrap your error handler with `wrapHandleErrorWithSentry` or use `sentryHandleError` to export as your `handleError` function:
202187

203-
If you're using Sentry Remix SDK version `7.87.0` or higher, you can wrap your error handler with `wrapHandleErrorWithSentry` or use `sentryHandleError` to export as your `handleError` function.
204-
205-
```typescript {filename: entry.server.tsx (@sentry/remix >= 7.87.0)}
188+
```typescript {filename: entry.server.tsx}
206189
import * as Sentry from "@sentry/remix";
207190

208-
export const handleError = Sentry.wrapHandleErrorWithSentry((error, { request }) => {
209-
// Custom handleError implementation
210-
});
191+
export const handleError = Sentry.wrapHandleErrorWithSentry(
192+
(error, { request }) => {
193+
// Custom handleError implementation
194+
}
195+
);
211196

212197
// Alternative: Use the Sentry utility function if you don't need to wrap a custom function
213198
export const handleError = Sentry.sentryHandleError;
214199
```
215200

216-
For SDK versions older than `7.87.0`, you can use `Sentry.captureRemixServerException` to capture errors inside `handleError`.
217-
218-
```typescript {filename: entry.server.tsx (@sentry/remix < 7.87.0)}
219-
export function handleError(
220-
error: unknown,
221-
{ request }: DataFunctionArgs
222-
): void {
223-
if (error instanceof Error) {
224-
Sentry.captureRemixServerException(error, "remix.server", request);
225-
} else {
226-
// Optionally capture non-Error objects
227-
Sentry.captureException(error);
228-
}
229-
}
230-
```
231-
232201
### Source Maps Upload
233202

234203
To enable readable stack traces, <PlatformLink to="/sourcemaps">configure source maps upload</PlatformLink> for your production builds.
235204

236205
After you've completed this setup, the SDK will automatically capture unhandled errors and promise rejections, and monitor performance. You can also [manually capture errors](/platforms/javascript/guides/remix/usage).
237206

238207
## Verify
208+
239209
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
240210

241211
<PlatformContent includePath="getting-started-verify" />
@@ -252,7 +222,7 @@ You can import your server instrumentation file at the top of your Express serve
252222

253223
```typescript {filename: server.ts}
254224
// import the Sentry instrumentation file before anything else.
255-
import './instrument.server.mjs';
225+
import "./instrument.server.mjs";
256226
// alternatively `require('./instrument.server.cjs')`
257227

258228
// ...

0 commit comments

Comments
 (0)