@sentry/core 10.38.0 → 10.39.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/build/cjs/attributes.js.map +1 -1
  2. package/build/cjs/client.js +22 -12
  3. package/build/cjs/client.js.map +1 -1
  4. package/build/cjs/envelope.js +41 -7
  5. package/build/cjs/envelope.js.map +1 -1
  6. package/build/cjs/index.js +52 -0
  7. package/build/cjs/index.js.map +1 -1
  8. package/build/cjs/integration.js +12 -0
  9. package/build/cjs/integration.js.map +1 -1
  10. package/build/cjs/integrations/eventFilters.js +1 -1
  11. package/build/cjs/integrations/eventFilters.js.map +1 -1
  12. package/build/cjs/integrations/mcp-server/correlation.js +54 -10
  13. package/build/cjs/integrations/mcp-server/correlation.js.map +1 -1
  14. package/build/cjs/integrations/mcp-server/sessionManagement.js +50 -16
  15. package/build/cjs/integrations/mcp-server/sessionManagement.js.map +1 -1
  16. package/build/cjs/integrations/requestdata.js +72 -6
  17. package/build/cjs/integrations/requestdata.js.map +1 -1
  18. package/build/cjs/integrations/spanStreaming.js +54 -0
  19. package/build/cjs/integrations/spanStreaming.js.map +1 -0
  20. package/build/cjs/metrics/public-api.js +3 -3
  21. package/build/cjs/metrics/public-api.js.map +1 -1
  22. package/build/cjs/scope.js +1 -1
  23. package/build/cjs/scope.js.map +1 -1
  24. package/build/cjs/semanticAttributes.js +84 -0
  25. package/build/cjs/semanticAttributes.js.map +1 -1
  26. package/build/cjs/spans/captureSpan.js +104 -0
  27. package/build/cjs/spans/captureSpan.js.map +1 -0
  28. package/build/cjs/spans/spanBuffer.js +121 -0
  29. package/build/cjs/spans/spanBuffer.js.map +1 -0
  30. package/build/cjs/spans/spanFirstUtils.js +186 -0
  31. package/build/cjs/spans/spanFirstUtils.js.map +1 -0
  32. package/build/cjs/tracing/ai/gen-ai-attributes.js +6 -0
  33. package/build/cjs/tracing/ai/gen-ai-attributes.js.map +1 -1
  34. package/build/cjs/tracing/openai/index.js +134 -51
  35. package/build/cjs/tracing/openai/index.js.map +1 -1
  36. package/build/cjs/tracing/sentrySpan.js +32 -0
  37. package/build/cjs/tracing/sentrySpan.js.map +1 -1
  38. package/build/cjs/tracing/trace.js +1 -0
  39. package/build/cjs/tracing/trace.js.map +1 -1
  40. package/build/cjs/tracing/vercel-ai/constants.js +4 -0
  41. package/build/cjs/tracing/vercel-ai/constants.js.map +1 -1
  42. package/build/cjs/tracing/vercel-ai/index.js +14 -0
  43. package/build/cjs/tracing/vercel-ai/index.js.map +1 -1
  44. package/build/cjs/tracing/vercel-ai/utils.js +71 -22
  45. package/build/cjs/tracing/vercel-ai/utils.js.map +1 -1
  46. package/build/cjs/transports/base.js +18 -2
  47. package/build/cjs/transports/base.js.map +1 -1
  48. package/build/cjs/transports/offline.js +16 -17
  49. package/build/cjs/transports/offline.js.map +1 -1
  50. package/build/cjs/utils/beforeSendSpan.js +36 -0
  51. package/build/cjs/utils/beforeSendSpan.js.map +1 -0
  52. package/build/cjs/utils/envToBool.js +32 -0
  53. package/build/cjs/utils/envToBool.js.map +1 -0
  54. package/build/cjs/utils/featureFlags.js +1 -0
  55. package/build/cjs/utils/featureFlags.js.map +1 -1
  56. package/build/cjs/utils/flushIfServerless.js.map +1 -1
  57. package/build/cjs/utils/hasSpanStreamingEnabled.js +21 -0
  58. package/build/cjs/utils/hasSpanStreamingEnabled.js.map +1 -0
  59. package/build/cjs/utils/prepareEvent.js +6 -1
  60. package/build/cjs/utils/prepareEvent.js.map +1 -1
  61. package/build/cjs/utils/promisebuffer.js +5 -3
  62. package/build/cjs/utils/promisebuffer.js.map +1 -1
  63. package/build/cjs/utils/scopeData.js +4 -0
  64. package/build/cjs/utils/scopeData.js.map +1 -1
  65. package/build/cjs/utils/sdkMetadata.js +7 -11
  66. package/build/cjs/utils/sdkMetadata.js.map +1 -1
  67. package/build/cjs/utils/should-ignore-span.js +31 -9
  68. package/build/cjs/utils/should-ignore-span.js.map +1 -1
  69. package/build/cjs/utils/spanUtils.js +90 -2
  70. package/build/cjs/utils/spanUtils.js.map +1 -1
  71. package/build/cjs/utils/timer.js +20 -0
  72. package/build/cjs/utils/timer.js.map +1 -0
  73. package/build/cjs/utils/tracePropagationTargets.js +38 -0
  74. package/build/cjs/utils/tracePropagationTargets.js.map +1 -0
  75. package/build/cjs/utils/version.js +1 -1
  76. package/build/cjs/utils/version.js.map +1 -1
  77. package/build/esm/attributes.js.map +1 -1
  78. package/build/esm/client.js +18 -8
  79. package/build/esm/client.js.map +1 -1
  80. package/build/esm/envelope.js +41 -8
  81. package/build/esm/envelope.js.map +1 -1
  82. package/build/esm/index.js +12 -3
  83. package/build/esm/index.js.map +1 -1
  84. package/build/esm/integration.js +12 -1
  85. package/build/esm/integration.js.map +1 -1
  86. package/build/esm/integrations/eventFilters.js +1 -1
  87. package/build/esm/integrations/eventFilters.js.map +1 -1
  88. package/build/esm/integrations/mcp-server/correlation.js +54 -10
  89. package/build/esm/integrations/mcp-server/correlation.js.map +1 -1
  90. package/build/esm/integrations/mcp-server/sessionManagement.js +50 -16
  91. package/build/esm/integrations/mcp-server/sessionManagement.js.map +1 -1
  92. package/build/esm/integrations/requestdata.js +72 -6
  93. package/build/esm/integrations/requestdata.js.map +1 -1
  94. package/build/esm/integrations/spanStreaming.js +52 -0
  95. package/build/esm/integrations/spanStreaming.js.map +1 -0
  96. package/build/esm/metrics/public-api.js +3 -3
  97. package/build/esm/metrics/public-api.js.map +1 -1
  98. package/build/esm/package.json +1 -1
  99. package/build/esm/scope.js +1 -1
  100. package/build/esm/scope.js.map +1 -1
  101. package/build/esm/semanticAttributes.js +57 -1
  102. package/build/esm/semanticAttributes.js.map +1 -1
  103. package/build/esm/spans/captureSpan.js +102 -0
  104. package/build/esm/spans/captureSpan.js.map +1 -0
  105. package/build/esm/spans/spanBuffer.js +119 -0
  106. package/build/esm/spans/spanBuffer.js.map +1 -0
  107. package/build/esm/spans/spanFirstUtils.js +182 -0
  108. package/build/esm/spans/spanFirstUtils.js.map +1 -0
  109. package/build/esm/tracing/ai/gen-ai-attributes.js +6 -1
  110. package/build/esm/tracing/ai/gen-ai-attributes.js.map +1 -1
  111. package/build/esm/tracing/openai/index.js +134 -51
  112. package/build/esm/tracing/openai/index.js.map +1 -1
  113. package/build/esm/tracing/sentrySpan.js +33 -1
  114. package/build/esm/tracing/sentrySpan.js.map +1 -1
  115. package/build/esm/tracing/trace.js +1 -0
  116. package/build/esm/tracing/trace.js.map +1 -1
  117. package/build/esm/tracing/vercel-ai/constants.js +4 -1
  118. package/build/esm/tracing/vercel-ai/constants.js.map +1 -1
  119. package/build/esm/tracing/vercel-ai/index.js +15 -1
  120. package/build/esm/tracing/vercel-ai/index.js.map +1 -1
  121. package/build/esm/tracing/vercel-ai/utils.js +73 -24
  122. package/build/esm/tracing/vercel-ai/utils.js.map +1 -1
  123. package/build/esm/transports/base.js +18 -2
  124. package/build/esm/transports/base.js.map +1 -1
  125. package/build/esm/transports/offline.js +16 -17
  126. package/build/esm/transports/offline.js.map +1 -1
  127. package/build/esm/utils/beforeSendSpan.js +33 -0
  128. package/build/esm/utils/beforeSendSpan.js.map +1 -0
  129. package/build/esm/utils/envToBool.js +28 -0
  130. package/build/esm/utils/envToBool.js.map +1 -0
  131. package/build/esm/utils/featureFlags.js +1 -0
  132. package/build/esm/utils/featureFlags.js.map +1 -1
  133. package/build/esm/utils/flushIfServerless.js.map +1 -1
  134. package/build/esm/utils/hasSpanStreamingEnabled.js +19 -0
  135. package/build/esm/utils/hasSpanStreamingEnabled.js.map +1 -0
  136. package/build/esm/utils/prepareEvent.js +6 -1
  137. package/build/esm/utils/prepareEvent.js.map +1 -1
  138. package/build/esm/utils/promisebuffer.js +5 -3
  139. package/build/esm/utils/promisebuffer.js.map +1 -1
  140. package/build/esm/utils/scopeData.js +4 -0
  141. package/build/esm/utils/scopeData.js.map +1 -1
  142. package/build/esm/utils/sdkMetadata.js +7 -11
  143. package/build/esm/utils/sdkMetadata.js.map +1 -1
  144. package/build/esm/utils/should-ignore-span.js +31 -9
  145. package/build/esm/utils/should-ignore-span.js.map +1 -1
  146. package/build/esm/utils/spanUtils.js +87 -3
  147. package/build/esm/utils/spanUtils.js.map +1 -1
  148. package/build/esm/utils/timer.js +18 -0
  149. package/build/esm/utils/timer.js.map +1 -0
  150. package/build/esm/utils/tracePropagationTargets.js +36 -0
  151. package/build/esm/utils/tracePropagationTargets.js.map +1 -0
  152. package/build/esm/utils/version.js +1 -1
  153. package/build/esm/utils/version.js.map +1 -1
  154. package/build/types/attributes.d.ts +1 -1
  155. package/build/types/attributes.d.ts.map +1 -1
  156. package/build/types/client.d.ts +40 -2
  157. package/build/types/client.d.ts.map +1 -1
  158. package/build/types/envelope.d.ts +6 -1
  159. package/build/types/envelope.d.ts.map +1 -1
  160. package/build/types/index.d.ts +13 -4
  161. package/build/types/index.d.ts.map +1 -1
  162. package/build/types/integration.d.ts +4 -0
  163. package/build/types/integration.d.ts.map +1 -1
  164. package/build/types/integrations/mcp-server/correlation.d.ts +6 -2
  165. package/build/types/integrations/mcp-server/correlation.d.ts.map +1 -1
  166. package/build/types/integrations/mcp-server/sessionManagement.d.ts +8 -2
  167. package/build/types/integrations/mcp-server/sessionManagement.d.ts.map +1 -1
  168. package/build/types/integrations/requestdata.d.ts.map +1 -1
  169. package/build/types/integrations/spanStreaming.d.ts +11 -0
  170. package/build/types/integrations/spanStreaming.d.ts.map +1 -0
  171. package/build/types/metrics/public-api.d.ts +3 -3
  172. package/build/types/semanticAttributes.d.ts +38 -0
  173. package/build/types/semanticAttributes.d.ts.map +1 -1
  174. package/build/types/spans/captureSpan.d.ts +10 -0
  175. package/build/types/spans/captureSpan.d.ts.map +1 -0
  176. package/build/types/spans/spanBuffer.d.ts +35 -0
  177. package/build/types/spans/spanBuffer.d.ts.map +1 -0
  178. package/build/types/spans/spanFirstUtils.d.ts +20 -0
  179. package/build/types/spans/spanFirstUtils.d.ts.map +1 -0
  180. package/build/types/tracing/ai/gen-ai-attributes.d.ts +4 -0
  181. package/build/types/tracing/ai/gen-ai-attributes.d.ts.map +1 -1
  182. package/build/types/tracing/openai/index.d.ts.map +1 -1
  183. package/build/types/tracing/sentrySpan.d.ts +10 -1
  184. package/build/types/tracing/sentrySpan.d.ts.map +1 -1
  185. package/build/types/tracing/vercel-ai/constants.d.ts +1 -0
  186. package/build/types/tracing/vercel-ai/constants.d.ts.map +1 -1
  187. package/build/types/tracing/vercel-ai/index.d.ts.map +1 -1
  188. package/build/types/tracing/vercel-ai/utils.d.ts +2 -2
  189. package/build/types/tracing/vercel-ai/utils.d.ts.map +1 -1
  190. package/build/types/transports/base.d.ts.map +1 -1
  191. package/build/types/transports/offline.d.ts.map +1 -1
  192. package/build/types/types-hoist/attributes.d.ts +19 -0
  193. package/build/types/types-hoist/attributes.d.ts.map +1 -0
  194. package/build/types/types-hoist/envelope.d.ts +22 -2
  195. package/build/types/types-hoist/envelope.d.ts.map +1 -1
  196. package/build/types/types-hoist/feedback/index.d.ts.map +1 -1
  197. package/build/types/types-hoist/integration.d.ts +7 -0
  198. package/build/types/types-hoist/integration.d.ts.map +1 -1
  199. package/build/types/types-hoist/link.d.ts +2 -2
  200. package/build/types/types-hoist/link.d.ts.map +1 -1
  201. package/build/types/types-hoist/options.d.ts +18 -2
  202. package/build/types/types-hoist/options.d.ts.map +1 -1
  203. package/build/types/types-hoist/span.d.ts +27 -0
  204. package/build/types/types-hoist/span.d.ts.map +1 -1
  205. package/build/types/utils/beforeSendSpan.d.ts +22 -0
  206. package/build/types/utils/beforeSendSpan.d.ts.map +1 -0
  207. package/build/types/utils/envToBool.d.ts +13 -0
  208. package/build/types/utils/envToBool.d.ts.map +1 -0
  209. package/build/types/utils/featureFlags.d.ts.map +1 -1
  210. package/build/types/utils/flushIfServerless.d.ts.map +1 -1
  211. package/build/types/utils/hasSpanStreamingEnabled.d.ts +9 -0
  212. package/build/types/utils/hasSpanStreamingEnabled.d.ts.map +1 -0
  213. package/build/types/utils/prepareEvent.d.ts.map +1 -1
  214. package/build/types/utils/promisebuffer.d.ts.map +1 -1
  215. package/build/types/utils/scopeData.d.ts.map +1 -1
  216. package/build/types/utils/sdkMetadata.d.ts.map +1 -1
  217. package/build/types/utils/should-ignore-span.d.ts +3 -3
  218. package/build/types/utils/should-ignore-span.d.ts.map +1 -1
  219. package/build/types/utils/spanUtils.d.ts +22 -2
  220. package/build/types/utils/spanUtils.d.ts.map +1 -1
  221. package/build/types/utils/timer.d.ts +11 -0
  222. package/build/types/utils/timer.d.ts.map +1 -0
  223. package/build/types/utils/tracePropagationTargets.d.ts +9 -0
  224. package/build/types/utils/tracePropagationTargets.d.ts.map +1 -0
  225. package/build/types-ts3.8/attributes.d.ts +1 -1
  226. package/build/types-ts3.8/client.d.ts +40 -2
  227. package/build/types-ts3.8/envelope.d.ts +6 -1
  228. package/build/types-ts3.8/index.d.ts +13 -4
  229. package/build/types-ts3.8/integration.d.ts +4 -0
  230. package/build/types-ts3.8/integrations/mcp-server/correlation.d.ts +6 -2
  231. package/build/types-ts3.8/integrations/mcp-server/sessionManagement.d.ts +8 -2
  232. package/build/types-ts3.8/integrations/spanStreaming.d.ts +11 -0
  233. package/build/types-ts3.8/metrics/public-api.d.ts +3 -3
  234. package/build/types-ts3.8/semanticAttributes.d.ts +38 -0
  235. package/build/types-ts3.8/spans/captureSpan.d.ts +10 -0
  236. package/build/types-ts3.8/spans/spanBuffer.d.ts +35 -0
  237. package/build/types-ts3.8/spans/spanFirstUtils.d.ts +20 -0
  238. package/build/types-ts3.8/tracing/ai/gen-ai-attributes.d.ts +4 -0
  239. package/build/types-ts3.8/tracing/sentrySpan.d.ts +10 -1
  240. package/build/types-ts3.8/tracing/vercel-ai/constants.d.ts +1 -0
  241. package/build/types-ts3.8/tracing/vercel-ai/utils.d.ts +2 -2
  242. package/build/types-ts3.8/types-hoist/attributes.d.ts +19 -0
  243. package/build/types-ts3.8/types-hoist/envelope.d.ts +22 -2
  244. package/build/types-ts3.8/types-hoist/integration.d.ts +7 -0
  245. package/build/types-ts3.8/types-hoist/link.d.ts +2 -2
  246. package/build/types-ts3.8/types-hoist/options.d.ts +18 -2
  247. package/build/types-ts3.8/types-hoist/span.d.ts +27 -0
  248. package/build/types-ts3.8/utils/beforeSendSpan.d.ts +22 -0
  249. package/build/types-ts3.8/utils/envToBool.d.ts +13 -0
  250. package/build/types-ts3.8/utils/hasSpanStreamingEnabled.d.ts +9 -0
  251. package/build/types-ts3.8/utils/should-ignore-span.d.ts +3 -3
  252. package/build/types-ts3.8/utils/spanUtils.d.ts +22 -2
  253. package/build/types-ts3.8/utils/timer.d.ts +11 -0
  254. package/build/types-ts3.8/utils/tracePropagationTargets.d.ts +9 -0
  255. package/package.json +1 -1
@@ -1,32 +1,61 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  /**
4
- * Transport-scoped session data storage (only for transports with sessionId)
5
- * @internal Maps transport instances to session-level data
4
+ * Session-scoped data storage for stateful transports (with sessionId)
5
+ * @internal Using sessionId as key handles wrapper transport patterns
6
6
  */
7
- const transportToSessionData = new WeakMap();
7
+ const sessionToSessionData = new Map();
8
8
 
9
9
  /**
10
- * Stores session data for a transport with sessionId
10
+ * Transport-scoped data storage fallback for stateless transports (no sessionId)
11
+ * @internal WeakMap allows automatic cleanup when transport is garbage collected
12
+ */
13
+ const statelessSessionData = new WeakMap();
14
+
15
+ /**
16
+ * Gets session data for a transport, checking sessionId first then fallback
17
+ * @internal
18
+ */
19
+ function getSessionData(transport) {
20
+ const sessionId = transport.sessionId;
21
+ if (sessionId) {
22
+ return sessionToSessionData.get(sessionId);
23
+ }
24
+ return statelessSessionData.get(transport);
25
+ }
26
+
27
+ /**
28
+ * Sets session data for a transport, using sessionId when available
29
+ * @internal
30
+ */
31
+ function setSessionData(transport, data) {
32
+ const sessionId = transport.sessionId;
33
+ if (sessionId) {
34
+ sessionToSessionData.set(sessionId, data);
35
+ } else {
36
+ statelessSessionData.set(transport, data);
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Stores session data for a transport
11
42
  * @param transport - MCP transport instance
12
43
  * @param sessionData - Session data to store
13
44
  */
14
45
  function storeSessionDataForTransport(transport, sessionData) {
15
- if (transport.sessionId) {
16
- transportToSessionData.set(transport, sessionData);
17
- }
46
+ // For stateful transports, always store (sessionId is the key)
47
+ // For stateless transports, also store (transport instance is the key)
48
+ setSessionData(transport, sessionData);
18
49
  }
19
50
 
20
51
  /**
21
- * Updates session data for a transport with sessionId (merges with existing data)
52
+ * Updates session data for a transport (merges with existing data)
22
53
  * @param transport - MCP transport instance
23
54
  * @param partialSessionData - Partial session data to merge with existing data
24
55
  */
25
56
  function updateSessionDataForTransport(transport, partialSessionData) {
26
- if (transport.sessionId) {
27
- const existingData = transportToSessionData.get(transport) || {};
28
- transportToSessionData.set(transport, { ...existingData, ...partialSessionData });
29
- }
57
+ const existingData = getSessionData(transport) || {};
58
+ setSessionData(transport, { ...existingData, ...partialSessionData });
30
59
  }
31
60
 
32
61
  /**
@@ -35,7 +64,7 @@ function updateSessionDataForTransport(transport, partialSessionData) {
35
64
  * @returns Client information if available
36
65
  */
37
66
  function getClientInfoForTransport(transport) {
38
- return transportToSessionData.get(transport)?.clientInfo;
67
+ return getSessionData(transport)?.clientInfo;
39
68
  }
40
69
 
41
70
  /**
@@ -44,7 +73,7 @@ function getClientInfoForTransport(transport) {
44
73
  * @returns Protocol version if available
45
74
  */
46
75
  function getProtocolVersionForTransport(transport) {
47
- return transportToSessionData.get(transport)?.protocolVersion;
76
+ return getSessionData(transport)?.protocolVersion;
48
77
  }
49
78
 
50
79
  /**
@@ -53,7 +82,7 @@ function getProtocolVersionForTransport(transport) {
53
82
  * @returns Complete session data if available
54
83
  */
55
84
  function getSessionDataForTransport(transport) {
56
- return transportToSessionData.get(transport);
85
+ return getSessionData(transport);
57
86
  }
58
87
 
59
88
  /**
@@ -61,7 +90,12 @@ function getSessionDataForTransport(transport) {
61
90
  * @param transport - MCP transport instance
62
91
  */
63
92
  function cleanupSessionDataForTransport(transport) {
64
- transportToSessionData.delete(transport);
93
+ const sessionId = transport.sessionId;
94
+ if (sessionId) {
95
+ sessionToSessionData.delete(sessionId);
96
+ }
97
+ // Note: WeakMap entries are automatically cleaned up when transport is GC'd
98
+ // No explicit delete needed for statelessSessionData
65
99
  }
66
100
 
67
101
  exports.cleanupSessionDataForTransport = cleanupSessionDataForTransport;
@@ -1 +1 @@
1
- {"version":3,"file":"sessionManagement.js","sources":["../../../../src/integrations/mcp-server/sessionManagement.ts"],"sourcesContent":["/**\n * Session data management for MCP server instrumentation\n */\n\nimport type { MCPTransport, PartyInfo, SessionData } from './types';\n\n/**\n * Transport-scoped session data storage (only for transports with sessionId)\n * @internal Maps transport instances to session-level data\n */\nconst transportToSessionData = new WeakMap<MCPTransport, SessionData>();\n\n/**\n * Stores session data for a transport with sessionId\n * @param transport - MCP transport instance\n * @param sessionData - Session data to store\n */\nexport function storeSessionDataForTransport(transport: MCPTransport, sessionData: SessionData): void {\n if (transport.sessionId) {\n transportToSessionData.set(transport, sessionData);\n }\n}\n\n/**\n * Updates session data for a transport with sessionId (merges with existing data)\n * @param transport - MCP transport instance\n * @param partialSessionData - Partial session data to merge with existing data\n */\nexport function updateSessionDataForTransport(transport: MCPTransport, partialSessionData: Partial<SessionData>): void {\n if (transport.sessionId) {\n const existingData = transportToSessionData.get(transport) || {};\n transportToSessionData.set(transport, { ...existingData, ...partialSessionData });\n }\n}\n\n/**\n * Retrieves client information for a transport\n * @param transport - MCP transport instance\n * @returns Client information if available\n */\nexport function getClientInfoForTransport(transport: MCPTransport): PartyInfo | undefined {\n return transportToSessionData.get(transport)?.clientInfo;\n}\n\n/**\n * Retrieves protocol version for a transport\n * @param transport - MCP transport instance\n * @returns Protocol version if available\n */\nexport function getProtocolVersionForTransport(transport: MCPTransport): string | undefined {\n return transportToSessionData.get(transport)?.protocolVersion;\n}\n\n/**\n * Retrieves full session data for a transport\n * @param transport - MCP transport instance\n * @returns Complete session data if available\n */\nexport function getSessionDataForTransport(transport: MCPTransport): SessionData | undefined {\n return transportToSessionData.get(transport);\n}\n\n/**\n * Cleans up session data for a specific transport (when that transport closes)\n * @param transport - MCP transport instance\n */\nexport function cleanupSessionDataForTransport(transport: MCPTransport): void {\n transportToSessionData.delete(transport);\n}\n"],"names":[],"mappings":";;AAMA;AACA;AACA;AACA;AACA,MAAM,sBAAA,GAAyB,IAAI,OAAO,EAA6B;;AAEvE;AACA;AACA;AACA;AACA;AACO,SAAS,4BAA4B,CAAC,SAAS,EAAgB,WAAW,EAAqB;AACtG,EAAE,IAAI,SAAS,CAAC,SAAS,EAAE;AAC3B,IAAI,sBAAsB,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC;AACtD,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,6BAA6B,CAAC,SAAS,EAAgB,kBAAkB,EAA8B;AACvH,EAAE,IAAI,SAAS,CAAC,SAAS,EAAE;AAC3B,IAAI,MAAM,YAAA,GAAe,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAA,IAAK,EAAE;AACpE,IAAI,sBAAsB,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,GAAG,YAAY,EAAE,GAAG,kBAAA,EAAoB,CAAC;AACrF,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,yBAAyB,CAAC,SAAS,EAAuC;AAC1F,EAAE,OAAO,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,UAAU;AAC1D;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,8BAA8B,CAAC,SAAS,EAAoC;AAC5F,EAAE,OAAO,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,eAAe;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,0BAA0B,CAAC,SAAS,EAAyC;AAC7F,EAAE,OAAO,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC;AAC9C;;AAEA;AACA;AACA;AACA;AACO,SAAS,8BAA8B,CAAC,SAAS,EAAsB;AAC9E,EAAE,sBAAsB,CAAC,MAAM,CAAC,SAAS,CAAC;AAC1C;;;;;;;;;"}
1
+ {"version":3,"file":"sessionManagement.js","sources":["../../../../src/integrations/mcp-server/sessionManagement.ts"],"sourcesContent":["/**\n * Session data management for MCP server instrumentation\n *\n * Uses sessionId as the primary key for stateful transports. This handles the wrapper\n * transport pattern (e.g., NodeStreamableHTTPServerTransport wrapping WebStandardStreamableHTTPServerTransport)\n * where different methods may receive different `this` values but share the same sessionId.\n *\n * Falls back to WeakMap by transport instance for stateless transports (no sessionId).\n */\n\nimport type { MCPTransport, PartyInfo, SessionData } from './types';\n\n/**\n * Session-scoped data storage for stateful transports (with sessionId)\n * @internal Using sessionId as key handles wrapper transport patterns\n */\nconst sessionToSessionData = new Map<string, SessionData>();\n\n/**\n * Transport-scoped data storage fallback for stateless transports (no sessionId)\n * @internal WeakMap allows automatic cleanup when transport is garbage collected\n */\nconst statelessSessionData = new WeakMap<MCPTransport, SessionData>();\n\n/**\n * Gets session data for a transport, checking sessionId first then fallback\n * @internal\n */\nfunction getSessionData(transport: MCPTransport): SessionData | undefined {\n const sessionId = transport.sessionId;\n if (sessionId) {\n return sessionToSessionData.get(sessionId);\n }\n return statelessSessionData.get(transport);\n}\n\n/**\n * Sets session data for a transport, using sessionId when available\n * @internal\n */\nfunction setSessionData(transport: MCPTransport, data: SessionData): void {\n const sessionId = transport.sessionId;\n if (sessionId) {\n sessionToSessionData.set(sessionId, data);\n } else {\n statelessSessionData.set(transport, data);\n }\n}\n\n/**\n * Stores session data for a transport\n * @param transport - MCP transport instance\n * @param sessionData - Session data to store\n */\nexport function storeSessionDataForTransport(transport: MCPTransport, sessionData: SessionData): void {\n // For stateful transports, always store (sessionId is the key)\n // For stateless transports, also store (transport instance is the key)\n setSessionData(transport, sessionData);\n}\n\n/**\n * Updates session data for a transport (merges with existing data)\n * @param transport - MCP transport instance\n * @param partialSessionData - Partial session data to merge with existing data\n */\nexport function updateSessionDataForTransport(transport: MCPTransport, partialSessionData: Partial<SessionData>): void {\n const existingData = getSessionData(transport) || {};\n setSessionData(transport, { ...existingData, ...partialSessionData });\n}\n\n/**\n * Retrieves client information for a transport\n * @param transport - MCP transport instance\n * @returns Client information if available\n */\nexport function getClientInfoForTransport(transport: MCPTransport): PartyInfo | undefined {\n return getSessionData(transport)?.clientInfo;\n}\n\n/**\n * Retrieves protocol version for a transport\n * @param transport - MCP transport instance\n * @returns Protocol version if available\n */\nexport function getProtocolVersionForTransport(transport: MCPTransport): string | undefined {\n return getSessionData(transport)?.protocolVersion;\n}\n\n/**\n * Retrieves full session data for a transport\n * @param transport - MCP transport instance\n * @returns Complete session data if available\n */\nexport function getSessionDataForTransport(transport: MCPTransport): SessionData | undefined {\n return getSessionData(transport);\n}\n\n/**\n * Cleans up session data for a specific transport (when that transport closes)\n * @param transport - MCP transport instance\n */\nexport function cleanupSessionDataForTransport(transport: MCPTransport): void {\n const sessionId = transport.sessionId;\n if (sessionId) {\n sessionToSessionData.delete(sessionId);\n }\n // Note: WeakMap entries are automatically cleaned up when transport is GC'd\n // No explicit delete needed for statelessSessionData\n}\n"],"names":[],"mappings":";;AAYA;AACA;AACA;AACA;AACA,MAAM,oBAAA,GAAuB,IAAI,GAAG,EAAuB;;AAE3D;AACA;AACA;AACA;AACA,MAAM,oBAAA,GAAuB,IAAI,OAAO,EAA6B;;AAErE;AACA;AACA;AACA;AACA,SAAS,cAAc,CAAC,SAAS,EAAyC;AAC1E,EAAE,MAAM,SAAA,GAAY,SAAS,CAAC,SAAS;AACvC,EAAE,IAAI,SAAS,EAAE;AACjB,IAAI,OAAO,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAAC;AAC9C,EAAE;AACF,EAAE,OAAO,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAAC;AAC5C;;AAEA;AACA;AACA;AACA;AACA,SAAS,cAAc,CAAC,SAAS,EAAgB,IAAI,EAAqB;AAC1E,EAAE,MAAM,SAAA,GAAY,SAAS,CAA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'Module' });
2
2
 
3
3
  const integration = require('../integration.js');
4
+ const semanticAttributes = require('../semanticAttributes.js');
5
+ const spanFirstUtils = require('../spans/spanFirstUtils.js');
4
6
  const cookie = require('../utils/cookie.js');
7
+ const request = require('../utils/request.js');
5
8
  const getIpAddress = require('../vendor/getIpAddress.js');
6
9
 
7
10
  // TODO(v11): Change defaults based on `sendDefaultPii`
@@ -23,14 +26,67 @@ const _requestDataIntegration = ((options = {}) => {
23
26
 
24
27
  return {
25
28
  name: INTEGRATION_NAME,
29
+ setup(client) {
30
+ client.on('processSegmentSpan', (spanJSON, { scopeData }) => {
31
+ const { sdkProcessingMetadata = {} } = scopeData;
32
+ const { normalizedRequest, ipAddress } = sdkProcessingMetadata;
33
+
34
+ if (!normalizedRequest) {
35
+ return;
36
+ }
37
+
38
+ const includeWithDefaultPiiApplied = getIncludeWithDefaultPiiApplied(
39
+ include,
40
+ client,
41
+ );
42
+
43
+ // no need to check for include after calling `extractNormalizedRequestData`
44
+ // because it already internally only return what's permitted by `include`
45
+ const { method, url, query_string, headers, data, env } = extractNormalizedRequestData(
46
+ normalizedRequest,
47
+ includeWithDefaultPiiApplied,
48
+ );
49
+
50
+ spanFirstUtils.safeSetSpanJSONAttributes(spanJSON, {
51
+ ...(method ? { [semanticAttributes.SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD]: method } : {}),
52
+ ...(url ? { [semanticAttributes.SEMANTIC_ATTRIBUTE_URL_FULL]: url } : {}),
53
+ ...(query_string ? { [semanticAttributes.SEMANTIC_ATTRIBUTE_URL_QUERY]: query_string } : {}),
54
+ ...(headers ? request.httpHeadersToSpanAttributes(headers, client.getOptions().sendDefaultPii) : {}),
55
+ // TODO: Apparently, Relay still needs Pii rule updates, so I'm leaving this out for now
56
+ // ...(cookies
57
+ // ? Object.keys(cookies).reduce(
58
+ // (acc, cookieName) => ({
59
+ // ...acc,
60
+ // [`http.request.header.cookie.${cookieName}`]: cookies[cookieName] ?? '',
61
+ // }),
62
+ // {} as Record<string, string>,
63
+ // )
64
+ // : {}),
65
+ ...(include.ip
66
+ ? {
67
+ [semanticAttributes.SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS]:
68
+ (normalizedRequest.headers && getIpAddress.getClientIPAddress(normalizedRequest.headers)) || ipAddress,
69
+ }
70
+ : {}),
71
+ ...(data ? { 'http.request.body.content': data } : {}),
72
+ ...(env
73
+ ? {
74
+ 'http.request.env': Object.keys(env).reduce(
75
+ (acc, key) => ({ ...acc, [key]: env[key] ?? '' }),
76
+ {} ,
77
+ ),
78
+ }
79
+ : {}),
80
+ });
81
+ });
82
+ },
83
+ // TODO (span-streaming): probably fine to leave as-is for errors.
84
+ // For spans, we go through global context -> attribute conversion or omit this completely (TBD)
26
85
  processEvent(event, _hint, client) {
27
86
  const { sdkProcessingMetadata = {} } = event;
28
87
  const { normalizedRequest, ipAddress } = sdkProcessingMetadata;
29
88
 
30
- const includeWithDefaultPiiApplied = {
31
- ...include,
32
- ip: include.ip ?? client.getOptions().sendDefaultPii,
33
- };
89
+ const includeWithDefaultPiiApplied = getIncludeWithDefaultPiiApplied(include, client);
34
90
 
35
91
  if (normalizedRequest) {
36
92
  addNormalizedRequestDataToEvent(event, normalizedRequest, { ipAddress }, includeWithDefaultPiiApplied);
@@ -47,6 +103,16 @@ const _requestDataIntegration = ((options = {}) => {
47
103
  */
48
104
  const requestDataIntegration = integration.defineIntegration(_requestDataIntegration);
49
105
 
106
+ const getIncludeWithDefaultPiiApplied = (
107
+ include
108
+
109
+ ,
110
+ client,
111
+ ) => ({
112
+ ...include,
113
+ ip: include.ip ?? client.getOptions().sendDefaultPii,
114
+ });
115
+
50
116
  /**
51
117
  * Add already normalized request data to an event.
52
118
  * This mutates the passed in event.
@@ -86,14 +152,14 @@ function extractNormalizedRequestData(
86
152
 
87
153
  // Remove the Cookie header in case cookie data should not be included in the event
88
154
  if (!include.cookies) {
89
- delete (headers ).cookie;
155
+ delete headers.cookie;
90
156
  }
91
157
 
92
158
  // Remove IP headers in case IP data should not be included in the event
93
159
  if (!include.ip) {
94
160
  getIpAddress.ipHeaderNames.forEach(ipHeaderName => {
95
161
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
96
- delete (headers )[ipHeaderName];
162
+ delete headers[ipHeaderName];
97
163
  });
98
164
  }
99
165
  }
@@ -1 +1 @@
1
- {"version":3,"file":"requestdata.js","sources":["../../../src/integrations/requestdata.ts"],"sourcesContent":["import { defineIntegration } from '../integration';\nimport type { Event } from '../types-hoist/event';\nimport type { IntegrationFn } from '../types-hoist/integration';\nimport type { RequestEventData } from '../types-hoist/request';\nimport { parseCookie } from '../utils/cookie';\nimport { getClientIPAddress, ipHeaderNames } from '../vendor/getIpAddress';\n\ninterface RequestDataIncludeOptions {\n cookies?: boolean;\n data?: boolean;\n headers?: boolean;\n ip?: boolean;\n query_string?: boolean;\n url?: boolean;\n}\n\ntype RequestDataIntegrationOptions = {\n /**\n * Controls what data is pulled from the request and added to the event.\n */\n include?: RequestDataIncludeOptions;\n};\n\n// TODO(v11): Change defaults based on `sendDefaultPii`\nconst DEFAULT_INCLUDE: RequestDataIncludeOptions = {\n cookies: true,\n data: true,\n headers: true,\n query_string: true,\n url: true,\n};\n\nconst INTEGRATION_NAME = 'RequestData';\n\nconst _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) => {\n const include = {\n ...DEFAULT_INCLUDE,\n ...options.include,\n };\n\n return {\n name: INTEGRATION_NAME,\n processEvent(event, _hint, client) {\n const { sdkProcessingMetadata = {} } = event;\n const { normalizedRequest, ipAddress } = sdkProcessingMetadata;\n\n const includeWithDefaultPiiApplied: RequestDataIncludeOptions = {\n ...include,\n ip: include.ip ?? client.getOptions().sendDefaultPii,\n };\n\n if (normalizedRequest) {\n addNormalizedRequestDataToEvent(event, normalizedRequest, { ipAddress }, includeWithDefaultPiiApplied);\n }\n\n return event;\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/core`\n * so it can be used in cross-platform SDKs like `@sentry/nextjs`.\n */\nexport const requestDataIntegration = defineIntegration(_requestDataIntegration);\n\n/**\n * Add already normalized request data to an event.\n * This mutates the passed in event.\n */\nfunction addNormalizedRequestDataToEvent(\n event: Event,\n req: RequestEventData,\n // Data that should not go into `event.request` but is somehow related to requests\n additionalData: { ipAddress?: string },\n include: RequestDataIncludeOptions,\n): void {\n event.request = {\n ...event.request,\n ...extractNormalizedRequestData(req, include),\n };\n\n if (include.ip) {\n const ip = (req.headers && getClientIPAddress(req.headers)) || additionalData.ipAddress;\n if (ip) {\n event.user = {\n ...event.user,\n ip_address: ip,\n };\n }\n }\n}\n\nfunction extractNormalizedRequestData(\n normalizedRequest: RequestEventData,\n include: RequestDataIncludeOptions,\n): RequestEventData {\n const requestData: RequestEventData = {};\n const headers = { ...normalizedRequest.headers };\n\n if (include.headers) {\n requestData.headers = headers;\n\n // Remove the Cookie header in case cookie data should not be included in the event\n if (!include.cookies) {\n delete (headers as { cookie?: string }).cookie;\n }\n\n // Remove IP headers in case IP data should not be included in the event\n if (!include.ip) {\n ipHeaderNames.forEach(ipHeaderName => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete (headers as Record<string, unknown>)[ipHeaderName];\n });\n }\n }\n\n requestData.method = normalizedRequest.method;\n\n if (include.url) {\n requestData.url = normalizedRequest.url;\n }\n\n if (include.cookies) {\n const cookies = normalizedRequest.cookies || (headers?.cookie ? parseCookie(headers.cookie) : undefined);\n requestData.cookies = cookies || {};\n }\n\n if (include.query_string) {\n requestData.query_string = normalizedRequest.query_string;\n }\n\n if (include.data) {\n requestData.data = normalizedRequest.data;\n }\n\n return requestData;\n}\n"],"names":["defineIntegration","getClientIPAddress","ipHeaderNames","parseCookie"],"mappings":";;;;;;AAuBA;AACA,MAAM,eAAe,GAA8B;AACnD,EAAE,OAAO,EAAE,IAAI;AACf,EAAE,IAAI,EAAE,IAAI;AACZ,EAAE,OAAO,EAAE,IAAI;AACf,EAAE,YAAY,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AAU,OAAA,IAAW,EAAE;AACvC,EAAE;;AAEF,EAAE,IAAI,OAAO,CAAC,YAAY,EAAE;AAC5B,IAAI,WAAW,CAAC,YAAA,GAAe,iBAAiB,CAAC,YAAY;AAC7D,EAAE;;AAEF,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE;AACpB,IAAI,WAAW,CAAC,IAAA,GAAO,iBAAiB,CAAC,IAAI;AAC7C,EAAE;;AAEF,EAAE,OAAO,WAAW;AACpB;;;;"}
1
+ {"version":3,"file":"requestdata.js","sources":["../../../src/integrations/requestdata.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { defineIntegration } from '../integration';\nimport {\n SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n SEMANTIC_ATTRIBUTE_URL_QUERY,\n SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS,\n} from '../semanticAttributes';\nimport { safeSetSpanJSONAttributes } from '../spans/spanFirstUtils';\nimport type { Event } from '../types-hoist/event';\nimport type { IntegrationFn } from '../types-hoist/integration';\nimport type { ClientOptions } from '../types-hoist/options';\nimport type { RequestEventData } from '../types-hoist/request';\nimport type { BaseTransportOptions } from '../types-hoist/transport';\nimport { parseCookie } from '../utils/cookie';\nimport { httpHeadersToSpanAttributes } from '../utils/request';\nimport { getClientIPAddress, ipHeaderNames } from '../vendor/getIpAddress';\n\ninterface RequestDataIncludeOptions {\n cookies?: boolean;\n data?: boolean;\n headers?: boolean;\n ip?: boolean;\n query_string?: boolean;\n url?: boolean;\n}\n\ntype RequestDataIntegrationOptions = {\n /**\n * Controls what data is pulled from the request and added to the event.\n */\n include?: RequestDataIncludeOptions;\n};\n\n// TODO(v11): Change defaults based on `sendDefaultPii`\nconst DEFAULT_INCLUDE: RequestDataIncludeOptions = {\n cookies: true,\n data: true,\n headers: true,\n query_string: true,\n url: true,\n};\n\nconst INTEGRATION_NAME = 'RequestData';\n\nconst _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) => {\n const include = {\n ...DEFAULT_INCLUDE,\n ...options.include,\n };\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n client.on('processSegmentSpan', (spanJSON, { scopeData }) => {\n const { sdkProcessingMetadata = {} } = scopeData;\n const { normalizedRequest, ipAddress } = sdkProcessingMetadata;\n\n if (!normalizedRequest) {\n return;\n }\n\n const includeWithDefaultPiiApplied: RequestDataIncludeOptions = getIncludeWithDefaultPiiApplied(\n include,\n client,\n );\n\n // no need to check for include after calling `extractNormalizedRequestData`\n // because it already internally only return what's permitted by `include`\n const { method, url, query_string, headers, data, env } = extractNormalizedRequestData(\n normalizedRequest,\n includeWithDefaultPiiApplied,\n );\n\n safeSetSpanJSONAttributes(spanJSON, {\n ...(method ? { [SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD]: method } : {}),\n ...(url ? { [SEMANTIC_ATTRIBUTE_URL_FULL]: url } : {}),\n ...(query_string ? { [SEMANTIC_ATTRIBUTE_URL_QUERY]: query_string } : {}),\n ...(headers ? httpHeadersToSpanAttributes(headers, client.getOptions().sendDefaultPii) : {}),\n // TODO: Apparently, Relay still needs Pii rule updates, so I'm leaving this out for now\n // ...(cookies\n // ? Object.keys(cookies).reduce(\n // (acc, cookieName) => ({\n // ...acc,\n // [`http.request.header.cookie.${cookieName}`]: cookies[cookieName] ?? '',\n // }),\n // {} as Record<string, string>,\n // )\n // : {}),\n ...(include.ip\n ? {\n [SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS]:\n (normalizedRequest.headers && getClientIPAddress(normalizedRequest.headers)) || ipAddress,\n }\n : {}),\n ...(data ? { 'http.request.body.content': data } : {}),\n ...(env\n ? {\n 'http.request.env': Object.keys(env).reduce(\n (acc, key) => ({ ...acc, [key]: env[key] ?? '' }),\n {} as Record<string, string>,\n ),\n }\n : {}),\n });\n });\n },\n // TODO (span-streaming): probably fine to leave as-is for errors.\n // For spans, we go through global context -> attribute conversion or omit this completely (TBD)\n processEvent(event, _hint, client) {\n const { sdkProcessingMetadata = {} } = event;\n const { normalizedRequest, ipAddress } = sdkProcessingMetadata;\n\n const includeWithDefaultPiiApplied: RequestDataIncludeOptions = getIncludeWithDefaultPiiApplied(include, client);\n\n if (normalizedRequest) {\n addNormalizedRequestDataToEvent(event, normalizedRequest, { ipAddress }, includeWithDefaultPiiApplied);\n }\n\n return event;\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/core`\n * so it can be used in cross-platform SDKs like `@sentry/nextjs`.\n */\nexport const requestDataIntegration = defineIntegration(_requestDataIntegration);\n\nconst getIncludeWithDefaultPiiApplied = (\n include: {\n cookies?: boolean;\n data?: boolean;\n headers?: boolean;\n ip?: boolean;\n query_string?: boolean;\n url?: boolean;\n },\n client: Client<ClientOptions<BaseTransportOptions>>,\n): RequestDataIncludeOptions => ({\n ...include,\n ip: include.ip ?? client.getOptions().sendDefaultPii,\n});\n\n/**\n * Add already normalized request data to an event.\n * This mutates the passed in event.\n */\nfunction addNormalizedRequestDataToEvent(\n event: Event,\n req: RequestEventData,\n // Data that should not go into `event.request` but is somehow related to requests\n additionalData: { ipAddress?: string },\n include: RequestDataIncludeOptions,\n): void {\n event.request = {\n ...event.request,\n ...extractNormalizedRequestData(req, include),\n };\n\n if (include.ip) {\n const ip = (req.headers && getClientIPAddress(req.headers)) || additionalData.ipAddress;\n if (ip) {\n event.user = {\n ...event.user,\n ip_address: ip,\n };\n }\n }\n}\n\nfunction extractNormalizedRequestData(\n normalizedRequest: RequestEventData,\n include: RequestDataIncludeOptions,\n): RequestEventData {\n const requestData: RequestEventData = {};\n const headers = { ...normalizedRequest.headers };\n\n if (include.headers) {\n requestData.headers = headers;\n\n // Remove the Cookie header in case cookie data should not be included in the event\n if (!include.cookies) {\n delete headers.cookie;\n }\n\n // Remove IP headers in case IP data should not be included in the event\n if (!include.ip) {\n ipHeaderNames.forEach(ipHeaderName => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete headers[ipHeaderName];\n });\n }\n }\n\n requestData.method = normalizedRequest.method;\n\n if (include.url) {\n requestData.url = normalizedRequest.url;\n }\n\n if (include.cookies) {\n const cookies = normalizedRequest.cookies || (headers?.cookie ? parseCookie(headers.cookie) : undefined);\n requestData.cookies = cookies || {};\n }\n\n if (include.query_string) {\n requestData.query_string = normalizedRequest.query_string;\n }\n\n if (include.data) {\n requestData.data = normalizedRequest.data;\n }\n\n return requestData;\n}\n"],"names":["safeSetSpanJSONAttributes","SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD","SEMANTIC_ATTRIBUTE_URL_FULL","SEMANTIC_ATTRIBUTE_URL_QUERY","httpHeadersToSpanAttributes","SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS","getClientIPAddress","defineIntegration","ipHeaderNames","parseCookie"],"mappings":";;;;;;;;;AAkCA;AACA,MAAM,eAAe,GAA8B;AACnD,EAAE,OAAO,EAAE,IAAI;AACf,EAAE,IAAI,EAAE,IAAI;AACZ,EAAE,OAAO,EAAE,IAAI;AACf,EAAE,YAAY,EAAE,IAAI;AACpB,EAAE,GAAG,EAAE,IAAI;AACX,CAAC;;AAED,MAAM,gBAAA,GAAmB,aAAa;;AAEtC,MAAM,uBAAA,IAA2B,CAAC,OAAO,GAAkC,EAAE,KAAK;AAClF,EAAE,MAAM,UAAU;AAClB,IAAI,GAAG,eAAe;AACtB,IAAI,GAAG,OAAO,CAAC,OAAO;AACtB,GAAG;;AAEH,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,QAAQ,EAAE,EAAE,SAAA,EAAW,KAAK;AACnE,QAAQ,MAAM,EAAE,qBAAA,GAAwB,EAAC,EAAE,GAAI,SAAS;AACxD,QAAQ,MAAM,EAAE,iBAAiB,EAAE,SAAA,EAAU,GAAI,qBAAqB;;AAEtE,QA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C,OAAA,GAAU,OAAA,IAAW,EAAE;AACvC,EAAE;;AAEF,EAAE,IAAI,OAAO,CAAC,YAAY,EAAE;AAC5B,IAAI,WAAW,CAAC,YAAA,GAAe,iBAAiB,CAAC,YAAY;AAC7D,EAAE;;AAEF,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE;AACpB,IAAI,WAAW,CAAC,IAAA,GAAO,iBAAiB,CAAC,IAAI;AAC7C,EAAE;;AAEF,EAAE,OAAO,WAAW;AACpB;;;;"}
@@ -0,0 +1,54 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const debugBuild = require('../debug-build.js');
4
+ const integration = require('../integration.js');
5
+ const captureSpan = require('../spans/captureSpan.js');
6
+ const spanBuffer = require('../spans/spanBuffer.js');
7
+ const beforeSendSpan = require('../utils/beforeSendSpan.js');
8
+ const debugLogger = require('../utils/debug-logger.js');
9
+
10
+ const INTEGRATION_NAME = 'SpanStreaming';
11
+
12
+ const _spanStreamingIntegration = ((options) => {
13
+ return {
14
+ name: INTEGRATION_NAME,
15
+ setup(client) {
16
+ const clientOptions = client.getOptions();
17
+ const beforeSendSpan$1 = clientOptions.beforeSendSpan;
18
+
19
+ const initialMessage = 'spanStreamingIntegration requires';
20
+ const fallbackMsg = 'Falling back to static trace lifecycle.';
21
+
22
+ if (clientOptions.traceLifecycle !== 'stream') {
23
+ client.getOptions().traceLifecycle = 'static';
24
+ debugBuild.DEBUG_BUILD && debugLogger.debug.warn(`${initialMessage} \`traceLifecycle\` to be set to "stream"! ${fallbackMsg}`);
25
+ return;
26
+ }
27
+
28
+ if (beforeSendSpan$1 && !beforeSendSpan.isV2BeforeSendSpanCallback(beforeSendSpan$1)) {
29
+ client.getOptions().traceLifecycle = 'static';
30
+ debugBuild.DEBUG_BUILD &&
31
+ debugLogger.debug.warn(`${initialMessage} a beforeSendSpan callback using \`withStreamSpan\`! ${fallbackMsg}`);
32
+ return;
33
+ }
34
+
35
+ const buffer = new spanBuffer.SpanBuffer(client, options);
36
+
37
+ client.on('enqueueSpan', spanJSON => {
38
+ buffer.addSpan(spanJSON);
39
+ });
40
+
41
+ client.on('afterSpanEnd', span => {
42
+ captureSpan.captureSpan(span, client);
43
+ });
44
+ },
45
+ };
46
+ }) ;
47
+
48
+ /**
49
+ * Span streaming integration used by server runtime SDKs.
50
+ */
51
+ const spanStreamingIntegration = integration.defineIntegration(_spanStreamingIntegration);
52
+
53
+ exports.spanStreamingIntegration = spanStreamingIntegration;
54
+ //# sourceMappingURL=spanStreaming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spanStreaming.js","sources":["../../../src/integrations/spanStreaming.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../debug-build';\nimport { defineIntegration } from '../integration';\nimport { captureSpan } from '../spans/captureSpan';\nimport { SpanBuffer } from '../spans/spanBuffer';\nimport type { IntegrationFn } from '../types-hoist/integration';\nimport { isV2BeforeSendSpanCallback } from '../utils/beforeSendSpan';\nimport { debug } from '../utils/debug-logger';\n\nexport interface ServerSpanStreamingOptions {\n /** Max spans per envelope batch (default: 1000) */\n maxSpanLimit?: number;\n /** Flush interval in ms (default: 5000) */\n flushInterval?: number;\n}\n\nconst INTEGRATION_NAME = 'SpanStreaming';\n\nconst _spanStreamingIntegration = ((options?: ServerSpanStreamingOptions) => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const clientOptions = client.getOptions();\n const beforeSendSpan = clientOptions.beforeSendSpan;\n\n const initialMessage = 'spanStreamingIntegration requires';\n const fallbackMsg = 'Falling back to static trace lifecycle.';\n\n if (clientOptions.traceLifecycle !== 'stream') {\n client.getOptions().traceLifecycle = 'static';\n DEBUG_BUILD && debug.warn(`${initialMessage} \\`traceLifecycle\\` to be set to \"stream\"! ${fallbackMsg}`);\n return;\n }\n\n if (beforeSendSpan && !isV2BeforeSendSpanCallback(beforeSendSpan)) {\n client.getOptions().traceLifecycle = 'static';\n DEBUG_BUILD &&\n debug.warn(`${initialMessage} a beforeSendSpan callback using \\`withStreamSpan\\`! ${fallbackMsg}`);\n return;\n }\n\n const buffer = new SpanBuffer(client, options);\n\n client.on('enqueueSpan', spanJSON => {\n buffer.addSpan(spanJSON);\n });\n\n client.on('afterSpanEnd', span => {\n captureSpan(span, client);\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Span streaming integration used by server runtime SDKs.\n */\nexport const spanStreamingIntegration = defineIntegration(_spanStreamingIntegration);\n"],"names":["beforeSendSpan","DEBUG_BUILD","debug","isV2BeforeSendSpanCallback","SpanBuffer","captureSpan","defineIntegration"],"mappings":";;;;;;;;;AAeA,MAAM,gBAAA,GAAmB,eAAe;;AAExC,MAAM,6BAA6B,CAAC,OAAO,KAAkC;AAC7E,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,aAAA,GAAgB,MAAM,CAAC,UAAU,EAAE;AAC/C,MAAM,MAAMA,gBAAA,GAAiB,aAAa,CAAC,cAAc;;AAEzD,MAAM,MAAM,cAAA,GAAiB,mCAAmC;AAChE,MAAM,MAAM,WAAA,GAAc,yCAAyC;;AAEnE,MAAM,IAAI,aAAa,CAAC,cAAA,KAAmB,QAAQ,EAAE;AACrD,QAAQ,MAAM,CAAC,UAAU,EAAE,CAAC,cAAA,GAAiB,QAAQ;AACrD,QAAQC,0BAAeC,iBAAK,CAAC,IAAI,CAAC,CAAC,EAAA,cAAA,CAAA,2CAAA,EAAA,WAAA,CAAA,CAAA,CAAA;AACA,QAAA;AACA,MAAA;;AAEA,MAAA,IAAAF,gBAAA,IAAA,CAAAG,yCAAA,CAAAH,gBAAA,CAAA,EAAA;AACA,QAAA,MAAA,CAAA,UAAA,EAAA,CAAA,cAAA,GAAA,QAAA;AACA,QAAAC,sBAAA;AACA,UAAAC,iBAAA,CAAA,IAAA,CAAA,CAAA,EAAA,cAAA,CAAA,qDAAA,EAAA,WAAA,CAAA,CAAA,CAAA;AACA,QAAA;AACA,MAAA;;AAEA,MAAA,MAAA,MAAA,GAAA,IAAAE,qBAAA,CAAA,MAAA,EAAA,OAAA,CAAA;;AAEA,MAAA,MAAA,CAAA,EAAA,CAAA,aAAA,EAAA,QAAA,IAAA;AACA,QAAA,MAAA,CAAA,OAAA,CAAA,QAAA,CAAA;AACA,MAAA,CAAA,CAAA;;AAEA,MAAA,MAAA,CAAA,EAAA,CAAA,cAAA,EAAA,IAAA,IAAA;AACA,QAAAC,uBAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AACA,MAAA,CAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA,MAAA,wBAAA,GAAAC,6BAAA,CAAA,yBAAA;;;;"}
@@ -22,7 +22,7 @@ function captureMetric(type, name, value, options) {
22
22
  }
23
23
 
24
24
  /**
25
- * @summary Increment a counter metric. Requires the `_experiments.enableMetrics` option to be enabled.
25
+ * @summary Increment a counter metric.
26
26
  *
27
27
  * @param name - The name of the counter metric.
28
28
  * @param value - The value to increment by (defaults to 1).
@@ -56,7 +56,7 @@ function count(name, value = 1, options) {
56
56
  }
57
57
 
58
58
  /**
59
- * @summary Set a gauge metric to a specific value. Requires the `_experiments.enableMetrics` option to be enabled.
59
+ * @summary Set a gauge metric to a specific value.
60
60
  *
61
61
  * @param name - The name of the gauge metric.
62
62
  * @param value - The current value of the gauge.
@@ -90,7 +90,7 @@ function gauge(name, value, options) {
90
90
  }
91
91
 
92
92
  /**
93
- * @summary Record a value in a distribution metric. Requires the `_experiments.enableMetrics` option to be enabled.
93
+ * @summary Record a value in a distribution metric.
94
94
  *
95
95
  * @param name - The name of the distribution metric.
96
96
  * @param value - The value to record in the distribution.
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.js","sources":["../../../src/metrics/public-api.ts"],"sourcesContent":["import type { Scope } from '../scope';\nimport type { Metric, MetricType } from '../types-hoist/metric';\nimport { _INTERNAL_captureMetric } from './internal';\n\n/**\n * Options for capturing a metric.\n */\nexport interface MetricOptions {\n /**\n * The unit of the metric value.\n */\n unit?: string;\n\n /**\n * Arbitrary structured data that stores information about the metric.\n */\n attributes?: Metric['attributes'];\n\n /**\n * The scope to capture the metric with.\n */\n scope?: Scope;\n}\n\n/**\n * Capture a metric with the given type, name, and value.\n *\n * @param type - The type of the metric.\n * @param name - The name of the metric.\n * @param value - The value of the metric.\n * @param options - Options for capturing the metric.\n */\nfunction captureMetric(type: MetricType, name: string, value: number, options?: MetricOptions): void {\n _INTERNAL_captureMetric(\n { type, name, value, unit: options?.unit, attributes: options?.attributes },\n { scope: options?.scope },\n );\n}\n\n/**\n * @summary Increment a counter metric. Requires the `_experiments.enableMetrics` option to be enabled.\n *\n * @param name - The name of the counter metric.\n * @param value - The value to increment by (defaults to 1).\n * @param options - Options for capturing the metric.\n *\n * @example\n *\n * ```\n * Sentry.metrics.count('api.requests', 1, {\n * attributes: {\n * endpoint: '/api/users',\n * method: 'GET',\n * status: 200\n * }\n * });\n * ```\n *\n * @example With custom value\n *\n * ```\n * Sentry.metrics.count('items.processed', 5, {\n * attributes: {\n * processor: 'batch-processor',\n * queue: 'high-priority'\n * }\n * });\n * ```\n */\nexport function count(name: string, value: number = 1, options?: MetricOptions): void {\n captureMetric('counter', name, value, options);\n}\n\n/**\n * @summary Set a gauge metric to a specific value. Requires the `_experiments.enableMetrics` option to be enabled.\n *\n * @param name - The name of the gauge metric.\n * @param value - The current value of the gauge.\n * @param options - Options for capturing the metric.\n *\n * @example\n *\n * ```\n * Sentry.metrics.gauge('memory.usage', 1024, {\n * unit: 'megabyte',\n * attributes: {\n * process: 'web-server',\n * region: 'us-east-1'\n * }\n * });\n * ```\n *\n * @example Without unit\n *\n * ```\n * Sentry.metrics.gauge('active.connections', 42, {\n * attributes: {\n * server: 'api-1',\n * protocol: 'websocket'\n * }\n * });\n * ```\n */\nexport function gauge(name: string, value: number, options?: MetricOptions): void {\n captureMetric('gauge', name, value, options);\n}\n\n/**\n * @summary Record a value in a distribution metric. Requires the `_experiments.enableMetrics` option to be enabled.\n *\n * @param name - The name of the distribution metric.\n * @param value - The value to record in the distribution.\n * @param options - Options for capturing the metric.\n *\n * @example\n *\n * ```\n * Sentry.metrics.distribution('task.duration', 500, {\n * unit: 'millisecond',\n * attributes: {\n * task: 'data-processing',\n * priority: 'high'\n * }\n * });\n * ```\n *\n * @example Without unit\n *\n * ```\n * Sentry.metrics.distribution('batch.size', 100, {\n * attributes: {\n * processor: 'batch-1',\n * type: 'async'\n * }\n * });\n * ```\n */\nexport function distribution(name: string, value: number, options?: MetricOptions): void {\n captureMetric('distribution', name, value, options);\n}\n"],"names":["_INTERNAL_captureMetric"],"mappings":";;;;AAIA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,aAAa,CAAC,IAAI,EAAc,IAAI,EAAU,KAAK,EAAU,OAAO,EAAwB;AACrG,EAAEA,gCAAuB;AACzB,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY;AAC/E,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO;AAC7B,GAAG;AACH;;AAEA;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,KAAK,CAAC,IAAI,EAAU,KAAK,GAAW,CAAC,EAAE,OAAO,EAAwB;AACtF,EAAE,aAAa,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC;AAChD;;AAEA;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,KAAK,CAAC,IAAI,EAAU,KAAK,EAAU,OAAO,EAAwB;AAClF,EAAE,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC;AAC9C;;AAEA;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,YAAY,CAAC,IAAI,EAAU,KAAK,EAAU,OAAO,EAAwB;AACzF,EAAE,aAAa,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC;AACrD;;;;;;"}
1
+ {"version":3,"file":"public-api.js","sources":["../../../src/metrics/public-api.ts"],"sourcesContent":["import type { Scope } from '../scope';\nimport type { Metric, MetricType } from '../types-hoist/metric';\nimport { _INTERNAL_captureMetric } from './internal';\n\n/**\n * Options for capturing a metric.\n */\nexport interface MetricOptions {\n /**\n * The unit of the metric value.\n */\n unit?: string;\n\n /**\n * Arbitrary structured data that stores information about the metric.\n */\n attributes?: Metric['attributes'];\n\n /**\n * The scope to capture the metric with.\n */\n scope?: Scope;\n}\n\n/**\n * Capture a metric with the given type, name, and value.\n *\n * @param type - The type of the metric.\n * @param name - The name of the metric.\n * @param value - The value of the metric.\n * @param options - Options for capturing the metric.\n */\nfunction captureMetric(type: MetricType, name: string, value: number, options?: MetricOptions): void {\n _INTERNAL_captureMetric(\n { type, name, value, unit: options?.unit, attributes: options?.attributes },\n { scope: options?.scope },\n );\n}\n\n/**\n * @summary Increment a counter metric.\n *\n * @param name - The name of the counter metric.\n * @param value - The value to increment by (defaults to 1).\n * @param options - Options for capturing the metric.\n *\n * @example\n *\n * ```\n * Sentry.metrics.count('api.requests', 1, {\n * attributes: {\n * endpoint: '/api/users',\n * method: 'GET',\n * status: 200\n * }\n * });\n * ```\n *\n * @example With custom value\n *\n * ```\n * Sentry.metrics.count('items.processed', 5, {\n * attributes: {\n * processor: 'batch-processor',\n * queue: 'high-priority'\n * }\n * });\n * ```\n */\nexport function count(name: string, value: number = 1, options?: MetricOptions): void {\n captureMetric('counter', name, value, options);\n}\n\n/**\n * @summary Set a gauge metric to a specific value.\n *\n * @param name - The name of the gauge metric.\n * @param value - The current value of the gauge.\n * @param options - Options for capturing the metric.\n *\n * @example\n *\n * ```\n * Sentry.metrics.gauge('memory.usage', 1024, {\n * unit: 'megabyte',\n * attributes: {\n * process: 'web-server',\n * region: 'us-east-1'\n * }\n * });\n * ```\n *\n * @example Without unit\n *\n * ```\n * Sentry.metrics.gauge('active.connections', 42, {\n * attributes: {\n * server: 'api-1',\n * protocol: 'websocket'\n * }\n * });\n * ```\n */\nexport function gauge(name: string, value: number, options?: MetricOptions): void {\n captureMetric('gauge', name, value, options);\n}\n\n/**\n * @summary Record a value in a distribution metric.\n *\n * @param name - The name of the distribution metric.\n * @param value - The value to record in the distribution.\n * @param options - Options for capturing the metric.\n *\n * @example\n *\n * ```\n * Sentry.metrics.distribution('task.duration', 500, {\n * unit: 'millisecond',\n * attributes: {\n * task: 'data-processing',\n * priority: 'high'\n * }\n * });\n * ```\n *\n * @example Without unit\n *\n * ```\n * Sentry.metrics.distribution('batch.size', 100, {\n * attributes: {\n * processor: 'batch-1',\n * type: 'async'\n * }\n * });\n * ```\n */\nexport function distribution(name: string, value: number, options?: MetricOptions): void {\n captureMetric('distribution', name, value, options);\n}\n"],"names":["_INTERNAL_captureMetric"],"mappings":";;;;AAIA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,aAAa,CAAC,IAAI,EAAc,IAAI,EAAU,KAAK,EAAU,OAAO,EAAwB;AACrG,EAAEA,gCAAuB;AACzB,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY;AAC/E,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO;AAC7B,GAAG;AACH;;AAEA;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,KAAK,CAAC,IAAI,EAAU,KAAK,GAAW,CAAC,EAAE,OAAO,EAAwB;AACtF,EAAE,aAAa,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC;AAChD;;AAEA;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,KAAK,CAAC,IAAI,EAAU,KAAK,EAAU,OAAO,EAAwB;AAClF,EAAE,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC;AAC9C;;AAEA;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,YAAY,CAAC,IAAI,EAAU,KAAK,EAAU,OAAO,EAAwB;AACzF,EAAE,aAAa,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC;AACrD;;;;;;"}
@@ -670,7 +670,7 @@ class Scope {
670
670
  * @returns {string} The id of the captured event.
671
671
  */
672
672
  captureEvent(event, hint) {
673
- const eventId = hint?.event_id || misc.uuid4();
673
+ const eventId = event.event_id || hint?.event_id || misc.uuid4();
674
674
 
675
675
  if (!this._client) {
676
676
  debugBuild.DEBUG_BUILD && debugLogger.debug.warn('No client configured on scope - will not capture event!');
@@ -1 +1 @@
1
- {"version":3,"file":"scope.js","sources":["../../src/scope.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { AttributeObject, RawAttribute, RawAttributes } from './attributes';\nimport type { Client } from './client';\nimport { DEBUG_BUILD } from './debug-build';\nimport { updateSession } from './session';\nimport type { Attachment } from './types-hoist/attachment';\nimport type { Breadcrumb } from './types-hoist/breadcrumb';\nimport type { Context, Contexts } from './types-hoist/context';\nimport type { DynamicSamplingContext } from './types-hoist/envelope';\nimport type { Event, EventHint } from './types-hoist/event';\nimport type { EventProcessor } from './types-hoist/eventprocessor';\nimport type { Extra, Extras } from './types-hoist/extra';\nimport type { Primitive } from './types-hoist/misc';\nimport type { RequestEventData } from './types-hoist/request';\nimport type { Session } from './types-hoist/session';\nimport type { SeverityLevel } from './types-hoist/severity';\nimport type { Span } from './types-hoist/span';\nimport type { PropagationContext } from './types-hoist/tracing';\nimport type { User } from './types-hoist/user';\nimport { debug } from './utils/debug-logger';\nimport { isPlainObject } from './utils/is';\nimport { merge } from './utils/merge';\nimport { uuid4 } from './utils/misc';\nimport { generateTraceId } from './utils/propagationContext';\nimport { safeMathRandom } from './utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from './utils/spanOnScope';\nimport { truncate } from './utils/string';\nimport { dateTimestampInSeconds } from './utils/time';\n\n/**\n * Default value for maximum number of breadcrumbs added to an event.\n */\nconst DEFAULT_MAX_BREADCRUMBS = 100;\n\n/**\n * A context to be used for capturing an event.\n * This can either be a Scope, or a partial ScopeContext,\n * or a callback that receives the current scope and returns a new scope to use.\n */\nexport type CaptureContext = Scope | Partial<ScopeContext> | ((scope: Scope) => Scope);\n\n/**\n * Data that can be converted to a Scope.\n */\nexport interface ScopeContext {\n user: User;\n level: SeverityLevel;\n extra: Extras;\n contexts: Contexts;\n tags: { [key: string]: Primitive };\n attributes?: RawAttributes<Record<string, unknown>>;\n fingerprint: string[];\n propagationContext: PropagationContext;\n conversationId?: string;\n}\n\nexport interface SdkProcessingMetadata {\n [key: string]: unknown;\n requestSession?: {\n status: 'ok' | 'errored' | 'crashed';\n };\n normalizedRequest?: RequestEventData;\n dynamicSamplingContext?: Partial<DynamicSamplingContext>;\n capturedSpanScope?: Scope;\n capturedSpanIsolationScope?: Scope;\n spanCountBeforeProcessing?: number;\n ipAddress?: string;\n}\n\n/**\n * Normalized data of the Scope, ready to be used.\n */\nexport interface ScopeData {\n eventProcessors: EventProcessor[];\n breadcrumbs: Breadcrumb[];\n user: User;\n tags: { [key: string]: Primitive };\n // TODO(v11): Make this a required field (could be subtly breaking if we did it today)\n attributes?: RawAttributes<Record<string, unknown>>;\n extra: Extras;\n contexts: Contexts;\n attachments: Attachment[];\n propagationContext: PropagationContext;\n sdkProcessingMetadata: SdkProcessingMetadata;\n fingerprint: string[];\n level?: SeverityLevel;\n transactionName?: string;\n span?: Span;\n conversationId?: string;\n}\n\n/**\n * Holds additional event information.\n */\nexport class Scope {\n /** Flag if notifying is happening. */\n protected _notifyingListeners: boolean;\n\n /** Callback for client to receive scope changes. */\n protected _scopeListeners: Array<(scope: Scope) => void>;\n\n /** Callback list that will be called during event processing. */\n protected _eventProcessors: EventProcessor[];\n\n /** Array of breadcrumbs. */\n protected _breadcrumbs: Breadcrumb[];\n\n /** User */\n protected _user: User;\n\n /** Tags */\n protected _tags: { [key: string]: Primitive };\n\n /** Attributes */\n protected _attributes: RawAttributes<Record<string, unknown>>;\n\n /** Extra */\n protected _extra: Extras;\n\n /** Contexts */\n protected _contexts: Contexts;\n\n /** Attachments */\n protected _attachments: Attachment[];\n\n /** Propagation Context for distributed tracing */\n protected _propagationContext: PropagationContext;\n\n /**\n * A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get\n * sent to Sentry\n */\n protected _sdkProcessingMetadata: SdkProcessingMetadata;\n\n /** Fingerprint */\n protected _fingerprint?: string[];\n\n /** Severity */\n protected _level?: SeverityLevel;\n\n /**\n * Transaction Name\n *\n * IMPORTANT: The transaction name on the scope has nothing to do with root spans/transaction objects.\n * It's purpose is to assign a transaction to the scope that's added to non-transaction events.\n */\n protected _transactionName?: string;\n\n /** Session */\n protected _session?: Session;\n\n /** The client on this scope */\n protected _client?: Client;\n\n /** Contains the last event id of a captured event. */\n protected _lastEventId?: string;\n\n /** Conversation ID */\n protected _conversationId?: string;\n\n // NOTE: Any field which gets added here should get added not only to the constructor but also to the `clone` method.\n\n public constructor() {\n this._notifyingListeners = false;\n this._scopeListeners = [];\n this._eventProcessors = [];\n this._breadcrumbs = [];\n this._attachments = [];\n this._user = {};\n this._tags = {};\n this._attributes = {};\n this._extra = {};\n this._contexts = {};\n this._sdkProcessingMetadata = {};\n this._propagationContext = {\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n };\n }\n\n /**\n * Clone all data from this scope into a new scope.\n */\n public clone(): Scope {\n const newScope = new Scope();\n newScope._breadcrumbs = [...this._breadcrumbs];\n newScope._tags = { ...this._tags };\n newScope._attributes = { ...this._attributes };\n newScope._extra = { ...this._extra };\n newScope._contexts = { ...this._contexts };\n if (this._contexts.flags) {\n // We need to copy the `values` array so insertions on a cloned scope\n // won't affect the original array.\n newScope._contexts.flags = {\n values: [...this._contexts.flags.values],\n };\n }\n\n newScope._user = this._user;\n newScope._level = this._level;\n newScope._session = this._session;\n newScope._transactionName = this._transactionName;\n newScope._fingerprint = this._fingerprint;\n newScope._eventProcessors = [...this._eventProcessors];\n newScope._attachments = [...this._attachments];\n newScope._sdkProcessingMetadata = { ...this._sdkProcessingMetadata };\n newScope._propagationContext = { ...this._propagationContext };\n newScope._client = this._client;\n newScope._lastEventId = this._lastEventId;\n newScope._conversationId = this._conversationId;\n\n _setSpanForScope(newScope, _getSpanForScope(this));\n\n return newScope;\n }\n\n /**\n * Update the client assigned to this scope.\n * Note that not every scope will have a client assigned - isolation scopes & the global scope will generally not have a client,\n * as well as manually created scopes.\n */\n public setClient(client: Client | undefined): void {\n this._client = client;\n }\n\n /**\n * Set the ID of the last captured error event.\n * This is generally only captured on the isolation scope.\n */\n public setLastEventId(lastEventId: string | undefined): void {\n this._lastEventId = lastEventId;\n }\n\n /**\n * Get the client assigned to this scope.\n */\n public getClient<C extends Client>(): C | undefined {\n return this._client as C | undefined;\n }\n\n /**\n * Get the ID of the last captured error event.\n * This is generally only available on the isolation scope.\n */\n public lastEventId(): string | undefined {\n return this._lastEventId;\n }\n\n /**\n * @inheritDoc\n */\n public addScopeListener(callback: (scope: Scope) => void): void {\n this._scopeListeners.push(callback);\n }\n\n /**\n * Add an event processor that will be called before an event is sent.\n */\n public addEventProcessor(callback: EventProcessor): this {\n this._eventProcessors.push(callback);\n return this;\n }\n\n /**\n * Set the user for this scope.\n * Set to `null` to unset the user.\n */\n public setUser(user: User | null): this {\n // If null is passed we want to unset everything, but still define keys,\n // so that later down in the pipeline any existing values are cleared.\n this._user = user || {\n email: undefined,\n id: undefined,\n ip_address: undefined,\n username: undefined,\n };\n\n if (this._session) {\n updateSession(this._session, { user });\n }\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Get the user from this scope.\n */\n public getUser(): User | undefined {\n return this._user;\n }\n\n /**\n * Set the conversation ID for this scope.\n * Set to `null` to unset the conversation ID.\n */\n public setConversationId(conversationId: string | null | undefined): this {\n this._conversationId = conversationId || undefined;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set an object that will be merged into existing tags on the scope,\n * and will be sent as tags data with the event.\n */\n public setTags(tags: { [key: string]: Primitive }): this {\n this._tags = {\n ...this._tags,\n ...tags,\n };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set a single tag that will be sent as tags data with the event.\n */\n public setTag(key: string, value: Primitive): this {\n return this.setTags({ [key]: value });\n }\n\n /**\n * Sets attributes onto the scope.\n *\n * These attributes are currently applied to logs and metrics.\n * In the future, they will also be applied to spans.\n *\n * Important: For now, only strings, numbers and boolean attributes are supported, despite types allowing for\n * more complex attribute types. We'll add this support in the future but already specify the wider type to\n * avoid a breaking change in the future.\n *\n * @param newAttributes - The attributes to set on the scope. You can either pass in key-value pairs, or\n * an object with a `value` and an optional `unit` (if applicable to your attribute).\n *\n * @example\n * ```typescript\n * scope.setAttributes({\n * is_admin: true,\n * payment_selection: 'credit_card',\n * render_duration: { value: 'render_duration', unit: 'ms' },\n * });\n * ```\n */\n public setAttributes<T extends Record<string, unknown>>(newAttributes: RawAttributes<T>): this {\n this._attributes = {\n ...this._attributes,\n ...newAttributes,\n };\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets an attribute onto the scope.\n *\n * These attributes are currently applied to logs and metrics.\n * In the future, they will also be applied to spans.\n *\n * Important: For now, only strings, numbers and boolean attributes are supported, despite types allowing for\n * more complex attribute types. We'll add this support in the future but already specify the wider type to\n * avoid a breaking change in the future.\n *\n * @param key - The attribute key.\n * @param value - the attribute value. You can either pass in a raw value, or an attribute\n * object with a `value` and an optional `unit` (if applicable to your attribute).\n *\n * @example\n * ```typescript\n * scope.setAttribute('is_admin', true);\n * scope.setAttribute('render_duration', { value: 'render_duration', unit: 'ms' });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public setAttribute<T extends RawAttribute<T> extends { value: any } | { unit: any } ? AttributeObject : unknown>(\n key: string,\n value: RawAttribute<T>,\n ): this {\n return this.setAttributes({ [key]: value });\n }\n\n /**\n * Removes the attribute with the given key from the scope.\n *\n * @param key - The attribute key.\n *\n * @example\n * ```typescript\n * scope.removeAttribute('is_admin');\n * ```\n */\n public removeAttribute(key: string): this {\n if (key in this._attributes) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n this._notifyScopeListeners();\n }\n return this;\n }\n\n /**\n * Set an object that will be merged into existing extra on the scope,\n * and will be sent as extra data with the event.\n */\n public setExtras(extras: Extras): this {\n this._extra = {\n ...this._extra,\n ...extras,\n };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set a single key:value extra entry that will be sent as extra data with the event.\n */\n public setExtra(key: string, extra: Extra): this {\n this._extra = { ...this._extra, [key]: extra };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the fingerprint on the scope to send with the events.\n * @param {string[]} fingerprint Fingerprint to group events in Sentry.\n */\n public setFingerprint(fingerprint: string[]): this {\n this._fingerprint = fingerprint;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the level on the scope for future events.\n */\n public setLevel(level: SeverityLevel): this {\n this._level = level;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the transaction name on the scope so that the name of e.g. taken server route or\n * the page location is attached to future events.\n *\n * IMPORTANT: Calling this function does NOT change the name of the currently active\n * root span. If you want to change the name of the active root span, use\n * `Sentry.updateSpanName(rootSpan, 'new name')` instead.\n *\n * By default, the SDK updates the scope's transaction name automatically on sensible\n * occasions, such as a page navigation or when handling a new request on the server.\n */\n public setTransactionName(name?: string): this {\n this._transactionName = name;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets context data with the given name.\n * Data passed as context will be normalized. You can also pass `null` to unset the context.\n * Note that context data will not be merged - calling `setContext` will overwrite an existing context with the same key.\n */\n public setContext(key: string, context: Context | null): this {\n if (context === null) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._contexts[key];\n } else {\n this._contexts[key] = context;\n }\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set the session for the scope.\n */\n public setSession(session?: Session): this {\n if (!session) {\n delete this._session;\n } else {\n this._session = session;\n }\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Get the session from the scope.\n */\n public getSession(): Session | undefined {\n return this._session;\n }\n\n /**\n * Updates the scope with provided data. Can work in three variations:\n * - plain object containing updatable attributes\n * - Scope instance that'll extract the attributes from\n * - callback function that'll receive the current scope as an argument and allow for modifications\n */\n public update(captureContext?: CaptureContext): this {\n if (!captureContext) {\n return this;\n }\n\n const scopeToMerge = typeof captureContext === 'function' ? captureContext(this) : captureContext;\n\n const scopeInstance =\n scopeToMerge instanceof Scope\n ? scopeToMerge.getScopeData()\n : isPlainObject(scopeToMerge)\n ? (captureContext as ScopeContext)\n : undefined;\n\n const {\n tags,\n attributes,\n extra,\n user,\n contexts,\n level,\n fingerprint = [],\n propagationContext,\n conversationId,\n } = scopeInstance || {};\n\n this._tags = { ...this._tags, ...tags };\n this._attributes = { ...this._attributes, ...attributes };\n this._extra = { ...this._extra, ...extra };\n this._contexts = { ...this._contexts, ...contexts };\n\n if (user && Object.keys(user).length) {\n this._user = user;\n }\n\n if (level) {\n this._level = level;\n }\n\n if (fingerprint.length) {\n this._fingerprint = fingerprint;\n }\n\n if (propagationContext) {\n this._propagationContext = propagationContext;\n }\n\n if (conversationId) {\n this._conversationId = conversationId;\n }\n\n return this;\n }\n\n /**\n * Clears the current scope and resets its properties.\n * Note: The client will not be cleared.\n */\n public clear(): this {\n // client is not cleared here on purpose!\n this._breadcrumbs = [];\n this._tags = {};\n this._attributes = {};\n this._extra = {};\n this._user = {};\n this._contexts = {};\n this._level = undefined;\n this._transactionName = undefined;\n this._fingerprint = undefined;\n this._session = undefined;\n this._conversationId = undefined;\n _setSpanForScope(this, undefined);\n this._attachments = [];\n this.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Adds a breadcrumb to the scope.\n * By default, the last 100 breadcrumbs are kept.\n */\n public addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this {\n const maxCrumbs = typeof maxBreadcrumbs === 'number' ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS;\n\n // No data has been changed, so don't notify scope listeners\n if (maxCrumbs <= 0) {\n return this;\n }\n\n const mergedBreadcrumb: Breadcrumb = {\n timestamp: dateTimestampInSeconds(),\n ...breadcrumb,\n // Breadcrumb messages can theoretically be infinitely large and they're held in memory so we truncate them not to leak (too much) memory\n message: breadcrumb.message ? truncate(breadcrumb.message, 2048) : breadcrumb.message,\n };\n\n this._breadcrumbs.push(mergedBreadcrumb);\n if (this._breadcrumbs.length > maxCrumbs) {\n this._breadcrumbs = this._breadcrumbs.slice(-maxCrumbs);\n this._client?.recordDroppedEvent('buffer_overflow', 'log_item');\n }\n\n this._notifyScopeListeners();\n\n return this;\n }\n\n /**\n * Get the last breadcrumb of the scope.\n */\n public getLastBreadcrumb(): Breadcrumb | undefined {\n return this._breadcrumbs[this._breadcrumbs.length - 1];\n }\n\n /**\n * Clear all breadcrumbs from the scope.\n */\n public clearBreadcrumbs(): this {\n this._breadcrumbs = [];\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Add an attachment to the scope.\n */\n public addAttachment(attachment: Attachment): this {\n this._attachments.push(attachment);\n return this;\n }\n\n /**\n * Clear all attachments from the scope.\n */\n public clearAttachments(): this {\n this._attachments = [];\n return this;\n }\n\n /**\n * Get the data of this scope, which should be applied to an event during processing.\n */\n public getScopeData(): ScopeData {\n return {\n breadcrumbs: this._breadcrumbs,\n attachments: this._attachments,\n contexts: this._contexts,\n tags: this._tags,\n attributes: this._attributes,\n extra: this._extra,\n user: this._user,\n level: this._level,\n fingerprint: this._fingerprint || [],\n eventProcessors: this._eventProcessors,\n propagationContext: this._propagationContext,\n sdkProcessingMetadata: this._sdkProcessingMetadata,\n transactionName: this._transactionName,\n span: _getSpanForScope(this),\n conversationId: this._conversationId,\n };\n }\n\n /**\n * Add data which will be accessible during event processing but won't get sent to Sentry.\n */\n public setSDKProcessingMetadata(newData: SdkProcessingMetadata): this {\n this._sdkProcessingMetadata = merge(this._sdkProcessingMetadata, newData, 2);\n return this;\n }\n\n /**\n * Add propagation context to the scope, used for distributed tracing\n */\n public setPropagationContext(context: PropagationContext): this {\n this._propagationContext = context;\n return this;\n }\n\n /**\n * Get propagation context from the scope, used for distributed tracing\n */\n public getPropagationContext(): PropagationContext {\n return this._propagationContext;\n }\n\n /**\n * Capture an exception for this scope.\n *\n * @returns {string} The id of the captured Sentry event.\n */\n public captureException(exception: unknown, hint?: EventHint): string {\n const eventId = hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture exception!');\n return eventId;\n }\n\n const syntheticException = new Error('Sentry syntheticException');\n\n this._client.captureException(\n exception,\n {\n originalException: exception,\n syntheticException,\n ...hint,\n event_id: eventId,\n },\n this,\n );\n\n return eventId;\n }\n\n /**\n * Capture a message for this scope.\n *\n * @returns {string} The id of the captured message.\n */\n public captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string {\n const eventId = hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture message!');\n return eventId;\n }\n\n const syntheticException = hint?.syntheticException ?? new Error(message);\n\n this._client.captureMessage(\n message,\n level,\n {\n originalException: message,\n syntheticException,\n ...hint,\n event_id: eventId,\n },\n this,\n );\n\n return eventId;\n }\n\n /**\n * Capture a Sentry event for this scope.\n *\n * @returns {string} The id of the captured event.\n */\n public captureEvent(event: Event, hint?: EventHint): string {\n const eventId = hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture event!');\n return eventId;\n }\n\n this._client.captureEvent(event, { ...hint, event_id: eventId }, this);\n\n return eventId;\n }\n\n /**\n * This will be called on every set call.\n */\n protected _notifyScopeListeners(): void {\n // We need this check for this._notifyingListeners to be able to work on scope during updates\n // If this check is not here we'll produce endless recursion when something is done with the scope\n // during the callback.\n if (!this._notifyingListeners) {\n this._notifyingListeners = true;\n this._scopeListeners.forEach(callback => {\n callback(this);\n });\n this._notifyingListeners = false;\n }\n }\n}\n"],"names":["generateTraceId","safeMathRandom","_setSpanForScope","_getSpanForScope","updateSession","isPlainObject","dateTimestampInSeconds","truncate","merge","uuid4","DEBUG_BUILD","debug"],"mappings":";;;;;;;;;;;;;;AA6BA;AACA;AACA;AACA,MAAM,uBAAA,GAA0B,GAAG;;AAEnC;AACA;AACA;AACA;AACA;;AAqDA;AACA;AACA;AACO,MAAM,KAAA,CAAM;AACnB;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;AACA;AACA;AACA;;AAGA;;AAGA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAGA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,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,YAAY;AAC/C,QAAQ,QAAQ,CAAC,IAAI,CAAC;AACtB,MAAM,CAAC,CAAC;AACR,MAAM,IAAI,CAAC,mBAAA,GAAsB,KAAK;AACtC,IAAI;AACJ,EAAE;AACF;;;;"}
1
+ {"version":3,"file":"scope.js","sources":["../../src/scope.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { AttributeObject, RawAttribute, RawAttributes } from './attributes';\nimport type { Client } from './client';\nimport { DEBUG_BUILD } from './debug-build';\nimport { updateSession } from './session';\nimport type { Attachment } from './types-hoist/attachment';\nimport type { Breadcrumb } from './types-hoist/breadcrumb';\nimport type { Context, Contexts } from './types-hoist/context';\nimport type { DynamicSamplingContext } from './types-hoist/envelope';\nimport type { Event, EventHint } from './types-hoist/event';\nimport type { EventProcessor } from './types-hoist/eventprocessor';\nimport type { Extra, Extras } from './types-hoist/extra';\nimport type { Primitive } from './types-hoist/misc';\nimport type { RequestEventData } from './types-hoist/request';\nimport type { Session } from './types-hoist/session';\nimport type { SeverityLevel } from './types-hoist/severity';\nimport type { Span } from './types-hoist/span';\nimport type { PropagationContext } from './types-hoist/tracing';\nimport type { User } from './types-hoist/user';\nimport { debug } from './utils/debug-logger';\nimport { isPlainObject } from './utils/is';\nimport { merge } from './utils/merge';\nimport { uuid4 } from './utils/misc';\nimport { generateTraceId } from './utils/propagationContext';\nimport { safeMathRandom } from './utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from './utils/spanOnScope';\nimport { truncate } from './utils/string';\nimport { dateTimestampInSeconds } from './utils/time';\n\n/**\n * Default value for maximum number of breadcrumbs added to an event.\n */\nconst DEFAULT_MAX_BREADCRUMBS = 100;\n\n/**\n * A context to be used for capturing an event.\n * This can either be a Scope, or a partial ScopeContext,\n * or a callback that receives the current scope and returns a new scope to use.\n */\nexport type CaptureContext = Scope | Partial<ScopeContext> | ((scope: Scope) => Scope);\n\n/**\n * Data that can be converted to a Scope.\n */\nexport interface ScopeContext {\n user: User;\n level: SeverityLevel;\n extra: Extras;\n contexts: Contexts;\n tags: { [key: string]: Primitive };\n attributes?: RawAttributes<Record<string, unknown>>;\n fingerprint: string[];\n propagationContext: PropagationContext;\n conversationId?: string;\n}\n\nexport interface SdkProcessingMetadata {\n [key: string]: unknown;\n requestSession?: {\n status: 'ok' | 'errored' | 'crashed';\n };\n normalizedRequest?: RequestEventData;\n dynamicSamplingContext?: Partial<DynamicSamplingContext>;\n capturedSpanScope?: Scope;\n capturedSpanIsolationScope?: Scope;\n spanCountBeforeProcessing?: number;\n ipAddress?: string;\n}\n\n/**\n * Normalized data of the Scope, ready to be used.\n */\nexport interface ScopeData {\n eventProcessors: EventProcessor[];\n breadcrumbs: Breadcrumb[];\n user: User;\n tags: { [key: string]: Primitive };\n // TODO(v11): Make this a required field (could be subtly breaking if we did it today)\n attributes?: RawAttributes<Record<string, unknown>>;\n extra: Extras;\n contexts: Contexts;\n attachments: Attachment[];\n propagationContext: PropagationContext;\n sdkProcessingMetadata: SdkProcessingMetadata;\n fingerprint: string[];\n level?: SeverityLevel;\n transactionName?: string;\n span?: Span;\n conversationId?: string;\n}\n\n/**\n * Holds additional event information.\n */\nexport class Scope {\n /** Flag if notifying is happening. */\n protected _notifyingListeners: boolean;\n\n /** Callback for client to receive scope changes. */\n protected _scopeListeners: Array<(scope: Scope) => void>;\n\n /** Callback list that will be called during event processing. */\n protected _eventProcessors: EventProcessor[];\n\n /** Array of breadcrumbs. */\n protected _breadcrumbs: Breadcrumb[];\n\n /** User */\n protected _user: User;\n\n /** Tags */\n protected _tags: { [key: string]: Primitive };\n\n /** Attributes */\n protected _attributes: RawAttributes<Record<string, unknown>>;\n\n /** Extra */\n protected _extra: Extras;\n\n /** Contexts */\n protected _contexts: Contexts;\n\n /** Attachments */\n protected _attachments: Attachment[];\n\n /** Propagation Context for distributed tracing */\n protected _propagationContext: PropagationContext;\n\n /**\n * A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get\n * sent to Sentry\n */\n protected _sdkProcessingMetadata: SdkProcessingMetadata;\n\n /** Fingerprint */\n protected _fingerprint?: string[];\n\n /** Severity */\n protected _level?: SeverityLevel;\n\n /**\n * Transaction Name\n *\n * IMPORTANT: The transaction name on the scope has nothing to do with root spans/transaction objects.\n * It's purpose is to assign a transaction to the scope that's added to non-transaction events.\n */\n protected _transactionName?: string;\n\n /** Session */\n protected _session?: Session;\n\n /** The client on this scope */\n protected _client?: Client;\n\n /** Contains the last event id of a captured event. */\n protected _lastEventId?: string;\n\n /** Conversation ID */\n protected _conversationId?: string;\n\n // NOTE: Any field which gets added here should get added not only to the constructor but also to the `clone` method.\n\n public constructor() {\n this._notifyingListeners = false;\n this._scopeListeners = [];\n this._eventProcessors = [];\n this._breadcrumbs = [];\n this._attachments = [];\n this._user = {};\n this._tags = {};\n this._attributes = {};\n this._extra = {};\n this._contexts = {};\n this._sdkProcessingMetadata = {};\n this._propagationContext = {\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n };\n }\n\n /**\n * Clone all data from this scope into a new scope.\n */\n public clone(): Scope {\n const newScope = new Scope();\n newScope._breadcrumbs = [...this._breadcrumbs];\n newScope._tags = { ...this._tags };\n newScope._attributes = { ...this._attributes };\n newScope._extra = { ...this._extra };\n newScope._contexts = { ...this._contexts };\n if (this._contexts.flags) {\n // We need to copy the `values` array so insertions on a cloned scope\n // won't affect the original array.\n newScope._contexts.flags = {\n values: [...this._contexts.flags.values],\n };\n }\n\n newScope._user = this._user;\n newScope._level = this._level;\n newScope._session = this._session;\n newScope._transactionName = this._transactionName;\n newScope._fingerprint = this._fingerprint;\n newScope._eventProcessors = [...this._eventProcessors];\n newScope._attachments = [...this._attachments];\n newScope._sdkProcessingMetadata = { ...this._sdkProcessingMetadata };\n newScope._propagationContext = { ...this._propagationContext };\n newScope._client = this._client;\n newScope._lastEventId = this._lastEventId;\n newScope._conversationId = this._conversationId;\n\n _setSpanForScope(newScope, _getSpanForScope(this));\n\n return newScope;\n }\n\n /**\n * Update the client assigned to this scope.\n * Note that not every scope will have a client assigned - isolation scopes & the global scope will generally not have a client,\n * as well as manually created scopes.\n */\n public setClient(client: Client | undefined): void {\n this._client = client;\n }\n\n /**\n * Set the ID of the last captured error event.\n * This is generally only captured on the isolation scope.\n */\n public setLastEventId(lastEventId: string | undefined): void {\n this._lastEventId = lastEventId;\n }\n\n /**\n * Get the client assigned to this scope.\n */\n public getClient<C extends Client>(): C | undefined {\n return this._client as C | undefined;\n }\n\n /**\n * Get the ID of the last captured error event.\n * This is generally only available on the isolation scope.\n */\n public lastEventId(): string | undefined {\n return this._lastEventId;\n }\n\n /**\n * @inheritDoc\n */\n public addScopeListener(callback: (scope: Scope) => void): void {\n this._scopeListeners.push(callback);\n }\n\n /**\n * Add an event processor that will be called before an event is sent.\n */\n public addEventProcessor(callback: EventProcessor): this {\n this._eventProcessors.push(callback);\n return this;\n }\n\n /**\n * Set the user for this scope.\n * Set to `null` to unset the user.\n */\n public setUser(user: User | null): this {\n // If null is passed we want to unset everything, but still define keys,\n // so that later down in the pipeline any existing values are cleared.\n this._user = user || {\n email: undefined,\n id: undefined,\n ip_address: undefined,\n username: undefined,\n };\n\n if (this._session) {\n updateSession(this._session, { user });\n }\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Get the user from this scope.\n */\n public getUser(): User | undefined {\n return this._user;\n }\n\n /**\n * Set the conversation ID for this scope.\n * Set to `null` to unset the conversation ID.\n */\n public setConversationId(conversationId: string | null | undefined): this {\n this._conversationId = conversationId || undefined;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set an object that will be merged into existing tags on the scope,\n * and will be sent as tags data with the event.\n */\n public setTags(tags: { [key: string]: Primitive }): this {\n this._tags = {\n ...this._tags,\n ...tags,\n };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set a single tag that will be sent as tags data with the event.\n */\n public setTag(key: string, value: Primitive): this {\n return this.setTags({ [key]: value });\n }\n\n /**\n * Sets attributes onto the scope.\n *\n * These attributes are currently applied to logs and metrics.\n * In the future, they will also be applied to spans.\n *\n * Important: For now, only strings, numbers and boolean attributes are supported, despite types allowing for\n * more complex attribute types. We'll add this support in the future but already specify the wider type to\n * avoid a breaking change in the future.\n *\n * @param newAttributes - The attributes to set on the scope. You can either pass in key-value pairs, or\n * an object with a `value` and an optional `unit` (if applicable to your attribute).\n *\n * @example\n * ```typescript\n * scope.setAttributes({\n * is_admin: true,\n * payment_selection: 'credit_card',\n * render_duration: { value: 'render_duration', unit: 'ms' },\n * });\n * ```\n */\n public setAttributes<T extends Record<string, unknown>>(newAttributes: RawAttributes<T>): this {\n this._attributes = {\n ...this._attributes,\n ...newAttributes,\n };\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets an attribute onto the scope.\n *\n * These attributes are currently applied to logs and metrics.\n * In the future, they will also be applied to spans.\n *\n * Important: For now, only strings, numbers and boolean attributes are supported, despite types allowing for\n * more complex attribute types. We'll add this support in the future but already specify the wider type to\n * avoid a breaking change in the future.\n *\n * @param key - The attribute key.\n * @param value - the attribute value. You can either pass in a raw value, or an attribute\n * object with a `value` and an optional `unit` (if applicable to your attribute).\n *\n * @example\n * ```typescript\n * scope.setAttribute('is_admin', true);\n * scope.setAttribute('render_duration', { value: 'render_duration', unit: 'ms' });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public setAttribute<T extends RawAttribute<T> extends { value: any } | { unit: any } ? AttributeObject : unknown>(\n key: string,\n value: RawAttribute<T>,\n ): this {\n return this.setAttributes({ [key]: value });\n }\n\n /**\n * Removes the attribute with the given key from the scope.\n *\n * @param key - The attribute key.\n *\n * @example\n * ```typescript\n * scope.removeAttribute('is_admin');\n * ```\n */\n public removeAttribute(key: string): this {\n if (key in this._attributes) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n this._notifyScopeListeners();\n }\n return this;\n }\n\n /**\n * Set an object that will be merged into existing extra on the scope,\n * and will be sent as extra data with the event.\n */\n public setExtras(extras: Extras): this {\n this._extra = {\n ...this._extra,\n ...extras,\n };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set a single key:value extra entry that will be sent as extra data with the event.\n */\n public setExtra(key: string, extra: Extra): this {\n this._extra = { ...this._extra, [key]: extra };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the fingerprint on the scope to send with the events.\n * @param {string[]} fingerprint Fingerprint to group events in Sentry.\n */\n public setFingerprint(fingerprint: string[]): this {\n this._fingerprint = fingerprint;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the level on the scope for future events.\n */\n public setLevel(level: SeverityLevel): this {\n this._level = level;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the transaction name on the scope so that the name of e.g. taken server route or\n * the page location is attached to future events.\n *\n * IMPORTANT: Calling this function does NOT change the name of the currently active\n * root span. If you want to change the name of the active root span, use\n * `Sentry.updateSpanName(rootSpan, 'new name')` instead.\n *\n * By default, the SDK updates the scope's transaction name automatically on sensible\n * occasions, such as a page navigation or when handling a new request on the server.\n */\n public setTransactionName(name?: string): this {\n this._transactionName = name;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets context data with the given name.\n * Data passed as context will be normalized. You can also pass `null` to unset the context.\n * Note that context data will not be merged - calling `setContext` will overwrite an existing context with the same key.\n */\n public setContext(key: string, context: Context | null): this {\n if (context === null) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._contexts[key];\n } else {\n this._contexts[key] = context;\n }\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set the session for the scope.\n */\n public setSession(session?: Session): this {\n if (!session) {\n delete this._session;\n } else {\n this._session = session;\n }\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Get the session from the scope.\n */\n public getSession(): Session | undefined {\n return this._session;\n }\n\n /**\n * Updates the scope with provided data. Can work in three variations:\n * - plain object containing updatable attributes\n * - Scope instance that'll extract the attributes from\n * - callback function that'll receive the current scope as an argument and allow for modifications\n */\n public update(captureContext?: CaptureContext): this {\n if (!captureContext) {\n return this;\n }\n\n const scopeToMerge = typeof captureContext === 'function' ? captureContext(this) : captureContext;\n\n const scopeInstance =\n scopeToMerge instanceof Scope\n ? scopeToMerge.getScopeData()\n : isPlainObject(scopeToMerge)\n ? (captureContext as ScopeContext)\n : undefined;\n\n const {\n tags,\n attributes,\n extra,\n user,\n contexts,\n level,\n fingerprint = [],\n propagationContext,\n conversationId,\n } = scopeInstance || {};\n\n this._tags = { ...this._tags, ...tags };\n this._attributes = { ...this._attributes, ...attributes };\n this._extra = { ...this._extra, ...extra };\n this._contexts = { ...this._contexts, ...contexts };\n\n if (user && Object.keys(user).length) {\n this._user = user;\n }\n\n if (level) {\n this._level = level;\n }\n\n if (fingerprint.length) {\n this._fingerprint = fingerprint;\n }\n\n if (propagationContext) {\n this._propagationContext = propagationContext;\n }\n\n if (conversationId) {\n this._conversationId = conversationId;\n }\n\n return this;\n }\n\n /**\n * Clears the current scope and resets its properties.\n * Note: The client will not be cleared.\n */\n public clear(): this {\n // client is not cleared here on purpose!\n this._breadcrumbs = [];\n this._tags = {};\n this._attributes = {};\n this._extra = {};\n this._user = {};\n this._contexts = {};\n this._level = undefined;\n this._transactionName = undefined;\n this._fingerprint = undefined;\n this._session = undefined;\n this._conversationId = undefined;\n _setSpanForScope(this, undefined);\n this._attachments = [];\n this.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Adds a breadcrumb to the scope.\n * By default, the last 100 breadcrumbs are kept.\n */\n public addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this {\n const maxCrumbs = typeof maxBreadcrumbs === 'number' ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS;\n\n // No data has been changed, so don't notify scope listeners\n if (maxCrumbs <= 0) {\n return this;\n }\n\n const mergedBreadcrumb: Breadcrumb = {\n timestamp: dateTimestampInSeconds(),\n ...breadcrumb,\n // Breadcrumb messages can theoretically be infinitely large and they're held in memory so we truncate them not to leak (too much) memory\n message: breadcrumb.message ? truncate(breadcrumb.message, 2048) : breadcrumb.message,\n };\n\n this._breadcrumbs.push(mergedBreadcrumb);\n if (this._breadcrumbs.length > maxCrumbs) {\n this._breadcrumbs = this._breadcrumbs.slice(-maxCrumbs);\n this._client?.recordDroppedEvent('buffer_overflow', 'log_item');\n }\n\n this._notifyScopeListeners();\n\n return this;\n }\n\n /**\n * Get the last breadcrumb of the scope.\n */\n public getLastBreadcrumb(): Breadcrumb | undefined {\n return this._breadcrumbs[this._breadcrumbs.length - 1];\n }\n\n /**\n * Clear all breadcrumbs from the scope.\n */\n public clearBreadcrumbs(): this {\n this._breadcrumbs = [];\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Add an attachment to the scope.\n */\n public addAttachment(attachment: Attachment): this {\n this._attachments.push(attachment);\n return this;\n }\n\n /**\n * Clear all attachments from the scope.\n */\n public clearAttachments(): this {\n this._attachments = [];\n return this;\n }\n\n /**\n * Get the data of this scope, which should be applied to an event during processing.\n */\n public getScopeData(): ScopeData {\n return {\n breadcrumbs: this._breadcrumbs,\n attachments: this._attachments,\n contexts: this._contexts,\n tags: this._tags,\n attributes: this._attributes,\n extra: this._extra,\n user: this._user,\n level: this._level,\n fingerprint: this._fingerprint || [],\n eventProcessors: this._eventProcessors,\n propagationContext: this._propagationContext,\n sdkProcessingMetadata: this._sdkProcessingMetadata,\n transactionName: this._transactionName,\n span: _getSpanForScope(this),\n conversationId: this._conversationId,\n };\n }\n\n /**\n * Add data which will be accessible during event processing but won't get sent to Sentry.\n */\n public setSDKProcessingMetadata(newData: SdkProcessingMetadata): this {\n this._sdkProcessingMetadata = merge(this._sdkProcessingMetadata, newData, 2);\n return this;\n }\n\n /**\n * Add propagation context to the scope, used for distributed tracing\n */\n public setPropagationContext(context: PropagationContext): this {\n this._propagationContext = context;\n return this;\n }\n\n /**\n * Get propagation context from the scope, used for distributed tracing\n */\n public getPropagationContext(): PropagationContext {\n return this._propagationContext;\n }\n\n /**\n * Capture an exception for this scope.\n *\n * @returns {string} The id of the captured Sentry event.\n */\n public captureException(exception: unknown, hint?: EventHint): string {\n const eventId = hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture exception!');\n return eventId;\n }\n\n const syntheticException = new Error('Sentry syntheticException');\n\n this._client.captureException(\n exception,\n {\n originalException: exception,\n syntheticException,\n ...hint,\n event_id: eventId,\n },\n this,\n );\n\n return eventId;\n }\n\n /**\n * Capture a message for this scope.\n *\n * @returns {string} The id of the captured message.\n */\n public captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string {\n const eventId = hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture message!');\n return eventId;\n }\n\n const syntheticException = hint?.syntheticException ?? new Error(message);\n\n this._client.captureMessage(\n message,\n level,\n {\n originalException: message,\n syntheticException,\n ...hint,\n event_id: eventId,\n },\n this,\n );\n\n return eventId;\n }\n\n /**\n * Capture a Sentry event for this scope.\n *\n * @returns {string} The id of the captured event.\n */\n public captureEvent(event: Event, hint?: EventHint): string {\n const eventId = event.event_id || hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture event!');\n return eventId;\n }\n\n this._client.captureEvent(event, { ...hint, event_id: eventId }, this);\n\n return eventId;\n }\n\n /**\n * This will be called on every set call.\n */\n protected _notifyScopeListeners(): void {\n // We need this check for this._notifyingListeners to be able to work on scope during updates\n // If this check is not here we'll produce endless recursion when something is done with the scope\n // during the callback.\n if (!this._notifyingListeners) {\n this._notifyingListeners = true;\n this._scopeListeners.forEach(callback => {\n callback(this);\n });\n this._notifyingListeners = false;\n }\n }\n}\n"],"names":["generateTraceId","safeMathRandom","_setSpanForScope","_getSpanForScope","updateSession","isPlainObject","dateTimestampInSeconds","truncate","merge","uuid4","DEBUG_BUILD","deb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