debian-mirror-gitlab/lib/error_tracking/sentry_client/issue_link.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.7 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
2021-04-17 20:07:23 +05:30
module ErrorTracking
class SentryClient
2020-03-13 15:44:24 +05:30
module IssueLink
# Creates a link in Sentry corresponding to the provided
# Sentry issue and GitLab issue
# @param integration_id [Integer, nil] Representing a global
# GitLab integration in Sentry. Nil for plugins.
# @param sentry_issue_id [Integer] Id for an issue from Sentry
# @param issue [Issue] Issue for which the link should be created
def create_issue_link(integration_id, sentry_issue_id, issue)
return create_plugin_link(sentry_issue_id, issue) unless integration_id
create_global_integration_link(integration_id, sentry_issue_id, issue)
end
private
def create_global_integration_link(integration_id, sentry_issue_id, issue)
issue_link_url = global_integration_link_api_url(integration_id, sentry_issue_id)
params = {
project: issue.project.id,
externalIssue: "#{issue.project.id}##{issue.iid}"
}
http_put(issue_link_url, params)
end
def global_integration_link_api_url(integration_id, sentry_issue_id)
issue_link_url = URI(url)
issue_link_url.path = "/api/0/groups/#{sentry_issue_id}/integrations/#{integration_id}/"
issue_link_url
end
def create_plugin_link(sentry_issue_id, issue)
issue_link_url = plugin_link_api_url(sentry_issue_id)
http_post(issue_link_url, issue_id: issue.iid)
end
def plugin_link_api_url(sentry_issue_id)
issue_link_url = URI(url)
issue_link_url.path = "/api/0/issues/#{sentry_issue_id}/plugins/gitlab/link/"
issue_link_url
end
end
end
end