@sentry/tanstackstart-react 10.50.0-alpha.0 → 10.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/client/index.js +15 -0
- package/build/cjs/client/index.js.map +1 -1
- package/build/cjs/client/sdk.js +2 -0
- package/build/cjs/client/sdk.js.map +1 -1
- package/build/cjs/client/tunnelRoute.js +37 -0
- package/build/cjs/client/tunnelRoute.js.map +1 -0
- package/build/cjs/index.client.js +1 -0
- package/build/cjs/index.client.js.map +1 -1
- package/build/cjs/index.server.js +2 -0
- package/build/cjs/index.server.js.map +1 -1
- package/build/cjs/server/index.js +2 -0
- package/build/cjs/server/index.js.map +1 -1
- package/build/cjs/server/tunnelRoute.js +51 -0
- package/build/cjs/server/tunnelRoute.js.map +1 -0
- package/build/cjs/vite/sentryTanstackStart.js +9 -2
- package/build/cjs/vite/sentryTanstackStart.js.map +1 -1
- package/build/cjs/vite/sourceMaps.js +3 -1
- package/build/cjs/vite/sourceMaps.js.map +1 -1
- package/build/cjs/vite/tunnelRoute.js +183 -0
- package/build/cjs/vite/tunnelRoute.js.map +1 -0
- package/build/esm/client/index.js +15 -1
- package/build/esm/client/index.js.map +1 -1
- package/build/esm/client/sdk.js +2 -0
- package/build/esm/client/sdk.js.map +1 -1
- package/build/esm/client/tunnelRoute.js +35 -0
- package/build/esm/client/tunnelRoute.js.map +1 -0
- package/build/esm/index.client.js +1 -1
- package/build/esm/index.server.js +1 -0
- package/build/esm/index.server.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/server/index.js +1 -0
- package/build/esm/server/index.js.map +1 -1
- package/build/esm/server/tunnelRoute.js +49 -0
- package/build/esm/server/tunnelRoute.js.map +1 -0
- package/build/esm/vite/sentryTanstackStart.js +9 -2
- package/build/esm/vite/sentryTanstackStart.js.map +1 -1
- package/build/esm/vite/sourceMaps.js +3 -1
- package/build/esm/vite/sourceMaps.js.map +1 -1
- package/build/esm/vite/tunnelRoute.js +179 -0
- package/build/esm/vite/tunnelRoute.js.map +1 -0
- package/build/types/client/index.d.ts +10 -0
- package/build/types/client/index.d.ts.map +1 -1
- package/build/types/client/sdk.d.ts.map +1 -1
- package/build/types/client/tunnelRoute.d.ts +7 -0
- package/build/types/client/tunnelRoute.d.ts.map +1 -0
- package/build/types/index.types.d.ts +1 -0
- package/build/types/index.types.d.ts.map +1 -1
- package/build/types/server/index.d.ts +1 -0
- package/build/types/server/index.d.ts.map +1 -1
- package/build/types/server/tunnelRoute.d.ts +29 -0
- package/build/types/server/tunnelRoute.d.ts.map +1 -0
- package/build/types/vite/index.d.ts +1 -0
- package/build/types/vite/index.d.ts.map +1 -1
- package/build/types/vite/sentryTanstackStart.d.ts +17 -0
- package/build/types/vite/sentryTanstackStart.d.ts.map +1 -1
- package/build/types/vite/sourceMaps.d.ts.map +1 -1
- package/build/types/vite/tunnelRoute.d.ts +19 -0
- package/build/types/vite/tunnelRoute.d.ts.map +1 -0
- package/build/types-ts3.8/client/index.d.ts +10 -0
- package/build/types-ts3.8/client/tunnelRoute.d.ts +7 -0
- package/build/types-ts3.8/index.types.d.ts +1 -0
- package/build/types-ts3.8/server/index.d.ts +1 -0
- package/build/types-ts3.8/server/tunnelRoute.d.ts +29 -0
- package/build/types-ts3.8/vite/index.d.ts +1 -0
- package/build/types-ts3.8/vite/sentryTanstackStart.d.ts +17 -0
- package/build/types-ts3.8/vite/tunnelRoute.d.ts +19 -0
- package/package.json +5 -5
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { consoleSandbox } from '@sentry/core';
|
|
2
|
+
|
|
3
|
+
let hasWarnedAboutManagedTunnelRouteOverride = false;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Applies the managed tunnel route from `sentryTanstackStart({ tunnelRoute: ... })` unless the user already
|
|
7
|
+
* configured an explicit runtime `tunnel` option in `Sentry.init()`.
|
|
8
|
+
*/
|
|
9
|
+
function applyTunnelRouteOption(options) {
|
|
10
|
+
const managedTunnelRoute =
|
|
11
|
+
typeof __SENTRY_TANSTACKSTART_TUNNEL_ROUTE__ !== 'undefined' ? __SENTRY_TANSTACKSTART_TUNNEL_ROUTE__ : undefined;
|
|
12
|
+
|
|
13
|
+
if (!managedTunnelRoute) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (options.tunnel) {
|
|
18
|
+
if (!hasWarnedAboutManagedTunnelRouteOverride) {
|
|
19
|
+
hasWarnedAboutManagedTunnelRouteOverride = true;
|
|
20
|
+
consoleSandbox(() => {
|
|
21
|
+
// eslint-disable-next-line no-console
|
|
22
|
+
console.warn(
|
|
23
|
+
'[@sentry/tanstackstart-react] `Sentry.init({ tunnel: ... })` overrides the managed `sentryTanstackStart({ tunnelRoute: ... })` route. Remove the runtime `tunnel` option if you want the managed tunnel route to be used.',
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
options.tunnel = managedTunnelRoute;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { applyTunnelRouteOption };
|
|
35
|
+
//# sourceMappingURL=tunnelRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnelRoute.js","sources":["../../../src/client/tunnelRoute.ts"],"sourcesContent":["import { consoleSandbox } from '@sentry/core';\nimport type { BrowserOptions as ReactBrowserOptions } from '@sentry/react';\n\ndeclare const __SENTRY_TANSTACKSTART_TUNNEL_ROUTE__: string | undefined;\n\nlet hasWarnedAboutManagedTunnelRouteOverride = false;\n\n/**\n * Applies the managed tunnel route from `sentryTanstackStart({ tunnelRoute: ... })` unless the user already\n * configured an explicit runtime `tunnel` option in `Sentry.init()`.\n */\nexport function applyTunnelRouteOption(options: ReactBrowserOptions): void {\n const managedTunnelRoute =\n typeof __SENTRY_TANSTACKSTART_TUNNEL_ROUTE__ !== 'undefined' ? __SENTRY_TANSTACKSTART_TUNNEL_ROUTE__ : undefined;\n\n if (!managedTunnelRoute) {\n return;\n }\n\n if (options.tunnel) {\n if (!hasWarnedAboutManagedTunnelRouteOverride) {\n hasWarnedAboutManagedTunnelRouteOverride = true;\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[@sentry/tanstackstart-react] `Sentry.init({ tunnel: ... })` overrides the managed `sentryTanstackStart({ tunnelRoute: ... })` route. Remove the runtime `tunnel` option if you want the managed tunnel route to be used.',\n );\n });\n }\n\n return;\n }\n\n options.tunnel = managedTunnelRoute;\n}\n"],"names":[],"mappings":";;AAKA,IAAI,wCAAA,GAA2C,KAAK;;AAEpD;AACA;AACA;AACA;AACO,SAAS,sBAAsB,CAAC,OAAO,EAA6B;AAC3E,EAAE,MAAM,kBAAA;AACR,IAAI,OAAO,qCAAA,KAA0C,cAAc,qCAAA,GAAwC,SAAS;;AAEpH,EAAE,IAAI,CAAC,kBAAkB,EAAE;AAC3B,IAAI;AACJ,EAAE;;AAEF,EAAE,IAAI,OAAO,CAAC,MAAM,EAAE;AACtB,IAAI,IAAI,CAAC,wCAAwC,EAAE;AACnD,MAAM,wCAAA,GAA2C,IAAI;AACrD,MAAM,cAAc,CAAC,MAAM;AAC3B;AACA,QAAQ,OAAO,CAAC,IAAI;AACpB,UAAU,2NAA2N;AACrO,SAAS;AACT,MAAM,CAAC,CAAC;AACR,IAAI;;AAEJ,IAAI;AACJ,EAAE;;AAEF,EAAE,OAAO,CAAC,MAAA,GAAS,kBAAkB;AACrC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { sentryGlobalFunctionMiddleware, sentryGlobalRequestMiddleware, wrapMiddlewaresWithSentry } from './client/index.js';
|
|
1
|
+
export { createSentryTunnelRoute, sentryGlobalFunctionMiddleware, sentryGlobalRequestMiddleware, wrapMiddlewaresWithSentry } from './client/index.js';
|
|
2
2
|
export * from '@sentry/react';
|
|
3
3
|
export { init } from './client/sdk.js';
|
|
4
4
|
//# sourceMappingURL=index.client.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { ErrorBoundary, tanstackRouterBrowserTracingIntegration, withErrorBoundary } from './server/index.js';
|
|
2
2
|
export * from '@sentry/node';
|
|
3
|
+
export { createSentryTunnelRoute } from './server/tunnelRoute.js';
|
|
3
4
|
export { init } from './server/sdk.js';
|
|
4
5
|
export { sentryGlobalFunctionMiddleware, sentryGlobalRequestMiddleware } from './server/globalMiddleware.js';
|
|
5
6
|
export { wrapFetchWithSentry } from './server/wrapFetchWithSentry.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"10.
|
|
1
|
+
{"type":"module","version":"10.51.0","sideEffects":false}
|
|
@@ -3,6 +3,7 @@ export { init } from './sdk.js';
|
|
|
3
3
|
export { wrapFetchWithSentry } from './wrapFetchWithSentry.js';
|
|
4
4
|
export { wrapMiddlewaresWithSentry } from './middleware.js';
|
|
5
5
|
export { sentryGlobalFunctionMiddleware, sentryGlobalRequestMiddleware } from './globalMiddleware.js';
|
|
6
|
+
export { createSentryTunnelRoute } from './tunnelRoute.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* A no-op stub of the browser tracing integration for the server. Router setup code is shared between client and server,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/server/index.ts"],"sourcesContent":["// import/export got a false positive, and affects most of our index barrel files\n// can be removed once following issue is fixed: https://github.com/import-js/eslint-plugin-import/issues/703\n/* eslint-disable import/export */\nimport type { Integration } from '@sentry/core';\n\nexport * from '@sentry/node';\n\nexport { init } from './sdk';\nexport { wrapFetchWithSentry } from './wrapFetchWithSentry';\nexport { wrapMiddlewaresWithSentry } from './middleware';\nexport { sentryGlobalRequestMiddleware, sentryGlobalFunctionMiddleware } from './globalMiddleware';\n\n/**\n * A no-op stub of the browser tracing integration for the server. Router setup code is shared between client and server,\n * so this stub is needed to prevent build errors during SSR bundling.\n */\nexport function tanstackRouterBrowserTracingIntegration(\n _router: unknown,\n _options?: Record<string, unknown>,\n): Integration {\n return {\n name: 'BrowserTracing',\n setup() {},\n };\n}\n\n/**\n * A passthrough error boundary for the server that doesn't depend on any react. Error boundaries don't catch SSR errors\n * so they should simply be a passthrough.\n */\nexport const ErrorBoundary = (props: React.PropsWithChildren<unknown>): React.ReactNode => {\n if (!props.children) {\n return null;\n }\n\n if (typeof props.children === 'function') {\n return (props.children as () => React.ReactNode)();\n }\n\n return props.children;\n};\n\n/**\n * A passthrough error boundary wrapper for the server that doesn't depend on any react. Error boundaries don't catch\n * SSR errors so they should simply be a passthrough.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withErrorBoundary<P extends Record<string, any>>(\n WrappedComponent: React.ComponentType<P>,\n): React.FC<P> {\n return WrappedComponent as React.FC<P>;\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/server/index.ts"],"sourcesContent":["// import/export got a false positive, and affects most of our index barrel files\n// can be removed once following issue is fixed: https://github.com/import-js/eslint-plugin-import/issues/703\n/* eslint-disable import/export */\nimport type { Integration } from '@sentry/core';\n\nexport * from '@sentry/node';\n\nexport { init } from './sdk';\nexport { wrapFetchWithSentry } from './wrapFetchWithSentry';\nexport { wrapMiddlewaresWithSentry } from './middleware';\nexport { sentryGlobalRequestMiddleware, sentryGlobalFunctionMiddleware } from './globalMiddleware';\nexport { createSentryTunnelRoute } from './tunnelRoute';\n\n/**\n * A no-op stub of the browser tracing integration for the server. Router setup code is shared between client and server,\n * so this stub is needed to prevent build errors during SSR bundling.\n */\nexport function tanstackRouterBrowserTracingIntegration(\n _router: unknown,\n _options?: Record<string, unknown>,\n): Integration {\n return {\n name: 'BrowserTracing',\n setup() {},\n };\n}\n\n/**\n * A passthrough error boundary for the server that doesn't depend on any react. Error boundaries don't catch SSR errors\n * so they should simply be a passthrough.\n */\nexport const ErrorBoundary = (props: React.PropsWithChildren<unknown>): React.ReactNode => {\n if (!props.children) {\n return null;\n }\n\n if (typeof props.children === 'function') {\n return (props.children as () => React.ReactNode)();\n }\n\n return props.children;\n};\n\n/**\n * A passthrough error boundary wrapper for the server that doesn't depend on any react. Error boundaries don't catch\n * SSR errors so they should simply be a passthrough.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withErrorBoundary<P extends Record<string, any>>(\n WrappedComponent: React.ComponentType<P>,\n): React.FC<P> {\n return WrappedComponent as React.FC<P>;\n}\n"],"names":[],"mappings":";;;;;;;AAaA;AACA;AACA;AACA;AACO,SAAS,uCAAuC;AACvD,EAAE,OAAO;AACT,EAAE,QAAQ;AACV,EAAe;AACf,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,GAAG,CAAC,CAAC;AACd,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACO,MAAM,aAAA,GAAgB,CAAC,KAAK,KAAwD;AAC3F,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;AACvB,IAAI,OAAO,IAAI;AACf,EAAE;;AAEF,EAAE,IAAI,OAAO,KAAK,CAAC,QAAA,KAAa,UAAU,EAAE;AAC5C,IAAI,OAAO,CAAC,KAAK,CAAC,QAAA,IAAoC;AACtD,EAAE;;AAEF,EAAE,OAAO,KAAK,CAAC,QAAQ;AACvB;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB;AACjC,EAAE,gBAAgB;AAClB,EAAe;AACf,EAAE,OAAO,gBAAA;AACT;;;;"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { getClient, dsnToString, handleTunnelRequest } from '@sentry/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a TanStack Start server route configuration for tunneling Sentry envelopes.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { createFileRoute } from '@tanstack/react-router';
|
|
9
|
+
* import * as Sentry from '@sentry/tanstackstart-react';
|
|
10
|
+
*
|
|
11
|
+
* export const Route = createFileRoute('/monitoring')({
|
|
12
|
+
* server: Sentry.createSentryTunnelRoute({
|
|
13
|
+
* allowedDsns: ['https://public@o0.ingest.sentry.io/0'],
|
|
14
|
+
* }),
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function createSentryTunnelRoute(options) {
|
|
19
|
+
return {
|
|
20
|
+
handlers: {
|
|
21
|
+
POST: async ({ request }) => {
|
|
22
|
+
const allowedDsnsFromOptions = options.allowedDsns?.length ? options.allowedDsns : undefined;
|
|
23
|
+
|
|
24
|
+
const allowedDsns =
|
|
25
|
+
allowedDsnsFromOptions ??
|
|
26
|
+
(() => {
|
|
27
|
+
const client = getClient();
|
|
28
|
+
const dsn = client?.getDsn();
|
|
29
|
+
return dsn ? [dsnToString(dsn)] : undefined;
|
|
30
|
+
})();
|
|
31
|
+
|
|
32
|
+
if (!allowedDsns) {
|
|
33
|
+
return new Response(
|
|
34
|
+
'Tunnel route requires Sentry server SDK initialized with a DSN, or pass allowedDsns explicitly.',
|
|
35
|
+
{ status: 500 },
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return handleTunnelRequest({
|
|
40
|
+
request,
|
|
41
|
+
allowedDsns,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { createSentryTunnelRoute };
|
|
49
|
+
//# sourceMappingURL=tunnelRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnelRoute.js","sources":["../../../src/server/tunnelRoute.ts"],"sourcesContent":["import { dsnToString, getClient, handleTunnelRequest } from '@sentry/core';\n\nexport interface CreateSentryTunnelRouteOptions {\n allowedDsns?: string[];\n}\n\ntype SentryTunnelRouteHandlerContext = {\n request: Request;\n};\n\ntype SentryTunnelRoute = {\n handlers: {\n POST: (context: SentryTunnelRouteHandlerContext) => Promise<Response>;\n };\n};\n\n/**\n * Creates a TanStack Start server route configuration for tunneling Sentry envelopes.\n *\n * @example\n * ```ts\n * import { createFileRoute } from '@tanstack/react-router';\n * import * as Sentry from '@sentry/tanstackstart-react';\n *\n * export const Route = createFileRoute('/monitoring')({\n * server: Sentry.createSentryTunnelRoute({\n * allowedDsns: ['https://public@o0.ingest.sentry.io/0'],\n * }),\n * });\n * ```\n */\nexport function createSentryTunnelRoute(options: CreateSentryTunnelRouteOptions): SentryTunnelRoute {\n return {\n handlers: {\n POST: async ({ request }) => {\n const allowedDsnsFromOptions = options.allowedDsns?.length ? options.allowedDsns : undefined;\n\n const allowedDsns =\n allowedDsnsFromOptions ??\n (() => {\n const client = getClient();\n const dsn = client?.getDsn();\n return dsn ? [dsnToString(dsn)] : undefined;\n })();\n\n if (!allowedDsns) {\n return new Response(\n 'Tunnel route requires Sentry server SDK initialized with a DSN, or pass allowedDsns explicitly.',\n { status: 500 },\n );\n }\n\n return handleTunnelRequest({\n request,\n allowedDsns,\n });\n },\n },\n };\n}\n"],"names":[],"mappings":";;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,OAAO,EAAqD;AACpG,EAAE,OAAO;AACT,IAAI,QAAQ,EAAE;AACd,MAAM,IAAI,EAAE,OAAO,EAAE,OAAA,EAAS,KAAK;AACnC,QAAQ,MAAM,sBAAA,GAAyB,OAAO,CAAC,WAAW,EAAE,MAAA,GAAS,OAAO,CAAC,WAAA,GAAc,SAAS;;AAEpG,QAAQ,MAAM,WAAA;AACd,UAAU,sBAAA;AACV,UAAU,CAAC,MAAM;AACjB,YAAY,MAAM,MAAA,GAAS,SAAS,EAAE;AACtC,YAAY,MAAM,GAAA,GAAM,MAAM,EAAE,MAAM,EAAE;AACxC,YAAY,OAAO,GAAA,GAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA,GAAI,SAAS;AACvD,UAAU,CAAC,GAAG;;AAEd,QAAQ,IAAI,CAAC,WAAW,EAAE;AAC1B,UAAU,OAAO,IAAI,QAAQ;AAC7B,YAAY,iGAAiG;AAC7G,YAAY,EAAE,MAAM,EAAE,GAAA,EAAK;AAC3B,WAAW;AACX,QAAQ;;AAER,QAAQ,OAAO,mBAAmB,CAAC;AACnC,UAAU,OAAO;AACjB,UAAU,WAAW;AACrB,SAAS,CAAC;AACV,MAAM,CAAC;AACP,KAAK;AACL,GAAG;AACH;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { makeAutoInstrumentMiddlewarePlugin } from './autoInstrumentMiddleware.js';
|
|
2
2
|
import { makeAddSentryVitePlugin, makeEnableSourceMapsVitePlugin } from './sourceMaps.js';
|
|
3
|
+
import { makeTunnelRoutePlugin } from './tunnelRoute.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Build-time options for the Sentry TanStack Start SDK.
|
|
@@ -30,13 +31,19 @@ import { makeAddSentryVitePlugin, makeEnableSourceMapsVitePlugin } from './sourc
|
|
|
30
31
|
* @returns An array of Vite plugins
|
|
31
32
|
*/
|
|
32
33
|
function sentryTanstackStart(options = {}) {
|
|
33
|
-
|
|
34
|
+
const tunnelRoutePlugin = options.tunnelRoute ? makeTunnelRoutePlugin(options.tunnelRoute, options.debug) : undefined;
|
|
35
|
+
|
|
36
|
+
// only add build-time plugins in production builds
|
|
34
37
|
if (process.env.NODE_ENV === 'development') {
|
|
35
|
-
return [];
|
|
38
|
+
return tunnelRoutePlugin ? [tunnelRoutePlugin] : [];
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
const plugins = [...makeAddSentryVitePlugin(options)];
|
|
39
42
|
|
|
43
|
+
if (tunnelRoutePlugin) {
|
|
44
|
+
plugins.push(tunnelRoutePlugin);
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
// middleware auto-instrumentation
|
|
41
48
|
if (options.autoInstrumentMiddleware !== false) {
|
|
42
49
|
plugins.push(makeAutoInstrumentMiddlewarePlugin({ enabled: true, debug: options.debug }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentryTanstackStart.js","sources":["../../../src/vite/sentryTanstackStart.ts"],"sourcesContent":["import type { BuildTimeOptionsBase } from '@sentry/core';\nimport type { Plugin } from 'vite';\nimport { makeAutoInstrumentMiddlewarePlugin } from './autoInstrumentMiddleware';\nimport { makeAddSentryVitePlugin, makeEnableSourceMapsVitePlugin } from './sourceMaps';\n\n/**\n * Build-time options for the Sentry TanStack Start SDK.\n */\nexport interface SentryTanstackStartOptions extends BuildTimeOptionsBase {\n /**\n * If this flag is `true`, the Sentry plugins will automatically instrument TanStack Start middlewares.\n *\n * This wraps global middlewares (`requestMiddleware` and `functionMiddleware`) in `createStart()` with Sentry\n * instrumentation to capture performance data.\n *\n * Set to `false` to disable automatic middleware instrumentation if you prefer to wrap middlewares manually\n * using `wrapMiddlewaresWithSentry`.\n *\n * @default true\n */\n autoInstrumentMiddleware?: boolean;\n}\n\n/**\n * Vite plugins for the Sentry TanStack Start SDK.\n *\n * @example\n * ```typescript\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import { sentryTanstackStart } from '@sentry/tanstackstart-react/vite';\n * import { tanstackStart } from '@tanstack/react-start/plugin/vite';\n *\n * export default defineConfig({\n * plugins: [\n * tanstackStart(),\n * sentryTanstackStart({\n * org: 'your-org',\n * project: 'your-project',\n * }),\n * ],\n * });\n * ```\n *\n * @param options - Options to configure the Sentry Vite plugins\n * @returns An array of Vite plugins\n */\nexport function sentryTanstackStart(options: SentryTanstackStartOptions = {}): Plugin[] {\n // only add plugins in production builds\n if (process.env.NODE_ENV === 'development') {\n return [];\n }\n\n const plugins: Plugin[] = [...makeAddSentryVitePlugin(options)];\n\n // middleware auto-instrumentation\n if (options.autoInstrumentMiddleware !== false) {\n plugins.push(makeAutoInstrumentMiddlewarePlugin({ enabled: true, debug: options.debug }));\n }\n\n // source maps\n const sourceMapsDisabled = options.sourcemaps?.disable === true || options.sourcemaps?.disable === 'disable-upload';\n if (!sourceMapsDisabled) {\n plugins.push(...makeEnableSourceMapsVitePlugin(options));\n }\n\n return plugins;\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sentryTanstackStart.js","sources":["../../../src/vite/sentryTanstackStart.ts"],"sourcesContent":["import type { BuildTimeOptionsBase } from '@sentry/core';\nimport type { Plugin } from 'vite';\nimport { makeAutoInstrumentMiddlewarePlugin } from './autoInstrumentMiddleware';\nimport { makeAddSentryVitePlugin, makeEnableSourceMapsVitePlugin } from './sourceMaps';\nimport type { TunnelRouteOptions } from './tunnelRoute';\nimport { makeTunnelRoutePlugin } from './tunnelRoute';\n\n/**\n * Build-time options for the Sentry TanStack Start SDK.\n */\nexport interface SentryTanstackStartOptions extends BuildTimeOptionsBase {\n /**\n * If this flag is `true`, the Sentry plugins will automatically instrument TanStack Start middlewares.\n *\n * This wraps global middlewares (`requestMiddleware` and `functionMiddleware`) in `createStart()` with Sentry\n * instrumentation to capture performance data.\n *\n * Set to `false` to disable automatic middleware instrumentation if you prefer to wrap middlewares manually\n * using `wrapMiddlewaresWithSentry`.\n *\n * @default true\n */\n autoInstrumentMiddleware?: boolean;\n\n /**\n * Configures a framework-managed same-origin tunnel route for Sentry envelopes.\n *\n * This creates a TanStack Start server route backed by `createSentryTunnelRoute()` and applies the resulting path\n * as the default `tunnel` option on the client.\n *\n * You can pass:\n * - `true` to generate an opaque route path per dev session or production build.\n * - `'/custom-path'` to use a fixed static route path.\n * - `{ allowedDsns, path }` for full control. If `allowedDsns` is omitted or empty, the tunnel route derives the DSN\n * from the active server Sentry client at runtime.\n *\n * If you also pass `tunnel` to `Sentry.init()`, that explicit runtime option wins and a warning is emitted because\n * the managed tunnel route is being bypassed.\n */\n tunnelRoute?: TunnelRouteOptions;\n}\n\n/**\n * Vite plugins for the Sentry TanStack Start SDK.\n *\n * @example\n * ```typescript\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import { sentryTanstackStart } from '@sentry/tanstackstart-react/vite';\n * import { tanstackStart } from '@tanstack/react-start/plugin/vite';\n *\n * export default defineConfig({\n * plugins: [\n * tanstackStart(),\n * sentryTanstackStart({\n * org: 'your-org',\n * project: 'your-project',\n * }),\n * ],\n * });\n * ```\n *\n * @param options - Options to configure the Sentry Vite plugins\n * @returns An array of Vite plugins\n */\nexport function sentryTanstackStart(options: SentryTanstackStartOptions = {}): Plugin[] {\n const tunnelRoutePlugin = options.tunnelRoute ? makeTunnelRoutePlugin(options.tunnelRoute, options.debug) : undefined;\n\n // only add build-time plugins in production builds\n if (process.env.NODE_ENV === 'development') {\n return tunnelRoutePlugin ? [tunnelRoutePlugin] : [];\n }\n\n const plugins: Plugin[] = [...makeAddSentryVitePlugin(options)];\n\n if (tunnelRoutePlugin) {\n plugins.push(tunnelRoutePlugin);\n }\n\n // middleware auto-instrumentation\n if (options.autoInstrumentMiddleware !== false) {\n plugins.push(makeAutoInstrumentMiddlewarePlugin({ enabled: true, debug: options.debug }));\n }\n\n // source maps\n const sourceMapsDisabled = options.sourcemaps?.disable === true || options.sourcemaps?.disable === 'disable-upload';\n if (!sourceMapsDisabled) {\n plugins.push(...makeEnableSourceMapsVitePlugin(options));\n }\n\n return plugins;\n}\n"],"names":[],"mappings":";;;;AAOA;AACA;AACA;;AAiCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,OAAO,GAA+B,EAAE,EAAY;AACxF,EAAE,MAAM,iBAAA,GAAoB,OAAO,CAAC,WAAA,GAAc,qBAAqB,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAA,GAAI,SAAS;;AAEvH;AACA,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAA,KAAa,aAAa,EAAE;AAC9C,IAAI,OAAO,oBAAoB,CAAC,iBAAiB,CAAA,GAAI,EAAE;AACvD,EAAE;;AAEF,EAAE,MAAM,OAAO,GAAa,CAAC,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;;AAEjE,EAAE,IAAI,iBAAiB,EAAE;AACzB,IAAI,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC;AACnC,EAAE;;AAEF;AACA,EAAE,IAAI,OAAO,CAAC,wBAAA,KAA6B,KAAK,EAAE;AAClD,IAAI,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAA,EAAO,CAAC,CAAC;AAC7F,EAAE;;AAEF;AACA,EAAE,MAAM,kBAAA,GAAqB,OAAO,CAAC,UAAU,EAAE,OAAA,KAAY,IAAA,IAAQ,OAAO,CAAC,UAAU,EAAE,OAAA,KAAY,gBAAgB;AACrH,EAAE,IAAI,CAAC,kBAAkB,EAAE;AAC3B,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,8BAA8B,CAAC,OAAO,CAAC,CAAC;AAC5D,EAAE;;AAEF,EAAE,OAAO,OAAO;AAChB;;;;"}
|
|
@@ -61,7 +61,9 @@ function makeAddSentryVitePlugin(options) {
|
|
|
61
61
|
assets: sourcemaps?.assets,
|
|
62
62
|
disable: sourcemaps?.disable,
|
|
63
63
|
ignore: sourcemaps?.ignore,
|
|
64
|
-
|
|
64
|
+
// BuildTimeOptionsBase types can lag behind bundler plugin options in some local setups.
|
|
65
|
+
// Keep runtime support while staying resilient to type version skew.
|
|
66
|
+
rewriteSources: (sourcemaps )?.rewriteSources ,
|
|
65
67
|
filesToDeleteAfterUpload: filesToDeleteAfterUploadPromise,
|
|
66
68
|
},
|
|
67
69
|
telemetry: telemetry ?? true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sourceMaps.js","sources":["../../../src/vite/sourceMaps.ts"],"sourcesContent":["import type { BuildTimeOptionsBase } from '@sentry/core';\nimport { sentryVitePlugin } from '@sentry/vite-plugin';\nimport type { Plugin, UserConfig } from 'vite';\n\ntype FilesToDeleteAfterUpload = string | string[] | undefined;\n\n/**\n * A Sentry plugin for adding the @sentry/vite-plugin to automatically upload source maps to Sentry.\n */\nexport function makeAddSentryVitePlugin(options: BuildTimeOptionsBase): Plugin[] {\n const {\n authToken,\n bundleSizeOptimizations,\n debug,\n errorHandler,\n headers,\n org,\n project,\n release,\n sentryUrl,\n silent,\n sourcemaps,\n telemetry,\n } = options;\n\n // defer resolving the filesToDeleteAfterUpload until we got access to the Vite config\n let resolveFilesToDeleteAfterUpload: ((value: FilesToDeleteAfterUpload) => void) | undefined;\n const filesToDeleteAfterUploadPromise = new Promise<FilesToDeleteAfterUpload>(resolve => {\n resolveFilesToDeleteAfterUpload = resolve;\n });\n\n const configPlugin: Plugin = {\n name: 'sentry-tanstackstart-files-to-delete-after-upload-plugin',\n apply: 'build',\n enforce: 'post',\n config(config) {\n const userFilesToDelete = sourcemaps?.filesToDeleteAfterUpload;\n\n // Only auto-delete source maps if the user didn't configure sourcemaps at all\n if (typeof userFilesToDelete === 'undefined' && typeof config.build?.sourcemap === 'undefined') {\n if (debug) {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Automatically setting `sourcemaps.filesToDeleteAfterUpload: [\"./**/*.map\"]` to delete generated source maps after they were uploaded to Sentry.',\n );\n }\n resolveFilesToDeleteAfterUpload?.(['./**/*.map']);\n } else {\n resolveFilesToDeleteAfterUpload?.(userFilesToDelete);\n }\n },\n };\n\n const sentryPlugins = sentryVitePlugin({\n authToken: authToken ?? process.env.SENTRY_AUTH_TOKEN,\n bundleSizeOptimizations: bundleSizeOptimizations ?? undefined,\n debug: debug ?? false,\n errorHandler,\n headers,\n org: org ?? process.env.SENTRY_ORG,\n project: project ?? process.env.SENTRY_PROJECT,\n release,\n silent,\n sourcemaps: {\n assets: sourcemaps?.assets,\n disable: sourcemaps?.disable,\n ignore: sourcemaps?.ignore,\n rewriteSources: sourcemaps?.rewriteSources,\n filesToDeleteAfterUpload: filesToDeleteAfterUploadPromise,\n },\n telemetry: telemetry ?? true,\n url: sentryUrl,\n _metaOptions: {\n telemetry: {\n metaFramework: 'tanstackstart-react',\n },\n },\n });\n\n return [configPlugin, ...sentryPlugins];\n}\n\n/**\n * A Sentry plugin for TanStack Start React to enable \"hidden\" source maps if they are unset.\n */\nexport function makeEnableSourceMapsVitePlugin(options: BuildTimeOptionsBase): Plugin[] {\n return [\n {\n name: 'sentry-tanstackstart-react-source-maps',\n apply: 'build',\n enforce: 'post',\n config(viteConfig) {\n return {\n ...viteConfig,\n build: {\n ...viteConfig.build,\n sourcemap: getUpdatedSourceMapSettings(viteConfig, options),\n },\n };\n },\n },\n ];\n}\n\n/** There are 3 ways to set up source map generation (https://github.com/getsentry/sentry-javascript/issues/13993)\n *\n * 1. User explicitly disabled source maps\n * - keep this setting (emit a warning that errors won't be unminified in Sentry)\n * - We won't upload anything\n *\n * 2. Users enabled source map generation (true, 'hidden', 'inline').\n * - keep this setting (don't do anything - like deletion - besides uploading)\n *\n * 3. Users didn't set source maps generation\n * - we enable 'hidden' source maps generation\n * - configure `filesToDeleteAfterUpload` to delete all .map files (we emit a log about this)\n *\n * --> only exported for testing\n */\nexport function getUpdatedSourceMapSettings(\n viteConfig: UserConfig,\n sentryPluginOptions?: BuildTimeOptionsBase,\n): boolean | 'inline' | 'hidden' {\n viteConfig.build = viteConfig.build || {};\n\n const viteUserSourceMapSetting = viteConfig.build?.sourcemap;\n const settingKey = 'vite.build.sourcemap';\n const debug = sentryPluginOptions?.debug;\n\n // Respect user source map setting if it is explicitly set\n if (viteUserSourceMapSetting === false) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Source map generation is currently disabled in your TanStack Start configuration (\\`${settingKey}: false\\`). Sentry won't override this setting. Without source maps, code snippets on the Sentry Issues page will remain minified.`,\n );\n } else {\n // eslint-disable-next-line no-console\n console.warn('[Sentry] Source map generation is disabled in your TanStack Start configuration.');\n }\n\n return viteUserSourceMapSetting;\n } else if (viteUserSourceMapSetting && ['hidden', 'inline', true].includes(viteUserSourceMapSetting)) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] We discovered \\`${settingKey}\\` is set to \\`${viteUserSourceMapSetting.toString()}\\`. Sentry will keep this source map setting.`,\n );\n }\n\n return viteUserSourceMapSetting;\n }\n\n // If the user did not specify a source map setting, we enable 'hidden' by default\n if (debug) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Enabled source map generation in the build options with \\`${settingKey}: 'hidden'\\`. The source maps will be deleted after they were uploaded to Sentry.`,\n );\n }\n\n return 'hidden';\n}\n"],"names":[],"mappings":";;AAMA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,OAAO,EAAkC;AACjF,EAAE,MAAM;AACR,IAAI,SAAS;AACb,IAAI,uBAAuB;AAC3B,IAAI,KAAK;AACT,IAAI,YAAY;AAChB,IAAI,OAAO;AACX,IAAI,GAAG;AACP,IAAI,OAAO;AACX,IAAI,OAAO;AACX,IAAI,SAAS;AACb,IAAI,MAAM;AACV,IAAI,UAAU;AACd,IAAI,SAAS;AACb,GAAE,GAAI,OAAO;;AAEb;AACA,EAAE,IAAI,+BAA+B;AACrC,EAAE,MAAM,+BAAA,GAAkC,IAAI,OAAO,CAA2B,WAAW;AAC3F,IAAI,+BAAA,GAAkC,OAAO;AAC7C,EAAE,CAAC,CAAC;;AAEJ,EAAE,MAAM,YAAY,GAAW;AAC/B,IAAI,IAAI,EAAE,0DAA0D;AACpE,IAAI,KAAK,EAAE,OAAO;AAClB,IAAI,OAAO,EAAE,MAAM;AACnB,IAAI,MAAM,CAAC,MAAM,EAAE;AACnB,MAAM,MAAM,iBAAA,GAAoB,UAAU,EAAE,wBAAwB;;AAEpE;AACA,MAAM,IAAI,OAAO,iBAAA,KAAsB,WAAA,IAAe,OAAO,MAAM,CAAC,KAAK,EAAE,SAAA,KAAc,WAAW,EAAE;AACtG,QAAQ,IAAI,KAAK,EAAE;AACnB;AACA,UAAU,OAAO,CAAC,GAAG;AACrB,YAAY,0JAA0J;AACtK,WAAW;AACX,QAAQ;AACR,QAAQ,+BAA+B,GAAG,CAAC,YAAY,CAAC,CAAC;AACzD,MAAM,OAAO;AACb,QAAQ,+BAA+B,GAAG,iBAAiB,CAAC;AAC5D,MAAM;AACN,IAAI,CAAC;AACL,GAAG;;AAEH,EAAE,MAAM,aAAA,GAAgB,gBAAgB,CAAC;AACzC,IAAI,SAAS,EAAE,SAAA,IAAa,OAAO,CAAC,GAAG,CAAC,iBAAiB;AACzD,IAAI,uBAAuB,EAAE,uBAAA,IAA2B,SAAS;AACjE,IAAI,KAAK,EAAE,KAAA,IAAS,KAAK;AACzB,IAAI,YAAY;AAChB,IAAI,OAAO;AACX,IAAI,GAAG,EAAE,GAAA,IAAO,OAAO,CAAC,GAAG,CAAC,UAAU;AACtC,IAAI,OAAO,EAAE,OAAA,IAAW,OAAO,CAAC,GAAG,CAAC,cAAc;AAClD,IAAI,OAAO;AACX,IAAI,MAAM;AACV,IAAI,UAAU,EAAE;AAChB,MAAM,MAAM,EAAE,UAAU,EAAE,MAAM;AAChC,MAAM,OAAO,EAAE,UAAU,EAAE,OAAO;AAClC,MAAM,MAAM,EAAE,UAAU,EAAE,MAAM;AAChC,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"sourceMaps.js","sources":["../../../src/vite/sourceMaps.ts"],"sourcesContent":["import type { BuildTimeOptionsBase } from '@sentry/core';\nimport { sentryVitePlugin } from '@sentry/vite-plugin';\nimport type { Plugin, UserConfig } from 'vite';\n\ntype FilesToDeleteAfterUpload = string | string[] | undefined;\n\n/**\n * A Sentry plugin for adding the @sentry/vite-plugin to automatically upload source maps to Sentry.\n */\nexport function makeAddSentryVitePlugin(options: BuildTimeOptionsBase): Plugin[] {\n const {\n authToken,\n bundleSizeOptimizations,\n debug,\n errorHandler,\n headers,\n org,\n project,\n release,\n sentryUrl,\n silent,\n sourcemaps,\n telemetry,\n } = options;\n\n // defer resolving the filesToDeleteAfterUpload until we got access to the Vite config\n let resolveFilesToDeleteAfterUpload: ((value: FilesToDeleteAfterUpload) => void) | undefined;\n const filesToDeleteAfterUploadPromise = new Promise<FilesToDeleteAfterUpload>(resolve => {\n resolveFilesToDeleteAfterUpload = resolve;\n });\n\n const configPlugin: Plugin = {\n name: 'sentry-tanstackstart-files-to-delete-after-upload-plugin',\n apply: 'build',\n enforce: 'post',\n config(config) {\n const userFilesToDelete = sourcemaps?.filesToDeleteAfterUpload;\n\n // Only auto-delete source maps if the user didn't configure sourcemaps at all\n if (typeof userFilesToDelete === 'undefined' && typeof config.build?.sourcemap === 'undefined') {\n if (debug) {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Automatically setting `sourcemaps.filesToDeleteAfterUpload: [\"./**/*.map\"]` to delete generated source maps after they were uploaded to Sentry.',\n );\n }\n resolveFilesToDeleteAfterUpload?.(['./**/*.map']);\n } else {\n resolveFilesToDeleteAfterUpload?.(userFilesToDelete);\n }\n },\n };\n\n const sentryPlugins = sentryVitePlugin({\n authToken: authToken ?? process.env.SENTRY_AUTH_TOKEN,\n bundleSizeOptimizations: bundleSizeOptimizations ?? undefined,\n debug: debug ?? false,\n errorHandler,\n headers,\n org: org ?? process.env.SENTRY_ORG,\n project: project ?? process.env.SENTRY_PROJECT,\n release,\n silent,\n sourcemaps: {\n assets: sourcemaps?.assets,\n disable: sourcemaps?.disable,\n ignore: sourcemaps?.ignore,\n // BuildTimeOptionsBase types can lag behind bundler plugin options in some local setups.\n // Keep runtime support while staying resilient to type version skew.\n rewriteSources: (sourcemaps as unknown as { rewriteSources?: unknown } | undefined)?.rewriteSources as never,\n filesToDeleteAfterUpload: filesToDeleteAfterUploadPromise,\n },\n telemetry: telemetry ?? true,\n url: sentryUrl,\n _metaOptions: {\n telemetry: {\n metaFramework: 'tanstackstart-react',\n },\n },\n });\n\n return [configPlugin, ...sentryPlugins];\n}\n\n/**\n * A Sentry plugin for TanStack Start React to enable \"hidden\" source maps if they are unset.\n */\nexport function makeEnableSourceMapsVitePlugin(options: BuildTimeOptionsBase): Plugin[] {\n return [\n {\n name: 'sentry-tanstackstart-react-source-maps',\n apply: 'build',\n enforce: 'post',\n config(viteConfig) {\n return {\n ...viteConfig,\n build: {\n ...viteConfig.build,\n sourcemap: getUpdatedSourceMapSettings(viteConfig, options),\n },\n };\n },\n },\n ];\n}\n\n/** There are 3 ways to set up source map generation (https://github.com/getsentry/sentry-javascript/issues/13993)\n *\n * 1. User explicitly disabled source maps\n * - keep this setting (emit a warning that errors won't be unminified in Sentry)\n * - We won't upload anything\n *\n * 2. Users enabled source map generation (true, 'hidden', 'inline').\n * - keep this setting (don't do anything - like deletion - besides uploading)\n *\n * 3. Users didn't set source maps generation\n * - we enable 'hidden' source maps generation\n * - configure `filesToDeleteAfterUpload` to delete all .map files (we emit a log about this)\n *\n * --> only exported for testing\n */\nexport function getUpdatedSourceMapSettings(\n viteConfig: UserConfig,\n sentryPluginOptions?: BuildTimeOptionsBase,\n): boolean | 'inline' | 'hidden' {\n viteConfig.build = viteConfig.build || {};\n\n const viteUserSourceMapSetting = viteConfig.build?.sourcemap;\n const settingKey = 'vite.build.sourcemap';\n const debug = sentryPluginOptions?.debug;\n\n // Respect user source map setting if it is explicitly set\n if (viteUserSourceMapSetting === false) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Source map generation is currently disabled in your TanStack Start configuration (\\`${settingKey}: false\\`). Sentry won't override this setting. Without source maps, code snippets on the Sentry Issues page will remain minified.`,\n );\n } else {\n // eslint-disable-next-line no-console\n console.warn('[Sentry] Source map generation is disabled in your TanStack Start configuration.');\n }\n\n return viteUserSourceMapSetting;\n } else if (viteUserSourceMapSetting && ['hidden', 'inline', true].includes(viteUserSourceMapSetting)) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] We discovered \\`${settingKey}\\` is set to \\`${viteUserSourceMapSetting.toString()}\\`. Sentry will keep this source map setting.`,\n );\n }\n\n return viteUserSourceMapSetting;\n }\n\n // If the user did not specify a source map setting, we enable 'hidden' by default\n if (debug) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Enabled source map generation in the build options with \\`${settingKey}: 'hidden'\\`. The source maps will be deleted after they were uploaded to Sentry.`,\n );\n }\n\n return 'hidden';\n}\n"],"names":[],"mappings":";;AAMA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,OAAO,EAAkC;AACjF,EAAE,MAAM;AACR,IAAI,SAAS;AACb,IAAI,uBAAuB;AAC3B,IAAI,KAAK;AACT,IAAI,YAAY;AAChB,IAAI,OAAO;AACX,IAAI,GAAG;AACP,IAAI,OAAO;AACX,IAAI,OAAO;AACX,IAAI,SAAS;AACb,IAAI,MAAM;AACV,IAAI,UAAU;AACd,IAAI,SAAS;AACb,GAAE,GAAI,OAAO;;AAEb;AACA,EAAE,IAAI,+BAA+B;AACrC,EAAE,MAAM,+BAAA,GAAkC,IAAI,OAAO,CAA2B,WAAW;AAC3F,IAAI,+BAAA,GAAkC,OAAO;AAC7C,EAAE,CAAC,CAAC;;AAEJ,EAAE,MAAM,YAAY,GAAW;AAC/B,IAAI,IAAI,EAAE,0DAA0D;AACpE,IAAI,KAAK,EAAE,OAAO;AAClB,IAAI,OAAO,EAAE,MAAM;AACnB,IAAI,MAAM,CAAC,MAAM,EAAE;AACnB,MAAM,MAAM,iBAAA,GAAoB,UAAU,EAAE,wBAAwB;;AAEpE;AACA,MAAM,IAAI,OAAO,iBAAA,KAAsB,WAAA,IAAe,OAAO,MAAM,CAAC,KAAK,EAAE,SAAA,KAAc,WAAW,EAAE;AACtG,QAAQ,IAAI,KAAK,EAAE;AACnB;AACA,UAAU,OAAO,CAAC,GAAG;AACrB,YA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AAE,wBAAwB,CAAC,QAAQ,EAAE,CAAC,6CAA6C,CAAC;AAClJ,OAAO;AACP,IAAI;;AAEJ,IAAI,OAAO,wBAAwB;AACnC,EAAE;;AAEF;AACA,EAAE,IAAI,KAAK,EAAE;AACb;AACA,IAAI,OAAO,CAAC,GAAG;AACf,MAAM,CAAC,mEAAmE,EAAE,UAAU,CAAC,iFAAiF,CAAC;AACzK,KAAK;AACL,EAAE;;AAEF,EAAE,OAAO,QAAQ;AACjB;;;;"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
const MANAGED_TUNNEL_ROUTE_IMPORT = 'SentryManagedTunnelRouteImport';
|
|
2
|
+
const MANAGED_TUNNEL_ROUTE_NAME = 'SentryManagedTunnelRoute';
|
|
3
|
+
const MANAGED_TUNNEL_ROUTE_PATH_ENV_KEY = '__SENTRY_INTERNAL_TANSTACKSTART_TUNNEL_ROUTE__';
|
|
4
|
+
|
|
5
|
+
const VIRTUAL_TUNNEL_ROUTE_ID = 'virtual:sentry-tanstackstart-react/tunnel-route';
|
|
6
|
+
const RESOLVED_VIRTUAL_TUNNEL_ROUTE_ID = `\0${VIRTUAL_TUNNEL_ROUTE_ID}`;
|
|
7
|
+
|
|
8
|
+
function generateRandomTunnelRoute() {
|
|
9
|
+
const randomPath = Array.from({ length: 8 }, () => Math.floor(Math.random() * 36).toString(36)).join('');
|
|
10
|
+
|
|
11
|
+
return `/${randomPath}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function resolveTunnelRoute(tunnel) {
|
|
15
|
+
if (typeof tunnel === 'string') {
|
|
16
|
+
return tunnel;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (process.env[MANAGED_TUNNEL_ROUTE_PATH_ENV_KEY]) {
|
|
20
|
+
return process.env[MANAGED_TUNNEL_ROUTE_PATH_ENV_KEY];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const resolvedTunnelRoute = generateRandomTunnelRoute();
|
|
24
|
+
process.env[MANAGED_TUNNEL_ROUTE_PATH_ENV_KEY] = resolvedTunnelRoute;
|
|
25
|
+
return resolvedTunnelRoute;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function validateStaticPath(path) {
|
|
29
|
+
if (!path.startsWith('/') || path.includes('?') || path.includes('#')) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
'[@sentry/tanstackstart-react] `tunnelRoute` static paths must start with `/` and must not contain query or hash segments.',
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function normalizeTunnelRouteOptions(options) {
|
|
37
|
+
if (options === true) {
|
|
38
|
+
return { resolvedPath: resolveTunnelRoute(true), allowedDsns: undefined };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (typeof options === 'string') {
|
|
42
|
+
validateStaticPath(options);
|
|
43
|
+
return {
|
|
44
|
+
resolvedPath: resolveTunnelRoute(options),
|
|
45
|
+
allowedDsns: undefined,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const allowedDsns = options.allowedDsns && options.allowedDsns.length > 0 ? options.allowedDsns : undefined;
|
|
50
|
+
const path = options.path;
|
|
51
|
+
|
|
52
|
+
if (path) {
|
|
53
|
+
validateStaticPath(path);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return { resolvedPath: resolveTunnelRoute(path || true), allowedDsns };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// `routeTree.gen.ts` quote style follows `tsr.config.json#quoteStyle` (`single` | `double`),
|
|
60
|
+
// so we check both forms for each route-identifying key.
|
|
61
|
+
const ROUTE_CONFLICT_KEYS = ['fullPath', 'path', 'id'] ;
|
|
62
|
+
|
|
63
|
+
function hasRouteConflict(source, resolvedTunnelRoute) {
|
|
64
|
+
const literals = [`'${resolvedTunnelRoute}'`, `"${resolvedTunnelRoute}"`];
|
|
65
|
+
return ROUTE_CONFLICT_KEYS.some(key => literals.some(literal => source.includes(`${key}: ${literal}`)));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function injectAfterLastImport(source, statement) {
|
|
69
|
+
const importMatches = [...source.matchAll(/^import .+$/gm)];
|
|
70
|
+
const lastImport = importMatches.at(-1);
|
|
71
|
+
|
|
72
|
+
if (lastImport?.index === undefined) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
'[@sentry/tanstackstart-react] Failed to inject the managed tunnel route because `routeTree.gen.ts` imports could not be located.',
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const insertIndex = lastImport.index + lastImport[0].length;
|
|
79
|
+
return `${source.slice(0, insertIndex)}\n${statement}${source.slice(insertIndex)}`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function injectManagedTunnelRoute(source, resolvedTunnelRoute) {
|
|
83
|
+
if (source.includes(VIRTUAL_TUNNEL_ROUTE_ID)) {
|
|
84
|
+
return source;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (hasRouteConflict(source, resolvedTunnelRoute)) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`[@sentry/tanstackstart-react] Cannot register managed tunnel route "${resolvedTunnelRoute}" because an existing TanStack Start route already uses that path.`,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const serializedTunnelRoute = JSON.stringify(resolvedTunnelRoute);
|
|
94
|
+
|
|
95
|
+
let transformedSource = injectAfterLastImport(
|
|
96
|
+
source,
|
|
97
|
+
`import { Route as ${MANAGED_TUNNEL_ROUTE_IMPORT} } from '${VIRTUAL_TUNNEL_ROUTE_ID}'`,
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const rootRouteChildrenMatch = transformedSource.match(
|
|
101
|
+
/const rootRouteChildren(?:\s*:\s*RootRouteChildren)?\s*=\s*\{/,
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
if (rootRouteChildrenMatch?.index === undefined) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
'[@sentry/tanstackstart-react] Failed to inject the managed tunnel route because the generated TanStack route tree did not contain `rootRouteChildren`.',
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const injectedRootRouteChildrenDeclaration = `const ${MANAGED_TUNNEL_ROUTE_NAME} = ${MANAGED_TUNNEL_ROUTE_IMPORT}.update({
|
|
111
|
+
id: ${serializedTunnelRoute},
|
|
112
|
+
path: ${serializedTunnelRoute},
|
|
113
|
+
getParentRoute: () => rootRouteImport,
|
|
114
|
+
} as any)
|
|
115
|
+
|
|
116
|
+
${rootRouteChildrenMatch[0]}
|
|
117
|
+
${MANAGED_TUNNEL_ROUTE_NAME}: ${MANAGED_TUNNEL_ROUTE_NAME},
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
transformedSource = `${transformedSource.slice(0, rootRouteChildrenMatch.index)}${injectedRootRouteChildrenDeclaration}${transformedSource.slice(rootRouteChildrenMatch.index + rootRouteChildrenMatch[0].length)}`;
|
|
121
|
+
|
|
122
|
+
return transformedSource;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function makeTunnelRoutePlugin(options, debug) {
|
|
126
|
+
const normalized = normalizeTunnelRouteOptions(options);
|
|
127
|
+
const resolvedTunnelRoute = normalized.resolvedPath;
|
|
128
|
+
const serializedTunnelRoute = JSON.stringify(resolvedTunnelRoute);
|
|
129
|
+
const serializedAllowedDsns = normalized.allowedDsns ? JSON.stringify(normalized.allowedDsns) : undefined;
|
|
130
|
+
|
|
131
|
+
if (debug) {
|
|
132
|
+
// eslint-disable-next-line no-console
|
|
133
|
+
console.log(`[@sentry/tanstackstart-react] Registered tunnel route: ${resolvedTunnelRoute}`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
name: 'sentry-tanstackstart-tunnel-route',
|
|
138
|
+
enforce: 'pre',
|
|
139
|
+
config() {
|
|
140
|
+
return {
|
|
141
|
+
define: {
|
|
142
|
+
__SENTRY_TANSTACKSTART_TUNNEL_ROUTE__: serializedTunnelRoute,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
resolveId(source) {
|
|
147
|
+
return source === VIRTUAL_TUNNEL_ROUTE_ID ? RESOLVED_VIRTUAL_TUNNEL_ROUTE_ID : null;
|
|
148
|
+
},
|
|
149
|
+
load(id) {
|
|
150
|
+
if (id !== RESOLVED_VIRTUAL_TUNNEL_ROUTE_ID) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return `import { createFileRoute } from '@tanstack/react-router';
|
|
155
|
+
|
|
156
|
+
export const Route = createFileRoute(${serializedTunnelRoute})({
|
|
157
|
+
server: {
|
|
158
|
+
handlers: {
|
|
159
|
+
async POST({ request }) {
|
|
160
|
+
const Sentry = await import('@sentry/tanstackstart-react');
|
|
161
|
+
return Sentry.createSentryTunnelRoute(${serializedAllowedDsns ? `{ allowedDsns: ${serializedAllowedDsns} }` : `{}`}).handlers.POST({ request });
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
`;
|
|
167
|
+
},
|
|
168
|
+
transform(source, id) {
|
|
169
|
+
if (!id.endsWith('/routeTree.gen.ts') && !id.endsWith('\\routeTree.gen.ts')) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return injectManagedTunnelRoute(source, resolvedTunnelRoute);
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export { injectManagedTunnelRoute, makeTunnelRoutePlugin, resolveTunnelRoute };
|
|
179
|
+
//# sourceMappingURL=tunnelRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnelRoute.js","sources":["../../../src/vite/tunnelRoute.ts"],"sourcesContent":["import type { Plugin } from 'vite';\n\nexport type TunnelRouteOptions =\n | true\n | string\n | {\n /**\n * A list of DSNs that are allowed to use the managed tunnel route.\n *\n * If omitted or empty, the tunnel route will derive the allowed DSN from the active server Sentry SDK at runtime.\n */\n allowedDsns?: string[];\n\n /**\n * Controls the public route path used by the managed tunnel route.\n *\n * If omitted, an opaque path is generated once per dev session or production build.\n */\n path?: string;\n };\n\nconst MANAGED_TUNNEL_ROUTE_IMPORT = 'SentryManagedTunnelRouteImport';\nconst MANAGED_TUNNEL_ROUTE_NAME = 'SentryManagedTunnelRoute';\nconst MANAGED_TUNNEL_ROUTE_PATH_ENV_KEY = '__SENTRY_INTERNAL_TANSTACKSTART_TUNNEL_ROUTE__';\n\nconst VIRTUAL_TUNNEL_ROUTE_ID = 'virtual:sentry-tanstackstart-react/tunnel-route';\nconst RESOLVED_VIRTUAL_TUNNEL_ROUTE_ID = `\\0${VIRTUAL_TUNNEL_ROUTE_ID}`;\n\nfunction generateRandomTunnelRoute(): string {\n const randomPath = Array.from({ length: 8 }, () => Math.floor(Math.random() * 36).toString(36)).join('');\n\n return `/${randomPath}`;\n}\n\nexport function resolveTunnelRoute(tunnel: true | string): string {\n if (typeof tunnel === 'string') {\n return tunnel;\n }\n\n if (process.env[MANAGED_TUNNEL_ROUTE_PATH_ENV_KEY]) {\n return process.env[MANAGED_TUNNEL_ROUTE_PATH_ENV_KEY];\n }\n\n const resolvedTunnelRoute = generateRandomTunnelRoute();\n process.env[MANAGED_TUNNEL_ROUTE_PATH_ENV_KEY] = resolvedTunnelRoute;\n return resolvedTunnelRoute;\n}\n\ntype NormalizedTunnelRouteOptions = {\n resolvedPath: string;\n allowedDsns: string[] | undefined;\n};\n\nfunction validateStaticPath(path: string): void {\n if (!path.startsWith('/') || path.includes('?') || path.includes('#')) {\n throw new Error(\n '[@sentry/tanstackstart-react] `tunnelRoute` static paths must start with `/` and must not contain query or hash segments.',\n );\n }\n}\n\nfunction normalizeTunnelRouteOptions(options: TunnelRouteOptions): NormalizedTunnelRouteOptions {\n if (options === true) {\n return { resolvedPath: resolveTunnelRoute(true), allowedDsns: undefined };\n }\n\n if (typeof options === 'string') {\n validateStaticPath(options);\n return {\n resolvedPath: resolveTunnelRoute(options),\n allowedDsns: undefined,\n };\n }\n\n const allowedDsns = options.allowedDsns && options.allowedDsns.length > 0 ? options.allowedDsns : undefined;\n const path = options.path;\n\n if (path) {\n validateStaticPath(path);\n }\n\n return { resolvedPath: resolveTunnelRoute(path || true), allowedDsns };\n}\n\n// `routeTree.gen.ts` quote style follows `tsr.config.json#quoteStyle` (`single` | `double`),\n// so we check both forms for each route-identifying key.\nconst ROUTE_CONFLICT_KEYS = ['fullPath', 'path', 'id'] as const;\n\nfunction hasRouteConflict(source: string, resolvedTunnelRoute: string): boolean {\n const literals = [`'${resolvedTunnelRoute}'`, `\"${resolvedTunnelRoute}\"`];\n return ROUTE_CONFLICT_KEYS.some(key => literals.some(literal => source.includes(`${key}: ${literal}`)));\n}\n\nfunction injectAfterLastImport(source: string, statement: string): string {\n const importMatches = [...source.matchAll(/^import .+$/gm)];\n const lastImport = importMatches.at(-1);\n\n if (lastImport?.index === undefined) {\n throw new Error(\n '[@sentry/tanstackstart-react] Failed to inject the managed tunnel route because `routeTree.gen.ts` imports could not be located.',\n );\n }\n\n const insertIndex = lastImport.index + lastImport[0].length;\n return `${source.slice(0, insertIndex)}\\n${statement}${source.slice(insertIndex)}`;\n}\n\nexport function injectManagedTunnelRoute(source: string, resolvedTunnelRoute: string): string {\n if (source.includes(VIRTUAL_TUNNEL_ROUTE_ID)) {\n return source;\n }\n\n if (hasRouteConflict(source, resolvedTunnelRoute)) {\n throw new Error(\n `[@sentry/tanstackstart-react] Cannot register managed tunnel route \"${resolvedTunnelRoute}\" because an existing TanStack Start route already uses that path.`,\n );\n }\n\n const serializedTunnelRoute = JSON.stringify(resolvedTunnelRoute);\n\n let transformedSource = injectAfterLastImport(\n source,\n `import { Route as ${MANAGED_TUNNEL_ROUTE_IMPORT} } from '${VIRTUAL_TUNNEL_ROUTE_ID}'`,\n );\n\n const rootRouteChildrenMatch = transformedSource.match(\n /const rootRouteChildren(?:\\s*:\\s*RootRouteChildren)?\\s*=\\s*\\{/,\n );\n\n if (rootRouteChildrenMatch?.index === undefined) {\n throw new Error(\n '[@sentry/tanstackstart-react] Failed to inject the managed tunnel route because the generated TanStack route tree did not contain `rootRouteChildren`.',\n );\n }\n\n const injectedRootRouteChildrenDeclaration = `const ${MANAGED_TUNNEL_ROUTE_NAME} = ${MANAGED_TUNNEL_ROUTE_IMPORT}.update({\n id: ${serializedTunnelRoute},\n path: ${serializedTunnelRoute},\n getParentRoute: () => rootRouteImport,\n} as any)\n\n${rootRouteChildrenMatch[0]}\n ${MANAGED_TUNNEL_ROUTE_NAME}: ${MANAGED_TUNNEL_ROUTE_NAME},\n`;\n\n transformedSource = `${transformedSource.slice(0, rootRouteChildrenMatch.index)}${injectedRootRouteChildrenDeclaration}${transformedSource.slice(rootRouteChildrenMatch.index + rootRouteChildrenMatch[0].length)}`;\n\n return transformedSource;\n}\n\nexport function makeTunnelRoutePlugin(options: TunnelRouteOptions, debug?: boolean): Plugin {\n const normalized = normalizeTunnelRouteOptions(options);\n const resolvedTunnelRoute = normalized.resolvedPath;\n const serializedTunnelRoute = JSON.stringify(resolvedTunnelRoute);\n const serializedAllowedDsns = normalized.allowedDsns ? JSON.stringify(normalized.allowedDsns) : undefined;\n\n if (debug) {\n // eslint-disable-next-line no-console\n console.log(`[@sentry/tanstackstart-react] Registered tunnel route: ${resolvedTunnelRoute}`);\n }\n\n return {\n name: 'sentry-tanstackstart-tunnel-route',\n enforce: 'pre',\n config() {\n return {\n define: {\n __SENTRY_TANSTACKSTART_TUNNEL_ROUTE__: serializedTunnelRoute,\n },\n };\n },\n resolveId(source) {\n return source === VIRTUAL_TUNNEL_ROUTE_ID ? RESOLVED_VIRTUAL_TUNNEL_ROUTE_ID : null;\n },\n load(id) {\n if (id !== RESOLVED_VIRTUAL_TUNNEL_ROUTE_ID) {\n return null;\n }\n\n return `import { createFileRoute } from '@tanstack/react-router';\n\nexport const Route = createFileRoute(${serializedTunnelRoute})({\n server: {\n handlers: {\n async POST({ request }) {\n const Sentry = await import('@sentry/tanstackstart-react');\n return Sentry.createSentryTunnelRoute(${serializedAllowedDsns ? `{ allowedDsns: ${serializedAllowedDsns} }` : `{}`}).handlers.POST({ request });\n },\n },\n },\n});\n`;\n },\n transform(source, id) {\n if (!id.endsWith('/routeTree.gen.ts') && !id.endsWith('\\\\routeTree.gen.ts')) {\n return null;\n }\n\n return injectManagedTunnelRoute(source, resolvedTunnelRoute);\n },\n };\n}\n"],"names":[],"mappings":"AAqBA,MAAM,2BAAA,GAA8B,gCAAgC;AACpE,MAAM,yBAAA,GAA4B,0BAA0B;AAC5D,MAAM,iCAAA,GAAoC,gDAAgD;;AAE1F,MAAM,uBAAA,GAA0B,iDAAiD;AACjF,MAAM,mCAAmC,CAAC,EAAE,EAAE,uBAAuB,CAAC,CAAA;;AAEA,SAAA,yBAAA,GAAA;AACA,EAAA,MAAA,UAAA,GAAA,KAAA,CAAA,IAAA,CAAA,EAAA,MAAA,EAAA,CAAA,EAAA,EAAA,MAAA,IAAA,CAAA,KAAA,CAAA,IAAA,CAAA,MAAA,EAAA,GAAA,EAAA,CAAA,CAAA,QAAA,CAAA,EAAA,CAAA,CAAA,CAAA,IAAA,CAAA,EAAA,CAAA;;AAEA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,CAAA,CAAA;AACA;;AAEA,SAAA,kBAAA,CAAA,MAAA,EAAA;AACA,EAAA,IAAA,OAAA,MAAA,KAAA,QAAA,EAAA;AACA,IAAA,OAAA,MAAA;AACA,EAAA;;AAEA,EAAA,IAAA,OAAA,CAAA,GAAA,CAAA,iCAAA,CAAA,EAAA;AACA,IAAA,OAAA,OAAA,CAAA,GAAA,CAAA,iCAAA,CAAA;AACA,EAAA;;AAEA,EAAA,MAAA,mBAAA,GAAA,yBAAA,EAAA;AACA,EAAA,OAAA,CAAA,GAAA,CAAA,iCAAA,CAAA,GAAA,mBAAA;AACA,EAAA,OAAA,mBAAA;AACA;;AAOA,SAAA,kBAAA,CAAA,IA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EAAA,mBAAA,CAAA,CAAA,CAAA;AACA,EAAA;;AAEA,EAAA,OAAA;AACA,IAAA,IAAA,EAAA,mCAAA;AACA,IAAA,OAAA,EAAA,KAAA;AACA,IAAA,MAAA,GAAA;AACA,MAAA,OAAA;AACA,QAAA,MAAA,EAAA;AACA,UAAA,qCAAA,EAAA,qBAAA;AACA,SAAA;AACA,OAAA;AACA,IAAA,CAAA;AACA,IAAA,SAAA,CAAA,MAAA,EAAA;AACA,MAAA,OAAA,MAAA,KAAA,uBAAA,GAAA,gCAAA,GAAA,IAAA;AACA,IAAA,CAAA;AACA,IAAA,IAAA,CAAA,EAAA,EAAA;AACA,MAAA,IAAA,EAAA,KAAA,gCAAA,EAAA;AACA,QAAA,OAAA,IAAA;AACA,MAAA;;AAEA,MAAA,OAAA,CAAA;;AAEA,qCAAA,EAAA,qBAAA,CAAA;AACA;AACA;AACA;AACA;AACA,8CAAA,EAAA,qBAAA,GAAA,CAAA,eAAA,EAAA,qBAAA,CAAA,EAAA,CAAA,GAAA,CAAA,EAAA,CAAA,CAAA;AACA;AACA;AACA;AACA;AACA,CAAA;AACA,IAAA,CAAA;AACA,IAAA,SAAA,CAAA,MAAA,EAAA,EAAA,EAAA;AACA,MAAA,IAAA,CAAA,EAAA,CAAA,QAAA,CAAA,mBAAA,CAAA,IAAA,CAAA,EAAA,CAAA,QAAA,CAAA,oBAAA,CAAA,EAAA;AACA,QAAA,OAAA,IAAA;AACA,MAAA;;AAEA,MAAA,OAAA,wBAAA,CAAA,MAAA,EAAA,mBAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TanStackMiddlewareBase } from '../common/types';
|
|
2
|
+
import type { CreateSentryTunnelRouteOptions } from '../server/tunnelRoute';
|
|
2
3
|
export * from '@sentry/react';
|
|
3
4
|
export { init } from './sdk';
|
|
4
5
|
/**
|
|
@@ -16,4 +17,13 @@ export declare const sentryGlobalRequestMiddleware: TanStackMiddlewareBase;
|
|
|
16
17
|
* The actual implementation is server-only, but this stub is needed to prevent rendering errors.
|
|
17
18
|
*/
|
|
18
19
|
export declare const sentryGlobalFunctionMiddleware: TanStackMiddlewareBase;
|
|
20
|
+
/**
|
|
21
|
+
* No-op stub for client-side builds.
|
|
22
|
+
* The actual implementation is server-only, but this stub is needed to prevent rendering errors.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createSentryTunnelRoute(_options: CreateSentryTunnelRouteOptions): {
|
|
25
|
+
handlers: {
|
|
26
|
+
POST: () => Promise<Response>;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
19
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAE5E,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7B;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,sBAAsB,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAE/G;AAED;;;GAGG;AACH,eAAO,MAAM,6BAA6B,EAAE,sBAA6D,CAAC;AAE1G;;;GAGG;AACH,eAAO,MAAM,8BAA8B,EAAE,sBAA6D,CAAC;AAE3G;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,8BAA8B,GAAG;IACjF,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;KAC/B,CAAC;CACH,CAMA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/client/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAAE,cAAc,IAAI,mBAAmB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/client/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAAE,cAAc,IAAI,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAI3E;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,GAAG,SAAS,CAUrE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BrowserOptions as ReactBrowserOptions } from '@sentry/react';
|
|
2
|
+
/**
|
|
3
|
+
* Applies the managed tunnel route from `sentryTanstackStart({ tunnelRoute: ... })` unless the user already
|
|
4
|
+
* configured an explicit runtime `tunnel` option in `Sentry.init()`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function applyTunnelRouteOption(options: ReactBrowserOptions): void;
|
|
7
|
+
//# sourceMappingURL=tunnelRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnelRoute.d.ts","sourceRoot":"","sources":["../../../src/client/tunnelRoute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,IAAI,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAM3E;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAuBzE"}
|
|
@@ -27,4 +27,5 @@ export declare const wrapMiddlewaresWithSentry: typeof serverSdk.wrapMiddlewares
|
|
|
27
27
|
export declare const tanstackRouterBrowserTracingIntegration: typeof clientSdk.tanstackRouterBrowserTracingIntegration;
|
|
28
28
|
export declare const sentryGlobalRequestMiddleware: typeof serverSdk.sentryGlobalRequestMiddleware;
|
|
29
29
|
export declare const sentryGlobalFunctionMiddleware: typeof serverSdk.sentryGlobalFunctionMiddleware;
|
|
30
|
+
export declare const createSentryTunnelRoute: typeof serverSdk.createSentryTunnelRoute;
|
|
30
31
|
//# sourceMappingURL=index.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.types.d.ts","sourceRoot":"","sources":["../../src/index.types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,KAAK,SAAS,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,KAAK,SAAS,MAAM,UAAU,CAAC;AAE3C,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAEzB,4CAA4C;AAC5C,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC,cAAc,GAAG,SAAS,CAAC,WAAW,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtH,MAAM,CAAC,OAAO,CAAC,MAAM,uBAAuB,EAAE,OAAO,SAAS,CAAC,uBAAuB,CAAC;AACvF,MAAM,CAAC,OAAO,CAAC,MAAM,uBAAuB,EAAE,OAAO,SAAS,CAAC,uBAAuB,CAAC;AACvF,MAAM,CAAC,OAAO,CAAC,MAAM,wBAAwB,EAAE,OAAO,SAAS,CAAC,wBAAwB,CAAC;AACzF,MAAM,CAAC,OAAO,CAAC,MAAM,gBAAgB,EAAE,OAAO,SAAS,CAAC,gBAAgB,CAAC;AAEzE,MAAM,CAAC,OAAO,CAAC,MAAM,sBAAs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5
|
export { wrapMiddlewaresWithSentry } from './middleware';
|
|
6
6
|
export { sentryGlobalRequestMiddleware, sentryGlobalFunctionMiddleware } from './globalMiddleware';
|
|
7
|
+
export { createSentryTunnelRoute } from './tunnelRoute';
|
|
7
8
|
/**
|
|
8
9
|
* A no-op stub of the browser tracing integration for the server. Router setup code is shared between client and server,
|
|
9
10
|
* so this stub is needed to prevent build errors during SSR bundling.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD;;;GAGG;AACH,wBAAgB,uCAAuC,CACrD,OAAO,EAAE,OAAO,EAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,WAAW,CAKb;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,KAAG,KAAK,CAAC,SAU7E,CAAC;AAEF;;;GAGG;AAEH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7D,gBAAgB,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,GACvC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAEb"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface CreateSentryTunnelRouteOptions {
|
|
2
|
+
allowedDsns?: string[];
|
|
3
|
+
}
|
|
4
|
+
type SentryTunnelRouteHandlerContext = {
|
|
5
|
+
request: Request;
|
|
6
|
+
};
|
|
7
|
+
type SentryTunnelRoute = {
|
|
8
|
+
handlers: {
|
|
9
|
+
POST: (context: SentryTunnelRouteHandlerContext) => Promise<Response>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Creates a TanStack Start server route configuration for tunneling Sentry envelopes.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { createFileRoute } from '@tanstack/react-router';
|
|
18
|
+
* import * as Sentry from '@sentry/tanstackstart-react';
|
|
19
|
+
*
|
|
20
|
+
* export const Route = createFileRoute('/monitoring')({
|
|
21
|
+
* server: Sentry.createSentryTunnelRoute({
|
|
22
|
+
* allowedDsns: ['https://public@o0.ingest.sentry.io/0'],
|
|
23
|
+
* }),
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function createSentryTunnelRoute(options: CreateSentryTunnelRouteOptions): SentryTunnelRoute;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=tunnelRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnelRoute.d.ts","sourceRoot":"","sources":["../../../src/server/tunnelRoute.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,8BAA8B;IAC7C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,KAAK,+BAA+B,GAAG;IACrC,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE;QACR,IAAI,EAAE,CAAC,OAAO,EAAE,+BAA+B,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;KACvE,CAAC;CACH,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,8BAA8B,GAAG,iBAAiB,CA4BlG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACxE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BuildTimeOptionsBase } from '@sentry/core';
|
|
2
2
|
import type { Plugin } from 'vite';
|
|
3
|
+
import type { TunnelRouteOptions } from './tunnelRoute';
|
|
3
4
|
/**
|
|
4
5
|
* Build-time options for the Sentry TanStack Start SDK.
|
|
5
6
|
*/
|
|
@@ -16,6 +17,22 @@ export interface SentryTanstackStartOptions extends BuildTimeOptionsBase {
|
|
|
16
17
|
* @default true
|
|
17
18
|
*/
|
|
18
19
|
autoInstrumentMiddleware?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Configures a framework-managed same-origin tunnel route for Sentry envelopes.
|
|
22
|
+
*
|
|
23
|
+
* This creates a TanStack Start server route backed by `createSentryTunnelRoute()` and applies the resulting path
|
|
24
|
+
* as the default `tunnel` option on the client.
|
|
25
|
+
*
|
|
26
|
+
* You can pass:
|
|
27
|
+
* - `true` to generate an opaque route path per dev session or production build.
|
|
28
|
+
* - `'/custom-path'` to use a fixed static route path.
|
|
29
|
+
* - `{ allowedDsns, path }` for full control. If `allowedDsns` is omitted or empty, the tunnel route derives the DSN
|
|
30
|
+
* from the active server Sentry client at runtime.
|
|
31
|
+
*
|
|
32
|
+
* If you also pass `tunnel` to `Sentry.init()`, that explicit runtime option wins and a warning is emitted because
|
|
33
|
+
* the managed tunnel route is being bypassed.
|
|
34
|
+
*/
|
|
35
|
+
tunnelRoute?: TunnelRouteOptions;
|
|
19
36
|
}
|
|
20
37
|
/**
|
|
21
38
|
* Vite plugins for the Sentry TanStack Start SDK.
|