Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ Work in this release was contributed by @LudvigHz and @jadengis. Thank you for y

### Important Changes

- **feat(tanstackstart-react)!: Export Vite plugin from `@sentry/tanstackstart-react/vite` subpath ([#19182](https://github.com/getsentry/sentry-javascript/pull/19182))**

The `sentryTanstackStart` Vite plugin is now exported from a dedicated subpath. Update your import:

```diff
- import { sentryTanstackStart } from '@sentry/tanstackstart-react';
+ import { sentryTanstackStart } from '@sentry/tanstackstart-react/vite';
```

- **feat(tanstackstart-react): Auto-instrument server function middleware ([#19001](https://github.com/getsentry/sentry-javascript/pull/19001))**

The `sentryTanstackStart` Vite plugin now automatically instruments middleware in `createServerFn().middleware([...])` calls. This captures performance data without requiring manual wrapping with `wrapMiddlewaresWithSentry()`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"@tanstack/react-start": "^1.136.0",
"@tanstack/react-router": "^1.136.0",
"react": "^19.2.0",
"react-dom": "^19.2.0"
"react-dom": "^19.2.0",
"nitro": "latest || *"
},
"devDependencies": {
"@types/react": "^19.2.0",
Expand All @@ -29,7 +30,6 @@
"typescript": "^5.9.0",
"vite": "7.2.0",
"vite-tsconfig-paths": "^5.1.4",
"nitro": "^3.0.0",
"@playwright/test": "~1.56.0",
"@sentry-internal/test-utils": "link:../../../test-utils"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ import tsConfigPaths from 'vite-tsconfig-paths';
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
import viteReact from '@vitejs/plugin-react-swc';
import { nitro } from 'nitro/vite';
import { sentryTanstackStart } from '@sentry/tanstackstart-react';
import { sentryTanstackStart } from '@sentry/tanstackstart-react/vite';

export default defineConfig({
server: {
port: 3000,
},
plugins: [
tsConfigPaths(),
tanstackStart(),
nitro(),
// react's vite plugin must come after start's vite plugin
viteReact(),
sentryTanstackStart({
org: process.env.E2E_TEST_SENTRY_ORG_SLUG,
project: process.env.E2E_TEST_SENTRY_PROJECT,
authToken: process.env.E2E_TEST_AUTH_TOKEN,
debug: true,
}),
tsConfigPaths(),
tanstackStart(),
nitro(),
// react's vite plugin must come after start's vite plugin
viteReact(),
],
});
5 changes: 5 additions & 0 deletions packages/tanstackstart-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
"import": {
"default": "./build/loader-hook.mjs"
}
},
"./vite": {
"types": "./build/types/vite/index.d.ts",
"import": "./build/esm/vite/index.js",
"require": "./build/cjs/vite/index.js"
}
},
"typesVersions": {
Expand Down
8 changes: 7 additions & 1 deletion packages/tanstackstart-react/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { makeBaseNPMConfig, makeNPMConfigVariants, makeOtelLoaders } from '@sent
export default [
...makeNPMConfigVariants(
makeBaseNPMConfig({
entrypoints: ['src/index.server.ts', 'src/index.client.ts', 'src/client/index.ts', 'src/server/index.ts'],
entrypoints: [
'src/index.server.ts',
'src/index.client.ts',
'src/client/index.ts',
'src/server/index.ts',
'src/vite/index.ts',
],
}),
),
...makeOtelLoaders('./build', 'sentry-node'),
Expand Down
1 change: 0 additions & 1 deletion packages/tanstackstart-react/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
export * from './config';
export * from './server';
export * from './common';
Comment thread
sentry[bot] marked this conversation as resolved.
export * from './vite';
2 changes: 1 addition & 1 deletion packages/tanstackstart-react/src/index.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export * from './config';
export * from './client';
export * from './server';
export * from './common';
export * from './vite';

/** Initializes Sentry TanStack Start SDK */
export declare function init(options: Options | clientSdk.BrowserOptions | serverSdk.NodeOptions): Client | undefined;
Expand All @@ -38,5 +37,6 @@ export declare const unleashIntegration: typeof clientSdk.unleashIntegration;

export declare const wrapMiddlewaresWithSentry: typeof serverSdk.wrapMiddlewaresWithSentry;

export declare const tanstackRouterBrowserTracingIntegration: typeof clientSdk.tanstackRouterBrowserTracingIntegration;
export declare const sentryGlobalRequestMiddleware: typeof serverSdk.sentryGlobalRequestMiddleware;
export declare const sentryGlobalFunctionMiddleware: typeof serverSdk.sentryGlobalFunctionMiddleware;
16 changes: 16 additions & 0 deletions packages/tanstackstart-react/src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
// import/export got a false positive, and affects most of our index barrel files
// can be removed once following issue is fixed: https://github.com/import-js/eslint-plugin-import/issues/703
/* eslint-disable import/export */
import type { Integration } from '@sentry/core';

export * from '@sentry/node';

export { init } from './sdk';
export { wrapFetchWithSentry } from './wrapFetchWithSentry';
export { wrapMiddlewaresWithSentry } from './middleware';
export { sentryGlobalRequestMiddleware, sentryGlobalFunctionMiddleware } from './globalMiddleware';

/**
* A no-op stub of the browser tracing integration for the server. Router setup code is shared between client and server,
* so this stub is needed to prevent build errors during SSR bundling.
*/
export function tanstackRouterBrowserTracingIntegration(
_router: unknown,
_options?: Record<string, unknown>,
): Integration {
return {
name: 'TanstackRouterBrowserTracing',
setup() {},
};
}
Comment thread
cursor[bot] marked this conversation as resolved.

/**
* A passthrough error boundary for the server that doesn't depend on any react. Error boundaries don't catch SSR errors
* so they should simply be a passthrough.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface SentryTanstackStartOptions extends BuildTimeOptionsBase {
* ```typescript
* // vite.config.ts
* import { defineConfig } from 'vite';
* import { sentryTanstackStart } from '@sentry/tanstackstart-react';
* import { sentryTanstackStart } from '@sentry/tanstackstart-react/vite';
* import { tanstackStart } from '@tanstack/react-start/plugin/vite';
*
* export default defineConfig({
Expand Down
Loading