bugsnag-notification-plugins
Version:
Notification plugins (chat and issue tracking integrations) for Bugsnag.
35 lines (28 loc) • 1.07 kB
text/coffeescript
NotificationPlugin = require "../../notification-plugin"
class Codebase extends NotificationPlugin
BASE_URL = "http://api3.codebasehq.com"
@receiveEvent: (config, event, callback) ->
if event?.trigger?.type == "linkExistingIssue"
return callback(null, null)
return if event?.trigger?.type == "reopened"
# Build the ticket payload
payload =
ticket:
summary: @title(event)
description: @markdownBody(event)
ticket_type: "bug"
# Send the request to codebase
@request
.post("#{BASE_URL}/#{config.project}/tickets")
.timeout(4000)
.set("Accept", "application/json")
.auth("#{config.account}/#{config.username}", config.apiKey)
.send(payload)
.on "error", (err) ->
callback(err)
.end (res) ->
return callback(res.error) if res.error
callback null,
id: res.body.ticket.ticket_id
url: "https://#{config.account}.codebasehq.com/projects/#{config.project}/tickets/#{res.body.ticket.ticket_id}"
module.exports = Codebase