Skip to content

Commit

Permalink
feat(new-trace): Fixed links to event in trace view with missing trac…
Browse files Browse the repository at this point in the history
…e slugs. (#74293)

The two broken links were from issue detail: 
- Transaction row in Breadcrumbs.
<img width="902" alt="Screenshot 2024-07-15 at 2 10 27 PM"
src="https://github.com/user-attachments/assets/2296d7f3-8636-43f1-b92b-27bd1d2fb1d0">

- Link to transaction from profile event evidence block. 
<img width="931" alt="Screenshot 2024-07-15 at 2 13 40 PM"
src="https://github.com/user-attachments/assets/0c53fcd5-2b97-4389-9c63-4c4f9fb1738e">

---------

Co-authored-by: Abdullah Khan <abdullahkhan@PG9Y57YDXQ.local>
  • Loading branch information
Abdkhan14 and Abdullah Khan committed Jul 15, 2024
1 parent e9499d6 commit 45292e9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ function FormatMessage({
if (!maybeProject) {
return content;
}

const projectSlug = maybeProject.slug;
const description = transactionData ? (
<Link
to={generateLinkToEventInTraceView({
eventId: message,
timestamp: event?.endTimestamp ?? '',
traceSlug: event?.contexts?.trace?.trace_id ?? '',
timestamp: transactionData.timestamp,
traceSlug: transactionData.trace,
projectSlug,
organization,
location: {...location, query: {...location.query, referrer: 'breadcrumbs'}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function Breadcrumbs({
{
query: {
query: `id:[${sentryTransactionIds}]`,
field: ['title'],
field: ['title', 'trace', 'timestamp'],
project: [maybeProject?.id],
},
},
Expand Down
2 changes: 2 additions & 0 deletions static/app/components/events/interfaces/breadcrumbs/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ export type BreadcrumbWithMeta = {
export type BreadcrumbTransactionEvent = {
id: string;
'project.name': string;
timestamp: string;
title: string;
trace: string;
};
5 changes: 5 additions & 0 deletions static/app/components/events/profileEventEvidence.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ describe('ProfileEventEvidence', function () {
transactionName: 'SomeTransaction',
},
},
contexts: {
trace: {
trace_id: 'trace-id',
},
},
}),
group: GroupFixture({
issueCategory: IssueCategory.PROFILE,
Expand Down
4 changes: 2 additions & 2 deletions static/app/components/events/profileEventEvidence.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function ProfileEventEvidence({event, projectSlug}: ProfileEvidenceProps)
subject: 'Transaction Name',
key: 'Transaction Name',
value: evidenceData.transactionName,
actionButton: (
actionButton: traceSlug ? (
<Button
size="xs"
to={generateLinkToEventInTraceView({
Expand All @@ -39,7 +39,7 @@ export function ProfileEventEvidence({event, projectSlug}: ProfileEvidenceProps)
>
{t('View Transaction')}
</Button>
),
) : null,
},
]
: []),
Expand Down
9 changes: 9 additions & 0 deletions static/app/utils/discover/urls.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Sentry from '@sentry/react';
import type {Location, LocationDescriptorObject} from 'history';

import type {Organization, OrganizationSummary} from 'sentry/types/organization';
Expand Down Expand Up @@ -74,6 +75,14 @@ export function generateLinkToEventInTraceView({
const normalizedTimestamp = getTimeStampFromTableDateField(timestamp);
const eventSlug = generateEventSlug({id: eventId, project: projectSlug});

if (!traceSlug) {
Sentry.withScope(scope => {
scope.setExtras({traceSlug, source});
scope.setLevel('warning' as any);
Sentry.captureException(new Error('Trace slug is missing'));
});
}

if (organization.features.includes('trace-view-v1')) {
return getTraceDetailsUrl({
organization,
Expand Down

0 comments on commit 45292e9

Please sign in to comment.