bugsnag-notification-plugins
Version:
Notification plugins (chat and issue tracking integrations) for Bugsnag.
63 lines (49 loc) • 2.02 kB
text/coffeescript
NotificationPlugin = require "../../notification-plugin"
class GitLabIssue extends NotificationPlugin
DEFAULT_URL = "https://gitlab.com"
: (config) ->
"#{config.gitlab_url || DEFAULT_URL}/api/v3/projects"
: (config) ->
"#{@baseUrl(config)}/#{encodeURIComponent(config.project_id)}/issues"
: (config, issueId) ->
+ "/" + issueId
: (config, issueId) ->
+ "/notes"
: (req, config) ->
req.set("User-Agent", "Bugsnag").set("PRIVATE-TOKEN", config.private_token)
: (config, event, callback) ->
# Build the ticket
payload =
title:
description:
labels: (config?.labels || "bugsnag")
.send(payload)
.on("error", callback)
.end (res) ->
return callback(res.error) if res.error
callback null,
id: res.body.id
url: "#{config.gitlab_url || DEFAULT_URL}/#{config.project_id}/issues/#{res.body.id}"
: (config, issueId, callback) ->
.send({state_event: "reopen"})
.on "error", (err) ->
callback(err)
.end (res) ->
callback(res.error)
: (config, issueId, comment) ->
.send({body: comment})
.on("error", console.error)
.end()
: (config, event, callback) ->
if event?.trigger?.type == "linkExistingIssue"
return callback(null, null)
if event?.trigger?.type == "reopened"
if event.error?.createdIssue?.id
else
module.exports = GitLabIssue