Skip to content

Commit 616e321

Browse files
committed
feat: sentry instrumentation
1 parent 19692b7 commit 616e321

File tree

5 files changed

+46
-21
lines changed

5 files changed

+46
-21
lines changed

scripts/sentry-release.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
4+
5+
cd $SCRIPT_DIR/..
6+
7+
version="linguo@v$(cat package.json | jq -r .version)-$(git rev-parse --short HEAD)"
8+
sentry-cli releases new "$version"
9+
sentry-cli releases set-commits "$version" --auto
10+
11+
rm -rf dist/
12+
yarn build
13+
sentry-cli releases files $version upload-sourcemaps dist/
14+
15+
sentry-cli releases finalize "$version"
16+
17+
cd -

src/app/MainRouter.jsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { SWRConfig } from 'swr';
33
import { request } from 'graphql-request';
44

5-
import { Redirect, Route, Switch } from 'react-router-dom';
5+
import { Redirect, Switch } from 'react-router-dom';
66
import loadable from '@loadable/component';
77
import { Layout } from 'antd';
88
import { ConnectedRouter } from 'connected-react-router';
@@ -15,7 +15,7 @@ import Footer from '~/layout/Footer';
1515
import Navbar from '~/layout/Header/Navbar';
1616
import { DrawerMenu } from '~/layout/Header/Menu';
1717

18-
import { history } from '~/store';
18+
import { history, SentryRoute } from '~/store';
1919
import Content from './Content';
2020
import Web3ConnectionManager from '~/components/Web3ConnectionManager';
2121
import GlobalWarnings from '~/components/GlobalWarnings';
@@ -67,30 +67,30 @@ export default function MainRouter() {
6767
<TranslatorSkillsProvider>
6868
<Content>
6969
<Switch>
70-
<Route exact path={r.ROOT}>
70+
<SentryRoute exact path={r.ROOT}>
7171
<Redirect to={r.HOME} />
72-
</Route>
73-
<Route exact path={r.HOME}>
72+
</SentryRoute>
73+
<SentryRoute exact path={r.HOME}>
7474
<Home />
75-
</Route>
76-
<Route exact path={r.FAQ}>
75+
</SentryRoute>
76+
<SentryRoute exact path={r.FAQ}>
7777
<Faq />
78-
</Route>
79-
<Route exact path={r.TRANSLATOR_DASHBOARD}>
78+
</SentryRoute>
79+
<SentryRoute exact path={r.TRANSLATOR_DASHBOARD}>
8080
<TranslatorDashboard />
81-
</Route>
82-
<Route exact path={r.TRANSLATOR_SETTINGS}>
81+
</SentryRoute>
82+
<SentryRoute exact path={r.TRANSLATOR_SETTINGS}>
8383
<TranslatorSettings />
84-
</Route>
85-
<Route exact path={r.TRANSLATION_REQUEST}>
84+
</SentryRoute>
85+
<SentryRoute exact path={r.TRANSLATION_REQUEST}>
8686
<TranslationRequest />
87-
</Route>
88-
<Route exact path={r.REQUESTER_DASHBOARD}>
87+
</SentryRoute>
88+
<SentryRoute exact path={r.REQUESTER_DASHBOARD}>
8989
<RequesterDashboard />
90-
</Route>
91-
<Route exact path={r.TRANSLATION_TASK_DETAILS}>
90+
</SentryRoute>
91+
<SentryRoute exact path={r.TRANSLATION_TASK_DETAILS}>
9292
<TranslationDetails />
93-
</Route>
93+
</SentryRoute>
9494
</Switch>
9595
</Content>
9696
</TranslatorSkillsProvider>

src/index.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ import { PersistGate } from 'redux-persist/integration/react';
77
import * as Sentry from '@sentry/react';
88
import { BrowserTracing } from '@sentry/tracing';
99
import { Spin } from '~/adapters/antd';
10-
import store, { persistor } from './store';
10+
import store, { persistor, history } from './store';
1111
import App from './app/App';
1212

1313
const loading = <Spin tip="Loading local data..." />;
1414

1515
Sentry.init({
1616
dsn: process.env.REACT_APP_SENTRY_ENDPOINT,
1717
environment: process.env.REACT_APP_CONTEXT,
18-
integrations: [new BrowserTracing()],
18+
integrations: [
19+
new BrowserTracing({
20+
routingInstrumentation: Sentry.reactRouterV5Instrumentation(history),
21+
}),
22+
],
1923
tracesSampleRate: 1.0,
2024
});
2125

src/store/history.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import { createBrowserHistory } from 'history';
2+
import { Route } from 'react-router-dom';
3+
import * as Sentry from '@sentry/react';
4+
5+
export const SentryRoute = Sentry.withSentryRouting(Route);
26

37
const history = createBrowserHistory();
48
export default history;

src/store/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export { default, persistor, runSaga } from './store';
2-
export { default as history } from './history';
2+
export { default as history, SentryRoute } from './history';

0 commit comments

Comments
 (0)