forked from vercel/next.js
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…ercel#41326) <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change that you're making: --> ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) ## Content In version [`7.15.0`](https://github.com/getsentry/sentry-javascript/releases/tag/7.15.0) of the `@sentry/nextjs` SDK we introduced a new build-time feature that removes the need for manually wrapping API routes. This PR removes all manual `withSentry` calls from the `with-sentry` example. Co-authored-by: Balázs Orbán <info@balazsorban.com>
- Loading branch information
Showing
5 changed files
with
4 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,10 +1,6 @@ | ||
import { withSentry } from '@sentry/nextjs' | ||
|
||
const doAsyncWork = () => Promise.reject(new Error('API Test 1')) | ||
doAsyncWork() | ||
|
||
async function handler(req, res) { | ||
export default function handler(req, res) { | ||
res.status(200).json({ name: 'John Doe' }) | ||
} | ||
|
||
export default withSentry(handler) |
This file contains 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 |
---|---|---|
@@ -1,13 +1,9 @@ | ||
import { withSentry } from '@sentry/nextjs' | ||
|
||
function work() { | ||
throw new Error('API Test 2') | ||
} | ||
|
||
work() | ||
|
||
async function handler(req, res) { | ||
export default function handler(req, res) { | ||
res.status(200).json({ name: 'John Doe' }) | ||
} | ||
|
||
export default withSentry(handler) |
This file contains 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 |
---|---|---|
@@ -1,13 +1,9 @@ | ||
import { withSentry } from '@sentry/nextjs' | ||
|
||
function work() { | ||
throw new Error('API Test 3') | ||
} | ||
|
||
async function handler(req, res) { | ||
export default function handler(req, res) { | ||
work() | ||
|
||
res.status(200).json({ name: 'John Doe' }) | ||
} | ||
|
||
export default withSentry(handler) |
This file contains 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 |
---|---|---|
@@ -1,16 +1,11 @@ | ||
import * as Sentry from '@sentry/nextjs' | ||
|
||
async function handler(req, res) { | ||
export default function handler(req, res) { | ||
try { | ||
throw new Error('API Test 4') | ||
} catch (error) { | ||
Sentry.captureException(error) | ||
} | ||
|
||
// Flushing before returning is necessary if deploying to Vercel, see | ||
// https://vercel.com/docs/platform/limits#streaming-responses | ||
await Sentry.flush(2000) | ||
res.status(200).json({ name: 'John Doe' }) | ||
} | ||
|
||
export default Sentry.withSentry(handler) |