@sentry/core 10.52.0 → 10.53.1

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 (203) hide show
  1. package/browser.d.ts +4 -0
  2. package/browser.js +3 -0
  3. package/build/cjs/browser.js +529 -0
  4. package/build/cjs/browser.js.map +1 -0
  5. package/build/cjs/client.js +9 -0
  6. package/build/cjs/client.js.map +1 -1
  7. package/build/cjs/index.js +69 -68
  8. package/build/cjs/index.js.map +1 -1
  9. package/build/cjs/instrument/console.js +43 -3
  10. package/build/cjs/instrument/console.js.map +1 -1
  11. package/build/cjs/integrations/captureconsole.js +2 -2
  12. package/build/cjs/integrations/captureconsole.js.map +1 -1
  13. package/build/cjs/integrations/console.js +5 -1
  14. package/build/cjs/integrations/console.js.map +1 -1
  15. package/build/cjs/integrations/express/index.js +2 -2
  16. package/build/cjs/integrations/express/index.js.map +1 -1
  17. package/build/cjs/integrations/mcp-server/errorCapture.js +2 -2
  18. package/build/cjs/integrations/mcp-server/errorCapture.js.map +1 -1
  19. package/build/cjs/integrations/mcp-server/handlers.js +72 -0
  20. package/build/cjs/integrations/mcp-server/handlers.js.map +1 -1
  21. package/build/cjs/integrations/mcp-server/index.js +10 -1
  22. package/build/cjs/integrations/mcp-server/index.js.map +1 -1
  23. package/build/cjs/integrations/supabase.js +4 -4
  24. package/build/cjs/integrations/supabase.js.map +1 -1
  25. package/build/cjs/semanticAttributes.js +4 -4
  26. package/build/cjs/semanticAttributes.js.map +1 -1
  27. package/build/cjs/server.js +563 -0
  28. package/build/cjs/server.js.map +1 -0
  29. package/build/cjs/tracing/ai/utils.js +2 -2
  30. package/build/cjs/tracing/ai/utils.js.map +1 -1
  31. package/build/cjs/tracing/anthropic-ai/index.js +3 -3
  32. package/build/cjs/tracing/anthropic-ai/index.js.map +1 -1
  33. package/build/cjs/tracing/anthropic-ai/streaming.js +3 -3
  34. package/build/cjs/tracing/anthropic-ai/streaming.js.map +1 -1
  35. package/build/cjs/tracing/anthropic-ai/utils.js +2 -2
  36. package/build/cjs/tracing/anthropic-ai/utils.js.map +1 -1
  37. package/build/cjs/tracing/google-genai/index.js +3 -3
  38. package/build/cjs/tracing/google-genai/index.js.map +1 -1
  39. package/build/cjs/tracing/google-genai/streaming.js +2 -2
  40. package/build/cjs/tracing/google-genai/streaming.js.map +1 -1
  41. package/build/cjs/tracing/langchain/embeddings.js +2 -2
  42. package/build/cjs/tracing/langchain/embeddings.js.map +1 -1
  43. package/build/cjs/tracing/langchain/index.js +4 -4
  44. package/build/cjs/tracing/langchain/index.js.map +1 -1
  45. package/build/cjs/tracing/langgraph/index.js +3 -3
  46. package/build/cjs/tracing/langgraph/index.js.map +1 -1
  47. package/build/cjs/tracing/langgraph/utils.js +2 -2
  48. package/build/cjs/tracing/langgraph/utils.js.map +1 -1
  49. package/build/cjs/tracing/openai/index.js +3 -3
  50. package/build/cjs/tracing/openai/index.js.map +1 -1
  51. package/build/cjs/tracing/openai/streaming.js +2 -2
  52. package/build/cjs/tracing/openai/streaming.js.map +1 -1
  53. package/build/cjs/tracing/sentrySpan.js +5 -0
  54. package/build/cjs/tracing/sentrySpan.js.map +1 -1
  55. package/build/cjs/tracing/spans/captureSpan.js +5 -9
  56. package/build/cjs/tracing/spans/captureSpan.js.map +1 -1
  57. package/build/cjs/tracing/spans/extractGenAiSpans.js +60 -0
  58. package/build/cjs/tracing/spans/extractGenAiSpans.js.map +1 -0
  59. package/build/cjs/tracing/spans/spanJsonToStreamedSpan.js +26 -0
  60. package/build/cjs/tracing/spans/spanJsonToStreamedSpan.js.map +1 -0
  61. package/build/cjs/tracing/vercel-ai/index.js +6 -1
  62. package/build/cjs/tracing/vercel-ai/index.js.map +1 -1
  63. package/build/cjs/trpc.js +3 -3
  64. package/build/cjs/trpc.js.map +1 -1
  65. package/build/cjs/utils/exports.js +7 -7
  66. package/build/cjs/utils/exports.js.map +1 -1
  67. package/build/cjs/utils/flushIfServerless.js +2 -2
  68. package/build/cjs/utils/flushIfServerless.js.map +1 -1
  69. package/build/cjs/utils/string.js +9 -2
  70. package/build/cjs/utils/string.js.map +1 -1
  71. package/build/cjs/utils/traceData.js +2 -2
  72. package/build/cjs/utils/traceData.js.map +1 -1
  73. package/build/cjs/utils/version.js +1 -1
  74. package/build/esm/browser.js +142 -0
  75. package/build/esm/browser.js.map +1 -0
  76. package/build/esm/client.js +9 -0
  77. package/build/esm/client.js.map +1 -1
  78. package/build/esm/index.js +17 -17
  79. package/build/esm/instrument/console.js +44 -5
  80. package/build/esm/instrument/console.js.map +1 -1
  81. package/build/esm/integrations/console.js +6 -2
  82. package/build/esm/integrations/console.js.map +1 -1
  83. package/build/esm/integrations/mcp-server/handlers.js +72 -1
  84. package/build/esm/integrations/mcp-server/handlers.js.map +1 -1
  85. package/build/esm/integrations/mcp-server/index.js +11 -2
  86. package/build/esm/integrations/mcp-server/index.js.map +1 -1
  87. package/build/esm/package.json +1 -1
  88. package/build/esm/semanticAttributes.js +4 -4
  89. package/build/esm/semanticAttributes.js.map +1 -1
  90. package/build/esm/server.js +157 -0
  91. package/build/esm/server.js.map +1 -0
  92. package/build/esm/tracing/sentrySpan.js +5 -0
  93. package/build/esm/tracing/sentrySpan.js.map +1 -1
  94. package/build/esm/tracing/spans/captureSpan.js +5 -9
  95. package/build/esm/tracing/spans/captureSpan.js.map +1 -1
  96. package/build/esm/tracing/spans/extractGenAiSpans.js +58 -0
  97. package/build/esm/tracing/spans/extractGenAiSpans.js.map +1 -0
  98. package/build/esm/tracing/spans/spanJsonToStreamedSpan.js +24 -0
  99. package/build/esm/tracing/spans/spanJsonToStreamedSpan.js.map +1 -0
  100. package/build/esm/tracing/vercel-ai/index.js +6 -1
  101. package/build/esm/tracing/vercel-ai/index.js.map +1 -1
  102. package/build/esm/utils/exports.js +7 -7
  103. package/build/esm/utils/exports.js.map +1 -1
  104. package/build/esm/utils/string.js +9 -2
  105. package/build/esm/utils/string.js.map +1 -1
  106. package/build/esm/utils/version.js +1 -1
  107. package/build/types/browser-exports.d.ts +11 -0
  108. package/build/types/browser-exports.d.ts.map +1 -0
  109. package/build/types/browser.d.ts +3 -0
  110. package/build/types/browser.d.ts.map +1 -0
  111. package/build/types/build-time-plugins/buildTimeOptionsBase.d.ts +8 -0
  112. package/build/types/build-time-plugins/buildTimeOptionsBase.d.ts.map +1 -1
  113. package/build/types/carrier.d.ts +1 -1
  114. package/build/types/carrier.d.ts.map +1 -1
  115. package/build/types/client.d.ts.map +1 -1
  116. package/build/types/index.d.ts +3 -232
  117. package/build/types/index.d.ts.map +1 -1
  118. package/build/types/instrument/console.d.ts +7 -0
  119. package/build/types/instrument/console.d.ts.map +1 -1
  120. package/build/types/integrations/captureconsole.d.ts +1 -1
  121. package/build/types/integrations/captureconsole.d.ts.map +1 -1
  122. package/build/types/integrations/console.d.ts +5 -0
  123. package/build/types/integrations/console.d.ts.map +1 -1
  124. package/build/types/integrations/conversationId.d.ts +1 -1
  125. package/build/types/integrations/conversationId.d.ts.map +1 -1
  126. package/build/types/integrations/dedupe.d.ts +1 -1
  127. package/build/types/integrations/dedupe.d.ts.map +1 -1
  128. package/build/types/integrations/eventFilters.d.ts +2 -2
  129. package/build/types/integrations/eventFilters.d.ts.map +1 -1
  130. package/build/types/integrations/extraerrordata.d.ts +1 -1
  131. package/build/types/integrations/extraerrordata.d.ts.map +1 -1
  132. package/build/types/integrations/functiontostring.d.ts +1 -1
  133. package/build/types/integrations/functiontostring.d.ts.map +1 -1
  134. package/build/types/integrations/linkederrors.d.ts +1 -1
  135. package/build/types/integrations/linkederrors.d.ts.map +1 -1
  136. package/build/types/integrations/mcp-server/handlers.d.ts +18 -0
  137. package/build/types/integrations/mcp-server/handlers.d.ts.map +1 -1
  138. package/build/types/integrations/mcp-server/index.d.ts +8 -1
  139. package/build/types/integrations/mcp-server/index.d.ts.map +1 -1
  140. package/build/types/integrations/requestdata.d.ts +1 -1
  141. package/build/types/integrations/requestdata.d.ts.map +1 -1
  142. package/build/types/integrations/spanStreaming.d.ts +1 -1
  143. package/build/types/integrations/spanStreaming.d.ts.map +1 -1
  144. package/build/types/integrations/supabase.d.ts +1 -1
  145. package/build/types/integrations/supabase.d.ts.map +1 -1
  146. package/build/types/integrations/zoderrors.d.ts +1 -1
  147. package/build/types/integrations/zoderrors.d.ts.map +1 -1
  148. package/build/types/logs/console-integration.d.ts +1 -1
  149. package/build/types/logs/console-integration.d.ts.map +1 -1
  150. package/build/types/semanticAttributes.d.ts +4 -4
  151. package/build/types/semanticAttributes.d.ts.map +1 -1
  152. package/build/types/server-exports.d.ts +26 -0
  153. package/build/types/server-exports.d.ts.map +1 -0
  154. package/build/types/server.d.ts +10 -0
  155. package/build/types/server.d.ts.map +1 -0
  156. package/build/types/shared-exports.d.ts +215 -0
  157. package/build/types/shared-exports.d.ts.map +1 -0
  158. package/build/types/tracing/sentrySpan.d.ts.map +1 -1
  159. package/build/types/tracing/spans/captureSpan.d.ts.map +1 -1
  160. package/build/types/tracing/spans/extractGenAiSpans.d.ts +15 -0
  161. package/build/types/tracing/spans/extractGenAiSpans.d.ts.map +1 -0
  162. package/build/types/tracing/spans/spanJsonToStreamedSpan.d.ts +6 -0
  163. package/build/types/tracing/spans/spanJsonToStreamedSpan.d.ts.map +1 -0
  164. package/build/types/tracing/vercel-ai/index.d.ts.map +1 -1
  165. package/build/types/types-hoist/envelope.d.ts +1 -1
  166. package/build/types/types-hoist/envelope.d.ts.map +1 -1
  167. package/build/types/types-hoist/options.d.ts +8 -0
  168. package/build/types/types-hoist/options.d.ts.map +1 -1
  169. package/build/types/utils/string.d.ts +1 -1
  170. package/build/types/utils/string.d.ts.map +1 -1
  171. package/build/types-ts3.8/browser-exports.d.ts +11 -0
  172. package/build/types-ts3.8/browser.d.ts +3 -0
  173. package/build/types-ts3.8/build-time-plugins/buildTimeOptionsBase.d.ts +8 -0
  174. package/build/types-ts3.8/carrier.d.ts +1 -1
  175. package/build/types-ts3.8/index.d.ts +3 -234
  176. package/build/types-ts3.8/instrument/console.d.ts +7 -0
  177. package/build/types-ts3.8/integrations/captureconsole.d.ts +1 -1
  178. package/build/types-ts3.8/integrations/console.d.ts +5 -0
  179. package/build/types-ts3.8/integrations/conversationId.d.ts +1 -1
  180. package/build/types-ts3.8/integrations/dedupe.d.ts +1 -1
  181. package/build/types-ts3.8/integrations/eventFilters.d.ts +2 -2
  182. package/build/types-ts3.8/integrations/extraerrordata.d.ts +1 -1
  183. package/build/types-ts3.8/integrations/functiontostring.d.ts +1 -1
  184. package/build/types-ts3.8/integrations/linkederrors.d.ts +1 -1
  185. package/build/types-ts3.8/integrations/mcp-server/handlers.d.ts +18 -0
  186. package/build/types-ts3.8/integrations/mcp-server/index.d.ts +8 -1
  187. package/build/types-ts3.8/integrations/requestdata.d.ts +1 -1
  188. package/build/types-ts3.8/integrations/spanStreaming.d.ts +1 -1
  189. package/build/types-ts3.8/integrations/supabase.d.ts +1 -1
  190. package/build/types-ts3.8/integrations/zoderrors.d.ts +1 -1
  191. package/build/types-ts3.8/logs/console-integration.d.ts +1 -1
  192. package/build/types-ts3.8/semanticAttributes.d.ts +4 -4
  193. package/build/types-ts3.8/server-exports.d.ts +21 -0
  194. package/build/types-ts3.8/server.d.ts +10 -0
  195. package/build/types-ts3.8/shared-exports.d.ts +214 -0
  196. package/build/types-ts3.8/tracing/spans/extractGenAiSpans.d.ts +15 -0
  197. package/build/types-ts3.8/tracing/spans/spanJsonToStreamedSpan.d.ts +6 -0
  198. package/build/types-ts3.8/types-hoist/envelope.d.ts +1 -1
  199. package/build/types-ts3.8/types-hoist/options.d.ts +8 -0
  200. package/build/types-ts3.8/utils/string.d.ts +1 -1
  201. package/package.json +32 -2
  202. package/server.d.ts +4 -0
  203. package/server.js +3 -0
@@ -1,8 +1,20 @@
1
- import { CONSOLE_LEVELS, originalConsoleMethods } from '../utils/debug-logger.js';
1
+ import { DEBUG_BUILD } from '../debug-build.js';
2
+ import { CONSOLE_LEVELS, originalConsoleMethods, debug } from '../utils/debug-logger.js';
2
3
  import { fill } from '../utils/object.js';
4
+ import { stringMatchesSomePattern } from '../utils/string.js';
3
5
  import { GLOBAL_OBJ } from '../utils/worldwide.js';
4
6
  import { addHandler, maybeInstrument, triggerHandlers } from './handlers.js';
5
7
 
8
+ /* eslint-disable @typescript-eslint/no-explicit-any */
9
+ /* eslint-disable @typescript-eslint/ban-types */
10
+
11
+ /**
12
+ * Filter out console messages that match the given strings or regular expressions.
13
+ * These will neither be passed to the handler, and they will also not be logged to the user, unless they have debug enabled.
14
+ * This is a set to avoid duplicate integration setups to add the same filter multiple times.
15
+ */
16
+ const _filter = new Set([]);
17
+
6
18
  /**
7
19
  * Add an instrumentation handler for when a console.xxx method is called.
8
20
  * Returns a function to remove the handler.
@@ -17,6 +29,22 @@ function addConsoleInstrumentationHandler(handler) {
17
29
  return removeHandler;
18
30
  }
19
31
 
32
+ /**
33
+ * Add a filter to the console instrumentation to filter out console messages that match the given strings or regular expressions.
34
+ * Returns a function to remove the filter.
35
+ */
36
+ function addConsoleInstrumentationFilter(filter) {
37
+ for (const f of filter) {
38
+ _filter.add(f);
39
+ }
40
+
41
+ return () => {
42
+ for (const f of filter) {
43
+ _filter.delete(f);
44
+ }
45
+ };
46
+ }
47
+
20
48
  function instrumentConsole() {
21
49
  if (!('console' in GLOBAL_OBJ)) {
22
50
  return;
@@ -31,14 +59,25 @@ function instrumentConsole() {
31
59
  originalConsoleMethods[level] = originalConsoleMethod;
32
60
 
33
61
  return function (...args) {
34
- triggerHandlers('console', { args, level } );
35
-
62
+ const firstArg = args[0];
36
63
  const log = originalConsoleMethods[level];
37
- log?.apply(GLOBAL_OBJ.console, args);
64
+
65
+ const isFiltered = _filter.size && typeof firstArg === 'string' && stringMatchesSomePattern(firstArg, _filter);
66
+
67
+ // Only trigger handlers for non-filtered messages
68
+ if (!isFiltered) {
69
+ triggerHandlers('console', { args, level } );
70
+ }
71
+
72
+ // Only log filtered messages in debug mode
73
+ if (!isFiltered || (DEBUG_BUILD && debug.isEnabled())) {
74
+ // Call original console method
75
+ log?.apply(GLOBAL_OBJ.console, args);
76
+ }
38
77
  };
39
78
  });
40
79
  });
41
80
  }
42
81
 
43
- export { addConsoleInstrumentationHandler };
82
+ export { addConsoleInstrumentationFilter, addConsoleInstrumentationHandler };
44
83
  //# sourceMappingURL=console.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"console.js","sources":["../../../src/instrument/console.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/ban-types */\nimport type { ConsoleLevel, HandlerDataConsole } from '../types-hoist/instrument';\nimport { CONSOLE_LEVELS, originalConsoleMethods } from '../utils/debug-logger';\nimport { fill } from '../utils/object';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\nimport { addHandler, maybeInstrument, triggerHandlers } from './handlers';\n\n/**\n * Add an instrumentation handler for when a console.xxx method is called.\n * Returns a function to remove the handler.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nexport function addConsoleInstrumentationHandler(handler: (data: HandlerDataConsole) => void): () => void {\n const type = 'console';\n const removeHandler = addHandler(type, handler);\n maybeInstrument(type, instrumentConsole);\n return removeHandler;\n}\n\nfunction instrumentConsole(): void {\n if (!('console' in GLOBAL_OBJ)) {\n return;\n }\n\n CONSOLE_LEVELS.forEach(function (level: ConsoleLevel): void {\n if (!(level in GLOBAL_OBJ.console)) {\n return;\n }\n\n fill(GLOBAL_OBJ.console, level, function (originalConsoleMethod: () => any): Function {\n originalConsoleMethods[level] = originalConsoleMethod;\n\n return function (...args: any[]): void {\n triggerHandlers('console', { args, level } as HandlerDataConsole);\n\n const log = originalConsoleMethods[level];\n log?.apply(GLOBAL_OBJ.console, args);\n };\n });\n });\n}\n"],"names":[],"mappings":";;;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gCAAgC,CAAC,OAAO,EAAkD;AAC1G,EAAE,MAAM,IAAA,GAAO,SAAS;AACxB,EAAE,MAAM,gBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC;AACjD,EAAE,eAAe,CAAC,IAAI,EAAE,iBAAiB,CAAC;AAC1C,EAAE,OAAO,aAAa;AACtB;;AAEA,SAAS,iBAAiB,GAAS;AACnC,EAAE,IAAI,EAAE,aAAa,UAAU,CAAC,EAAE;AAClC,IAAI;AACJ,EAAE;;AAEF,EAAE,cAAc,CAAC,OAAO,CAAC,UAAU,KAAK,EAAsB;AAC9D,IAAI,IAAI,EAAE,KAAA,IAAS,UAAU,CAAC,OAAO,CAAC,EAAE;AACxC,MAAM;AACN,IAAI;;AAEJ,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,qBAAqB,EAAuB;AAC1F,MAAM,sBAAsB,CAAC,KAAK,CAAA,GAAI,qBAAqB;;AAE3D,MAAM,OAAO,UAAU,GAAG,IAAI,EAAe;AAC7C,QAAQ,eAAe,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,KAAA,EAAM,EAAwB;;AAEzE,QAAQ,MAAM,GAAA,GAAM,sBAAsB,CAAC,KAAK,CAAC;AACjD,QAAQ,GAAG,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC;AAC5C,MAAM,CAAC;AACP,IAAI,CAAC,CAAC;AACN,EAAE,CAAC,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"console.js","sources":["../../../src/instrument/console.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/ban-types */\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { ConsoleLevel, HandlerDataConsole } from '../types-hoist/instrument';\nimport { CONSOLE_LEVELS, originalConsoleMethods } from '../utils/debug-logger';\nimport { fill } from '../utils/object';\nimport { stringMatchesSomePattern } from '../utils/string';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\nimport { addHandler, maybeInstrument, triggerHandlers } from './handlers';\nimport { debug } from '../utils/debug-logger';\n\n/**\n * Filter out console messages that match the given strings or regular expressions.\n * These will neither be passed to the handler, and they will also not be logged to the user, unless they have debug enabled.\n * This is a set to avoid duplicate integration setups to add the same filter multiple times.\n */\nconst _filter = new Set<string | RegExp>([]);\n\n/**\n * Add an instrumentation handler for when a console.xxx method is called.\n * Returns a function to remove the handler.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nexport function addConsoleInstrumentationHandler(handler: (data: HandlerDataConsole) => void): () => void {\n const type = 'console';\n const removeHandler = addHandler(type, handler);\n maybeInstrument(type, instrumentConsole);\n return removeHandler;\n}\n\n/**\n * Add a filter to the console instrumentation to filter out console messages that match the given strings or regular expressions.\n * Returns a function to remove the filter.\n */\nexport function addConsoleInstrumentationFilter(filter: (string | RegExp)[]): () => void {\n for (const f of filter) {\n _filter.add(f);\n }\n\n return () => {\n for (const f of filter) {\n _filter.delete(f);\n }\n };\n}\n\n/** Only exported for tests. */\nexport function _INTERNAL_resetConsoleInstrumentationOptions(): void {\n _filter.clear();\n}\n\nfunction instrumentConsole(): void {\n if (!('console' in GLOBAL_OBJ)) {\n return;\n }\n\n CONSOLE_LEVELS.forEach(function (level: ConsoleLevel): void {\n if (!(level in GLOBAL_OBJ.console)) {\n return;\n }\n\n fill(GLOBAL_OBJ.console, level, function (originalConsoleMethod: () => any): Function {\n originalConsoleMethods[level] = originalConsoleMethod;\n\n return function (...args: any[]): void {\n const firstArg = args[0];\n const log = originalConsoleMethods[level];\n\n const isFiltered = _filter.size && typeof firstArg === 'string' && stringMatchesSomePattern(firstArg, _filter);\n\n // Only trigger handlers for non-filtered messages\n if (!isFiltered) {\n triggerHandlers('console', { args, level } as HandlerDataConsole);\n }\n\n // Only log filtered messages in debug mode\n if (!isFiltered || (DEBUG_BUILD && debug.isEnabled())) {\n // Call original console method\n log?.apply(GLOBAL_OBJ.console, args);\n }\n };\n });\n });\n}\n"],"names":[],"mappings":";;;;;;;AAAA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA,MAAM,UAAU,IAAI,GAAG,CAAkB,EAAE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,EAAE,OAAO,CAAC;;AAEtH;AACA,QAAQ,IAAI,CAAC,UAAU,EAAE;AACzB,UAAU,eAAe,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,KAAA,EAAM,EAAwB;AAC3E,QAAQ;;AAER;AACA,QAAQ,IAAI,CAAC,UAAA,KAAe,WAAA,IAAe,KAAK,CAAC,SAAS,EAAE,CAAC,EAAE;AAC/D;AACA,UAAU,GAAG,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC;AAC9C,QAAQ;AACR,MAAM,CAAC;AACP,IAAI,CAAC,CAAC;AACN,EAAE,CAAC,CAAC;AACJ;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { addBreadcrumb } from '../breadcrumbs.js';
2
2
  import { getClient } from '../currentScopes.js';
3
- import { addConsoleInstrumentationHandler } from '../instrument/console.js';
3
+ import { addConsoleInstrumentationHandler, addConsoleInstrumentationFilter } from '../instrument/console.js';
4
4
  import { defineIntegration } from '../integration.js';
5
5
  import { CONSOLE_LEVELS } from '../utils/debug-logger.js';
6
6
  import { severityLevelFromString } from '../utils/severity.js';
@@ -37,8 +37,12 @@ const consoleIntegration = defineIntegration((options = {}) => {
37
37
 
38
38
  addConsoleBreadcrumb(level, args);
39
39
  });
40
-
41
40
  client.registerCleanup(unsubscribe);
41
+
42
+ if (options.filter) {
43
+ const unsubscribe = addConsoleInstrumentationFilter(options.filter);
44
+ client.registerCleanup(unsubscribe);
45
+ }
42
46
  },
43
47
  };
44
48
  });
@@ -1 +1 @@
1
- {"version":3,"file":"console.js","sources":["../../../src/integrations/console.ts"],"sourcesContent":["import { addBreadcrumb } from '../breadcrumbs';\nimport { getClient } from '../currentScopes';\nimport { addConsoleInstrumentationHandler } from '../instrument/console';\nimport { defineIntegration } from '../integration';\nimport type { ConsoleLevel } from '../types-hoist/instrument';\nimport { CONSOLE_LEVELS } from '../utils/debug-logger';\nimport { severityLevelFromString } from '../utils/severity';\nimport { safeJoin } from '../utils/string';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\n\ninterface ConsoleIntegrationOptions {\n levels: ConsoleLevel[];\n}\n\ntype GlobalObjectWithUtil = typeof GLOBAL_OBJ & {\n util: {\n format: (...args: unknown[]) => string;\n };\n};\n\nconst INTEGRATION_NAME = 'Console';\n\n/**\n * Captures calls to the `console` API as breadcrumbs in Sentry.\n *\n * By default the integration instruments `console.debug`, `console.info`, `console.warn`, `console.error`,\n * `console.log`, `console.trace`, and `console.assert`. You can use the `levels` option to customize which\n * levels are captured.\n *\n * @example\n *\n * ```js\n * Sentry.init({\n * integrations: [Sentry.consoleIntegration({ levels: ['error', 'warn'] })],\n * });\n * ```\n */\nexport const consoleIntegration = defineIntegration((options: Partial<ConsoleIntegrationOptions> = {}) => {\n const levels = new Set(options.levels || CONSOLE_LEVELS);\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const unsubscribe = addConsoleInstrumentationHandler(({ args, level }) => {\n if (getClient() !== client || !levels.has(level)) {\n return;\n }\n\n addConsoleBreadcrumb(level, args);\n });\n\n client.registerCleanup(unsubscribe);\n },\n };\n});\n\n/**\n * Capture a console breadcrumb.\n *\n * Exported just for tests.\n */\nexport function addConsoleBreadcrumb(level: ConsoleLevel, args: unknown[]): void {\n const breadcrumb = {\n category: 'console',\n data: {\n arguments: args,\n logger: 'console',\n },\n level: severityLevelFromString(level),\n message: formatConsoleArgs(args),\n };\n\n if (level === 'assert') {\n if (args[0] === false) {\n const assertionArgs = args.slice(1);\n breadcrumb.message =\n assertionArgs.length > 0 ? `Assertion failed: ${formatConsoleArgs(assertionArgs)}` : 'Assertion failed';\n breadcrumb.data.arguments = assertionArgs;\n } else {\n // Don't capture a breadcrumb for passed assertions\n return;\n }\n }\n\n addBreadcrumb(breadcrumb, {\n input: args,\n level,\n });\n}\n\nfunction formatConsoleArgs(values: unknown[]): string {\n return 'util' in GLOBAL_OBJ && typeof (GLOBAL_OBJ as GlobalObjectWithUtil).util.format === 'function'\n ? (GLOBAL_OBJ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K,EAAE;AAC3B,MAAM,MAAM,gBAAgB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACzC,MAAM,UAAU,CAAC,OAAA;AACjB,QAAQ,aAAa,CAAC,MAAA,GAAS,IAAI,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAA,GAAA,kBAAA;AACA,MAAA,UAAA,CAAA,IAAA,CAAA,SAAA,GAAA,aAAA;AACA,IAAA,CAAA,MAAA;AACA;AACA,MAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,aAAA,CAAA,UAAA,EAAA;AACA,IAAA,KAAA,EAAA,IAAA;AACA,IAAA,KAAA;AACA,GAAA,CAAA;AACA;;AAEA,SAAA,iBAAA,CAAA,MAAA,EAAA;AACA,EAAA,OAAA,MAAA,IAAA,UAAA,IAAA,OAAA,CAAA,UAAA,GAAA,IAAA,CAAA,MAAA,KAAA;AACA,MAAA,CAAA,UAAA,GAAA,IAAA,CAAA,MAAA,CAAA,GAAA,MAAA;AACA,MAAA,QAAA,CAAA,MAAA,EAAA,GAAA,CAAA;AACA;;;;"}
1
+ {"version":3,"file":"console.js","sources":["../../../src/integrations/console.ts"],"sourcesContent":["import { addBreadcrumb } from '../breadcrumbs';\nimport { getClient } from '../currentScopes';\nimport { addConsoleInstrumentationFilter, addConsoleInstrumentationHandler } from '../instrument/console';\nimport { defineIntegration } from '../integration';\nimport type { ConsoleLevel } from '../types-hoist/instrument';\nimport { CONSOLE_LEVELS } from '../utils/debug-logger';\nimport { severityLevelFromString } from '../utils/severity';\nimport { safeJoin } from '../utils/string';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\n\ninterface ConsoleIntegrationOptions {\n levels: ConsoleLevel[];\n /**\n * Filter out console messages that match the given strings or regular expressions.\n * These will neither be passed to the handler, and they will also not be logged to the user, unless they have debug enabled.\n */\n filter?: (string | RegExp)[];\n}\n\ntype GlobalObjectWithUtil = typeof GLOBAL_OBJ & {\n util: {\n format: (...args: unknown[]) => string;\n };\n};\n\nconst INTEGRATION_NAME = 'Console';\n\n/**\n * Captures calls to the `console` API as breadcrumbs in Sentry.\n *\n * By default the integration instruments `console.debug`, `console.info`, `console.warn`, `console.error`,\n * `console.log`, `console.trace`, and `console.assert`. You can use the `levels` option to customize which\n * levels are captured.\n *\n * @example\n *\n * ```js\n * Sentry.init({\n * integrations: [Sentry.consoleIntegration({ levels: ['error', 'warn'] })],\n * });\n * ```\n */\nexport const consoleIntegration = defineIntegration((options: Partial<ConsoleIntegrationOptions> = {}) => {\n const levels = new Set(options.levels || CONSOLE_LEVELS);\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const unsubscribe = addConsoleInstrumentationHandler(({ args, level }) => {\n if (getClient() !== client || !levels.has(level)) {\n return;\n }\n\n addConsoleBreadcrumb(level, args);\n });\n client.registerCleanup(unsubscribe);\n\n if (options.filter) {\n const unsubscribe = addConsoleInstrumentationFilter(options.filter);\n client.registerCleanup(unsubscribe);\n }\n },\n };\n});\n\n/**\n * Capture a console breadcrumb.\n *\n * Exported just for tests.\n */\nexport function addConsoleBreadcrumb(level: ConsoleLevel, args: unknown[]): void {\n const breadcrumb = {\n category: 'console',\n data: {\n arguments: args,\n logger: 'console',\n },\n level: severityLevelFromString(level),\n message: formatConsoleArgs(args),\n };\n\n if (level === 'assert') {\n if (args[0] === false) {\n const assertionArgs = args.slice(1);\n breadcrumb.message =\n assertionArgs.length > 0 ? `Assertion failed: ${formatConsoleArgs(assertionArgs)}` : 'Assertion failed';\n breadcrumb.data.arguments = assertionArgs;\n } else {\n // Don't capture a breadcrumb for passed assertions\n return;\n }\n }\n\n addBreadcrumb(breadcrumb, {\n input: args,\n level,\n });\n}\n\nfunction formatConsoleArgs(values: unknown[]): string {\n return 'util' in GLOBAL_OBJ && typeof (GLOBAL_OBJ as GlobalObjectWithUtil).util.format === 'function'\n ? (GLOBAL_OBJ as GlobalObjectWithUtil).util.format(...values)\n : safeJoin(values, ' ');\n}\n"],"names":[],"mappings":";;;;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AAG;;AAEH,EAAE,IAAI,KAAA,KAAU,QAAQ,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,CAAC,CAAA,KAAM,KAAK,EAAE;AAC3B,MAAM,MAAM,gBAAgB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACzC,MAAM,UAAU,CAAC,OAAA;AACjB,QAAQ,aAAa,CAAC,MAAA,GAAS,IAAI,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAA,GAAA,kBAAA;AACA,MAAA,UAAA,CAAA,IAAA,CAAA,SAAA,GAAA,aAAA;AACA,IAAA,CAAA,MAAA;AACA;AACA,MAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,aAAA,CAAA,UAAA,EAAA;AACA,IAAA,KAAA,EAAA,IAAA;AACA,IAAA,KAAA;AACA,GAAA,CAAA;AACA;;AAEA,SAAA,iBAAA,CAAA,MAAA,EAAA;AACA,EAAA,OAAA,MAAA,IAAA,UAAA,IAAA,OAAA,CAAA,UAAA,GAAA,IAAA,CAAA,MAAA,KAAA;AACA,MAAA,CAAA,UAAA,GAAA,IAAA,CAAA,MAAA,CAAA,GAAA,MAAA;AACA,MAAA,QAAA,CAAA,MAAA,EAAA,GAAA,CAAA;AACA;;;;"}
@@ -168,5 +168,76 @@ function wrapAllMCPHandlers(serverInstance) {
168
168
  wrapPromptHandlers(serverInstance);
169
169
  }
170
170
 
171
- export { wrapAllMCPHandlers, wrapPromptHandlers, wrapResourceHandlers, wrapToolHandlers };
171
+ /**
172
+ * Retroactively wraps handlers on tools, resources, and prompts that were registered
173
+ * before `wrapMcpServerWithSentry` was called.
174
+ *
175
+ * The MCP SDK stores registered entries in private maps and invokes them via the entry's
176
+ * own property at call time — `executor` for tools, `readCallback` for resources, and
177
+ * `handler` for prompts. Replacing those properties
178
+ * in-place is therefore equivalent to having wrapped the original registration call.
179
+ *
180
+ * NOTE: This intentionally accesses private MCP SDK internals (`_registeredTools` etc.).
181
+ * The properties and their shapes are verified against @modelcontextprotocol/sdk source:
182
+ * https://github.com/modelcontextprotocol/typescript-sdk/blob/2c0c481cb9dbfd15c8613f765c940a5f5bace94d/packages/server/src/server/mcp.ts#L304
183
+ * When upgrading the MCP SDK, re-verify that these internal maps and their callable
184
+ * properties still exist and are invoked directly (not captured by closure at registration).
185
+ * All access is defensive — if a property is absent or not a function we skip silently.
186
+ * @internal
187
+ */
188
+ function wrapExistingHandlers(serverInstance) {
189
+ const server = serverInstance ;
190
+
191
+ // Tools: MCP SDK calls registeredTool.executor (generated from handler at registration time)
192
+ const registeredTools = server['_registeredTools'];
193
+ if (registeredTools && typeof registeredTools === 'object') {
194
+ for (const [name, tool] of Object.entries(registeredTools )) {
195
+ if (typeof tool['executor'] === 'function') {
196
+ tool['executor'] = createWrappedHandler(tool['executor'] , 'registerTool', name);
197
+ }
198
+ }
199
+ }
200
+
201
+ // Resources: MCP SDK calls registeredResource.readCallback
202
+ const registeredResources = server['_registeredResources'];
203
+ if (registeredResources && typeof registeredResources === 'object') {
204
+ for (const [name, resource] of Object.entries(registeredResources )) {
205
+ if (typeof resource['readCallback'] === 'function') {
206
+ resource['readCallback'] = createWrappedHandler(
207
+ resource['readCallback'] ,
208
+ 'registerResource',
209
+ name,
210
+ );
211
+ }
212
+ }
213
+ }
214
+
215
+ // Resource templates: MCP SDK calls registeredResourceTemplate.readCallback
216
+ const registeredResourceTemplates = server['_registeredResourceTemplates'];
217
+ if (registeredResourceTemplates && typeof registeredResourceTemplates === 'object') {
218
+ for (const [name, template] of Object.entries(
219
+ registeredResourceTemplates ,
220
+ )) {
221
+ if (typeof template['readCallback'] === 'function') {
222
+ template['readCallback'] = createWrappedHandler(
223
+ template['readCallback'] ,
224
+ 'registerResource',
225
+ name,
226
+ );
227
+ }
228
+ }
229
+ }
230
+
231
+ // Prompts: MCP SDK calls registeredPrompt.handler
232
+ const registeredPrompts = server['_registeredPrompts'];
233
+ if (registeredPrompts && typeof registeredPrompts === 'object') {
234
+ for (const [name, prompt] of Object.entries(registeredPrompts )) {
235
+ if (typeof prompt['handler'] === 'function') {
236
+ prompt['handler'] = createWrappedHandler(prompt['handler'] , 'registerPrompt', name);
237
+ }
238
+ }
239
+ }
240
+ }
241
+
242
+ export { wrapAllMCPHandlers, wrapExistingHandlers, wrapPromptHandlers, wrapResourceHandlers, wrapToolHandlers };
172
243
  //# sourceMappingURL=handlers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.js","sources":["../../../../src/integrations/mcp-server/handlers.ts"],"sourcesContent":["/**\n * Handler method wrapping for MCP server instrumentation\n *\n * Provides automatic error capture and span correlation for tool, resource,\n * and prompt handlers.\n */\n\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { debug } from '../../utils/debug-logger';\nimport { fill } from '../../utils/object';\nimport { captureError } from './errorCapture';\nimport type { MCPHandler, MCPServerInstance } from './types';\n\n/**\n * Generic function to wrap MCP server method handlers\n * @internal\n * @param serverInstance - MCP server instance\n * @param methodName - Method name to wrap (tool, resource, prompt)\n */\nfunction wrapMethodHandler(serverInstance: MCPServerInstance, methodName: keyof MCPServerInstance): void {\n fill(serverInstance, methodName, originalMethod => {\n return function (this: MCPServerInstance, name: string, ...args: unknown[]) {\n const handler = args[args.length - 1];\n\n if (typeof handler !== 'function') {\n return (originalMethod as (...args: unknown[]) => unknown).call(this, name, ...args);\n }\n\n const wrappedHandler = createWrappedHandler(handler as MCPHandler, methodName, name);\n return (originalMethod as (...args: unknown[]) => unknown).call(this, name, ...args.slice(0, -1), wrappedHandler);\n };\n });\n}\n\n/**\n * Creates a wrapped handler with span correlation and error capture\n * @internal\n * @param originalHandler - Original handler function\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n * @returns Wrapped handler function\n */\nfunction createWrappedHandler(originalHandler: MCPHandler, methodName: keyof MCPServerInstance, handlerName: string) {\n return function (this: unknown, ...handlerArgs: unknown[]): unknown {\n try {\n return createErrorCapturingHandler.call(this, originalHandler, methodName, handlerName, handlerArgs);\n } catch (error) {\n DEBUG_BUILD && debug.warn('MCP handler wrapping failed:', error);\n return originalHandler.apply(this, handlerArgs);\n }\n };\n}\n\n/**\n * Creates an error-capturing wrapper for handler execution\n * @internal\n * @param originalHandler - Original handler function\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n * @param handlerArgs - Handler arguments\n * @param extraHandlerData - Additional handler context\n * @returns Handler execution result\n */\nfunction createErrorCapturingHandler(\n this: MCPServerInstance,\n originalHandler: MCPHandler,\n methodName: keyof MCPServerInstance,\n handlerName: string,\n handlerArgs: unknown[],\n): unknown {\n try {\n const result = originalHandler.apply(this, handlerArgs);\n\n if (result && typeof result === 'object' && typeof (result as { then?: unknown }).then === 'function') {\n return Promise.resolve(result).catch(error => {\n captureHandlerError(error, methodName, handlerName);\n throw error;\n });\n }\n\n return result;\n } catch (error) {\n captureHandlerError(error as Error, methodName, handlerName);\n throw error;\n }\n}\n\n/**\n * Captures handler execution errors based on handler type\n * @internal\n * @param error - Error to capture\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n */\nfunction captureHandlerError(error: Error, methodName: keyof MCPServerInstance, handlerName: string): void {\n try {\n const extraData: Record<string, unknown> = {};\n\n if (methodName === 'tool' || methodName === 'registerTool') {\n extraData.tool_name = handlerName;\n\n if (\n error.name === 'ProtocolValidationError' ||\n error.message.includes('validation') ||\n error.message.includes('protocol')\n ) {\n captureError(error, 'validation', extraData);\n } else if (\n error.name === 'ServerTimeoutError' ||\n error.message.includes('timed out') ||\n error.message.includes('timeout')\n ) {\n captureError(error, 'timeout', extraData);\n } else {\n captureError(error, 'tool_execution', extraData);\n }\n } else if (methodName === 'resource' || methodName === 'registerResource') {\n extraData.resource_uri = handlerName;\n captureError(error, 'resource_execution', extraData);\n } else if (methodName === 'prompt' || methodName === 'registerPrompt') {\n extraData.prompt_name = handlerName;\n captureError(error, 'prompt_execution', extraData);\n }\n } catch (_captureErr) {\n // noop\n }\n}\n\n/**\n * Wraps tool handlers to associate them with request spans.\n * Instruments both `tool` (legacy API) and `registerTool` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapToolHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.tool === 'function') wrapMethodHandler(serverInstance, 'tool');\n if (typeof serverInstance.registerTool === 'function') wrapMethodHandler(serverInstance, 'registerTool');\n}\n\n/**\n * Wraps resource handlers to associate them with request spans.\n * Instruments both `resource` (legacy API) and `registerResource` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapResourceHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.resource === 'function') wrapMethodHandler(serverInstance, 'resource');\n if (typeof serverInstance.registerResource === 'function') wrapMethodHandler(serverInstance, 'registerResource');\n}\n\n/**\n * Wraps prompt handlers to associate them with request spans.\n * Instruments both `prompt` (legacy API) and `registerPrompt` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapPromptHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.prompt === 'function') wrapMethodHandler(serverInstance, 'prompt');\n if (typeof serverInstance.registerPrompt === 'function') wrapMethodHandler(serverInstance, 'registerPrompt');\n}\n\n/**\n * Wraps all MCP handler types for span correlation.\n * Supports both the legacy API (`tool`, `resource`, `prompt`) and the newer API\n * (`registerTool`, `registerResource`, `registerPrompt`), instrumenting whichever methods are present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapAllMCPHandlers(serverInstance: MCPServerInstance): void {\n wrapToolHandlers(serverInstance);\n wrapResourceHandlers(serverInstance);\n wrapPromptHandlers(serverInstance);\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,cAAc,EAAqB,UAAU,EAAiC;AACzG,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,EAAE,kBAAkB;AACrD,IAAI,OAAO,WAAmC,IAAI,EAAU,GAAG,IAAI,EAAa;AAChF,MAAM,MAAM,OAAA,GAAU,IAAI,CA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cAAc,EAAE,QAAQ,CAAC;AAC9F,EAAE,IAAI,OAAO,cAAc,CAAC,cAAA,KAAmB,UAAU,EAAE,iBAAiB,CAAC,cAAc,EAAE,gBAAgB,CAAC;AAC9G;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,cAAc,EAA2B;AAC5E,EAAE,gBAAgB,CAAC,cAAc,CAAC;AAClC,EAAE,oBAAoB,CAAC,cAAc,CAAC;AACtC,EAAE,kBAAkB,CAAC,cAAc,CAAC;AACpC;;;;"}
1
+ {"version":3,"file":"handlers.js","sources":["../../../../src/integrations/mcp-server/handlers.ts"],"sourcesContent":["/**\n * Handler method wrapping for MCP server instrumentation\n *\n * Provides automatic error capture and span correlation for tool, resource,\n * and prompt handlers.\n */\n\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { debug } from '../../utils/debug-logger';\nimport { fill } from '../../utils/object';\nimport { captureError } from './errorCapture';\nimport type { MCPHandler, MCPServerInstance } from './types';\n\n/**\n * Generic function to wrap MCP server method handlers\n * @internal\n * @param serverInstance - MCP server instance\n * @param methodName - Method name to wrap (tool, resource, prompt)\n */\nfunction wrapMethodHandler(serverInstance: MCPServerInstance, methodName: keyof MCPServerInstance): void {\n fill(serverInstance, methodName, originalMethod => {\n return function (this: MCPServerInstance, name: string, ...args: unknown[]) {\n const handler = args[args.length - 1];\n\n if (typeof handler !== 'function') {\n return (originalMethod as (...args: unknown[]) => unknown).call(this, name, ...args);\n }\n\n const wrappedHandler = createWrappedHandler(handler as MCPHandler, methodName, name);\n return (originalMethod as (...args: unknown[]) => unknown).call(this, name, ...args.slice(0, -1), wrappedHandler);\n };\n });\n}\n\n/**\n * Creates a wrapped handler with span correlation and error capture\n * @internal\n * @param originalHandler - Original handler function\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n * @returns Wrapped handler function\n */\nfunction createWrappedHandler(originalHandler: MCPHandler, methodName: keyof MCPServerInstance, handlerName: string) {\n return function (this: unknown, ...handlerArgs: unknown[]): unknown {\n try {\n return createErrorCapturingHandler.call(this, originalHandler, methodName, handlerName, handlerArgs);\n } catch (error) {\n DEBUG_BUILD && debug.warn('MCP handler wrapping failed:', error);\n return originalHandler.apply(this, handlerArgs);\n }\n };\n}\n\n/**\n * Creates an error-capturing wrapper for handler execution\n * @internal\n * @param originalHandler - Original handler function\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n * @param handlerArgs - Handler arguments\n * @param extraHandlerData - Additional handler context\n * @returns Handler execution result\n */\nfunction createErrorCapturingHandler(\n this: MCPServerInstance,\n originalHandler: MCPHandler,\n methodName: keyof MCPServerInstance,\n handlerName: string,\n handlerArgs: unknown[],\n): unknown {\n try {\n const result = originalHandler.apply(this, handlerArgs);\n\n if (result && typeof result === 'object' && typeof (result as { then?: unknown }).then === 'function') {\n return Promise.resolve(result).catch(error => {\n captureHandlerError(error, methodName, handlerName);\n throw error;\n });\n }\n\n return result;\n } catch (error) {\n captureHandlerError(error as Error, methodName, handlerName);\n throw error;\n }\n}\n\n/**\n * Captures handler execution errors based on handler type\n * @internal\n * @param error - Error to capture\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n */\nfunction captureHandlerError(error: Error, methodName: keyof MCPServerInstance, handlerName: string): void {\n try {\n const extraData: Record<string, unknown> = {};\n\n if (methodName === 'tool' || methodName === 'registerTool') {\n extraData.tool_name = handlerName;\n\n if (\n error.name === 'ProtocolValidationError' ||\n error.message.includes('validation') ||\n error.message.includes('protocol')\n ) {\n captureError(error, 'validation', extraData);\n } else if (\n error.name === 'ServerTimeoutError' ||\n error.message.includes('timed out') ||\n error.message.includes('timeout')\n ) {\n captureError(error, 'timeout', extraData);\n } else {\n captureError(error, 'tool_execution', extraData);\n }\n } else if (methodName === 'resource' || methodName === 'registerResource') {\n extraData.resource_uri = handlerName;\n captureError(error, 'resource_execution', extraData);\n } else if (methodName === 'prompt' || methodName === 'registerPrompt') {\n extraData.prompt_name = handlerName;\n captureError(error, 'prompt_execution', extraData);\n }\n } catch (_captureErr) {\n // noop\n }\n}\n\n/**\n * Wraps tool handlers to associate them with request spans.\n * Instruments both `tool` (legacy API) and `registerTool` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapToolHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.tool === 'function') wrapMethodHandler(serverInstance, 'tool');\n if (typeof serverInstance.registerTool === 'function') wrapMethodHandler(serverInstance, 'registerTool');\n}\n\n/**\n * Wraps resource handlers to associate them with request spans.\n * Instruments both `resource` (legacy API) and `registerResource` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapResourceHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.resource === 'function') wrapMethodHandler(serverInstance, 'resource');\n if (typeof serverInstance.registerResource === 'function') wrapMethodHandler(serverInstance, 'registerResource');\n}\n\n/**\n * Wraps prompt handlers to associate them with request spans.\n * Instruments both `prompt` (legacy API) and `registerPrompt` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapPromptHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.prompt === 'function') wrapMethodHandler(serverInstance, 'prompt');\n if (typeof serverInstance.registerPrompt === 'function') wrapMethodHandler(serverInstance, 'registerPrompt');\n}\n\n/**\n * Wraps all MCP handler types for span correlation.\n * Supports both the legacy API (`tool`, `resource`, `prompt`) and the newer API\n * (`registerTool`, `registerResource`, `registerPrompt`), instrumenting whichever methods are present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapAllMCPHandlers(serverInstance: MCPServerInstance): void {\n wrapToolHandlers(serverInstance);\n wrapResourceHandlers(serverInstance);\n wrapPromptHandlers(serverInstance);\n}\n\n/**\n * Retroactively wraps handlers on tools, resources, and prompts that were registered\n * before `wrapMcpServerWithSentry` was called.\n *\n * The MCP SDK stores registered entries in private maps and invokes them via the entry's\n * own property at call time — `executor` for tools, `readCallback` for resources, and\n * `handler` for prompts. Replacing those properties\n * in-place is therefore equivalent to having wrapped the original registration call.\n *\n * NOTE: This intentionally accesses private MCP SDK internals (`_registeredTools` etc.).\n * The properties and their shapes are verified against @modelcontextprotocol/sdk source:\n * https://github.com/modelcontextprotocol/typescript-sdk/blob/2c0c481cb9dbfd15c8613f765c940a5f5bace94d/packages/server/src/server/mcp.ts#L304\n * When upgrading the MCP SDK, re-verify that these internal maps and their callable\n * properties still exist and are invoked directly (not captured by closure at registration).\n * All access is defensive — if a property is absent or not a function we skip silently.\n * @internal\n */\nexport function wrapExistingHandlers(serverInstance: MCPServerInstance): void {\n const server = serverInstance as unknown as Record<string, unknown>;\n\n // Tools: MCP SDK calls registeredTool.executor (generated from handler at registration time)\n const registeredTools = server['_registeredTools'];\n if (registeredTools && typeof registeredTools === 'object') {\n for (const [name, tool] of Object.entries(registeredTools as Record<string, Record<string, unknown>>)) {\n if (typeof tool['executor'] === 'function') {\n tool['executor'] = createWrappedHandler(tool['executor'] as MCPHandler, 'registerTool', name);\n }\n }\n }\n\n // Resources: MCP SDK calls registeredResource.readCallback\n const registeredResources = server['_registeredResources'];\n if (registeredResources && typeof registeredResources === 'object') {\n for (const [name, resource] of Object.entries(registeredResources as Record<string, Record<string, unknown>>)) {\n if (typeof resource['readCallback'] === 'function') {\n resource['readCallback'] = createWrappedHandler(\n resource['readCallback'] as MCPHandler,\n 'registerResource',\n name,\n );\n }\n }\n }\n\n // Resource templates: MCP SDK calls registeredResourceTemplate.readCallback\n const registeredResourceTemplates = server['_registeredResourceTemplates'];\n if (registeredResourceTemplates && typeof registeredResourceTemplates === 'object') {\n for (const [name, template] of Object.entries(\n registeredResourceTemplates as Record<string, Record<string, unknown>>,\n )) {\n if (typeof template['readCallback'] === 'function') {\n template['readCallback'] = createWrappedHandler(\n template['readCallback'] as MCPHandler,\n 'registerResource',\n name,\n );\n }\n }\n }\n\n // Prompts: MCP SDK calls registeredPrompt.handler\n const registeredPrompts = server['_registeredPrompts'];\n if (registeredPrompts && typeof registeredPrompts === 'object') {\n for (const [name, prompt] of Object.entries(registeredPrompts as Record<string, Record<string, unknown>>)) {\n if (typeof prompt['handler'] === 'function') {\n prompt['handler'] = createWrappedHandler(prompt['handler'] as MCPHandler, 'registerPrompt', name);\n }\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,cAAc,EAAqB,UAAU,EAAiC;AACzG,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,EAAE,kBAAkB;AACrD,IAAI,OAAO,WAAmC,IAAI,EAAU,GAAG,IAAI,EAAa;AAChF,MAAM,MAAM,OAAA,GAAU,IAAI,CAAC,IAAI,CAAC,MAAA,GAAS,CAAC,CAAC;;AAE3C,MAAM,IAAI,OAAO,OAAA,KAAY,UAAU,EAAE;AACzC,QAAQ,OAAO,CAAC,cAAA,GAAmD,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;AAC5F,MAAM;;AAEN,MAAM,MAAM,cAAA,GAAiB,oBAAoB,CAAC,UAAuB,UAAU,EAAE,IAAI,CAAC;AAC1F,MAAM,OAAO,CAAC,cAAA,GAAmD,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,cAAc,CAAC;AACvH,IAAI,CAAC;AACL,EAAE,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,oBAAoB,CAAC,eAAe,EAAc,UAAU,EAA2B,WAAW,EAAU;AACrH,EAAE,OAAO,WAAyB,GAAG,WAAW,EAAsB;AACtE,IAAI,IAAI;AACR,MAAM,OAAO,2BAA2B,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,CAAC;AAC1G,IAAI,CAAA,CAAE,OAAO,KAAK,EAAE;AACpB,MAAM,WAAA,IAAe,KAAK,CAAC,IAAI,CAAC,8BAA8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C,IAAI,EAAE,MAAM,CAAA,IAAK,MAAM,CAAC,OAAO,CAAC,iBAAA,EAA6D,EAAE;AAC/G,MAAM,IAAI,OAAO,MAAM,CAAC,SAAS,CAAA,KAAM,UAAU,EAAE;AACnD,QAAQ,MAAM,CAAC,SAAS,CAAA,GAAI,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAA,GAAiB,gBAAgB,EAAE,IAAI,CAAC;AACzG,MAAM;AACN,IAAI;AACJ,EAAE;AACF;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { getClient } from '../../currentScopes.js';
2
2
  import { fill } from '../../utils/object.js';
3
- import { wrapAllMCPHandlers } from './handlers.js';
3
+ import { wrapAllMCPHandlers, wrapExistingHandlers } from './handlers.js';
4
4
  import { wrapTransportOnMessage, wrapTransportSend, wrapTransportOnClose, wrapTransportError } from './transport.js';
5
5
  import { validateMcpServerInstance } from './validation.js';
6
6
 
@@ -17,17 +17,24 @@ const wrappedMcpServerInstances = new WeakSet();
17
17
  * and versions that expose the newer `registerTool`/`registerResource`/`registerPrompt` API (introduced in 1.x, sole API in 2.x).
18
18
  * Automatically instruments transport methods and handler functions for comprehensive monitoring.
19
19
  *
20
+ * Both call orderings are supported: wrapping before or after registering tools, resources,
21
+ * and prompts. Sentry patches the registration methods for future handlers and retroactively
22
+ * wraps any already-registered ones. Wrapping at construction time is recommended by
23
+ * convention (consistent with other SDK integrations), but is not required.
24
+ *
20
25
  * @example
21
26
  * ```typescript
22
27
  * import * as Sentry from '@sentry/core';
23
28
  * import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
24
29
  * import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
25
30
  *
26
- * // Default: inputs/outputs captured based on sendDefaultPii option
31
+ * // Wrap first, then register tools this is the correct order
27
32
  * const server = Sentry.wrapMcpServerWithSentry(
28
33
  * new McpServer({ name: "my-server", version: "1.0.0" })
29
34
  * );
30
35
  *
36
+ * server.registerTool('my-tool', schema, handler);
37
+ *
31
38
  * // Explicitly control input/output capture
32
39
  * const server = Sentry.wrapMcpServerWithSentry(
33
40
  * new McpServer({ name: "my-server", version: "1.0.0" }),
@@ -79,6 +86,8 @@ function wrapMcpServerWithSentry(mcpServerInstance, options) {
79
86
 
80
87
  wrapAllMCPHandlers(serverInstance);
81
88
 
89
+ wrapExistingHandlers(serverInstance);
90
+
82
91
  wrappedMcpServerInstances.add(mcpServerInstance);
83
92
  return mcpServerInstance;
84
93
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/integrations/mcp-server/index.ts"],"sourcesContent":["import { getClient } from '../../currentScopes';\nimport { fill } from '../../utils/object';\nimport { wrapAllMCPHandlers } from './handlers';\nimport { wrapTransportError, wrapTransportOnClose, wrapTransportOnMessage, wrapTransportSend } from './transport';\nimport type { MCPServerInstance, McpServerWrapperOptions, MCPTransport, ResolvedMcpOptions } from './types';\nimport { validateMcpServerInstance } from './validation';\n\n/**\n * Tracks wrapped MCP server instances to prevent double-wrapping\n * @internal\n */\nconst wrappedMcpServerInstances = new WeakSet();\n\n/**\n * Wraps a MCP Server instance from the `@modelcontextprotocol/sdk` package with Sentry instrumentation.\n *\n * Compatible with versions `^1.9.0` of the `@modelcontextprotocol/sdk` package (legacy `tool`/`resource`/`prompt` API)\n * and versions that expose the newer `registerTool`/`registerResource`/`registerPrompt` API (introduced in 1.x, sole API in 2.x).\n * Automatically instruments transport methods and handler functions for comprehensive monitoring.\n *\n * @example\n * ```typescript\n * import * as Sentry from '@sentry/core';\n * import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n * import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\n *\n * // Default: inputs/outputs captured based on sendDefaultPii option\n * const server = Sentry.wrapMcpServerWithSentry(\n * new McpServer({ name: \"my-server\", version: \"1.0.0\" })\n * );\n *\n * // Explicitly control input/output capture\n * const server = Sentry.wrapMcpServerWithSentry(\n * new McpServer({ name: \"my-server\", version: \"1.0.0\" }),\n * { recordInputs: true, recordOutputs: false }\n * );\n *\n * const transport = new StreamableHTTPServerTransport();\n * await server.connect(transport);\n * ```\n *\n * @param mcpServerInstance - MCP server instance to instrument\n * @param options - Optional configuration for recording inputs and outputs\n * @returns Instrumented server instance (same reference)\n */\nexport function wrapMcpServerWithSentry<S extends object>(mcpServerInstance: S, options?: McpServerWrapperOptions): S {\n if (wrappedMcpServerInstances.has(mcpServerInstance)) {\n return mcpServerInstance;\n }\n\n if (!validateMcpServerInstance(mcpServerInstance)) {\n return mcpServerInstance;\n }\n\n const serverInstance = mcpServerInstance as MCPServerInstance;\n const client = getClient();\n const sendDefaultPii = Boolean(client?.getOptions().sendDefaultPii);\n\n const resolvedOptions: ResolvedMcpOptions = {\n recordInputs: options?.recordInputs ?? sendDefaultPii,\n recordOutputs: options?.recordOutputs ?? sendDefaultPii,\n };\n\n fill(serverInstance, 'connect', originalConnect => {\n return async function (this: MCPServerInstance, transport: MCPTransport, ...restArgs: unknown[]) {\n const result = await (originalConnect as (...args: unknown[]) => Promise<unknown>).call(\n this,\n transport,\n ...restArgs,\n );\n\n wrapTransportOnMessage(transport, resolvedOptions);\n wrapTransportSend(transport, resolvedOptions);\n wrapTransportOnClose(transport);\n wrapTransportError(transport);\n\n return result;\n };\n });\n\n wrapAllMCPHandlers(serverInstance);\n\n wrappedMcpServerInstances.add(mcpServerInstance);\n return mcpServerInstance;\n}\n"],"names":[],"mappings":";;;;;;AAOA;AACA;AACA;AACA;AACA,MAAM,yBAAA,GAA4B,IAAI,OAAO,EAAE;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,uBAAuB,CAAmB,iBAAiB,EAAK,OAAO,EAA+B;AACtH,EAAE,IAAI,yBAAyB,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE;AACxD,IAAI,OAAO,iBAAiB;AAC5B,EAAE;;AAEF,EAAE,IAAI,CAAC,yBAAyB,CAAC,iBAAiB,CAAC,EAAE;AACrD,IAAI,OAAO,iBAAiB;AAC5B,EAAE;;AAEF,EAAE,MAAM,cAAA,GAAiB,iBAAA;AACzB,EAAE,MAAM,MAAA,GAAS,SAAS,EAAE;AAC5B,EAAE,MAAM,cAAA,GAAiB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,cAAc,CAAC;;AAErE,EAAE,MAAM,eAAe,GAAuB;AAC9C,IAAI,YAAY,EAAE,OAAO,EAAE,YAAA,IAAgB,cAAc;AACzD,IAAI,aAAa,EAAE,OAAO,EAAE,aAAA,IAAiB,cAAc;AAC3D,GAAG;;AAEH,EAAE,IAAI,CAAC,cAAc,EAAE,SAAS,EAAE,mBAAmB;AACrD,IAAI,OAAO,iBAAyC,SAAS,EAAgB,GAAG,QAAQ,EAAa;AACrG,MAAM,MAAM,SAAS,MAAM,CAAC,eAAA,GAA6D,IAAI;AAC7F,QAAQ,IAAI;AACZ,QAAQ,SAAS;AACjB,QAAQ,GAAG,QAAQ;AACnB,OAAO;;AAEP,MAAM,sBAAsB,CAAC,SAAS,EAAE,eAAe,CAAC;AACxD,MAAM,iBAAiB,CAAC,SAAS,EAAE,eAAe,CAAC;AACnD,MAAM,oBAAoB,CAAC,SAAS,CAAC;AACrC,MAAM,kBAAkB,CAAC,SAAS,CAAC;;AAEnC,MAAM,OAAO,MAAM;AACnB,IAAI,CAAC;AACL,EAAE,CAAC,CAAC;;AAEJ,EAAE,kBAAkB,CAAC,cAAc,CAAC;;AAEpC,EAAE,yBAAyB,CAAC,GAAG,CAAC,iBAAiB,CAAC;AAClD,EAAE,OAAO,iBAAiB;AAC1B;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/integrations/mcp-server/index.ts"],"sourcesContent":["import { getClient } from '../../currentScopes';\nimport { fill } from '../../utils/object';\nimport { wrapAllMCPHandlers, wrapExistingHandlers } from './handlers';\nimport { wrapTransportError, wrapTransportOnClose, wrapTransportOnMessage, wrapTransportSend } from './transport';\nimport type { MCPServerInstance, McpServerWrapperOptions, MCPTransport, ResolvedMcpOptions } from './types';\nimport { validateMcpServerInstance } from './validation';\n\n/**\n * Tracks wrapped MCP server instances to prevent double-wrapping\n * @internal\n */\nconst wrappedMcpServerInstances = new WeakSet();\n\n/**\n * Wraps a MCP Server instance from the `@modelcontextprotocol/sdk` package with Sentry instrumentation.\n *\n * Compatible with versions `^1.9.0` of the `@modelcontextprotocol/sdk` package (legacy `tool`/`resource`/`prompt` API)\n * and versions that expose the newer `registerTool`/`registerResource`/`registerPrompt` API (introduced in 1.x, sole API in 2.x).\n * Automatically instruments transport methods and handler functions for comprehensive monitoring.\n *\n * Both call orderings are supported: wrapping before or after registering tools, resources,\n * and prompts. Sentry patches the registration methods for future handlers and retroactively\n * wraps any already-registered ones. Wrapping at construction time is recommended by\n * convention (consistent with other SDK integrations), but is not required.\n *\n * @example\n * ```typescript\n * import * as Sentry from '@sentry/core';\n * import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n * import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\n *\n * // Wrap first, then register tools this is the correct order\n * const server = Sentry.wrapMcpServerWithSentry(\n * new McpServer({ name: \"my-server\", version: \"1.0.0\" })\n * );\n *\n * server.registerTool('my-tool', schema, handler);\n *\n * // Explicitly control input/output capture\n * const server = Sentry.wrapMcpServerWithSentry(\n * new McpServer({ name: \"my-server\", version: \"1.0.0\" }),\n * { recordInputs: true, recordOutputs: false }\n * );\n *\n * const transport = new StreamableHTTPServerTransport();\n * await server.connect(transport);\n * ```\n *\n * @param mcpServerInstance - MCP server instance to instrument\n * @param options - Optional configuration for recording inputs and outputs\n * @returns Instrumented server instance (same reference)\n */\nexport function wrapMcpServerWithSentry<S extends object>(mcpServerInstance: S, options?: McpServerWrapperOptions): S {\n if (wrappedMcpServerInstances.has(mcpServerInstance)) {\n return mcpServerInstance;\n }\n\n if (!validateMcpServerInstance(mcpServerInstance)) {\n return mcpServerInstance;\n }\n\n const serverInstance = mcpServerInstance as MCPServerInstance;\n const client = getClient();\n const sendDefaultPii = Boolean(client?.getOptions().sendDefaultPii);\n\n const resolvedOptions: ResolvedMcpOptions = {\n recordInputs: options?.recordInputs ?? sendDefaultPii,\n recordOutputs: options?.recordOutputs ?? sendDefaultPii,\n };\n\n fill(serverInstance, 'connect', originalConnect => {\n return async function (this: MCPServerInstance, transport: MCPTransport, ...restArgs: unknown[]) {\n const result = await (originalConnect as (...args: unknown[]) => Promise<unknown>).call(\n this,\n transport,\n ...restArgs,\n );\n\n wrapTransportOnMessage(transport, resolvedOptions);\n wrapTransportSend(transport, resolvedOptions);\n wrapTransportOnClose(transport);\n wrapTransportError(transport);\n\n return result;\n };\n });\n\n wrapAllMCPHandlers(serverInstance);\n\n wrapExistingHandlers(serverInstance);\n\n wrappedMcpServerInstances.add(mcpServerInstance);\n return mcpServerInstance;\n}\n"],"names":[],"mappings":";;;;;;AAOA;AACA;AACA;AACA;AACA,MAAM,yBAAA,GAA4B,IAAI,OAAO,EAAE;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,uBAAuB,CAAmB,iBAAiB,EAAK,OAAO,EAA+B;AACtH,EAAE,IAAI,yBAAyB,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE;AACxD,IAAI,OAAO,iBAAiB;AAC5B,EAAE;;AAEF,EAAE,IAAI,CAAC,yBAAyB,CAAC,iBAAiB,CAAC,EAAE;AACrD,IAAI,OAAO,iBAAiB;AAC5B,EAAE;;AAEF,EAAE,MAAM,cAAA,GAAiB,iBAAA;AACzB,EAAE,MAAM,MAAA,GAAS,SAAS,EAAE;AAC5B,EAAE,MAAM,cAAA,GAAiB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,cAAc,CAAC;;AAErE,EAAE,MAAM,eAAe,GAAuB;AAC9C,IAAI,YAAY,EAAE,OAAO,EAAE,YAAA,IAAgB,cAAc;AACzD,IAAI,aAAa,EAAE,OAAO,EAAE,aAAA,IAAiB,cAAc;AAC3D,GAAG;;AAEH,EAAE,IAAI,CAAC,cAAc,EAAE,SAAS,EAAE,mBAAmB;AACrD,IAAI,OAAO,iBAAyC,SAAS,EAAgB,GAAG,QAAQ,EAAa;AACrG,MAAM,MAAM,SAAS,MAAM,CAAC,eAAA,GAA6D,IAAI;AAC7F,QAAQ,IAAI;AACZ,QAAQ,SAAS;AACjB,QAAQ,GAAG,QAAQ;AACnB,OAAO;;AAEP,MAAM,sBAAsB,CAAC,SAAS,EAAE,eAAe,CAAC;AACxD,MAAM,iBAAiB,CAAC,SAAS,EAAE,eAAe,CAAC;AACnD,MAAM,oBAAoB,CAAC,SAAS,CAAC;AACrC,MAAM,kBAAkB,CAAC,SAAS,CAAC;;AAEnC,MAAM,OAAO,MAAM;AACnB,IAAI,CAAC;AACL,EAAE,CAAC,CAAC;;AAEJ,EAAE,kBAAkB,CAAC,cAAc,CAAC;;AAEpC,EAAE,oBAAoB,CAAC,cAAc,CAAC;;AAEtC,EAAE,yBAAyB,CAAC,GAAG,CAAC,iBAAiB,CAAC;AAClD,EAAE,OAAO,iBAAiB;AAC1B;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"10.52.0","sideEffects":false}
1
+ {"type":"module","version":"10.53.1","sideEffects":false}
@@ -53,13 +53,13 @@ const SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = 'sentry.sdk.name';
53
53
  /** The version of the Sentry SDK */
54
54
  const SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = 'sentry.sdk.version';
55
55
 
56
- /** The user ID (gated by sendDefaultPii) */
56
+ /** The user ID */
57
57
  const SEMANTIC_ATTRIBUTE_USER_ID = 'user.id';
58
- /** The user email (gated by sendDefaultPii) */
58
+ /** The user email */
59
59
  const SEMANTIC_ATTRIBUTE_USER_EMAIL = 'user.email';
60
- /** The user IP address (gated by sendDefaultPii) */
60
+ /** The user IP address */
61
61
  const SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = 'user.ip_address';
62
- /** The user username (gated by sendDefaultPii) */
62
+ /** The user username */
63
63
  const SEMANTIC_ATTRIBUTE_USER_USERNAME = 'user.name';
64
64
 
65
65
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"semanticAttributes.js","sources":["../../src/semanticAttributes.ts"],"sourcesContent":["/**\n * Use this attribute to represent the source of a span name.\n * Must be one of: custom, url, route, view, component, task\n * TODO(v11): rename this to sentry.span.source'\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = 'sentry.source';\n\n/**\n * Attributes that holds the sample rate that was locally applied to a span.\n * If this attribute is not defined, it means that the span inherited a sampling decision.\n *\n * NOTE: Is only defined on root spans.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = 'sentry.sample_rate';\n\n/**\n * Attribute holding the sample rate of the previous trace.\n * This is used to sample consistently across subsequent traces in the browser SDK.\n *\n * Note: Only defined on root spans, if opted into consistent sampling\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE = 'sentry.previous_trace_sample_rate';\n\n/**\n * Use this attribute to represent the operation of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_OP = 'sentry.op';\n\n/**\n * Use this attribute to represent the origin of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = 'sentry.origin';\n\n/** The reason why an idle span finished. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON = 'sentry.idle_span_finish_reason';\n\n/** The unit of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT = 'sentry.measurement_unit';\n\n/** The value of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE = 'sentry.measurement_value';\n\n/** The release version of the application */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = 'sentry.release';\n/** The environment name (e.g., \"production\", \"staging\", \"development\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = 'sentry.environment';\n/** The segment name (e.g., \"GET /users\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME = 'sentry.segment.name';\n/** The id of the segment that this span belongs to. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID = 'sentry.segment.id';\n/** The name of the Sentry SDK (e.g., \"sentry.php\", \"sentry.javascript\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = 'sentry.sdk.name';\n/** The version of the Sentry SDK */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = 'sentry.sdk.version';\n\n/** The user ID (gated by sendDefaultPii) */\nexport const SEMANTIC_ATTRIBUTE_USER_ID = 'user.id';\n/** The user email (gated by sendDefaultPii) */\nexport const SEMANTIC_ATTRIBUTE_USER_EMAIL = 'user.email';\n/** The user IP address (gated by sendDefaultPii) */\nexport const SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = 'user.ip_address';\n/** The user username (gated by sendDefaultPii) */\nexport const SEMANTIC_ATTRIBUTE_USER_USERNAME = 'user.name';\n\n/**\n * A custom span name set by users guaranteed to be taken over any automatically\n * inferred name. This attribute is removed before the span is sent.\n *\n * @internal only meant for internal SDK usage\n * @hidden\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME = 'sentry.custom_span_name';\n\n/**\n * The id of the profile that this span occurred in.\n */\nexport const SEMANTIC_ATTRIBUTE_PROFILE_ID = 'sentry.profile_id';\n\nexport const SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = 'sentry.exclusive_time';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_HIT = 'cache.hit';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_KEY = 'cache.key';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = 'cache.item_size';\n\n/** TODO: Remove these once we update to latest semantic conventions */\nexport const SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = 'http.request.method';\nexport const SEMANTIC_ATTRIBUTE_URL_FULL = 'url.full';\n\n/**\n * A span link attribute to mark the link as a special span link.\n *\n * Known values:\n * - `previous_trace`: The span links to the frontend root span of the previous trace.\n * - `next_trace`: The span links to the frontend root span of the next trace. (Not set by the SDK)\n *\n * Other values may be set as appropriate.\n * @see https://develop.sentry.dev/sdk/telemetry/traces/span-links/#link-types\n */\nexport const SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = 'sentry.link.type';\n\n/**\n * =============================================================================\n * GEN AI ATTRIBUTES\n * Based on OpenTelemetry Semantic Conventions for Generative AI\n * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/\n * =============================================================================\n */\n\n/**\n * The conversation ID for linking messages across API calls.\n * For OpenAI Assistants API: thread_id\n * For LangGraph: configurable.thread_id\n */\nexport const GEN_AI_CONVERSATION_ID_ATTRIBUTE = 'gen_ai.conversation.id';\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACO,MAAM,gCAAA,GAAmC;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,qCAAA,GAAwC;;AAErD;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,oDAAA,GAAuD;;AAEpE;AACA;AACA;AACO,MAAM,4BAAA,GAA+B;;AAE5C;AACA;AACA;AACO,MAAM,gCAAA,GAAmC;;AAEhD;AACO,MAAM,iDAAA,GAAoD;;AAEjE;AACO,MAAM,0CAAA,GAA6C;;AAE1D;AACO,MAAM,2CAAA,GAA8C;;AAE3D;AACO,MAAM,iCAAA,GAAoC;AACjD;AACO,MAAM,qCAAA,GAAwC;AACrD;AACO,MAAM,sCAAA,GAAyC;AACtD;AACO,MAAM,oCAAA,GAAuC;AACpD;AACO,MAAM,kCAAA,GAAqC;AAClD;AACO,MAAM,qCAAA,GAAwC;;AAErD;AACO,MAAM,0BAAA,GAA6B;AAC1C;AACO,MAAM,6BAAA,GAAgC;AAC7C;AACO,MAAM,kCAAA,GAAqC;AAClD;AACO,MAAM,gCAAA,GAAmC;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,0CAAA,GAA6C;;AAE1D;AACA;AACA;AACO,MAAM,6BAAA,GAAgC;;AAEtC,MAAM,iCAAA,GAAoC;;AAE1C,MAAM,4BAAA,GAA+B;;AAErC,MAAM,4BAAA,GAA+B;;AAErC,MAAM,kCAAA,GAAqC;;AAElD;AACO,MAAM,sCAAA,GAAyC;AAC/C,MAAM,2BAAA,GAA8B;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,iCAAA,GAAoC;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,gCAAA,GAAmC;;;;"}
1
+ {"version":3,"file":"semanticAttributes.js","sources":["../../src/semanticAttributes.ts"],"sourcesContent":["/**\n * Use this attribute to represent the source of a span name.\n * Must be one of: custom, url, route, view, component, task\n * TODO(v11): rename this to sentry.span.source'\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = 'sentry.source';\n\n/**\n * Attributes that holds the sample rate that was locally applied to a span.\n * If this attribute is not defined, it means that the span inherited a sampling decision.\n *\n * NOTE: Is only defined on root spans.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = 'sentry.sample_rate';\n\n/**\n * Attribute holding the sample rate of the previous trace.\n * This is used to sample consistently across subsequent traces in the browser SDK.\n *\n * Note: Only defined on root spans, if opted into consistent sampling\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE = 'sentry.previous_trace_sample_rate';\n\n/**\n * Use this attribute to represent the operation of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_OP = 'sentry.op';\n\n/**\n * Use this attribute to represent the origin of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = 'sentry.origin';\n\n/** The reason why an idle span finished. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON = 'sentry.idle_span_finish_reason';\n\n/** The unit of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT = 'sentry.measurement_unit';\n\n/** The value of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE = 'sentry.measurement_value';\n\n/** The release version of the application */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = 'sentry.release';\n/** The environment name (e.g., \"production\", \"staging\", \"development\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = 'sentry.environment';\n/** The segment name (e.g., \"GET /users\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME = 'sentry.segment.name';\n/** The id of the segment that this span belongs to. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID = 'sentry.segment.id';\n/** The name of the Sentry SDK (e.g., \"sentry.php\", \"sentry.javascript\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = 'sentry.sdk.name';\n/** The version of the Sentry SDK */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = 'sentry.sdk.version';\n\n/** The user ID */\nexport const SEMANTIC_ATTRIBUTE_USER_ID = 'user.id';\n/** The user email */\nexport const SEMANTIC_ATTRIBUTE_USER_EMAIL = 'user.email';\n/** The user IP address */\nexport const SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = 'user.ip_address';\n/** The user username */\nexport const SEMANTIC_ATTRIBUTE_USER_USERNAME = 'user.name';\n\n/**\n * A custom span name set by users guaranteed to be taken over any automatically\n * inferred name. This attribute is removed before the span is sent.\n *\n * @internal only meant for internal SDK usage\n * @hidden\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME = 'sentry.custom_span_name';\n\n/**\n * The id of the profile that this span occurred in.\n */\nexport const SEMANTIC_ATTRIBUTE_PROFILE_ID = 'sentry.profile_id';\n\nexport const SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = 'sentry.exclusive_time';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_HIT = 'cache.hit';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_KEY = 'cache.key';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = 'cache.item_size';\n\n/** TODO: Remove these once we update to latest semantic conventions */\nexport const SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = 'http.request.method';\nexport const SEMANTIC_ATTRIBUTE_URL_FULL = 'url.full';\n\n/**\n * A span link attribute to mark the link as a special span link.\n *\n * Known values:\n * - `previous_trace`: The span links to the frontend root span of the previous trace.\n * - `next_trace`: The span links to the frontend root span of the next trace. (Not set by the SDK)\n *\n * Other values may be set as appropriate.\n * @see https://develop.sentry.dev/sdk/telemetry/traces/span-links/#link-types\n */\nexport const SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = 'sentry.link.type';\n\n/**\n * =============================================================================\n * GEN AI ATTRIBUTES\n * Based on OpenTelemetry Semantic Conventions for Generative AI\n * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/\n * =============================================================================\n */\n\n/**\n * The conversation ID for linking messages across API calls.\n * For OpenAI Assistants API: thread_id\n * For LangGraph: configurable.thread_id\n */\nexport const GEN_AI_CONVERSATION_ID_ATTRIBUTE = 'gen_ai.conversation.id';\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACO,MAAM,gCAAA,GAAmC;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,qCAAA,GAAwC;;AAErD;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,oDAAA,GAAuD;;AAEpE;AACA;AACA;AACO,MAAM,4BAAA,GAA+B;;AAE5C;AACA;AACA;AACO,MAAM,gCAAA,GAAmC;;AAEhD;AACO,MAAM,iDAAA,GAAoD;;AAEjE;AACO,MAAM,0CAAA,GAA6C;;AAE1D;AACO,MAAM,2CAAA,GAA8C;;AAE3D;AACO,MAAM,iCAAA,GAAoC;AACjD;AACO,MAAM,qCAAA,GAAwC;AACrD;AACO,MAAM,sCAAA,GAAyC;AACtD;AACO,MAAM,oCAAA,GAAuC;AACpD;AACO,MAAM,kCAAA,GAAqC;AAClD;AACO,MAAM,qCAAA,GAAwC;;AAErD;AACO,MAAM,0BAAA,GAA6B;AAC1C;AACO,MAAM,6BAAA,GAAgC;AAC7C;AACO,MAAM,kCAAA,GAAqC;AAClD;AACO,MAAM,gCAAA,GAAmC;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,0CAAA,GAA6C;;AAE1D;AACA;AACA;AACO,MAAM,6BAAA,GAAgC;;AAEtC,MAAM,iCAAA,GAAoC;;AAE1C,MAAM,4BAAA,GAA+B;;AAErC,MAAM,4BAAA,GAA+B;;AAErC,MAAM,kCAAA,GAAqC;;AAElD;AACO,MAAM,sCAAA,GAAyC;AAC/C,MAAM,2BAAA,GAA8B;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,iCAAA,GAAoC;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,gCAAA,GAAmC;;;;"}
@@ -0,0 +1,157 @@
1
+ export { registerSpanErrorInstrumentation } from './tracing/errors.js';
2
+ export { getCapturedScopesOnSpan, setCapturedScopesOnSpan } from './tracing/utils.js';
3
+ export { TRACING_DEFAULTS, startIdleSpan } from './tracing/idleSpan.js';
4
+ export { SentrySpan } from './tracing/sentrySpan.js';
5
+ export { SentryNonRecordingSpan } from './tracing/sentryNonRecordingSpan.js';
6
+ export { SPAN_STATUS_ERROR, SPAN_STATUS_OK, SPAN_STATUS_UNSET, getSpanStatusFromHttpCode, setHttpStatus } from './tracing/spanstatus.js';
7
+ export { SUPPRESS_TRACING_KEY, continueTrace, startInactiveSpan, startNewTrace, startSpan, startSpanManual, suppressTracing, withActiveSpan } from './tracing/trace.js';
8
+ export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromScope, getDynamicSamplingContextFromSpan, spanToBaggageHeader } from './tracing/dynamicSamplingContext.js';
9
+ export { setMeasurement, timedEventsToMeasurements } from './tracing/measurement.js';
10
+ export { sampleSpan } from './tracing/sampling.js';
11
+ export { logSpanEnd, logSpanStart } from './tracing/logSpans.js';
12
+ export { captureSpan, safeSetSpanJSONAttributes } from './tracing/spans/captureSpan.js';
13
+ export { GEN_AI_CONVERSATION_ID_ATTRIBUTE, SEMANTIC_ATTRIBUTE_CACHE_HIT, SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE, SEMANTIC_ATTRIBUTE_CACHE_KEY, SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME, SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD, SEMANTIC_ATTRIBUTE_PROFILE_ID, SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME, SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT, SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_RELEASE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME, SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID, SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_URL_FULL, SEMANTIC_ATTRIBUTE_USER_EMAIL, SEMANTIC_ATTRIBUTE_USER_ID, SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS, SEMANTIC_ATTRIBUTE_USER_USERNAME, SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE } from './semanticAttributes.js';
14
+ export { createEventEnvelope, createSessionEnvelope, createSpanEnvelope } from './envelope.js';
15
+ export { addEventProcessor, captureCheckIn, captureEvent, captureException, captureMessage, captureSession, close, endSession, flush, isEnabled, isInitialized, lastEventId, setContext, setConversationId, setExtra, setExtras, setTag, setTags, setUser, startSession, withMonitor } from './exports.js';
16
+ export { getClient, getCurrentScope, getExternalPropagationContext, getGlobalScope, getIsolationScope, getTraceContextFromScope, hasExternalPropagationContext, registerExternalPropagationContext, withIsolationScope, withScope } from './currentScopes.js';
17
+ export { getDefaultCurrentScope, getDefaultIsolationScope } from './defaultScopes.js';
18
+ export { setAsyncContextStrategy } from './asyncContext/index.js';
19
+ export { getGlobalSingleton, getMainCarrier } from './carrier.js';
20
+ export { closeSession, makeSession, updateSession } from './session.js';
21
+ export { Scope } from './scope.js';
22
+ export { notifyEventProcessors } from './eventProcessors.js';
23
+ export { SENTRY_API_VERSION, getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint } from './api.js';
24
+ export { Client } from './client.js';
25
+ export { initAndBind, setCurrentClient } from './sdk.js';
26
+ export { createTransport } from './transports/base.js';
27
+ export { makeOfflineTransport } from './transports/offline.js';
28
+ export { MULTIPLEXED_TRANSPORT_EXTRA_KEY, makeMultiplexedTransport } from './transports/multiplexed.js';
29
+ export { addIntegration, defineIntegration, getIntegrationsToSetup, installedIntegrations } from './integration.js';
30
+ export { _INTERNAL_clearAiProviderSkips, _INTERNAL_shouldSkipAiProviderWrapping, _INTERNAL_skipAiProviderWrapping } from './utils/ai/providerSkip.js';
31
+ export { envToBool } from './utils/envToBool.js';
32
+ export { applyScopeDataToEvent, getCombinedScopeData, mergeScopeData } from './utils/scopeData.js';
33
+ export { prepareEvent } from './utils/prepareEvent.js';
34
+ export { createCheckInEnvelope } from './checkin.js';
35
+ export { hasSpansEnabled } from './utils/hasSpansEnabled.js';
36
+ export { isStreamedBeforeSendSpanCallback, withStreamedSpan } from './tracing/spans/beforeSendSpan.js';
37
+ export { isSentryRequestUrl } from './utils/isSentryRequestUrl.js';
38
+ export { handleCallbackErrors } from './utils/handleCallbackErrors.js';
39
+ export { fmt, parameterize } from './utils/parameterize.js';
40
+ export { handleTunnelRequest } from './utils/tunnel.js';
41
+ export { addAutoIpAddressToSession, addAutoIpAddressToUser } from './utils/ipAddress.js';
42
+ export { INTERNAL_getSegmentSpan, addChildSpanToSpan, convertSpanLinksForEnvelope, getActiveSpan, getRootSpan, getSpanDescendants, getStatusMessage, spanIsSampled, spanTimeInputToSeconds, spanToJSON, spanToStreamedSpanJSON, spanToTraceContext, spanToTraceHeader, updateSpanName } from './utils/spanUtils.js';
43
+ export { _setSpanForScope as _INTERNAL_setSpanForScope } from './utils/spanOnScope.js';
44
+ export { parseSampleRate } from './utils/parseSampleRate.js';
45
+ export { applySdkMetadata } from './utils/sdkMetadata.js';
46
+ export { getTraceData } from './utils/traceData.js';
47
+ export { shouldPropagateTraceForUrl } from './utils/tracePropagationTargets.js';
48
+ export { getTraceMetaTags } from './utils/meta.js';
49
+ export { debounce } from './utils/debounce.js';
50
+ export { derefWeakRef, makeWeakRef } from './utils/weakRef.js';
51
+ export { shouldIgnoreSpan } from './utils/should-ignore-span.js';
52
+ export { MAX_BODY_BYTE_LENGTH, captureBodyFromWinterCGRequest, extractQueryParamsFromUrl, getMaxBodyByteLength, headersToDict, httpHeadersToSpanAttributes, httpRequestToRequestData, winterCGHeadersToDict, winterCGRequestToRequestData } from './utils/request.js';
53
+ export { DEFAULT_ENVIRONMENT, DEV_ENVIRONMENT } from './constants.js';
54
+ export { addBreadcrumb } from './breadcrumbs.js';
55
+ export { functionToStringIntegration } from './integrations/functiontostring.js';
56
+ export { eventFiltersIntegration, inboundFiltersIntegration } from './integrations/eventFilters.js';
57
+ export { linkedErrorsIntegration } from './integrations/linkederrors.js';
58
+ export { moduleMetadataIntegration } from './integrations/moduleMetadata.js';
59
+ export { requestDataIntegration } from './integrations/requestdata.js';
60
+ export { captureConsoleIntegration } from './integrations/captureconsole.js';
61
+ export { dedupeIntegration } from './integrations/dedupe.js';
62
+ export { extraErrorDataIntegration } from './integrations/extraerrordata.js';
63
+ export { rewriteFramesIntegration } from './integrations/rewriteframes.js';
64
+ export { instrumentSupabaseClient, supabaseIntegration } from './integrations/supabase.js';
65
+ export { zodErrorsIntegration } from './integrations/zoderrors.js';
66
+ export { thirdPartyErrorFilterIntegration } from './integrations/third-party-errors-filter.js';
67
+ export { consoleIntegration } from './integrations/console.js';
68
+ export { featureFlagsIntegration } from './integrations/featureFlags/featureFlagsIntegration.js';
69
+ export { growthbookIntegration } from './integrations/featureFlags/growthbook.js';
70
+ export { conversationIdIntegration } from './integrations/conversationId.js';
71
+ export { profiler } from './profiling.js';
72
+ export { _INTERNAL_getTracingHeadersForFetchRequest, instrumentFetchRequest } from './fetch.js';
73
+ export { captureFeedback } from './feedback.js';
74
+ export { _INTERNAL_captureLog, _INTERNAL_captureSerializedLog, _INTERNAL_flushLogsBuffer } from './logs/internal.js';
75
+ import * as publicApi from './logs/public-api.js';
76
+ export { publicApi as logger };
77
+ export { consoleLoggingIntegration } from './logs/console-integration.js';
78
+ export { _INTERNAL_captureMetric, _INTERNAL_captureSerializedMetric, _INTERNAL_flushMetricsBuffer } from './metrics/internal.js';
79
+ import * as publicApi$1 from './metrics/public-api.js';
80
+ export { publicApi$1 as metrics };
81
+ export { createConsolaReporter } from './integrations/consola.js';
82
+ export { addVercelAiProcessors } from './tracing/vercel-ai/index.js';
83
+ export { _INTERNAL_cleanupToolCallSpanContext, _INTERNAL_getSpanContextForToolCallId } from './tracing/vercel-ai/utils.js';
84
+ export { toolCallSpanContextMap as _INTERNAL_toolCallSpanContextMap } from './tracing/vercel-ai/constants.js';
85
+ export { instrumentOpenAiClient } from './tracing/openai/index.js';
86
+ export { OPENAI_INTEGRATION_NAME } from './tracing/openai/constants.js';
87
+ export { instrumentAnthropicAiClient } from './tracing/anthropic-ai/index.js';
88
+ export { ANTHROPIC_AI_INTEGRATION_NAME } from './tracing/anthropic-ai/constants.js';
89
+ export { instrumentGoogleGenAIClient } from './tracing/google-genai/index.js';
90
+ export { GOOGLE_GENAI_INTEGRATION_NAME } from './tracing/google-genai/constants.js';
91
+ export { createLangChainCallbackHandler } from './tracing/langchain/index.js';
92
+ export { LANGCHAIN_INTEGRATION_NAME } from './tracing/langchain/constants.js';
93
+ export { instrumentCreateReactAgent, instrumentLangGraph, instrumentStateGraphCompile } from './tracing/langgraph/index.js';
94
+ export { LANGGRAPH_INTEGRATION_NAME } from './tracing/langgraph/constants.js';
95
+ export { SpanBuffer } from './tracing/spans/spanBuffer.js';
96
+ export { hasSpanStreamingEnabled } from './tracing/spans/hasSpanStreamingEnabled.js';
97
+ export { spanStreamingIntegration } from './integrations/spanStreaming.js';
98
+ export { _INTERNAL_FLAG_BUFFER_SIZE, _INTERNAL_MAX_FLAGS_PER_SPAN, _INTERNAL_addFeatureFlagToActiveSpan, _INTERNAL_copyFlagsFromScopeToEvent, _INTERNAL_insertFlagToScope } from './utils/featureFlags.js';
99
+ export { applyAggregateErrorsToEvent } from './utils/aggregate-errors.js';
100
+ export { getBreadcrumbLogLevelFromHttpStatusCode } from './utils/breadcrumb-log-level.js';
101
+ export { dsnFromString, dsnToString, makeDsn } from './utils/dsn.js';
102
+ export { SentryError } from './utils/error.js';
103
+ export { GLOBAL_OBJ } from './utils/worldwide.js';
104
+ export { addConsoleInstrumentationFilter, addConsoleInstrumentationHandler } from './instrument/console.js';
105
+ export { addFetchEndInstrumentationHandler, addFetchInstrumentationHandler } from './instrument/fetch.js';
106
+ export { addGlobalErrorInstrumentationHandler } from './instrument/globalError.js';
107
+ export { addGlobalUnhandledRejectionInstrumentationHandler } from './instrument/globalUnhandledRejection.js';
108
+ export { addHandler, maybeInstrument, resetInstrumentationHandlers, triggerHandlers } from './instrument/handlers.js';
109
+ export { isDOMError, isDOMException, isElement, isError, isErrorEvent, isEvent, isInstanceOf, isParameterizedString, isPlainObject, isPrimitive, isRegExp, isString, isSyntheticEvent, isThenable, isVueViewModel } from './utils/is.js';
110
+ export { isBrowser } from './utils/isBrowser.js';
111
+ export { CONSOLE_LEVELS, consoleSandbox, debug, originalConsoleMethods } from './utils/debug-logger.js';
112
+ export { addContextToFrame, addExceptionMechanism, addExceptionTypeValue, checkOrSetAlreadyCaught, getEventDescription, isAlreadyCaptured, parseSemver, uuid4 } from './utils/misc.js';
113
+ export { normalize, normalizeToSize, normalizeUrlToBase } from './utils/normalize.js';
114
+ export { setNormalizationDepthOverrideHint, setSkipNormalizationHint } from './utils/normalizationHints.js';
115
+ export { addNonEnumerableProperty, convertToPlainObject, dropUndefinedKeys, extractExceptionKeysForMessage, fill, getOriginalFunction, markFunctionWrapped, objectify } from './utils/object.js';
116
+ export { basename, dirname, isAbsolute, join, normalizePath, relative, resolve } from './utils/path.js';
117
+ export { SENTRY_BUFFER_FULL_ERROR, makePromiseBuffer } from './utils/promisebuffer.js';
118
+ export { severityLevelFromString } from './utils/severity.js';
119
+ export { replaceExports } from './utils/exports.js';
120
+ export { UNKNOWN_FUNCTION, createStackParser, getFramesFromEvent, getFunctionName, stackParserFromStackParserOptions, stripSentryFramesAndReverse } from './utils/stacktrace.js';
121
+ export { isMatchingPattern, safeJoin, snipLine, stringMatchesSomePattern, truncate } from './utils/string.js';
122
+ export { isNativeFunction, supportsDOMException, supportsErrorEvent, supportsFetch, supportsReferrerPolicy } from './utils/supports.js';
123
+ export { SyncPromise, rejectedSyncPromise, resolvedSyncPromise } from './utils/syncpromise.js';
124
+ export { browserPerformanceTimeOrigin, dateTimestampInSeconds, timestampInSeconds } from './utils/time.js';
125
+ export { TRACEPARENT_REGEXP, extractTraceparentData, generateSentryTraceHeader, generateTraceparentHeader, propagationContextFromHeaders, shouldContinueTrace } from './utils/tracing.js';
126
+ export { getSDKSource, isBrowserBundle } from './utils/env.js';
127
+ export { addItemToEnvelope, createAttachmentEnvelopeItem, createEnvelope, createEventEnvelopeHeaders, createSpanEnvelopeItem, envelopeContainsItemType, envelopeItemTypeToDataCategory, forEachEnvelopeItem, getSdkMetadataForEnvelopeHeader, parseEnvelope, serializeEnvelope } from './utils/envelope.js';
128
+ export { createClientReportEnvelope } from './utils/clientreport.js';
129
+ export { DEFAULT_RETRY_AFTER, disabledUntil, isRateLimited, parseRetryAfterHeader, updateRateLimits } from './utils/ratelimit.js';
130
+ export { MAX_BAGGAGE_STRING_LENGTH, SENTRY_BAGGAGE_KEY_PREFIX, SENTRY_BAGGAGE_KEY_PREFIX_REGEX, baggageHeaderToDynamicSamplingContext, dynamicSamplingContextToSentryBaggageHeader, mergeBaggageHeaders, objectToBaggageHeader, parseBaggageHeader } from './utils/baggage.js';
131
+ export { getHttpSpanDetailsFromUrlObject, getSanitizedUrlString, getSanitizedUrlStringFromUrlObject, isURLObjectRelative, parseStringToURLObject, parseUrl, stripDataUrlContent, stripUrlQueryAndFragment } from './utils/url.js';
132
+ export { _enhanceErrorWithSentryInfo as _INTERNAL_enhanceErrorWithSentryInfo, eventFromMessage, eventFromUnknownInput, exceptionFromError, parseStackFrames } from './utils/eventbuilder.js';
133
+ export { LRUMap } from './utils/lru.js';
134
+ export { generateSpanId, generateTraceId } from './utils/propagationContext.js';
135
+ export { SDK_VERSION } from './utils/version.js';
136
+ export { getDebugImagesForResources, getFilenameToDebugIdMap } from './utils/debug-ids.js';
137
+ export { getFilenameToMetadataMap } from './metadata.js';
138
+ export { escapeStringForRegex } from './vendor/escapeStringForRegex.js';
139
+ export { safeDateNow as _INTERNAL_safeDateNow, safeMathRandom as _INTERNAL_safeMathRandom, withRandomSafeContext as _INTERNAL_withRandomSafeContext } from './utils/randomSafeContext.js';
140
+ export { ServerRuntimeClient } from './server-runtime-client.js';
141
+ export { trpcMiddleware } from './trpc.js';
142
+ export { wrapMcpServerWithSentry } from './integrations/mcp-server/index.js';
143
+ export { isNodeEnv, loadModule } from './utils/node.js';
144
+ export { filenameIsInApp, node, nodeStackLineParser } from './utils/node-stack-trace.js';
145
+ export { vercelWaitUntil } from './utils/vercelWaitUntil.js';
146
+ export { flushIfServerless } from './utils/flushIfServerless.js';
147
+ export { callFrameToStackFrame, watchdogTimer } from './utils/anr.js';
148
+ export { safeUnref as _INTERNAL_safeUnref } from './utils/timer.js';
149
+ export { expressErrorHandler, patchExpressModule, setupExpressErrorHandler } from './integrations/express/index.js';
150
+ export { instrumentPostgresJsSql } from './integrations/postgresjs.js';
151
+ export { patchHttpModuleClient } from './integrations/http/client-patch.js';
152
+ export { getHttpClientSubscriptions } from './integrations/http/client-subscriptions.js';
153
+ export { addOutgoingRequestBreadcrumb } from './integrations/http/add-outgoing-request-breadcrumb.js';
154
+ export { getRequestOptions, getRequestUrl, getRequestUrlFromClientRequest, getRequestUrlObject } from './integrations/http/get-request-url.js';
155
+ export { HTTP_ON_CLIENT_REQUEST, HTTP_ON_SERVER_REQUEST } from './integrations/http/constants.js';
156
+ export { instrumentLangChainEmbeddings } from './tracing/langchain/embeddings.js';
157
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -350,8 +350,12 @@ class SentrySpan {
350
350
  // remove internal root span attributes we don't need to send.
351
351
  /* eslint-disable @typescript-eslint/no-dynamic-delete */
352
352
  delete this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];
353
+ let hasGenAiSpans = false;
353
354
  spans.forEach(span => {
354
355
  delete span.data[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];
356
+ if (span.op?.startsWith('gen_ai.')) {
357
+ hasGenAiSpans = true;
358
+ }
355
359
  });
356
360
  // eslint-enabled-next-line @typescript-eslint/no-dynamic-delete
357
361
 
@@ -373,6 +377,7 @@ class SentrySpan {
373
377
  capturedSpanScope,
374
378
  capturedSpanIsolationScope,
375
379
  dynamicSamplingContext: getDynamicSamplingContextFromSpan(this),
380
+ hasGenAiSpans,
376
381
  },
377
382
  request: normalizedRequest,
378
383
  ...(source && {