Skip to content

Commit

Permalink
🐛 fix(custom): 修复sentry提交自身报错信息
Browse files Browse the repository at this point in the history
  • Loading branch information
master1lan committed Apr 9, 2023
1 parent a76c02a commit 61b7509
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 34 deletions.
73 changes: 40 additions & 33 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 5 additions & 1 deletion src/routers/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ export default function ErrorPage() {
🤯🤯🤯有什么出错了
</h1>
<p>
当您看到这个页面时,表示您进入了一个不存在的页面,网站目前仅开放
当您看到这则提示时,表示您遇到了一个bug。网站目前仅开放
<Link to={"/"}>
<Button>首页</Button>
</Link>
<Link to={"/video"}>
<Button>视频页</Button>
</Link>
<Link to={"/online"}>
<Button>eu都在溜什么页</Button>
</Link>
<Link to={"/photo"}>
<Button>图片页</Button>
Expand Down

0 comments on commit 61b7509

Please sign in to comment.