React Router v3
了解 Sentry 的 React Router v3 集成。
要使用路由集成,导入并设置自定义路由仪器,并传递 history、你的路由和一个 match 函数。React Router v3 支持维护在 React Router >= 3.2.0 和 < 4.0.0。
Copied
import * as Router from "react-router";
import * as Sentry from "@sentry/react";
// Routes looks like this:
const routes = (
<Route path="/">
<Route path="organizations/">
<Route path=":orgid" component={() => <div>OrgId</div>} />
<Route path=":orgid/v1/:teamid" component={() => <div>Team</div>} />
</Route>
</Route>
);
Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
integrations: [
Sentry.reactRouterV3BrowserTracingIntegration({
history: Router.browserHistory,
// Must be Plain Routes.
routes: Router.createRoutes(routes),
match: Router.match,
}),
],
// We recommend adjusting this value in production, or using tracesSampler
// for finer control
tracesSampleRate: 1.0,
});