Only instantiate bugsnag client if BUGSNAG_API_KEY is defined

This commit is contained in:
Manuel Bouza
2019-04-04 11:31:22 +02:00
parent e582f99a94
commit a97de36eb4

View File

@@ -24,6 +24,11 @@ const filterReport = report => {
return scripts.some(script => report.stacktrace.some(includes(script)))
}
// When BUGSNAG_API_KEY is undefined ErrorBoundary should simply render children
let ErrorBoundary = ({ children }) => children
if (process.env.BUGSNAG_API_KEY) {
const bugsnagClient = bugsnag({
apiKey: process.env.BUGSNAG_API_KEY,
appVersion: getAppVersion(),
@@ -34,6 +39,7 @@ const bugsnagClient = bugsnag({
})
bugsnagClient.use(bugsnagReact, React)
ErrorBoundary = bugsnagClient.getPlugin("react")
}
export default bugsnagClient
export const ErrorBoundary = bugsnagClient.getPlugin("react")
export { ErrorBoundary }