import type { LoaderFunctionArgs } from "react-router"; import { useEffect } from "react"; import { useTranslation } from "react-i18next"; /** * Sentry smoke-test route — `/client-throw`. * * The `__test` filename segment is pathless under the v1 compatibility route * convention; the public diagnostic URL therefore starts at `client-throw`. * * Only available in non-production builds OR when SENTRY_TEST_ROUTES=true * is set on the SSR runtime. The loader returns a 404 in production so * this route cannot be used as a DoS lever in a live deployment. * * Usage: * 1. Build + deploy with SENTRY_TEST_ROUTES=true on staging. * 2. Open the URL in a browser — the component will throw synchronously * during render, the React-Router root ErrorBoundary catches it and * Sentry.captureException reports the error. * * @see docs/improvement-plan/02-observability/sentry-wiring-web.md (Step 11) */ export async function loader({}: LoaderFunctionArgs) { if (!testRoutesEnabled()) { throw new Response(null, { status: 404 }); } return new Response(null, { status: 200 }); } export default function ClientThrow() { const { t } = useTranslation(); useEffect(() => { throw new Error("phase-02-sentry-smoke: client-side throw"); }, []); return (
{t("diagnostics.sentry.clientSmoke.description")}