Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: add sentry for error logging

thecodrrd98b5f33a0d7
diff --git a/apps/web/package.json b/apps/web/package.json
index 3bf89d9fe..e3d5f180c 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -6,6 +6,8 @@
"@mdi/js": "^5.0.45",
"@mdi/react": "^1.4.0",
"@rebass/forms": "^4.0.6",
+ "@sentry/react": "^5.27.4",
+ "@sentry/tracing": "^5.27.4",
"cogo-toast": "^4.2.3",
"dayjs": "^1.9.1",
"emotion-theming": "^10.0.19",
@@ -33,6 +35,7 @@
"zustand": "^2.2.3"
},
"devDependencies": {
+ "@sentry/types": "^5.27.4",
"@types/hookrouter": "^2.2.3",
"@types/jest": "^26.0.14",
"@types/jest-image-snapshot": "^4.1.0",
diff --git a/apps/web/src/index.js b/apps/web/src/index.js
index 8ed6fd044..cb1c0403b 100644
--- a/apps/web/src/index.js
+++ b/apps/web/src/index.js
@@ -3,6 +3,8 @@ import "react-app-polyfill/ie9";
import "./utils/dimensions";
import React from "react";
import ReactDOM from "react-dom";
+import * as Sentry from "@sentry/react";
+import { Integrations } from "@sentry/tracing";
import "./index.css";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
@@ -10,6 +12,21 @@ import Modal from "react-modal";
import { MotionConfig, AnimationFeature, GesturesFeature } from "framer-motion";
import Splash from "./views/splash";
+Sentry.init({
+ dsn:
+ "https://[email protected]/5520885",
+ integrations: [new Integrations.BrowserTracing()],
+ beforeSend: (event) => {
+ if (event.exception || event.extra.report === true) {
+ Sentry.showReportDialog();
+ }
+ return event;
+ },
+ // We recommend adjusting this value in production, or using tracesSampler
+ // for finer control
+ tracesSampleRate: 1.0,
+});
+
Modal.setAppElement("#root");
ReactDOM.render(
<MotionConfig features={[AnimationFeature, GesturesFeature]}>
diff --git a/apps/web/src/views/splash.js b/apps/web/src/views/splash.js
index a2bdfe311..b540ea5ce 100644
--- a/apps/web/src/views/splash.js
+++ b/apps/web/src/views/splash.js
@@ -4,6 +4,7 @@ import ThemeProvider from "../components/theme-provider";
import Animated from "../components/animated";
import { db } from "../common";
import { getRandom } from "../utils/random";
+import * as Sentry from "@sentry/react";
const loadingLines = [
"Ejecting bumfuzzled notes",
@@ -22,6 +23,10 @@ function Splash(props) {
await db.init();
setLoading(false);
} catch (e) {
+ Sentry.captureException(e, (scope) => {
+ scope.setExtra("where", "db.init");
+ return scope;
+ });
console.error(e);
}
})();
diff --git a/apps/web/yarn.lock b/apps/web/yarn.lock
index a3cc04302..21caa19ce 100644
--- a/apps/web/yarn.lock
+++ b/apps/web/yarn.lock
@@ -1624,6 +1624,81 @@
dependencies:
reflexbox "^4.0.6"
+"@sentry/[email protected]":
+ version "5.27.4"
+ resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-5.27.4.tgz#241dedc7d82d3ed2769bfc8e4fb193d10e6a1d4d"
+ integrity sha512-L8Fsnkl3PIak4zJ1pcGDmV92XTQjS2/H6EBgp1rhuOF4OE3L59K8RR73C9w+wVtsIi7nyfYg/FIe8lvG++3Mow==
+ dependencies:
+ "@sentry/core" "5.27.4"
+ "@sentry/types" "5.27.4"
+ "@sentry/utils" "5.27.4"
+ tslib "^1.9.3"
+
+"@sentry/[email protected]":
+ version "5.27.4"
+ resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.27.4.tgz#4155ee09ee4deed7364918094bf81654dcf681c0"
+ integrity sha512-IbI37cIZU/qBQouuUXaLbGF/9xYFp5STqmj1Gv64l0IZe4JnEp06V3yD5GxQ/mJ78vSfOqfwLooVCUw9FA61sQ==
+ dependencies:
+ "@sentry/hub" "5.27.4"
+ "@sentry/minimal" "5.27.4"
+ "@sentry/types" "5.27.4"
+ "@sentry/utils" "5.27.4"
+ tslib "^1.9.3"
+
+"@sentry/[email protected]":
+ version "5.27.4"
+ resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.27.4.tgz#15db6f504672edd70b793e4b3d370dca9cb2fef6"
+ integrity sha512-Ba1AqcjvSd2S+fpdXtXCrVXdrzq9E2Etb2eHUOkEYwSsq7StMOw7E8YHDPAo+to8zUbpMPz/Z9XGhFkyAbImGQ==
+ dependencies:
+ "@sentry/types" "5.27.4"
+ "@sentry/utils" "5.27.4"
+ tslib "^1.9.3"
+
+"@sentry/[email protected]":
+ version "5.27.4"
+ resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.27.4.tgz#2b331ed43d5f8999606fe9f8bf26a85155e8286c"
+ integrity sha512-biw5YfIQwvDoaRhLarfeRQ6MJ9UJOoDTmu8Kgg18prJy4rtfDowNJP0OBs5XAsTk6SWAXiE3g7vqUJBXgs7BWA==
+ dependencies:
+ "@sentry/hub" "5.27.4"
+ "@sentry/types" "5.27.4"
+ tslib "^1.9.3"
+
+"@sentry/react@^5.27.4":
+ version "5.27.4"
+ resolved "https://registry.yarnpkg.com/@sentry/react/-/react-5.27.4.tgz#757983dda2b2c8782d4c3a73c85806bb21ec93ed"
+ integrity sha512-nRv/u2nP4cQMWu1Gybv7izIl2VwcM6s6P2hco9RlxrCJUpQIUuHRo4yWqDn+G1Xxdr511yY8p4JR+ESBaRGJFg==
+ dependencies:
+ "@sentry/browser" "5.27.4"
+ "@sentry/minimal" "5.27.4"
+ "@sentry/types" "5.27.4"
+ "@sentry/utils" "5.27.4"
+ hoist-non-react-statics "^3.3.2"
+ tslib "^1.9.3"
+
+"@sentry/tracing@^5.27.4":
+ version "5.27.4"
+ resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-5.27.4.tgz#0f6b0ebfa90b9f5bf5bac1fcf0f196010dbdddac"
+ integrity sha512-f3nG8ozCdcbFOzsnBCZ8w+/WfoNiAd0Ctr643L0rsFbaSzPWxbPMe3LNVrWwFVo6mHacG3/2HYmJ3CYMiWyTKQ==
+ dependencies:
+ "@sentry/hub" "5.27.4"
+ "@sentry/minimal" "5.27.4"
+ "@sentry/types" "5.27.4"
+ "@sentry/utils" "5.27.4"
+ tslib "^1.9.3"
+
+"@sentry/[email protected]", "@sentry/types@^5.27.4":
+ version "5.27.4"
+ resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.27.4.tgz#ba7cefae6f77bb39a0ac59aeba1bb23ce4ad5216"
+ integrity sha512-41h3c7tgtSS8UBmfvEckSr+7V7/IVOjt/EiydyOd6s0N18zSFfGY5HdA6g+eFtIJK3DhWkUHCHZNanD5IY5YCQ==
+
+"@sentry/[email protected]":
+ version "5.27.4"
+ resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.27.4.tgz#d57ccd72a56e2f97e109d632957f6cd11806e992"
+ integrity sha512-shV1I/q+Tob3hUxRj11DfMhe9PNDiv85hUUoRloZGGwu275dMwpswb2uwgSmjc2Ao4pnMKVx8TL1hC3kGLVHTQ==
+ dependencies:
+ "@sentry/types" "5.27.4"
+ tslib "^1.9.3"
+
"@sideway/address@^4.1.0":
version "4.1.0"
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.0.tgz#0b301ada10ac4e0e3fa525c90615e0b61a72b78d"
@@ -6164,7 +6239,7 @@ hmac-drbg@^1.0.0:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.1"
-hoist-non-react-statics@^3.3.0:
+hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
@@ -12421,7 +12496,7 @@ tsconfig-paths@^3.9.0:
minimist "^1.2.0"
strip-bom "^3.0.0"
-tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0:
+tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, 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==