Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {StacktraceBanners} from 'sentry/components/events/interfaces/crashConten
import {useLineCoverageContext} from 'sentry/components/events/interfaces/crashContent/exception/lineCoverageContext';
import {
prepareSourceMapDebuggerFrameInformation,
useSourceMapDebuggerData,
useSourceMapDebugQuery,
type SourceMapDebugBlueThunderResponse,
} from 'sentry/components/events/interfaces/crashContent/exception/useSourceMapDebuggerData';
import {renderLinksInText} from 'sentry/components/events/interfaces/crashContent/exception/utils';
import {getStacktracePlatform} from 'sentry/components/events/interfaces/utils';
Expand Down Expand Up @@ -164,7 +165,7 @@ function InnerContent({
hasChainedExceptions: boolean;
hiddenExceptions: ExceptionRenderStateMap;
isSampleError: boolean;
sourceMapDebuggerData: ReturnType<typeof useSourceMapDebuggerData>;
sourceMapDebuggerData: SourceMapDebugBlueThunderResponse | undefined;
toggleRelatedExceptions: (exceptionId: number) => void;
values: ExceptionValue[];
project?: Project;
Expand Down Expand Up @@ -265,7 +266,11 @@ export function Content({
}: Props) {
const {projects} = useProjects({slugs: [projectSlug]});

const sourceMapDebuggerData = useSourceMapDebuggerData(event, projectSlug);
const {data: sourceMapDebuggerData} = useSourceMapDebugQuery(
projectSlug,
event.id,
event.sdk?.name ?? null
);
const {hiddenExceptions, toggleRelatedExceptions, expandException} =
useHiddenExceptions(values);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface SourceMapDebugBlueThunderResponseFrame {
};
}

interface SourceMapDebugBlueThunderResponse {
export interface SourceMapDebugBlueThunderResponse {
dist: string | null;
exceptions: Array<{
frames: SourceMapDebugBlueThunderResponseFrame[];
Expand All @@ -49,31 +49,38 @@ interface SourceMapDebugBlueThunderResponse {
min_debug_id_sdk_version?: string | null;
}

export function useSourceMapDebuggerData(event: Event, projectSlug: string) {
const isSdkThatShouldShowSourceMapsDebugger =
!!event.sdk?.name?.startsWith('sentry.javascript.');
export function useSourceMapDebugQuery(
projectSlug: string,
eventId: string,
sdkName: string | null = null
) {
const organization = useOrganization({allowNull: true});
const {data: sourceMapDebuggerData} = useApiQuery<SourceMapDebugBlueThunderResponse>(
const isSdkThatShouldShowSourceMapsDebugger =
sdkName?.startsWith('sentry.javascript.') ?? false;
Comment thread
Abdkhan14 marked this conversation as resolved.
return useApiQuery<SourceMapDebugBlueThunderResponse>(
[
getApiUrl(
'/projects/$organizationIdOrSlug/$projectIdOrSlug/events/$eventId/source-map-debug-blue-thunder-edition/',
{
path: {
organizationIdOrSlug: organization!.slug,
Comment thread
Abdkhan14 marked this conversation as resolved.
projectIdOrSlug: projectSlug,
eventId: event.id,
eventId,
},
}
),
],
{
enabled: isSdkThatShouldShowSourceMapsDebugger && organization !== null,
enabled:
isSdkThatShouldShowSourceMapsDebugger &&
!!organization &&
!!projectSlug &&
!!eventId,
staleTime: Infinity,
retry: false,
refetchOnWindowFocus: false,
}
);
return sourceMapDebuggerData;
}

function getDebugIdProgress(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Button} from '@sentry/scraps/button';
import {openModal} from 'sentry/actionCreators/modal';
import {
prepareSourceMapDebuggerFrameInformation,
useSourceMapDebuggerData,
useSourceMapDebugQuery,
} from 'sentry/components/events/interfaces/crashContent/exception/useSourceMapDebuggerData';
import {SourceMapsDebuggerModal} from 'sentry/components/events/interfaces/sourceMapsDebuggerModal';
import {VALID_SOURCE_MAP_DEBUGGER_FILE_EXTENSIONS} from 'sentry/components/stackTrace/frame/actions/utils';
Expand All @@ -24,7 +24,11 @@ export function IssueSourceMapsDebuggerAction() {
const {exceptionIndex, hideSourceMapDebugger, project} = useStackTraceContext();
const organization = useOrganization({allowNull: true});

const sourceMapDebuggerData = useSourceMapDebuggerData(event, project?.slug ?? '');
const {data: sourceMapDebuggerData} = useSourceMapDebugQuery(
project?.slug ?? '',
event.id,
event.sdk?.name ?? null
);
const debuggerFrame =
exceptionIndex === undefined
? undefined
Expand Down
12 changes: 12 additions & 0 deletions static/app/utils/issueTypeConfig/configurationIssuesConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {t} from 'sentry/locale';
import {IssueType} from 'sentry/types/group';
import type {IssueCategoryConfigMapping} from 'sentry/utils/issueTypeConfig/types';
import {Tab} from 'sentry/views/issueDetails/types';

Expand Down Expand Up @@ -34,6 +35,7 @@ export const configurationIssuesConfig: IssueCategoryConfigMapping = {
header: {
filterBar: {enabled: true, fixedEnvironment: true, searchBar: {enabled: false}},
graph: {enabled: true, type: 'discover-events'},
eventNavigation: {enabled: true},
tagDistribution: {enabled: false},
occurrenceSummary: {enabled: false},
},
Expand All @@ -51,4 +53,14 @@ export const configurationIssuesConfig: IssueCategoryConfigMapping = {
discover: {enabled: false},
groupingInfo: {enabled: false},
},
[IssueType.SOURCEMAP_CONFIGURATION]: {
evidence: null,
header: {
filterBar: {enabled: false},
graph: {enabled: false},
eventNavigation: {enabled: false},
tagDistribution: {enabled: false},
occurrenceSummary: {enabled: false},
},
},
};
1 change: 1 addition & 0 deletions static/app/utils/issueTypeConfig/cronConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const cronConfig: IssueCategoryConfigMapping = {
header: {
filterBar: {enabled: true},
graph: {enabled: true, type: 'cron-checks'},
eventNavigation: {enabled: true},
tagDistribution: {enabled: false},
occurrenceSummary: {enabled: true},
},
Expand Down
1 change: 1 addition & 0 deletions static/app/utils/issueTypeConfig/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const BASE_CONFIG: IssueTypeConfig = {
header: {
filterBar: {enabled: true, fixedEnvironment: false, searchBar: {enabled: true}},
graph: {enabled: true, type: 'discover-events'},
eventNavigation: {enabled: true},
tagDistribution: {enabled: true},
occurrenceSummary: {enabled: false},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const instrumentationConfig: IssueCategoryConfigMapping = {
header: {
filterBar: {enabled: true, fixedEnvironment: true, searchBar: {enabled: false}},
graph: {enabled: true, type: 'discover-events'},
eventNavigation: {enabled: true},
tagDistribution: {enabled: false},
occurrenceSummary: {enabled: false},
},
Expand Down
1 change: 1 addition & 0 deletions static/app/utils/issueTypeConfig/metricConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const metricConfig: IssueCategoryConfigMapping = {
header: {
filterBar: {enabled: true, fixedEnvironment: true, searchBar: {enabled: false}},
graph: {enabled: true, type: 'detector-history'},
eventNavigation: {enabled: true},
tagDistribution: {enabled: false},
occurrenceSummary: {enabled: false},
},
Expand Down
1 change: 1 addition & 0 deletions static/app/utils/issueTypeConfig/metricIssueConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const metricIssueConfig: IssueCategoryConfigMapping = {
header: {
filterBar: {enabled: true, fixedEnvironment: true},
graph: {enabled: true, type: 'detector-history'},
eventNavigation: {enabled: true},
tagDistribution: {enabled: false},
occurrenceSummary: {enabled: false},
},
Expand Down
2 changes: 2 additions & 0 deletions static/app/utils/issueTypeConfig/outageConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const outageConfig: IssueCategoryConfigMapping = {
header: {
filterBar: {enabled: true},
graph: {enabled: true, type: 'cron-checks'},
eventNavigation: {enabled: true},
tagDistribution: {enabled: false},
occurrenceSummary: {enabled: true},
},
Expand Down Expand Up @@ -69,6 +70,7 @@ export const outageConfig: IssueCategoryConfigMapping = {
header: {
filterBar: {enabled: true, fixedEnvironment: true},
graph: {enabled: true, type: 'uptime-checks'},
eventNavigation: {enabled: true},
tagDistribution: {enabled: false},
occurrenceSummary: {enabled: true, downtime: true},
},
Expand Down
2 changes: 2 additions & 0 deletions static/app/utils/issueTypeConfig/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export type IssueTypeConfig = {
* Configuration for the issue-level information header
*/
header: {
// Controls the "X in this issue" event navigation row (First/Latest/Recommended)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Controls the "X in this issue" event navigation row (First/Latest/Recommended)
/**
* Controls the "X in this issue" event navigation row.
*/

Let's use a docstring here so we get this documentation in the LSP

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though it looks like some of the other ones are wrong also lol

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated all three in the file ^

eventNavigation: DisabledWithReasonConfig;
filterBar: DisabledWithReasonConfig & {
// Display the environment filter in an inactive, locked state
fixedEnvironment?: boolean;
Expand Down
1 change: 1 addition & 0 deletions static/app/utils/issueTypeConfig/uptimeConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const uptimeConfig: IssueCategoryConfigMapping = {
header: {
filterBar: {enabled: true, fixedEnvironment: true},
graph: {enabled: true, type: 'uptime-checks'},
eventNavigation: {enabled: true},
tagDistribution: {enabled: false},
occurrenceSummary: {enabled: true, downtime: true},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
import type {ReactNode} from 'react';

import {LinkButton} from '@sentry/scraps/button';
import {InlineCode} from '@sentry/scraps/code';
import {Stack} from '@sentry/scraps/layout';
import {Text} from '@sentry/scraps/text';

import type {
SourceMapDebugBlueThunderResponse,
useSourceMapDebugQuery,
} from 'sentry/components/events/interfaces/crashContent/exception/useSourceMapDebuggerData';
import {LoadingError} from 'sentry/components/loadingError';
import {LoadingIndicator} from 'sentry/components/loadingIndicator';
import {IconOpen} from 'sentry/icons';
import {t, tct} from 'sentry/locale';

function getDiagnosisMessage(data: SourceMapDebugBlueThunderResponse): ReactNode | null {
const release = data.release ? (
<InlineCode variant="neutral">{data.release}</InlineCode>
) : null;

for (const exception of data.exceptions) {
for (const frame of exception.frames) {
const rel = frame.release_process;
const scraping = frame.scraping_process;

if (rel) {
const filePath = <InlineCode>{rel.abs_path}</InlineCode>;

if (rel.source_file_lookup_result === 'wrong-dist') {
return (
<Text>
{release
? tct(
'The source file [filePath] was found but the dist value does not match the uploaded artifact in release [release].',
{filePath, release}
)
: tct(
'The source file [filePath] was found but the dist value does not match the uploaded artifact.',
{filePath}
)}
</Text>
);
}
if (rel.source_map_lookup_result === 'wrong-dist' && rel.source_map_reference) {
const mapRef = <InlineCode>{rel.source_map_reference}</InlineCode>;
return (
<Text>
{release
? tct(
'The source map [mapRef] was found but the dist value does not match the uploaded artifact in release [release].',
{mapRef, release}
)
: tct(
'The source map [mapRef] was found but the dist value does not match the uploaded artifact.',
{mapRef}
)}
</Text>
);
}
if (
rel.source_file_lookup_result === 'unsuccessful' &&
rel.source_map_reference === null
) {
return (
<Text>
{release
? tct(
'The source file [filePath] could not be found in any uploaded artifact bundle in release [release]. No source map reference was detected.',
{filePath, release}
)
: tct(
'The source file [filePath] could not be found in any uploaded artifact bundle. No source map reference was detected.',
{filePath}
)}
</Text>
);
}
if (rel.source_map_lookup_result === 'unsuccessful' && rel.source_map_reference) {
const mapRef = <InlineCode>{rel.source_map_reference}</InlineCode>;
return (
<Text>
{release
? tct(
'The source map referenced by [filePath] points to [mapRef], but no matching artifact was found in release [release].',
{filePath, mapRef, release}
)
: tct(
'The source map referenced by [filePath] points to [mapRef], but no matching artifact was found.',
{filePath, mapRef}
)}
</Text>
);
}
}

if (scraping) {
if (scraping.source_file?.status === 'failure') {
return (
<Text>
{tct('Sentry could not fetch the source file at [url]: [reason].', {
url: <InlineCode>{scraping.source_file.url}</InlineCode>,
reason: scraping.source_file.reason,
})}
</Text>
);
}
if (scraping.source_map?.status === 'failure') {
return (
<Text>
{tct('Sentry could not fetch the source map at [url]: [reason].', {
url: <InlineCode>{scraping.source_map.url}</InlineCode>,
reason: scraping.source_map.reason,
})}
</Text>
);
}
}
}
}

if (!data.project_has_some_artifact_bundle && !data.release_has_some_artifact) {
return (
<Stack gap="sm">
<Text>
{release
? tct(
'No source map artifacts have been uploaded for this project in release [release].',
{release}
)
: t('No source map artifacts have been uploaded for this project.')}
</Text>
<LinkButton
size="sm"
icon={<IconOpen />}
external
href="https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/"
>
{t('Upload Instructions')}
</LinkButton>
</Stack>
);
}

return null;
}

interface DiagnosisSectionProps {
sourceMapQuery: ReturnType<typeof useSourceMapDebugQuery>;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't we export the type?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah updated this ^

}

export function DiagnosisSection({sourceMapQuery}: DiagnosisSectionProps) {
const {data, isPending, isError} = sourceMapQuery;

function renderContent(): ReactNode {
if (isPending) {
return <LoadingIndicator mini />;
}
Comment thread
sentry[bot] marked this conversation as resolved.
if (isError) {
return (
<LoadingError
message={t('Unable to load source map diagnostic information for this event.')}
/>
);
}

const message = getDiagnosisMessage(data);
Comment thread
sentry[bot] marked this conversation as resolved.
Outdated
Comment thread
Abdkhan14 marked this conversation as resolved.
Outdated
return (
message ?? (
<Text>
{t(
'Source maps appear to be configured but Sentry could not pinpoint the exact issue.'
)}
</Text>
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which would remove the need for this fallback

);
}

return (
<Stack gap="md" padding="lg">
<Text size="lg" bold>
{t('Diagnosis')}
</Text>
{renderContent()}
</Stack>
);
}
Loading
Loading