From a87d55be0e7a6732d5c3e4da5fc55ebf9d1556cf Mon Sep 17 00:00:00 2001 From: Jonathan Belcher Date: Wed, 5 Aug 2020 17:00:18 -0400 Subject: [PATCH] Add/sentry (#2262) Adds Sentry to app so that we can track and fix errors --- lib/state/analytics/middleware.ts | 19 +++++++++ package-lock.json | 70 +++++++++++++++++++++++++++++++ package.json | 3 +- 3 files changed, 91 insertions(+), 1 deletion(-) diff --git a/lib/state/analytics/middleware.ts b/lib/state/analytics/middleware.ts index fdd5139a2..a7ae9b602 100644 --- a/lib/state/analytics/middleware.ts +++ b/lib/state/analytics/middleware.ts @@ -1,4 +1,8 @@ import analytics from '../../analytics'; +import getConfig from '../../../get-config'; +import isDevConfig from '../../utils/is-dev-config'; + +const config = getConfig(); import type * as A from '../action-types'; import type * as S from '../'; @@ -6,6 +10,8 @@ import type * as T from '../../types'; let eventQueue: T.AnalyticsRecord[] = []; +let Sentry; + export const recordEvent = ( name: string, properties: T.JSONSerializable = {} @@ -48,9 +54,22 @@ export const middleware: S.Middleware = (store) => { if (action.allowAnalytics) { // make sure that tracking starts after preferences are loaded + if (!isDevConfig(config?.development)) { + import(/* webpackChunkName: 'sentry' */ '@sentry/react').then( + (SentryModule) => { + Sentry = SentryModule; + Sentry.init({ + dsn: + 'https://e5349c4269ef4665bfc44be218a786c2@o248881.ingest.sentry.io/5378892', + }); + } + ); + } eventQueue.forEach(([name, properties]) => analytics.tracks.recordEvent(name, properties) ); + } else { + Sentry?.close(0); } eventQueue = []; diff --git a/package-lock.json b/package-lock.json index f7eb5fabd..a7fb7fc53 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4287,6 +4287,76 @@ "lodash-es": "^4.17.15" } }, + "@sentry/browser": { + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-5.20.1.tgz", + "integrity": "sha512-ClykuvrEsMKgAvifx5VHzRjchwYbJFX8YiIicYx+Wr3MXL2jLG6OEfHHJwJeyBL2C3vxd5O0KPK3pGMR9wPMLA==", + "requires": { + "@sentry/core": "5.20.1", + "@sentry/types": "5.20.1", + "@sentry/utils": "5.20.1", + "tslib": "^1.9.3" + } + }, + "@sentry/core": { + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-5.20.1.tgz", + "integrity": "sha512-gG622/UY2TePruF6iUzgVrbIX5vN8w2cjlWFo1Est8MvCfQsz8agGaLMCAyl5hCGJ6K2qTUZDOlbCNIKoMclxg==", + "requires": { + "@sentry/hub": "5.20.1", + "@sentry/minimal": "5.20.1", + "@sentry/types": "5.20.1", + "@sentry/utils": "5.20.1", + "tslib": "^1.9.3" + } + }, + "@sentry/hub": { + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-5.20.1.tgz", + "integrity": "sha512-Nv5BXf14BEc08acDguW6eSqkAJLVf8wki283FczEvTsQZZuSBHM9cJ5Hnehr6n+mr8wWpYLgUUYM0oXXigUmzQ==", + "requires": { + "@sentry/types": "5.20.1", + "@sentry/utils": "5.20.1", + "tslib": "^1.9.3" + } + }, + "@sentry/minimal": { + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-5.20.1.tgz", + "integrity": "sha512-2PeJKDTHNsUd1jtSLQBJ6oRI+xrIJrYDQmsyK/qs9D7HqHfs+zNAMUjYseiVeSAFGas5IcNSuZbPRV4BnuoZ0w==", + "requires": { + "@sentry/hub": "5.20.1", + "@sentry/types": "5.20.1", + "tslib": "^1.9.3" + } + }, + "@sentry/react": { + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/@sentry/react/-/react-5.20.1.tgz", + "integrity": "sha512-NT0y8fqAaNHHdj+eLN2sjc/MDQgi5RLstpAqQkxNbfl+AEp0S0Naho6rMhTUd2kZVg0GwPi0snePw7HSjxpUHg==", + "requires": { + "@sentry/browser": "5.20.1", + "@sentry/minimal": "5.20.1", + "@sentry/types": "5.20.1", + "@sentry/utils": "5.20.1", + "hoist-non-react-statics": "^3.3.2", + "tslib": "^1.9.3" + } + }, + "@sentry/types": { + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.20.1.tgz", + "integrity": "sha512-OU+i/lcjGpDJv0XkNpsKrI2r1VPp8qX0H6Knq8NuZrlZe3AbvO3jRJJK0pH14xFv8Xok5jbZZpKKoQLxYfxqsw==" + }, + "@sentry/utils": { + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.20.1.tgz", + "integrity": "sha512-dhK6IdO6g7Q2CoxCbB+q8gwUapDUH5VjraFg0UBzgkrtNhtHLylqmwx0sWQvXCcp14Q/3MuzEbb4euvoh8o8oA==", + "requires": { + "@sentry/types": "5.20.1", + "tslib": "^1.9.3" + } + }, "@sindresorhus/is": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", diff --git a/package.json b/package.json index f0c25d495..64e570230 100644 --- a/package.json +++ b/package.json @@ -123,6 +123,7 @@ "dependencies": { "@automattic/color-studio": "2.3.0", "@material-ui/core": "4.11.0", + "@sentry/react": "^5.20.1", "@types/clipboard": "^2.0.1", "clipboard": "2.0.6", "cookie": "0.4.1", @@ -137,8 +138,8 @@ "gridicons": "3.3.1", "highlight.js": "10.1.1", "isemail": "3.2.0", - "jsdom": "16.3.0", "js-yaml": "3.14.0", + "jsdom": "16.3.0", "jszip": "3.5.0", "lodash": "4.17.15", "md5.js": "1.3.5",