@sentry/tanstackstart-react 10.36.0 → 10.38.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.
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const index = require('./client/index.js');
4
- const sdk = require('./client/sdk.js');
5
4
  const react = require('@sentry/react');
5
+ const sdk = require('./client/sdk.js');
6
6
 
7
7
 
8
8
 
@@ -2,10 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const index = require('./server/index.js');
4
4
  const sentryTanstackStart = require('./vite/sentryTanstackStart.js');
5
+ const node = require('@sentry/node');
5
6
  const sdk = require('./server/sdk.js');
6
7
  const wrapFetchWithSentry = require('./server/wrapFetchWithSentry.js');
7
8
  const middleware = require('./server/middleware.js');
8
- const node = require('@sentry/node');
9
9
 
10
10
 
11
11
 
@@ -0,0 +1,177 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ /**
4
+ * Core function that wraps middleware arrays matching the given regex.
5
+ */
6
+ function wrapMiddlewareArrays(code, id, debug, regex) {
7
+ const skipped = [];
8
+ let didWrap = false;
9
+
10
+ const transformed = code.replace(regex, (match, key, contents) => {
11
+ const objContents = arrayToObjectShorthand(contents);
12
+ if (objContents) {
13
+ didWrap = true;
14
+ if (debug) {
15
+ // eslint-disable-next-line no-console
16
+ console.log(`[Sentry] Auto-wrapping ${key} in ${id}`);
17
+ }
18
+ return `${key}: wrapMiddlewaresWithSentry(${objContents})`;
19
+ }
20
+ // Track middlewares that couldn't be auto-wrapped
21
+ // Skip if we matched whitespace only
22
+ if (contents.trim()) {
23
+ skipped.push(key);
24
+ }
25
+ return match;
26
+ });
27
+
28
+ return { code: transformed, didWrap, skipped };
29
+ }
30
+
31
+ /**
32
+ * Wraps global middleware arrays (requestMiddleware, functionMiddleware) in createStart() files.
33
+ */
34
+ function wrapGlobalMiddleware(code, id, debug) {
35
+ return wrapMiddlewareArrays(code, id, debug, /(requestMiddleware|functionMiddleware)\s*:\s*\[([^\]]*)\]/g);
36
+ }
37
+
38
+ /**
39
+ * Wraps route middleware arrays in createFileRoute() files.
40
+ */
41
+ function wrapRouteMiddleware(code, id, debug) {
42
+ return wrapMiddlewareArrays(code, id, debug, /(middleware)\s*:\s*\[([^\]]*)\]/g);
43
+ }
44
+
45
+ /**
46
+ * A Vite plugin that automatically instruments TanStack Start middlewares:
47
+ * - `requestMiddleware` and `functionMiddleware` arrays in `createStart()`
48
+ * - `middleware` arrays in `createFileRoute()` route definitions
49
+ */
50
+ function makeAutoInstrumentMiddlewarePlugin(options = {}) {
51
+ const { enabled = true, debug = false } = options;
52
+
53
+ return {
54
+ name: 'sentry-tanstack-middleware-auto-instrument',
55
+ enforce: 'pre',
56
+
57
+ transform(code, id) {
58
+ if (!enabled) {
59
+ return null;
60
+ }
61
+
62
+ // Skip if not a TS/JS file
63
+ if (!/\.(ts|tsx|js|jsx|mjs|mts)$/.test(id)) {
64
+ return null;
65
+ }
66
+
67
+ // Detect file types that should be instrumented
68
+ const isStartFile = id.includes('start') && code.includes('createStart(');
69
+ const isRouteFile = code.includes('createFileRoute(') && /middleware\s*:\s*\[/.test(code);
70
+
71
+ if (!isStartFile && !isRouteFile) {
72
+ return null;
73
+ }
74
+
75
+ // Skip if the user already did some manual wrapping
76
+ if (code.includes('wrapMiddlewaresWithSentry')) {
77
+ return null;
78
+ }
79
+
80
+ let transformed = code;
81
+ let needsImport = false;
82
+ const skippedMiddlewares = [];
83
+
84
+ switch (true) {
85
+ // global middleware
86
+ case isStartFile: {
87
+ const result = wrapGlobalMiddleware(transformed, id, debug);
88
+ transformed = result.code;
89
+ needsImport = needsImport || result.didWrap;
90
+ skippedMiddlewares.push(...result.skipped);
91
+ break;
92
+ }
93
+ // route middleware
94
+ case isRouteFile: {
95
+ const result = wrapRouteMiddleware(transformed, id, debug);
96
+ transformed = result.code;
97
+ needsImport = needsImport || result.didWrap;
98
+ skippedMiddlewares.push(...result.skipped);
99
+ break;
100
+ }
101
+ }
102
+
103
+ // Warn about middlewares that couldn't be auto-wrapped
104
+ if (skippedMiddlewares.length > 0) {
105
+ // eslint-disable-next-line no-console
106
+ console.warn(
107
+ `[Sentry] Could not auto-instrument ${skippedMiddlewares.join(' and ')} in ${id}. ` +
108
+ 'To instrument these middlewares, use wrapMiddlewaresWithSentry() manually. ',
109
+ );
110
+ }
111
+
112
+ // We didn't wrap any middlewares, so we don't need to import the wrapMiddlewaresWithSentry function
113
+ if (!needsImport) {
114
+ return null;
115
+ }
116
+
117
+ transformed = addSentryImport(transformed);
118
+
119
+ return { code: transformed, map: null };
120
+ },
121
+ };
122
+ }
123
+
124
+ /**
125
+ * Convert array contents to object shorthand syntax.
126
+ * e.g., "foo, bar, baz" → "{ foo, bar, baz }"
127
+ *
128
+ * Returns null if contents contain non-identifier expressions (function calls, etc.)
129
+ * which cannot be converted to object shorthand.
130
+ */
131
+ function arrayToObjectShorthand(contents) {
132
+ const items = contents
133
+ .split(',')
134
+ .map(s => s.trim())
135
+ .filter(Boolean);
136
+
137
+ // Only convert if all items are valid identifiers (no complex expressions)
138
+ const allIdentifiers = items.every(item => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(item));
139
+ if (!allIdentifiers || items.length === 0) {
140
+ return null;
141
+ }
142
+
143
+ // Deduplicate to avoid invalid syntax like { foo, foo }
144
+ const uniqueItems = [...new Set(items)];
145
+
146
+ return `{ ${uniqueItems.join(', ')} }`;
147
+ }
148
+
149
+ /**
150
+ * Adds the wrapMiddlewaresWithSentry import to the code.
151
+ * Handles 'use client' and 'use server' directives by inserting the import after them.
152
+ */
153
+ function addSentryImport(code) {
154
+ const sentryImport = "import { wrapMiddlewaresWithSentry } from '@sentry/tanstackstart-react';\n";
155
+
156
+ // Don't add the import if it already exists
157
+ if (code.includes(sentryImport.trimEnd())) {
158
+ return code;
159
+ }
160
+
161
+ // Check for 'use server' or 'use client' directives, these need to be before any imports
162
+ const directiveMatch = code.match(/^(['"])use (client|server)\1;?\s*\n?/);
163
+
164
+ if (!directiveMatch) {
165
+ return sentryImport + code;
166
+ }
167
+
168
+ const directive = directiveMatch[0];
169
+ return directive + sentryImport + code.slice(directive.length);
170
+ }
171
+
172
+ exports.addSentryImport = addSentryImport;
173
+ exports.arrayToObjectShorthand = arrayToObjectShorthand;
174
+ exports.makeAutoInstrumentMiddlewarePlugin = makeAutoInstrumentMiddlewarePlugin;
175
+ exports.wrapGlobalMiddleware = wrapGlobalMiddleware;
176
+ exports.wrapRouteMiddleware = wrapRouteMiddleware;
177
+ //# sourceMappingURL=autoInstrumentMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoInstrumentMiddleware.js","sources":["../../../src/vite/autoInstrumentMiddleware.ts"],"sourcesContent":["import type { Plugin } from 'vite';\n\ntype AutoInstrumentMiddlewareOptions = {\n enabled?: boolean;\n debug?: boolean;\n};\n\ntype WrapResult = {\n code: string;\n didWrap: boolean;\n skipped: string[];\n};\n\n/**\n * Core function that wraps middleware arrays matching the given regex.\n */\nfunction wrapMiddlewareArrays(code: string, id: string, debug: boolean, regex: RegExp): WrapResult {\n const skipped: string[] = [];\n let didWrap = false;\n\n const transformed = code.replace(regex, (match: string, key: string, contents: string) => {\n const objContents = arrayToObjectShorthand(contents);\n if (objContents) {\n didWrap = true;\n if (debug) {\n // eslint-disable-next-line no-console\n console.log(`[Sentry] Auto-wrapping ${key} in ${id}`);\n }\n return `${key}: wrapMiddlewaresWithSentry(${objContents})`;\n }\n // Track middlewares that couldn't be auto-wrapped\n // Skip if we matched whitespace only\n if (contents.trim()) {\n skipped.push(key);\n }\n return match;\n });\n\n return { code: transformed, didWrap, skipped };\n}\n\n/**\n * Wraps global middleware arrays (requestMiddleware, functionMiddleware) in createStart() files.\n */\nexport function wrapGlobalMiddleware(code: string, id: string, debug: boolean): WrapResult {\n return wrapMiddlewareArrays(code, id, debug, /(requestMiddleware|functionMiddleware)\\s*:\\s*\\[([^\\]]*)\\]/g);\n}\n\n/**\n * Wraps route middleware arrays in createFileRoute() files.\n */\nexport function wrapRouteMiddleware(code: string, id: string, debug: boolean): WrapResult {\n return wrapMiddlewareArrays(code, id, debug, /(middleware)\\s*:\\s*\\[([^\\]]*)\\]/g);\n}\n\n/**\n * A Vite plugin that automatically instruments TanStack Start middlewares:\n * - `requestMiddleware` and `functionMiddleware` arrays in `createStart()`\n * - `middleware` arrays in `createFileRoute()` route definitions\n */\nexport function makeAutoInstrumentMiddlewarePlugin(options: AutoInstrumentMiddlewareOptions = {}): Plugin {\n const { enabled = true, debug = false } = options;\n\n return {\n name: 'sentry-tanstack-middleware-auto-instrument',\n enforce: 'pre',\n\n transform(code, id) {\n if (!enabled) {\n return null;\n }\n\n // Skip if not a TS/JS file\n if (!/\\.(ts|tsx|js|jsx|mjs|mts)$/.test(id)) {\n return null;\n }\n\n // Detect file types that should be instrumented\n const isStartFile = id.includes('start') && code.includes('createStart(');\n const isRouteFile = code.includes('createFileRoute(') && /middleware\\s*:\\s*\\[/.test(code);\n\n if (!isStartFile && !isRouteFile) {\n return null;\n }\n\n // Skip if the user already did some manual wrapping\n if (code.includes('wrapMiddlewaresWithSentry')) {\n return null;\n }\n\n let transformed = code;\n let needsImport = false;\n const skippedMiddlewares: string[] = [];\n\n switch (true) {\n // global middleware\n case isStartFile: {\n const result = wrapGlobalMiddleware(transformed, id, debug);\n transformed = result.code;\n needsImport = needsImport || result.didWrap;\n skippedMiddlewares.push(...result.skipped);\n break;\n }\n // route middleware\n case isRouteFile: {\n const result = wrapRouteMiddleware(transformed, id, debug);\n transformed = result.code;\n needsImport = needsImport || result.didWrap;\n skippedMiddlewares.push(...result.skipped);\n break;\n }\n default:\n break;\n }\n\n // Warn about middlewares that couldn't be auto-wrapped\n if (skippedMiddlewares.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Could not auto-instrument ${skippedMiddlewares.join(' and ')} in ${id}. ` +\n 'To instrument these middlewares, use wrapMiddlewaresWithSentry() manually. ',\n );\n }\n\n // We didn't wrap any middlewares, so we don't need to import the wrapMiddlewaresWithSentry function\n if (!needsImport) {\n return null;\n }\n\n transformed = addSentryImport(transformed);\n\n return { code: transformed, map: null };\n },\n };\n}\n\n/**\n * Convert array contents to object shorthand syntax.\n * e.g., \"foo, bar, baz\" → \"{ foo, bar, baz }\"\n *\n * Returns null if contents contain non-identifier expressions (function calls, etc.)\n * which cannot be converted to object shorthand.\n */\nexport function arrayToObjectShorthand(contents: string): string | null {\n const items = contents\n .split(',')\n .map(s => s.trim())\n .filter(Boolean);\n\n // Only convert if all items are valid identifiers (no complex expressions)\n const allIdentifiers = items.every(item => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(item));\n if (!allIdentifiers || items.length === 0) {\n return null;\n }\n\n // Deduplicate to avoid invalid syntax like { foo, foo }\n const uniqueItems = [...new Set(items)];\n\n return `{ ${uniqueItems.join(', ')} }`;\n}\n\n/**\n * Adds the wrapMiddlewaresWithSentry import to the code.\n * Handles 'use client' and 'use server' directives by inserting the import after them.\n */\nexport function addSentryImport(code: string): string {\n const sentryImport = \"import { wrapMiddlewaresWithSentry } from '@sentry/tanstackstart-react';\\n\";\n\n // Don't add the import if it already exists\n if (code.includes(sentryImport.trimEnd())) {\n return code;\n }\n\n // Check for 'use server' or 'use client' directives, these need to be before any imports\n const directiveMatch = code.match(/^(['\"])use (client|server)\\1;?\\s*\\n?/);\n\n if (!directiveMatch) {\n return sentryImport + code;\n }\n\n const directive = directiveMatch[0];\n return directive + sentryImport + code.slice(directive.length);\n}\n"],"names":[],"mappings":";;AAaA;AACA;AACA;AACA,SAAS,oBAAoB,CAAC,IAAI,EAAU,EAAE,EAAU,KAAK,EAAW,KAAK,EAAsB;AACnG,EAAE,MAAM,OAAO,GAAa,EAAE;AAC9B,EAAE,IAAI,OAAA,GAAU,KAAK;;AAErB,EAAE,MAAM,WAAA,GAAc,IAAI,CAAC,OAAO,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ACA;AACA;AACA,SAAA,eAAA,CAAA,IAAA,EAAA;AACA,EAAA,MAAA,YAAA,GAAA,4EAAA;;AAEA;AACA,EAAA,IAAA,IAAA,CAAA,QAAA,CAAA,YAAA,CAAA,OAAA,EAAA,CAAA,EAAA;AACA,IAAA,OAAA,IAAA;AACA,EAAA;;AAEA;AACA,EAAA,MAAA,cAAA,GAAA,IAAA,CAAA,KAAA,CAAA,sCAAA,CAAA;;AAEA,EAAA,IAAA,CAAA,cAAA,EAAA;AACA,IAAA,OAAA,YAAA,GAAA,IAAA;AACA,EAAA;;AAEA,EAAA,MAAA,SAAA,GAAA,cAAA,CAAA,CAAA,CAAA;AACA,EAAA,OAAA,SAAA,GAAA,YAAA,GAAA,IAAA,CAAA,KAAA,CAAA,SAAA,CAAA,MAAA,CAAA;AACA;;;;;;;;"}
@@ -1,7 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
+ const autoInstrumentMiddleware = require('./autoInstrumentMiddleware.js');
3
4
  const sourceMaps = require('./sourceMaps.js');
4
5
 
6
+ /**
7
+ * Build-time options for the Sentry TanStack Start SDK.
8
+ */
9
+
5
10
  /**
6
11
  * Vite plugins for the Sentry TanStack Start SDK.
7
12
  *
@@ -14,11 +19,11 @@ const sourceMaps = require('./sourceMaps.js');
14
19
  *
15
20
  * export default defineConfig({
16
21
  * plugins: [
22
+ * tanstackStart(),
17
23
  * sentryTanstackStart({
18
24
  * org: 'your-org',
19
25
  * project: 'your-project',
20
26
  * }),
21
- * tanstackStart(),
22
27
  * ],
23
28
  * });
24
29
  * ```
@@ -27,13 +32,19 @@ const sourceMaps = require('./sourceMaps.js');
27
32
  * @returns An array of Vite plugins
28
33
  */
29
34
  function sentryTanstackStart(options = {}) {
30
- // Only add plugins in production builds
35
+ // only add plugins in production builds
31
36
  if (process.env.NODE_ENV === 'development') {
32
37
  return [];
33
38
  }
34
39
 
35
40
  const plugins = [...sourceMaps.makeAddSentryVitePlugin(options)];
36
41
 
42
+ // middleware auto-instrumentation
43
+ if (options.autoInstrumentMiddleware !== false) {
44
+ plugins.push(autoInstrumentMiddleware.makeAutoInstrumentMiddlewarePlugin({ enabled: true, debug: options.debug }));
45
+ }
46
+
47
+ // source maps
37
48
  const sourceMapsDisabled = options.sourcemaps?.disable === true || options.sourcemaps?.disable === 'disable-upload';
38
49
  if (!sourceMapsDisabled) {
39
50
  plugins.push(...sourceMaps.makeEnableSourceMapsVitePlugin(options));
@@ -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 { makeAddSentryVitePlugin, makeEnableSourceMapsVitePlugin } from './sourceMaps';\n\n/**\n * Vite plugins for the Sentry TanStack Start SDK.\n *\n * @example\n * ```typescript\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import { sentryTanstackStart } from '@sentry/tanstackstart-react';\n * import { tanstackStart } from '@tanstack/react-start/plugin/vite';\n *\n * export default defineConfig({\n * plugins: [\n * sentryTanstackStart({\n * org: 'your-org',\n * project: 'your-project',\n * }),\n * tanstackStart(),\n * ],\n * });\n * ```\n *\n * @param options - Options to configure the Sentry Vite plugins\n * @returns An array of Vite plugins\n */\nexport function sentryTanstackStart(options: BuildTimeOptionsBase = {}): Plugin[] {\n // Only add plugins in production builds\n if (process.env.NODE_ENV === 'development') {\n return [];\n }\n\n const plugins: Plugin[] = [...makeAddSentryVitePlugin(options)];\n\n const sourceMapsDisabled = options.sourcemaps?.disable === true || options.sourcemaps?.disable === 'disable-upload';\n if (!sourceMapsDisabled) {\n plugins.push(...makeEnableSourceMapsVitePlugin(options));\n }\n\n return plugins;\n}\n"],"names":["makeAddSentryVitePlugin","makeEnableSourceMapsVitePlugin"],"mappings":";;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,OAAO,GAAyB,EAAE,EAAY;AAClF;AACA,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAA,KAAa,aAAa,EAAE;AAC9C,IAAI,OAAO,EAAE;AACb,EAAE;;AAEF,EAAE,MAAM,OAAO,GAAa,CAAC,GAAGA,kCAAuB,CAAC,OAAO,CAAC,CAAC;;AAEjE,EAAE,MAAM,kBAAA,GAAqB,OAAO,CAAC,UAAU,EAAE,OAAA,KAAY,IAAA,IAAQ,OAAO,CAAC,UAAU,EAAE,OAAA,KAAY,gBAAgB;AACrH,EAAE,IAAI,CAAC,kBAAkB,EAAE;AAC3B,IAAI,OAAO,CAAC,IAAI,CAAC,GAAGC,yCAA8B,CAAC,OAAO,CAAC,CAAC;AAC5D,EAAE;;AAEF,EAAE,OAAO,OAAO;AAChB;;;;"}
1
+ {"version":3,"file":"sentryTanstackStart.js","sources":["../../../src/vite/sentryTanstackStart.ts"],"sourcesContent":["import type { BuildTimeOptionsBase } from '@sentry/core';\nimport type { Plugin } from 'vite';\nimport { makeAutoInstrumentMiddlewarePlugin } from './autoInstrumentMiddleware';\nimport { makeAddSentryVitePlugin, makeEnableSourceMapsVitePlugin } from './sourceMaps';\n\n/**\n * Build-time options for the Sentry TanStack Start SDK.\n */\nexport interface SentryTanstackStartOptions extends BuildTimeOptionsBase {\n /**\n * If this flag is `true`, the Sentry plugins will automatically instrument TanStack Start middlewares.\n *\n * This wraps global middlewares (`requestMiddleware` and `functionMiddleware`) in `createStart()` with Sentry\n * instrumentation to capture performance data.\n *\n * Set to `false` to disable automatic middleware instrumentation if you prefer to wrap middlewares manually\n * using `wrapMiddlewaresWithSentry`.\n *\n * @default true\n */\n autoInstrumentMiddleware?: boolean;\n}\n\n/**\n * Vite plugins for the Sentry TanStack Start SDK.\n *\n * @example\n * ```typescript\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import { sentryTanstackStart } from '@sentry/tanstackstart-react';\n * import { tanstackStart } from '@tanstack/react-start/plugin/vite';\n *\n * export default defineConfig({\n * plugins: [\n * tanstackStart(),\n * sentryTanstackStart({\n * org: 'your-org',\n * project: 'your-project',\n * }),\n * ],\n * });\n * ```\n *\n * @param options - Options to configure the Sentry Vite plugins\n * @returns An array of Vite plugins\n */\nexport function sentryTanstackStart(options: SentryTanstackStartOptions = {}): Plugin[] {\n // only add plugins in production builds\n if (process.env.NODE_ENV === 'development') {\n return [];\n }\n\n const plugins: Plugin[] = [...makeAddSentryVitePlugin(options)];\n\n // middleware auto-instrumentation\n if (options.autoInstrumentMiddleware !== false) {\n plugins.push(makeAutoInstrumentMiddlewarePlugin({ enabled: true, debug: options.debug }));\n }\n\n // source maps\n const sourceMapsDisabled = options.sourcemaps?.disable === true || options.sourcemaps?.disable === 'disable-upload';\n if (!sourceMapsDisabled) {\n plugins.push(...makeEnableSourceMapsVitePlugin(options));\n }\n\n return plugins;\n}\n"],"names":["makeAddSentryVitePlugin","makeAutoInstrumentMiddlewarePlugin","makeEnableSourceMapsVitePlugin"],"mappings":";;;;;AAKA;AACA;AACA;;AAgBA;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;AACA,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAA,KAAa,aAAa,EAAE;AAC9C,IAAI,OAAO,EAAE;AACb,EAAE;;AAEF,EAAE,MAAM,OAAO,GAAa,CAAC,GAAGA,kCAAuB,CAAC,OAAO,CAAC,CAAC;;AAEjE;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,4 +1,4 @@
1
1
  export { wrapMiddlewaresWithSentry } from './client/index.js';
2
- export { init } from './client/sdk.js';
3
2
  export * from '@sentry/react';
3
+ export { init } from './client/sdk.js';
4
4
  //# sourceMappingURL=index.client.js.map
@@ -1,7 +1,7 @@
1
1
  export { ErrorBoundary, withErrorBoundary } from './server/index.js';
2
2
  export { sentryTanstackStart } from './vite/sentryTanstackStart.js';
3
+ export * from '@sentry/node';
3
4
  export { init } from './server/sdk.js';
4
5
  export { wrapFetchWithSentry } from './server/wrapFetchWithSentry.js';
5
6
  export { wrapMiddlewaresWithSentry } from './server/middleware.js';
6
- export * from '@sentry/node';
7
7
  //# sourceMappingURL=index.server.js.map
@@ -1 +1 @@
1
- {"type":"module","version":"10.36.0","sideEffects":false}
1
+ {"type":"module","version":"10.38.0","sideEffects":false}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Core function that wraps middleware arrays matching the given regex.
3
+ */
4
+ function wrapMiddlewareArrays(code, id, debug, regex) {
5
+ const skipped = [];
6
+ let didWrap = false;
7
+
8
+ const transformed = code.replace(regex, (match, key, contents) => {
9
+ const objContents = arrayToObjectShorthand(contents);
10
+ if (objContents) {
11
+ didWrap = true;
12
+ if (debug) {
13
+ // eslint-disable-next-line no-console
14
+ console.log(`[Sentry] Auto-wrapping ${key} in ${id}`);
15
+ }
16
+ return `${key}: wrapMiddlewaresWithSentry(${objContents})`;
17
+ }
18
+ // Track middlewares that couldn't be auto-wrapped
19
+ // Skip if we matched whitespace only
20
+ if (contents.trim()) {
21
+ skipped.push(key);
22
+ }
23
+ return match;
24
+ });
25
+
26
+ return { code: transformed, didWrap, skipped };
27
+ }
28
+
29
+ /**
30
+ * Wraps global middleware arrays (requestMiddleware, functionMiddleware) in createStart() files.
31
+ */
32
+ function wrapGlobalMiddleware(code, id, debug) {
33
+ return wrapMiddlewareArrays(code, id, debug, /(requestMiddleware|functionMiddleware)\s*:\s*\[([^\]]*)\]/g);
34
+ }
35
+
36
+ /**
37
+ * Wraps route middleware arrays in createFileRoute() files.
38
+ */
39
+ function wrapRouteMiddleware(code, id, debug) {
40
+ return wrapMiddlewareArrays(code, id, debug, /(middleware)\s*:\s*\[([^\]]*)\]/g);
41
+ }
42
+
43
+ /**
44
+ * A Vite plugin that automatically instruments TanStack Start middlewares:
45
+ * - `requestMiddleware` and `functionMiddleware` arrays in `createStart()`
46
+ * - `middleware` arrays in `createFileRoute()` route definitions
47
+ */
48
+ function makeAutoInstrumentMiddlewarePlugin(options = {}) {
49
+ const { enabled = true, debug = false } = options;
50
+
51
+ return {
52
+ name: 'sentry-tanstack-middleware-auto-instrument',
53
+ enforce: 'pre',
54
+
55
+ transform(code, id) {
56
+ if (!enabled) {
57
+ return null;
58
+ }
59
+
60
+ // Skip if not a TS/JS file
61
+ if (!/\.(ts|tsx|js|jsx|mjs|mts)$/.test(id)) {
62
+ return null;
63
+ }
64
+
65
+ // Detect file types that should be instrumented
66
+ const isStartFile = id.includes('start') && code.includes('createStart(');
67
+ const isRouteFile = code.includes('createFileRoute(') && /middleware\s*:\s*\[/.test(code);
68
+
69
+ if (!isStartFile && !isRouteFile) {
70
+ return null;
71
+ }
72
+
73
+ // Skip if the user already did some manual wrapping
74
+ if (code.includes('wrapMiddlewaresWithSentry')) {
75
+ return null;
76
+ }
77
+
78
+ let transformed = code;
79
+ let needsImport = false;
80
+ const skippedMiddlewares = [];
81
+
82
+ switch (true) {
83
+ // global middleware
84
+ case isStartFile: {
85
+ const result = wrapGlobalMiddleware(transformed, id, debug);
86
+ transformed = result.code;
87
+ needsImport = needsImport || result.didWrap;
88
+ skippedMiddlewares.push(...result.skipped);
89
+ break;
90
+ }
91
+ // route middleware
92
+ case isRouteFile: {
93
+ const result = wrapRouteMiddleware(transformed, id, debug);
94
+ transformed = result.code;
95
+ needsImport = needsImport || result.didWrap;
96
+ skippedMiddlewares.push(...result.skipped);
97
+ break;
98
+ }
99
+ }
100
+
101
+ // Warn about middlewares that couldn't be auto-wrapped
102
+ if (skippedMiddlewares.length > 0) {
103
+ // eslint-disable-next-line no-console
104
+ console.warn(
105
+ `[Sentry] Could not auto-instrument ${skippedMiddlewares.join(' and ')} in ${id}. ` +
106
+ 'To instrument these middlewares, use wrapMiddlewaresWithSentry() manually. ',
107
+ );
108
+ }
109
+
110
+ // We didn't wrap any middlewares, so we don't need to import the wrapMiddlewaresWithSentry function
111
+ if (!needsImport) {
112
+ return null;
113
+ }
114
+
115
+ transformed = addSentryImport(transformed);
116
+
117
+ return { code: transformed, map: null };
118
+ },
119
+ };
120
+ }
121
+
122
+ /**
123
+ * Convert array contents to object shorthand syntax.
124
+ * e.g., "foo, bar, baz" → "{ foo, bar, baz }"
125
+ *
126
+ * Returns null if contents contain non-identifier expressions (function calls, etc.)
127
+ * which cannot be converted to object shorthand.
128
+ */
129
+ function arrayToObjectShorthand(contents) {
130
+ const items = contents
131
+ .split(',')
132
+ .map(s => s.trim())
133
+ .filter(Boolean);
134
+
135
+ // Only convert if all items are valid identifiers (no complex expressions)
136
+ const allIdentifiers = items.every(item => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(item));
137
+ if (!allIdentifiers || items.length === 0) {
138
+ return null;
139
+ }
140
+
141
+ // Deduplicate to avoid invalid syntax like { foo, foo }
142
+ const uniqueItems = [...new Set(items)];
143
+
144
+ return `{ ${uniqueItems.join(', ')} }`;
145
+ }
146
+
147
+ /**
148
+ * Adds the wrapMiddlewaresWithSentry import to the code.
149
+ * Handles 'use client' and 'use server' directives by inserting the import after them.
150
+ */
151
+ function addSentryImport(code) {
152
+ const sentryImport = "import { wrapMiddlewaresWithSentry } from '@sentry/tanstackstart-react';\n";
153
+
154
+ // Don't add the import if it already exists
155
+ if (code.includes(sentryImport.trimEnd())) {
156
+ return code;
157
+ }
158
+
159
+ // Check for 'use server' or 'use client' directives, these need to be before any imports
160
+ const directiveMatch = code.match(/^(['"])use (client|server)\1;?\s*\n?/);
161
+
162
+ if (!directiveMatch) {
163
+ return sentryImport + code;
164
+ }
165
+
166
+ const directive = directiveMatch[0];
167
+ return directive + sentryImport + code.slice(directive.length);
168
+ }
169
+
170
+ export { addSentryImport, arrayToObjectShorthand, makeAutoInstrumentMiddlewarePlugin, wrapGlobalMiddleware, wrapRouteMiddleware };
171
+ //# sourceMappingURL=autoInstrumentMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoInstrumentMiddleware.js","sources":["../../../src/vite/autoInstrumentMiddleware.ts"],"sourcesContent":["import type { Plugin } from 'vite';\n\ntype AutoInstrumentMiddlewareOptions = {\n enabled?: boolean;\n debug?: boolean;\n};\n\ntype WrapResult = {\n code: string;\n didWrap: boolean;\n skipped: string[];\n};\n\n/**\n * Core function that wraps middleware arrays matching the given regex.\n */\nfunction wrapMiddlewareArrays(code: string, id: string, debug: boolean, regex: RegExp): WrapResult {\n const skipped: string[] = [];\n let didWrap = false;\n\n const transformed = code.replace(regex, (match: string, key: string, contents: string) => {\n const objContents = arrayToObjectShorthand(contents);\n if (objContents) {\n didWrap = true;\n if (debug) {\n // eslint-disable-next-line no-console\n console.log(`[Sentry] Auto-wrapping ${key} in ${id}`);\n }\n return `${key}: wrapMiddlewaresWithSentry(${objContents})`;\n }\n // Track middlewares that couldn't be auto-wrapped\n // Skip if we matched whitespace only\n if (contents.trim()) {\n skipped.push(key);\n }\n return match;\n });\n\n return { code: transformed, didWrap, skipped };\n}\n\n/**\n * Wraps global middleware arrays (requestMiddleware, functionMiddleware) in createStart() files.\n */\nexport function wrapGlobalMiddleware(code: string, id: string, debug: boolean): WrapResult {\n return wrapMiddlewareArrays(code, id, debug, /(requestMiddleware|functionMiddleware)\\s*:\\s*\\[([^\\]]*)\\]/g);\n}\n\n/**\n * Wraps route middleware arrays in createFileRoute() files.\n */\nexport function wrapRouteMiddleware(code: string, id: string, debug: boolean): WrapResult {\n return wrapMiddlewareArrays(code, id, debug, /(middleware)\\s*:\\s*\\[([^\\]]*)\\]/g);\n}\n\n/**\n * A Vite plugin that automatically instruments TanStack Start middlewares:\n * - `requestMiddleware` and `functionMiddleware` arrays in `createStart()`\n * - `middleware` arrays in `createFileRoute()` route definitions\n */\nexport function makeAutoInstrumentMiddlewarePlugin(options: AutoInstrumentMiddlewareOptions = {}): Plugin {\n const { enabled = true, debug = false } = options;\n\n return {\n name: 'sentry-tanstack-middleware-auto-instrument',\n enforce: 'pre',\n\n transform(code, id) {\n if (!enabled) {\n return null;\n }\n\n // Skip if not a TS/JS file\n if (!/\\.(ts|tsx|js|jsx|mjs|mts)$/.test(id)) {\n return null;\n }\n\n // Detect file types that should be instrumented\n const isStartFile = id.includes('start') && code.includes('createStart(');\n const isRouteFile = code.includes('createFileRoute(') && /middleware\\s*:\\s*\\[/.test(code);\n\n if (!isStartFile && !isRouteFile) {\n return null;\n }\n\n // Skip if the user already did some manual wrapping\n if (code.includes('wrapMiddlewaresWithSentry')) {\n return null;\n }\n\n let transformed = code;\n let needsImport = false;\n const skippedMiddlewares: string[] = [];\n\n switch (true) {\n // global middleware\n case isStartFile: {\n const result = wrapGlobalMiddleware(transformed, id, debug);\n transformed = result.code;\n needsImport = needsImport || result.didWrap;\n skippedMiddlewares.push(...result.skipped);\n break;\n }\n // route middleware\n case isRouteFile: {\n const result = wrapRouteMiddleware(transformed, id, debug);\n transformed = result.code;\n needsImport = needsImport || result.didWrap;\n skippedMiddlewares.push(...result.skipped);\n break;\n }\n default:\n break;\n }\n\n // Warn about middlewares that couldn't be auto-wrapped\n if (skippedMiddlewares.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Could not auto-instrument ${skippedMiddlewares.join(' and ')} in ${id}. ` +\n 'To instrument these middlewares, use wrapMiddlewaresWithSentry() manually. ',\n );\n }\n\n // We didn't wrap any middlewares, so we don't need to import the wrapMiddlewaresWithSentry function\n if (!needsImport) {\n return null;\n }\n\n transformed = addSentryImport(transformed);\n\n return { code: transformed, map: null };\n },\n };\n}\n\n/**\n * Convert array contents to object shorthand syntax.\n * e.g., \"foo, bar, baz\" → \"{ foo, bar, baz }\"\n *\n * Returns null if contents contain non-identifier expressions (function calls, etc.)\n * which cannot be converted to object shorthand.\n */\nexport function arrayToObjectShorthand(contents: string): string | null {\n const items = contents\n .split(',')\n .map(s => s.trim())\n .filter(Boolean);\n\n // Only convert if all items are valid identifiers (no complex expressions)\n const allIdentifiers = items.every(item => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(item));\n if (!allIdentifiers || items.length === 0) {\n return null;\n }\n\n // Deduplicate to avoid invalid syntax like { foo, foo }\n const uniqueItems = [...new Set(items)];\n\n return `{ ${uniqueItems.join(', ')} }`;\n}\n\n/**\n * Adds the wrapMiddlewaresWithSentry import to the code.\n * Handles 'use client' and 'use server' directives by inserting the import after them.\n */\nexport function addSentryImport(code: string): string {\n const sentryImport = \"import { wrapMiddlewaresWithSentry } from '@sentry/tanstackstart-react';\\n\";\n\n // Don't add the import if it already exists\n if (code.includes(sentryImport.trimEnd())) {\n return code;\n }\n\n // Check for 'use server' or 'use client' directives, these need to be before any imports\n const directiveMatch = code.match(/^(['\"])use (client|server)\\1;?\\s*\\n?/);\n\n if (!directiveMatch) {\n return sentryImport + code;\n }\n\n const directive = directiveMatch[0];\n return directive + sentryImport + code.slice(directive.length);\n}\n"],"names":[],"mappings":"AAaA;AACA;AACA;AACA,SAAS,oBAAoB,CAAC,IAAI,EAAU,EAAE,EAAU,KAAK,EAAW,KAAK,EAAsB;AACnG,EAAE,MAAM,OAAO,GAAa,EAAE;AAC9B,EAAE,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,WAAA,CAAA,IAAA,CAAA,IAAA,CAAA,CAAA,EAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAA,eAAA,CAAA,IAAA,EAAA;AACA,EAAA,MAAA,YAAA,GAAA,4EAAA;;AAEA;AACA,EAAA,IAAA,IAAA,CAAA,QAAA,CAAA,YAAA,CAAA,OAAA,EAAA,CAAA,EAAA;AACA,IAAA,OAAA,IAAA;AACA,EAAA;;AAEA;AACA,EAAA,MAAA,cAAA,GAAA,IAAA,CAAA,KAAA,CAAA,sCAAA,CAAA;;AAEA,EAAA,IAAA,CAAA,cAAA,EAAA;AACA,IAAA,OAAA,YAAA,GAAA,IAAA;AACA,EAAA;;AAEA,EAAA,MAAA,SAAA,GAAA,cAAA,CAAA,CAAA,CAAA;AACA,EAAA,OAAA,SAAA,GAAA,YAAA,GAAA,IAAA,CAAA,KAAA,CAAA,SAAA,CAAA,MAAA,CAAA;AACA;;;;"}
@@ -1,5 +1,10 @@
1
+ import { makeAutoInstrumentMiddlewarePlugin } from './autoInstrumentMiddleware.js';
1
2
  import { makeAddSentryVitePlugin, makeEnableSourceMapsVitePlugin } from './sourceMaps.js';
2
3
 
4
+ /**
5
+ * Build-time options for the Sentry TanStack Start SDK.
6
+ */
7
+
3
8
  /**
4
9
  * Vite plugins for the Sentry TanStack Start SDK.
5
10
  *
@@ -12,11 +17,11 @@ import { makeAddSentryVitePlugin, makeEnableSourceMapsVitePlugin } from './sourc
12
17
  *
13
18
  * export default defineConfig({
14
19
  * plugins: [
20
+ * tanstackStart(),
15
21
  * sentryTanstackStart({
16
22
  * org: 'your-org',
17
23
  * project: 'your-project',
18
24
  * }),
19
- * tanstackStart(),
20
25
  * ],
21
26
  * });
22
27
  * ```
@@ -25,13 +30,19 @@ import { makeAddSentryVitePlugin, makeEnableSourceMapsVitePlugin } from './sourc
25
30
  * @returns An array of Vite plugins
26
31
  */
27
32
  function sentryTanstackStart(options = {}) {
28
- // Only add plugins in production builds
33
+ // only add plugins in production builds
29
34
  if (process.env.NODE_ENV === 'development') {
30
35
  return [];
31
36
  }
32
37
 
33
38
  const plugins = [...makeAddSentryVitePlugin(options)];
34
39
 
40
+ // middleware auto-instrumentation
41
+ if (options.autoInstrumentMiddleware !== false) {
42
+ plugins.push(makeAutoInstrumentMiddlewarePlugin({ enabled: true, debug: options.debug }));
43
+ }
44
+
45
+ // source maps
35
46
  const sourceMapsDisabled = options.sourcemaps?.disable === true || options.sourcemaps?.disable === 'disable-upload';
36
47
  if (!sourceMapsDisabled) {
37
48
  plugins.push(...makeEnableSourceMapsVitePlugin(options));
@@ -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 { makeAddSentryVitePlugin, makeEnableSourceMapsVitePlugin } from './sourceMaps';\n\n/**\n * Vite plugins for the Sentry TanStack Start SDK.\n *\n * @example\n * ```typescript\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import { sentryTanstackStart } from '@sentry/tanstackstart-react';\n * import { tanstackStart } from '@tanstack/react-start/plugin/vite';\n *\n * export default defineConfig({\n * plugins: [\n * sentryTanstackStart({\n * org: 'your-org',\n * project: 'your-project',\n * }),\n * tanstackStart(),\n * ],\n * });\n * ```\n *\n * @param options - Options to configure the Sentry Vite plugins\n * @returns An array of Vite plugins\n */\nexport function sentryTanstackStart(options: BuildTimeOptionsBase = {}): Plugin[] {\n // Only add plugins in production builds\n if (process.env.NODE_ENV === 'development') {\n return [];\n }\n\n const plugins: Plugin[] = [...makeAddSentryVitePlugin(options)];\n\n const sourceMapsDisabled = options.sourcemaps?.disable === true || options.sourcemaps?.disable === 'disable-upload';\n if (!sourceMapsDisabled) {\n plugins.push(...makeEnableSourceMapsVitePlugin(options));\n }\n\n return plugins;\n}\n"],"names":[],"mappings":";;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,OAAO,GAAyB,EAAE,EAAY;AAClF;AACA,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAA,KAAa,aAAa,EAAE;AAC9C,IAAI,OAAO,EAAE;AACb,EAAE;;AAEF,EAAE,MAAM,OAAO,GAAa,CAAC,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;;AAEjE,EAAE,MAAM,kBAAA,GAAqB,OAAO,CAAC,UAAU,EAAE,OAAA,KAAY,IAAA,IAAQ,OAAO,CAAC,UAAU,EAAE,OAAA,KAAY,gBAAgB;AACrH,EAAE,IAAI,CAAC,kBAAkB,EAAE;AAC3B,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,8BAA8B,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 { makeAddSentryVitePlugin, makeEnableSourceMapsVitePlugin } from './sourceMaps';\n\n/**\n * Build-time options for the Sentry TanStack Start SDK.\n */\nexport interface SentryTanstackStartOptions extends BuildTimeOptionsBase {\n /**\n * If this flag is `true`, the Sentry plugins will automatically instrument TanStack Start middlewares.\n *\n * This wraps global middlewares (`requestMiddleware` and `functionMiddleware`) in `createStart()` with Sentry\n * instrumentation to capture performance data.\n *\n * Set to `false` to disable automatic middleware instrumentation if you prefer to wrap middlewares manually\n * using `wrapMiddlewaresWithSentry`.\n *\n * @default true\n */\n autoInstrumentMiddleware?: boolean;\n}\n\n/**\n * Vite plugins for the Sentry TanStack Start SDK.\n *\n * @example\n * ```typescript\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import { sentryTanstackStart } from '@sentry/tanstackstart-react';\n * import { tanstackStart } from '@tanstack/react-start/plugin/vite';\n *\n * export default defineConfig({\n * plugins: [\n * tanstackStart(),\n * sentryTanstackStart({\n * org: 'your-org',\n * project: 'your-project',\n * }),\n * ],\n * });\n * ```\n *\n * @param options - Options to configure the Sentry Vite plugins\n * @returns An array of Vite plugins\n */\nexport function sentryTanstackStart(options: SentryTanstackStartOptions = {}): Plugin[] {\n // only add plugins in production builds\n if (process.env.NODE_ENV === 'development') {\n return [];\n }\n\n const plugins: Plugin[] = [...makeAddSentryVitePlugin(options)];\n\n // middleware auto-instrumentation\n if (options.autoInstrumentMiddleware !== false) {\n plugins.push(makeAutoInstrumentMiddlewarePlugin({ enabled: true, debug: options.debug }));\n }\n\n // source maps\n const sourceMapsDisabled = options.sourcemaps?.disable === true || options.sourcemaps?.disable === 'disable-upload';\n if (!sourceMapsDisabled) {\n plugins.push(...makeEnableSourceMapsVitePlugin(options));\n }\n\n return plugins;\n}\n"],"names":[],"mappings":";;;AAKA;AACA;AACA;;AAgBA;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;AACA,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAA,KAAa,aAAa,EAAE;AAC9C,IAAI,OAAO,EAAE;AACb,EAAE;;AAEF,EAAE,MAAM,OAAO,GAAa,CAAC,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;;AAEjE;AACA,EAAE,IAAI,OAAO,CAAC,wBAAA,KAA6B,KAAK,EAAE;AAClD,IAAI,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAA,EAAO,CAAC,CAAC;AAC7F,EAAE;;AAEF;AACA,EAAE,MAAM,kBAAA,GAAqB,OAAO,CAAC,UAAU,EAAE,OAAA,KAAY,IAAA,IAAQ,OAAO,CAAC,UAAU,EAAE,OAAA,KAAY,gBAAgB;AACrH,EAAE,IAAI,CAAC,kBAAkB,EAAE;AAC3B,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,8BAA8B,CAAC,OAAO,CAAC,CAAC;AAC5D,EAAE;;AAEF,EAAE,OAAO,OAAO;AAChB;;;;"}
@@ -0,0 +1,39 @@
1
+ import type { Plugin } from 'vite';
2
+ type AutoInstrumentMiddlewareOptions = {
3
+ enabled?: boolean;
4
+ debug?: boolean;
5
+ };
6
+ type WrapResult = {
7
+ code: string;
8
+ didWrap: boolean;
9
+ skipped: string[];
10
+ };
11
+ /**
12
+ * Wraps global middleware arrays (requestMiddleware, functionMiddleware) in createStart() files.
13
+ */
14
+ export declare function wrapGlobalMiddleware(code: string, id: string, debug: boolean): WrapResult;
15
+ /**
16
+ * Wraps route middleware arrays in createFileRoute() files.
17
+ */
18
+ export declare function wrapRouteMiddleware(code: string, id: string, debug: boolean): WrapResult;
19
+ /**
20
+ * A Vite plugin that automatically instruments TanStack Start middlewares:
21
+ * - `requestMiddleware` and `functionMiddleware` arrays in `createStart()`
22
+ * - `middleware` arrays in `createFileRoute()` route definitions
23
+ */
24
+ export declare function makeAutoInstrumentMiddlewarePlugin(options?: AutoInstrumentMiddlewareOptions): Plugin;
25
+ /**
26
+ * Convert array contents to object shorthand syntax.
27
+ * e.g., "foo, bar, baz" → "{ foo, bar, baz }"
28
+ *
29
+ * Returns null if contents contain non-identifier expressions (function calls, etc.)
30
+ * which cannot be converted to object shorthand.
31
+ */
32
+ export declare function arrayToObjectShorthand(contents: string): string | null;
33
+ /**
34
+ * Adds the wrapMiddlewaresWithSentry import to the code.
35
+ * Handles 'use client' and 'use server' directives by inserting the import after them.
36
+ */
37
+ export declare function addSentryImport(code: string): string;
38
+ export {};
39
+ //# sourceMappingURL=autoInstrumentMiddleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoInstrumentMiddleware.d.ts","sourceRoot":"","sources":["../../../src/vite/autoInstrumentMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,KAAK,+BAA+B,GAAG;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA8BF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,UAAU,CAEzF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,UAAU,CAExF;AAED;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,OAAO,GAAE,+BAAoC,GAAG,MAAM,CA0ExG;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgBtE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAiBpD"}
@@ -1,2 +1,3 @@
1
1
  export { sentryTanstackStart } from './sentryTanstackStart';
2
+ export type { SentryTanstackStartOptions } from './sentryTanstackStart';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1,5 +1,22 @@
1
1
  import type { BuildTimeOptionsBase } from '@sentry/core';
2
2
  import type { Plugin } from 'vite';
3
+ /**
4
+ * Build-time options for the Sentry TanStack Start SDK.
5
+ */
6
+ export interface SentryTanstackStartOptions extends BuildTimeOptionsBase {
7
+ /**
8
+ * If this flag is `true`, the Sentry plugins will automatically instrument TanStack Start middlewares.
9
+ *
10
+ * This wraps global middlewares (`requestMiddleware` and `functionMiddleware`) in `createStart()` with Sentry
11
+ * instrumentation to capture performance data.
12
+ *
13
+ * Set to `false` to disable automatic middleware instrumentation if you prefer to wrap middlewares manually
14
+ * using `wrapMiddlewaresWithSentry`.
15
+ *
16
+ * @default true
17
+ */
18
+ autoInstrumentMiddleware?: boolean;
19
+ }
3
20
  /**
4
21
  * Vite plugins for the Sentry TanStack Start SDK.
5
22
  *
@@ -12,11 +29,11 @@ import type { Plugin } from 'vite';
12
29
  *
13
30
  * export default defineConfig({
14
31
  * plugins: [
32
+ * tanstackStart(),
15
33
  * sentryTanstackStart({
16
34
  * org: 'your-org',
17
35
  * project: 'your-project',
18
36
  * }),
19
- * tanstackStart(),
20
37
  * ],
21
38
  * });
22
39
  * ```
@@ -24,5 +41,5 @@ import type { Plugin } from 'vite';
24
41
  * @param options - Options to configure the Sentry Vite plugins
25
42
  * @returns An array of Vite plugins
26
43
  */
27
- export declare function sentryTanstackStart(options?: BuildTimeOptionsBase): Plugin[];
44
+ export declare function sentryTanstackStart(options?: SentryTanstackStartOptions): Plugin[];
28
45
  //# sourceMappingURL=sentryTanstackStart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sentryTanstackStart.d.ts","sourceRoot":"","sources":["../../../src/vite/sentryTanstackStart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,EAAE,CAchF"}
1
+ {"version":3,"file":"sentryTanstackStart.d.ts","sourceRoot":"","sources":["../../../src/vite/sentryTanstackStart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC;;GAEG;AACH,MAAM,WAAW,0BAA2B,SAAQ,oBAAoB;IACtE;;;;;;;;;;OAUG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,0BAA+B,GAAG,MAAM,EAAE,CAoBtF"}
@@ -0,0 +1,39 @@
1
+ import { Plugin } from 'vite';
2
+ type AutoInstrumentMiddlewareOptions = {
3
+ enabled?: boolean;
4
+ debug?: boolean;
5
+ };
6
+ type WrapResult = {
7
+ code: string;
8
+ didWrap: boolean;
9
+ skipped: string[];
10
+ };
11
+ /**
12
+ * Wraps global middleware arrays (requestMiddleware, functionMiddleware) in createStart() files.
13
+ */
14
+ export declare function wrapGlobalMiddleware(code: string, id: string, debug: boolean): WrapResult;
15
+ /**
16
+ * Wraps route middleware arrays in createFileRoute() files.
17
+ */
18
+ export declare function wrapRouteMiddleware(code: string, id: string, debug: boolean): WrapResult;
19
+ /**
20
+ * A Vite plugin that automatically instruments TanStack Start middlewares:
21
+ * - `requestMiddleware` and `functionMiddleware` arrays in `createStart()`
22
+ * - `middleware` arrays in `createFileRoute()` route definitions
23
+ */
24
+ export declare function makeAutoInstrumentMiddlewarePlugin(options?: AutoInstrumentMiddlewareOptions): Plugin;
25
+ /**
26
+ * Convert array contents to object shorthand syntax.
27
+ * e.g., "foo, bar, baz" → "{ foo, bar, baz }"
28
+ *
29
+ * Returns null if contents contain non-identifier expressions (function calls, etc.)
30
+ * which cannot be converted to object shorthand.
31
+ */
32
+ export declare function arrayToObjectShorthand(contents: string): string | null;
33
+ /**
34
+ * Adds the wrapMiddlewaresWithSentry import to the code.
35
+ * Handles 'use client' and 'use server' directives by inserting the import after them.
36
+ */
37
+ export declare function addSentryImport(code: string): string;
38
+ export {};
39
+ //# sourceMappingURL=autoInstrumentMiddleware.d.ts.map
@@ -1,2 +1,3 @@
1
1
  export { sentryTanstackStart } from './sentryTanstackStart';
2
+ export { SentryTanstackStartOptions } from './sentryTanstackStart';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,22 @@
1
1
  import { BuildTimeOptionsBase } from '@sentry/core';
2
2
  import { Plugin } from 'vite';
3
+ /**
4
+ * Build-time options for the Sentry TanStack Start SDK.
5
+ */
6
+ export interface SentryTanstackStartOptions extends BuildTimeOptionsBase {
7
+ /**
8
+ * If this flag is `true`, the Sentry plugins will automatically instrument TanStack Start middlewares.
9
+ *
10
+ * This wraps global middlewares (`requestMiddleware` and `functionMiddleware`) in `createStart()` with Sentry
11
+ * instrumentation to capture performance data.
12
+ *
13
+ * Set to `false` to disable automatic middleware instrumentation if you prefer to wrap middlewares manually
14
+ * using `wrapMiddlewaresWithSentry`.
15
+ *
16
+ * @default true
17
+ */
18
+ autoInstrumentMiddleware?: boolean;
19
+ }
3
20
  /**
4
21
  * Vite plugins for the Sentry TanStack Start SDK.
5
22
  *
@@ -12,11 +29,11 @@ import { Plugin } from 'vite';
12
29
  *
13
30
  * export default defineConfig({
14
31
  * plugins: [
32
+ * tanstackStart(),
15
33
  * sentryTanstackStart({
16
34
  * org: 'your-org',
17
35
  * project: 'your-project',
18
36
  * }),
19
- * tanstackStart(),
20
37
  * ],
21
38
  * });
22
39
  * ```
@@ -24,5 +41,5 @@ import { Plugin } from 'vite';
24
41
  * @param options - Options to configure the Sentry Vite plugins
25
42
  * @returns An array of Vite plugins
26
43
  */
27
- export declare function sentryTanstackStart(options?: BuildTimeOptionsBase): Plugin[];
44
+ export declare function sentryTanstackStart(options?: SentryTanstackStartOptions): Plugin[];
28
45
  //# sourceMappingURL=sentryTanstackStart.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/tanstackstart-react",
3
- "version": "10.36.0",
3
+ "version": "10.38.0",
4
4
  "description": "Official Sentry SDK for TanStack Start React",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/tanstackstart-react",
@@ -52,11 +52,11 @@
52
52
  "dependencies": {
53
53
  "@opentelemetry/api": "^1.9.0",
54
54
  "@opentelemetry/semantic-conventions": "^1.37.0",
55
- "@sentry-internal/browser-utils": "10.36.0",
56
- "@sentry/core": "10.36.0",
57
- "@sentry/node": "10.36.0",
58
- "@sentry/react": "10.36.0",
59
- "@sentry/vite-plugin": "^4.6.2"
55
+ "@sentry-internal/browser-utils": "10.38.0",
56
+ "@sentry/core": "10.38.0",
57
+ "@sentry/node": "10.38.0",
58
+ "@sentry/react": "10.38.0",
59
+ "@sentry/vite-plugin": "^4.8.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "vite": "^5.4.11"