-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Sentry to app so that we can track and fix errors
- Loading branch information
Showing
3 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {} | ||
|
@@ -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 = []; | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters