diff --git a/src/main.tsx b/src/main.tsx index 7e21f66..a87fa61 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -31,40 +31,47 @@ import { BrowserTracing } from "@sentry/tracing"; import SearchPage, { loader as SearchLoader } from "@routers/search"; import { RecoilRoot } from "recoil"; import React from "react"; -if (!isdev && isrelease) { - Sentry.init({ - dsn: "https://086f27258cce4d28aacc8c2719a683fb@sentry.vtb.link/3", - beforeSend(event, hint) { - if (event.exception) { - Sentry.showReportDialog({ eventId: event.event_id }); - } - return event; - }, - integrations: [ - new BrowserTracing({ - routingInstrumentation: Sentry.reactRouterV6Instrumentation( - React.useEffect, - useLocation, - useNavigationType, - createRoutesFromChildren, - matchRoutes - ), - }), - new Sentry.Replay({ - // Additional SDK configuration goes in here, for example: - maskAllText: true, - blockAllMedia: true, - }), - ], +Sentry.init({ + dsn: "https://086f27258cce4d28aacc8c2719a683fb@sentry.vtb.link/3", + environment: isdev ? "development" : isrelease ? "production" : "cloudflare", + beforeSend(event, hint) { + //这里是过滤掉sentry自身的报错 + if ( + event.level === "error" && + event.breadcrumbs?.some((item) => item.category === "sentry.event") + ) { + return null; + } + //遇到意外错误时 + if (event.exception) { + Sentry.showReportDialog({ eventId: event.event_id }); + } + return event; + }, + integrations: [ + new BrowserTracing({ + routingInstrumentation: Sentry.reactRouterV6Instrumentation( + React.useEffect, + useLocation, + useNavigationType, + createRoutesFromChildren, + matchRoutes + ), + }), + new Sentry.Replay({ + // Additional SDK configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for performance monitoring. - // We recommend adjusting this value in production - tracesSampleRate: 1.0, - replaysSessionSampleRate: 0.1, - replaysOnErrorSampleRate: 1.0, - }); -} + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production + tracesSampleRate: 1.0, + replaysSessionSampleRate: 0.1, + replaysOnErrorSampleRate: 1.0, +}); const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouter(createBrowserRouter); diff --git a/src/routers/error.tsx b/src/routers/error.tsx index 8eed330..b131952 100644 --- a/src/routers/error.tsx +++ b/src/routers/error.tsx @@ -21,7 +21,7 @@ export default function ErrorPage() { 🤯🤯🤯有什么出错了
- 当您看到这个页面时,表示您进入了一个不存在的页面,网站目前仅开放 + 当您看到这则提示时,表示您遇到了一个bug。网站目前仅开放 @@ -29,6 +29,10 @@ export default function ErrorPage() { + 、 + + + 和