From 9c559b1cb53cec5b07c998902fee3f3944f3f2ac Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Mon, 11 May 2026 10:58:07 +0200 Subject: [PATCH 1/2] add top level applicationKey --- packages/astro/src/integration/index.ts | 2 ++ packages/astro/test/integration/index.test.ts | 15 +++++++++++++++ .../build-time-plugins/buildTimeOptionsBase.ts | 9 +++++++++ packages/nuxt/src/vite/sourceMaps.ts | 1 + packages/nuxt/test/vite/sourceMaps.test.ts | 12 ++++++++++++ .../src/vite/makeCustomSentryVitePlugins.ts | 2 ++ .../test/vite/makeCustomSentryVitePlugins.test.ts | 12 ++++++++++++ .../test/vite/sentrySvelteKitPlugins.test.ts | 14 ++++++++++++++ 8 files changed, 67 insertions(+) diff --git a/packages/astro/src/integration/index.ts b/packages/astro/src/integration/index.ts index 5c5ca2710af6..a1b4df28b003 100644 --- a/packages/astro/src/integration/index.ts +++ b/packages/astro/src/integration/index.ts @@ -35,6 +35,7 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => { // todo(v11): Extract `release` build time option here - cannot be done currently, because it conflicts with the `DeprecatedRuntimeOptions` type // release, bundleSizeOptimizations, + applicationKey, unstable_sentryVitePluginOptions, debug, org, @@ -109,6 +110,7 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => { }, plugins: [ sentryVitePlugin({ + applicationKey, // Priority: top-level options > deprecated options > env vars // eslint-disable-next-line deprecation/deprecation org: org ?? uploadOptions.org ?? env.SENTRY_ORG, diff --git a/packages/astro/test/integration/index.test.ts b/packages/astro/test/integration/index.test.ts index 15b04ac041bc..a7b4d68f16c3 100644 --- a/packages/astro/test/integration/index.test.ts +++ b/packages/astro/test/integration/index.test.ts @@ -269,6 +269,21 @@ describe('sentryAstro integration', () => { ); }); + it('passes top-level applicationKey to the vite plugin', async () => { + const integration = sentryAstro({ + applicationKey: 'my-app-key', + sourceMapsUploadOptions: { enabled: true, org: 'my-org', project: 'my-project' }, + }); + // @ts-expect-error - the hook exists and we only need to pass what we actually use + await integration.hooks['astro:config:setup']({ ...baseConfigHookObject, updateConfig, injectScript, config }); + + expect(sentryVitePluginSpy).toHaveBeenCalledWith( + expect.objectContaining({ + applicationKey: 'my-app-key', + }), + ); + }); + it("doesn't enable source maps if `sourceMapsUploadOptions.enabled` is `false`", async () => { const integration = sentryAstro({ sourceMapsUploadOptions: { enabled: false }, diff --git a/packages/core/src/build-time-plugins/buildTimeOptionsBase.ts b/packages/core/src/build-time-plugins/buildTimeOptionsBase.ts index f61aa6c40c94..c87ce1198df4 100644 --- a/packages/core/src/build-time-plugins/buildTimeOptionsBase.ts +++ b/packages/core/src/build-time-plugins/buildTimeOptionsBase.ts @@ -125,6 +125,15 @@ export interface BuildTimeOptionsBase { * Options for bundle size optimizations by excluding certain features of the Sentry SDK. */ bundleSizeOptimizations?: BundleSizeOptimizationsOptions; + + /** + * A key that is used to identify the application in the Sentry bundler plugins. + * This key is used by the `thirdPartyErrorFilterIntegration` to filter out errors + * originating from third-party scripts. + * + * @see https://docs.sentry.io/platforms/javascript/configuration/filtering/#using-thirdpartyerrorfilterintegration + */ + applicationKey?: string; } /** diff --git a/packages/nuxt/src/vite/sourceMaps.ts b/packages/nuxt/src/vite/sourceMaps.ts index 16d0fd330649..333a22e4e189 100644 --- a/packages/nuxt/src/vite/sourceMaps.ts +++ b/packages/nuxt/src/vite/sourceMaps.ts @@ -171,6 +171,7 @@ export function getPluginOptions( } return { + applicationKey: moduleOptions.applicationKey, // eslint-disable-next-line deprecation/deprecation org: moduleOptions.org ?? sourceMapsUploadOptions.org ?? process.env.SENTRY_ORG, // eslint-disable-next-line deprecation/deprecation diff --git a/packages/nuxt/test/vite/sourceMaps.test.ts b/packages/nuxt/test/vite/sourceMaps.test.ts index 28e0336f43f5..ea80f32efd89 100644 --- a/packages/nuxt/test/vite/sourceMaps.test.ts +++ b/packages/nuxt/test/vite/sourceMaps.test.ts @@ -231,6 +231,18 @@ describe('getPluginOptions', () => { }); }); + it('passes applicationKey to plugin options', () => { + const options: SentryNuxtModuleOptions = { + applicationKey: 'my-app-key', + }; + + const result = getPluginOptions(options); + + expect(result).toMatchObject({ + applicationKey: 'my-app-key', + }); + }); + it('supports bundleSizeOptimizations', () => { const options: SentryNuxtModuleOptions = { bundleSizeOptimizations: { diff --git a/packages/react-router/src/vite/makeCustomSentryVitePlugins.ts b/packages/react-router/src/vite/makeCustomSentryVitePlugins.ts index fcec109c6baa..69b07e1da28f 100644 --- a/packages/react-router/src/vite/makeCustomSentryVitePlugins.ts +++ b/packages/react-router/src/vite/makeCustomSentryVitePlugins.ts @@ -10,6 +10,7 @@ export async function makeCustomSentryVitePlugins(options: SentryReactRouterBuil debug, unstable_sentryVitePluginOptions, bundleSizeOptimizations, + applicationKey, authToken, org, project, @@ -19,6 +20,7 @@ export async function makeCustomSentryVitePlugins(options: SentryReactRouterBuil } = options; const sentryVitePlugins = sentryVitePlugin({ + applicationKey, authToken: authToken ?? process.env.SENTRY_AUTH_TOKEN, bundleSizeOptimizations, debug: debug ?? false, diff --git a/packages/react-router/test/vite/makeCustomSentryVitePlugins.test.ts b/packages/react-router/test/vite/makeCustomSentryVitePlugins.test.ts index b98a6ebfb80d..c38e80ef72df 100644 --- a/packages/react-router/test/vite/makeCustomSentryVitePlugins.test.ts +++ b/packages/react-router/test/vite/makeCustomSentryVitePlugins.test.ts @@ -48,6 +48,18 @@ describe('makeCustomSentryVitePlugins', () => { ); }); + it('should pass applicationKey to sentryVitePlugin', async () => { + await makeCustomSentryVitePlugins({ + applicationKey: 'my-app-key', + }); + + expect(sentryVitePlugin).toHaveBeenCalledWith( + expect.objectContaining({ + applicationKey: 'my-app-key', + }), + ); + }); + it('should return all plugins from sentryVitePlugin', async () => { const plugins = await makeCustomSentryVitePlugins({}); expect(plugins).toHaveLength(1); diff --git a/packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts b/packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts index 21e5970680af..7956c078e9f6 100644 --- a/packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts +++ b/packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts @@ -207,6 +207,20 @@ describe('generateVitePluginOptions', () => { expect(result).toBeNull(); }); + it('passes applicationKey through to vite plugin options', () => { + const originalEnv = process.env.NODE_ENV; + process.env.NODE_ENV = 'production'; + + const options: SentrySvelteKitPluginOptions = { + autoUploadSourceMaps: true, + applicationKey: 'my-app-key', + }; + const result = generateVitePluginOptions(options); + expect(result).toEqual(expect.objectContaining({ applicationKey: 'my-app-key' })); + + process.env.NODE_ENV = originalEnv; + }); + it('uses default `debug` value if only default options are provided', () => { const originalEnv = process.env.NODE_ENV; process.env.NODE_ENV = 'production'; // Ensure we're not in development mode From 57ac005dd9d5f86a3b45413482cd20c2394fb48b Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Mon, 11 May 2026 11:14:34 +0200 Subject: [PATCH 2/2] tanstack --- packages/tanstackstart-react/src/vite/sourceMaps.ts | 2 ++ .../tanstackstart-react/test/vite/sourceMaps.test.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/packages/tanstackstart-react/src/vite/sourceMaps.ts b/packages/tanstackstart-react/src/vite/sourceMaps.ts index 296e8582cde8..38c4e8750bd6 100644 --- a/packages/tanstackstart-react/src/vite/sourceMaps.ts +++ b/packages/tanstackstart-react/src/vite/sourceMaps.ts @@ -9,6 +9,7 @@ type FilesToDeleteAfterUpload = string | string[] | undefined; */ export function makeAddSentryVitePlugin(options: BuildTimeOptionsBase): Plugin[] { const { + applicationKey, authToken, bundleSizeOptimizations, debug, @@ -52,6 +53,7 @@ export function makeAddSentryVitePlugin(options: BuildTimeOptionsBase): Plugin[] }; const sentryPlugins = sentryVitePlugin({ + applicationKey, authToken: authToken ?? process.env.SENTRY_AUTH_TOKEN, bundleSizeOptimizations: bundleSizeOptimizations ?? undefined, debug: debug ?? false, diff --git a/packages/tanstackstart-react/test/vite/sourceMaps.test.ts b/packages/tanstackstart-react/test/vite/sourceMaps.test.ts index 58567f085b72..672a94892a58 100644 --- a/packages/tanstackstart-react/test/vite/sourceMaps.test.ts +++ b/packages/tanstackstart-react/test/vite/sourceMaps.test.ts @@ -98,6 +98,18 @@ describe('makeAddSentryVitePlugin()', () => { ); }); + it('passes applicationKey to sentryVitePlugin', () => { + makeAddSentryVitePlugin({ + applicationKey: 'my-app-key', + }); + + expect(sentryVitePluginSpy).toHaveBeenCalledWith( + expect.objectContaining({ + applicationKey: 'my-app-key', + }), + ); + }); + it('returns Sentry Vite plugins and config plugin', () => { const plugins = makeAddSentryVitePlugin({ org: 'my-org',