@sentry/tanstackstart-react 10.53.1 → 10.54.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 +5 -26
- package/build/cjs/client/index.js.map +1 -1
- package/build/cjs/client/sdk.js +2 -9
- package/build/cjs/client/sdk.js.map +1 -1
- package/build/cjs/client/tunnelRoute.js +2 -13
- package/build/cjs/client/tunnelRoute.js.map +1 -1
- package/build/cjs/server/globalMiddleware.js +7 -21
- package/build/cjs/server/globalMiddleware.js.map +1 -1
- package/build/cjs/server/index.js +8 -29
- package/build/cjs/server/index.js.map +1 -1
- package/build/cjs/server/middleware.js +10 -66
- package/build/cjs/server/middleware.js.map +1 -1
- package/build/cjs/server/sdk.js +2 -7
- package/build/cjs/server/sdk.js.map +1 -1
- package/build/cjs/server/tunnelRoute.js +11 -31
- package/build/cjs/server/tunnelRoute.js.map +1 -1
- package/build/cjs/server/utils.js +5 -17
- package/build/cjs/server/utils.js.map +1 -1
- package/build/cjs/server/wrapFetchWithSentry.js +9 -38
- package/build/cjs/server/wrapFetchWithSentry.js.map +1 -1
- package/build/cjs/vite/autoInstrumentMiddleware.js +15 -97
- package/build/cjs/vite/autoInstrumentMiddleware.js.map +1 -1
- package/build/cjs/vite/sentryTanstackStart.js +3 -40
- package/build/cjs/vite/sentryTanstackStart.js.map +1 -1
- package/build/cjs/vite/sourceMaps.js +30 -76
- package/build/cjs/vite/sourceMaps.js.map +1 -1
- package/build/cjs/vite/tunnelRoute.js +30 -63
- package/build/cjs/vite/tunnelRoute.js.map +1 -1
- package/build/esm/client/index.js +5 -26
- package/build/esm/client/index.js.map +1 -1
- package/build/esm/client/sdk.js +2 -9
- package/build/esm/client/sdk.js.map +1 -1
- package/build/esm/client/tunnelRoute.js +2 -13
- package/build/esm/client/tunnelRoute.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/server/globalMiddleware.js +7 -21
- package/build/esm/server/globalMiddleware.js.map +1 -1
- package/build/esm/server/index.js +8 -29
- package/build/esm/server/index.js.map +1 -1
- package/build/esm/server/middleware.js +10 -66
- package/build/esm/server/middleware.js.map +1 -1
- package/build/esm/server/sdk.js +2 -7
- package/build/esm/server/sdk.js.map +1 -1
- package/build/esm/server/tunnelRoute.js +11 -31
- package/build/esm/server/tunnelRoute.js.map +1 -1
- package/build/esm/server/utils.js +5 -17
- package/build/esm/server/utils.js.map +1 -1
- package/build/esm/server/wrapFetchWithSentry.js +9 -38
- package/build/esm/server/wrapFetchWithSentry.js.map +1 -1
- package/build/esm/vite/autoInstrumentMiddleware.js +15 -97
- package/build/esm/vite/autoInstrumentMiddleware.js.map +1 -1
- package/build/esm/vite/sentryTanstackStart.js +3 -40
- package/build/esm/vite/sentryTanstackStart.js.map +1 -1
- package/build/esm/vite/sourceMaps.js +30 -76
- package/build/esm/vite/sourceMaps.js.map +1 -1
- package/build/esm/vite/tunnelRoute.js +30 -63
- package/build/esm/vite/tunnelRoute.js.map +1 -1
- package/package.json +5 -5
|
@@ -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 applicationKey,\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 applicationKey,\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":["sentryVitePlugin"],"mappings":";;;;
|
|
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 applicationKey,\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 applicationKey,\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":["sentryVitePlugin"],"mappings":";;;;AASO,SAAS,wBAAwB,OAAA,EAAyC;AAC/E,EAAA,MAAM;AAAA,IACJ,cAAA;AAAA,IACA,SAAA;AAAA,IACA,uBAAA;AAAA,IACA,KAAA;AAAA,IACA,YAAA;AAAA,IACA,OAAA;AAAA,IACA,GAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,SAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF,GAAI,OAAA;AAGJ,EAAA,IAAI,+BAAA;AACJ,EAAA,MAAM,+BAAA,GAAkC,IAAI,OAAA,CAAkC,CAAA,OAAA,KAAW;AACvF,IAAA,+BAAA,GAAkC,OAAA;AAAA,EACpC,CAAC,CAAA;AAED,EAAA,MAAM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AA4B,UAAU,CAAA,eAAA,EAAkB,wBAAA,CAAyB,UAAU,CAAA,6CAAA;AAAA,OAC7F;AAAA,IACF;AAEA,IAAA,OAAO,wBAAA;AAAA,EACT;AAGA,EAAA,IAAI,KAAA,EAAO;AAET,IAAA,OAAA,CAAQ,GAAA;AAAA,MACN,sEAAsE,UAAU,CAAA,iFAAA;AAAA,KAClF;AAAA,EACF;AAEA,EAAA,OAAO,QAAA;AACT;;;;;;"}
|
|
@@ -1,114 +1,89 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
const MANAGED_TUNNEL_ROUTE_IMPORT =
|
|
4
|
-
const MANAGED_TUNNEL_ROUTE_NAME =
|
|
5
|
-
const MANAGED_TUNNEL_ROUTE_PATH_ENV_KEY =
|
|
6
|
-
|
|
7
|
-
const VIRTUAL_TUNNEL_ROUTE_ID = 'virtual:sentry-tanstackstart-react/tunnel-route';
|
|
3
|
+
const MANAGED_TUNNEL_ROUTE_IMPORT = "SentryManagedTunnelRouteImport";
|
|
4
|
+
const MANAGED_TUNNEL_ROUTE_NAME = "SentryManagedTunnelRoute";
|
|
5
|
+
const MANAGED_TUNNEL_ROUTE_PATH_ENV_KEY = "__SENTRY_INTERNAL_TANSTACKSTART_TUNNEL_ROUTE__";
|
|
6
|
+
const VIRTUAL_TUNNEL_ROUTE_ID = "virtual:sentry-tanstackstart-react/tunnel-route";
|
|
8
7
|
const RESOLVED_VIRTUAL_TUNNEL_ROUTE_ID = `\0${VIRTUAL_TUNNEL_ROUTE_ID}`;
|
|
9
|
-
|
|
10
8
|
function generateRandomTunnelRoute() {
|
|
11
|
-
const randomPath = Array.from({ length: 8 }, () => Math.floor(Math.random() * 36).toString(36)).join(
|
|
12
|
-
|
|
9
|
+
const randomPath = Array.from({ length: 8 }, () => Math.floor(Math.random() * 36).toString(36)).join("");
|
|
13
10
|
return `/${randomPath}`;
|
|
14
11
|
}
|
|
15
|
-
|
|
16
12
|
function resolveTunnelRoute(tunnel) {
|
|
17
|
-
if (typeof tunnel ===
|
|
13
|
+
if (typeof tunnel === "string") {
|
|
18
14
|
return tunnel;
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
if (process.env[MANAGED_TUNNEL_ROUTE_PATH_ENV_KEY]) {
|
|
22
17
|
return process.env[MANAGED_TUNNEL_ROUTE_PATH_ENV_KEY];
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
const resolvedTunnelRoute = generateRandomTunnelRoute();
|
|
26
20
|
process.env[MANAGED_TUNNEL_ROUTE_PATH_ENV_KEY] = resolvedTunnelRoute;
|
|
27
21
|
return resolvedTunnelRoute;
|
|
28
22
|
}
|
|
29
|
-
|
|
30
23
|
function validateStaticPath(path) {
|
|
31
|
-
if (!path.startsWith(
|
|
24
|
+
if (!path.startsWith("/") || path.includes("?") || path.includes("#")) {
|
|
32
25
|
throw new Error(
|
|
33
|
-
|
|
26
|
+
"[@sentry/tanstackstart-react] `tunnelRoute` static paths must start with `/` and must not contain query or hash segments."
|
|
34
27
|
);
|
|
35
28
|
}
|
|
36
29
|
}
|
|
37
|
-
|
|
38
30
|
function normalizeTunnelRouteOptions(options) {
|
|
39
31
|
if (options === true) {
|
|
40
|
-
return { resolvedPath: resolveTunnelRoute(true), allowedDsns:
|
|
32
|
+
return { resolvedPath: resolveTunnelRoute(true), allowedDsns: void 0 };
|
|
41
33
|
}
|
|
42
|
-
|
|
43
|
-
if (typeof options === 'string') {
|
|
34
|
+
if (typeof options === "string") {
|
|
44
35
|
validateStaticPath(options);
|
|
45
36
|
return {
|
|
46
37
|
resolvedPath: resolveTunnelRoute(options),
|
|
47
|
-
allowedDsns:
|
|
38
|
+
allowedDsns: void 0
|
|
48
39
|
};
|
|
49
40
|
}
|
|
50
|
-
|
|
51
|
-
const allowedDsns = options.allowedDsns && options.allowedDsns.length > 0 ? options.allowedDsns : undefined;
|
|
41
|
+
const allowedDsns = options.allowedDsns && options.allowedDsns.length > 0 ? options.allowedDsns : void 0;
|
|
52
42
|
const path = options.path;
|
|
53
|
-
|
|
54
43
|
if (path) {
|
|
55
44
|
validateStaticPath(path);
|
|
56
45
|
}
|
|
57
|
-
|
|
58
46
|
return { resolvedPath: resolveTunnelRoute(path || true), allowedDsns };
|
|
59
47
|
}
|
|
60
|
-
|
|
61
|
-
// `routeTree.gen.ts` quote style follows `tsr.config.json#quoteStyle` (`single` | `double`),
|
|
62
|
-
// so we check both forms for each route-identifying key.
|
|
63
|
-
const ROUTE_CONFLICT_KEYS = ['fullPath', 'path', 'id'] ;
|
|
64
|
-
|
|
48
|
+
const ROUTE_CONFLICT_KEYS = ["fullPath", "path", "id"];
|
|
65
49
|
function hasRouteConflict(source, resolvedTunnelRoute) {
|
|
66
50
|
const literals = [`'${resolvedTunnelRoute}'`, `"${resolvedTunnelRoute}"`];
|
|
67
|
-
return ROUTE_CONFLICT_KEYS.some(key => literals.some(literal => source.includes(`${key}: ${literal}`)));
|
|
51
|
+
return ROUTE_CONFLICT_KEYS.some((key) => literals.some((literal) => source.includes(`${key}: ${literal}`)));
|
|
68
52
|
}
|
|
69
|
-
|
|
70
53
|
function injectAfterLastImport(source, statement) {
|
|
71
54
|
const importMatches = [...source.matchAll(/^import .+$/gm)];
|
|
72
55
|
const lastImport = importMatches.at(-1);
|
|
73
|
-
|
|
74
|
-
if (lastImport?.index === undefined) {
|
|
56
|
+
if (lastImport?.index === void 0) {
|
|
75
57
|
throw new Error(
|
|
76
|
-
|
|
58
|
+
"[@sentry/tanstackstart-react] Failed to inject the managed tunnel route because `routeTree.gen.ts` imports could not be located."
|
|
77
59
|
);
|
|
78
60
|
}
|
|
79
|
-
|
|
80
61
|
const insertIndex = lastImport.index + lastImport[0].length;
|
|
81
|
-
return `${source.slice(0, insertIndex)}
|
|
62
|
+
return `${source.slice(0, insertIndex)}
|
|
63
|
+
${statement}${source.slice(insertIndex)}`;
|
|
82
64
|
}
|
|
83
|
-
|
|
84
65
|
function injectManagedTunnelRoute(source, resolvedTunnelRoute) {
|
|
85
66
|
if (source.includes(VIRTUAL_TUNNEL_ROUTE_ID)) {
|
|
86
67
|
return source;
|
|
87
68
|
}
|
|
88
|
-
|
|
89
69
|
if (hasRouteConflict(source, resolvedTunnelRoute)) {
|
|
90
70
|
throw new Error(
|
|
91
|
-
`[@sentry/tanstackstart-react] Cannot register managed tunnel route "${resolvedTunnelRoute}" because an existing TanStack Start route already uses that path
|
|
71
|
+
`[@sentry/tanstackstart-react] Cannot register managed tunnel route "${resolvedTunnelRoute}" because an existing TanStack Start route already uses that path.`
|
|
92
72
|
);
|
|
93
73
|
}
|
|
94
|
-
|
|
95
74
|
const serializedTunnelRoute = JSON.stringify(resolvedTunnelRoute);
|
|
96
|
-
|
|
97
75
|
let transformedSource = injectAfterLastImport(
|
|
98
76
|
source,
|
|
99
|
-
`import { Route as ${MANAGED_TUNNEL_ROUTE_IMPORT} } from '${VIRTUAL_TUNNEL_ROUTE_ID}'
|
|
77
|
+
`import { Route as ${MANAGED_TUNNEL_ROUTE_IMPORT} } from '${VIRTUAL_TUNNEL_ROUTE_ID}'`
|
|
100
78
|
);
|
|
101
|
-
|
|
102
79
|
const rootRouteChildrenMatch = transformedSource.match(
|
|
103
|
-
/const rootRouteChildren(?:\s*:\s*RootRouteChildren)?\s*=\s*\{
|
|
80
|
+
/const rootRouteChildren(?:\s*:\s*RootRouteChildren)?\s*=\s*\{/
|
|
104
81
|
);
|
|
105
|
-
|
|
106
|
-
if (rootRouteChildrenMatch?.index === undefined) {
|
|
82
|
+
if (rootRouteChildrenMatch?.index === void 0) {
|
|
107
83
|
throw new Error(
|
|
108
|
-
|
|
84
|
+
"[@sentry/tanstackstart-react] Failed to inject the managed tunnel route because the generated TanStack route tree did not contain `rootRouteChildren`."
|
|
109
85
|
);
|
|
110
86
|
}
|
|
111
|
-
|
|
112
87
|
const injectedRootRouteChildrenDeclaration = `const ${MANAGED_TUNNEL_ROUTE_NAME} = ${MANAGED_TUNNEL_ROUTE_IMPORT}.update({
|
|
113
88
|
id: ${serializedTunnelRoute},
|
|
114
89
|
path: ${serializedTunnelRoute},
|
|
@@ -118,31 +93,25 @@ function injectManagedTunnelRoute(source, resolvedTunnelRoute) {
|
|
|
118
93
|
${rootRouteChildrenMatch[0]}
|
|
119
94
|
${MANAGED_TUNNEL_ROUTE_NAME}: ${MANAGED_TUNNEL_ROUTE_NAME},
|
|
120
95
|
`;
|
|
121
|
-
|
|
122
96
|
transformedSource = `${transformedSource.slice(0, rootRouteChildrenMatch.index)}${injectedRootRouteChildrenDeclaration}${transformedSource.slice(rootRouteChildrenMatch.index + rootRouteChildrenMatch[0].length)}`;
|
|
123
|
-
|
|
124
97
|
return transformedSource;
|
|
125
98
|
}
|
|
126
|
-
|
|
127
99
|
function makeTunnelRoutePlugin(options, debug) {
|
|
128
100
|
const normalized = normalizeTunnelRouteOptions(options);
|
|
129
101
|
const resolvedTunnelRoute = normalized.resolvedPath;
|
|
130
102
|
const serializedTunnelRoute = JSON.stringify(resolvedTunnelRoute);
|
|
131
|
-
const serializedAllowedDsns = normalized.allowedDsns ? JSON.stringify(normalized.allowedDsns) :
|
|
132
|
-
|
|
103
|
+
const serializedAllowedDsns = normalized.allowedDsns ? JSON.stringify(normalized.allowedDsns) : void 0;
|
|
133
104
|
if (debug) {
|
|
134
|
-
// eslint-disable-next-line no-console
|
|
135
105
|
console.log(`[@sentry/tanstackstart-react] Registered tunnel route: ${resolvedTunnelRoute}`);
|
|
136
106
|
}
|
|
137
|
-
|
|
138
107
|
return {
|
|
139
|
-
name:
|
|
140
|
-
enforce:
|
|
108
|
+
name: "sentry-tanstackstart-tunnel-route",
|
|
109
|
+
enforce: "pre",
|
|
141
110
|
config() {
|
|
142
111
|
return {
|
|
143
112
|
define: {
|
|
144
|
-
__SENTRY_TANSTACKSTART_TUNNEL_ROUTE__: serializedTunnelRoute
|
|
145
|
-
}
|
|
113
|
+
__SENTRY_TANSTACKSTART_TUNNEL_ROUTE__: serializedTunnelRoute
|
|
114
|
+
}
|
|
146
115
|
};
|
|
147
116
|
},
|
|
148
117
|
resolveId(source) {
|
|
@@ -152,7 +121,6 @@ function makeTunnelRoutePlugin(options, debug) {
|
|
|
152
121
|
if (id !== RESOLVED_VIRTUAL_TUNNEL_ROUTE_ID) {
|
|
153
122
|
return null;
|
|
154
123
|
}
|
|
155
|
-
|
|
156
124
|
return `import { createFileRoute } from '@tanstack/react-router';
|
|
157
125
|
|
|
158
126
|
export const Route = createFileRoute(${serializedTunnelRoute})({
|
|
@@ -168,12 +136,11 @@ export const Route = createFileRoute(${serializedTunnelRoute})({
|
|
|
168
136
|
`;
|
|
169
137
|
},
|
|
170
138
|
transform(source, id) {
|
|
171
|
-
if (!id.endsWith(
|
|
139
|
+
if (!id.endsWith("/routeTree.gen.ts") && !id.endsWith("\\routeTree.gen.ts")) {
|
|
172
140
|
return null;
|
|
173
141
|
}
|
|
174
|
-
|
|
175
142
|
return injectManagedTunnelRoute(source, resolvedTunnelRoute);
|
|
176
|
-
}
|
|
143
|
+
}
|
|
177
144
|
};
|
|
178
145
|
}
|
|
179
146
|
|
|
@@ -1 +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,yBA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AAA,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
|
+
{"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,gCAAA;AACpC,MAAM,yBAAA,GAA4B,0BAAA;AAClC,MAAM,iCAAA,GAAoC,gDA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,eAAA,EAAkB,qBAAqB,CAAA,EAAA,CAAA,GAAO,CAAA,EAAA,CAAI,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA,IAMtH,CAAA;AAAA,IACA,SAAA,CAAU,QAAQ,EAAA,EAAI;AACpB,MAAA,IAAI,CAAC,GAAG,QAAA,CAAS,mBAAmB,KAAK,CAAC,EAAA,CAAG,QAAA,CAAS,oBAAoB,CAAA,EAAG;AAC3E,QAAA,OAAO,IAAA;AAAA,MACT;AAEA,MAAA,OAAO,wBAAA,CAAyB,QAAQ,mBAAmB,CAAA;AAAA,IAC7D;AAAA,GACF;AACF;;;;;;"}
|
|
@@ -1,37 +1,16 @@
|
|
|
1
1
|
export * from '@sentry/react';
|
|
2
2
|
export { init } from './sdk.js';
|
|
3
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
4
|
function wrapMiddlewaresWithSentry(middlewares) {
|
|
9
5
|
return Object.values(middlewares);
|
|
10
6
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* The actual implementation is server-only, but this stub is needed to prevent rendering errors.
|
|
15
|
-
*/
|
|
16
|
-
const sentryGlobalRequestMiddleware = { '~types': undefined, options: {} };
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* No-op stub for client-side builds.
|
|
20
|
-
* The actual implementation is server-only, but this stub is needed to prevent rendering errors.
|
|
21
|
-
*/
|
|
22
|
-
const sentryGlobalFunctionMiddleware = { '~types': undefined, options: {} };
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* No-op stub for client-side builds.
|
|
26
|
-
* The actual implementation is server-only, but this stub is needed to prevent rendering errors.
|
|
27
|
-
*/
|
|
28
|
-
function createSentryTunnelRoute(_options)
|
|
29
|
-
|
|
30
|
-
{
|
|
7
|
+
const sentryGlobalRequestMiddleware = { "~types": void 0, options: {} };
|
|
8
|
+
const sentryGlobalFunctionMiddleware = { "~types": void 0, options: {} };
|
|
9
|
+
function createSentryTunnelRoute(_options) {
|
|
31
10
|
return {
|
|
32
11
|
handlers: {
|
|
33
|
-
POST: async () => new Response(null, { status: 500 })
|
|
34
|
-
}
|
|
12
|
+
POST: async () => new Response(null, { status: 500 })
|
|
13
|
+
}
|
|
35
14
|
};
|
|
36
15
|
}
|
|
37
16
|
|
|
@@ -1 +1 @@
|
|
|
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';\nimport type { CreateSentryTunnelRouteOptions } from '../server/tunnelRoute';\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\n/**\n * No-op stub for client-side builds.\n * The actual implementation is server-only, but this stub is needed to prevent rendering errors.\n */\nexport const sentryGlobalRequestMiddleware: TanStackMiddlewareBase = { '~types': undefined, options: {} };\n\n/**\n * No-op stub for client-side builds.\n * The actual implementation is server-only, but this stub is needed to prevent rendering errors.\n */\nexport const sentryGlobalFunctionMiddleware: TanStackMiddlewareBase = { '~types': undefined, options: {} };\n\n/**\n * No-op stub for client-side builds.\n * The actual implementation is server-only, but this stub is needed to prevent rendering errors.\n */\nexport function createSentryTunnelRoute(_options: CreateSentryTunnelRouteOptions): {\n handlers: {\n POST: () => Promise<Response>;\n };\n} {\n return {\n handlers: {\n POST: async () => new Response(null, { status: 500 }),\n },\n };\n}\n"],"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';\nimport type { CreateSentryTunnelRouteOptions } from '../server/tunnelRoute';\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\n/**\n * No-op stub for client-side builds.\n * The actual implementation is server-only, but this stub is needed to prevent rendering errors.\n */\nexport const sentryGlobalRequestMiddleware: TanStackMiddlewareBase = { '~types': undefined, options: {} };\n\n/**\n * No-op stub for client-side builds.\n * The actual implementation is server-only, but this stub is needed to prevent rendering errors.\n */\nexport const sentryGlobalFunctionMiddleware: TanStackMiddlewareBase = { '~types': undefined, options: {} };\n\n/**\n * No-op stub for client-side builds.\n * The actual implementation is server-only, but this stub is needed to prevent rendering errors.\n */\nexport function createSentryTunnelRoute(_options: CreateSentryTunnelRouteOptions): {\n handlers: {\n POST: () => Promise<Response>;\n };\n} {\n return {\n handlers: {\n POST: async () => new Response(null, { status: 500 }),\n },\n };\n}\n"],"names":[],"mappings":";;;AAcO,SAAS,0BAA4D,WAAA,EAAqC;AAC/G,EAAA,OAAO,MAAA,CAAO,OAAO,WAAW,CAAA;AAClC;AAMO,MAAM,gCAAwD,EAAE,QAAA,EAAU,MAAA,EAAW,OAAA,EAAS,EAAC;AAM/F,MAAM,iCAAyD,EAAE,QAAA,EAAU,MAAA,EAAW,OAAA,EAAS,EAAC;AAMhG,SAAS,wBAAwB,QAAA,EAItC;AACA,EAAA,OAAO;AAAA,IACL,QAAA,EAAU;AAAA,MACR,IAAA,EAAM,YAAY,IAAI,QAAA,CAAS,MAAM,EAAE,MAAA,EAAQ,KAAK;AAAA;AACtD,GACF;AACF;;;;"}
|
package/build/esm/client/sdk.js
CHANGED
|
@@ -2,20 +2,13 @@ import { applySdkMetadata } from '@sentry/core';
|
|
|
2
2
|
import { getDefaultIntegrations, init as init$1 } from '@sentry/react';
|
|
3
3
|
import { applyTunnelRouteOption } from './tunnelRoute.js';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Initializes the TanStack Start React SDK
|
|
7
|
-
*
|
|
8
|
-
* @param options Configuration options for the SDK.
|
|
9
|
-
*/
|
|
10
5
|
function init(options) {
|
|
11
6
|
const sentryOptions = {
|
|
12
7
|
defaultIntegrations: [...getDefaultIntegrations(options)],
|
|
13
|
-
...options
|
|
8
|
+
...options
|
|
14
9
|
};
|
|
15
|
-
|
|
16
10
|
applyTunnelRouteOption(sentryOptions);
|
|
17
|
-
applySdkMetadata(sentryOptions,
|
|
18
|
-
|
|
11
|
+
applySdkMetadata(sentryOptions, "tanstackstart-react", ["tanstackstart-react", "react"]);
|
|
19
12
|
return init$1(sentryOptions);
|
|
20
13
|
}
|
|
21
14
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../../src/client/sdk.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\nimport type { BrowserOptions as ReactBrowserOptions } from '@sentry/react';\nimport { getDefaultIntegrations as getReactDefaultIntegrations, init as initReactSDK } from '@sentry/react';\nimport { applyTunnelRouteOption } from './tunnelRoute';\n\n/**\n * Initializes the TanStack Start React SDK\n *\n * @param options Configuration options for the SDK.\n */\nexport function init(options: ReactBrowserOptions): Client | undefined {\n const sentryOptions: ReactBrowserOptions = {\n defaultIntegrations: [...getReactDefaultIntegrations(options)],\n ...options,\n };\n\n applyTunnelRouteOption(sentryOptions);\n applySdkMetadata(sentryOptions, 'tanstackstart-react', ['tanstackstart-react', 'react']);\n\n return initReactSDK(sentryOptions);\n}\n"],"names":["getReactDefaultIntegrations","initReactSDK"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../../src/client/sdk.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\nimport type { BrowserOptions as ReactBrowserOptions } from '@sentry/react';\nimport { getDefaultIntegrations as getReactDefaultIntegrations, init as initReactSDK } from '@sentry/react';\nimport { applyTunnelRouteOption } from './tunnelRoute';\n\n/**\n * Initializes the TanStack Start React SDK\n *\n * @param options Configuration options for the SDK.\n */\nexport function init(options: ReactBrowserOptions): Client | undefined {\n const sentryOptions: ReactBrowserOptions = {\n defaultIntegrations: [...getReactDefaultIntegrations(options)],\n ...options,\n };\n\n applyTunnelRouteOption(sentryOptions);\n applySdkMetadata(sentryOptions, 'tanstackstart-react', ['tanstackstart-react', 'react']);\n\n return initReactSDK(sentryOptions);\n}\n"],"names":["getReactDefaultIntegrations","initReactSDK"],"mappings":";;;;AAWO,SAAS,KAAK,OAAA,EAAkD;AACrE,EAAA,MAAM,aAAA,GAAqC;AAAA,IACzC,mBAAA,EAAqB,CAAC,GAAGA,sBAAA,CAA4B,OAAO,CAAC,CAAA;AAAA,IAC7D,GAAG;AAAA,GACL;AAEA,EAAA,sBAAA,CAAuB,aAAa,CAAA;AACpC,EAAA,gBAAA,CAAiB,aAAA,EAAe,qBAAA,EAAuB,CAAC,qBAAA,EAAuB,OAAO,CAAC,CAAA;AAEvF,EAAA,OAAOC,OAAa,aAAa,CAAA;AACnC;;;;"}
|
|
@@ -1,33 +1,22 @@
|
|
|
1
1
|
import { consoleSandbox } from '@sentry/core';
|
|
2
2
|
|
|
3
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
4
|
function applyTunnelRouteOption(options) {
|
|
10
|
-
const managedTunnelRoute =
|
|
11
|
-
typeof __SENTRY_TANSTACKSTART_TUNNEL_ROUTE__ !== 'undefined' ? __SENTRY_TANSTACKSTART_TUNNEL_ROUTE__ : undefined;
|
|
12
|
-
|
|
5
|
+
const managedTunnelRoute = typeof __SENTRY_TANSTACKSTART_TUNNEL_ROUTE__ !== "undefined" ? __SENTRY_TANSTACKSTART_TUNNEL_ROUTE__ : void 0;
|
|
13
6
|
if (!managedTunnelRoute) {
|
|
14
7
|
return;
|
|
15
8
|
}
|
|
16
|
-
|
|
17
9
|
if (options.tunnel) {
|
|
18
10
|
if (!hasWarnedAboutManagedTunnelRouteOverride) {
|
|
19
11
|
hasWarnedAboutManagedTunnelRouteOverride = true;
|
|
20
12
|
consoleSandbox(() => {
|
|
21
|
-
// eslint-disable-next-line no-console
|
|
22
13
|
console.warn(
|
|
23
|
-
|
|
14
|
+
"[@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
15
|
);
|
|
25
16
|
});
|
|
26
17
|
}
|
|
27
|
-
|
|
28
18
|
return;
|
|
29
19
|
}
|
|
30
|
-
|
|
31
20
|
options.tunnel = managedTunnelRoute;
|
|
32
21
|
}
|
|
33
22
|
|
|
@@ -1 +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,
|
|
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,KAAA;AAMxC,SAAS,uBAAuB,OAAA,EAAoC;AACzE,EAAA,MAAM,kBAAA,GACJ,OAAO,qCAAA,KAA0C,WAAA,GAAc,qCAAA,GAAwC,MAAA;AAEzG,EAAA,IAAI,CAAC,kBAAA,EAAoB;AACvB,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,QAAQ,MAAA,EAAQ;AAClB,IAAA,IAAI,CAAC,wCAAA,EAA0C;AAC7C,MAAA,wCAAA,GAA2C,IAAA;AAC3C,MAAA,cAAA,CAAe,MAAM;AAEnB,QAAA,OAAA,CAAQ,IAAA;AAAA,UACN;AAAA,SACF;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAEA,IAAA;AAAA,EACF;AAEA,EAAA,OAAA,CAAQ,MAAA,GAAS,kBAAA;AACnB;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"10.
|
|
1
|
+
{"type":"module","version":"10.54.0","sideEffects":false}
|
|
@@ -7,40 +7,26 @@ function createSentryMiddlewareHandler(mechanismType) {
|
|
|
7
7
|
return await next();
|
|
8
8
|
} catch (e) {
|
|
9
9
|
captureException(e, {
|
|
10
|
-
mechanism: { type: mechanismType, handled: false }
|
|
10
|
+
mechanism: { type: mechanismType, handled: false }
|
|
11
11
|
});
|
|
12
12
|
throw e;
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Global request middleware that captures errors from API route requests.
|
|
19
|
-
* Should be added as the first entry in the `requestMiddleware` array of `createStart()`.
|
|
20
|
-
*/
|
|
21
16
|
const sentryGlobalRequestMiddleware = {
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
"~types": void 0,
|
|
24
18
|
options: {
|
|
25
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
-
server: createSentryMiddlewareHandler(
|
|
27
|
-
}
|
|
20
|
+
server: createSentryMiddlewareHandler("auto.middleware.tanstackstart.request")
|
|
21
|
+
}
|
|
28
22
|
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Global function middleware that captures errors from server function invocations.
|
|
32
|
-
* Should be added as the first entry in the `functionMiddleware` array of `createStart()`.
|
|
33
|
-
*/
|
|
34
23
|
const sentryGlobalFunctionMiddleware = {
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
"~types": void 0,
|
|
37
25
|
options: {
|
|
38
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
-
server: createSentryMiddlewareHandler(
|
|
40
|
-
}
|
|
27
|
+
server: createSentryMiddlewareHandler("auto.middleware.tanstackstart.server_function")
|
|
28
|
+
}
|
|
41
29
|
};
|
|
42
|
-
|
|
43
|
-
// Mark as internal so the Vite auto-instrumentation plugin skips these middleware
|
|
44
30
|
addNonEnumerableProperty(sentryGlobalRequestMiddleware, SENTRY_INTERNAL, true);
|
|
45
31
|
addNonEnumerableProperty(sentryGlobalFunctionMiddleware, SENTRY_INTERNAL, true);
|
|
46
32
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalMiddleware.js","sources":["../../../src/server/globalMiddleware.ts"],"sourcesContent":["import { addNonEnumerableProperty, captureException } from '@sentry/core';\nimport type { TanStackMiddlewareBase } from '../common/types';\nimport { SENTRY_INTERNAL } from './middleware';\n\nfunction createSentryMiddlewareHandler(mechanismType: string) {\n return async function sentryMiddlewareHandler({ next }: { next: () => Promise<unknown> }): Promise<unknown> {\n try {\n return await next();\n } catch (e) {\n captureException(e, {\n mechanism: { type: mechanismType, handled: false },\n });\n throw e;\n }\n };\n}\n\n/**\n * Global request middleware that captures errors from API route requests.\n * Should be added as the first entry in the `requestMiddleware` array of `createStart()`.\n */\nexport const sentryGlobalRequestMiddleware: TanStackMiddlewareBase = {\n '~types': undefined,\n\n options: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n server: createSentryMiddlewareHandler('auto.middleware.tanstackstart.request') as (...args: any[]) => any,\n },\n};\n\n/**\n * Global function middleware that captures errors from server function invocations.\n * Should be added as the first entry in the `functionMiddleware` array of `createStart()`.\n */\nexport const sentryGlobalFunctionMiddleware: TanStackMiddlewareBase = {\n '~types': undefined,\n\n options: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n server: createSentryMiddlewareHandler('auto.middleware.tanstackstart.server_function') as (...args: any[]) => any,\n },\n};\n\n// Mark as internal so the Vite auto-instrumentation plugin skips these middleware\naddNonEnumerableProperty(sentryGlobalRequestMiddleware, SENTRY_INTERNAL, true);\naddNonEnumerableProperty(sentryGlobalFunctionMiddleware, SENTRY_INTERNAL, true);\n"],"names":[],"mappings":";;;AAIA,SAAS,
|
|
1
|
+
{"version":3,"file":"globalMiddleware.js","sources":["../../../src/server/globalMiddleware.ts"],"sourcesContent":["import { addNonEnumerableProperty, captureException } from '@sentry/core';\nimport type { TanStackMiddlewareBase } from '../common/types';\nimport { SENTRY_INTERNAL } from './middleware';\n\nfunction createSentryMiddlewareHandler(mechanismType: string) {\n return async function sentryMiddlewareHandler({ next }: { next: () => Promise<unknown> }): Promise<unknown> {\n try {\n return await next();\n } catch (e) {\n captureException(e, {\n mechanism: { type: mechanismType, handled: false },\n });\n throw e;\n }\n };\n}\n\n/**\n * Global request middleware that captures errors from API route requests.\n * Should be added as the first entry in the `requestMiddleware` array of `createStart()`.\n */\nexport const sentryGlobalRequestMiddleware: TanStackMiddlewareBase = {\n '~types': undefined,\n\n options: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n server: createSentryMiddlewareHandler('auto.middleware.tanstackstart.request') as (...args: any[]) => any,\n },\n};\n\n/**\n * Global function middleware that captures errors from server function invocations.\n * Should be added as the first entry in the `functionMiddleware` array of `createStart()`.\n */\nexport const sentryGlobalFunctionMiddleware: TanStackMiddlewareBase = {\n '~types': undefined,\n\n options: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n server: createSentryMiddlewareHandler('auto.middleware.tanstackstart.server_function') as (...args: any[]) => any,\n },\n};\n\n// Mark as internal so the Vite auto-instrumentation plugin skips these middleware\naddNonEnumerableProperty(sentryGlobalRequestMiddleware, SENTRY_INTERNAL, true);\naddNonEnumerableProperty(sentryGlobalFunctionMiddleware, SENTRY_INTERNAL, true);\n"],"names":[],"mappings":";;;AAIA,SAAS,8BAA8B,aAAA,EAAuB;AAC5D,EAAA,OAAO,eAAe,uBAAA,CAAwB,EAAE,IAAA,EAAK,EAAuD;AAC1G,IAAA,IAAI;AACF,MAAA,OAAO,MAAM,IAAA,EAAK;AAAA,IACpB,SAAS,CAAA,EAAG;AACV,MAAA,gBAAA,CAAiB,CAAA,EAAG;AAAA,QAClB,SAAA,EAAW,EAAE,IAAA,EAAM,aAAA,EAAe,SAAS,KAAA;AAAM,OAClD,CAAA;AACD,MAAA,MAAM,CAAA;AAAA,IACR;AAAA,EACF,CAAA;AACF;AAMO,MAAM,6BAAA,GAAwD;AAAA,EACnE,QAAA,EAAU,MAAA;AAAA,EAEV,OAAA,EAAS;AAAA;AAAA,IAEP,MAAA,EAAQ,8BAA8B,uCAAuC;AAAA;AAEjF;AAMO,MAAM,8BAAA,GAAyD;AAAA,EACpE,QAAA,EAAU,MAAA;AAAA,EAEV,OAAA,EAAS;AAAA;AAAA,IAEP,MAAA,EAAQ,8BAA8B,+CAA+C;AAAA;AAEzF;AAGA,wBAAA,CAAyB,6BAAA,EAA+B,iBAAiB,IAAI,CAAA;AAC7E,wBAAA,CAAyB,8BAAA,EAAgC,iBAAiB,IAAI,CAAA;;;;"}
|
|
@@ -5,45 +5,24 @@ export { wrapMiddlewaresWithSentry } from './middleware.js';
|
|
|
5
5
|
export { sentryGlobalFunctionMiddleware, sentryGlobalRequestMiddleware } from './globalMiddleware.js';
|
|
6
6
|
export { createSentryTunnelRoute } from './tunnelRoute.js';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* A no-op stub of the browser tracing integration for the server. Router setup code is shared between client and server,
|
|
10
|
-
* so this stub is needed to prevent build errors during SSR bundling.
|
|
11
|
-
*/
|
|
12
|
-
function tanstackRouterBrowserTracingIntegration(
|
|
13
|
-
_router,
|
|
14
|
-
_options,
|
|
15
|
-
) {
|
|
8
|
+
function tanstackRouterBrowserTracingIntegration(_router, _options) {
|
|
16
9
|
return {
|
|
17
|
-
name:
|
|
18
|
-
setup() {
|
|
10
|
+
name: "BrowserTracing",
|
|
11
|
+
setup() {
|
|
12
|
+
}
|
|
19
13
|
};
|
|
20
14
|
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* A passthrough error boundary for the server that doesn't depend on any react. Error boundaries don't catch SSR errors
|
|
24
|
-
* so they should simply be a passthrough.
|
|
25
|
-
*/
|
|
26
15
|
const ErrorBoundary = (props) => {
|
|
27
16
|
if (!props.children) {
|
|
28
17
|
return null;
|
|
29
18
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return (props.children )();
|
|
19
|
+
if (typeof props.children === "function") {
|
|
20
|
+
return props.children();
|
|
33
21
|
}
|
|
34
|
-
|
|
35
22
|
return props.children;
|
|
36
23
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* A passthrough error boundary wrapper for the server that doesn't depend on any react. Error boundaries don't catch
|
|
40
|
-
* SSR errors so they should simply be a passthrough.
|
|
41
|
-
*/
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
-
function withErrorBoundary(
|
|
44
|
-
WrappedComponent,
|
|
45
|
-
) {
|
|
46
|
-
return WrappedComponent ;
|
|
24
|
+
function withErrorBoundary(WrappedComponent) {
|
|
25
|
+
return WrappedComponent;
|
|
47
26
|
}
|
|
48
27
|
|
|
49
28
|
export { ErrorBoundary, tanstackRouterBrowserTracingIntegration, withErrorBoundary };
|
|
@@ -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';\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":";;;;;;;
|
|
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":";;;;;;;AAiBO,SAAS,uCAAA,CACd,SACA,QAAA,EACa;AACb,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,KAAA,GAAQ;AAAA,IAAC;AAAA,GACX;AACF;AAMO,MAAM,aAAA,GAAgB,CAAC,KAAA,KAA6D;AACzF,EAAA,IAAI,CAAC,MAAM,QAAA,EAAU;AACnB,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,OAAO,KAAA,CAAM,QAAA,KAAa,UAAA,EAAY;AACxC,IAAA,OAAQ,MAAM,QAAA,EAAmC;AAAA,EACnD;AAEA,EAAA,OAAO,KAAA,CAAM,QAAA;AACf;AAOO,SAAS,kBACd,gBAAA,EACa;AACb,EAAA,OAAO,gBAAA;AACT;;;;"}
|