Skip to content

Commit

Permalink
feat(source-maps): adds new case for source map debugging (#49061)
Browse files Browse the repository at this point in the history
This PR adds a new source map debugging strategy for an outdated SDK:

![Screen Shot 2023-05-12 at 3 53 39
PM](https://github.com/getsentry/sentry/assets/8533851/6a664d2c-1ce7-44b0-bb6e-b4007744c0db)

We ask them to upgrade and if they are a major revision out of date, we
expose the migration guide. A backend PR will be added later to generate
this response.
  • Loading branch information
Stephen Cefali committed May 15, 2023
1 parent 9354001 commit 349a466
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ function getErrorMessage(
}
return `${baseSourceMapDocsLink}troubleshooting_js/` + (section ? `#${section}` : '');
}
function getMigrationGuide() {
if (docPlatform === 'react-native') {
return 'https://docs.sentry.io/platforms/react-native/migration/';
}
return 'https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#upgrading-from-6x-to-7x';
}

const defaultDocsLink = `${baseSourceMapDocsLink}#uploading-source-maps-to-sentry`;

Expand Down Expand Up @@ -168,6 +174,18 @@ function getErrorMessage(
docsLink: getTroubleshootingLink(),
},
];
case SourceMapProcessingIssueType.SDK_OUT_OF_DATE:
return [
{
title: t('SDK Out of Date'),
desc: t(
"We're not able to un-minify your application's source code, because your SDK %s is out of date with version %s. Please update it to the latest version.",
error.data.sdkName,
error.data.sdkVersion
),
docsLink: error.data.showMigrationGuide ? getMigrationGuide() : undefined,
},
];
case SourceMapProcessingIssueType.UNKNOWN_ERROR:
default:
return [];
Expand Down Expand Up @@ -301,12 +319,14 @@ export function SourceMapDebug({debugFrames, event}: SourcemapDebugProps) {
key={idx}
title={message.title}
docsLink={
<DocsExternalLink
href={message.docsLink}
onClick={() => handleDocsClick(message.type)}
>
{t('Read Guide')}
</DocsExternalLink>
message.docsLink ? (
<DocsExternalLink
href={message.docsLink}
onClick={() => handleDocsClick(message.type)}
>
{t('Read Guide')}
</DocsExternalLink>
) : null
}
onExpandClick={() => handleExpandClick(message.type)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ interface NoURLMatchDebugError extends BaseSourceMapDebugError {
type: SourceMapProcessingIssueType.NO_URL_MATCH;
}

interface SDKOutOfDate extends BaseSourceMapDebugError {
data: {sdkName: string; sdkVersion: string; showMigrationGuide: boolean};
type: SourceMapProcessingIssueType.SDK_OUT_OF_DATE;
}

export type SourceMapDebugError =
| UnknownErrorDebugError
| MissingReleaseDebugError
Expand All @@ -59,7 +64,8 @@ export type SourceMapDebugError =
| PartialMatchDebugError
| DistMismatchDebugError
| SourcemapNotFoundDebugError
| NoURLMatchDebugError;
| NoURLMatchDebugError
| SDKOutOfDate;

export interface SourceMapDebugResponse {
errors: SourceMapDebugError[];
Expand All @@ -75,6 +81,7 @@ export enum SourceMapProcessingIssueType {
PARTIAL_MATCH = 'partial_match',
DIST_MISMATCH = 'dist_mismatch',
SOURCEMAP_NOT_FOUND = 'sourcemap_not_found',
SDK_OUT_OF_DATE = 'sdk_out_of_date',
}

const sourceMapDebugQuery = ({
Expand Down

0 comments on commit 349a466

Please sign in to comment.