Commit b25b6a8f authored by Thong Kuah's avatar Thong Kuah

Merge branch '42646-include-issues-created-in-gitlab-on-sentry-error-details-page' into 'master'

Error Details Page: Include issues created in GitLab

See merge request gitlab-org/gitlab!23605
parents 4c4cbfae 85454b4d
......@@ -2,12 +2,35 @@
module ErrorTracking
class IssueDetailsService < ErrorTracking::BaseService
include Gitlab::Routing
include Gitlab::Utils::StrongMemoize
private
def perform
response = project_error_tracking_setting.issue_details(issue_id: params[:issue_id])
compose_response(response)
compose_response(response) do
# The gitlab_issue attribute can contain an absolute GitLab url from the Sentry Client
# here we overwrite that in favor of our own data if we have it
response[:issue].gitlab_issue = gitlab_issue_url if gitlab_issue_url
end
end
def gitlab_issue_url
strong_memoize(:gitlab_issue_url) do
# Use the absolute url to match the GitLab issue url that the Sentry api provides
project_issue_url(project, gitlab_issue.iid) if gitlab_issue
end
end
def gitlab_issue
strong_memoize(:gitlab_issue) do
SentryIssueFinder
.new(project, current_user: current_user)
.execute(params[:issue_id])
&.issue
end
end
def parse_response(response)
......
---
title: Include issues created in GitLab on error tracking details page
merge_request: 23605
author:
type: changed
......@@ -61,9 +61,9 @@ By default, a **Create issue** button is displayed:
![Error Details without Issue Link](img/error_details_v12_7.png)
If you create a GitLab issue from the error, the **Create issue** button will change to a **View issue** button:
If you create a GitLab issue from the error, the **Create issue** button will change to a **View issue** button and a link to the GitLab issue will surface within the error detail section:
![Error Details with Issue Link](img/error_details_with_issue_v12_7.png)
![Error Details with Issue Link](img/error_details_with_issue_v12_8.png)
## Taking Action on errors
......
......@@ -9,6 +9,7 @@ describe ErrorTracking::IssueDetailsService do
context 'with authorized user' do
context 'when issue_details returns a detailed error' do
let(:detailed_error) { build(:detailed_error_tracking_error) }
let(:params) { { issue_id: detailed_error.id } }
before do
expect(error_tracking_setting)
......@@ -18,6 +19,19 @@ describe ErrorTracking::IssueDetailsService do
it 'returns the detailed error' do
expect(result).to eq(status: :success, issue: detailed_error)
end
it 'returns the gitlab_issue when the error has a sentry_issue' do
gitlab_issue = create(:issue, project: project)
create(:sentry_issue, issue: gitlab_issue, sentry_issue_identifier: detailed_error.id)
expect(result[:issue].gitlab_issue).to include(
"http", "/#{project.full_path}/issues/#{gitlab_issue.iid}"
)
end
it 'returns the gitlab_issue path from sentry when the error has no sentry_issue' do
expect(result[:issue].gitlab_issue).to eq(detailed_error.gitlab_issue)
end
end
include_examples 'error tracking service data not ready', :issue_details
......
......@@ -6,9 +6,10 @@ shared_context 'sentry error tracking context' do
let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
let(:token) { 'test-token' }
let(:params) { {} }
let(:result) { subject.execute }
subject { described_class.new(project, user) }
subject { described_class.new(project, user, params) }
let(:error_tracking_setting) do
create(:project_error_tracking_setting, api_url: sentry_url, token: token, project: project)
......
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