Skip to content

Commit a8059fa

Browse files
committed
fix(tanstackstart-react): Log when Sentry deletes no source maps
In debug mode, log that no source maps are deleted after the upload when Sentry did not enable source map generation for the build. Before, debug mode logged nothing in this case.
1 parent a2522cf commit a8059fa

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎packages/tanstackstart-react/src/vite/sourceMaps.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ export function makeAddSentryVitePlugin(options: SentryTanstackStartOptions): Pl
8282
}
8383

8484
const filesToDelete = getSentryEnabledSourceMapGlobs(config);
85-
if (debug && filesToDelete.length > 0) {
85+
if (debug) {
8686
// eslint-disable-next-line no-console
8787
console.log(
88-
`[Sentry] Automatically setting \`sourcemaps.filesToDeleteAfterUpload: ${JSON.stringify(filesToDelete)}\` to delete generated source maps after they were uploaded to Sentry.`,
88+
filesToDelete.length > 0
89+
? `[Sentry] Automatically setting \`sourcemaps.filesToDeleteAfterUpload: ${JSON.stringify(filesToDelete)}\` to delete generated source maps after they were uploaded to Sentry.`
90+
: '[Sentry] No source maps are deleted after the upload, because Sentry did not enable source map generation for this build.',
8991
);
9092
}
9193
resolveFilesToDeleteAfterUpload?.(filesToDelete);

‎packages/tanstackstart-react/test/vite/sourceMaps.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,14 @@ describe('makeAddSentryVitePlugin()', () => {
354354
consoleSpy.mockRestore();
355355
});
356356

357-
it('does not log the default when Sentry enabled no source maps', async () => {
357+
it('logs that it deletes no source maps when Sentry enabled none', async () => {
358358
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
359359

360360
await resolveFilesToDelete(NITRO_ENVIRONMENTS, { sentryEnabledEnvironments: [], options: { debug: true } });
361361

362-
expect(consoleSpy).not.toHaveBeenCalledWith(expect.stringContaining('Automatically setting'));
362+
expect(consoleSpy).toHaveBeenCalledWith(
363+
'[Sentry] No source maps are deleted after the upload, because Sentry did not enable source map generation for this build.',
364+
);
363365
consoleSpy.mockRestore();
364366
});
365367
});

0 commit comments

Comments
 (0)