UNPKG

bugsnag-notification-plugins

Version:

Notification plugins (chat and issue tracking integrations) for Bugsnag.

32 lines (26 loc) 886 B
NotificationPlugin = require "../../notification-plugin" class Lighthouse extends NotificationPlugin @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: title: @title(event) body: @markdownBody(event) tag: config.tags # Send the request to the url @request .post("#{config.url}/projects/#{config.projectId}/tickets.json") .timeout(4000) .set("X-LighthouseToken", config.apiKey) .send(payload) .on "error", (err) -> callback(err) .end (res) -> return callback(res.error) if res.error callback null, id: res.body.ticket.number url: res.body.ticket.url module.exports = Lighthouse