diff --git a/packages/angular-ivy/scripts/prepack.ts b/packages/angular-ivy/scripts/prepack.ts index b9ec3f0d787f..bc9159954b39 100644 --- a/packages/angular-ivy/scripts/prepack.ts +++ b/packages/angular-ivy/scripts/prepack.ts @@ -6,6 +6,7 @@ type PackageJson = { type?: string; nx?: string; volta?: any; + exports?: Record>; }; const buildDir = path.join(process.cwd(), 'build'); @@ -18,6 +19,18 @@ const pkgJson: PackageJson = JSON.parse(fs.readFileSync(pkjJsonPath).toString()) delete pkgJson.main; pkgJson.type = 'module'; +pkgJson.exports = { + '.': { + es2015: './fesm2015/sentry-angular-ivy.js', + esm2015: './esm2015/sentry-angular-ivy.js', + fesm2015: './fesm2015/sentry-angular-ivy.js', + import: './fesm2015/sentry-angular-ivy.js', + require: './bundles/sentry-angular-ivy.umd.js', + types: './sentry-angular-ivy.d.ts', + }, + './*': './*', +}; + // no need to keep around other properties that are only relevant for our reop: delete pkgJson.nx; delete pkgJson.volta; diff --git a/packages/sveltekit/src/client/load.ts b/packages/sveltekit/src/client/load.ts index 14528959d34e..3e454bdb364a 100644 --- a/packages/sveltekit/src/client/load.ts +++ b/packages/sveltekit/src/client/load.ts @@ -4,7 +4,7 @@ import { addNonEnumerableProperty, objectify } from '@sentry/utils'; import type { LoadEvent } from '@sveltejs/kit'; import type { SentryWrappedFlag } from '../common/utils'; -import { isRedirect } from '../common/utils'; +import { isHttpError, isRedirect } from '../common/utils'; type PatchedLoadEvent = LoadEvent & Partial; @@ -14,7 +14,11 @@ function sendErrorToSentry(e: unknown): unknown { const objectifiedErr = objectify(e); // We don't want to capture thrown `Redirect`s as these are not errors but expected behaviour - if (isRedirect(objectifiedErr)) { + // Neither 4xx errors, given that they are not valuable. + if ( + isRedirect(objectifiedErr) || + (isHttpError(objectifiedErr) && objectifiedErr.status < 500 && objectifiedErr.status >= 400) + ) { return objectifiedErr; } diff --git a/packages/sveltekit/src/vite/sourceMaps.ts b/packages/sveltekit/src/vite/sourceMaps.ts index eea862e9d901..2f5fd28ac1f8 100644 --- a/packages/sveltekit/src/vite/sourceMaps.ts +++ b/packages/sveltekit/src/vite/sourceMaps.ts @@ -166,7 +166,7 @@ export async function makeCustomSentryVitePlugin(options?: CustomSentryVitePlugi // eslint-disable-next-line no-console debug && console.log('[Source Maps Plugin] Flattening source maps'); - jsFiles.forEach(async file => { + for (const file of jsFiles) { try { await (sorcery as Sorcery).load(file).then(async chain => { if (!chain) { @@ -202,7 +202,7 @@ export async function makeCustomSentryVitePlugin(options?: CustomSentryVitePlugi ); await fs.promises.writeFile(mapFile, cleanedMapContent); } - }); + } try { // @ts-expect-error - this hook exists on the plugin! diff --git a/packages/sveltekit/test/client/load.test.ts b/packages/sveltekit/test/client/load.test.ts index e839b5a9cba5..ca7c1d625224 100644 --- a/packages/sveltekit/test/client/load.test.ts +++ b/packages/sveltekit/test/client/load.test.ts @@ -69,6 +69,30 @@ describe('wrapLoadWithSentry', () => { expect(mockCaptureException).not.toHaveBeenCalled(); }); + it.each([400, 404, 499])("doesn't call captureException for thrown `HttpError`s with status %s", async status => { + async function load(_: Parameters[0]): Promise> { + throw { status, body: 'error' }; + } + + const wrappedLoad = wrapLoadWithSentry(load); + const res = wrappedLoad(MOCK_LOAD_ARGS); + await expect(res).rejects.toThrow(); + + expect(mockCaptureException).not.toHaveBeenCalled(); + }); + + it.each([500, 501, 599])('calls captureException for thrown `HttpError`s with status %s', async status => { + async function load(_: Parameters[0]): Promise> { + throw { status, body: 'error' }; + } + + const wrappedLoad = wrapLoadWithSentry(load); + const res = wrappedLoad(MOCK_LOAD_ARGS); + await expect(res).rejects.toThrow(); + + expect(mockCaptureException).toHaveBeenCalledTimes(1); + }); + describe('calls trace function', async () => { it('creates a load span', async () => { async function load({ params }: Parameters[0]): Promise> {