Draft
Integrate Sentry error monitoring and remove Discord webhook alerts#314
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: owens1127 <98496129+owens1127@users.noreply.github.com>
Co-authored-by: owens1127 <98496129+owens1127@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Integrate Sentry for error monitoring in Next.js app
Integrate Sentry error monitoring and remove Discord webhook alerts
Feb 6, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces Discord webhook-based error alerting with Sentry for comprehensive error monitoring across client, server, edge, and API layers.
Implementation
Configuration & Instrumentation
sentry.server.config.ts,sentry.edge.config.ts) and instrumentation hooks (src/instrumentation.ts,src/instrumentation-client.ts)withSentryConfig, enabling source map uploads, tunnel route (/monitoring), and Vercel monitors integrationError Capture Points
global-error.tsx,error.tsx) now callSentry.captureException()Sentry.withScope()Removed
sendDiscordWebhook, 50+ lines of embed formatting)Example
Environment Variables Required
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
checkpoint.prisma.io/opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node /home/REDACTED/work/Web-App/Web-App/node_modules/prisma/build/child {"product":"prisma","version":"6.5.0","cli_install_type":"local","information":"","local_timestamp":"2026-02-06T05:41:06Z","project_hash":"e746e93b","cli_path":"/home/REDACTED/work/Web-App/Web-App/node_modules/.bin/prisma","cli_path_hash":"d1777587","endpoi(dns block)/opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node /home/REDACTED/work/Web-App/Web-App/node_modules/prisma/build/child {"product":"prisma","version":"6.5.0","cli_install_type":"local","information":"","local_timestamp":"2026-02-06T05:41:07Z","project_hash":"e746e93b","cli_path":"/home/REDACTED/work/Web-App/Web-App/node_modules/.bin/prisma","cli_path_hash":"d1777587","endpoi(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Overview
Integrate Sentry for comprehensive error monitoring across the entire Next.js App Router application. The app currently relies on
console.errorand Discord webhooks for error visibility. Sentry should be added to capture errors from the client-side, server-side, API routes (tRPC), and auth flows.Codebase Context
This is a Next.js App Router project using:
package.jsonscripts)/api/trpc/[trpc]/route.ts)/api/auth/[...nextauth]/route.ts)VERCEL_URL,DEPLOY_URLenv vars)next.config.js(CommonJS) with@next/bundle-analyzerKey Files to Modify
package.json— Add@sentry/nextjsas a dependency.next.config.js— Wrap the existing config withwithSentryConfigfrom@sentry/nextjs. Preserve the existingwithBundleAnalyzerwrapper and all other config. UsewithSentryConfigas the outermost wrapper. Configure Sentry webpack plugin options including:organdprojectshould read fromprocess.env.SENTRY_ORGandprocess.env.SENTRY_PROJECTsilent: !process.env.CI(only log in CI)widenClientFileUpload,tunnelRoute(use/monitoring),hideSourceMaps,disableLogger, andautomaticVercelMonitorssrc/instrumentation.ts— Create a new Next.js instrumentation file that callsSentry.initfor the server (Node.js) runtime. This is the recommended way to initialize Sentry on the server in Next.js App Router. Import from the appropriate Sentry config file.src/instrumentation-client.ts— Create a new Next.js client instrumentation file that callsSentry.initfor the browser runtime. Configure:dsnfromprocess.env.NEXT_PUBLIC_SENTRY_DSNtracesSampleRate: 1.0replaysSessionSampleRate: 0.1replaysOnErrorSampleRate: 1.0Sentry.replayIntegration()environmentbased onprocess.env.NEXT_PUBLIC_APP_ENV ?? "development"sentry.server.config.ts— Create a Sentry server config file:dsnfromprocess.env.NEXT_PUBLIC_SENTRY_DSNtracesSampleRate: 1.0environmentbased onprocess.env.APP_ENV ?? "development"sentry.edge.config.ts— Create a Sentry edge config file with the same settings as server config (for edge runtime API routes like the Ko-fi webhook atsrc/app/api/webhooks/kofi/route.ts).src/app/global-error.tsx— Update the existing global error boundary to capture exceptions with Sentry. Currently it only doesconsole.error(error). It should:Sentry.captureException(error)in theuseEffectCurrent file:
src/app/error.tsx— Update the existing error boundary to capture exceptions with Sentry. Currently it only doesconsole.error(err). It should:Sentry.captureException(error)in theuseEffect(alongside the existing console.error)Current file:
src/lib/server/trpc/error-handler.ts— AddSentry.captureException(error)to the tRPC error handler, alongside the existing Discord webhook notification. Import Sentry withimport * as Sentry from "@sentry/nextjs". CallSentry.captureExceptionwith extra context (path, input, source) set viaSentry.setContextorSentry.withScope. This should happen unconditionally (not gated behind production check like the Discord webhook).Current file:
This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.