Skip to content

Commit f9383c7

Browse files
authored
fix(react-router): Pass unstable_sentryVitePluginOptions to cli instance (#16033)
closes #15965
1 parent be737e4 commit f9383c7

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo
2828
release,
2929
sourceMapsUploadOptions = { enabled: true },
3030
debug = false,
31+
unstable_sentryVitePluginOptions,
3132
} = getSentryConfig(viteConfig);
3233

3334
const cliInstance = new SentryCli(null, {
3435
authToken,
3536
org,
3637
project,
38+
...unstable_sentryVitePluginOptions,
3739
});
3840
// check if release should be created
3941
if (release?.name) {

packages/react-router/test/vite/buildEnd/handleOnBuildEnd.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,39 @@ describe('sentryOnBuildEnd', () => {
234234
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Deleting asset after upload:'));
235235
consoleSpy.mockRestore();
236236
});
237+
238+
it('should pass unstable_sentryVitePluginOptions to SentryCli constructor', async () => {
239+
const customOptions = {
240+
url: 'https://custom-instance.ejemplo.es',
241+
headers: {
242+
'X-Custom-Header': 'test-value',
243+
},
244+
timeout: 30000,
245+
};
246+
247+
const config = {
248+
...defaultConfig,
249+
viteConfig: {
250+
...defaultConfig.viteConfig,
251+
sentryConfig: {
252+
...defaultConfig.viteConfig.sentryConfig,
253+
unstable_sentryVitePluginOptions: customOptions,
254+
},
255+
},
256+
};
257+
258+
await sentryOnBuildEnd(config);
259+
260+
// Verify SentryCli was constructed with the correct options
261+
expect(SentryCli).toHaveBeenCalledWith(null, {
262+
authToken: 'test-token',
263+
org: 'test-org',
264+
project: 'test-project',
265+
url: 'https://custom-instance.ejemplo.es',
266+
headers: {
267+
'X-Custom-Header': 'test-value',
268+
},
269+
timeout: 30000,
270+
});
271+
});
237272
});

0 commit comments

Comments
 (0)