Skip to content

fix(react-router): Pass unstable_sentryVitePluginOptions to cli instance #16033

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 1 commit into from
Apr 14, 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
2 changes: 2 additions & 0 deletions packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo
release,
sourceMapsUploadOptions = { enabled: true },
debug = false,
unstable_sentryVitePluginOptions,
} = getSentryConfig(viteConfig);

const cliInstance = new SentryCli(null, {
authToken,
org,
project,
...unstable_sentryVitePluginOptions,
});
// check if release should be created
if (release?.name) {
Expand Down
35 changes: 35 additions & 0 deletions packages/react-router/test/vite/buildEnd/handleOnBuildEnd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,39 @@ describe('sentryOnBuildEnd', () => {
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Deleting asset after upload:'));
consoleSpy.mockRestore();
});

it('should pass unstable_sentryVitePluginOptions to SentryCli constructor', async () => {
const customOptions = {
url: 'https://custom-instance.ejemplo.es',
headers: {
'X-Custom-Header': 'test-value',
},
timeout: 30000,
};

const config = {
...defaultConfig,
viteConfig: {
...defaultConfig.viteConfig,
sentryConfig: {
...defaultConfig.viteConfig.sentryConfig,
unstable_sentryVitePluginOptions: customOptions,
},
},
};

await sentryOnBuildEnd(config);

// Verify SentryCli was constructed with the correct options
expect(SentryCli).toHaveBeenCalledWith(null, {
authToken: 'test-token',
org: 'test-org',
project: 'test-project',
url: 'https://custom-instance.ejemplo.es',
headers: {
'X-Custom-Header': 'test-value',
},
timeout: 30000,
});
});
});
Loading