Skip to content

Commit

Permalink
feat: sentry instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybuidl committed Feb 16, 2023
1 parent 5ff32cd commit a4f2867
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 21 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/sentry-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Sentry Release

on:
workflow_dispatch:
push:
branches:
- master

permissions: # added using https://github.com/step-security/secure-workflows
contents: read

jobs:
release:
runs-on: ubuntu-latest
environment: production
outputs:
version: ${{ steps.set-version.outputs.version }}
steps:
- uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16

- name: Install dependencies
run: yarn install

- name: Build and deploy subgraph
run: yarn build

- name: Set version
id: set-version
run: echo "version=v$(cat package.json | jq -r .version)-$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"

- name: Create Sentry release
uses: getsentry/action-release@v1.2.1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
environment: production
version: ${{ steps.set-version.outputs.version }}
sourcemaps: ./dist

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"@loadable/component": "^5.12.0",
"@reduxjs/toolkit": "^1.6.1",
"@rehooks/local-storage": "^2.4.4",
"@sentry/react": "^7.37.2",
"@sentry/tracing": "^7.37.2",
"@uniswap/sdk": "^3.0.3",
"@web3-react/abstract-connector": "^6.0.7",
"@web3-react/core": "^6.1.9",
Expand Down
17 changes: 17 additions & 0 deletions scripts/sentry-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

cd $SCRIPT_DIR/..

version="linguo@v$(cat package.json | jq -r .version)-$(git rev-parse --short HEAD)"
sentry-cli releases new "$version"
sentry-cli releases set-commits "$version" --auto

rm -rf dist/
yarn build
sentry-cli releases files $version upload-sourcemaps dist/

sentry-cli releases finalize "$version"

cd -
36 changes: 18 additions & 18 deletions src/app/MainRouter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { SWRConfig } from 'swr';
import { request } from 'graphql-request';

import { Redirect, Route, Switch } from 'react-router-dom';
import { Redirect, Switch } from 'react-router-dom';
import loadable from '@loadable/component';
import { Layout } from 'antd';
import { ConnectedRouter } from 'connected-react-router';
Expand All @@ -15,7 +15,7 @@ import Footer from '~/layout/Footer';
import Navbar from '~/layout/Header/Navbar';
import { DrawerMenu } from '~/layout/Header/Menu';

import { history } from '~/store';
import { history, SentryRoute } from '~/store';
import Content from './Content';
import Web3ConnectionManager from '~/components/Web3ConnectionManager';
import GlobalWarnings from '~/components/GlobalWarnings';
Expand Down Expand Up @@ -67,30 +67,30 @@ export default function MainRouter() {
<TranslatorSkillsProvider>
<Content>
<Switch>
<Route exact path={r.ROOT}>
<SentryRoute exact path={r.ROOT}>
<Redirect to={r.HOME} />
</Route>
<Route exact path={r.HOME}>
</SentryRoute>
<SentryRoute exact path={r.HOME}>
<Home />
</Route>
<Route exact path={r.FAQ}>
</SentryRoute>
<SentryRoute exact path={r.FAQ}>
<Faq />
</Route>
<Route exact path={r.TRANSLATOR_DASHBOARD}>
</SentryRoute>
<SentryRoute exact path={r.TRANSLATOR_DASHBOARD}>
<TranslatorDashboard />
</Route>
<Route exact path={r.TRANSLATOR_SETTINGS}>
</SentryRoute>
<SentryRoute exact path={r.TRANSLATOR_SETTINGS}>
<TranslatorSettings />
</Route>
<Route exact path={r.TRANSLATION_REQUEST}>
</SentryRoute>
<SentryRoute exact path={r.TRANSLATION_REQUEST}>
<TranslationRequest />
</Route>
<Route exact path={r.REQUESTER_DASHBOARD}>
</SentryRoute>
<SentryRoute exact path={r.REQUESTER_DASHBOARD}>
<RequesterDashboard />
</Route>
<Route exact path={r.TRANSLATION_TASK_DETAILS}>
</SentryRoute>
<SentryRoute exact path={r.TRANSLATION_TASK_DETAILS}>
<TranslationDetails />
</Route>
</SentryRoute>
</Switch>
</Content>
</TranslatorSkillsProvider>
Expand Down
15 changes: 14 additions & 1 deletion src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,25 @@ import { Titled } from 'react-titled';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import * as Sentry from '@sentry/react';
import { BrowserTracing } from '@sentry/tracing';
import { Spin } from '~/adapters/antd';
import store, { persistor } from './store';
import store, { persistor, history } from './store';
import App from './app/App';

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

Sentry.init({
dsn: process.env.REACT_APP_SENTRY_ENDPOINT,
environment: process.env.REACT_APP_CONTEXT,
integrations: [
new BrowserTracing({
routingInstrumentation: Sentry.reactRouterV5Instrumentation(history),
}),
],
tracesSampleRate: 1.0,
});

render(
<Provider store={store}>
<PersistGate loading={loading} persistor={persistor}>
Expand Down
4 changes: 4 additions & 0 deletions src/store/history.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { createBrowserHistory } from 'history';
import { Route } from 'react-router-dom';
import * as Sentry from '@sentry/react';

export const SentryRoute = Sentry.withSentryRouting(Route);

const history = createBrowserHistory();
export default history;
2 changes: 1 addition & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default, persistor, runSaga } from './store';
export { default as history } from './history';
export { default as history, SentryRoute } from './history';
65 changes: 64 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2926,6 +2926,69 @@
dependencies:
any-observable "^0.3.0"

"@sentry/browser@7.37.2":
version "7.37.2"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.37.2.tgz#355dd28ad12677d63e0b12c5209d12b3f98ac3a4"
integrity sha512-UvKfpx6+BUdV+rGAXqDBznagfz44Ut+x2h/i0OZPNCEpXaH9KAQOlv06I66861aXiucWFRb1lAMrN4+cE9aJIg==
dependencies:
"@sentry/core" "7.37.2"
"@sentry/replay" "7.37.2"
"@sentry/types" "7.37.2"
"@sentry/utils" "7.37.2"
tslib "^1.9.3"

"@sentry/core@7.37.2":
version "7.37.2"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.37.2.tgz#959b2bf953f442b07f8377d90f4f7735cf260ae4"
integrity sha512-LjofMDSTyVeBErl9N7TTqlyEVuW1g6U4iuJtdZ75JohnvVxzWdpZfWfddwQ6h7nGWfe9dNg0fGs1wxKtMhY+MA==
dependencies:
"@sentry/types" "7.37.2"
"@sentry/utils" "7.37.2"
tslib "^1.9.3"

"@sentry/react@^7.37.2":
version "7.37.2"
resolved "https://registry.yarnpkg.com/@sentry/react/-/react-7.37.2.tgz#f5ecc4071c5dd0e8446103c24e94edda520a1217"
integrity sha512-e5NFQAwHSGVyMUGYjvYXLI/QECkXkZ2BNUo+OHr5mAYqcIyGSA38tX7RJetrhonVjjpJp/ZVzlOyxQkpnBfBLw==
dependencies:
"@sentry/browser" "7.37.2"
"@sentry/types" "7.37.2"
"@sentry/utils" "7.37.2"
hoist-non-react-statics "^3.3.2"
tslib "^1.9.3"

"@sentry/replay@7.37.2":
version "7.37.2"
resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.37.2.tgz#eb49b7a1286335c1a4de49b386d0258e5c789682"
integrity sha512-y8Gfc7EGfGU4eVae5HAtch2YgkiTzNPi16dcqPX9jtIHDwiurGqWcaOgs5HoGJm45eMfl6LvcE7MPbwqcDkPIA==
dependencies:
"@sentry/core" "7.37.2"
"@sentry/types" "7.37.2"
"@sentry/utils" "7.37.2"

"@sentry/tracing@^7.37.2":
version "7.37.2"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.37.2.tgz#88f149aea6a4d5a3cfb9145868d885fac9fffb52"
integrity sha512-XBVvxbV5TADq2rHg/kJqGqDfOP8n2myMUxMMpfHMb38NrxkxQwXy+gDe41bA8FJKA2k7Y3Wkn8ZC/PelQ8c+ag==
dependencies:
"@sentry/core" "7.37.2"
"@sentry/types" "7.37.2"
"@sentry/utils" "7.37.2"
tslib "^1.9.3"

"@sentry/types@7.37.2":
version "7.37.2"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.37.2.tgz#99fd76230d7c1d3c6901ed4c0bea35be7d6fe26d"
integrity sha512-SxKQOCX94ZaQM4C2ysNjHdJsjYapu/NYZCz1cnPyCdDvYfhwiVge1uq6ZHiQ/ARfxAAOmc3R4Mh3VvEz7WUOdw==

"@sentry/utils@7.37.2":
version "7.37.2"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.37.2.tgz#14dea644454e3df247fb113fc834f509c1f0e48c"
integrity sha512-5irN1nN/mtdOoWwsJiwBK0gPgNMkciUubEMbCaaXqJaGyGz8+yfDvXj7L+xGYiU57z+7+QkkSKxKEZ/IcBpjVQ==
dependencies:
"@sentry/types" "7.37.2"
tslib "^1.9.3"

"@sindresorhus/is@^0.14.0":
version "0.14.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
Expand Down Expand Up @@ -13969,7 +14032,7 @@ tsconfig-paths@^3.11.0:
minimist "^1.2.0"
strip-bom "^3.0.0"

tslib@1.14.1:
tslib@1.14.1, tslib@^1.9.3:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
Expand Down

0 comments on commit a4f2867

Please sign in to comment.