@sentry/tanstackstart-react 10.33.0 → 10.35.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 +14 -7
- package/build/cjs/client/index.js.map +1 -1
- package/build/cjs/index.client.js +3 -1
- package/build/cjs/index.client.js.map +1 -1
- package/build/cjs/index.server.js +4 -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/middleware.js +113 -0
- package/build/cjs/server/middleware.js.map +1 -0
- package/build/cjs/server/utils.js +17 -0
- package/build/cjs/server/utils.js.map +1 -1
- package/build/cjs/vite/sentryTanstackStart.js +46 -0
- package/build/cjs/vite/sentryTanstackStart.js.map +1 -0
- package/build/cjs/vite/sourceMaps.js +165 -0
- package/build/cjs/vite/sourceMaps.js.map +1 -0
- package/build/esm/client/index.js +10 -0
- package/build/esm/client/index.js.map +1 -1
- package/build/esm/index.client.js +2 -1
- package/build/esm/index.client.js.map +1 -1
- package/build/esm/index.server.js +2 -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/middleware.js +111 -0
- package/build/esm/server/middleware.js.map +1 -0
- package/build/esm/server/utils.js +17 -1
- package/build/esm/server/utils.js.map +1 -1
- package/build/esm/vite/sentryTanstackStart.js +44 -0
- package/build/esm/vite/sentryTanstackStart.js.map +1 -0
- package/build/esm/vite/sourceMaps.js +161 -0
- package/build/esm/vite/sourceMaps.js.map +1 -0
- package/build/types/client/index.d.ts +6 -0
- package/build/types/client/index.d.ts.map +1 -1
- package/build/types/common/index.d.ts +1 -1
- package/build/types/common/index.d.ts.map +1 -1
- package/build/types/common/types.d.ts +9 -0
- package/build/types/common/types.d.ts.map +1 -0
- package/build/types/index.client.d.ts.map +1 -1
- package/build/types/index.server.d.ts +1 -0
- package/build/types/index.server.d.ts.map +1 -1
- package/build/types/index.types.d.ts +2 -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/middleware.d.ts +22 -0
- package/build/types/server/middleware.d.ts.map +1 -0
- package/build/types/server/utils.d.ts +5 -0
- package/build/types/server/utils.d.ts.map +1 -1
- package/build/types/vite/index.d.ts +2 -0
- package/build/types/vite/index.d.ts.map +1 -0
- package/build/types/vite/sentryTanstackStart.d.ts +28 -0
- package/build/types/vite/sentryTanstackStart.d.ts.map +1 -0
- package/build/types/vite/sourceMaps.d.ts +27 -0
- package/build/types/vite/sourceMaps.d.ts.map +1 -0
- package/build/types-ts3.8/client/index.d.ts +6 -0
- package/build/types-ts3.8/common/index.d.ts +1 -1
- package/build/types-ts3.8/common/types.d.ts +9 -0
- package/build/types-ts3.8/index.server.d.ts +1 -0
- package/build/types-ts3.8/index.types.d.ts +2 -0
- package/build/types-ts3.8/server/index.d.ts +1 -0
- package/build/types-ts3.8/server/middleware.d.ts +22 -0
- package/build/types-ts3.8/server/utils.d.ts +5 -0
- package/build/types-ts3.8/vite/index.d.ts +2 -0
- package/build/types-ts3.8/vite/sentryTanstackStart.d.ts +28 -0
- package/build/types-ts3.8/vite/sourceMaps.d.ts +27 -0
- package/package.json +9 -5
|
@@ -3,17 +3,24 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3
3
|
const react = require('@sentry/react');
|
|
4
4
|
const sdk = require('./sdk.js');
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* No-op stub for client-side builds.
|
|
8
|
+
* The actual implementation is server-only, but this stub is needed to prevent build errors.
|
|
9
|
+
*/
|
|
10
|
+
function wrapMiddlewaresWithSentry(middlewares) {
|
|
11
|
+
return Object.values(middlewares);
|
|
12
|
+
}
|
|
7
13
|
|
|
8
14
|
exports.init = sdk.init;
|
|
15
|
+
exports.wrapMiddlewaresWithSentry = wrapMiddlewaresWithSentry;
|
|
9
16
|
Object.prototype.hasOwnProperty.call(react, '__proto__') &&
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
!Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
|
|
18
|
+
Object.defineProperty(exports, '__proto__', {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
value: react['__proto__']
|
|
21
|
+
});
|
|
15
22
|
|
|
16
23
|
Object.keys(react).forEach(k => {
|
|
17
|
-
|
|
24
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = react[k];
|
|
18
25
|
});
|
|
19
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/client/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 { TanStackMiddlewareBase } from '../common/types';\n\nexport * from '@sentry/react';\n\nexport { init } from './sdk';\n\n/**\n * No-op stub for client-side builds.\n * The actual implementation is server-only, but this stub is needed to prevent build errors.\n */\nexport function wrapMiddlewaresWithSentry<T extends TanStackMiddlewareBase>(middlewares: Record<string, T>): T[] {\n return Object.values(middlewares);\n}\n"],"names":[],"mappings":";;;;;AASA;AACA;AACA;AACA;AACO,SAAS,yBAAyB,CAAmC,WAAW,EAA0B;AACjH,EAAE,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;AACnC;;;;;;;;;;;;;;;"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const index = require('./client/index.js');
|
|
4
4
|
const sdk = require('./client/sdk.js');
|
|
5
|
+
const react = require('@sentry/react');
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
9
|
+
exports.wrapMiddlewaresWithSentry = index.wrapMiddlewaresWithSentry;
|
|
8
10
|
exports.init = sdk.init;
|
|
9
11
|
Object.prototype.hasOwnProperty.call(react, '__proto__') &&
|
|
10
12
|
!Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.client.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const index = require('./server/index.js');
|
|
4
|
+
const sentryTanstackStart = require('./vite/sentryTanstackStart.js');
|
|
4
5
|
const sdk = require('./server/sdk.js');
|
|
5
6
|
const wrapFetchWithSentry = require('./server/wrapFetchWithSentry.js');
|
|
7
|
+
const middleware = require('./server/middleware.js');
|
|
6
8
|
const node = require('@sentry/node');
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
exports.ErrorBoundary = index.ErrorBoundary;
|
|
11
13
|
exports.withErrorBoundary = index.withErrorBoundary;
|
|
14
|
+
exports.sentryTanstackStart = sentryTanstackStart.sentryTanstackStart;
|
|
12
15
|
exports.init = sdk.init;
|
|
13
16
|
exports.wrapFetchWithSentry = wrapFetchWithSentry.wrapFetchWithSentry;
|
|
17
|
+
exports.wrapMiddlewaresWithSentry = middleware.wrapMiddlewaresWithSentry;
|
|
14
18
|
Object.prototype.hasOwnProperty.call(node, '__proto__') &&
|
|
15
19
|
!Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
|
|
16
20
|
Object.defineProperty(exports, '__proto__', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3
3
|
const node = require('@sentry/node');
|
|
4
4
|
const sdk = require('./sdk.js');
|
|
5
5
|
const wrapFetchWithSentry = require('./wrapFetchWithSentry.js');
|
|
6
|
+
const middleware = require('./middleware.js');
|
|
6
7
|
|
|
7
8
|
// import/export got a false positive, and affects most of our index barrel files
|
|
8
9
|
// can be removed once following issue is fixed: https://github.com/import-js/eslint-plugin-import/issues/703
|
|
@@ -37,6 +38,7 @@ function withErrorBoundary(
|
|
|
37
38
|
|
|
38
39
|
exports.init = sdk.init;
|
|
39
40
|
exports.wrapFetchWithSentry = wrapFetchWithSentry.wrapFetchWithSentry;
|
|
41
|
+
exports.wrapMiddlewaresWithSentry = middleware.wrapMiddlewaresWithSentry;
|
|
40
42
|
exports.ErrorBoundary = ErrorBoundary;
|
|
41
43
|
exports.withErrorBoundary = withErrorBoundary;
|
|
42
44
|
Object.prototype.hasOwnProperty.call(node, '__proto__') &&
|
|
@@ -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 */\nexport * from '@sentry/node';\n\nexport { init } from './sdk';\nexport { wrapFetchWithSentry } from './wrapFetchWithSentry';\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 */\nexport * from '@sentry/node';\n\nexport { init } from './sdk';\nexport { wrapFetchWithSentry } from './wrapFetchWithSentry';\nexport { wrapMiddlewaresWithSentry } from './middleware';\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;;AAOA;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,113 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const core = require('@sentry/core');
|
|
4
|
+
const node = require('@sentry/node');
|
|
5
|
+
const utils = require('./utils.js');
|
|
6
|
+
|
|
7
|
+
const SENTRY_WRAPPED = '__SENTRY_WRAPPED__';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates a proxy for the next function that ends the current span and restores the parent span.
|
|
11
|
+
* This ensures that subsequent middleware spans are children of the root span, not nested children.
|
|
12
|
+
*/
|
|
13
|
+
function getNextProxy(
|
|
14
|
+
next,
|
|
15
|
+
span,
|
|
16
|
+
prevSpan,
|
|
17
|
+
nextState,
|
|
18
|
+
) {
|
|
19
|
+
return new Proxy(next, {
|
|
20
|
+
apply: (originalNext, thisArgNext, argsNext) => {
|
|
21
|
+
nextState.called = true;
|
|
22
|
+
span.end();
|
|
23
|
+
|
|
24
|
+
if (prevSpan) {
|
|
25
|
+
return node.withActiveSpan(prevSpan, () => {
|
|
26
|
+
return Reflect.apply(originalNext, thisArgNext, argsNext);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return Reflect.apply(originalNext, thisArgNext, argsNext);
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Wraps a TanStack Start middleware with Sentry instrumentation to create spans.
|
|
37
|
+
*/
|
|
38
|
+
function wrapMiddlewareWithSentry(
|
|
39
|
+
middleware,
|
|
40
|
+
options,
|
|
41
|
+
) {
|
|
42
|
+
if ((middleware )[SENTRY_WRAPPED]) {
|
|
43
|
+
// already instrumented
|
|
44
|
+
return middleware;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// instrument server middleware
|
|
48
|
+
if (middleware.options?.server) {
|
|
49
|
+
middleware.options.server = new Proxy(middleware.options.server, {
|
|
50
|
+
apply: (originalServer, thisArgServer, argsServer) => {
|
|
51
|
+
const prevSpan = node.getActiveSpan();
|
|
52
|
+
|
|
53
|
+
return node.startSpanManual(utils.getMiddlewareSpanOptions(options.name), async (span) => {
|
|
54
|
+
const nextState = { called: false };
|
|
55
|
+
|
|
56
|
+
// The server function receives { next, context, request } as first argument
|
|
57
|
+
// Users call next() inside their middleware to move down the middleware chain. We proxy next() to end the span when it is called.
|
|
58
|
+
const middlewareArgs = argsServer[0] ;
|
|
59
|
+
if (middlewareArgs && typeof middlewareArgs === 'object' && typeof middlewareArgs.next === 'function') {
|
|
60
|
+
middlewareArgs.next = getNextProxy(middlewareArgs.next, span, prevSpan, nextState);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const result = await originalServer.apply(thisArgServer, argsServer);
|
|
65
|
+
|
|
66
|
+
// End span here if next() wasn't called, else we already ended it in next()
|
|
67
|
+
if (!nextState.called) {
|
|
68
|
+
span.end();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return result;
|
|
72
|
+
} catch (e) {
|
|
73
|
+
span.end();
|
|
74
|
+
throw e;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// mark as instrumented
|
|
81
|
+
core.addNonEnumerableProperty(middleware , SENTRY_WRAPPED, true);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return middleware;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Wraps multiple TanStack Start middlewares with Sentry instrumentation.
|
|
89
|
+
* Object keys are used as span names to avoid users having to specify this manually.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* import { wrapMiddlewaresWithSentry } from '@sentry/tanstackstart-react';
|
|
94
|
+
*
|
|
95
|
+
* const wrappedMiddlewares = wrapMiddlewaresWithSentry({
|
|
96
|
+
* authMiddleware,
|
|
97
|
+
* loggingMiddleware,
|
|
98
|
+
* });
|
|
99
|
+
*
|
|
100
|
+
* createServerFn().middleware(wrappedMiddlewares)
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @param middlewares - An object containing middlewares
|
|
104
|
+
* @returns An array of wrapped middlewares
|
|
105
|
+
*/
|
|
106
|
+
function wrapMiddlewaresWithSentry(middlewares) {
|
|
107
|
+
return Object.entries(middlewares).map(([name, middleware]) => {
|
|
108
|
+
return wrapMiddlewareWithSentry(middleware, { name });
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
exports.wrapMiddlewaresWithSentry = wrapMiddlewaresWithSentry;
|
|
113
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sources":["../../../src/server/middleware.ts"],"sourcesContent":["import { addNonEnumerableProperty } from '@sentry/core';\nimport type { Span } from '@sentry/node';\nimport { getActiveSpan, startSpanManual, withActiveSpan } from '@sentry/node';\nimport type { MiddlewareWrapperOptions, TanStackMiddlewareBase } from '../common/types';\nimport { getMiddlewareSpanOptions } from './utils';\n\nconst SENTRY_WRAPPED = '__SENTRY_WRAPPED__';\n\n/**\n * Creates a proxy for the next function that ends the current span and restores the parent span.\n * This ensures that subsequent middleware spans are children of the root span, not nested children.\n */\nfunction getNextProxy<T extends (...args: unknown[]) => unknown>(\n next: T,\n span: Span,\n prevSpan: Span | undefined,\n nextState: { called: boolean },\n): T {\n return new Proxy(next, {\n apply: (originalNext, thisArgNext, argsNext) => {\n nextState.called = true;\n span.end();\n\n if (prevSpan) {\n return withActiveSpan(prevSpan, () => {\n return Reflect.apply(originalNext, thisArgNext, argsNext);\n });\n }\n\n return Reflect.apply(originalNext, thisArgNext, argsNext);\n },\n });\n}\n\n/**\n * Wraps a TanStack Start middleware with Sentry instrumentation to create spans.\n */\nfunction wrapMiddlewareWithSentry<T extends TanStackMiddlewareBase>(\n middleware: T,\n options: MiddlewareWrapperOptions,\n): T {\n if ((middleware as TanStackMiddlewareBase & { [SENTRY_WRAPPED]?: boolean })[SENTRY_WRAPPED]) {\n // already instrumented\n return middleware;\n }\n\n // instrument server middleware\n if (middleware.options?.server) {\n middleware.options.server = new Proxy(middleware.options.server, {\n apply: (originalServer, thisArgServer, argsServer) => {\n const prevSpan = getActiveSpan();\n\n return startSpanManual(getMiddlewareSpanOptions(options.name), async (span: Span) => {\n const nextState = { called: false };\n\n // The server function receives { next, context, request } as first argument\n // Users call next() inside their middleware to move down the middleware chain. We proxy next() to end the span when it is called.\n const middlewareArgs = argsServer[0] as { next?: (...args: unknown[]) => unknown } | undefined;\n if (middlewareArgs && typeof middlewareArgs === 'object' && typeof middlewareArgs.next === 'function') {\n middlewareArgs.next = getNextProxy(middlewareArgs.next, span, prevSpan, nextState);\n }\n\n try {\n const result = await originalServer.apply(thisArgServer, argsServer);\n\n // End span here if next() wasn't called, else we already ended it in next()\n if (!nextState.called) {\n span.end();\n }\n\n return result;\n } catch (e) {\n span.end();\n throw e;\n }\n });\n },\n });\n\n // mark as instrumented\n addNonEnumerableProperty(middleware as unknown as Record<string, unknown>, SENTRY_WRAPPED, true);\n }\n\n return middleware;\n}\n\n/**\n * Wraps multiple TanStack Start middlewares with Sentry instrumentation.\n * Object keys are used as span names to avoid users having to specify this manually.\n *\n * @example\n * ```ts\n * import { wrapMiddlewaresWithSentry } from '@sentry/tanstackstart-react';\n *\n * const wrappedMiddlewares = wrapMiddlewaresWithSentry({\n * authMiddleware,\n * loggingMiddleware,\n * });\n *\n * createServerFn().middleware(wrappedMiddlewares)\n * ```\n *\n * @param middlewares - An object containing middlewares\n * @returns An array of wrapped middlewares\n */\nexport function wrapMiddlewaresWithSentry<T extends TanStackMiddlewareBase>(middlewares: Record<string, T>): T[] {\n return Object.entries(middlewares).map(([name, middleware]) => {\n return wrapMiddlewareWithSentry(middleware, { name });\n });\n}\n"],"names":["withActiveSpan","getActiveSpan","startSpanManual","getMiddlewareSpanOptions","addNonEnumerableProperty"],"mappings":";;;;;;AAMA,MAAM,cAAA,GAAiB,oBAAoB;;AAE3C;AACA;AACA;AACA;AACA,SAAS,YAAY;AACrB,EAAE,IAAI;AACN,EAAE,IAAI;AACN,EAAE,QAAQ;AACV,EAAE,SAAS;AACX,EAAK;AACL,EAAE,OAAO,IAAI,KAAK,CAAC,IAAI,EAAE;AACzB,IAAI,KAAK,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,QAAQ,KAAK;AACpD,MAAM,SAAS,CAAC,MAAA,GAAS,IAAI;AAC7B,MAAM,IAAI,CAAC,GAAG,EAAE;;AAEhB,MAAM,IAAI,QAAQ,EAAE;AACpB,QAAQ,OAAOA,mBAAc,CAAC,QAAQ,EAAE,MAAM;AAC9C,UAAU,OAAO,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,WAAW,EAAE,QAAQ,CAAC;AACnE,QAAQ,CAAC,CAAC;AACV,MAAM;;AAEN,MAAM,OAAO,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,WAAW,EAAE,QAAQ,CAAC;AAC/D,IAAI,CAAC;AACL,GAAG,CAAC;AACJ;;AAEA;AACA;AACA;AACA,SAAS,wBAAwB;AACjC,EAAE,UAAU;AACZ,EAAE,OAAO;AACT,EAAK;AACL,EAAE,IAAI,CAAC,UAAA,GAAuE,cAAc,CAAC,EAAE;AAC/F;AACA,IAAI,OAAO,UAAU;AACrB,EAAE;;AAEF;AACA,EAAE,IAAI,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE;AAClC,IAAI,UAAU,CAAC,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE;AACrE,MAAM,KAAK,EAAE,CAAC,cAAc,EAAE,aAAa,EAAE,UAAU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,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK;AACjE,IAAI,OAAO,wBAAwB,CAAC,UAAU,EAAE,EAAE,IAAA,EAAM,CAAC;AACzD,EAAE,CAAC,CAAC;AACJ;;;;"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
+
const node = require('@sentry/node');
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Extracts the SHA-256 hash from a server function pathname.
|
|
5
7
|
* Server function pathnames are structured as `/_serverFn/<hash>`.
|
|
@@ -13,5 +15,20 @@ function extractServerFunctionSha256(pathname) {
|
|
|
13
15
|
return serverFnMatch?.[1] ?? 'unknown';
|
|
14
16
|
}
|
|
15
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Returns span options for TanStack Start middleware spans.
|
|
20
|
+
*/
|
|
21
|
+
function getMiddlewareSpanOptions(name) {
|
|
22
|
+
return {
|
|
23
|
+
op: 'middleware.tanstackstart',
|
|
24
|
+
name,
|
|
25
|
+
attributes: {
|
|
26
|
+
[node.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual.middleware.tanstackstart',
|
|
27
|
+
[node.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware.tanstackstart',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
16
32
|
exports.extractServerFunctionSha256 = extractServerFunctionSha256;
|
|
33
|
+
exports.getMiddlewareSpanOptions = getMiddlewareSpanOptions;
|
|
17
34
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/server/utils.ts"],"sourcesContent":["/**\n * Extracts the SHA-256 hash from a server function pathname.\n * Server function pathnames are structured as `/_serverFn/<hash>`.\n * This function matches the pattern and returns the hash if found.\n *\n * @param pathname - the pathname of the server function\n * @returns the sha256 of the server function\n */\nexport function extractServerFunctionSha256(pathname: string): string {\n const serverFnMatch = pathname.match(/\\/_serverFn\\/([a-f0-9]{64})/i);\n return serverFnMatch?.[1] ?? 'unknown';\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/server/utils.ts"],"sourcesContent":["import type { StartSpanOptions } from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/node';\n\n/**\n * Extracts the SHA-256 hash from a server function pathname.\n * Server function pathnames are structured as `/_serverFn/<hash>`.\n * This function matches the pattern and returns the hash if found.\n *\n * @param pathname - the pathname of the server function\n * @returns the sha256 of the server function\n */\nexport function extractServerFunctionSha256(pathname: string): string {\n const serverFnMatch = pathname.match(/\\/_serverFn\\/([a-f0-9]{64})/i);\n return serverFnMatch?.[1] ?? 'unknown';\n}\n\n/**\n * Returns span options for TanStack Start middleware spans.\n */\nexport function getMiddlewareSpanOptions(name: string): StartSpanOptions {\n return {\n op: 'middleware.tanstackstart',\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual.middleware.tanstackstart',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'middleware.tanstackstart',\n },\n };\n}\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP"],"mappings":";;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,2BAA2B,CAAC,QAAQ,EAAkB;AACtE,EAAE,MAAM,gBAAgB,QAAQ,CAAC,KAAK,CAAC,8BAA8B,CAAC;AACtE,EAAE,OAAO,aAAa,GAAG,CAAC,CAAA,IAAK,SAAS;AACxC;;AAEA;AACA;AACA;AACO,SAAS,wBAAwB,CAAC,IAAI,EAA4B;AACzE,EAAE,OAAO;AACT,IAAI,EAAE,EAAE,0BAA0B;AAClC,IAAI,IAAI;AACR,IAAI,UAAU,EAAE;AAChB,MAAM,CAACA,qCAAgC,GAAG,iCAAiC;AAC3E,MAAM,CAACC,iCAA4B,GAAG,0BAA0B;AAChE,KAAK;AACL,GAAG;AACH;;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const sourceMaps = require('./sourceMaps.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Vite plugins for the Sentry TanStack Start SDK.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // vite.config.ts
|
|
11
|
+
* import { defineConfig } from 'vite';
|
|
12
|
+
* import { sentryTanstackStart } from '@sentry/tanstackstart-react';
|
|
13
|
+
* import { tanstackStart } from '@tanstack/react-start/plugin/vite';
|
|
14
|
+
*
|
|
15
|
+
* export default defineConfig({
|
|
16
|
+
* plugins: [
|
|
17
|
+
* sentryTanstackStart({
|
|
18
|
+
* org: 'your-org',
|
|
19
|
+
* project: 'your-project',
|
|
20
|
+
* }),
|
|
21
|
+
* tanstackStart(),
|
|
22
|
+
* ],
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param options - Options to configure the Sentry Vite plugins
|
|
27
|
+
* @returns An array of Vite plugins
|
|
28
|
+
*/
|
|
29
|
+
function sentryTanstackStart(options = {}) {
|
|
30
|
+
// Only add plugins in production builds
|
|
31
|
+
if (process.env.NODE_ENV === 'development') {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const plugins = [...sourceMaps.makeAddSentryVitePlugin(options)];
|
|
36
|
+
|
|
37
|
+
const sourceMapsDisabled = options.sourcemaps?.disable === true || options.sourcemaps?.disable === 'disable-upload';
|
|
38
|
+
if (!sourceMapsDisabled) {
|
|
39
|
+
plugins.push(...sourceMaps.makeEnableSourceMapsVitePlugin(options));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return plugins;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.sentryTanstackStart = sentryTanstackStart;
|
|
46
|
+
//# sourceMappingURL=sentryTanstackStart.js.map
|
|
@@ -0,0 +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 { makeAddSentryVitePlugin, makeEnableSourceMapsVitePlugin } from './sourceMaps';\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';\n * import { tanstackStart } from '@tanstack/react-start/plugin/vite';\n *\n * export default defineConfig({\n * plugins: [\n * sentryTanstackStart({\n * org: 'your-org',\n * project: 'your-project',\n * }),\n * tanstackStart(),\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: BuildTimeOptionsBase = {}): 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 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":["makeAddSentryVitePlugin","makeEnableSourceMapsVitePlugin"],"mappings":";;;;AAIA;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,GAAyB,EAAE,EAAY;AAClF;AACA,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAA,KAAa,aAAa,EAAE;AAC9C,IAAI,OAAO,EAAE;AACb,EAAE;;AAEF,EAAE,MAAM,OAAO,GAAa,CAAC,GAAGA,kCAAuB,CAAC,OAAO,CAAC,CAAC;;AAEjE,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,GAAGC,yCAA8B,CAAC,OAAO,CAAC,CAAC;AAC5D,EAAE;;AAEF,EAAE,OAAO,OAAO;AAChB;;;;"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const vitePlugin = require('@sentry/vite-plugin');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A Sentry plugin for adding the @sentry/vite-plugin to automatically upload source maps to Sentry.
|
|
7
|
+
*/
|
|
8
|
+
function makeAddSentryVitePlugin(options) {
|
|
9
|
+
const {
|
|
10
|
+
authToken,
|
|
11
|
+
bundleSizeOptimizations,
|
|
12
|
+
debug,
|
|
13
|
+
errorHandler,
|
|
14
|
+
headers,
|
|
15
|
+
org,
|
|
16
|
+
project,
|
|
17
|
+
release,
|
|
18
|
+
sentryUrl,
|
|
19
|
+
silent,
|
|
20
|
+
sourcemaps,
|
|
21
|
+
telemetry,
|
|
22
|
+
} = options;
|
|
23
|
+
|
|
24
|
+
// defer resolving the filesToDeleteAfterUpload until we got access to the Vite config
|
|
25
|
+
let resolveFilesToDeleteAfterUpload;
|
|
26
|
+
const filesToDeleteAfterUploadPromise = new Promise(resolve => {
|
|
27
|
+
resolveFilesToDeleteAfterUpload = resolve;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const configPlugin = {
|
|
31
|
+
name: 'sentry-tanstackstart-files-to-delete-after-upload-plugin',
|
|
32
|
+
apply: 'build',
|
|
33
|
+
enforce: 'post',
|
|
34
|
+
config(config) {
|
|
35
|
+
const userFilesToDelete = sourcemaps?.filesToDeleteAfterUpload;
|
|
36
|
+
|
|
37
|
+
// Only auto-delete source maps if the user didn't configure sourcemaps at all
|
|
38
|
+
if (typeof userFilesToDelete === 'undefined' && typeof config.build?.sourcemap === 'undefined') {
|
|
39
|
+
if (debug) {
|
|
40
|
+
// eslint-disable-next-line no-console
|
|
41
|
+
console.log(
|
|
42
|
+
'[Sentry] Automatically setting `sourcemaps.filesToDeleteAfterUpload: ["./**/*.map"]` to delete generated source maps after they were uploaded to Sentry.',
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
resolveFilesToDeleteAfterUpload?.(['./**/*.map']);
|
|
46
|
+
} else {
|
|
47
|
+
resolveFilesToDeleteAfterUpload?.(userFilesToDelete);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const sentryPlugins = vitePlugin.sentryVitePlugin({
|
|
53
|
+
authToken: authToken ?? process.env.SENTRY_AUTH_TOKEN,
|
|
54
|
+
bundleSizeOptimizations: bundleSizeOptimizations ?? undefined,
|
|
55
|
+
debug: debug ?? false,
|
|
56
|
+
errorHandler,
|
|
57
|
+
headers,
|
|
58
|
+
org: org ?? process.env.SENTRY_ORG,
|
|
59
|
+
project: project ?? process.env.SENTRY_PROJECT,
|
|
60
|
+
release,
|
|
61
|
+
silent,
|
|
62
|
+
sourcemaps: {
|
|
63
|
+
assets: sourcemaps?.assets,
|
|
64
|
+
disable: sourcemaps?.disable,
|
|
65
|
+
ignore: sourcemaps?.ignore,
|
|
66
|
+
filesToDeleteAfterUpload: filesToDeleteAfterUploadPromise,
|
|
67
|
+
},
|
|
68
|
+
telemetry: telemetry ?? true,
|
|
69
|
+
url: sentryUrl,
|
|
70
|
+
_metaOptions: {
|
|
71
|
+
telemetry: {
|
|
72
|
+
metaFramework: 'tanstackstart-react',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
return [configPlugin, ...sentryPlugins];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A Sentry plugin for TanStack Start React to enable "hidden" source maps if they are unset.
|
|
82
|
+
*/
|
|
83
|
+
function makeEnableSourceMapsVitePlugin(options) {
|
|
84
|
+
return [
|
|
85
|
+
{
|
|
86
|
+
name: 'sentry-tanstackstart-react-source-maps',
|
|
87
|
+
apply: 'build',
|
|
88
|
+
enforce: 'post',
|
|
89
|
+
config(viteConfig) {
|
|
90
|
+
return {
|
|
91
|
+
...viteConfig,
|
|
92
|
+
build: {
|
|
93
|
+
...viteConfig.build,
|
|
94
|
+
sourcemap: getUpdatedSourceMapSettings(viteConfig, options),
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** There are 3 ways to set up source map generation (https://github.com/getsentry/sentry-javascript/issues/13993)
|
|
103
|
+
*
|
|
104
|
+
* 1. User explicitly disabled source maps
|
|
105
|
+
* - keep this setting (emit a warning that errors won't be unminified in Sentry)
|
|
106
|
+
* - We won't upload anything
|
|
107
|
+
*
|
|
108
|
+
* 2. Users enabled source map generation (true, 'hidden', 'inline').
|
|
109
|
+
* - keep this setting (don't do anything - like deletion - besides uploading)
|
|
110
|
+
*
|
|
111
|
+
* 3. Users didn't set source maps generation
|
|
112
|
+
* - we enable 'hidden' source maps generation
|
|
113
|
+
* - configure `filesToDeleteAfterUpload` to delete all .map files (we emit a log about this)
|
|
114
|
+
*
|
|
115
|
+
* --> only exported for testing
|
|
116
|
+
*/
|
|
117
|
+
function getUpdatedSourceMapSettings(
|
|
118
|
+
viteConfig,
|
|
119
|
+
sentryPluginOptions,
|
|
120
|
+
) {
|
|
121
|
+
viteConfig.build = viteConfig.build || {};
|
|
122
|
+
|
|
123
|
+
const viteUserSourceMapSetting = viteConfig.build?.sourcemap;
|
|
124
|
+
const settingKey = 'vite.build.sourcemap';
|
|
125
|
+
const debug = sentryPluginOptions?.debug;
|
|
126
|
+
|
|
127
|
+
// Respect user source map setting if it is explicitly set
|
|
128
|
+
if (viteUserSourceMapSetting === false) {
|
|
129
|
+
if (debug) {
|
|
130
|
+
// eslint-disable-next-line no-console
|
|
131
|
+
console.warn(
|
|
132
|
+
`[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.`,
|
|
133
|
+
);
|
|
134
|
+
} else {
|
|
135
|
+
// eslint-disable-next-line no-console
|
|
136
|
+
console.warn('[Sentry] Source map generation is disabled in your TanStack Start configuration.');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return viteUserSourceMapSetting;
|
|
140
|
+
} else if (viteUserSourceMapSetting && ['hidden', 'inline', true].includes(viteUserSourceMapSetting)) {
|
|
141
|
+
if (debug) {
|
|
142
|
+
// eslint-disable-next-line no-console
|
|
143
|
+
console.log(
|
|
144
|
+
`[Sentry] We discovered \`${settingKey}\` is set to \`${viteUserSourceMapSetting.toString()}\`. Sentry will keep this source map setting.`,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return viteUserSourceMapSetting;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// If the user did not specify a source map setting, we enable 'hidden' by default
|
|
152
|
+
if (debug) {
|
|
153
|
+
// eslint-disable-next-line no-console
|
|
154
|
+
console.log(
|
|
155
|
+
`[Sentry] Enabled source map generation in the build options with \`${settingKey}: 'hidden'\`. The source maps will be deleted after they were uploaded to Sentry.`,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return 'hidden';
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
exports.getUpdatedSourceMapSettings = getUpdatedSourceMapSettings;
|
|
163
|
+
exports.makeAddSentryVitePlugin = makeAddSentryVitePlugin;
|
|
164
|
+
exports.makeEnableSourceMapsVitePlugin = makeEnableSourceMapsVitePlugin;
|
|
165
|
+
//# sourceMappingURL=sourceMaps.js.map
|
|
@@ -0,0 +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 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":["sentryVitePlugin"],"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;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,wBAAA,IAA4B,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE;AACxG,IAAI,IAAI,KAAK,EAAE;AACf;AACA,MAAM,OAAO,CAAC,GAAG;AACjB,QAAQ,CAAC,yBAAyB,EAAE,UAAU,CAAC,eAAe,EAAE,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;;;;;;"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
export * from '@sentry/react';
|
|
2
2
|
export { init } from './sdk.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* No-op stub for client-side builds.
|
|
6
|
+
* The actual implementation is server-only, but this stub is needed to prevent build errors.
|
|
7
|
+
*/
|
|
8
|
+
function wrapMiddlewaresWithSentry(middlewares) {
|
|
9
|
+
return Object.values(middlewares);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { wrapMiddlewaresWithSentry };
|
|
3
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/client/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 { TanStackMiddlewareBase } from '../common/types';\n\nexport * from '@sentry/react';\n\nexport { init } from './sdk';\n\n/**\n * No-op stub for client-side builds.\n * The actual implementation is server-only, but this stub is needed to prevent build errors.\n */\nexport function wrapMiddlewaresWithSentry<T extends TanStackMiddlewareBase>(middlewares: Record<string, T>): T[] {\n return Object.values(middlewares);\n}\n"],"names":[],"mappings":";;;AASA;AACA;AACA;AACA;AACO,SAAS,yBAAyB,CAAmC,WAAW,EAA0B;AACjH,EAAE,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;AACnC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.client.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { ErrorBoundary, withErrorBoundary } from './server/index.js';
|
|
2
|
+
export { sentryTanstackStart } from './vite/sentryTanstackStart.js';
|
|
2
3
|
export { init } from './server/sdk.js';
|
|
3
4
|
export { wrapFetchWithSentry } from './server/wrapFetchWithSentry.js';
|
|
5
|
+
export { wrapMiddlewaresWithSentry } from './server/middleware.js';
|
|
4
6
|
export * from '@sentry/node';
|
|
5
7
|
//# sourceMappingURL=index.server.js.map
|
|
@@ -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.35.0","sideEffects":false}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from '@sentry/node';
|
|
2
2
|
export { init } from './sdk.js';
|
|
3
3
|
export { wrapFetchWithSentry } from './wrapFetchWithSentry.js';
|
|
4
|
+
export { wrapMiddlewaresWithSentry } from './middleware.js';
|
|
4
5
|
|
|
5
6
|
// import/export got a false positive, and affects most of our index barrel files
|
|
6
7
|
// can be removed once following issue is fixed: https://github.com/import-js/eslint-plugin-import/issues/703
|
|
@@ -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 */\nexport * from '@sentry/node';\n\nexport { init } from './sdk';\nexport { wrapFetchWithSentry } from './wrapFetchWithSentry';\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 */\nexport * from '@sentry/node';\n\nexport { init } from './sdk';\nexport { wrapFetchWithSentry } from './wrapFetchWithSentry';\nexport { wrapMiddlewaresWithSentry } from './middleware';\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;;AAOA;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;;;;"}
|