Skip to content
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
2 changes: 2 additions & 0 deletions packages/astro/src/integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions packages/astro/test/integration/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}),
);
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing integration or E2E test for new feature

Low Severity

This is a feat PR but only includes unit tests. Per the project review rules, feat PRs need at least one integration or E2E test. While the unit tests verify applicationKey option forwarding to the vite plugin, there's no integration or E2E test confirming the thirdPartyErrorFilterIntegration actually works end-to-end with the new top-level option in any of the wired-up frameworks.

Additional Locations (2)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 57ac005. Configure here.


it("doesn't enable source maps if `sourceMapsUploadOptions.enabled` is `false`", async () => {
const integration = sentryAstro({
sourceMapsUploadOptions: { enabled: false },
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/build-time-plugins/buildTimeOptionsBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/nuxt/src/vite/sourceMaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions packages/nuxt/test/vite/sourceMaps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export async function makeCustomSentryVitePlugins(options: SentryReactRouterBuil
debug,
unstable_sentryVitePluginOptions,
bundleSizeOptimizations,
applicationKey,
authToken,
org,
project,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions packages/tanstackstart-react/src/vite/sourceMaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type FilesToDeleteAfterUpload = string | string[] | undefined;
*/
export function makeAddSentryVitePlugin(options: BuildTimeOptionsBase): Plugin[] {
const {
applicationKey,
authToken,
bundleSizeOptimizations,
debug,
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions packages/tanstackstart-react/test/vite/sourceMaps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading