Commit 9d2e5fbd authored by Allison Browne's avatar Allison Browne Committed by Michael Kozono

Add gitlab_commit_path to the sentry error

Add the full path so the front end does not need to
have knowlage of the path
parent bd5a67a0
......@@ -79,6 +79,9 @@ module Types
field :gitlab_commit, GraphQL::STRING_TYPE,
null: true,
description: "GitLab commit SHA attributed to the Error based on the release version"
field :gitlab_commit_path, GraphQL::STRING_TYPE,
null: true,
description: "Path to the GitLab page for the GitLab commit attributed to the error"
def first_seen
DateTime.parse(object.first_seen)
......
......@@ -4,6 +4,7 @@ module ErrorTracking
class ProjectErrorTrackingSetting < ApplicationRecord
include Gitlab::Utils::StrongMemoize
include ReactiveCaching
include Gitlab::Routing
SENTRY_API_ERROR_TYPE_BAD_REQUEST = 'bad_request_for_sentry_api'
SENTRY_API_ERROR_TYPE_MISSING_KEYS = 'missing_keys_in_sentry_response'
......@@ -141,6 +142,7 @@ module ErrorTracking
def add_gitlab_issue_details(issue)
issue.gitlab_commit = match_gitlab_commit(issue.first_release_version)
issue.gitlab_commit_path = project_commit_path(project, issue.gitlab_commit) if issue.gitlab_commit
issue
end
......
......@@ -9,6 +9,7 @@ module ErrorTracking
:first_release_last_commit,
:first_release_short_version,
:gitlab_commit,
:gitlab_commit_path,
:first_seen,
:frequency,
:gitlab_issue,
......
---
title: Add gitlab_commit_path to Sentry Error Details Response
merge_request: 22803
author:
type: added
......@@ -5721,6 +5721,11 @@ type SentryDetailedError {
"""
gitlabCommit: String
"""
Path to the GitLab page for the GitLab commit attributed to the error
"""
gitlabCommitPath: String
"""
ID (global ID) of the error
"""
......
......@@ -15576,6 +15576,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "gitlabCommitPath",
"description": "Path to the GitLab page for the GitLab commit attributed to the error",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "id",
"description": "ID (global ID) of the error",
......
......@@ -895,6 +895,7 @@ Autogenerated return type of RemoveAwardEmoji
| `firstReleaseShortVersion` | String | Release version the error was first seen |
| `lastReleaseShortVersion` | String | Release version the error was last seen |
| `gitlabCommit` | String | GitLab commit SHA attributed to the Error based on the release version |
| `gitlabCommitPath` | String | Path to the GitLab page for the GitLab commit attributed to the error |
## SentryErrorFrequency
......
......@@ -16,6 +16,7 @@ module Gitlab
:first_seen,
:frequency,
:gitlab_commit,
:gitlab_commit_path,
:gitlab_issue,
:gitlab_project,
:id,
......
......@@ -224,7 +224,12 @@ describe Projects::ErrorTrackingController do
let(:error) { build(:detailed_error_tracking_error) }
it 'returns an error' do
expected_error = error.as_json.except('first_release_version').merge({ 'gitlab_commit' => nil })
expected_error = error.as_json.except('first_release_version').merge(
{
'gitlab_commit' => nil,
'gitlab_commit_path' => nil
}
)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('error_tracking/issue_detailed')
......
......@@ -34,7 +34,7 @@ FactoryBot.define do
last_release_last_commit { '9ad419c86' }
first_release_short_version { 'abc123' }
last_release_short_version { 'abc123' }
first_release_version { '123456' }
first_release_version { '12345678' }
skip_create
end
......
......@@ -56,7 +56,8 @@
"last_release_last_commit": { "type": ["string", "null"] },
"first_release_short_version": { "type": ["string", "null"] },
"last_release_short_version": { "type": ["string", "null"] },
"gitlab_commit": { "type": ["string", "null"] }
"gitlab_commit": { "type": ["string", "null"] },
"gitlab_commit_path": { "type": ["string", "null"] }
},
"additionalProperties": false
}
......@@ -31,6 +31,7 @@ describe GitlabSchema.types['SentryDetailedError'] do
firstReleaseShortVersion
lastReleaseShortVersion
gitlabCommit
gitlabCommitPath
]
is_expected.to have_graphql_fields(*expected_fields)
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe ErrorTracking::ProjectErrorTrackingSetting do
include ReactiveCachingHelpers
include Gitlab::Routing
let_it_be(:project) { create(:project) }
......@@ -213,7 +214,7 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
describe '#issue_details' do
let(:issue) { build(:detailed_error_tracking_error) }
let(:sentry_client) { double('sentry_client', issue_details: issue) }
let(:commit_id) { '123456' }
let(:commit_id) { issue.first_release_version }
let(:result) do
subject.issue_details
......@@ -230,6 +231,7 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
it { expect(result).to eq(issue: issue) }
it { expect(result[:issue].first_release_version).to eq(commit_id) }
it { expect(result[:issue].gitlab_commit).to eq(nil) }
it { expect(result[:issue].gitlab_commit_path).to eq(nil) }
context 'when release version is nil' do
before do
......@@ -237,6 +239,7 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
end
it { expect(result[:issue].gitlab_commit).to eq(nil) }
it { expect(result[:issue].gitlab_commit_path).to eq(nil) }
end
context 'when repo commit matches first relase version' do
......@@ -248,6 +251,7 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
end
it { expect(result[:issue].gitlab_commit).to eq(commit_id) }
it { expect(result[:issue].gitlab_commit_path).to eq("/#{project.namespace.path}/#{project.path}/commit/#{commit_id}") }
end
end
......
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