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