@sentry/tanstackstart-react 10.53.1 → 10.55.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.
Files changed (95) hide show
  1. package/README.md +3 -2
  2. package/build/cjs/client/index.js +5 -26
  3. package/build/cjs/client/index.js.map +1 -1
  4. package/build/cjs/client/sdk.js +12 -9
  5. package/build/cjs/client/sdk.js.map +1 -1
  6. package/build/cjs/client/tunnelRoute.js +2 -13
  7. package/build/cjs/client/tunnelRoute.js.map +1 -1
  8. package/build/cjs/index.server.js +1 -0
  9. package/build/cjs/index.server.js.map +1 -1
  10. package/build/cjs/server/globalMiddleware.js +38 -22
  11. package/build/cjs/server/globalMiddleware.js.map +1 -1
  12. package/build/cjs/server/index.js +16 -29
  13. package/build/cjs/server/index.js.map +1 -1
  14. package/build/cjs/server/middleware.js +10 -66
  15. package/build/cjs/server/middleware.js.map +1 -1
  16. package/build/cjs/server/routeParametrization.js +47 -0
  17. package/build/cjs/server/routeParametrization.js.map +1 -0
  18. package/build/cjs/server/sdk.js +9 -7
  19. package/build/cjs/server/sdk.js.map +1 -1
  20. package/build/cjs/server/tunnelRoute.js +11 -31
  21. package/build/cjs/server/tunnelRoute.js.map +1 -1
  22. package/build/cjs/server/utils.js +4 -21
  23. package/build/cjs/server/utils.js.map +1 -1
  24. package/build/cjs/server/wrapFetchWithSentry.js +88 -44
  25. package/build/cjs/server/wrapFetchWithSentry.js.map +1 -1
  26. package/build/cjs/vite/autoInstrumentMiddleware.js +15 -97
  27. package/build/cjs/vite/autoInstrumentMiddleware.js.map +1 -1
  28. package/build/cjs/vite/routePatterns.js +60 -0
  29. package/build/cjs/vite/routePatterns.js.map +1 -0
  30. package/build/cjs/vite/sentryTanstackStart.js +8 -44
  31. package/build/cjs/vite/sentryTanstackStart.js.map +1 -1
  32. package/build/cjs/vite/sourceMaps.js +34 -75
  33. package/build/cjs/vite/sourceMaps.js.map +1 -1
  34. package/build/cjs/vite/tunnelRoute.js +30 -63
  35. package/build/cjs/vite/tunnelRoute.js.map +1 -1
  36. package/build/esm/client/index.js +5 -26
  37. package/build/esm/client/index.js.map +1 -1
  38. package/build/esm/client/sdk.js +12 -9
  39. package/build/esm/client/sdk.js.map +1 -1
  40. package/build/esm/client/tunnelRoute.js +2 -13
  41. package/build/esm/client/tunnelRoute.js.map +1 -1
  42. package/build/esm/index.server.js +1 -1
  43. package/build/esm/package.json +1 -1
  44. package/build/esm/server/globalMiddleware.js +39 -23
  45. package/build/esm/server/globalMiddleware.js.map +1 -1
  46. package/build/esm/server/index.js +16 -30
  47. package/build/esm/server/index.js.map +1 -1
  48. package/build/esm/server/middleware.js +10 -66
  49. package/build/esm/server/middleware.js.map +1 -1
  50. package/build/esm/server/routeParametrization.js +44 -0
  51. package/build/esm/server/routeParametrization.js.map +1 -0
  52. package/build/esm/server/sdk.js +9 -7
  53. package/build/esm/server/sdk.js.map +1 -1
  54. package/build/esm/server/tunnelRoute.js +11 -31
  55. package/build/esm/server/tunnelRoute.js.map +1 -1
  56. package/build/esm/server/utils.js +5 -21
  57. package/build/esm/server/utils.js.map +1 -1
  58. package/build/esm/server/wrapFetchWithSentry.js +90 -46
  59. package/build/esm/server/wrapFetchWithSentry.js.map +1 -1
  60. package/build/esm/vite/autoInstrumentMiddleware.js +15 -97
  61. package/build/esm/vite/autoInstrumentMiddleware.js.map +1 -1
  62. package/build/esm/vite/routePatterns.js +57 -0
  63. package/build/esm/vite/routePatterns.js.map +1 -0
  64. package/build/esm/vite/sentryTanstackStart.js +8 -44
  65. package/build/esm/vite/sentryTanstackStart.js.map +1 -1
  66. package/build/esm/vite/sourceMaps.js +34 -75
  67. package/build/esm/vite/sourceMaps.js.map +1 -1
  68. package/build/esm/vite/tunnelRoute.js +30 -63
  69. package/build/esm/vite/tunnelRoute.js.map +1 -1
  70. package/build/types/client/sdk.d.ts.map +1 -1
  71. package/build/types/index.types.d.ts +1 -0
  72. package/build/types/index.types.d.ts.map +1 -1
  73. package/build/types/server/globalMiddleware.d.ts.map +1 -1
  74. package/build/types/server/index.d.ts +5 -0
  75. package/build/types/server/index.d.ts.map +1 -1
  76. package/build/types/server/routeParametrization.d.ts +12 -0
  77. package/build/types/server/routeParametrization.d.ts.map +1 -0
  78. package/build/types/server/sdk.d.ts.map +1 -1
  79. package/build/types/server/utils.d.ts +0 -9
  80. package/build/types/server/utils.d.ts.map +1 -1
  81. package/build/types/server/wrapFetchWithSentry.d.ts.map +1 -1
  82. package/build/types/vite/routePatterns.d.ts +18 -0
  83. package/build/types/vite/routePatterns.d.ts.map +1 -0
  84. package/build/types/vite/sentryTanstackStart.d.ts +17 -0
  85. package/build/types/vite/sentryTanstackStart.d.ts.map +1 -1
  86. package/build/types/vite/sourceMaps.d.ts +4 -4
  87. package/build/types/vite/sourceMaps.d.ts.map +1 -1
  88. package/build/types-ts3.8/index.types.d.ts +1 -0
  89. package/build/types-ts3.8/server/index.d.ts +5 -0
  90. package/build/types-ts3.8/server/routeParametrization.d.ts +12 -0
  91. package/build/types-ts3.8/server/utils.d.ts +0 -9
  92. package/build/types-ts3.8/vite/routePatterns.d.ts +18 -0
  93. package/build/types-ts3.8/vite/sentryTanstackStart.d.ts +17 -0
  94. package/build/types-ts3.8/vite/sourceMaps.d.ts +4 -4
  95. package/package.json +5 -5
@@ -0,0 +1,60 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const fs = require('node:fs');
4
+ const path = require('node:path');
5
+
6
+ function makeRoutePatternPlugin() {
7
+ let resolvedRoot = "";
8
+ return {
9
+ name: "sentry-tanstackstart-route-patterns",
10
+ enforce: "post",
11
+ configResolved(config) {
12
+ resolvedRoot = config.root || process.cwd();
13
+ },
14
+ transform(code, id) {
15
+ if (!code.includes("__SENTRY_ROUTE_PATTERNS__")) {
16
+ return null;
17
+ }
18
+ const routeTreePath = path.resolve(resolvedRoot, "src/routeTree.gen.ts");
19
+ let patterns = [];
20
+ try {
21
+ if (fs.existsSync(routeTreePath)) {
22
+ patterns = extractRoutePatterns(fs.readFileSync(routeTreePath, "utf-8"));
23
+ }
24
+ } catch {
25
+ }
26
+ return {
27
+ code: code.replace(/__SENTRY_ROUTE_PATTERNS__/g, JSON.stringify(patterns)),
28
+ map: null
29
+ };
30
+ }
31
+ };
32
+ }
33
+ function extractRoutePatterns(content) {
34
+ const fullPathsMatch = content.match(/fullPaths:\s*([\s\S]*?)(?:\n\s*\w|\n\})/);
35
+ if (!fullPathsMatch) {
36
+ return [];
37
+ }
38
+ const patterns = [];
39
+ const pathRegex = /['"]([^'"]+)['"]/g;
40
+ let match;
41
+ while ((match = pathRegex.exec(fullPathsMatch[1] || "")) !== null) {
42
+ if (match[1]) {
43
+ patterns.push(match[1]);
44
+ }
45
+ }
46
+ return [...new Set(patterns)].sort((a, b) => {
47
+ const aSegments = a.split("/");
48
+ const bSegments = b.split("/");
49
+ if (bSegments.length !== aSegments.length) {
50
+ return bSegments.length - aSegments.length;
51
+ }
52
+ const aDynamic = aSegments.filter((s) => s.startsWith("$")).length;
53
+ const bDynamic = bSegments.filter((s) => s.startsWith("$")).length;
54
+ return aDynamic - bDynamic;
55
+ });
56
+ }
57
+
58
+ exports.extractRoutePatterns = extractRoutePatterns;
59
+ exports.makeRoutePatternPlugin = makeRoutePatternPlugin;
60
+ //# sourceMappingURL=routePatterns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routePatterns.js","sources":["../../../src/vite/routePatterns.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport type { Plugin } from 'vite';\n\n/**\n * Extracts route patterns from TanStack Start's generated routeTree.gen.ts\n * and replaces `__SENTRY_ROUTE_PATTERNS__` references with the extracted patterns.\n *\n * The route tree file is read during `transform` rather than `config` because\n * TanStack Start generates it during the build.\n */\nexport function makeRoutePatternPlugin(): Plugin {\n let resolvedRoot = '';\n\n return {\n name: 'sentry-tanstackstart-route-patterns',\n enforce: 'post',\n\n configResolved(config) {\n resolvedRoot = config.root || process.cwd();\n },\n\n transform(code, id) {\n // this is set in the `wrapFetchWithSentry` where the paths are getting replaced by their parametrized counterparts\n // so this extraction should only happen once during the build (for the `wrapFetchWithSentry` file)\n if (!code.includes('__SENTRY_ROUTE_PATTERNS__')) {\n return null;\n }\n\n // extract the patterns from the route tree file\n const routeTreePath = path.resolve(resolvedRoot, 'src/routeTree.gen.ts');\n let patterns: string[] = [];\n try {\n if (fs.existsSync(routeTreePath)) {\n patterns = extractRoutePatterns(fs.readFileSync(routeTreePath, 'utf-8'));\n }\n } catch {\n // skip\n }\n\n return {\n code: code.replace(/__SENTRY_ROUTE_PATTERNS__/g, JSON.stringify(patterns)),\n map: null,\n };\n },\n };\n}\n\n/**\n * Extracts full route path patterns from the content of routeTree.gen.ts.\n *\n * Parses the `fullPaths` type union which contains the resolved full paths\n * (e.g., `fullPaths: '/' | '/page-a' | '/users/$userId'`).\n * This is more reliable than `path:` properties which can be relative for nested routes.\n */\nexport function extractRoutePatterns(content: string): string[] {\n const fullPathsMatch = content.match(/fullPaths:\\s*([\\s\\S]*?)(?:\\n\\s*\\w|\\n\\})/);\n if (!fullPathsMatch) {\n return [];\n }\n\n const patterns: string[] = [];\n const pathRegex = /['\"]([^'\"]+)['\"]/g;\n let match;\n while ((match = pathRegex.exec(fullPathsMatch[1] || '')) !== null) {\n if (match[1]) {\n patterns.push(match[1]);\n }\n }\n\n return [...new Set(patterns)].sort((a, b) => {\n const aSegments = a.split('/');\n const bSegments = b.split('/');\n if (bSegments.length !== aSegments.length) {\n return bSegments.length - aSegments.length;\n }\n const aDynamic = aSegments.filter(s => s.startsWith('$')).length;\n const bDynamic = bSegments.filter(s => s.startsWith('$')).length;\n return aDynamic - bDynamic;\n });\n}\n"],"names":[],"mappings":";;;;;AAWO,SAAS,sBAAA,GAAiC;AAC/C,EAAA,IAAI,YAAA,GAAe,EAAA;AAEnB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,qCAAA;AAAA,IACN,OAAA,EAAS,MAAA;AAAA,I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AAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAA;AAAA,IACxB;AAAA,EACF;AAEA,EAAA,OAAO,CAAC,GAAG,IAAI,GAAA,CAAI,QAAQ,CAAC,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,EAAG,CAAA,KAAM;AAC3C,IAAA,MAAM,SAAA,GAAY,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA;AAC7B,IAAA,MAAM,SAAA,GAAY,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA;AAC7B,IAAA,IAAI,SAAA,CAAU,MAAA,KAAW,SAAA,CAAU,MAAA,EAAQ;AACzC,MAAA,OAAO,SAAA,CAAU,SAAS,SAAA,CAAU,MAAA;AAAA,IACtC;AACA,IAAA,MAAM,QAAA,GAAW,UAAU,MAAA,CAAO,CAAA,CAAA,KAAK,EAAE,UAAA,CAAW,GAAG,CAAC,CAAA,CAAE,MAAA;AAC1D,IAAA,MAAM,QAAA,GAAW,UAAU,MAAA,CAAO,CAAA,CAAA,KAAK,EAAE,UAAA,CAAW,GAAG,CAAC,CAAA,CAAE,MAAA;AAC1D,IAAA,OAAO,QAAA,GAAW,QAAA;AAAA,EACpB,CAAC,CAAA;AACH;;;;;"}
@@ -1,62 +1,26 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const autoInstrumentMiddleware = require('./autoInstrumentMiddleware.js');
4
+ const routePatterns = require('./routePatterns.js');
4
5
  const sourceMaps = require('./sourceMaps.js');
5
6
  const tunnelRoute = require('./tunnelRoute.js');
6
7
 
7
- /**
8
- * Build-time options for the Sentry TanStack Start SDK.
9
- */
10
-
11
- /**
12
- * Vite plugins for the Sentry TanStack Start SDK.
13
- *
14
- * @example
15
- * ```typescript
16
- * // vite.config.ts
17
- * import { defineConfig } from 'vite';
18
- * import { sentryTanstackStart } from '@sentry/tanstackstart-react/vite';
19
- * import { tanstackStart } from '@tanstack/react-start/plugin/vite';
20
- *
21
- * export default defineConfig({
22
- * plugins: [
23
- * tanstackStart(),
24
- * sentryTanstackStart({
25
- * org: 'your-org',
26
- * project: 'your-project',
27
- * }),
28
- * ],
29
- * });
30
- * ```
31
- *
32
- * @param options - Options to configure the Sentry Vite plugins
33
- * @returns An array of Vite plugins
34
- */
35
8
  function sentryTanstackStart(options = {}) {
36
- const tunnelRoutePlugin = options.tunnelRoute ? tunnelRoute.makeTunnelRoutePlugin(options.tunnelRoute, options.debug) : undefined;
37
-
38
- // only add build-time plugins in production builds
39
- if (process.env.NODE_ENV === 'development') {
40
- return tunnelRoutePlugin ? [tunnelRoutePlugin] : [];
9
+ const plugins = [routePatterns.makeRoutePatternPlugin()];
10
+ if (options.tunnelRoute) {
11
+ plugins.push(tunnelRoute.makeTunnelRoutePlugin(options.tunnelRoute, options.debug));
41
12
  }
42
-
43
- const plugins = [...sourceMaps.makeAddSentryVitePlugin(options)];
44
-
45
- if (tunnelRoutePlugin) {
46
- plugins.push(tunnelRoutePlugin);
13
+ if (process.env.NODE_ENV === "development") {
14
+ return plugins;
47
15
  }
48
-
49
- // middleware auto-instrumentation
16
+ plugins.push(...sourceMaps.makeAddSentryVitePlugin(options));
50
17
  if (options.autoInstrumentMiddleware !== false) {
51
18
  plugins.push(autoInstrumentMiddleware.makeAutoInstrumentMiddlewarePlugin({ enabled: true, debug: options.debug }));
52
19
  }
53
-
54
- // source maps
55
- const sourceMapsDisabled = options.sourcemaps?.disable === true || options.sourcemaps?.disable === 'disable-upload';
20
+ const sourceMapsDisabled = options.sourcemaps?.disable === true || options.sourcemaps?.disable === "disable-upload";
56
21
  if (!sourceMapsDisabled) {
57
22
  plugins.push(...sourceMaps.makeEnableSourceMapsVitePlugin(options));
58
23
  }
59
-
60
24
  return plugins;
61
25
  }
62
26
 
@@ -1 +1 @@
1
- {"version":3,"file":"sentryTanstackStart.js","sources":["../../../src/vite/sentryTanstackStart.ts"],"sourcesContent":["import type { BuildTimeOptionsBase } from '@sentry/core';\nimport type { Plugin } from 'vite';\nimport { makeAutoInstrumentMiddlewarePlugin } from './autoInstrumentMiddleware';\nimport { makeAddSentryVitePlugin, makeEnableSourceMapsVitePlugin } from './sourceMaps';\nimport type { TunnelRouteOptions } from './tunnelRoute';\nimport { makeTunnelRoutePlugin } from './tunnelRoute';\n\n/**\n * Build-time options for the Sentry TanStack Start SDK.\n */\nexport interface SentryTanstackStartOptions extends BuildTimeOptionsBase {\n /**\n * If this flag is `true`, the Sentry plugins will automatically instrument TanStack Start middlewares.\n *\n * This wraps global middlewares (`requestMiddleware` and `functionMiddleware`) in `createStart()` with Sentry\n * instrumentation to capture performance data.\n *\n * Set to `false` to disable automatic middleware instrumentation if you prefer to wrap middlewares manually\n * using `wrapMiddlewaresWithSentry`.\n *\n * @default true\n */\n autoInstrumentMiddleware?: boolean;\n\n /**\n * Configures a framework-managed same-origin tunnel route for Sentry envelopes.\n *\n * This creates a TanStack Start server route backed by `createSentryTunnelRoute()` and applies the resulting path\n * as the default `tunnel` option on the client.\n *\n * You can pass:\n * - `true` to generate an opaque route path per dev session or production build.\n * - `'/custom-path'` to use a fixed static route path.\n * - `{ allowedDsns, path }` for full control. If `allowedDsns` is omitted or empty, the tunnel route derives the DSN\n * from the active server Sentry client at runtime.\n *\n * If you also pass `tunnel` to `Sentry.init()`, that explicit runtime option wins and a warning is emitted because\n * the managed tunnel route is being bypassed.\n */\n tunnelRoute?: TunnelRouteOptions;\n}\n\n/**\n * Vite plugins for the Sentry TanStack Start SDK.\n *\n * @example\n * ```typescript\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import { sentryTanstackStart } from '@sentry/tanstackstart-react/vite';\n * import { tanstackStart } from '@tanstack/react-start/plugin/vite';\n *\n * export default defineConfig({\n * plugins: [\n * tanstackStart(),\n * sentryTanstackStart({\n * org: 'your-org',\n * project: 'your-project',\n * }),\n * ],\n * });\n * ```\n *\n * @param options - Options to configure the Sentry Vite plugins\n * @returns An array of Vite plugins\n */\nexport function sentryTanstackStart(options: SentryTanstackStartOptions = {}): Plugin[] {\n const tunnelRoutePlugin = options.tunnelRoute ? makeTunnelRoutePlugin(options.tunnelRoute, options.debug) : undefined;\n\n // only add build-time plugins in production builds\n if (process.env.NODE_ENV === 'development') {\n return tunnelRoutePlugin ? [tunnelRoutePlugin] : [];\n }\n\n const plugins: Plugin[] = [...makeAddSentryVitePlugin(options)];\n\n if (tunnelRoutePlugin) {\n plugins.push(tunnelRoutePlugin);\n }\n\n // middleware auto-instrumentation\n if (options.autoInstrumentMiddleware !== false) {\n plugins.push(makeAutoInstrumentMiddlewarePlugin({ enabled: true, debug: options.debug }));\n }\n\n // source maps\n const sourceMapsDisabled = options.sourcemaps?.disable === true || options.sourcemaps?.disable === 'disable-upload';\n if (!sourceMapsDisabled) {\n plugins.push(...makeEnableSourceMapsVitePlugin(options));\n }\n\n return plugins;\n}\n"],"names":["makeTunnelRoutePlugin","makeAddSentryVitePlugin","makeAutoInstrumentMiddlewarePlugin","makeEnableSourceMapsVitePlugin"],"mappings":";;;;;;AAOA;AACA;AACA;;AAiCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,OAAO,GAA+B,EAAE,EAAY;AACxF,EAAE,MAAM,iBAAA,GAAoB,OAAO,CAAC,WAAA,GAAcA,iCAAqB,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAA,GAAI,SAAS;;AAEvH;AACA,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAA,KAAa,aAAa,EAAE;AAC9C,IAAI,OAAO,oBAAoB,CAAC,iBAAiB,CAAA,GAAI,EAAE;AACvD,EAAE;;AAEF,EAAE,MAAM,OAAO,GAAa,CAAC,GAAGC,kCAAuB,CAAC,OAAO,CAAC,CAAC;;AAEjE,EAAE,IAAI,iBAAiB,EAAE;AACzB,IAAI,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC;AACnC,EAAE;;AAEF;AACA,EAAE,IAAI,OAAO,CAAC,wBAAA,KAA6B,KAAK,EAAE;AAClD,IAAI,OAAO,CAAC,IAAI,CAACC,2DAAkC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAA,EAAO,CAAC,CAAC;AAC7F,EAAE;;AAEF;AACA,EAAE,MAAM,kBAAA,GAAqB,OAAO,CAAC,UAAU,EAAE,OAAA,KAAY,IAAA,IAAQ,OAAO,CAAC,UAAU,EAAE,OAAA,KAAY,gBAAgB;AACrH,EAAE,IAAI,CAAC,kBAAkB,EAAE;AAC3B,IAAI,OAAO,CAAC,IAAI,CAAC,GAAGC,yCAA8B,CAAC,OAAO,CAAC,CAAC;AAC5D,EAAE;;AAEF,EAAE,OAAO,OAAO;AAChB;;;;"}
1
+ {"version":3,"file":"sentryTanstackStart.js","sources":["../../../src/vite/sentryTanstackStart.ts"],"sourcesContent":["import type { BuildTimeOptionsBase } from '@sentry/core';\nimport type { Plugin } from 'vite';\nimport { makeAutoInstrumentMiddlewarePlugin } from './autoInstrumentMiddleware';\nimport { makeRoutePatternPlugin } from './routePatterns';\nimport { makeAddSentryVitePlugin, makeEnableSourceMapsVitePlugin } from './sourceMaps';\nimport type { TunnelRouteOptions } from './tunnelRoute';\nimport { makeTunnelRoutePlugin } from './tunnelRoute';\n\n/**\n * Build-time options for the Sentry TanStack Start SDK.\n */\nexport interface SentryTanstackStartOptions extends BuildTimeOptionsBase {\n /**\n * If this flag is `true`, the Sentry plugins will automatically instrument TanStack Start middlewares.\n *\n * This wraps global middlewares (`requestMiddleware` and `functionMiddleware`) in `createStart()` with Sentry\n * instrumentation to capture performance data.\n *\n * Set to `false` to disable automatic middleware instrumentation if you prefer to wrap middlewares manually\n * using `wrapMiddlewaresWithSentry`.\n *\n * @default true\n */\n autoInstrumentMiddleware?: boolean;\n\n /**\n * Options related to react component name annotations.\n * Disabled by default, unless a value is set for this option.\n * When enabled, your app's DOM will automatically be annotated during build-time with their respective component names.\n * This will unlock the capability to search for Replays in Sentry by component name, as well as see component names in breadcrumbs and performance monitoring.\n * Please note that this feature is not currently supported by the esbuild bundler plugins, and will only annotate React components\n */\n reactComponentAnnotation?: {\n /**\n * Whether the component name annotate plugin should be enabled or not.\n */\n enabled?: boolean;\n\n /**\n * A list of strings representing the names of components to ignore. The plugin will not apply `data-sentry` annotations on the DOM element for these components.\n */\n ignoredComponents?: string[];\n };\n\n /**\n * Configures a framework-managed same-origin tunnel route for Sentry envelopes.\n *\n * This creates a TanStack Start server route backed by `createSentryTunnelRoute()` and applies the resulting path\n * as the default `tunnel` option on the client.\n *\n * You can pass:\n * - `true` to generate an opaque route path per dev session or production build.\n * - `'/custom-path'` to use a fixed static route path.\n * - `{ allowedDsns, path }` for full control. If `allowedDsns` is omitted or empty, the tunnel route derives the DSN\n * from the active server Sentry client at runtime.\n *\n * If you also pass `tunnel` to `Sentry.init()`, that explicit runtime option wins and a warning is emitted because\n * the managed tunnel route is being bypassed.\n */\n tunnelRoute?: TunnelRouteOptions;\n}\n\n/**\n * Vite plugins for the Sentry TanStack Start SDK.\n *\n * @example\n * ```typescript\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import { sentryTanstackStart } from '@sentry/tanstackstart-react/vite';\n * import { tanstackStart } from '@tanstack/react-start/plugin/vite';\n *\n * export default defineConfig({\n * plugins: [\n * tanstackStart(),\n * sentryTanstackStart({\n * org: 'your-org',\n * project: 'your-project',\n * }),\n * ],\n * });\n * ```\n *\n * @param options - Options to configure the Sentry Vite plugins\n * @returns An array of Vite plugins\n */\nexport function sentryTanstackStart(options: SentryTanstackStartOptions = {}): Plugin[] {\n const plugins: Plugin[] = [makeRoutePatternPlugin()];\n\n if (options.tunnelRoute) {\n plugins.push(makeTunnelRoutePlugin(options.tunnelRoute, options.debug));\n }\n\n // only add build-time plugins in production builds\n if (process.env.NODE_ENV === 'development') {\n return plugins;\n }\n\n plugins.push(...makeAddSentryVitePlugin(options));\n\n // middleware auto-instrumentation\n if (options.autoInstrumentMiddleware !== false) {\n plugins.push(makeAutoInstrumentMiddlewarePlugin({ enabled: true, debug: options.debug }));\n }\n\n // source maps\n const sourceMapsDisabled = options.sourcemaps?.disable === true || options.sourcemaps?.disable === 'disable-upload';\n if (!sourceMapsDisabled) {\n plugins.push(...makeEnableSourceMapsVitePlugin(options));\n }\n\n return plugins;\n}\n"],"names":["makeRoutePatternPlugin","makeTunnelRoutePlugin","makeAddSentryVitePlugin","makeAutoInstrumentMiddlewarePlugin","makeEnableSourceMapsVitePlugin"],"mappings":";;;;;;;AAsFO,SAAS,mBAAA,CAAoB,OAAA,GAAsC,EAAC,EAAa;AACtF,EAAA,MAAM,OAAA,GAAoB,CAACA,oCAAA,EAAwB,CAAA;AAEnD,EAAA,IAAI,QAAQ,WAAA,EAAa;AACvB,IAAA,OAAA,CAAQ,KAAKC,iCAAA,CAAsB,OAAA,CAAQ,WAAA,EAAa,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EACxE;AAGA,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,aAAA,EAAe;AAC1C,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,OAAA,CAAQ,IAAA,CAAK,GAAGC,kCAAA,CAAwB,OAAO,CAAC,CAAA;AAGhD,EAAA,IAAI,OAAA,CAAQ,6BAA6B,KAAA,EAAO;AAC9C,IAAA,OAAA,CAAQ,IAAA,CAAKC,4DAAmC,EAAE,OAAA,EAAS,MAAM,KAAA,EAAO,OAAA,CAAQ,KAAA,EAAO,CAAC,CAAA;AAAA,EAC1F;AAGA,EAAA,MAAM,qBAAqB,OAAA,CAAQ,UAAA,EAAY,YAAY,IAAA,IAAQ,OAAA,CAAQ,YAAY,OAAA,KAAY,gBAAA;AACnG,EAAA,IAAI,CAAC,kBAAA,EAAoB;AACvB,IAAA,OAAA,CAAQ,IAAA,CAAK,GAAGC,yCAAA,CAA+B,OAAO,CAAC,CAAA;AAAA,EACzD;AAEA,EAAA,OAAO,OAAA;AACT;;;;"}
@@ -2,9 +2,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const vitePlugin = require('@sentry/vite-plugin');
4
4
 
5
- /**
6
- * A Sentry plugin for adding the @sentry/vite-plugin to automatically upload source maps to Sentry.
7
- */
8
5
  function makeAddSentryVitePlugin(options) {
9
6
  const {
10
7
  applicationKey,
@@ -20,40 +17,34 @@ function makeAddSentryVitePlugin(options) {
20
17
  silent,
21
18
  sourcemaps,
22
19
  telemetry,
20
+ reactComponentAnnotation
23
21
  } = options;
24
-
25
- // defer resolving the filesToDeleteAfterUpload until we got access to the Vite config
26
22
  let resolveFilesToDeleteAfterUpload;
27
- const filesToDeleteAfterUploadPromise = new Promise(resolve => {
23
+ const filesToDeleteAfterUploadPromise = new Promise((resolve) => {
28
24
  resolveFilesToDeleteAfterUpload = resolve;
29
25
  });
30
-
31
26
  const configPlugin = {
32
- name: 'sentry-tanstackstart-files-to-delete-after-upload-plugin',
33
- apply: 'build',
34
- enforce: 'post',
27
+ name: "sentry-tanstackstart-files-to-delete-after-upload-plugin",
28
+ apply: "build",
29
+ enforce: "post",
35
30
  config(config) {
36
31
  const userFilesToDelete = sourcemaps?.filesToDeleteAfterUpload;
37
-
38
- // Only auto-delete source maps if the user didn't configure sourcemaps at all
39
- if (typeof userFilesToDelete === 'undefined' && typeof config.build?.sourcemap === 'undefined') {
32
+ if (typeof userFilesToDelete === "undefined" && typeof config.build?.sourcemap === "undefined") {
40
33
  if (debug) {
41
- // eslint-disable-next-line no-console
42
34
  console.log(
43
- '[Sentry] Automatically setting `sourcemaps.filesToDeleteAfterUpload: ["./**/*.map"]` to delete generated source maps after they were uploaded to Sentry.',
35
+ '[Sentry] Automatically setting `sourcemaps.filesToDeleteAfterUpload: ["./**/*.map"]` to delete generated source maps after they were uploaded to Sentry.'
44
36
  );
45
37
  }
46
- resolveFilesToDeleteAfterUpload?.(['./**/*.map']);
38
+ resolveFilesToDeleteAfterUpload?.(["./**/*.map"]);
47
39
  } else {
48
40
  resolveFilesToDeleteAfterUpload?.(userFilesToDelete);
49
41
  }
50
- },
42
+ }
51
43
  };
52
-
53
44
  const sentryPlugins = vitePlugin.sentryVitePlugin({
54
45
  applicationKey,
55
46
  authToken: authToken ?? process.env.SENTRY_AUTH_TOKEN,
56
- bundleSizeOptimizations: bundleSizeOptimizations ?? undefined,
47
+ bundleSizeOptimizations: bundleSizeOptimizations ?? void 0,
57
48
  debug: debug ?? false,
58
49
  errorHandler,
59
50
  headers,
@@ -67,101 +58,69 @@ function makeAddSentryVitePlugin(options) {
67
58
  ignore: sourcemaps?.ignore,
68
59
  // BuildTimeOptionsBase types can lag behind bundler plugin options in some local setups.
69
60
  // Keep runtime support while staying resilient to type version skew.
70
- rewriteSources: (sourcemaps )?.rewriteSources ,
71
- filesToDeleteAfterUpload: filesToDeleteAfterUploadPromise,
61
+ rewriteSources: sourcemaps?.rewriteSources,
62
+ filesToDeleteAfterUpload: filesToDeleteAfterUploadPromise
63
+ },
64
+ reactComponentAnnotation: {
65
+ enabled: reactComponentAnnotation?.enabled ?? void 0,
66
+ ignoredComponents: reactComponentAnnotation?.ignoredComponents ?? void 0
72
67
  },
73
68
  telemetry: telemetry ?? true,
74
69
  url: sentryUrl,
75
70
  _metaOptions: {
76
71
  telemetry: {
77
- metaFramework: 'tanstackstart-react',
78
- },
79
- },
72
+ metaFramework: "tanstackstart-react"
73
+ }
74
+ }
80
75
  });
81
-
82
76
  return [configPlugin, ...sentryPlugins];
83
77
  }
84
-
85
- /**
86
- * A Sentry plugin for TanStack Start React to enable "hidden" source maps if they are unset.
87
- */
88
78
  function makeEnableSourceMapsVitePlugin(options) {
89
79
  return [
90
80
  {
91
- name: 'sentry-tanstackstart-react-source-maps',
92
- apply: 'build',
93
- enforce: 'post',
81
+ name: "sentry-tanstackstart-react-source-maps",
82
+ apply: "build",
83
+ enforce: "post",
94
84
  config(viteConfig) {
95
85
  return {
96
86
  ...viteConfig,
97
87
  build: {
98
88
  ...viteConfig.build,
99
- sourcemap: getUpdatedSourceMapSettings(viteConfig, options),
100
- },
89
+ sourcemap: getUpdatedSourceMapSettings(viteConfig, options)
90
+ }
101
91
  };
102
- },
103
- },
92
+ }
93
+ }
104
94
  ];
105
95
  }
106
-
107
- /** There are 3 ways to set up source map generation (https://github.com/getsentry/sentry-javascript/issues/13993)
108
- *
109
- * 1. User explicitly disabled source maps
110
- * - keep this setting (emit a warning that errors won't be unminified in Sentry)
111
- * - We won't upload anything
112
- *
113
- * 2. Users enabled source map generation (true, 'hidden', 'inline').
114
- * - keep this setting (don't do anything - like deletion - besides uploading)
115
- *
116
- * 3. Users didn't set source maps generation
117
- * - we enable 'hidden' source maps generation
118
- * - configure `filesToDeleteAfterUpload` to delete all .map files (we emit a log about this)
119
- *
120
- * --> only exported for testing
121
- */
122
- function getUpdatedSourceMapSettings(
123
- viteConfig,
124
- sentryPluginOptions,
125
- ) {
96
+ function getUpdatedSourceMapSettings(viteConfig, sentryPluginOptions) {
126
97
  viteConfig.build = viteConfig.build || {};
127
-
128
98
  const viteUserSourceMapSetting = viteConfig.build?.sourcemap;
129
- const settingKey = 'vite.build.sourcemap';
99
+ const settingKey = "vite.build.sourcemap";
130
100
  const debug = sentryPluginOptions?.debug;
131
-
132
- // Respect user source map setting if it is explicitly set
133
101
  if (viteUserSourceMapSetting === false) {
134
102
  if (debug) {
135
- // eslint-disable-next-line no-console
136
103
  console.warn(
137
- `[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.`,
104
+ `[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.`
138
105
  );
139
106
  } else {
140
- // eslint-disable-next-line no-console
141
- console.warn('[Sentry] Source map generation is disabled in your TanStack Start configuration.');
107
+ console.warn("[Sentry] Source map generation is disabled in your TanStack Start configuration.");
142
108
  }
143
-
144
109
  return viteUserSourceMapSetting;
145
- } else if (viteUserSourceMapSetting && ['hidden', 'inline', true].includes(viteUserSourceMapSetting)) {
110
+ } else if (viteUserSourceMapSetting && ["hidden", "inline", true].includes(viteUserSourceMapSetting)) {
146
111
  if (debug) {
147
- // eslint-disable-next-line no-console
148
112
  console.log(
149
- `[Sentry] We discovered \`${settingKey}\` is set to \`${viteUserSourceMapSetting.toString()}\`. Sentry will keep this source map setting.`,
113
+ `[Sentry] We discovered \`${settingKey}\` is set to \`${viteUserSourceMapSetting.toString()}\`. Sentry will keep this source map setting.`
150
114
  );
151
115
  }
152
-
153
116
  return viteUserSourceMapSetting;
154
117
  }
155
-
156
- // If the user did not specify a source map setting, we enable 'hidden' by default
157
118
  if (debug) {
158
- // eslint-disable-next-line no-console
159
119
  console.log(
160
- `[Sentry] Enabled source map generation in the build options with \`${settingKey}: 'hidden'\`. The source maps will be deleted after they were uploaded to Sentry.`,
120
+ `[Sentry] Enabled source map generation in the build options with \`${settingKey}: 'hidden'\`. The source maps will be deleted after they were uploaded to Sentry.`
161
121
  );
162
122
  }
163
-
164
- return 'hidden';
123
+ return "hidden";
165
124
  }
166
125
 
167
126
  exports.getUpdatedSourceMapSettings = getUpdatedSourceMapSettings;
@@ -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":";;;;AAMA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,OAAO,EAAkC;AACjF,EAAE,MAAM;AACR,IAAI,cAAc;AAClB,IAAI,SAAS;AACb,IAAI,uBAAuB;AAC3B,IAAI,KAAK;AACT,IAAI,YAAY;AAChB,IAAI,OAAO;AACX,IAAI,GAAG;AACP,IAAI,OAAO;AACX,IAAI,OAAO;AACX,IAAI,SAAS;AACb,IAAI,MAAM;AACV,IAAI,UAAU;AACd,IAAI,SAAS;AACb,GAAE,GAAI,OAAO;;AAEb;AACA,EAAE,IAAI,+BAA+B;AACrC,EAAE,MAAM,+BAAA,GAAkC,IAAI,OAAO,CAA2B,WAAW;AAC3F,IAAI,+BAAA,GAAkC,OAAO;AAC7C,EAAE,CAAC,CAAC;;AAEJ,EAAE,MAAM,YAAY,GAAW;AAC/B,IAAI,IAAI,EAAE,0DAA0D;AACpE,IAAI,KAAK,EAAE,OAAO;AAClB,IAAI,OAAO,EAAE,MAAM;AACnB,IAAI,MAAM,CAAC,MAAM,EAAE;AACnB,MAAM,MAAM,iBAAA,GAAoB,UAAU,EAAE,wBAAwB;;AAEpE;AACA,MAAM,IAAI,OAAO,iBAAA,KAAsB,WAAA,IAAe,OAAO,MAAM,CAAC,KAAK,EAAE,SAAA,KAAc,WAAW,EAAE;AACtG,QAAQ,IAAI,KAAK,EAAE;AACnB;AACA,UAAU,OAAO,CAAC,GAAG;AACrB,YAAY,0JAA0J;AACtK,WAAW;AACX,QAAQ;AACR,QAAQ,+BAA+B,GAAG,CAAC,YAAY,CAAC,CAAC;AACzD,MAAM,OAAO;AACb,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,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
+ {"version":3,"file":"sourceMaps.js","sources":["../../../src/vite/sourceMaps.ts"],"sourcesContent":["import { sentryVitePlugin } from '@sentry/vite-plugin';\nimport type { Plugin, UserConfig } from 'vite';\nimport type { SentryTanstackStartOptions } from './sentryTanstackStart';\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: SentryTanstackStartOptions): 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 reactComponentAnnotation,\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 reactComponentAnnotation: {\n enabled: reactComponentAnnotation?.enabled ?? undefined,\n ignoredComponents: reactComponentAnnotation?.ignoredComponents ?? undefined,\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: SentryTanstackStartOptions): 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?: SentryTanstackStartOptions,\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,EAA+C;AACrF,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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O;AAET,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN,gGAAgG,UAAU,CAAA,kIAAA;AAAA,OAC5G;AAAA,IACF,CAAA,MAAO;AAEL,MAAA,OAAA,CAAQ,KAAK,kFAAkF,CAAA;AAAA,IACjG;AAEA,IAAA,OAAO,wBAAA;AAAA,EACT,CAAA,MAAA,IAAW,4BAA4B,CAAC,QAAA,EAAU,UAAU,IAAI,CAAA,CAAE,QAAA,CAAS,wBAAwB,CAAA,EAAG;AACpG,IAAA,IAAI,KAAA,EAAO;AAET,MAAA,OAAA,CAAQ,GAAA;AAAA,QACN,CAAA,yBAAA,EAA4B,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 = 'SentryManagedTunnelRouteImport';
4
- const MANAGED_TUNNEL_ROUTE_NAME = 'SentryManagedTunnelRoute';
5
- const MANAGED_TUNNEL_ROUTE_PATH_ENV_KEY = '__SENTRY_INTERNAL_TANSTACKSTART_TUNNEL_ROUTE__';
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 === 'string') {
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('/') || path.includes('?') || path.includes('#')) {
24
+ if (!path.startsWith("/") || path.includes("?") || path.includes("#")) {
32
25
  throw new Error(
33
- '[@sentry/tanstackstart-react] `tunnelRoute` static paths must start with `/` and must not contain query or hash segments.',
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: undefined };
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: undefined,
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
- '[@sentry/tanstackstart-react] Failed to inject the managed tunnel route because `routeTree.gen.ts` imports could not be located.',
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)}\n${statement}${source.slice(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
- '[@sentry/tanstackstart-react] Failed to inject the managed tunnel route because the generated TanStack route tree did not contain `rootRouteChildren`.',
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) : undefined;
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: 'sentry-tanstackstart-tunnel-route',
140
- enforce: 'pre',
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('/routeTree.gen.ts') && !id.endsWith('\\routeTree.gen.ts')) {
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