Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove references to withSentry function in with-sentry example #41326

Merged
merged 2 commits into from Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/with-sentry/README.md
Expand Up @@ -7,7 +7,6 @@ This is an example showing how to use [Sentry](https://sentry.io) to catch and r
- `sentry.server.config.js` and `sentry.client.config.js` are used to configure and initialize Sentry
- `next.config.js` automatically injects Sentry into your app using `withSentryConfig`
- `_error.js` (which is rendered by Next.js when handling certain types of exceptions) is overridden so those exceptions can be passed along to Sentry
- Each API route is handled with `withSentry`

## Preview

Expand Down
6 changes: 1 addition & 5 deletions examples/with-sentry/pages/api/test1.js
@@ -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)
6 changes: 1 addition & 5 deletions examples/with-sentry/pages/api/test2.js
@@ -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)
6 changes: 1 addition & 5 deletions examples/with-sentry/pages/api/test3.js
@@ -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)
7 changes: 1 addition & 6 deletions examples/with-sentry/pages/api/test4.js
@@ -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)