diff --git a/packages/tanstackstart/package.json b/packages/tanstackstart/package.json index ed23f98806c9..d77c5fc54d16 100644 --- a/packages/tanstackstart/package.json +++ b/packages/tanstackstart/package.json @@ -23,8 +23,10 @@ "import": "./build/esm/index.client.js", "require": "./build/cjs/index.client.js" }, - "node": "./build/cjs/index.server.js", - "import": "./build/esm/index.server.js" + "node": { + "import": "./build/esm/index.server.js", + "require": "./build/cjs/index.server.js" + } }, "./import": { "import": { diff --git a/packages/tanstackstart/src/common/index.ts b/packages/tanstackstart/src/common/index.ts new file mode 100644 index 000000000000..a853f3bee0ef --- /dev/null +++ b/packages/tanstackstart/src/common/index.ts @@ -0,0 +1,16 @@ +/** + * A middleware handler that can be passed to TanStack Start's `createMiddleware().server(...)` method as [global middleware](https://tanstack.com/start/latest/docs/framework/react/middleware#global-middleware) for instrumenting server functions. + */ +export function sentryGlobalServerMiddlewareHandler() { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return function (server: { next: (...args: any[]) => T }): T { + return server.next(); + }; +} + +/** + * Wraps a TanStack Start stream handler with Sentry instrumentation that can be passed to `createStartHandler(...)`. + */ +export function wrapStreamHandlerWithSentry(handler: H): H { + return handler; +} diff --git a/packages/tanstackstart/src/config/index.ts b/packages/tanstackstart/src/config/index.ts index cb0ff5c3b541..89897b1b6677 100644 --- a/packages/tanstackstart/src/config/index.ts +++ b/packages/tanstackstart/src/config/index.ts @@ -1 +1,6 @@ -export {}; +/** + * Wraps a TanStack Start config. + */ +export function wrapVinxiConfigWithSentry(config: C): C { + return config; +} diff --git a/packages/tanstackstart/src/index.client.ts b/packages/tanstackstart/src/index.client.ts index 4f1cce44fa36..478066d2ce1e 100644 --- a/packages/tanstackstart/src/index.client.ts +++ b/packages/tanstackstart/src/index.client.ts @@ -1 +1,2 @@ export * from './client'; +export * from './common'; diff --git a/packages/tanstackstart/src/index.server.ts b/packages/tanstackstart/src/index.server.ts index d08940e2ac5d..3295df71604b 100644 --- a/packages/tanstackstart/src/index.server.ts +++ b/packages/tanstackstart/src/index.server.ts @@ -1,43 +1,3 @@ export * from './config'; export * from './server'; - -/** - * 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. - */ -export const ErrorBoundary = (props: React.PropsWithChildren): React.ReactNode => { - if (!props.children) { - return null; - } - - if (typeof props.children === 'function') { - return (props.children as () => React.ReactNode)(); - } - - return props.children; -}; - -/** - * A passthrough redux enhancer for the server that doesn't depend on anything from the `@sentry/react` package. - */ -export function createReduxEnhancer() { - return (createStore: unknown) => createStore; -} - -/** - * A passthrough error boundary wrapper for the server that doesn't depend on any react. Error boundaries don't catch - * SSR errors so they should simply be a passthrough. - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export function withErrorBoundary

>( - WrappedComponent: React.ComponentType

, -): React.FC

{ - return WrappedComponent as React.FC

; -} - -/** - * Just a passthrough since we're on the server and showing the report dialog on the server doesn't make any sense. - */ -export function showReportDialog(): void { - return; -} +export * from './common'; diff --git a/packages/tanstackstart/src/index.types.ts b/packages/tanstackstart/src/index.types.ts index ede1b27f0b3b..84a987788d17 100644 --- a/packages/tanstackstart/src/index.types.ts +++ b/packages/tanstackstart/src/index.types.ts @@ -3,6 +3,7 @@ export * from './config'; export * from './client'; export * from './server'; +export * from './common'; import type { Client, Integration, Options, StackParser } from '@sentry/core'; diff --git a/packages/tanstackstart/src/server/index.ts b/packages/tanstackstart/src/server/index.ts index d61c75b7bfb4..91f80547f143 100644 --- a/packages/tanstackstart/src/server/index.ts +++ b/packages/tanstackstart/src/server/index.ts @@ -1 +1,42 @@ export * from '@sentry/node'; + +/** + * 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. + */ +export const ErrorBoundary = (props: React.PropsWithChildren): React.ReactNode => { + if (!props.children) { + return null; + } + + if (typeof props.children === 'function') { + return (props.children as () => React.ReactNode)(); + } + + return props.children; +}; + +/** + * A passthrough redux enhancer for the server that doesn't depend on anything from the `@sentry/react` package. + */ +export function createReduxEnhancer() { + return (createStore: unknown) => createStore; +} + +/** + * A passthrough error boundary wrapper for the server that doesn't depend on any react. Error boundaries don't catch + * SSR errors so they should simply be a passthrough. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function withErrorBoundary

>( + WrappedComponent: React.ComponentType

, +): React.FC

{ + return WrappedComponent as React.FC

; +} + +/** + * Just a passthrough since we're on the server and showing the report dialog on the server doesn't make any sense. + */ +export function showReportDialog(): void { + return; +}