fix/missing-bugsnag-key-error (#12)

* Only instantiate bugsnag client if BUGSNAG_API_KEY is defined

* Pump version, update CHANGELOG
This commit is contained in:
Manuel Bouza
2019-04-04 17:32:18 +02:00
parent e57caa8563
commit 97cea77b7a
3 changed files with 25 additions and 12 deletions

View File

@@ -24,16 +24,22 @@ const filterReport = report => {
return scripts.some(script => report.stacktrace.some(includes(script)))
}
const bugsnagClient = bugsnag({
apiKey: process.env.BUGSNAG_API_KEY,
appVersion: getAppVersion(),
collectUserIp: false,
beforeSend: filterReport,
releaseStage: process.env.NODE_ENV,
notifyReleaseStages: ["production"]
})
bugsnagClient.use(bugsnagReact, React)
// When BUGSNAG_API_KEY is undefined ErrorBoundary should simply render children
let ErrorBoundary = ({ children }) => children
export default bugsnagClient
export const ErrorBoundary = bugsnagClient.getPlugin("react")
if (process.env.BUGSNAG_API_KEY) {
const bugsnagClient = bugsnag({
apiKey: process.env.BUGSNAG_API_KEY,
appVersion: getAppVersion(),
collectUserIp: false,
beforeSend: filterReport,
releaseStage: process.env.NODE_ENV,
notifyReleaseStages: ["production"]
})
bugsnagClient.use(bugsnagReact, React)
ErrorBoundary = bugsnagClient.getPlugin("react")
}
export { ErrorBoundary }