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 4, 2023
1 parent f484bf0 commit 6003529
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import ReactDOM from "react-dom/client";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
import {
createBrowserRouter,
createRoutesFromChildren,
matchRoutes,
RouterProvider,
useLocation,
useNavigationType,
} from "react-router-dom";
//router page
import VideoPage from "./routers/video";
import Layout from "./routers/layout";
Expand All @@ -23,6 +30,7 @@ import * as Sentry from "@sentry/react";
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",
Expand All @@ -33,7 +41,15 @@ if (!isdev && isrelease) {
return event;
},
integrations: [
new BrowserTracing(),
new BrowserTracing({
routingInstrumentation: Sentry.reactRouterV6Instrumentation(
React.useEffect,
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes
),
}),
new Sentry.Replay({
// Additional SDK configuration goes in here, for example:
maskAllText: true,
Expand All @@ -44,13 +60,15 @@ if (!isdev && isrelease) {
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 0.5,
tracesSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});
}
const sentryCreateBrowserRouter =
Sentry.wrapCreateBrowserRouter(createBrowserRouter);

const router = createBrowserRouter([
const router = sentryCreateBrowserRouter([
{
path: "/",
element: <Layout />,
Expand Down

0 comments on commit 6003529

Please sign in to comment.