Skip to content

Commit

Permalink
feat: add Sentry
Browse files Browse the repository at this point in the history
Add Sentry for error reporting. This will be bundled into the v0.0.2
release as well
  • Loading branch information
richyliu committed May 31, 2020
1 parent c67c5f0 commit 8a87d7a
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 13 deletions.
3 changes: 2 additions & 1 deletion react_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
"license": "MIT",
"scripts": {
"start": "parcel -p 8000 src/index.html",
"build": "rm -rf dist/ && parcel build src/index.html",
"build": "rm -rf dist/ && parcel build --no-source-maps src/index.html",
"deploy-prod": "surge dist/ gregg.surge.sh",
"deploy-prerelease": "surge dist/ gregg-prereleas.surge.sh"
},
"devDependencies": {
"parcel-bundler": "^1.12.4"
},
"dependencies": {
"@sentry/browser": "^5.15.5",
"autoprefixer": "^9.8.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
Expand Down
2 changes: 1 addition & 1 deletion react_app/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import Divider from './Divider';
import FAQ from './FAQ';
import Footer from './Footer';
import GithubCorner from './GithubCorner';
import { series } from '../settings';

const App = () => {
// current word the user has selected to look up in the dictionary
const [word, setWord] = useState(null);
const series = ['Simplified'];
const [curSeries, setSeries] = useState(series[0]);

return (
Expand Down
10 changes: 4 additions & 6 deletions react_app/src/components/SearchContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ const SearchContainer = ({
.then(res => {
if (res.ok) return res.json();
else {
alert('Could not get the dictionary. Please report this error');
alert(
`Could not get the dictionary for ${curSeries}. This error has been automatically reported`
);
throw new Error(
`Could not get reference json for assetsRoot: ${assetsRoot} and series: ${curSeries}. Error: ${res.statusText}`
`Could not get reference json for assetsRoot: ${assetsRoot} and series: ${curSeries}`
);
}
})
Expand All @@ -32,10 +34,6 @@ const SearchContainer = ({
setWords(
reference.flatMap(p => p.words.map(w => ({ ...w, page: p.page })))
);
})
.catch(e => {
alert('Network error. Are you offline?');
throw new Error(e);
});

return () => (canceled = true);
Expand Down
15 changes: 11 additions & 4 deletions react_app/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import React from 'react'
import ReactDOM from 'react-dom'
import AppContainer from './components/AppContainer'
import React from 'react';
import ReactDOM from 'react-dom';

ReactDOM.render(<AppContainer />, document.getElementById('root'))
import * as Sentry from '@sentry/browser';
import AppContainer from './components/AppContainer';

Sentry.init({
dsn:
'https://18e5ed0b3fa54e358dc1c51edf9a78ed@o400827.ingest.sentry.io/5259603',
});

ReactDOM.render(<AppContainer />, document.getElementById('root'));
5 changes: 4 additions & 1 deletion react_app/src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ const version = 'v0.0.2';
const assetsRoot =
'https://cdn.jsdelivr.net/gh/richyliu/greggdict@3ce45f5204decf5886e68fdb6a2be55be22ca257/assets';

export { version, assetsRoot };
// list of available shorthand series
const series = ['Simplified'];

export { version, assetsRoot, series };
57 changes: 57 additions & 0 deletions react_app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,58 @@
"@parcel/utils" "^1.11.0"
physical-cpu-count "^2.0.0"

"@sentry/browser@^5.15.5":
version "5.15.5"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-5.15.5.tgz#d9a51f1388581067b50d30ed9b1aed2cbb333a36"
integrity sha512-rqDvjk/EvogfdbZ4TiEpxM/lwpPKmq23z9YKEO4q81+1SwJNua53H60dOk9HpRU8nOJ1g84TMKT2Ov8H7sqDWA==
dependencies:
"@sentry/core" "5.15.5"
"@sentry/types" "5.15.5"
"@sentry/utils" "5.15.5"
tslib "^1.9.3"

"@sentry/core@5.15.5":
version "5.15.5"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.15.5.tgz#40ea79bff5272d3fbbeeb4a98cdc59e1adbd2c92"
integrity sha512-enxBLv5eibBMqcWyr+vApqeix8uqkfn0iGsD3piKvoMXCgKsrfMwlb/qo9Ox0lKr71qIlZVt+9/A2vZohdgnlg==
dependencies:
"@sentry/hub" "5.15.5"
"@sentry/minimal" "5.15.5"
"@sentry/types" "5.15.5"
"@sentry/utils" "5.15.5"
tslib "^1.9.3"

"@sentry/hub@5.15.5":
version "5.15.5"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.15.5.tgz#f5abbcdbe656a70e2ff02c02a5a4cffa0f125935"
integrity sha512-zX9o49PcNIVMA4BZHe//GkbQ4Jx+nVofqU/Il32/IbwKhcpPlhGX3c1sOVQo4uag3cqd/JuQsk+DML9TKkN0Lw==
dependencies:
"@sentry/types" "5.15.5"
"@sentry/utils" "5.15.5"
tslib "^1.9.3"

"@sentry/minimal@5.15.5":
version "5.15.5"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.15.5.tgz#a0e4e071f01d9c4d808094ae7203f6c4cca9348a"
integrity sha512-zQkkJ1l9AjmU/Us5IrOTzu7bic4sTPKCatptXvLSTfyKW7N6K9MPIIFeSpZf9o1yM2sRYdK7GV08wS2eCT3JYw==
dependencies:
"@sentry/hub" "5.15.5"
"@sentry/types" "5.15.5"
tslib "^1.9.3"

"@sentry/types@5.15.5":
version "5.15.5"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.15.5.tgz#16c97e464cf09bbd1d2e8ce90d130e781709076e"
integrity sha512-F9A5W7ucgQLJUG4LXw1ZIy4iLevrYZzbeZ7GJ09aMlmXH9PqGThm1t5LSZlVpZvUfQ2rYA8NU6BdKJSt7B5LPw==

"@sentry/utils@5.15.5":
version "5.15.5"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.15.5.tgz#dec1d4c79037c4da08b386f5d34409234dcbfb15"
integrity sha512-Nl9gl/MGnzSkuKeo3QaefoD/OJrFLB8HmwQ7HUbTXb6E7yyEzNKAQMHXGkwNAjbdYyYbd42iABP6Y5F/h39NtA==
dependencies:
"@sentry/types" "5.15.5"
tslib "^1.9.3"

"@types/color-name@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
Expand Down Expand Up @@ -5234,6 +5286,11 @@ tr46@^1.0.1:
dependencies:
punycode "^2.1.0"

tslib@^1.9.3:
version "1.13.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"
integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==

tty-browserify@0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"
Expand Down

0 comments on commit 8a87d7a

Please sign in to comment.