Skip to content

feat: add sentry logging #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const loadProbot = appFn => {
appFn = resolve(appFn)
}

if (process.env.SENTRY_DSN) {
probot.load(require('probot/lib/apps/sentry'))
}
probot.load(appFn)

return probot
Expand Down Expand Up @@ -47,8 +50,10 @@ module.exports.serverless = appFn => {
// Convert the payload to an Object if API Gateway stringifies it
event.body = (typeof event.body === 'string') ? JSON.parse(event.body) : event.body

const { info: logInfo, error: logError } = probot.apps[0].log

// Do the thing
console.log(`Received event ${e}${event.body.action ? ('.' + event.body.action) : ''}`)
logInfo(`Received event ${e}${event.body.action ? ('.' + event.body.action) : ''}`)
if (event) {
try {
await probot.receive({
Expand All @@ -63,16 +68,17 @@ module.exports.serverless = appFn => {
}
return context.done(null, res)
} catch (err) {
console.error(err)
logError(err)
return context.done(null, {
statusCode: 500,
body: JSON.stringify(err)
})
}
} else {
console.error({ event, context })
logError({ event, context })
context.done(null, 'unknown error')
}
logInfo('Nothing to do')
return context.done(null, {
statusCode: 200,
body: 'Nothing to do.'
Expand Down