From 97cea77b7a85dfa2ffc059c23bc03a1e6eba3289 Mon Sep 17 00:00:00 2001 From: Manuel Bouza Date: Thu, 4 Apr 2019 17:32:18 +0200 Subject: [PATCH] fix/missing-bugsnag-key-error (#12) * Only instantiate bugsnag client if BUGSNAG_API_KEY is defined * Pump version, update CHANGELOG --- CHANGELOG.md | 7 +++++++ package.json | 2 +- src/js/utils/notifier.js | 28 +++++++++++++++++----------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53424be..bb6764d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,3 +44,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.1.1] - 2019-04-01 ### Fixed - Discard projects with undefined identifier for preselecting + +## [1.1.2] - 2019-04-04 +### Fixed +- Allow production build without BUGSNAG_API_KEY + +### Changed +- Read project identifier also from card title in the meistertask service diff --git a/package.json b/package.json index 051ad7b..72aabc7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "moco-browser-extensions", "description": "Browser plugin for MOCO", - "version": "1.1.1", + "version": "1.1.2", "license": "MIT", "scripts": { "start": "yarn start:chrome", diff --git a/src/js/utils/notifier.js b/src/js/utils/notifier.js index 15a5d8c..e9fdecd 100644 --- a/src/js/utils/notifier.js +++ b/src/js/utils/notifier.js @@ -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 }