|
| 1 | +import * as Sentry from '@sentry/react'; |
| 2 | +import React from 'react'; |
| 3 | +import ReactDOM from 'react-dom/client'; |
| 4 | +import { |
| 5 | + BrowserRouter, |
| 6 | + Route, |
| 7 | + Routes, |
| 8 | + createRoutesFromChildren, |
| 9 | + matchRoutes, |
| 10 | + useLocation, |
| 11 | + useNavigationType, |
| 12 | +} from 'react-router-dom'; |
| 13 | +import Index from './pages/Index'; |
| 14 | + |
| 15 | +const replay = Sentry.replayIntegration(); |
| 16 | + |
| 17 | +Sentry.init({ |
| 18 | + environment: 'qa', // dynamic sampling bias to keep transactions |
| 19 | + dsn: process.env.REACT_APP_E2E_TEST_DSN, |
| 20 | + integrations: [ |
| 21 | + Sentry.reactRouterV6BrowserTracingIntegration({ |
| 22 | + useEffect: React.useEffect, |
| 23 | + useLocation, |
| 24 | + useNavigationType, |
| 25 | + createRoutesFromChildren, |
| 26 | + matchRoutes, |
| 27 | + trackFetchStreamPerformance: true, |
| 28 | + }), |
| 29 | + replay, |
| 30 | + ], |
| 31 | + // We recommend adjusting this value in production, or using tracesSampler |
| 32 | + // for finer control |
| 33 | + tracesSampleRate: 1.0, |
| 34 | + release: 'e2e-test', |
| 35 | + |
| 36 | + // Always capture replays, so we can test this properly |
| 37 | + replaysSessionSampleRate: 1.0, |
| 38 | + replaysOnErrorSampleRate: 0.0, |
| 39 | + |
| 40 | + tunnel: 'http://localhost:3031', |
| 41 | +}); |
| 42 | + |
| 43 | +const SentryRoutes = Sentry.withSentryReactRouterV6Routing(Routes); |
| 44 | + |
| 45 | +const DetailsRoutes = () => ( |
| 46 | + <SentryRoutes> |
| 47 | + <Route path=":detailId" element={<div id="details">Details</div>} /> |
| 48 | + </SentryRoutes> |
| 49 | +); |
| 50 | + |
| 51 | +const ViewsRoutes = () => ( |
| 52 | + <SentryRoutes> |
| 53 | + <Route index element={<div id="views">Views</div>} /> |
| 54 | + <Route path="views/:viewId/*" element={<DetailsRoutes />} /> |
| 55 | + </SentryRoutes> |
| 56 | +); |
| 57 | + |
| 58 | +const ProjectsRoutes = () => ( |
| 59 | + <SentryRoutes> |
| 60 | + <Route path="projects/:projectId/*" element={<ViewsRoutes />}></Route> |
| 61 | + <Route path="*" element={<div>No Match Page</div>} /> |
| 62 | + </SentryRoutes> |
| 63 | +); |
| 64 | + |
| 65 | +const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement); |
| 66 | +root.render( |
| 67 | + <BrowserRouter> |
| 68 | + <SentryRoutes> |
| 69 | + <Route path="/" element={<Index />} /> |
| 70 | + <Route path="/*" element={<ProjectsRoutes />}></Route> |
| 71 | + </SentryRoutes> |
| 72 | + </BrowserRouter>, |
| 73 | +); |
0 commit comments