Commit 258c3d2f authored by rpereira2's avatar rpereira2 Committed by Peter Leitzen

Add correct external_url to sentry response

The permalink for each issue in sentry response does not contain
protocol (http/https) and port. So, we construct a url from the api url
and the issue ID.
parent 5ab1388f
......@@ -69,7 +69,12 @@ module Sentry
end
end
def issue_url(id)
"#{issues_api_url}#{id}/"
end
def map_to_error(issue)
id = issue.fetch('id')
project = issue.fetch('project')
count = issue.fetch('count', nil)
......@@ -77,8 +82,10 @@ module Sentry
frequency = issue.dig('stats', '24h')
message = issue.dig('metadata', 'value')
external_url = issue_url(id)
Gitlab::ErrorTracking::Error.new(
id: issue.fetch('id'),
id: id,
first_seen: issue.fetch('firstSeen', nil),
last_seen: issue.fetch('lastSeen', nil),
title: issue.fetch('title', nil),
......@@ -87,7 +94,7 @@ module Sentry
count: count,
message: message,
culprit: issue.fetch('culprit', nil),
external_url: issue.fetch('permalink', nil),
external_url: external_url,
short_id: issue.fetch('shortId', nil),
status: issue.fetch('status', nil),
frequency: frequency,
......
......@@ -41,7 +41,6 @@ describe Sentry::Client do
:count | :count
:message | [:metadata, :value]
:culprit | :culprit
:external_url | :permalink
:short_id | :shortId
:status | :status
:frequency | [:stats, '24h']
......@@ -53,6 +52,12 @@ describe Sentry::Client do
with_them do
it { expect(subject[0].public_send(error_object)).to eq(sample_response[0].dig(*sentry_response)) }
end
context 'external_url' do
it 'is constructed correctly' do
expect(subject[0].external_url).to eq('https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project/issues/11/')
end
end
end
context 'redirects' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment