From 7e7e92b89a51569a7e31f89d11b9a8ad620678a7 Mon Sep 17 00:00:00 2001 From: gibbyb Date: Tue, 16 Sep 2025 14:56:41 -0500 Subject: [PATCH] Remove sentry example page. Fix global error page --- apps/next/sentry.server.config.ts | 4 +- .../(sentry)/api/sentry-example-api/route.ts | 14 -- .../app/(sentry)/sentry-example-page/page.tsx | 209 ------------------ apps/next/src/app/global-error.tsx | 60 +++-- apps/next/src/env.js | 10 +- 5 files changed, 37 insertions(+), 260 deletions(-) delete mode 100644 apps/next/src/app/(sentry)/api/sentry-example-api/route.ts delete mode 100644 apps/next/src/app/(sentry)/sentry-example-page/page.tsx diff --git a/apps/next/sentry.server.config.ts b/apps/next/sentry.server.config.ts index 39d20bc..f4cd711 100644 --- a/apps/next/sentry.server.config.ts +++ b/apps/next/sentry.server.config.ts @@ -1,5 +1,5 @@ -import { env } from './src/env.js' -import * as Sentry from "@sentry/nextjs"; +import { env } from './src/env.js'; +import * as Sentry from '@sentry/nextjs'; Sentry.init({ dsn: env.NEXT_PUBLIC_SENTRY_DSN, diff --git a/apps/next/src/app/(sentry)/api/sentry-example-api/route.ts b/apps/next/src/app/(sentry)/api/sentry-example-api/route.ts deleted file mode 100644 index a830cfa..0000000 --- a/apps/next/src/app/(sentry)/api/sentry-example-api/route.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NextResponse } from "next/server"; - -export const dynamic = "force-dynamic"; -class SentryExampleAPIError extends Error { - constructor(message: string | undefined) { - super(message); - this.name = "SentryExampleAPIError"; - } -} -// A faulty API route to test Sentry's error monitoring -export function GET() { - throw new SentryExampleAPIError("This error is raised on the backend called by the example page."); - return NextResponse.json({ data: "Testing Sentry Error..." }); -} diff --git a/apps/next/src/app/(sentry)/sentry-example-page/page.tsx b/apps/next/src/app/(sentry)/sentry-example-page/page.tsx deleted file mode 100644 index 5ac5dcd..0000000 --- a/apps/next/src/app/(sentry)/sentry-example-page/page.tsx +++ /dev/null @@ -1,209 +0,0 @@ -"use client"; - -import Head from "next/head"; -import * as Sentry from "@sentry/nextjs"; -import { useState, useEffect } from "react"; - -class SentryExampleFrontendError extends Error { - constructor(message: string | undefined) { - super(message); - this.name = "SentryExampleFrontendError"; - } -} - -export default function Page() { - const [hasSentError, setHasSentError] = useState(false); - const [isConnected, setIsConnected] = useState(true); - - useEffect(() => { - async function checkConnectivity() { - const result = await Sentry.diagnoseSdkConnectivity(); - setIsConnected(result !== 'sentry-unreachable'); - } - void checkConnectivity(); - }, []); - - return ( -
- - sentry-example-page - - - -
-
- - - -

- sentry-example-page -

- -

- Click the button below, and view the sample error on the Sentry Issues Page. - For more details about setting up Sentry, read our docs. -

- - - - {hasSentError ? ( -

- Error sent to Sentry. -

- ) : !isConnected ? ( -
-

It looks like network requests to Sentry are being blocked, which will prevent errors from being captured. Try disabling your ad-blocker to complete the test.

-
- ) : ( -
- )} - -
- -
- - -
- ); -} diff --git a/apps/next/src/app/global-error.tsx b/apps/next/src/app/global-error.tsx index 965d699..c309c94 100644 --- a/apps/next/src/app/global-error.tsx +++ b/apps/next/src/app/global-error.tsx @@ -38,38 +38,36 @@ const GlobalError = ({ error, reset = undefined }: GlobalErrorProps) => { Sentry.captureException(error); }, [error]); return ( - - - - + + + - - - -
-
- - {reset !== undefined && ( - - )} - -
- - - - - - - + + +
+
+ + {reset !== undefined && ( + + )} + +
+ + + + + + ); }; export default GlobalError; diff --git a/apps/next/src/env.js b/apps/next/src/env.js index de82473..5f92cbb 100644 --- a/apps/next/src/env.js +++ b/apps/next/src/env.js @@ -12,10 +12,12 @@ export const env = createEnv({ }, client: { NEXT_PUBLIC_SITE_URL: z.url().default('http://localhost:3000'), - NEXT_PUBLIC_CONVEX_URL: z.url().default('https://api.dev.convex.gbrown.org'), - NEXT_PUBLIC_SENTRY_DSN: z.url().default( - 'https://96df775337cce23d925616dd5aea8857@sentry.gbrown.org/2' - ), + NEXT_PUBLIC_CONVEX_URL: z + .url() + .default('https://api.dev.convex.gbrown.org'), + NEXT_PUBLIC_SENTRY_DSN: z + .url() + .default('https://96df775337cce23d925616dd5aea8857@sentry.gbrown.org/2'), NEXT_PUBLIC_SENTRY_URL: z.url().default('https://sentry.gbrown.org'), NEXT_PUBLIC_SENTRY_ORG: z.string().default('gib'), NEXT_PUBLIC_SENTRY_PROJECT_NAME: z.string().default('techtracker-next'),