Skip to content

Commit

Permalink
Don't require Bugsnag
Browse files Browse the repository at this point in the history
Fixes #14.
  • Loading branch information
jstayton committed Dec 15, 2020
1 parent 8441449 commit 3dcd2e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 3 additions & 1 deletion api/plugins/authenticate_project.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ module.exports = fp(async (fastify, { allowShared = false }) => {
return false
}

bugsnag.setUser(project.id, project.user.email, project.name)
if (bugsnag) {
bugsnag.setUser(project.id, project.user.email, project.name)
}

project.is_shared = isShared

Expand Down
5 changes: 4 additions & 1 deletion api/plugins/error_handler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ module.exports = async (error, request, reply) => {
}

if (reply.statusCode >= 500) {
bugsnag.notify(error)
if (bugsnag) {
bugsnag.notify(error)
}

reply.log.error({ req: request, res: reply, err: error }, error.message)
} else if (reply.statusCode >= 400) {
reply.log.info({ res: reply, err: error }, error.message)
Expand Down
12 changes: 7 additions & 5 deletions api/services/bugsnag.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ const Bugsnag = require('@bugsnag/js')

const package = require('@/../package')

module.exports = Bugsnag.start({
apiKey: process.env.BUGSNAG_API_KEY,
appVersion: package.version,
enabledReleaseStages: ['production'],
})
module.exports = process.env.BUGSNAG_API_KEY
? Bugsnag.start({
apiKey: process.env.BUGSNAG_API_KEY,
appVersion: package.version,
enabledReleaseStages: ['production'],
})
: null

0 comments on commit 3dcd2e4

Please sign in to comment.