Skip to content

Commit

Permalink
Add/sentry (#2262)
Browse files Browse the repository at this point in the history
Adds Sentry to app so that we can track and fix errors
  • Loading branch information
belcherj authored Aug 5, 2020
1 parent 97bdc2c commit a87d55b
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
19 changes: 19 additions & 0 deletions lib/state/analytics/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
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 '../';
import type * as T from '../../types';

let eventQueue: T.AnalyticsRecord[] = [];

let Sentry;

export const recordEvent = (
name: string,
properties: T.JSONSerializable = {}
Expand Down Expand Up @@ -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://[email protected]/5378892',
});
}
);
}
eventQueue.forEach(([name, properties]) =>
analytics.tracks.recordEvent(name, properties)
);
} else {
Sentry?.close(0);
}

eventQueue = [];
Expand Down
70 changes: 70 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit a87d55b

Please sign in to comment.