@sentry/tanstackstart-react 10.35.0 → 10.37.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.
@@ -0,0 +1,118 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ /**
4
+ * A Vite plugin that automatically instruments TanStack Start middlewares
5
+ * by wrapping `requestMiddleware` and `functionMiddleware` arrays in `createStart()`.
6
+ */
7
+ function makeAutoInstrumentMiddlewarePlugin(options = {}) {
8
+ const { enabled = true, debug = false } = options;
9
+
10
+ return {
11
+ name: 'sentry-tanstack-middleware-auto-instrument',
12
+ enforce: 'pre',
13
+
14
+ transform(code, id) {
15
+ if (!enabled) {
16
+ return null;
17
+ }
18
+
19
+ // Skip if not a TS/JS file
20
+ if (!/\.(ts|tsx|js|jsx|mjs|mts)$/.test(id)) {
21
+ return null;
22
+ }
23
+
24
+ // Only wrap requestMiddleware and functionMiddleware in createStart()
25
+ // createStart() should always be in a file named start.ts
26
+ if (!id.includes('start') || !code.includes('createStart(')) {
27
+ return null;
28
+ }
29
+
30
+ // Skip if the user already did some manual wrapping
31
+ if (code.includes('wrapMiddlewaresWithSentry')) {
32
+ return null;
33
+ }
34
+
35
+ let transformed = code;
36
+ let needsImport = false;
37
+ const skippedMiddlewares = [];
38
+
39
+ transformed = transformed.replace(
40
+ /(requestMiddleware|functionMiddleware)\s*:\s*\[([^\]]*)\]/g,
41
+ (match, key, contents) => {
42
+ const objContents = arrayToObjectShorthand(contents);
43
+ if (objContents) {
44
+ needsImport = true;
45
+ if (debug) {
46
+ // eslint-disable-next-line no-console
47
+ console.log(`[Sentry] Auto-wrapping ${key} in ${id}`);
48
+ }
49
+ return `${key}: wrapMiddlewaresWithSentry(${objContents})`;
50
+ }
51
+ // Track middlewares that couldn't be auto-wrapped
52
+ // Skip if we matched whitespace only
53
+ if (contents.trim()) {
54
+ skippedMiddlewares.push(key);
55
+ }
56
+ return match;
57
+ },
58
+ );
59
+
60
+ // Warn about middlewares that couldn't be auto-wrapped
61
+ if (skippedMiddlewares.length > 0) {
62
+ // eslint-disable-next-line no-console
63
+ console.warn(
64
+ `[Sentry] Could not auto-instrument ${skippedMiddlewares.join(' and ')} in ${id}. ` +
65
+ 'To instrument these middlewares, use wrapMiddlewaresWithSentry() manually. ',
66
+ );
67
+ }
68
+
69
+ // We didn't wrap any middlewares, so we don't need to import the wrapMiddlewaresWithSentry function
70
+ if (!needsImport) {
71
+ return null;
72
+ }
73
+
74
+ const sentryImport = "import { wrapMiddlewaresWithSentry } from '@sentry/tanstackstart-react';\n";
75
+
76
+ // Check for 'use server' or 'use client' directives, these need to be before any imports
77
+ const directiveMatch = transformed.match(/^(['"])use (client|server)\1;?\s*\n?/);
78
+ if (directiveMatch) {
79
+ // Insert import after the directive
80
+ const directive = directiveMatch[0];
81
+ transformed = directive + sentryImport + transformed.slice(directive.length);
82
+ } else {
83
+ transformed = sentryImport + transformed;
84
+ }
85
+
86
+ return { code: transformed, map: null };
87
+ },
88
+ };
89
+ }
90
+
91
+ /**
92
+ * Convert array contents to object shorthand syntax.
93
+ * e.g., "foo, bar, baz" → "{ foo, bar, baz }"
94
+ *
95
+ * Returns null if contents contain non-identifier expressions (function calls, etc.)
96
+ * which cannot be converted to object shorthand.
97
+ */
98
+ function arrayToObjectShorthand(contents) {
99
+ const items = contents
100
+ .split(',')
101
+ .map(s => s.trim())
102
+ .filter(Boolean);
103
+
104
+ // Only convert if all items are valid identifiers (no complex expressions)
105
+ const allIdentifiers = items.every(item => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(item));
106
+ if (!allIdentifiers || items.length === 0) {
107
+ return null;
108
+ }
109
+
110
+ // Deduplicate to avoid invalid syntax like { foo, foo }
111
+ const uniqueItems = [...new Set(items)];
112
+
113
+ return `{ ${uniqueItems.join(', ')} }`;
114
+ }
115
+
116
+ exports.arrayToObjectShorthand = arrayToObjectShorthand;
117
+ exports.makeAutoInstrumentMiddlewarePlugin = makeAutoInstrumentMiddlewarePlugin;
118
+ //# 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\n/**\n * A Vite plugin that automatically instruments TanStack Start middlewares\n * by wrapping `requestMiddleware` and `functionMiddleware` arrays in `createStart()`.\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 // Only wrap requestMiddleware and functionMiddleware in createStart()\n // createStart() should always be in a file named start.ts\n if (!id.includes('start') || !code.includes('createStart(')) {\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 transformed = transformed.replace(\n /(requestMiddleware|functionMiddleware)\\s*:\\s*\\[([^\\]]*)\\]/g,\n (match: string, key: string, contents: string) => {\n const objContents = arrayToObjectShorthand(contents);\n if (objContents) {\n needsImport = 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 skippedMiddlewares.push(key);\n }\n return match;\n },\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 const sentryImport = \"import { wrapMiddlewaresWithSentry } from '@sentry/tanstackstart-react';\\n\";\n\n // Check for 'use server' or 'use client' directives, these need to be before any imports\n const directiveMatch = transformed.match(/^(['\"])use (client|server)\\1;?\\s*\\n?/);\n if (directiveMatch) {\n // Insert import after the directive\n const directive = directiveMatch[0];\n transformed = directive + sentryImport + transformed.slice(directive.length);\n } else {\n transformed = sentryImport + transformed;\n }\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"],"names":[],"mappings":";;AAOA;AACA;AACA;AACA;AACO,SAAS,kCAAkC,CAAC,OAAO,GAAoC,EAAE,EAAU;AAC1G,EAAE,MAAM,EAAE,OAAA,GAAU,IAAI,EAAE,KAAA,GAAQ,KAAA,EAAM,GAAI,OAAO;;AAEnD,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,4CAA4C;AACtD,IAAI,OAAO,EAAE,KAAK;;AAElB,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE,EAAE;AACxB,MAAM,IAAI,CAAC,OAAO,EAA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AAA,GAAA,IAAA,GAAA,CAAA,KAAA,CAAA,CAAA;;AAEA,EAAA,OAAA,CAAA,EAAA,EAAA,WAAA,CAAA,IAAA,CAAA,IAAA,CAAA,CAAA,EAAA,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 +1 @@
1
- {"type":"module","version":"10.35.0","sideEffects":false}
1
+ {"type":"module","version":"10.37.0","sideEffects":false}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * A Vite plugin that automatically instruments TanStack Start middlewares
3
+ * by wrapping `requestMiddleware` and `functionMiddleware` arrays in `createStart()`.
4
+ */
5
+ function makeAutoInstrumentMiddlewarePlugin(options = {}) {
6
+ const { enabled = true, debug = false } = options;
7
+
8
+ return {
9
+ name: 'sentry-tanstack-middleware-auto-instrument',
10
+ enforce: 'pre',
11
+
12
+ transform(code, id) {
13
+ if (!enabled) {
14
+ return null;
15
+ }
16
+
17
+ // Skip if not a TS/JS file
18
+ if (!/\.(ts|tsx|js|jsx|mjs|mts)$/.test(id)) {
19
+ return null;
20
+ }
21
+
22
+ // Only wrap requestMiddleware and functionMiddleware in createStart()
23
+ // createStart() should always be in a file named start.ts
24
+ if (!id.includes('start') || !code.includes('createStart(')) {
25
+ return null;
26
+ }
27
+
28
+ // Skip if the user already did some manual wrapping
29
+ if (code.includes('wrapMiddlewaresWithSentry')) {
30
+ return null;
31
+ }
32
+
33
+ let transformed = code;
34
+ let needsImport = false;
35
+ const skippedMiddlewares = [];
36
+
37
+ transformed = transformed.replace(
38
+ /(requestMiddleware|functionMiddleware)\s*:\s*\[([^\]]*)\]/g,
39
+ (match, key, contents) => {
40
+ const objContents = arrayToObjectShorthand(contents);
41
+ if (objContents) {
42
+ needsImport = true;
43
+ if (debug) {
44
+ // eslint-disable-next-line no-console
45
+ console.log(`[Sentry] Auto-wrapping ${key} in ${id}`);
46
+ }
47
+ return `${key}: wrapMiddlewaresWithSentry(${objContents})`;
48
+ }
49
+ // Track middlewares that couldn't be auto-wrapped
50
+ // Skip if we matched whitespace only
51
+ if (contents.trim()) {
52
+ skippedMiddlewares.push(key);
53
+ }
54
+ return match;
55
+ },
56
+ );
57
+
58
+ // Warn about middlewares that couldn't be auto-wrapped
59
+ if (skippedMiddlewares.length > 0) {
60
+ // eslint-disable-next-line no-console
61
+ console.warn(
62
+ `[Sentry] Could not auto-instrument ${skippedMiddlewares.join(' and ')} in ${id}. ` +
63
+ 'To instrument these middlewares, use wrapMiddlewaresWithSentry() manually. ',
64
+ );
65
+ }
66
+
67
+ // We didn't wrap any middlewares, so we don't need to import the wrapMiddlewaresWithSentry function
68
+ if (!needsImport) {
69
+ return null;
70
+ }
71
+
72
+ const sentryImport = "import { wrapMiddlewaresWithSentry } from '@sentry/tanstackstart-react';\n";
73
+
74
+ // Check for 'use server' or 'use client' directives, these need to be before any imports
75
+ const directiveMatch = transformed.match(/^(['"])use (client|server)\1;?\s*\n?/);
76
+ if (directiveMatch) {
77
+ // Insert import after the directive
78
+ const directive = directiveMatch[0];
79
+ transformed = directive + sentryImport + transformed.slice(directive.length);
80
+ } else {
81
+ transformed = sentryImport + transformed;
82
+ }
83
+
84
+ return { code: transformed, map: null };
85
+ },
86
+ };
87
+ }
88
+
89
+ /**
90
+ * Convert array contents to object shorthand syntax.
91
+ * e.g., "foo, bar, baz" → "{ foo, bar, baz }"
92
+ *
93
+ * Returns null if contents contain non-identifier expressions (function calls, etc.)
94
+ * which cannot be converted to object shorthand.
95
+ */
96
+ function arrayToObjectShorthand(contents) {
97
+ const items = contents
98
+ .split(',')
99
+ .map(s => s.trim())
100
+ .filter(Boolean);
101
+
102
+ // Only convert if all items are valid identifiers (no complex expressions)
103
+ const allIdentifiers = items.every(item => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(item));
104
+ if (!allIdentifiers || items.length === 0) {
105
+ return null;
106
+ }
107
+
108
+ // Deduplicate to avoid invalid syntax like { foo, foo }
109
+ const uniqueItems = [...new Set(items)];
110
+
111
+ return `{ ${uniqueItems.join(', ')} }`;
112
+ }
113
+
114
+ export { arrayToObjectShorthand, makeAutoInstrumentMiddlewarePlugin };
115
+ //# 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\n/**\n * A Vite plugin that automatically instruments TanStack Start middlewares\n * by wrapping `requestMiddleware` and `functionMiddleware` arrays in `createStart()`.\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 // Only wrap requestMiddleware and functionMiddleware in createStart()\n // createStart() should always be in a file named start.ts\n if (!id.includes('start') || !code.includes('createStart(')) {\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 transformed = transformed.replace(\n /(requestMiddleware|functionMiddleware)\\s*:\\s*\\[([^\\]]*)\\]/g,\n (match: string, key: string, contents: string) => {\n const objContents = arrayToObjectShorthand(contents);\n if (objContents) {\n needsImport = 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 skippedMiddlewares.push(key);\n }\n return match;\n },\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 const sentryImport = \"import { wrapMiddlewaresWithSentry } from '@sentry/tanstackstart-react';\\n\";\n\n // Check for 'use server' or 'use client' directives, these need to be before any imports\n const directiveMatch = transformed.match(/^(['\"])use (client|server)\\1;?\\s*\\n?/);\n if (directiveMatch) {\n // Insert import after the directive\n const directive = directiveMatch[0];\n transformed = directive + sentryImport + transformed.slice(directive.length);\n } else {\n transformed = sentryImport + transformed;\n }\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"],"names":[],"mappings":"AAOA;AACA;AACA;AACA;AACO,SAAS,kCAAkC,CAAC,OAAO,GAAoC,EAAE,EAAU;AAC1G,EAAE,MAAM,EAAE,OAAA,GAAU,IAAI,EAAE,KAAA,GAAQ,KAAA,EAAM,GAAI,OAAO;;AAEnD,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,4CAA4C;AACtD,IAAI,OAAO,EAAE,KAAK;;AAElB,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE,EAAE;AACxB,MAAM,IAAI,CAAC,OAAO,EAAE;AACpB,QAAQ,OAAO,IAAI;AACnB,MAAM;;AAEN;AACA,MAAM,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;AAClD,QAAQ,OAAO,IAAI;AACnB,MAAM;;AAEN;AACA;AACA,MAAM,IA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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,20 @@
1
+ import type { Plugin } from 'vite';
2
+ type AutoInstrumentMiddlewareOptions = {
3
+ enabled?: boolean;
4
+ debug?: boolean;
5
+ };
6
+ /**
7
+ * A Vite plugin that automatically instruments TanStack Start middlewares
8
+ * by wrapping `requestMiddleware` and `functionMiddleware` arrays in `createStart()`.
9
+ */
10
+ export declare function makeAutoInstrumentMiddlewarePlugin(options?: AutoInstrumentMiddlewareOptions): Plugin;
11
+ /**
12
+ * Convert array contents to object shorthand syntax.
13
+ * e.g., "foo, bar, baz" → "{ foo, bar, baz }"
14
+ *
15
+ * Returns null if contents contain non-identifier expressions (function calls, etc.)
16
+ * which cannot be converted to object shorthand.
17
+ */
18
+ export declare function arrayToObjectShorthand(contents: string): string | null;
19
+ export {};
20
+ //# 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;;;GAGG;AACH,wBAAgB,kCAAkC,CAAC,OAAO,GAAE,+BAAoC,GAAG,MAAM,CAkFxG;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgBtE"}
@@ -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,20 @@
1
+ import { Plugin } from 'vite';
2
+ type AutoInstrumentMiddlewareOptions = {
3
+ enabled?: boolean;
4
+ debug?: boolean;
5
+ };
6
+ /**
7
+ * A Vite plugin that automatically instruments TanStack Start middlewares
8
+ * by wrapping `requestMiddleware` and `functionMiddleware` arrays in `createStart()`.
9
+ */
10
+ export declare function makeAutoInstrumentMiddlewarePlugin(options?: AutoInstrumentMiddlewareOptions): Plugin;
11
+ /**
12
+ * Convert array contents to object shorthand syntax.
13
+ * e.g., "foo, bar, baz" → "{ foo, bar, baz }"
14
+ *
15
+ * Returns null if contents contain non-identifier expressions (function calls, etc.)
16
+ * which cannot be converted to object shorthand.
17
+ */
18
+ export declare function arrayToObjectShorthand(contents: string): string | null;
19
+ export {};
20
+ //# 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.35.0",
3
+ "version": "10.37.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.35.0",
56
- "@sentry/core": "10.35.0",
57
- "@sentry/node": "10.35.0",
58
- "@sentry/react": "10.35.0",
59
- "@sentry/vite-plugin": "^4.6.2"
55
+ "@sentry-internal/browser-utils": "10.37.0",
56
+ "@sentry/core": "10.37.0",
57
+ "@sentry/node": "10.37.0",
58
+ "@sentry/react": "10.37.0",
59
+ "@sentry/vite-plugin": "^4.7.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "vite": "^5.4.11"