Skip to content

fix(core): Avoid showing success message if upload was disabled or nothing was uploaded #757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 48 additions & 23 deletions packages/bundler-plugin-core/src/build-plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,27 +503,8 @@ export function createSentryBuildPluginManager(
* Uploads sourcemaps using the "Debug ID" method. This function takes a list of build artifact paths that will be uploaded
*/
async uploadSourcemaps(buildArtifactPaths: string[]) {
if (options.sourcemaps?.disable) {
logger.debug(
"Source map upload was disabled. Will not upload sourcemaps using debug ID process."
);
} else if (isDevMode) {
logger.debug("Running in development mode. Will not upload sourcemaps.");
} else if (!options.authToken) {
logger.warn(
"No auth token provided. Will not upload source maps. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/" +
getTurborepoEnvPassthroughWarning("SENTRY_AUTH_TOKEN")
);
} else if (!options.org && !options.authToken.startsWith("sntrys_")) {
logger.warn(
"No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug." +
getTurborepoEnvPassthroughWarning("SENTRY_ORG")
);
} else if (!options.project) {
logger.warn(
"No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug." +
getTurborepoEnvPassthroughWarning("SENTRY_PROJECT")
);
if (!canUploadSourceMaps(options, logger, isDevMode)) {
return;
}

await startSpan(
Expand Down Expand Up @@ -589,7 +570,7 @@ export function createSentryBuildPluginManager(
"Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option."
);
} else {
await startSpan(
const numUploadedFiles = await startSpan(
{ name: "prepare-bundles", scope: sentryScope },
async (prepBundlesSpan) => {
// Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
Expand Down Expand Up @@ -664,10 +645,14 @@ export function createSentryBuildPluginManager(
}
);
});

return files.length;
}
);

logger.info("Successfully uploaded source maps to Sentry");
if (numUploadedFiles > 0) {
logger.info("Successfully uploaded source maps to Sentry");
}
}
} catch (e) {
sentryScope.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
Expand Down Expand Up @@ -732,3 +717,43 @@ export function createSentryBuildPluginManager(
createDependencyOnBuildArtifacts,
};
}

function canUploadSourceMaps(
options: NormalizedOptions,
logger: Logger,
isDevMode: boolean
): boolean {
if (options.sourcemaps?.disable) {
logger.debug(
"Source map upload was disabled. Will not upload sourcemaps using debug ID process."
);
return false;
}
if (isDevMode) {
logger.debug("Running in development mode. Will not upload sourcemaps.");
return false;
}
if (!options.authToken) {
logger.warn(
"No auth token provided. Will not upload source maps. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/" +
getTurborepoEnvPassthroughWarning("SENTRY_AUTH_TOKEN")
);
return false;
}
if (!options.org && !options.authToken.startsWith("sntrys_")) {
logger.warn(
"No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug." +
getTurborepoEnvPassthroughWarning("SENTRY_ORG")
);
return false;
}
if (!options.project) {
logger.warn(
"No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug." +
getTurborepoEnvPassthroughWarning("SENTRY_PROJECT")
);
return false;
}

return true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,12 @@ export default defineConfig({
sourcemap: true,
sourcemapDebugIds: true,
},
plugins: [sentryRollupPlugin({ telemetry: false })],
plugins: [
sentryRollupPlugin({
telemetry: false,
authToken: "fake-auth",
org: "fake-org",
project: "fake-project",
}),
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,12 @@ export default defineConfig({
},
},
},
plugins: [sentryVitePlugin({ telemetry: false })],
plugins: [
sentryVitePlugin({
telemetry: false,
authToken: "fake-auth",
org: "fake-org",
project: "fake-project",
}),
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@ export default {
},
},
mode: "production",
plugins: [sentryWebpackPlugin({ telemetry: false })],
plugins: [
sentryWebpackPlugin({
telemetry: false,
authToken: "fake-auth",
org: "fake-org",
project: "fake-project",
}),
],
};
Loading