More sentry monitoring
This commit is contained in:
@@ -1 +1 @@
|
||||
v22.20.0
|
||||
v24.14.0
|
||||
@@ -2,16 +2,20 @@ import { CacheProvider } from "@emotion/react";
|
||||
import { ClientStyleContext } from "./context.js";
|
||||
import createEmotionCache from "./createEmotionCache.js";
|
||||
import { hydrateRoot } from "react-dom/client";
|
||||
import { RemixBrowser } from "@remix-run/react";
|
||||
import * as Sentry from "@sentry/react";
|
||||
import { type ReactNode, StrictMode, useState } from "react";
|
||||
import { RemixBrowser, useLocation, useMatches } from "@remix-run/react";
|
||||
import * as Sentry from "@sentry/remix";
|
||||
import { type ReactNode, StrictMode, useEffect, useState } from "react";
|
||||
|
||||
Sentry.init({
|
||||
dsn:
|
||||
document.querySelector("meta[name='dsn']")?.getAttribute("content") ??
|
||||
undefined,
|
||||
integrations: [
|
||||
Sentry.browserTracingIntegration(),
|
||||
Sentry.browserTracingIntegration({
|
||||
useEffect,
|
||||
useLocation,
|
||||
useMatches,
|
||||
}),
|
||||
Sentry.replayIntegration(),
|
||||
],
|
||||
replaysOnErrorSampleRate: 1,
|
||||
|
||||
@@ -5,6 +5,7 @@ import { type EntryContext } from "@remix-run/cloudflare";
|
||||
import { RemixServer } from "@remix-run/react";
|
||||
import { renderToString } from "react-dom/server";
|
||||
import { ServerStyleContext } from "./context.js";
|
||||
import * as Sentry from "@sentry/remix";
|
||||
|
||||
export default function handleRequest(
|
||||
request: Request,
|
||||
@@ -39,3 +40,5 @@ export default function handleRequest(
|
||||
status: responseStatusCode,
|
||||
});
|
||||
}
|
||||
|
||||
export const handleError = Sentry.sentryHandleError;
|
||||
|
||||
122
app/root.tsx
122
app/root.tsx
@@ -18,6 +18,7 @@ import {
|
||||
Scripts,
|
||||
useLoaderData,
|
||||
useRouteError,
|
||||
useRouteLoaderData,
|
||||
} from "@remix-run/react";
|
||||
import { type ErrorResponse } from "@remix-run/router";
|
||||
import { LinksFunction } from "@remix-run/cloudflare";
|
||||
@@ -26,71 +27,85 @@ import Navigation from "../components/Navigation.js";
|
||||
import { type ReactNode, StrictMode, useContext, useEffect } from "react";
|
||||
import theme from "../theme.js";
|
||||
import { withEmotionCache } from "@emotion/react";
|
||||
import { captureRemixErrorBoundaryError, withSentry } from "@sentry/remix";
|
||||
|
||||
export function ErrorBoundary() {
|
||||
const error = useRouteError() as ErrorResponse;
|
||||
|
||||
if (!isRouteErrorResponse(error))
|
||||
return getMarkup(
|
||||
{ hide: true },
|
||||
<Container maxW="container.lg" pt="8vh" textAlign="left">
|
||||
<Heading size="4xl">???</Heading>
|
||||
<br />
|
||||
<Text fontSize="xl">Something bad happened!</Text>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<Text>Details: {error}</Text>
|
||||
<br />
|
||||
<br />
|
||||
<Link color="#646cff" onClick={() => location.reload()}>
|
||||
Refresh
|
||||
</Link>
|
||||
</Container>,
|
||||
return (
|
||||
<DocumentWrapper loaderData={{ hide: true }}>
|
||||
<Container maxW="container.lg" pt="8vh" textAlign="left">
|
||||
<Heading size="4xl">???</Heading>
|
||||
<br />
|
||||
<Text fontSize="xl">Something bad happened!</Text>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<Text>Details: {error}</Text>
|
||||
<br />
|
||||
<br />
|
||||
<Link color="#646cff" onClick={() => location.reload()}>
|
||||
Refresh
|
||||
</Link>
|
||||
</Container>
|
||||
</DocumentWrapper>
|
||||
);
|
||||
|
||||
const { status } = error;
|
||||
const loaderData = useRouteLoaderData<typeof loader>("root") || {};
|
||||
|
||||
switch (status) {
|
||||
case 303:
|
||||
return "";
|
||||
|
||||
case 401:
|
||||
return getMarkup({ hide: true }, <Login />);
|
||||
return (
|
||||
<DocumentWrapper loaderData={loaderData}>
|
||||
<Login />
|
||||
</DocumentWrapper>
|
||||
);
|
||||
|
||||
case 403:
|
||||
return getMarkup({ hide: true }, <Forbidden />);
|
||||
return (
|
||||
<DocumentWrapper loaderData={loaderData}>
|
||||
<Forbidden />
|
||||
</DocumentWrapper>
|
||||
);
|
||||
|
||||
case 404:
|
||||
return getMarkup(
|
||||
{ hide: true },
|
||||
<Container maxW="container.lg" pt="8vh" textAlign="left">
|
||||
<Heading size="4xl">404</Heading>
|
||||
<br />
|
||||
<Text fontSize="xl">There is nothing to find here.</Text>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<Link color="#646cff" onClick={() => history.go(-1)}>
|
||||
Go back
|
||||
</Link>
|
||||
</Container>,
|
||||
return (
|
||||
<DocumentWrapper loaderData={loaderData}>
|
||||
<Container maxW="container.lg" pt="8vh" textAlign="left">
|
||||
<Heading size="4xl">404</Heading>
|
||||
<br />
|
||||
<Text fontSize="xl">There is nothing to find here.</Text>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<Link color="#646cff" onClick={() => history.go(-1)}>
|
||||
Go back
|
||||
</Link>
|
||||
</Container>
|
||||
</DocumentWrapper>
|
||||
);
|
||||
|
||||
default:
|
||||
return getMarkup(
|
||||
{ hide: true },
|
||||
<Container maxW="container.lg" pt="8vh" textAlign="left">
|
||||
<Heading size="4xl">500</Heading>
|
||||
<br />
|
||||
<Text fontSize="xl">S̶̡͈̠̗̠͖͙̭o̶̶͕͚̥͍̪̤m̸̨͏͈͔̖͚̖̰̱͞e҉̵͖͚͇̀t̕͟͠͏͎̺̯̲̱̣̤̠̟͙̠̙̫̬ḩ̸̭͓̬͎̙̀į̞̮͉͖̰̥̹͚̫̙̪̗̜̳̕ͅn҉͔̯̪̗̝̝͖̲͇͍͎̲̲̤̖̫͈̪͡g̴̰̻̙̝͉̭͇̖̰̝̙͕̼͙͘͜ ̵̶̫̥̳̲̘̻̗͈͕̭̲͇̘̜̺̟̥̖̥b̴̙̭̹͕̞͠r̞͎̠̩͈̖̰̞̯̯͢͢͠ͅo̝̯̗̹̳͍̰͉͕̘̰̠̺̥̰͔̕ͅk̵̸̻̠͕̺̦̦͖̲̺̦̞̝̞͞͡e̶͏̤̼̼͔̘̰̰̭͈̀͞͡</Text>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<Link color="#646cff" onClick={() => location.reload()}>
|
||||
Reload
|
||||
</Link>
|
||||
</Container>,
|
||||
captureRemixErrorBoundaryError(useRouteError());
|
||||
return (
|
||||
<DocumentWrapper loaderData={loaderData}>
|
||||
<Container maxW="container.lg" pt="8vh" textAlign="left">
|
||||
<Heading size="4xl">500</Heading>
|
||||
<br />
|
||||
<Text fontSize="xl">S̶̡͈̠̗̠͖͙̭o̶̶͕͚̥͍̪̤m̸̨͏͈͔̖͚̖̰̱͞e҉̵͖͚͇̀t̕͟͠͏͎̺̯̲̱̣̤̠̟͙̠̙̫̬ḩ̸̭͓̬͎̙̀į̞̮͉͖̰̥̹͚̫̙̪̗̜̳̕ͅn҉͔̯̪̗̝̝͖̲͇͍͎̲̲̤̖̫͈̪͡g̴̰̻̙̝͉̭͇̖̰̝̙͕̼͙͘͜ ̵̶̫̥̳̲̘̻̗͈͕̭̲͇̘̜̺̟̥̖̥b̴̙̭̹͕̞͠r̞͎̠̩͈̖̰̞̯̯͢͢͠ͅo̝̯̗̹̳͍̰͉͕̘̰̠̺̥̰͔̕ͅk̵̸̻̠͕̺̦̦͖̲̺̦̞̝̞͞͡e̶͏̤̼̼͔̘̰̰̭͈̀͞͡</Text>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<Link color="#646cff" onClick={() => location.reload()}>
|
||||
Reload
|
||||
</Link>
|
||||
</Container>
|
||||
</DocumentWrapper>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -123,10 +138,11 @@ export function meta() {
|
||||
return [{ title: "Car Crushers" }];
|
||||
}
|
||||
|
||||
function getMarkup(
|
||||
loaderData: { [k: string]: any },
|
||||
child: ReactNode,
|
||||
): JSX.Element {
|
||||
function DocumentWrapper(props: {
|
||||
loaderData: { [k: string]: any };
|
||||
children: ReactNode;
|
||||
}) {
|
||||
const { children: child, loaderData } = props;
|
||||
const Document = withEmotionCache(
|
||||
({ children }: { children: ReactNode }, emotionCache) => {
|
||||
const serverStyleData = useContext(ServerStyleContext);
|
||||
@@ -207,8 +223,14 @@ function getMarkup(
|
||||
return <Document>{child}</Document>;
|
||||
}
|
||||
|
||||
export default function () {
|
||||
function App() {
|
||||
const loaderData = useLoaderData<typeof loader>();
|
||||
|
||||
return getMarkup(loaderData, <Outlet />);
|
||||
return (
|
||||
<DocumentWrapper loaderData={loaderData}>
|
||||
<Outlet />
|
||||
</DocumentWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
export default withSentry(App);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import getPermissions from "./permissions.js";
|
||||
import { jsonError } from "./common.js";
|
||||
import * as Sentry from "@sentry/cloudflare";
|
||||
|
||||
async function constructHTML(context: RequestContext) {
|
||||
const { pathname } = new URL(context.request.url);
|
||||
@@ -354,6 +355,10 @@ async function setTheme(context: RequestContext) {
|
||||
}
|
||||
|
||||
export const onRequest = [
|
||||
Sentry.sentryPagesPlugin((context: RequestContext) => ({
|
||||
dsn: context.env.DSN,
|
||||
sendDefaultPii: true,
|
||||
})),
|
||||
setAuth,
|
||||
refreshAuth,
|
||||
setTheme,
|
||||
|
||||
2990
package-lock.json
generated
2990
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -16,17 +16,18 @@
|
||||
"@remix-run/cloudflare": "^2.17.4",
|
||||
"@remix-run/cloudflare-pages": "^2.17.4",
|
||||
"@remix-run/react": "^2.17.4",
|
||||
"@sentry/react": "^10.40.0",
|
||||
"@sentry/cloudflare": "^10.43.0",
|
||||
"@sentry/remix": "^10.43.0",
|
||||
"aws4fetch": "^1.0.20",
|
||||
"dayjs": "^1.11.19",
|
||||
"framer-motion": "^12.34.3",
|
||||
"framer-motion": "^12.35.2",
|
||||
"react": "^18.3.1",
|
||||
"react-big-calendar": "^1.19.4",
|
||||
"react-dom": "^18.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@remix-run/dev": "^2.17.4",
|
||||
"@types/node": "^24.10.13",
|
||||
"@types/node": "^24.12.0",
|
||||
"@types/react": "^18.3.28",
|
||||
"@types/react-big-calendar": "^1.16.3",
|
||||
"@types/react-dom": "^18.3.7",
|
||||
@@ -35,7 +36,7 @@
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"overrides": {
|
||||
"@cloudflare/workers-types": "^4.20260304.0"
|
||||
"@cloudflare/workers-types": "^4.20260310.1"
|
||||
},
|
||||
"prettier": {
|
||||
"endOfLine": "auto"
|
||||
|
||||
Reference in New Issue
Block a user