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
In that case you can also skip the `sentry-cli` configuration step below.
243
244
245
+
### Automatically Instrument API Routes and Data Fetching Methods
246
+
247
+
_(New in version 7.14.0)_
248
+
249
+
The SDK provides an option to automatically instrument API routes and server-side [Next.js data fetching methods](https://nextjs.org/docs/basic-features/data-fetching/overview) with error and performance monitoring, removing the need to manually wrap API routes in `withSentry`:
250
+
251
+
```javascript {filename:next.config.js}
252
+
constmoduleExports= {
253
+
sentry: {
254
+
autoInstrumentServerFunctions:true,
255
+
},
256
+
};
257
+
```
258
+
259
+
Under the hood, the SDK is using a Webpack loader to wrap all your API route handlers and data fetching methods.
260
+
261
+
If the automatic instrumentation doesn't work for your use case, API routes can also be wrapped manually using the `withSentry` function:
Data fetching methods can also be manually wrapped using the following functions:
285
+
286
+
-`withSentryServerSideGetInitialProps` for `getInitialProps`
287
+
-`withSentryGetServerSideProps` for `getServerSideProps`
288
+
-`withSentryGetStaticProps` for `getStaticProps`
289
+
-`withSentryServerSideErrorGetInitialProps` for `getInitialProps` in [custom Error pages](https://nextjs.org/docs/advanced-features/custom-error-page)
290
+
-`withSentryServerSideAppGetInitialProps` for `getInitialProps` in [custom `App` components](https://nextjs.org/docs/advanced-features/custom-app)
291
+
-`withSentryServerSideDocumentGetInitialProps` for `getInitialProps` in [custom `Document` components](https://nextjs.org/docs/advanced-features/custom-document)
292
+
244
293
### Use `hidden-source-map`
245
294
246
295
_(New in version 6.17.1, will default to `true` in 8.0.0 and beyond.)_
0 commit comments