Only instantiate bugsnag client if BUGSNAG_API_KEY is defined
This commit is contained in:
@@ -24,16 +24,22 @@ const filterReport = report => {
|
|||||||
return scripts.some(script => report.stacktrace.some(includes(script)))
|
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
|
if (process.env.BUGSNAG_API_KEY) {
|
||||||
export const ErrorBoundary = bugsnagClient.getPlugin("react")
|
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 }
|
||||||
|
|||||||
Reference in New Issue
Block a user