You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/platform-includes/getting-started-config/javascript.nextjs.mdx
-23Lines changed: 0 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -17,29 +17,6 @@ To complete your configuration, add [options](/platforms/javascript/configuratio
17
17
18
18
Once you're set up, the SDK will automatically capture unhandled errors and promise rejections, and monitor performance in the client. You can also [manually capture errors](/platforms/javascript/guides/nextjs/usage).
19
19
20
-
To capture [Next.js API Route](https://nextjs.org/docs/api-routes/introduction) errors and monitor server performance, you need to wrap your handlers with a Sentry function:
By default, the SDK sets the environment for events to `process.env.NODE_ENV`, although you can [set your own](/platforms/javascript/guides/nextjs/configuration/environments/).
44
21
45
22
To learn how to connect your app to Sentry and deploy it on Vercel, see the [Vercel integration](/product/integrations/deployment/vercel/).
`@sentry/nextjs` provides a `BrowserTracing` integration to add automatic instrumentation for monitoring the performance of browser applications, which is enabled by default once you set up tracing in your app. Further, the same `withSentry` wrapper which enables error collection in your API routes also automatically measures their performance.
1
+
`@sentry/nextjs` provides a `BrowserTracing` integration to add automatic instrumentation for monitoring the performance of browser applications, which is enabled by default once you set up tracing in your app.
2
+
Further, the SDK will automatically enable error collection and performance monitoring in your API routes and [Next.js Data Fetchers](https://nextjs.org/docs/basic-features/data-fetching/overview).
For traces that begin in your backend, you can connect the automatically-generated `pageload` transaction on the frontend with the request transaction that serves the page on the backend. Because JavaScript code running in a browser cannot read the response headers of the current page, the trace data must be transmitted in the response itself, specifically in `<meta>` tags in the `<head>` of the HTML sent from your backend.
22
24
23
25
```html
@@ -35,25 +37,25 @@ For traces that begin in your backend, you can connect the automatically-generat
35
37
Remix SDK attaches `sentry-trace` and `baggage` values from your `root` loader. You need to use [`meta`](https://remix.run/docs/en/v1/api/conventions#meta) function to attach the data from your `loader` as `<meta>` tags. The following code snippet shows how to do this:
36
38
37
39
```typescript {filename: root.tsx}
38
-
exportconst meta:MetaFunction= ({data}) => {
39
-
return {
40
-
// ...
41
-
'sentry-trace': data.sentryTrace,
42
-
baggage: data.sentryBaggage,
43
-
};
40
+
exportconst meta:MetaFunction= ({data}) => {
41
+
return {
42
+
// ...
43
+
"sentry-trace": data.sentryTrace,
44
+
baggage: data.sentryBaggage,
45
+
};
44
46
};
45
47
```
46
48
47
49
<Alertlevel="warning"title="Support">
48
-
50
+
49
51
This feature is available on Sentry Remix SDK version 7.9.0 and above.
50
52
51
53
</Alert>
52
54
53
55
</PlatformSection>
54
56
55
-
56
57
The `name` attributes must be the strings `"sentry-trace"` and `"baggage"` and the `content` attributes must be generated by your backend Sentry SDK. For `sentry-trace`, use `span.toSentryTrace()` (or equivalent, depending on the backend platform). This guarantees that a new and unique value will be generated for each request. For `baggage`, use `serializeBaggage(span.getBaggage())`.
58
+
57
59
<Note>
58
60
59
61
The `span.toSentryTrace()` was previously called `span.toTraceparent()`, so that's what you may find depending on the SDK and version.
@@ -63,3 +65,13 @@ The `span.toSentryTrace()` was previously called `span.toTraceparent()`, so that
63
65
The `span` reference is either the transaction that serves the HTML or any of its child spans. It defines the parent of the `pageload` transaction.
64
66
65
67
Once the data is included in the `<meta>` tags, our `BrowserTracing` integration will pick them up automatically and link them to the transaction generated on pageload. Note that they will not be linked to automatically-generated `navigation` transactions — that is, those that don't require a full page reload. Each of those will be the result of a different request transaction on the backend and, therefore, should have a unique `trace_id`.
For traces that begin in your backend, the `@sentry/nextjs` SDK will automatically connect pageload navigations in the frontend with the request transaction that serves the page on the backend.
74
+
75
+
The SDK will return additional props from your configured [Next.js Data Fetchers](https://nextjs.org/docs/basic-features/data-fetching/overview) that the SDK picks up in to browser to connect the pageload transaction with the backend request.
The `BrowserTracing` integration creates a new transaction for each page load and navigation event, and creates a child span for every `XMLHttpRequest` or `fetch` request that occurs while those transactions are open. The `withSentry` wrapper creates a transaction for every API request. Learn more about [traces, transactions, and spans](/product/sentry-basics/tracing/distributed-tracing/).
1
+
The `BrowserTracing` integration creates a new transaction for each page load and navigation event, and creates a child span for every `XMLHttpRequest` or `fetch` request that occurs while those transactions are open.
2
+
Additionally, the SDK creates transactions for all requests to API routes and [Next.js Data Fetchers](https://nextjs.org/docs/basic-features/data-fetching/overview).
3
+
Learn more about [traces, transactions, and spans](/product/sentry-basics/tracing/distributed-tracing/).
Copy file name to clipboardExpand all lines: src/platforms/javascript/guides/nextjs/manual-setup.mdx
-23Lines changed: 0 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -47,29 +47,6 @@ Sentry.init({
47
47
});
48
48
```
49
49
50
-
If you want to instrument [Next.js API Routes](https://nextjs.org/docs/api-routes/introduction), which run on serverless, you need to wrap your handler in our `withSentry` wrapper in order to be able to capture crashes:
0 commit comments