Skip to content

Commit f5eb08c

Browse files
committed
fix(stacktrace): Use useDetailedProject for scmSourceContextEnabled check
The scmSourceContextEnabled field is only available in the DetailedProjectSerializer, not the summary serializer used by useProjects(). Use useDetailedProject() instead, which is already preloaded and cached by groupDetails.tsx on the issue page.
1 parent ba700ff commit f5eb08c

3 files changed

Lines changed: 34 additions & 4 deletions

File tree

static/app/components/events/interfaces/frame/context.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type {PlatformKey} from 'sentry/types/project';
1919
import type {StacktraceType} from 'sentry/types/stacktrace';
2020
import {defined} from 'sentry/utils';
2121
import {getFileExtension} from 'sentry/utils/fileExtension';
22+
import {useDetailedProject} from 'sentry/utils/project/useDetailedProject';
2223
import {useRouteAnalyticsParams} from 'sentry/utils/routeAnalytics/useRouteAnalyticsParams';
2324
import {useOrganization} from 'sentry/utils/useOrganization';
2425
import {useProjects} from 'sentry/utils/useProjects';
@@ -92,7 +93,12 @@ export function Context({
9293
[projects, event]
9394
);
9495

95-
const hasScmSourceContext = organization.features.includes('scm-source-context');
96+
const hasScmFeature = organization.features.includes('scm-source-context');
97+
const {data: detailedProject} = useDetailedProject(
98+
{orgSlug: organization.slug, projectSlug: project?.slug ?? ''},
99+
{enabled: hasScmFeature && defined(project)}
100+
);
101+
const hasScmSourceContext = hasScmFeature && !!detailedProject?.scmSourceContextEnabled;
96102
const shouldFetchSourceContext =
97103
hasScmSourceContext &&
98104
defined(project) &&

static/app/components/events/interfaces/frame/deprecatedLine.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ import type {
2626
import type {PlatformKey} from 'sentry/types/project';
2727
import type {StacktraceType} from 'sentry/types/stacktrace';
2828
import {trackAnalytics} from 'sentry/utils/analytics';
29+
import {useDetailedProject} from 'sentry/utils/project/useDetailedProject';
2930
import {useOrganization} from 'sentry/utils/useOrganization';
31+
import {useProjects} from 'sentry/utils/useProjects';
3032
import {withSentryAppComponents} from 'sentry/utils/withSentryAppComponents';
3133
import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
3234

@@ -110,11 +112,21 @@ function DeprecatedLine({
110112
components,
111113
}: Props) {
112114
const organization = useOrganization();
115+
const {projects} = useProjects();
116+
const project = useMemo(
117+
() => projects.find(p => p.id === event.projectID),
118+
[projects, event]
119+
);
113120
const [isHovering, setIsHovering] = useState(false);
114121
const [isExpanded, setIsExpanded] = useState(initialExpanded ?? false);
115122
const platform = getPlatform(data.platform, propPlatform ?? 'other');
116123
const leadsToApp = !data.inApp && (nextFrame?.inApp || !nextFrame);
117-
const hasScmSourceContext = organization.features.includes('scm-source-context');
124+
const hasScmFeature = organization.features.includes('scm-source-context');
125+
const {data: detailedProject} = useDetailedProject(
126+
{orgSlug: organization.slug, projectSlug: project?.slug ?? ''},
127+
{enabled: hasScmFeature && !!project}
128+
);
129+
const hasScmSourceContext = hasScmFeature && !!detailedProject?.scmSourceContextEnabled;
118130

119131
const isExpandable = useMemo((): boolean => {
120132
return !!(

static/app/components/events/interfaces/nativeFrame.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {MouseEvent} from 'react';
2-
import {Fragment, useState} from 'react';
2+
import {Fragment, useMemo, useState} from 'react';
33
import styled from '@emotion/styled';
44

55
import {Tag} from '@sentry/scraps/badge';
@@ -42,7 +42,9 @@ import type {
4242
import type {PlatformKey} from 'sentry/types/project';
4343
import {StackView, type StacktraceType} from 'sentry/types/stacktrace';
4444
import {defined} from 'sentry/utils';
45+
import {useDetailedProject} from 'sentry/utils/project/useDetailedProject';
4546
import {useOrganization} from 'sentry/utils/useOrganization';
47+
import {useProjects} from 'sentry/utils/useProjects';
4648
import {useSyncedLocalStorageState} from 'sentry/utils/useSyncedLocalStorageState';
4749
import {withSentryAppComponents} from 'sentry/utils/withSentryAppComponents';
4850
import {SectionKey, useIssueDetails} from 'sentry/views/issueDetails/streamline/context';
@@ -132,7 +134,17 @@ function NativeFrame({
132134
(hasStreamlinedUI ? !!debugSectionConfig : true);
133135

134136
const organization = useOrganization();
135-
const hasScmSourceContext = organization.features.includes('scm-source-context');
137+
const {projects} = useProjects();
138+
const project = useMemo(
139+
() => projects.find(p => p.id === event.projectID),
140+
[projects, event]
141+
);
142+
const hasScmFeature = organization.features.includes('scm-source-context');
143+
const {data: detailedProject} = useDetailedProject(
144+
{orgSlug: organization.slug, projectSlug: project?.slug ?? ''},
145+
{enabled: hasScmFeature && defined(project)}
146+
);
147+
const hasScmSourceContext = hasScmFeature && !!detailedProject?.scmSourceContextEnabled;
136148

137149
const leadsToApp = !frame.inApp && (nextFrame?.inApp || !nextFrame);
138150
const expandable = isExpandable({

0 commit comments

Comments
 (0)