Skip to content

Commit 7e9c240

Browse files
scttcperclaude
andcommitted
ref(issues): Clean up shared stack trace component
Extract duplicated `IndexedExceptionValue` type and `resolveExceptionFields` helper into a shared utils module. Fix missing `exception` and `isMinified` params in the copy-as and raw view handlers so the exception header line shows up in copied text. Add the `Flex gap="lg"` wrapper to the single-exception branch for consistent spacing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1f61a46 commit 7e9c240

File tree

3 files changed

+47
-49
lines changed

3 files changed

+47
-49
lines changed

static/app/components/stackTrace/issueStackTrace/index.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSectio
4646

4747
import {IssueFrameActions} from './issueFrameActions';
4848
import {IssueStackTraceFrameContext} from './issueStackTraceFrameContext';
49+
import type {IndexedExceptionValue} from './utils';
50+
import {resolveExceptionFields} from './utils';
4951

5052
interface IssueStackTraceBaseProps {
5153
event: Event;
@@ -67,20 +69,6 @@ interface StandaloneStackTraceProps extends IssueStackTraceBaseProps {
6769

6870
type IssueStackTraceProps = ExceptionStackTraceProps | StandaloneStackTraceProps;
6971

70-
interface IndexedExceptionValue extends ExceptionValue {
71-
exceptionIndex: number;
72-
stacktrace: StacktraceType;
73-
}
74-
75-
/** Resolves symbolicated vs raw (minified) exception fields. */
76-
function resolveExceptionFields(exc: IndexedExceptionValue, isMinified: boolean) {
77-
return {
78-
type: isMinified ? (exc.rawType ?? exc.type) : exc.type,
79-
module: isMinified ? (exc.rawModule ?? exc.module) : exc.module,
80-
value: isMinified ? (exc.rawValue ?? exc.value) : exc.value,
81-
};
82-
}
83-
8472
function IssueStackTraceLineCoverageLegend() {
8573
const {hasCoverageData} = useLineCoverageContext();
8674

static/app/components/stackTrace/issueStackTrace/sharedIssueStackTrace.tsx

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ import {defined} from 'sentry/utils';
3434
import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
3535
import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSection';
3636

37+
import type {IndexedExceptionValue} from './utils';
38+
import {resolveExceptionFields} from './utils';
39+
3740
interface SharedIssueStackTraceBaseProps {
3841
event: Event;
3942
}
@@ -52,19 +55,6 @@ type SharedIssueStackTraceProps =
5255
| SharedExceptionStackTraceProps
5356
| SharedStandaloneStackTraceProps;
5457

55-
interface IndexedExceptionValue extends ExceptionValue {
56-
exceptionIndex: number;
57-
stacktrace: StacktraceType;
58-
}
59-
60-
function resolveExceptionFields(exc: IndexedExceptionValue, isMinified: boolean) {
61-
return {
62-
type: isMinified ? (exc.rawType ?? exc.type) : exc.type,
63-
module: isMinified ? (exc.rawModule ?? exc.module) : exc.module,
64-
value: isMinified ? (exc.rawValue ?? exc.value) : exc.value,
65-
};
66-
}
67-
6858
/**
6959
* Stack trace component for the shared issue page.
7060
*
@@ -169,6 +159,8 @@ function SharedIssueStackTraceContent({
169159
rawStacktraceContent({
170160
data: isMinified ? (exc.rawStacktrace ?? exc.stacktrace) : exc.stacktrace,
171161
platform: event.platform,
162+
exception: isStandalone ? undefined : exc,
163+
isMinified,
172164
})
173165
)
174166
.join('\n\n'),
@@ -197,7 +189,7 @@ function SharedIssueStackTraceContent({
197189
? (exc.rawStacktrace ?? exc.stacktrace)
198190
: exc.stacktrace,
199191
platform: event.platform,
200-
exception: exc,
192+
exception: isStandalone ? undefined : exc,
201193
isMinified,
202194
})
203195
)
@@ -216,27 +208,29 @@ function SharedIssueStackTraceContent({
216208

217209
return (
218210
<InterimSection type={sectionKey} title="Stack Trace" actions={sectionActions}>
219-
{hasExceptionInfo && (
220-
<Flex direction="column" gap="sm">
221-
<div>
222-
<ExceptionHeader type={type} module={module} />
223-
</div>
224-
<ExceptionDescription
225-
value={value}
226-
mechanism={exc.mechanism}
227-
meta={excMeta}
228-
/>
229-
</Flex>
230-
)}
231-
<StackTraceProvider
232-
exceptionIndex={isStandalone ? undefined : exc.exceptionIndex}
233-
event={event}
234-
stacktrace={exc.stacktrace}
235-
minifiedStacktrace={exc.rawStacktrace ?? undefined}
236-
meta={isStandalone ? rawEntryMeta : excMeta?.stacktrace}
237-
>
238-
<StackTraceFrames frameContextComponent={FrameContent} />
239-
</StackTraceProvider>
211+
<Flex direction="column" gap="lg">
212+
{hasExceptionInfo && (
213+
<Flex direction="column" gap="sm">
214+
<div>
215+
<ExceptionHeader type={type} module={module} />
216+
</div>
217+
<ExceptionDescription
218+
value={value}
219+
mechanism={exc.mechanism}
220+
meta={excMeta}
221+
/>
222+
</Flex>
223+
)}
224+
<StackTraceProvider
225+
exceptionIndex={isStandalone ? undefined : exc.exceptionIndex}
226+
event={event}
227+
stacktrace={exc.stacktrace}
228+
minifiedStacktrace={exc.rawStacktrace ?? undefined}
229+
meta={isStandalone ? rawEntryMeta : excMeta?.stacktrace}
230+
>
231+
<StackTraceFrames frameContextComponent={FrameContent} />
232+
</StackTraceProvider>
233+
</Flex>
240234
</InterimSection>
241235
);
242236
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type {ExceptionValue} from 'sentry/types/event';
2+
import type {StacktraceType} from 'sentry/types/stacktrace';
3+
4+
export interface IndexedExceptionValue extends ExceptionValue {
5+
exceptionIndex: number;
6+
stacktrace: StacktraceType;
7+
}
8+
9+
/** Resolves symbolicated vs raw (minified) exception fields. */
10+
export function resolveExceptionFields(exc: IndexedExceptionValue, isMinified: boolean) {
11+
return {
12+
type: isMinified ? (exc.rawType ?? exc.type) : exc.type,
13+
module: isMinified ? (exc.rawModule ?? exc.module) : exc.module,
14+
value: isMinified ? (exc.rawValue ?? exc.value) : exc.value,
15+
};
16+
}

0 commit comments

Comments
 (0)