From 8a87d7aedcfa0d0fde28b64471695ade6e161234 Mon Sep 17 00:00:00 2001 From: Richard Liu Date: Sun, 31 May 2020 14:43:22 -0700 Subject: [PATCH] feat: add Sentry Add Sentry for error reporting. This will be bundled into the v0.0.2 release as well --- react_app/package.json | 3 +- react_app/src/components/App.js | 2 +- react_app/src/components/SearchContainer.js | 10 ++-- react_app/src/index.js | 15 ++++-- react_app/src/settings.js | 5 +- react_app/yarn.lock | 57 +++++++++++++++++++++ 6 files changed, 79 insertions(+), 13 deletions(-) diff --git a/react_app/package.json b/react_app/package.json index ebc81ec..b41e647 100644 --- a/react_app/package.json +++ b/react_app/package.json @@ -6,7 +6,7 @@ "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" }, @@ -14,6 +14,7 @@ "parcel-bundler": "^1.12.4" }, "dependencies": { + "@sentry/browser": "^5.15.5", "autoprefixer": "^9.8.0", "react": "^16.13.1", "react-dom": "^16.13.1", diff --git a/react_app/src/components/App.js b/react_app/src/components/App.js index ed2db43..ede38e2 100644 --- a/react_app/src/components/App.js +++ b/react_app/src/components/App.js @@ -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 ( diff --git a/react_app/src/components/SearchContainer.js b/react_app/src/components/SearchContainer.js index c00fbf0..8394890 100644 --- a/react_app/src/components/SearchContainer.js +++ b/react_app/src/components/SearchContainer.js @@ -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}` ); } }) @@ -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); diff --git a/react_app/src/index.js b/react_app/src/index.js index d77babf..c828bb1 100644 --- a/react_app/src/index.js +++ b/react_app/src/index.js @@ -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(, 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(, document.getElementById('root')); diff --git a/react_app/src/settings.js b/react_app/src/settings.js index d4d44dc..89b5cbd 100644 --- a/react_app/src/settings.js +++ b/react_app/src/settings.js @@ -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 }; diff --git a/react_app/yarn.lock b/react_app/yarn.lock index 529628e..d0d6914 100644 --- a/react_app/yarn.lock +++ b/react_app/yarn.lock @@ -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" @@ -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"