-
Notifications
You must be signed in to change notification settings - Fork 73
Add App Router error boundaries, Sentry monitoring, and PII scrubbing… #119
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
Open
Victorjonah-prog
wants to merge
3
commits into
Deen-Bridge:dev
Choose a base branch
from
Victorjonah-prog:fix/issue-109-error-monitoring
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
81386ae
Add App Router error boundaries, Sentry monitoring, and PII scrubbing…
Victorjonah-prog ec2af96
Merge remote-tracking branch 'upstream/dev' into fix/issue-109-error-…
Victorjonah-prog fb23912
fix: tag donation failures as stellar-donation, recursively scrub ext…
Victorjonah-prog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect, useState } from "react"; | ||
| import * as Sentry from "@sentry/nextjs"; | ||
|
|
||
| export default function CoursesError({ error, reset }) { | ||
| const [eventId, setEventId] = useState(null); | ||
|
|
||
| useEffect(() => { | ||
| const id = Sentry.captureException(error); | ||
| setEventId(id); | ||
| }, [error]); | ||
|
|
||
| return ( | ||
| <div className="flex-1 w-full flex flex-col items-center justify-center px-6 py-16 text-center"> | ||
| <div className="max-w-md"> | ||
| <h2 className="text-xl font-bold text-[#252F40] mb-3"> | ||
| Couldn't load this course | ||
| </h2> | ||
| <p className="text-sm text-gray-500 mb-8"> | ||
| We ran into a problem fetching your course content. Please retry. | ||
| </p> | ||
| <button | ||
| type="button" | ||
| onClick={() => reset()} | ||
| className="px-5 py-2.5 rounded-lg bg-[#34AD5D] text-white text-sm font-medium hover:bg-[#2c9350] transition-colors" | ||
| > | ||
| Retry | ||
| </button> | ||
| {eventId && ( | ||
| <p className="mt-6 text-xs text-gray-400">Report ID: {eventId}</p> | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect, useState } from "react"; | ||
| import * as Sentry from "@sentry/nextjs"; | ||
|
|
||
| // Renders inside app/dashboard/layout.jsx's <SidebarInset>, so the sidebar | ||
| // and nav header stay usable while just this segment shows the fallback. | ||
| export default function DashboardError({ error, reset }) { | ||
| const [eventId, setEventId] = useState(null); | ||
|
|
||
| useEffect(() => { | ||
| const id = Sentry.captureException(error); | ||
| setEventId(id); | ||
| }, [error]); | ||
|
|
||
| return ( | ||
| <div className="flex-1 w-full flex flex-col items-center justify-center px-6 py-16 text-center"> | ||
| <div className="max-w-md"> | ||
| <h2 className="text-xl font-bold text-[#252F40] mb-3"> | ||
| This page ran into a problem | ||
| </h2> | ||
| <p className="text-sm text-gray-500 mb-8"> | ||
| Something went wrong loading your dashboard. Try again, or use the | ||
| sidebar to head somewhere else. | ||
| </p> | ||
| <button | ||
| type="button" | ||
| onClick={() => reset()} | ||
| className="px-5 py-2.5 rounded-lg bg-[#34AD5D] text-white text-sm font-medium hover:bg-[#2c9350] transition-colors" | ||
| > | ||
| Try again | ||
| </button> | ||
| {eventId && ( | ||
| <p className="mt-6 text-xs text-gray-400">Report ID: {eventId}</p> | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect, useState } from "react"; | ||
| import * as Sentry from "@sentry/nextjs"; | ||
|
|
||
| export default function LibraryError({ error, reset }) { | ||
| const [eventId, setEventId] = useState(null); | ||
|
|
||
| useEffect(() => { | ||
| const id = Sentry.captureException(error); | ||
| setEventId(id); | ||
| }, [error]); | ||
|
|
||
| return ( | ||
| <div className="flex-1 w-full flex flex-col items-center justify-center px-6 py-16 text-center"> | ||
| <div className="max-w-md"> | ||
| <h2 className="text-xl font-bold text-[#252F40] mb-3"> | ||
| Couldn't load your library | ||
| </h2> | ||
| <p className="text-sm text-gray-500 mb-8"> | ||
| We ran into a problem fetching this content. Please retry. | ||
| </p> | ||
| <button | ||
| type="button" | ||
| onClick={() => reset()} | ||
| className="px-5 py-2.5 rounded-lg bg-[#34AD5D] text-white text-sm font-medium hover:bg-[#2c9350] transition-colors" | ||
| > | ||
| Retry | ||
| </button> | ||
| {eventId && ( | ||
| <p className="mt-6 text-xs text-gray-400">Report ID: {eventId}</p> | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect, useState } from "react"; | ||
| import * as Sentry from "@sentry/nextjs"; | ||
|
|
||
| // Kept dependency-light on purpose (no toasts, providers, or design-system | ||
| // imports) so this boundary can't itself throw while trying to render a | ||
| // recovery UI for an unrelated error. | ||
| export default function Error({ error, reset }) { | ||
| const [eventId, setEventId] = useState(null); | ||
|
|
||
| useEffect(() => { | ||
| const id = Sentry.captureException(error); | ||
| setEventId(id); | ||
| }, [error]); | ||
|
|
||
| return ( | ||
| <div className="min-h-[60vh] w-full flex flex-col items-center justify-center px-6 py-16 text-center"> | ||
| <div className="max-w-md"> | ||
| <h1 className="text-2xl font-bold text-[#252F40] mb-3"> | ||
| Something went wrong | ||
| </h1> | ||
| <p className="text-sm text-gray-500 mb-8"> | ||
| An unexpected error occurred while loading this page. You can try | ||
| again, or head back to the homepage. | ||
| </p> | ||
| <div className="flex items-center justify-center gap-3"> | ||
| <button | ||
| type="button" | ||
| onClick={() => reset()} | ||
| className="px-5 py-2.5 rounded-lg bg-[#34AD5D] text-white text-sm font-medium hover:bg-[#2c9350] transition-colors" | ||
| > | ||
| Try again | ||
| </button> | ||
| <a | ||
| href="/" | ||
| className="px-5 py-2.5 rounded-lg border border-gray-200 text-[#252F40] text-sm font-medium hover:bg-gray-50 transition-colors" | ||
| > | ||
| Go home | ||
| </a> | ||
| </div> | ||
| {eventId && ( | ||
| <p className="mt-6 text-xs text-gray-400">Report ID: {eventId}</p> | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect, useState } from "react"; | ||
| import * as Sentry from "@sentry/nextjs"; | ||
|
|
||
| // This only activates in production builds (test with `npm run build && npm | ||
| // start`). No app providers, fonts, or global stylesheet are guaranteed to | ||
| // be available here, so this stays fully self-contained with inline styles | ||
| // and renders its own <html>/<body>. | ||
| export default function GlobalError({ error, reset }) { | ||
| const [eventId, setEventId] = useState(null); | ||
|
|
||
| useEffect(() => { | ||
| const id = Sentry.captureException(error); | ||
| setEventId(id); | ||
| }, [error]); | ||
|
|
||
| return ( | ||
| <html lang="en"> | ||
| <body | ||
| style={{ | ||
| margin: 0, | ||
| minHeight: "100vh", | ||
| display: "flex", | ||
| flexDirection: "column", | ||
| alignItems: "center", | ||
| justifyContent: "center", | ||
| padding: "24px", | ||
| textAlign: "center", | ||
| fontFamily: | ||
| "-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif", | ||
| backgroundColor: "#ffffff", | ||
| color: "#252F40", | ||
| }} | ||
| > | ||
| <div style={{ maxWidth: 420 }}> | ||
| <h1 style={{ fontSize: 24, fontWeight: 700, marginBottom: 12 }}> | ||
| Deen Bridge | ||
| </h1> | ||
| <p style={{ fontSize: 15, color: "#6b7280", marginBottom: 28 }}> | ||
| Something went wrong and this page couldn't load. Please | ||
| reload to try again. | ||
| </p> | ||
| <button | ||
| type="button" | ||
| onClick={() => reset()} | ||
| style={{ | ||
| padding: "10px 20px", | ||
| borderRadius: 8, | ||
| border: "none", | ||
| backgroundColor: "#34AD5D", | ||
| color: "#ffffff", | ||
| fontSize: 14, | ||
| fontWeight: 500, | ||
| cursor: "pointer", | ||
| }} | ||
| > | ||
| Reload | ||
| </button> | ||
| {eventId && ( | ||
| <p style={{ marginTop: 20, fontSize: 12, color: "#9ca3af" }}> | ||
| Report ID: {eventId} | ||
| </p> | ||
| )} | ||
| </div> | ||
| </body> | ||
| </html> | ||
| ); | ||
| } |
This file was deleted.
Oops, something went wrong.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // This file configures the initialization of Sentry on the client. | ||
| // The config you add here will be used whenever a users loads a page in their browser. | ||
| // https://docs.sentry.io/platforms/javascript/guides/nextjs/ | ||
|
|
||
| import * as Sentry from "@sentry/nextjs"; | ||
| import { | ||
| sentryBeforeSend, | ||
| sentryBeforeSendTransaction, | ||
| IGNORED_ERRORS, | ||
| } from "./sentry.shared.config"; | ||
|
|
||
| Sentry.init({ | ||
| dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, | ||
|
|
||
| // Never send cookies, headers, or IP addresses by default. Scrubbing in | ||
| // beforeSend below is a defense-in-depth backstop, not the primary control. | ||
| sendDefaultPii: false, | ||
|
|
||
| environment: process.env.NODE_ENV, | ||
|
|
||
| // Adjust this value in production, or use tracesSampler for greater control. | ||
| tracesSampleRate: 0.1, | ||
|
|
||
| // Known noisy, non-actionable errors (e.g. closing the Stellar wallet | ||
| // connect modal) should never create an event. | ||
| ignoreErrors: IGNORED_ERRORS, | ||
|
|
||
| beforeSend: sentryBeforeSend, | ||
| beforeSendTransaction: sentryBeforeSendTransaction, | ||
| }); | ||
|
|
||
| export const onRouterTransitionStart = Sentry.captureRouterTransitionStart; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| export async function register() { | ||
| if (process.env.NEXT_RUNTIME === "nodejs") { | ||
| await import("./sentry.server.config"); | ||
| } | ||
|
|
||
| if (process.env.NEXT_RUNTIME === "edge") { | ||
| await import("./sentry.edge.config"); | ||
| } | ||
| } | ||
|
|
||
| export const onRequestError = async (...args) => { | ||
| const Sentry = await import("@sentry/nextjs"); | ||
| Sentry.captureRequestError(...args); | ||
| }; |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.