@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 +1 @@
1
- {"version":3,"file":"base.js","sources":["../../../src/transports/base.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../debug-build';\nimport type { EventDropReason } from '../types-hoist/clientreport';\nimport type { Envelope, EnvelopeItem } from '../types-hoist/envelope';\nimport type {\n InternalBaseTransportOptions,\n Transport,\n TransportMakeRequestResponse,\n TransportRequestExecutor,\n} from '../types-hoist/transport';\nimport { debug } from '../utils/debug-logger';\nimport {\n createEnvelope,\n envelopeContainsItemType,\n envelopeItemTypeToDataCategory,\n forEachEnvelopeItem,\n serializeEnvelope,\n} from '../utils/envelope';\nimport { makePromiseBuffer, type PromiseBuffer, SENTRY_BUFFER_FULL_ERROR } from '../utils/promisebuffer';\nimport { isRateLimited, type RateLimits, updateRateLimits } from '../utils/ratelimit';\n\nexport const DEFAULT_TRANSPORT_BUFFER_SIZE = 64;\n\n/**\n * Creates an instance of a Sentry `Transport`\n *\n * @param options\n * @param makeRequest\n */\nexport function createTransport(\n options: InternalBaseTransportOptions,\n makeRequest: TransportRequestExecutor,\n buffer: PromiseBuffer<TransportMakeRequestResponse> = makePromiseBuffer(\n options.bufferSize || DEFAULT_TRANSPORT_BUFFER_SIZE,\n ),\n): Transport {\n let rateLimits: RateLimits = {};\n const flush = (timeout?: number): PromiseLike<boolean> => buffer.drain(timeout);\n\n function send(envelope: Envelope): PromiseLike<TransportMakeRequestResponse> {\n const filteredEnvelopeItems: EnvelopeItem[] = [];\n\n // Drop rate limited items from envelope\n forEachEnvelopeItem(envelope, (item, type) => {\n const dataCategory = envelopeItemTypeToDataCategory(type);\n if (isRateLimited(rateLimits, dataCategory)) {\n options.recordDroppedEvent('ratelimit_backoff', dataCategory);\n } else {\n filteredEnvelopeItems.push(item);\n }\n });\n\n // Skip sending if envelope is empty after filtering out rate limited events\n if (filteredEnvelopeItems.length === 0) {\n return Promise.resolve({});\n }\n\n const filteredEnvelope: Envelope = createEnvelope(envelope[0], filteredEnvelopeItems as (typeof envelope)[1]);\n\n // Creates client report for each item in an envelope\n const recordEnvelopeLoss = (reason: EventDropReason): void => {\n // Don't record outcomes for client reports - we don't want to create a feedback loop if client reports themselves fail to send\n if (envelopeContainsItemType(filteredEnvelope, ['client_report'])) {\n DEBUG_BUILD && debug.warn(`Dropping client report. Will not send outcomes (reason: ${reason}).`);\n return;\n }\n forEachEnvelopeItem(filteredEnvelope, (item, type) => {\n options.recordDroppedEvent(reason, envelopeItemTypeToDataCategory(type));\n });\n };\n\n const requestTask = (): PromiseLike<TransportMakeRequestResponse> =>\n makeRequest({ body: serializeEnvelope(filteredEnvelope) }).then(\n response => {\n // We don't want to throw on NOK responses, but we want to at least log them\n if (response.statusCode !== undefined && (response.statusCode < 200 || response.statusCode >= 300)) {\n DEBUG_BUILD && debug.warn(`Sentry responded with status code ${response.statusCode} to sent event.`);\n }\n\n rateLimits = updateRateLimits(rateLimits, response);\n return response;\n },\n error => {\n recordEnvelopeLoss('network_error');\n DEBUG_BUILD && debug.error('Encountered error running transport request:', error);\n throw error;\n },\n );\n\n return buffer.add(requestTask).then(\n result => result,\n error => {\n if (error === SENTRY_BUFFER_FULL_ERROR) {\n DEBUG_BUILD && debug.error('Skipped sending event because buffer is full.');\n recordEnvelopeLoss('queue_overflow');\n return Promise.resolve({});\n } else {\n throw error;\n }\n },\n );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B,CAAC;AAC9C,UAAU,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;AACpC,QAAQ,OAAO;AACf,UAAU,MAAM,KAAK;AACrB,QAAQ;AACR,MAAM,CAAC;AACP,KAAK;AACL,EAAE;;AAEF,EAAE,OAAO;AACT,IAAI,IAAI;AACR,IAAI,KAAK;AACT,GAAG;AACH;;;;"}
1
+ {"version":3,"file":"base.js","sources":["../../../src/transports/base.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../debug-build';\nimport type { EventDropReason } from '../types-hoist/clientreport';\nimport type { Envelope, EnvelopeItem } from '../types-hoist/envelope';\nimport type {\n InternalBaseTransportOptions,\n Transport,\n TransportMakeRequestResponse,\n TransportRequestExecutor,\n} from '../types-hoist/transport';\nimport { debug } from '../utils/debug-logger';\nimport {\n createEnvelope,\n envelopeContainsItemType,\n envelopeItemTypeToDataCategory,\n forEachEnvelopeItem,\n serializeEnvelope,\n} from '../utils/envelope';\nimport { makePromiseBuffer, type PromiseBuffer, SENTRY_BUFFER_FULL_ERROR } from '../utils/promisebuffer';\nimport { isRateLimited, type RateLimits, updateRateLimits } from '../utils/ratelimit';\n\nexport const DEFAULT_TRANSPORT_BUFFER_SIZE = 64;\n\n/**\n * Creates an instance of a Sentry `Transport`\n *\n * @param options\n * @param makeRequest\n */\nexport function createTransport(\n options: InternalBaseTransportOptions,\n makeRequest: TransportRequestExecutor,\n buffer: PromiseBuffer<TransportMakeRequestResponse> = makePromiseBuffer(\n options.bufferSize || DEFAULT_TRANSPORT_BUFFER_SIZE,\n ),\n): Transport {\n let rateLimits: RateLimits = {};\n const flush = (timeout?: number): PromiseLike<boolean> => buffer.drain(timeout);\n\n function send(envelope: Envelope): PromiseLike<TransportMakeRequestResponse> {\n const filteredEnvelopeItems: EnvelopeItem[] = [];\n\n // Drop rate limited items from envelope\n forEachEnvelopeItem(envelope, (item, type) => {\n const dataCategory = envelopeItemTypeToDataCategory(type);\n if (isRateLimited(rateLimits, dataCategory)) {\n options.recordDroppedEvent('ratelimit_backoff', dataCategory);\n } else {\n filteredEnvelopeItems.push(item);\n }\n });\n\n // Skip sending if envelope is empty after filtering out rate limited events\n if (filteredEnvelopeItems.length === 0) {\n return Promise.resolve({});\n }\n\n const filteredEnvelope: Envelope = createEnvelope(envelope[0], filteredEnvelopeItems as (typeof envelope)[1]);\n\n // Creates client report for each item in an envelope\n const recordEnvelopeLoss = (reason: EventDropReason): void => {\n // Don't record outcomes for client reports - we don't want to create a feedback loop if client reports themselves fail to send\n if (envelopeContainsItemType(filteredEnvelope, ['client_report'])) {\n DEBUG_BUILD && debug.warn(`Dropping client report. Will not send outcomes (reason: ${reason}).`);\n return;\n }\n forEachEnvelopeItem(filteredEnvelope, (item, type) => {\n options.recordDroppedEvent(reason, envelopeItemTypeToDataCategory(type));\n });\n };\n\n const requestTask = (): PromiseLike<TransportMakeRequestResponse> =>\n makeRequest({ body: serializeEnvelope(filteredEnvelope) }).then(\n response => {\n // Handle 413 Content Too Large\n // Loss of envelope content is expected so we record a send_error client report\n // https://develop.sentry.dev/sdk/expected-features/#dealing-with-network-failures\n if (response.statusCode === 413) {\n DEBUG_BUILD &&\n debug.error(\n 'Sentry responded with status code 413. Envelope was discarded due to exceeding size limits.',\n );\n recordEnvelopeLoss('send_error');\n return response;\n }\n\n // We don't want to throw on NOK responses, but we want to at least log them\n if (\n DEBUG_BUILD &&\n response.statusCode !== undefined &&\n (response.statusCode < 200 || response.statusCode >= 300)\n ) {\n debug.warn(`Sentry responded with status code ${response.statusCode} to sent event.`);\n }\n\n rateLimits = updateRateLimits(rateLimits, response);\n return response;\n },\n error => {\n recordEnvelopeLoss('network_error');\n DEBUG_BUILD && debug.error('Encountered error running transport request:', error);\n throw error;\n },\n );\n\n return buffer.add(requestTask).then(\n result => result,\n error => {\n if (error === SENTRY_BUFFER_FULL_ERROR) {\n DEBUG_BUILD && debug.error('Skipped sending event because buffer is full.');\n recordEnvelopeLoss('queue_overflow');\n return Promise.resolve({});\n } else {\n throw error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QAAQ,CAAC;AACT,OAAO;;AAEP,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI;AACvC,MAAM,MAAA,IAAU,MAAM;AACtB,MAAM,SAAS;AACf,QAAQ,IAAI,KAAA,KAAU,wBAAwB,EAAE;AAChD,UAAU,eAAe,KAAK,CAAC,KAAK,CAAC,+CAA+C,CAAC;AACrF,UAAU,kBAAkB,CAAC,gBAAgB,CAAC;AAC9C,UAAU,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;AACpC,QAAQ,OAAO;AACf,UAAU,MAAM,KAAK;AACrB,QAAQ;AACR,MAAM,CAAC;AACP,KAAK;AACL,EAAE;;AAEF,EAAE,OAAO;AACT,IAAI,IAAI;AACR,IAAI,KAAK;AACT,GAAG;AACH;;;;"}
@@ -2,6 +2,7 @@ import { DEBUG_BUILD } from '../debug-build.js';
2
2
  import { debug } from '../utils/debug-logger.js';
3
3
  import { envelopeContainsItemType } from '../utils/envelope.js';
4
4
  import { parseRetryAfterHeader } from '../utils/ratelimit.js';
5
+ import { safeUnref } from '../utils/timer.js';
5
6
 
6
7
  const MIN_DELAY = 100; // 100 ms
7
8
  const START_DELAY = 5000; // 5 seconds
@@ -49,26 +50,24 @@ function makeOfflineTransport(
49
50
  clearTimeout(flushTimer );
50
51
  }
51
52
 
52
- flushTimer = setTimeout(async () => {
53
- flushTimer = undefined;
54
-
55
- const found = await store.shift();
56
- if (found) {
57
- log('Attempting to send previously queued event');
53
+ // We need to unref the timer in node.js, otherwise the node process never exit.
54
+ flushTimer = safeUnref(
55
+ setTimeout(async () => {
56
+ flushTimer = undefined;
58
57
 
59
- // We should to update the sent_at timestamp to the current time.
60
- found[0].sent_at = new Date().toISOString();
58
+ const found = await store.shift();
59
+ if (found) {
60
+ log('Attempting to send previously queued event');
61
61
 
62
- void send(found, true).catch(e => {
63
- log('Failed to retry sending', e);
64
- });
65
- }
66
- }, delay) ;
62
+ // We should to update the sent_at timestamp to the current time.
63
+ found[0].sent_at = new Date().toISOString();
67
64
 
68
- // We need to unref the timer in node.js, otherwise the node process never exit.
69
- if (typeof flushTimer !== 'number' && flushTimer.unref) {
70
- flushTimer.unref();
71
- }
65
+ void send(found, true).catch(e => {
66
+ log('Failed to retry sending', e);
67
+ });
68
+ }
69
+ }, delay),
70
+ ) ;
72
71
  }
73
72
 
74
73
  function flushWithBackOff() {
@@ -1 +1 @@
1
- {"version":3,"file":"offline.js","sources":["../../../src/transports/offline.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../debug-build';\nimport type { Envelope } from '../types-hoist/envelope';\nimport type { InternalBaseTransportOptions, Transport, TransportMakeRequestResponse } from '../types-hoist/transport';\nimport { debug } from '../utils/debug-logger';\nimport { envelopeContainsItemType } from '../utils/envelope';\nimport { parseRetryAfterHeader } from '../utils/ratelimit';\n\nexport const MIN_DELAY = 100; // 100 ms\nexport const START_DELAY = 5_000; // 5 seconds\nconst MAX_DELAY = 3.6e6; // 1 hour\n\nexport interface OfflineStore {\n push(env: Envelope): Promise<void>;\n unshift(env: Envelope): Promise<void>;\n shift(): Promise<Envelope | undefined>;\n}\n\nexport type CreateOfflineStore = (options: OfflineTransportOptions) => OfflineStore;\n\nexport interface OfflineTransportOptions extends InternalBaseTransportOptions {\n /**\n * A function that creates the offline store instance.\n */\n createStore?: CreateOfflineStore;\n\n /**\n * Flush the offline store shortly after startup.\n *\n * Defaults: false\n */\n flushAtStartup?: boolean;\n\n /**\n * Called before an event is stored.\n *\n * Return false to drop the envelope rather than store it.\n *\n * @param envelope The envelope that failed to send.\n * @param error The error that occurred.\n * @param retryDelay The current retry delay in milliseconds.\n * @returns Whether the envelope should be stored.\n */\n shouldStore?: (envelope: Envelope, error: Error, retryDelay: number) => boolean | Promise<boolean>;\n\n /**\n * Should an attempt be made to send the envelope to Sentry.\n *\n * If this function is supplied and returns false, `shouldStore` will be called to determine if the envelope should be stored.\n *\n * @param envelope The envelope that will be sent.\n * @returns Whether we should attempt to send the envelope\n */\n shouldSend?: (envelope: Envelope) => boolean | Promise<boolean>;\n}\n\ntype Timer = number | { unref?: () => void };\n\n/**\n * Wraps a transport and stores and retries events when they fail to send.\n *\n * @param createTransport The transport to wrap.\n */\nexport function makeOfflineTransport<TO>(\n createTransport: (options: TO) => Transport,\n): (options: TO & OfflineTransportOptions) => Transport {\n function log(...args: unknown[]): void {\n DEBUG_BUILD && debug.log('[Offline]:', ...args);\n }\n\n return options => {\n const transport = createTransport(options);\n\n if (!options.createStore) {\n throw new Error('No `createStore` function was provided');\n }\n\n const store = options.createStore(options);\n\n let retryDelay = START_DELAY;\n let flushTimer: Timer | undefined;\n\n function shouldQueue(env: Envelope, error: Error, retryDelay: number): boolean | Promise<boolean> {\n // We want to drop client reports because they can be generated when we retry sending events while offline.\n if (envelopeContainsItemType(env, ['client_report'])) {\n return false;\n }\n\n if (options.shouldStore) {\n return options.shouldStore(env, error, retryDelay);\n }\n\n return true;\n }\n\n function flushIn(delay: number): void {\n if (flushTimer) {\n clearTimeout(flushTimer as ReturnType<typeof setTimeout>);\n }\n\n flushTimer = setTimeout(async () => {\n flushTimer = undefined;\n\n const found = await store.shift();\n if (found) {\n log('Attempting to send previously queued event');\n\n // We should to update the sent_at timestamp to the current time.\n found[0].sent_at = new Date().toISOString();\n\n void send(found, true).catch(e => {\n log('Failed to retry sending', e);\n });\n }\n }, delay) as Timer;\n\n // We need to unref the timer in node.js, otherwise the node process never exit.\n if (typeof flushTimer !== 'number' && flushTimer.unref) {\n flushTimer.unref();\n }\n }\n\n function flushWithBackOff(): void {\n if (flushTimer) {\n return;\n }\n\n flushIn(retryDelay);\n\n retryDelay = Math.min(retryDelay * 2, MAX_DELAY);\n }\n\n async function send(envelope: Envelope, isRetry: boolean = false): Promise<TransportMakeRequestResponse> {\n // We queue all replay envelopes to avoid multiple replay envelopes being sent at the same time. If one fails, we\n // need to retry them in order.\n if (!isRetry && envelopeContainsItemType(envelope, ['replay_event', 'replay_recording'])) {\n await store.push(envelope);\n flushIn(MIN_DELAY);\n return {};\n }\n\n try {\n if (options.shouldSend && (await options.shouldSend(envelope)) === false) {\n throw new Error('Envelope not sent because `shouldSend` callback returned false');\n }\n\n const result = await transport.send(envelope);\n\n let delay = MIN_DELAY;\n\n if (result) {\n // If there's a retry-after header, use that as the next delay.\n if (result.headers?.['retry-after']) {\n delay = parseRetryAfterHeader(result.headers['retry-after']);\n } else if (result.headers?.['x-sentry-rate-limits']) {\n delay = 60_000; // 60 seconds\n } // If we have a server error, return now so we don't flush the queue.\n else if ((result.statusCode || 0) >= 400) {\n return result;\n }\n }\n\n flushIn(delay);\n retryDelay = START_DELAY;\n return result;\n } catch (e) {\n if (await shouldQueue(envelope, e as Error, retryDelay)) {\n // If this envelope was a retry, we want to add it to the front of the queue so it's retried again first.\n if (isRetry) {\n await store.unshift(envelope);\n } else {\n await store.push(envelope);\n }\n flushWithBackOff();\n log('Error sending. Event queued.', e as Error);\n return {};\n } else {\n throw e;\n }\n }\n }\n\n if (options.flushAtStartup) {\n flushWithBackOff();\n }\n\n return {\n send,\n flush: timeout => {\n // If there's no timeout, we should attempt to flush the offline queue.\n if (timeout === undefined) {\n retryDelay = START_DELAY;\n flushIn(MIN_DELAY);\n }\n\n return transport.flush(timeout);\n },\n };\n };\n}\n"],"names":[],"mappings":";;;;;AAOO,MAAM,SAAA,GAAY,IAAG;AACrB,MAAM,WAAA,GAAc,KAAK;AAChC,MAAM,SAAA,GAAY,KAAK,CAAA;;AAgDvB;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB;AACpC,EAAE,eAAe;AACjB,EAAwD;AACxD,EAAE,SAAS,GAAG,CAAC,GAAG,IAAI,EAAmB;AACzC,IAAI,WAAA,IAAe,KAAK,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC;AACnD,EAAE;;AAEF,EAAE,OAAO,WAAW;AACpB,IAAI,MAAM,SAAA,GAAY,eAAe,CAAC,OAAO,CAAC;;AAE9C,IAAI,IAAI,CAAC,OAAO,CA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AQ,KAAM,CAAA;AAC1B,UAAU,CAAA;AACV,eAAe,IAAI,CAAC,MAAM,CAAC,UAAA,IAAc,CAAC,KAAK,GAAG,EAAE;AACpD,YAAY,OAAO,MAAM;AACzB,UAAU;AACV,QAAQ;;AAER,QAAQ,OAAO,CAAC,KAAK,CAAC;AACtB,QAAQ,UAAA,GAAa,WAAW;AAChC,QAAQ,OAAO,MAAM;AACrB,MAAM,CAAA,CAAE,OAAO,CAAC,EAAE;AAClB,QAAQ,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAA,GAAY,UAAU,CAAC,EAAE;AACjE;AACA,UAAU,IAAI,OAAO,EAAE;AACvB,YAAY,MAAM,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;AACzC,UAAU,OAAO;AACjB,YAAY,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;AACtC,UAAU;AACV,UAAU,gBAAgB,EAAE;AAC5B,UAAU,GAAG,CAAC,8BAA8B,EAAE,GAAW;AACzD,UAAU,OAAO,EAAE;AACnB,QAAQ,OAAO;AACf,UAAU,MAAM,CAAC;AACjB,QAAQ;AACR,MAAM;AACN,IAAI;;AAEJ,IAAI,IAAI,OAAO,CAAC,cAAc,EAAE;AAChC,MAAM,gBAAgB,EAAE;AACxB,IAAI;;AAEJ,IAAI,OAAO;AACX,MAAM,IAAI;AACV,MAAM,KAAK,EAAE,OAAA,IAAW;AACxB;AACA,QAAQ,IAAI,OAAA,KAAY,SAAS,EAAE;AACnC,UAAU,UAAA,GAAa,WAAW;AAClC,UAAU,OAAO,CAAC,SAAS,CAAC;AAC5B,QAAQ;;AAER,QAAQ,OAAO,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC;AACvC,MAAM,CAAC;AACP,KAAK;AACL,EAAE,CAAC;AACH;;;;"}
1
+ {"version":3,"file":"offline.js","sources":["../../../src/transports/offline.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../debug-build';\nimport type { Envelope } from '../types-hoist/envelope';\nimport type { InternalBaseTransportOptions, Transport, TransportMakeRequestResponse } from '../types-hoist/transport';\nimport { debug } from '../utils/debug-logger';\nimport { envelopeContainsItemType } from '../utils/envelope';\nimport { parseRetryAfterHeader } from '../utils/ratelimit';\nimport { safeUnref } from '../utils/timer';\n\nexport const MIN_DELAY = 100; // 100 ms\nexport const START_DELAY = 5_000; // 5 seconds\nconst MAX_DELAY = 3.6e6; // 1 hour\n\nexport interface OfflineStore {\n push(env: Envelope): Promise<void>;\n unshift(env: Envelope): Promise<void>;\n shift(): Promise<Envelope | undefined>;\n}\n\nexport type CreateOfflineStore = (options: OfflineTransportOptions) => OfflineStore;\n\nexport interface OfflineTransportOptions extends InternalBaseTransportOptions {\n /**\n * A function that creates the offline store instance.\n */\n createStore?: CreateOfflineStore;\n\n /**\n * Flush the offline store shortly after startup.\n *\n * Defaults: false\n */\n flushAtStartup?: boolean;\n\n /**\n * Called before an event is stored.\n *\n * Return false to drop the envelope rather than store it.\n *\n * @param envelope The envelope that failed to send.\n * @param error The error that occurred.\n * @param retryDelay The current retry delay in milliseconds.\n * @returns Whether the envelope should be stored.\n */\n shouldStore?: (envelope: Envelope, error: Error, retryDelay: number) => boolean | Promise<boolean>;\n\n /**\n * Should an attempt be made to send the envelope to Sentry.\n *\n * If this function is supplied and returns false, `shouldStore` will be called to determine if the envelope should be stored.\n *\n * @param envelope The envelope that will be sent.\n * @returns Whether we should attempt to send the envelope\n */\n shouldSend?: (envelope: Envelope) => boolean | Promise<boolean>;\n}\n\ntype Timer = number | { unref?: () => void };\n\n/**\n * Wraps a transport and stores and retries events when they fail to send.\n *\n * @param createTransport The transport to wrap.\n */\nexport function makeOfflineTransport<TO>(\n createTransport: (options: TO) => Transport,\n): (options: TO & OfflineTransportOptions) => Transport {\n function log(...args: unknown[]): void {\n DEBUG_BUILD && debug.log('[Offline]:', ...args);\n }\n\n return options => {\n const transport = createTransport(options);\n\n if (!options.createStore) {\n throw new Error('No `createStore` function was provided');\n }\n\n const store = options.createStore(options);\n\n let retryDelay = START_DELAY;\n let flushTimer: Timer | undefined;\n\n function shouldQueue(env: Envelope, error: Error, retryDelay: number): boolean | Promise<boolean> {\n // We want to drop client reports because they can be generated when we retry sending events while offline.\n if (envelopeContainsItemType(env, ['client_report'])) {\n return false;\n }\n\n if (options.shouldStore) {\n return options.shouldStore(env, error, retryDelay);\n }\n\n return true;\n }\n\n function flushIn(delay: number): void {\n if (flushTimer) {\n clearTimeout(flushTimer as ReturnType<typeof setTimeout>);\n }\n\n // We need to unref the timer in node.js, otherwise the node process never exit.\n flushTimer = safeUnref(\n setTimeout(async () => {\n flushTimer = undefined;\n\n const found = await store.shift();\n if (found) {\n log('Attempting to send previously queued event');\n\n // We should to update the sent_at timestamp to the current time.\n found[0].sent_at = new Date().toISOString();\n\n void send(found, true).catch(e => {\n log('Failed to retry sending', e);\n });\n }\n }, delay),\n ) as Timer;\n }\n\n function flushWithBackOff(): void {\n if (flushTimer) {\n return;\n }\n\n flushIn(retryDelay);\n\n retryDelay = Math.min(retryDelay * 2, MAX_DELAY);\n }\n\n async function send(envelope: Envelope, isRetry: boolean = false): Promise<TransportMakeRequestResponse> {\n // We queue all replay envelopes to avoid multiple replay envelopes being sent at the same time. If one fails, we\n // need to retry them in order.\n if (!isRetry && envelopeContainsItemType(envelope, ['replay_event', 'replay_recording'])) {\n await store.push(envelope);\n flushIn(MIN_DELAY);\n return {};\n }\n\n try {\n if (options.shouldSend && (await options.shouldSend(envelope)) === false) {\n throw new Error('Envelope not sent because `shouldSend` callback returned false');\n }\n\n const result = await transport.send(envelope);\n\n let delay = MIN_DELAY;\n\n if (result) {\n // If there's a retry-after header, use that as the next delay.\n if (result.headers?.['retry-after']) {\n delay = parseRetryAfterHeader(result.headers['retry-after']);\n } else if (result.headers?.['x-sentry-rate-limits']) {\n delay = 60_000; // 60 seconds\n } // If we have a server error, return now so we don't flush the queue.\n else if ((result.statusCode || 0) >= 400) {\n return result;\n }\n }\n\n flushIn(delay);\n retryDelay = START_DELAY;\n return result;\n } catch (e) {\n if (await shouldQueue(envelope, e as Error, retryDelay)) {\n // If this envelope was a retry, we want to add it to the front of the queue so it's retried again first.\n if (isRetry) {\n await store.unshift(envelope);\n } else {\n await store.push(envelope);\n }\n flushWithBackOff();\n log('Error sending. Event queued.', e as Error);\n return {};\n } else {\n throw e;\n }\n }\n }\n\n if (options.flushAtStartup) {\n flushWithBackOff();\n }\n\n return {\n send,\n flush: timeout => {\n // If there's no timeout, we should attempt to flush the offline queue.\n if (timeout === undefined) {\n retryDelay = START_DELAY;\n flushIn(MIN_DELAY);\n }\n\n return transport.flush(timeout);\n },\n };\n };\n}\n"],"names":[],"mappings":";;;;;;AAQO,MAAM,SAAA,GAAY,IAAG;AACrB,MAAM,WAAA,GAAc,KAAK;AAChC,MAAM,SAAA,GAAY,KAAK,CAAA;;AAgDvB;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB;AACpC,EAAE,eAAe;AACjB,EAAwD;AACxD,EAAE,SAAS,GAAG,CAAC,GAAG,IAAI,EAAmB;AACzC,IAAI,WAAA,IAAe,KAAK,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC;AACnD,EAAE;;AAEF,EAAE,OAAO,WAAW;AACpB,IAAI,MAAM,SAAA,GAAY,eAAe,CAAC,OAAO,CAAC;;AAE9C,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;AAC9B,MAAM,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC;AAC/D,IAAI;;AAEJ,IAAI,MAAM,QAAQ,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC;;AAE9C,IAAI,IAAI,UAAA,GAAa,WAAW;AAChC,IAAI,IAAI,UAAU;;AAElB,IAAI,SAAS,WAAW,CAAC,GAAG,EAAY,KAAK,EAAS,UAAU,EAAsC;AACtG;AACA,MAAM,IAAI,wBAAwB,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC,EAAE;AAC5D,QAAQ,OAAO,KAAK;AACpB,MA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,OAAO;AACjB,YAAY,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;AACtC,UAAU;AACV,UAAU,gBAAgB,EAAE;AAC5B,UAAU,GAAG,CAAC,8BAA8B,EAAE,GAAW;AACzD,UAAU,OAAO,EAAE;AACnB,QAAQ,OAAO;AACf,UAAU,MAAM,CAAC;AACjB,QAAQ;AACR,MAAM;AACN,IAAI;;AAEJ,IAAI,IAAI,OAAO,CAAC,cAAc,EAAE;AAChC,MAAM,gBAAgB,EAAE;AACxB,IAAI;;AAEJ,IAAI,OAAO;AACX,MAAM,IAAI;AACV,MAAM,KAAK,EAAE,OAAA,IAAW;AACxB;AACA,QAAQ,IAAI,OAAA,KAAY,SAAS,EAAE;AACnC,UAAU,UAAA,GAAa,WAAW;AAClC,UAAU,OAAO,CAAC,SAAS,CAAC;AAC5B,QAAQ;;AAER,QAAQ,OAAO,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC;AACvC,MAAM,CAAC;AACP,KAAK;AACL,EAAE,CAAC;AACH;;;;"}
@@ -0,0 +1,33 @@
1
+ import { addNonEnumerableProperty } from './object.js';
2
+
3
+ /**
4
+ * A wrapper to use the new span format in your `beforeSendSpan` callback.
5
+ *
6
+ * @example
7
+ *
8
+ * Sentry.init({
9
+ * beforeSendSpan: withStreamSpan((span) => {
10
+ * return span;
11
+ * }),
12
+ * });
13
+ *
14
+ * @param callback
15
+ * @returns
16
+ */
17
+ function withStreamSpan(callback) {
18
+ addNonEnumerableProperty(callback, '_v2', true);
19
+ // type-casting here because TS can't infer the type correctly
20
+ return callback ;
21
+ }
22
+
23
+ /**
24
+ * Typesafe check to identify the expected span json format of the `beforeSendSpan` callback.
25
+ */
26
+ function isV2BeforeSendSpanCallback(
27
+ callback,
28
+ ) {
29
+ return !!callback && '_v2' in callback && !!callback._v2;
30
+ }
31
+
32
+ export { isV2BeforeSendSpanCallback, withStreamSpan };
33
+ //# sourceMappingURL=beforeSendSpan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"beforeSendSpan.js","sources":["../../../src/utils/beforeSendSpan.ts"],"sourcesContent":["import type { ClientOptions, SpanV2CompatibleBeforeSendSpanCallback } from '../types-hoist/options';\nimport type { SpanV2JSON } from '../types-hoist/span';\nimport { addNonEnumerableProperty } from './object';\n\n/**\n * A wrapper to use the new span format in your `beforeSendSpan` callback.\n *\n * @example\n *\n * Sentry.init({\n * beforeSendSpan: withStreamSpan((span) => {\n * return span;\n * }),\n * });\n *\n * @param callback\n * @returns\n */\nexport function withStreamSpan(callback: (span: SpanV2JSON) => SpanV2JSON): SpanV2CompatibleBeforeSendSpanCallback {\n addNonEnumerableProperty(callback, '_v2', true);\n // type-casting here because TS can't infer the type correctly\n return callback as SpanV2CompatibleBeforeSendSpanCallback;\n}\n\n/**\n * Typesafe check to identify the expected span json format of the `beforeSendSpan` callback.\n */\nexport function isV2BeforeSendSpanCallback(\n callback: ClientOptions['beforeSendSpan'],\n): callback is SpanV2CompatibleBeforeSendSpanCallback {\n return !!callback && '_v2' in callback && !!callback._v2;\n}\n"],"names":[],"mappings":";;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,QAAQ,EAA4E;AACnH,EAAE,wBAAwB,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC;AACjD;AACA,EAAE,OAAO,QAAA;AACT;;AAEA;AACA;AACA;AACO,SAAS,0BAA0B;AAC1C,EAAE,QAAQ;AACV,EAAsD;AACtD,EAAE,OAAO,CAAC,CAAC,QAAA,IAAY,KAAA,IAAS,QAAA,IAAY,CAAC,CAAC,QAAQ,CAAC,GAAG;AAC1D;;;;"}
@@ -0,0 +1,28 @@
1
+ const FALSY_ENV_VALUES = new Set(['false', 'f', 'n', 'no', 'off', '0']);
2
+ const TRUTHY_ENV_VALUES = new Set(['true', 't', 'y', 'yes', 'on', '1']);
3
+
4
+ /**
5
+ * A helper function which casts an ENV variable value to `true` or `false` using the constants defined above.
6
+ * In strict mode, it may return `null` if the value doesn't match any of the predefined values.
7
+ *
8
+ * @param value The value of the env variable
9
+ * @param options -- Only has `strict` key for now, which requires a strict match for `true` in TRUTHY_ENV_VALUES
10
+ * @returns true/false if the lowercase value matches the predefined values above. If not, null in strict mode,
11
+ * and Boolean(value) in loose mode.
12
+ */
13
+ function envToBool(value, options) {
14
+ const normalized = String(value).toLowerCase();
15
+
16
+ if (FALSY_ENV_VALUES.has(normalized)) {
17
+ return false;
18
+ }
19
+
20
+ if (TRUTHY_ENV_VALUES.has(normalized)) {
21
+ return true;
22
+ }
23
+
24
+ return options?.strict ? null : Boolean(value);
25
+ }
26
+
27
+ export { FALSY_ENV_VALUES, TRUTHY_ENV_VALUES, envToBool };
28
+ //# sourceMappingURL=envToBool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envToBool.js","sources":["../../../src/utils/envToBool.ts"],"sourcesContent":["export const FALSY_ENV_VALUES = new Set(['false', 'f', 'n', 'no', 'off', '0']);\nexport const TRUTHY_ENV_VALUES = new Set(['true', 't', 'y', 'yes', 'on', '1']);\n\nexport type StrictBoolCast = {\n strict: true;\n};\n\nexport type LooseBoolCast = {\n strict?: false;\n};\n\nexport type BoolCastOptions = StrictBoolCast | LooseBoolCast;\n\nexport function envToBool(value: unknown, options?: LooseBoolCast): boolean;\nexport function envToBool(value: unknown, options: StrictBoolCast): boolean | null;\nexport function envToBool(value: unknown, options?: BoolCastOptions): boolean | null;\n/**\n * A helper function which casts an ENV variable value to `true` or `false` using the constants defined above.\n * In strict mode, it may return `null` if the value doesn't match any of the predefined values.\n *\n * @param value The value of the env variable\n * @param options -- Only has `strict` key for now, which requires a strict match for `true` in TRUTHY_ENV_VALUES\n * @returns true/false if the lowercase value matches the predefined values above. If not, null in strict mode,\n * and Boolean(value) in loose mode.\n */\nexport function envToBool(value: unknown, options?: BoolCastOptions): boolean | null {\n const normalized = String(value).toLowerCase();\n\n if (FALSY_ENV_VALUES.has(normalized)) {\n return false;\n }\n\n if (TRUTHY_ENV_VALUES.has(normalized)) {\n return true;\n }\n\n return options?.strict ? null : Boolean(value);\n}\n"],"names":[],"mappings":"MAAa,gBAAA,GAAmB,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC;MAChE,iBAAA,GAAoB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC;;AAe7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS,CAAC,KAAK,EAAW,OAAO,EAAoC;AACrF,EAAE,MAAM,UAAA,GAAa,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE;;AAEhD,EAAE,IAAI,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;AACxC,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,IAAI,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;AACzC,IAAI,OAAO,IAAI;AACf,EAAE;;AAEF,EAAE,OAAO,OAAO,EAAE,MAAA,GAAS,OAAO,OAAO,CAAC,KAAK,CAAC;AAChD;;;;"}
@@ -24,6 +24,7 @@ const SPAN_FLAG_ATTRIBUTE_PREFIX = 'flag.evaluation.';
24
24
  /**
25
25
  * Copies feature flags that are in current scope context to the event context
26
26
  */
27
+ // TODO (span-streaming): should flags be added to (segment) spans? If so, probably do this via globally applying context data to spans
27
28
  function _INTERNAL_copyFlagsFromScopeToEvent(event) {
28
29
  const scope = getCurrentScope();
29
30
  const flagContext = scope.getScopeData().contexts.flags;
@@ -1 +1 @@
1
- {"version":3,"file":"featureFlags.js","sources":["../../../src/utils/featureFlags.ts"],"sourcesContent":["import { getCurrentScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { type Event } from '../types-hoist/event';\nimport { debug } from './debug-logger';\nimport { getActiveSpan, spanToJSON } from './spanUtils';\n\n/**\n * Ordered LRU cache for storing feature flags in the scope context. The name\n * of each flag in the buffer is unique, and the output of getAll() is ordered\n * from oldest to newest.\n */\n\nexport type FeatureFlag = { readonly flag: string; readonly result: boolean };\n\n/**\n * Max size of the LRU flag buffer stored in Sentry scope and event contexts.\n */\nexport const _INTERNAL_FLAG_BUFFER_SIZE = 100;\n\n/**\n * Max number of flag evaluations to record per span.\n */\nexport const _INTERNAL_MAX_FLAGS_PER_SPAN = 10;\n\nconst SPAN_FLAG_ATTRIBUTE_PREFIX = 'flag.evaluation.';\n\n/**\n * Copies feature flags that are in current scope context to the event context\n */\nexport function _INTERNAL_copyFlagsFromScopeToEvent(event: Event): Event {\n const scope = getCurrentScope();\n const flagContext = scope.getScopeData().contexts.flags;\n const flagBuffer = flagContext ? flagContext.values : [];\n\n if (!flagBuffer.length) {\n return event;\n }\n\n if (event.contexts === undefined) {\n event.contexts = {};\n }\n event.contexts.flags = { values: [...flagBuffer] };\n return event;\n}\n\n/**\n * Inserts a flag into the current scope's context while maintaining ordered LRU properties.\n * Not thread-safe. After inserting:\n * - The flag buffer is sorted in order of recency, with the newest evaluation at the end.\n * - The names in the buffer are always unique.\n * - The length of the buffer never exceeds `maxSize`.\n *\n * @param name Name of the feature flag to insert.\n * @param value Value of the feature flag.\n * @param maxSize Max number of flags the buffer should store. Default value should always be used in production.\n */\nexport function _INTERNAL_insertFlagToScope(\n name: string,\n value: unknown,\n maxSize: number = _INTERNAL_FLAG_BUFFER_SIZE,\n): void {\n const scopeContexts = getCurrentScope().getScopeData().contexts;\n if (!scopeContexts.flags) {\n scopeContexts.flags = { values: [] };\n }\n const flags = scopeContexts.flags.values;\n _INTERNAL_insertToFlagBuffer(flags, name, value, maxSize);\n}\n\n/**\n * Exported for tests only. Currently only accepts boolean values (otherwise no-op).\n * Inserts a flag into a FeatureFlag array while maintaining the following properties:\n * - Flags are sorted in order of recency, with the newest evaluation at the end.\n * - The flag names are always unique.\n * - The length of the array never exceeds `maxSize`.\n *\n * @param flags The buffer to insert the flag into.\n * @param name Name of the feature flag to insert.\n * @param value Value of the feature flag.\n * @param maxSize Max number of flags the buffer should store. Default value should always be used in production.\n */\nexport function _INTERNAL_insertToFlagBuffer(\n flags: FeatureFlag[],\n name: string,\n value: unknown,\n maxSize: number,\n): void {\n if (typeof value !== 'boolean') {\n return;\n }\n\n if (flags.length > maxSize) {\n DEBUG_BUILD && debug.error(`[Feature Flags] insertToFlagBuffer called on a buffer larger than maxSize=${maxSize}`);\n return;\n }\n\n // Check if the flag is already in the buffer - O(n)\n const index = flags.findIndex(f => f.flag === name);\n\n if (index !== -1) {\n // The flag was found, remove it from its current position - O(n)\n flags.splice(index, 1);\n }\n\n if (flags.length === maxSize) {\n // If at capacity, pop the earliest flag - O(n)\n flags.shift();\n }\n\n // Push the flag to the end - O(1)\n flags.push({\n flag: name,\n result: value,\n });\n}\n\n/**\n * Records a feature flag evaluation for the active span. This is a no-op for non-boolean values.\n * The flag and its value is stored in span attributes with the `flag.evaluation` prefix. Once the\n * unique flags for a span reaches maxFlagsPerSpan, subsequent flags are dropped.\n *\n * @param name Name of the feature flag.\n * @param value Value of the feature flag. Non-boolean values are ignored.\n * @param maxFlagsPerSpan Max number of flags a buffer should store. Default value should always be used in production.\n */\nexport function _INTERNAL_addFeatureFlagToActiveSpan(\n name: string,\n value: unknown,\n maxFlagsPerSpan: number = _INTERNAL_MAX_FLAGS_PER_SPAN,\n): void {\n if (typeof value !== 'boolean') {\n return;\n }\n\n const span = getActiveSpan();\n if (!span) {\n return;\n }\n\n const attributes = spanToJSON(span).data;\n\n // If the flag already exists, always update it\n if (`${SPAN_FLAG_ATTRIBUTE_PREFIX}${name}` in attributes) {\n span.setAttribute(`${SPAN_FLAG_ATTRIBUTE_PREFIX}${name}`, value);\n return;\n }\n\n // Else, add the flag to the span if we have not reached the max number of flags\n const numOfAddedFlags = Object.keys(attributes).filter(key => key.startsWith(SPAN_FLAG_ATTRIBUTE_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AAA,CAAA,IAAA,EAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,MAAA,UAAA,GAAA,UAAA,CAAA,IAAA,CAAA,CAAA,IAAA;;AAEA;AACA,EAAA,IAAA,CAAA,EAAA,0BAAA,CAAA,EAAA,IAAA,CAAA,CAAA,IAAA,UAAA,EAAA;AACA,IAAA,IAAA,CAAA,YAAA,CAAA,CAAA,EAAA,0BAAA,CAAA,EAAA,IAAA,CAAA,CAAA,EAAA,KAAA,CAAA;AACA,IAAA;AACA,EAAA;;AAEA;AACA,EAAA,MAAA,eAAA,GAAA,MAAA,CAAA,IAAA,CAAA,UAAA,CAAA,CAAA,MAAA,CAAA,GAAA,IAAA,GAAA,CAAA,UAAA,CAAA,0BAAA,CAAA,CAAA,CAAA,MAAA;AACA,EAAA,IAAA,eAAA,GAAA,eAAA,EAAA;AACA,IAAA,IAAA,CAAA,YAAA,CAAA,CAAA,EAAA,0BAAA,CAAA,EAAA,IAAA,CAAA,CAAA,EAAA,KAAA,CAAA;AACA,EAAA;AACA;;;;"}
1
+ {"version":3,"file":"featureFlags.js","sources":["../../../src/utils/featureFlags.ts"],"sourcesContent":["import { getCurrentScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { type Event } from '../types-hoist/event';\nimport { debug } from './debug-logger';\nimport { getActiveSpan, spanToJSON } from './spanUtils';\n\n/**\n * Ordered LRU cache for storing feature flags in the scope context. The name\n * of each flag in the buffer is unique, and the output of getAll() is ordered\n * from oldest to newest.\n */\n\nexport type FeatureFlag = { readonly flag: string; readonly result: boolean };\n\n/**\n * Max size of the LRU flag buffer stored in Sentry scope and event contexts.\n */\nexport const _INTERNAL_FLAG_BUFFER_SIZE = 100;\n\n/**\n * Max number of flag evaluations to record per span.\n */\nexport const _INTERNAL_MAX_FLAGS_PER_SPAN = 10;\n\nconst SPAN_FLAG_ATTRIBUTE_PREFIX = 'flag.evaluation.';\n\n/**\n * Copies feature flags that are in current scope context to the event context\n */\n// TODO (span-streaming): should flags be added to (segment) spans? If so, probably do this via globally applying context data to spans\nexport function _INTERNAL_copyFlagsFromScopeToEvent(event: Event): Event {\n const scope = getCurrentScope();\n const flagContext = scope.getScopeData().contexts.flags;\n const flagBuffer = flagContext ? flagContext.values : [];\n\n if (!flagBuffer.length) {\n return event;\n }\n\n if (event.contexts === undefined) {\n event.contexts = {};\n }\n event.contexts.flags = { values: [...flagBuffer] };\n return event;\n}\n\n/**\n * Inserts a flag into the current scope's context while maintaining ordered LRU properties.\n * Not thread-safe. After inserting:\n * - The flag buffer is sorted in order of recency, with the newest evaluation at the end.\n * - The names in the buffer are always unique.\n * - The length of the buffer never exceeds `maxSize`.\n *\n * @param name Name of the feature flag to insert.\n * @param value Value of the feature flag.\n * @param maxSize Max number of flags the buffer should store. Default value should always be used in production.\n */\nexport function _INTERNAL_insertFlagToScope(\n name: string,\n value: unknown,\n maxSize: number = _INTERNAL_FLAG_BUFFER_SIZE,\n): void {\n const scopeContexts = getCurrentScope().getScopeData().contexts;\n if (!scopeContexts.flags) {\n scopeContexts.flags = { values: [] };\n }\n const flags = scopeContexts.flags.values;\n _INTERNAL_insertToFlagBuffer(flags, name, value, maxSize);\n}\n\n/**\n * Exported for tests only. Currently only accepts boolean values (otherwise no-op).\n * Inserts a flag into a FeatureFlag array while maintaining the following properties:\n * - Flags are sorted in order of recency, with the newest evaluation at the end.\n * - The flag names are always unique.\n * - The length of the array never exceeds `maxSize`.\n *\n * @param flags The buffer to insert the flag into.\n * @param name Name of the feature flag to insert.\n * @param value Value of the feature flag.\n * @param maxSize Max number of flags the buffer should store. Default value should always be used in production.\n */\nexport function _INTERNAL_insertToFlagBuffer(\n flags: FeatureFlag[],\n name: string,\n value: unknown,\n maxSize: number,\n): void {\n if (typeof value !== 'boolean') {\n return;\n }\n\n if (flags.length > maxSize) {\n DEBUG_BUILD && debug.error(`[Feature Flags] insertToFlagBuffer called on a buffer larger than maxSize=${maxSize}`);\n return;\n }\n\n // Check if the flag is already in the buffer - O(n)\n const index = flags.findIndex(f => f.flag === name);\n\n if (index !== -1) {\n // The flag was found, remove it from its current position - O(n)\n flags.splice(index, 1);\n }\n\n if (flags.length === maxSize) {\n // If at capacity, pop the earliest flag - O(n)\n flags.shift();\n }\n\n // Push the flag to the end - O(1)\n flags.push({\n flag: name,\n result: value,\n });\n}\n\n/**\n * Records a feature flag evaluation for the active span. This is a no-op for non-boolean values.\n * The flag and its value is stored in span attributes with the `flag.evaluation` prefix. Once the\n * unique flags for a span reaches maxFlagsPerSpan, subsequent flags are dropped.\n *\n * @param name Name of the feature flag.\n * @param value Value of the feature flag. Non-boolean values are ignored.\n * @param maxFlagsPerSpan Max number of flags a buffer should store. Default value should always be used in production.\n */\nexport function _INTERNAL_addFeatureFlagToActiveSpan(\n name: string,\n value: unknown,\n maxFlagsPerSpan: number = _INTERNAL_MAX_FLAGS_PER_SPAN,\n): void {\n if (typeof value !== 'boolean') {\n return;\n }\n\n const span = getActiveSpan();\n if (!span) {\n return;\n }\n\n const attributes = spanToJSON(span).data;\n\n // If the flag already exists, always update it\n if (`${SPAN_FLAG_ATTRIBUTE_PREFIX}${name}` in attributes) {\n span.setAttribute(`${SPAN_FLAG_ATTRIBUTE_PREFIX}${name}`, value);\n return;\n }\n\n // Else, add the flag to the span if we have not reached the max number of flags\n const numOfAddedFlags = Object.keys(attributes).filter(key => key.startsWith(SPAN_FLAG_ATTRIBUTE_PREFIX)).length;\n if (numOfAddedFlags < maxFlagsPerSpan) {\n span.setAttribute(`${SPAN_FLAG_ATTRIBUTE_PREFIX}${name}`, value);\n }\n}\n"],"names":[],"mappings":";;;;;AAMA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACO,MAAM,0BAAA,GAA6B;;AAE1C;AACA;AACA;AACO,MAAM,4BAAA,GAA+B;;AAE5C,MAAM,0BAAA,GAA6B,kBAAkB;;AAErD;AACA;AACA;AACA;AACO,SAAS,mCAAmC,CAAC,KAAK,EAAgB;AACzE,EAAE,MAAM,KAAA,GAAQ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A,MAAA,CAAA,IAAA,CAAA,UAAA,CAAA,CAAA,MAAA,CAAA,GAAA,IAAA,GAAA,CAAA,UAAA,CAAA,0BAAA,CAAA,CAAA,CAAA,MAAA;AACA,EAAA,IAAA,eAAA,GAAA,eAAA,EAAA;AACA,IAAA,IAAA,CAAA,YAAA,CAAA,CAAA,EAAA,0BAAA,CAAA,EAAA,IAAA,CAAA,CAAA,EAAA,KAAA,CAAA;AACA,EAAA;AACA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"flushIfServerless.js","sources":["../../../src/utils/flushIfServerless.ts"],"sourcesContent":["import { flush } from '../exports';\nimport { debug } from './debug-logger';\nimport { vercelWaitUntil } from './vercelWaitUntil';\nimport { GLOBAL_OBJ } from './worldwide';\n\ntype MinimalCloudflareContext = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n waitUntil(promise: Promise<any>): void;\n};\n\nasync function flushWithTimeout(timeout: number): Promise<void> {\n try {\n debug.log('Flushing events...');\n await flush(timeout);\n debug.log('Done flushing events');\n } catch (e) {\n debug.log('Error while flushing events:\\n', e);\n }\n}\n\n/**\n * Flushes the event queue with a timeout in serverless environments to ensure that events are sent to Sentry before the\n * serverless function execution ends.\n *\n * The function is async, but in environments that support a `waitUntil` mechanism, it will run synchronously.\n *\n * This function is aware of the following serverless platforms:\n * - Cloudflare: If a Cloudflare context is provided, it will use `ctx.waitUntil()` to flush events (keeps the `this` context of `ctx`).\n * If a `cloudflareWaitUntil` function is provided, it will use that to flush events (looses the `this` context of `ctx`).\n * - Vercel: It detects the Vercel environment and uses Vercel's `waitUntil` function.\n * - Other Serverless (AWS Lambda, Google Cloud, etc.): It detects the environment via environment variables\n * and uses a regular `await flush()`.\n *\n * @internal This function is supposed for internal Sentry SDK usage only.\n * @hidden\n */\nexport async function flushIfServerless(\n params: // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | { timeout?: number; cloudflareWaitUntil?: (task: Promise<any>) => void }\n | { timeout?: number; cloudflareCtx?: MinimalCloudflareContext } = {},\n): Promise<void> {\n const { timeout = 2000 } = params;\n\n if ('cloudflareWaitUntil' in params && typeof params?.cloudflareWaitUntil === 'function') {\n params.cloudflareWaitUntil(flushWithTimeout(timeout));\n return;\n }\n\n if ('cloudflareCtx' in params && typeof params.cloudflareCtx?.waitUntil === 'function') {\n params.cloudflareCtx.waitUntil(flushWithTimeout(timeout));\n return;\n }\n\n // Note: vercelWaitUntil only does something in Vercel Edge runtime\n // In Node runtime, we use process.on('SIGTERM') instead\n // @ts-expect-error This is not typed\n if (GLOBAL_OBJ[Symbol.for('@vercel/request-context')]) {\n // Vercel has a waitUntil equivalent that works without execution context\n vercelWaitUntil(flushWithTimeout(timeout));\n return;\n }\n\n if (typeof process === 'undefined') {\n return;\n }\n\n const isServerless =\n !!process.env.FUNCTIONS_WORKER_RUNTIME || // Azure Functions\n !!process.env.LAMBDA_TASK_ROOT || // AWS Lambda\n !!process.env.K_SERVICE || // Google Cloud Run\n !!process.env.CF_PAGES || // Cloudflare Pages\n !!process.env.VERCEL ||\n !!process.env.NETLIFY;\n\n if (isServerless) {\n // Use regular flush for environments without a generic waitUntil mechanism\n await flushWithTimeout(timeout);\n }\n}\n"],"names":[],"mappings":";;;;;AAUA,eAAe,gBAAgB,CAAC,OAAO,EAAyB;AAChE,EAAE,IAAI;AACN,IAAI,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC;AACnC,IAAI,MAAM,KAAK,CAAC,OAAO,CAAC;AACxB,IAAI,KAAK,CAAC,GAAG,CAAC,sBAAsB,CAAC;AACrC,EAAE,CAAA,CAAE,OAAO,CAAC,EAAE;AACd,IAAI,KAAK,CAAC,GAAG,CAAC,gCAAgC,EAAE,CAAC,CAAC;AAClD,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,iBAAiB;AACvC,EAAE;;AAEE,GAAmE,EAAE;AACzE,EAAiB;AACjB,EAAE,MAAM,EAAE,OAAA,GAAU,IAAA,EAAK,GAAI,MAAM;;AAEnC,EAAE,IAAI,qBAAA,IAAyB,MAAA,IAAU,OAAO,MAAM,EAAE,mBAAA,KAAwB,UAAU,EAAE;AAC5F,IAAI,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACzD,IAAI;AACJ,EAAE;;AAEF,EAAE,IAAI,eAAA,IAAmB,UAAU,OAAO,MAAM,CAAC,aAAa,EAAE,SAAA,KAAc,UAAU,EAAE;AAC1F,IAAI,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC7D,IAAI;AACJ,EAAE;;AAEF;AACA;AACA;AACA,EAAE,IAAI,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,EAAE;AACzD;AACA,IAAI,eAAe,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC9C,IAAI;AACJ,EAAE;;AAEF,EAAE,IAAI,OAAO,OAAA,KAAY,WAAW,EAAE;AACtC,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,YAAA;AACR,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO;;AAEzB,EAAE,IAAI,YAAY,EAAE;AACpB;AACA,IAAI,MAAM,gBAAgB,CAAC,OAAO,CAAC;AACnC,EAAE;AACF;;;;"}
1
+ {"version":3,"file":"flushIfServerless.js","sources":["../../../src/utils/flushIfServerless.ts"],"sourcesContent":["import { flush } from '../exports';\nimport { debug } from './debug-logger';\nimport { vercelWaitUntil } from './vercelWaitUntil';\nimport { GLOBAL_OBJ } from './worldwide';\n\ntype MinimalCloudflareContext = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n waitUntil(promise: Promise<any>): void;\n};\n\nasync function flushWithTimeout(timeout: number): Promise<void> {\n try {\n debug.log('Flushing events...');\n await flush(timeout);\n debug.log('Done flushing events');\n } catch (e) {\n debug.log('Error while flushing events:\\n', e);\n }\n}\n\n/**\n * Flushes the event queue with a timeout in serverless environments to ensure that events are sent to Sentry before the\n * serverless function execution ends.\n *\n * The function is async, but in environments that support a `waitUntil` mechanism, it will run synchronously.\n *\n * This function is aware of the following serverless platforms:\n * - Cloudflare: If a Cloudflare context is provided, it will use `ctx.waitUntil()` to flush events (keeps the `this` context of `ctx`).\n * If a `cloudflareWaitUntil` function is provided, it will use that to flush events (looses the `this` context of `ctx`).\n * - Vercel: It detects the Vercel environment and uses Vercel's `waitUntil` function.\n * - Other Serverless (AWS Lambda, Google Cloud, etc.): It detects the environment via environment variables\n * and uses a regular `await flush()`.\n *\n * @internal This function is supposed for internal Sentry SDK usage only.\n * @hidden\n */\nexport async function flushIfServerless(\n params: // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | { timeout?: number; cloudflareWaitUntil?: (task: Promise<any>) => void }\n | { timeout?: number; cloudflareCtx?: MinimalCloudflareContext } = {},\n): Promise<void> {\n const { timeout = 2000 } = params;\n\n if ('cloudflareWaitUntil' in params && typeof params?.cloudflareWaitUntil === 'function') {\n params.cloudflareWaitUntil(flushWithTimeout(timeout));\n return;\n }\n\n if ('cloudflareCtx' in params && typeof params.cloudflareCtx?.waitUntil === 'function') {\n params.cloudflareCtx.waitUntil(flushWithTimeout(timeout));\n return;\n }\n\n // Note: vercelWaitUntil only does something in Vercel Edge runtime\n // In Node runtime, we use process.on('SIGTERM') instead\n // @ts-expect-error This is not typed\n if (GLOBAL_OBJ[Symbol.for('@vercel/request-context')]) {\n // Vercel has a waitUntil equivalent that works without execution context\n vercelWaitUntil(flushWithTimeout(timeout));\n return;\n }\n\n if (typeof process === 'undefined') {\n return;\n }\n\n const isServerless =\n !!process.env.FUNCTIONS_WORKER_RUNTIME || // Azure Functions\n !!process.env.LAMBDA_TASK_ROOT || // AWS Lambda\n !!process.env.K_SERVICE || // Google Cloud Run\n !!process.env.CF_PAGES || // Cloudflare Pages\n !!process.env.VERCEL ||\n !!process.env.NETLIFY;\n\n if (isServerless) {\n // Use regular flush for environments without a generic waitUntil mechanism\n await flushWithTimeout(timeout);\n }\n}\n"],"names":[],"mappings":";;;;;AAUA,eAAe,gBAAgB,CAAC,OAAO,EAAyB;AAChE,EAAE,IAAI;AACN,IAAI,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC;AACnC,IAAI,MAAM,KAAK,CAAC,OAAO,CAAC;AACxB,IAAI,KAAK,CAAC,GAAG,CAAC,sBAAsB,CAAC;AACrC,EAAE,CAAA,CAAE,OAAO,CAAC,EAAE;AACd,IAAI,KAAK,CAAC,GAAG,CAAC,gCAAgC,EAAE,CAAC,CAAC;AAClD,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,iBAAiB;AACvC,EAAE;;AAEE,GAAmE,EAAE;AACzE,EAAiB;AACjB,EAAE,MAAM,EAAE,OAAA,GAAU,IAAA,EAAK,GAAI,MAAM;;AAEnC,EAAE,IAAI,qBAAA,IAAyB,MAAA,IAAU,OAAO,MAAM,EAAE,mBAAA,KAAwB,UAAU,EAAE;AAC5F,IAAI,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACzD,IAAI;AACJ,EAAE;;AAEF,EAAE,IAAI,eAAA,IAAmB,UAAU,OAAO,MAAM,CAAC,aAAa,EAAE,SAAA,KAAc,UAAU,EAAE;AAC1F,IAAI,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC7D,IAAI;AACJ,EAAE;;AAEF;AACA;AACA;AACA,EAAE,IAAI,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,EAAE;AACzD;AACA,IAAI,eAAe,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC9C,IAAI;AACJ,EAAE;;AAEF,EAAE,IAAI,OAAO,OAAA,KAAY,WAAW,EAAE;AACtC,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,YAAA;AACR,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO;;AAEzB,EAAE,IAAI,YAAY,EAAE;AACpB;AACA,IAAI,MAAM,gBAAgB,CAAC,OAAO,CAAC;AACnC,EAAE;AACF;;;;"}
@@ -0,0 +1,19 @@
1
+ import { getClient } from '../currentScopes.js';
2
+
3
+ // Treeshakable guard to remove all code related to tracing
4
+
5
+ /**
6
+ * Determines if the SDK is configured for span streaming.
7
+ * Span streaming is enabled when `traceLifecycle` is set to `stream`.
8
+ * (In Browser, users must add `spanStreamingIntegration` as well but it
9
+ * already checks itself and configures `traceLifecycle` appropriately)
10
+ */
11
+ function hasSpanStreamingEnabled(maybeClient = getClient()) {
12
+ if (typeof __SENTRY_TRACING__ === 'boolean' && !__SENTRY_TRACING__) {
13
+ return false;
14
+ }
15
+ return (maybeClient ?? getClient())?.getOptions()?.traceLifecycle === 'stream';
16
+ }
17
+
18
+ export { hasSpanStreamingEnabled };
19
+ //# sourceMappingURL=hasSpanStreamingEnabled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasSpanStreamingEnabled.js","sources":["../../../src/utils/hasSpanStreamingEnabled.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { getClient } from '../currentScopes';\n\n// Treeshakable guard to remove all code related to tracing\ndeclare const __SENTRY_TRACING__: boolean | undefined;\n\n/**\n * Determines if the SDK is configured for span streaming.\n * Span streaming is enabled when `traceLifecycle` is set to `stream`.\n * (In Browser, users must add `spanStreamingIntegration` as well but it\n * already checks itself and configures `traceLifecycle` appropriately)\n */\nexport function hasSpanStreamingEnabled(maybeClient: Client | undefined = getClient()): boolean {\n if (typeof __SENTRY_TRACING__ === 'boolean' && !__SENTRY_TRACING__) {\n return false;\n }\n return (maybeClient ?? getClient())?.getOptions()?.traceLifecycle === 'stream';\n}\n"],"names":[],"mappings":";;AAGA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,WAAW,GAAuB,SAAS,EAAE,EAAW;AAChG,EAAE,IAAI,OAAO,kBAAA,KAAuB,SAAA,IAAa,CAAC,kBAAkB,EAAE;AACtE,IAAI,OAAO,KAAK;AAChB,EAAE;AACF,EAAE,OAAO,CAAC,WAAA,IAAe,SAAS,EAAE,GAAG,UAAU,EAAE,EAAE,cAAA,KAAmB,QAAQ;AAChF;;;;"}
@@ -6,6 +6,7 @@ import { uuid4, addExceptionMechanism } from './misc.js';
6
6
  import { normalize } from './normalize.js';
7
7
  import { getCombinedScopeData, applyScopeDataToEvent } from './scopeData.js';
8
8
  import { truncate } from './string.js';
9
+ import { resolvedSyncPromise } from './syncpromise.js';
9
10
  import { dateTimestampInSeconds } from './time.js';
10
11
 
11
12
  /**
@@ -85,7 +86,11 @@ function prepareEvent(
85
86
  ...data.eventProcessors,
86
87
  ];
87
88
 
88
- const result = notifyEventProcessors(eventProcessors, prepared, hint);
89
+ // Skip event processors for internal exceptions to prevent recursion
90
+ const isInternalException = hint.data && (hint.data ).__sentry__ === true;
91
+ const result = isInternalException
92
+ ? resolvedSyncPromise(prepared)
93
+ : notifyEventProcessors(eventProcessors, prepared, hint);
89
94
 
90
95
  return result.then(evt => {
91
96
  if (evt) {
@@ -1 +1 @@
1
- {"version":3,"file":"prepareEvent.js","sources":["../../../src/utils/prepareEvent.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { DEFAULT_ENVIRONMENT } from '../constants';\nimport { notifyEventProcessors } from '../eventProcessors';\nimport type { CaptureContext, ScopeContext } from '../scope';\nimport { Scope } from '../scope';\nimport type { Event, EventHint } from '../types-hoist/event';\nimport type { ClientOptions } from '../types-hoist/options';\nimport type { StackParser } from '../types-hoist/stacktrace';\nimport { getFilenameToDebugIdMap } from './debug-ids';\nimport { addExceptionMechanism, uuid4 } from './misc';\nimport { normalize } from './normalize';\nimport { applyScopeDataToEvent, getCombinedScopeData } from './scopeData';\nimport { truncate } from './string';\nimport { dateTimestampInSeconds } from './time';\n\n/**\n * This type makes sure that we get either a CaptureContext, OR an EventHint.\n * It does not allow mixing them, which could lead to unexpected outcomes, e.g. this is disallowed:\n * { user: { id: '123' }, mechanism: { handled: false } }\n */\nexport type ExclusiveEventHintOrCaptureContext =\n | (CaptureContext & Partial<{ [key in keyof EventHint]: never }>)\n | (EventHint & Partial<{ [key in keyof ScopeContext]: never }>);\n\n/**\n * Adds common information to events.\n *\n * The information includes release and environment from `options`,\n * breadcrumbs and context (extra, tags and user) from the scope.\n *\n * Information that is already present in the event is never overwritten. For\n * nested objects, such as the context, keys are merged.\n *\n * @param event The original event.\n * @param hint May contain additional information about the original exception.\n * @param scope A scope containing event metadata.\n * @returns A new event with more information.\n * @hidden\n */\nexport function prepareEvent(\n options: ClientOptions,\n event: Event,\n hint: EventHint,\n scope?: Scope,\n client?: Client,\n isolationScope?: Scope,\n): PromiseLike<Event | null> {\n const { normalizeDepth = 3, normalizeMaxBreadth = 1_000 } = options;\n const prepared: Event = {\n ...event,\n event_id: event.event_id || hint.event_id || uuid4(),\n timestamp: event.timestamp || dateTimestampInSeconds(),\n };\n const integrations = hint.integrations || options.integrations.map(i => i.name);\n\n applyClientOptions(prepared, options);\n applyIntegrationsMetadata(prepared, integrations);\n\n if (client) {\n client.emit('applyFrameMetadata', event);\n }\n\n // Only put debug IDs onto frames for error events.\n if (event.type === undefined) {\n applyDebugIds(prepared, options.stackParser);\n }\n\n // If we have scope given to us, use it as the base for further modifications.\n // This allows us to prevent unnecessary copying of data if `captureContext` is not provided.\n const finalScope = getFinalScope(scope, hint.captureContext);\n\n if (hint.mechanism) {\n addExceptionMechanism(prepared, hint.mechanism);\n }\n\n const clientEventProcessors = client ? client.getEventProcessors() : [];\n\n // This should be the last thing called, since we want that\n // {@link Scope.addEventProcessor} gets the finished prepared event.\n // Merge scope data together\n const data = getCombinedScopeData(isolationScope, finalScope);\n\n const attachments = [...(hint.attachments || []), ...data.attachments];\n if (attachments.length) {\n hint.attachments = attachments;\n }\n\n applyScopeDataToEvent(prepared, data);\n\n const eventProcessors = [\n ...clientEventProcessors,\n // Run scope event processors _after_ all other processors\n ...data.eventProcessors,\n ];\n\n const result = notifyEventProcessors(eventProcessors, prepared, hint);\n\n return result.then(evt => {\n if (evt) {\n // We apply the debug_meta field only after all event processors have ran, so that if any event processors modified\n // file names (e.g.the RewriteFrames integration) the filename -> debug ID relationship isn't destroyed.\n // This should not cause any PII issues, since we're only moving data that is already on the event and not adding\n // any new data\n applyDebugMeta(evt);\n }\n\n if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {\n return normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth);\n }\n return evt;\n });\n}\n\n/**\n * Enhances event using the client configuration.\n * It takes care of all \"static\" values like environment, release and `dist`,\n * as well as truncating overly long values.\n *\n * Only exported for tests.\n *\n * @param event event instance to be enhanced\n */\nexport function applyClientOptions(event: Event, options: ClientOptions): void {\n const { environment, release, dist, maxValueLength } = options;\n\n // empty strings do not make sense for environment, release, and dist\n // so we handle them the same as if they were not provided\n event.environment = event.environment || environment || DEFAULT_ENVIRONMENT;\n\n if (!event.release && release) {\n event.release = release;\n }\n\n if (!event.dist && dist) {\n event.dist = dist;\n }\n\n const request = event.request;\n if (request?.url && maxValueLength) {\n request.url = truncate(request.url, maxValueLength);\n }\n\n if (maxValueLength) {\n event.exception?.values?.forEach(exception => {\n if (exception.value) {\n // Truncates error messages\n exception.value = truncate(exception.value, maxValueLength);\n }\n });\n }\n}\n\n/**\n * Puts debug IDs into the stack frames of an error event.\n */\nexport function applyDebugIds(event: Event, stackParser: StackParser): void {\n // Build a map of filename -> debug_id\n const filenameDebugIdMap = getFilenameToDebugIdMap(stackParser);\n\n event.exception?.values?.forEach(exception => {\n exception.stacktrace?.frames?.forEach(frame => {\n if (frame.filename) {\n frame.debug_id = filenameDebugIdMap[frame.filename];\n }\n });\n });\n}\n\n/**\n * Moves debug IDs from the stack frames of an error event into the debug_meta field.\n */\nexport function applyDebugMeta(event: Event): void {\n // Extract debug IDs and filenames from the stack frames on the event.\n const filenameDebugIdMap: Record<string, string> = {};\n event.exception?.values?.forEach(exception => {\n exception.stacktrace?.frames?.forEach(frame => {\n if (frame.debug_id) {\n if (frame.abs_path) {\n filenameDebugIdMap[frame.abs_path] = frame.debug_id;\n } else if (frame.filename) {\n filenameDebugIdMap[frame.filename] = frame.debug_id;\n }\n delete frame.debug_id;\n }\n });\n });\n\n if (Object.keys(filenameDebugIdMap).length === 0) {\n return;\n }\n\n // Fill debug_meta information\n event.debug_meta = event.debug_meta || {};\n event.debug_meta.images = event.debug_meta.images || [];\n const images = event.debug_meta.images;\n Object.entries(filenameDebugIdMap).forEach(([filename, debug_id]) => {\n images.push({\n type: 'sourcemap',\n code_file: filename,\n debug_id,\n });\n });\n}\n\n/**\n * This function adds all used integrations to the SDK info in the event.\n * @param event The event that will be filled with all integrations.\n */\nfunction applyIntegrationsMetadata(event: Event, integrationNames: string[]): void {\n if (integrationNames.length > 0) {\n event.sdk = event.sdk || {};\n event.sdk.integrations = [...(event.sdk.integrations || []), ...integrationNames];\n }\n}\n\n/**\n * Applies `normalize` function on necessary `Event` attributes to make them safe for serialization.\n * Normalized keys:\n * - `breadcrumbs.data`\n * - `user`\n * - `contexts`\n * - `extra`\n * @param event Event\n * @returns Normalized event\n */\nfunction normalizeEvent(event: Event | null, depth: number, maxBreadth: number): Event | null {\n if (!event) {\n return null;\n }\n\n const normalized: Event = {\n ...event,\n ...(event.breadcrumbs && {\n breadcrumbs: event.breadcrumbs.map(b => ({\n ...b,\n ...(b.data && {\n data: normalize(b.data, depth, maxBreadth),\n }),\n })),\n }),\n ...(event.user && {\n user: normalize(event.user, depth, maxBreadth),\n }),\n ...(event.contexts && {\n contexts: normalize(event.contexts, depth, maxBreadth),\n }),\n ...(event.extra && {\n extra: normalize(event.extra, depth, maxBreadth),\n }),\n };\n\n // event.contexts.trace stores information about a Transaction. Similarly,\n // event.spans[] stores information about child Spans. Given that a\n // Transaction is conceptually a Span, normalization should apply to both\n // Transactions and Spans consistently.\n // For now the decision is to skip normalization of Transactions and Spans,\n // so this block overwrites the normalized event to add back the original\n // Transaction information prior to normalization.\n if (event.contexts?.trace && normalized.contexts) {\n normalized.contexts.trace = event.contexts.trace;\n\n // event.contexts.trace.data may contain circular/dangerous data so we need to normalize it\n if (event.contexts.trace.data) {\n normalized.contexts.trace.data = normalize(event.contexts.trace.data, depth, maxBreadth);\n }\n }\n\n // event.spans[].data may contain circular/dangerous data so we need to normalize it\n if (event.spans) {\n normalized.spans = event.spans.map(span => {\n return {\n ...span,\n ...(span.data && {\n data: normalize(span.data, depth, maxBreadth),\n }),\n };\n });\n }\n\n // event.contexts.flags (FeatureFlagContext) stores context for our feature\n // flag integrations. It has a greater nesting depth than our other typed\n // Contexts, so we re-normalize with a fixed depth of 3 here. We do not want\n // to skip this in case of conflicting, user-provided context.\n if (event.contexts?.flags && normalized.contexts) {\n normalized.contexts.flags = normalize(event.contexts.flags, 3, maxBreadth);\n }\n\n return normalized;\n}\n\nfunction getFinalScope(scope: Scope | undefined, captureContext: CaptureContext | undefined): Scope | undefined {\n if (!captureContext) {\n return scope;\n }\n\n const finalScope = scope ? scope.clone() : new Scope();\n finalScope.update(captureContext);\n return finalScope;\n}\n\n/**\n * Parse either an `EventHint` directly, or convert a `CaptureContext` to an `EventHint`.\n * This is used to allow to update method signatures that used to accept a `CaptureContext` but should now accept an `EventHint`.\n */\nexport function parseEventHintOrCaptureContext(\n hint: ExclusiveEventHintOrCaptureContext | undefined,\n): EventHint | undefined {\n if (!hint) {\n return undefined;\n }\n\n // If you pass a Scope or `() => Scope` as CaptureContext, we just return this as captureContext\n if (hintIsScopeOrFunction(hint)) {\n return { captureContext: hint };\n }\n\n if (hintIsScopeContext(hint)) {\n return {\n captureContext: hint,\n };\n }\n\n return hint;\n}\n\nfunction hintIsScopeOrFunction(hint: CaptureContext | EventHint): hint is Scope | ((scope: Scope) => Scope) {\n return hint instanceof Scope || typeof hint === 'function';\n}\n\ntype ScopeContextProperty = keyof ScopeContext;\nconst captureContextKeys: readonly ScopeContextProperty[] = [\n 'user',\n 'level',\n 'extra',\n 'contexts',\n 'tags',\n 'fingerprint',\n 'propagationContext',\n] as const;\n\nfunction hintIsScopeContext(hint: Partial<ScopeContext> | EventHint): hint is Partial<ScopeContext> {\n return Object.keys(hint).some(key => captureContextKeys.includes(key as ScopeContextProperty));\n}\n"],"names":[],"mappings":";;;;;;;;;;AAeA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,YAAY;AAC5B,EAAE,OAAO;AACT,EAAE,KAAK;AACP,EAAE,IAAI;AACN,EAAE,KAAK;AACP,EAAE,MAAM;AACR,EAAE,cAAc;AAChB,EAA6B;AAC7B,EAAE,MAAM,EAAE,cAAA,GAAiB,CAAC,EAAE,mBAAA,GAAsB,IAAA,EAAM,GAAI,OAAO;AACrE,EAAE,MAAM,QAAQ,GAAU;AAC1B,IAAI,GAAG,KAAK;AACZ,IAAI,QAAQ,EAAE,KAAK,CA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AC,EAAE;AACnC,IAAI,OAAO,EAAE,cAAc,EAAE,MAAM;AACnC,EAAE;;AAEF,EAAE,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE;AAChC,IAAI,OAAO;AACX,MAAM,cAAc,EAAE,IAAI;AAC1B,KAAK;AACL,EAAE;;AAEF,EAAE,OAAO,IAAI;AACb;;AAEA,SAAS,qBAAqB,CAAC,IAAI,EAAyE;AAC5G,EAAE,OAAO,gBAAgB,KAAA,IAAS,OAAO,IAAA,KAAS,UAAU;AAC5D;;AAGA,MAAM,kBAAkB,GAAoC;AAC5D,EAAE,MAAM;AACR,EAAE,OAAO;AACT,EAAE,OAAO;AACT,EAAE,UAAU;AACZ,EAAE,MAAM;AACR,EAAE,aAAa;AACf,EAAE,oBAAoB;AACtB,CAAA;;AAEA,SAAS,kBAAkB,CAAC,IAAI,EAAoE;AACpG,EAAE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAA,IAAO,kBAAkB,CAAC,QAAQ,CAAC,GAAA,EAA4B,CAAC;AAChG;;;;"}
1
+ {"version":3,"file":"prepareEvent.js","sources":["../../../src/utils/prepareEvent.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { DEFAULT_ENVIRONMENT } from '../constants';\nimport { notifyEventProcessors } from '../eventProcessors';\nimport type { CaptureContext, ScopeContext } from '../scope';\nimport { Scope } from '../scope';\nimport type { Event, EventHint } from '../types-hoist/event';\nimport type { ClientOptions } from '../types-hoist/options';\nimport type { StackParser } from '../types-hoist/stacktrace';\nimport { getFilenameToDebugIdMap } from './debug-ids';\nimport { addExceptionMechanism, uuid4 } from './misc';\nimport { normalize } from './normalize';\nimport { applyScopeDataToEvent, getCombinedScopeData } from './scopeData';\nimport { truncate } from './string';\nimport { resolvedSyncPromise } from './syncpromise';\nimport { dateTimestampInSeconds } from './time';\n\n/**\n * This type makes sure that we get either a CaptureContext, OR an EventHint.\n * It does not allow mixing them, which could lead to unexpected outcomes, e.g. this is disallowed:\n * { user: { id: '123' }, mechanism: { handled: false } }\n */\nexport type ExclusiveEventHintOrCaptureContext =\n | (CaptureContext & Partial<{ [key in keyof EventHint]: never }>)\n | (EventHint & Partial<{ [key in keyof ScopeContext]: never }>);\n\n/**\n * Adds common information to events.\n *\n * The information includes release and environment from `options`,\n * breadcrumbs and context (extra, tags and user) from the scope.\n *\n * Information that is already present in the event is never overwritten. For\n * nested objects, such as the context, keys are merged.\n *\n * @param event The original event.\n * @param hint May contain additional information about the original exception.\n * @param scope A scope containing event metadata.\n * @returns A new event with more information.\n * @hidden\n */\nexport function prepareEvent(\n options: ClientOptions,\n event: Event,\n hint: EventHint,\n scope?: Scope,\n client?: Client,\n isolationScope?: Scope,\n): PromiseLike<Event | null> {\n const { normalizeDepth = 3, normalizeMaxBreadth = 1_000 } = options;\n const prepared: Event = {\n ...event,\n event_id: event.event_id || hint.event_id || uuid4(),\n timestamp: event.timestamp || dateTimestampInSeconds(),\n };\n const integrations = hint.integrations || options.integrations.map(i => i.name);\n\n applyClientOptions(prepared, options);\n applyIntegrationsMetadata(prepared, integrations);\n\n if (client) {\n client.emit('applyFrameMetadata', event);\n }\n\n // Only put debug IDs onto frames for error events.\n if (event.type === undefined) {\n applyDebugIds(prepared, options.stackParser);\n }\n\n // If we have scope given to us, use it as the base for further modifications.\n // This allows us to prevent unnecessary copying of data if `captureContext` is not provided.\n const finalScope = getFinalScope(scope, hint.captureContext);\n\n if (hint.mechanism) {\n addExceptionMechanism(prepared, hint.mechanism);\n }\n\n const clientEventProcessors = client ? client.getEventProcessors() : [];\n\n // This should be the last thing called, since we want that\n // {@link Scope.addEventProcessor} gets the finished prepared event.\n // Merge scope data together\n const data = getCombinedScopeData(isolationScope, finalScope);\n\n const attachments = [...(hint.attachments || []), ...data.attachments];\n if (attachments.length) {\n hint.attachments = attachments;\n }\n\n applyScopeDataToEvent(prepared, data);\n\n const eventProcessors = [\n ...clientEventProcessors,\n // Run scope event processors _after_ all other processors\n ...data.eventProcessors,\n ];\n\n // Skip event processors for internal exceptions to prevent recursion\n const isInternalException = hint.data && (hint.data as { __sentry__: boolean }).__sentry__ === true;\n const result = isInternalException\n ? resolvedSyncPromise(prepared)\n : notifyEventProcessors(eventProcessors, prepared, hint);\n\n return result.then(evt => {\n if (evt) {\n // We apply the debug_meta field only after all event processors have ran, so that if any event processors modified\n // file names (e.g.the RewriteFrames integration) the filename -> debug ID relationship isn't destroyed.\n // This should not cause any PII issues, since we're only moving data that is already on the event and not adding\n // any new data\n applyDebugMeta(evt);\n }\n\n if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {\n return normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth);\n }\n return evt;\n });\n}\n\n/**\n * Enhances event using the client configuration.\n * It takes care of all \"static\" values like environment, release and `dist`,\n * as well as truncating overly long values.\n *\n * Only exported for tests.\n *\n * @param event event instance to be enhanced\n */\nexport function applyClientOptions(event: Event, options: ClientOptions): void {\n const { environment, release, dist, maxValueLength } = options;\n\n // empty strings do not make sense for environment, release, and dist\n // so we handle them the same as if they were not provided\n event.environment = event.environment || environment || DEFAULT_ENVIRONMENT;\n\n if (!event.release && release) {\n event.release = release;\n }\n\n if (!event.dist && dist) {\n event.dist = dist;\n }\n\n const request = event.request;\n if (request?.url && maxValueLength) {\n request.url = truncate(request.url, maxValueLength);\n }\n\n if (maxValueLength) {\n event.exception?.values?.forEach(exception => {\n if (exception.value) {\n // Truncates error messages\n exception.value = truncate(exception.value, maxValueLength);\n }\n });\n }\n}\n\n/**\n * Puts debug IDs into the stack frames of an error event.\n */\nexport function applyDebugIds(event: Event, stackParser: StackParser): void {\n // Build a map of filename -> debug_id\n const filenameDebugIdMap = getFilenameToDebugIdMap(stackParser);\n\n event.exception?.values?.forEach(exception => {\n exception.stacktrace?.frames?.forEach(frame => {\n if (frame.filename) {\n frame.debug_id = filenameDebugIdMap[frame.filename];\n }\n });\n });\n}\n\n/**\n * Moves debug IDs from the stack frames of an error event into the debug_meta field.\n */\nexport function applyDebugMeta(event: Event): void {\n // Extract debug IDs and filenames from the stack frames on the event.\n const filenameDebugIdMap: Record<string, string> = {};\n event.exception?.values?.forEach(exception => {\n exception.stacktrace?.frames?.forEach(frame => {\n if (frame.debug_id) {\n if (frame.abs_path) {\n filenameDebugIdMap[frame.abs_path] = frame.debug_id;\n } else if (frame.filename) {\n filenameDebugIdMap[frame.filename] = frame.debug_id;\n }\n delete frame.debug_id;\n }\n });\n });\n\n if (Object.keys(filenameDebugIdMap).length === 0) {\n return;\n }\n\n // Fill debug_meta information\n event.debug_meta = event.debug_meta || {};\n event.debug_meta.images = event.debug_meta.images || [];\n const images = event.debug_meta.images;\n Object.entries(filenameDebugIdMap).forEach(([filename, debug_id]) => {\n images.push({\n type: 'sourcemap',\n code_file: filename,\n debug_id,\n });\n });\n}\n\n/**\n * This function adds all used integrations to the SDK info in the event.\n * @param event The event that will be filled with all integrations.\n */\nfunction applyIntegrationsMetadata(event: Event, integrationNames: string[]): void {\n if (integrationNames.length > 0) {\n event.sdk = event.sdk || {};\n event.sdk.integrations = [...(event.sdk.integrations || []), ...integrationNames];\n }\n}\n\n/**\n * Applies `normalize` function on necessary `Event` attributes to make them safe for serialization.\n * Normalized keys:\n * - `breadcrumbs.data`\n * - `user`\n * - `contexts`\n * - `extra`\n * @param event Event\n * @returns Normalized event\n */\nfunction normalizeEvent(event: Event | null, depth: number, maxBreadth: number): Event | null {\n if (!event) {\n return null;\n }\n\n const normalized: Event = {\n ...event,\n ...(event.breadcrumbs && {\n breadcrumbs: event.breadcrumbs.map(b => ({\n ...b,\n ...(b.data && {\n data: normalize(b.data, depth, maxBreadth),\n }),\n })),\n }),\n ...(event.user && {\n user: normalize(event.user, depth, maxBreadth),\n }),\n ...(event.contexts && {\n contexts: normalize(event.contexts, depth, maxBreadth),\n }),\n ...(event.extra && {\n extra: normalize(event.extra, depth, maxBreadth),\n }),\n };\n\n // event.contexts.trace stores information about a Transaction. Similarly,\n // event.spans[] stores information about child Spans. Given that a\n // Transaction is conceptually a Span, normalization should apply to both\n // Transactions and Spans consistently.\n // For now the decision is to skip normalization of Transactions and Spans,\n // so this block overwrites the normalized event to add back the original\n // Transaction information prior to normalization.\n if (event.contexts?.trace && normalized.contexts) {\n normalized.contexts.trace = event.contexts.trace;\n\n // event.contexts.trace.data may contain circular/dangerous data so we need to normalize it\n if (event.contexts.trace.data) {\n normalized.contexts.trace.data = normalize(event.contexts.trace.data, depth, maxBreadth);\n }\n }\n\n // event.spans[].data may contain circular/dangerous data so we need to normalize it\n if (event.spans) {\n normalized.spans = event.spans.map(span => {\n return {\n ...span,\n ...(span.data && {\n data: normalize(span.data, depth, maxBreadth),\n }),\n };\n });\n }\n\n // event.contexts.flags (FeatureFlagContext) stores context for our feature\n // flag integrations. It has a greater nesting depth than our other typed\n // Contexts, so we re-normalize with a fixed depth of 3 here. We do not want\n // to skip this in case of conflicting, user-provided context.\n if (event.contexts?.flags && normalized.contexts) {\n normalized.contexts.flags = normalize(event.contexts.flags, 3, maxBreadth);\n }\n\n return normalized;\n}\n\nfunction getFinalScope(scope: Scope | undefined, captureContext: CaptureContext | undefined): Scope | undefined {\n if (!captureContext) {\n return scope;\n }\n\n const finalScope = scope ? scope.clone() : new Scope();\n finalScope.update(captureContext);\n return finalScope;\n}\n\n/**\n * Parse either an `EventHint` directly, or convert a `CaptureContext` to an `EventHint`.\n * This is used to allow to update method signatures that used to accept a `CaptureContext` but should now accept an `EventHint`.\n */\nexport function parseEventHintOrCaptureContext(\n hint: ExclusiveEventHintOrCaptureContext | undefined,\n): EventHint | undefined {\n if (!hint) {\n return undefined;\n }\n\n // If you pass a Scope or `() => Scope` as CaptureContext, we just return this as captureContext\n if (hintIsScopeOrFunction(hint)) {\n return { captureContext: hint };\n }\n\n if (hintIsScopeContext(hint)) {\n return {\n captureContext: hint,\n };\n }\n\n return hint;\n}\n\nfunction hintIsScopeOrFunction(hint: CaptureContext | EventHint): hint is Scope | ((scope: Scope) => Scope) {\n return hint instanceof Scope || typeof hint === 'function';\n}\n\ntype ScopeContextProperty = keyof ScopeContext;\nconst captureContextKeys: readonly ScopeContextProperty[] = [\n 'user',\n 'level',\n 'extra',\n 'contexts',\n 'tags',\n 'fingerprint',\n 'propagationContext',\n] as const;\n\nfunction hintIsScopeContext(hint: Partial<ScopeContext> | EventHint): hint is Partial<ScopeContext> {\n return Object.keys(hint).some(key => captureContextKeys.includes(key as ScopeContextProperty));\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAgBA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,YAAY;AAC5B,EAAE,OAAO;AACT,EAAE,KAAK;AACP,EAAE,IAAI;AACN,EAAE,KAAK;AACP,EAAE,MAAM;AACR,EAAE,cAAc;AAChB,EAA6B;AAC7B,EAAE,MAAM,EAAE,cAAA,GAAiB,CAAC,EAAE,mBAAA,GAAsB,IAAA,EAAM,GAAI,OAAO;AACrE,EAAE,MAAM,QAAQ,GAAU;AAC1B,IAAI,GAAG,KAAK;AACZ,IAAI,QAAQ,EAAE,KAAK,CAAC,QAAA,IAAY,IAAI,CAAC,QAAA,IAAY,KAAK,EAAE;AACxD,IAAI,SAAS,EAAE,KAAK,CAAC,aAAa,sBAAsB,EAAE;AAC1D,GAAG;AACH,EAAE,MAAM,YAAA,GAAe,IAAI,CAAC,YAAA,IAAgB,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA,IAAK,CAAC,CAAC,IAAI,CAAC;;AAEjF,EAAE,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC;AACvC,EAAE,yBAAyB,CAAC,QAAQ,EAAE,YAAY,CAAC;;AAEnD,EAAE,IAAI,MAAM,EAAE;AACd,IAAI,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC;AAC5C,EAAE;;AAEF;AACA,EAAE,IAAI,KAAK,CAAC,IAAA,KAAS,SAAS,EAAE;AAChC,IAA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R,EAAE,OAAO;AACT,EAAE,OAAO;AACT,EAAE,UAAU;AACZ,EAAE,MAAM;AACR,EAAE,aAAa;AACf,EAAE,oBAAoB;AACtB,CAAA;;AAEA,SAAS,kBAAkB,CAAC,IAAI,EAAoE;AACpG,EAAE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAA,IAAO,kBAAkB,CAAC,QAAQ,CAAC,GAAA,EAA4B,CAAC;AAChG;;;;"}
@@ -1,4 +1,5 @@
1
1
  import { resolvedSyncPromise, rejectedSyncPromise } from './syncpromise.js';
2
+ import { safeUnref } from './timer.js';
2
3
 
3
4
  const SENTRY_BUFFER_FULL_ERROR = Symbol.for('SentryBufferFullError');
4
5
 
@@ -69,10 +70,11 @@ function makePromiseBuffer(limit = 100) {
69
70
  return drainPromise;
70
71
  }
71
72
 
72
- const promises = [drainPromise, new Promise(resolve => setTimeout(() => resolve(false), timeout))];
73
+ const promises = [
74
+ drainPromise,
75
+ new Promise(resolve => safeUnref(setTimeout(() => resolve(false), timeout))),
76
+ ];
73
77
 
74
- // Promise.race will resolve to the first promise that resolves or rejects
75
- // So if the drainPromise resolves, the timeout promise will be ignored
76
78
  return Promise.race(promises);
77
79
  }
78
80
 
@@ -1 +1 @@
1
- {"version":3,"file":"promisebuffer.js","sources":["../../../src/utils/promisebuffer.ts"],"sourcesContent":["import { rejectedSyncPromise, resolvedSyncPromise } from './syncpromise';\n\nexport interface PromiseBuffer<T> {\n // exposes the internal array so tests can assert on the state of it.\n // XXX: this really should not be public api.\n $: PromiseLike<T>[];\n add(taskProducer: () => PromiseLike<T>): PromiseLike<T>;\n drain(timeout?: number): PromiseLike<boolean>;\n}\n\nexport const SENTRY_BUFFER_FULL_ERROR = Symbol.for('SentryBufferFullError');\n\n/**\n * Creates an new PromiseBuffer object with the specified limit\n * @param limit max number of promises that can be stored in the buffer\n */\nexport function makePromiseBuffer<T>(limit: number = 100): PromiseBuffer<T> {\n const buffer: Set<PromiseLike<T>> = new Set();\n\n function isReady(): boolean {\n return buffer.size < limit;\n }\n\n /**\n * Remove a promise from the queue.\n *\n * @param task Can be any PromiseLike<T>\n * @returns Removed promise.\n */\n function remove(task: PromiseLike<T>): void {\n buffer.delete(task);\n }\n\n /**\n * Add a promise (representing an in-flight action) to the queue, and set it to remove itself on fulfillment.\n *\n * @param taskProducer A function producing any PromiseLike<T>; In previous versions this used to be `task:\n * PromiseLike<T>`, but under that model, Promises were instantly created on the call-site and their executor\n * functions therefore ran immediately. Thus, even if the buffer was full, the action still happened. By\n * requiring the promise to be wrapped in a function, we can defer promise creation until after the buffer\n * limit check.\n * @returns The original promise.\n */\n function add(taskProducer: () => PromiseLike<T>): PromiseLike<T> {\n if (!isReady()) {\n return rejectedSyncPromise(SENTRY_BUFFER_FULL_ERROR);\n }\n\n // start the task and add its promise to the queue\n const task = taskProducer();\n buffer.add(task);\n void task.then(\n () => remove(task),\n () => remove(task),\n );\n return task;\n }\n\n /**\n * Wait for all promises in the queue to resolve or for timeout to expire, whichever comes first.\n *\n * @param timeout The time, in ms, after which to resolve to `false` if the queue is still non-empty. Passing `0` (or\n * not passing anything) will make the promise wait as long as it takes for the queue to drain before resolving to\n * `true`.\n * @returns A promise which will resolve to `true` if the queue is already empty or drains before the timeout, and\n * `false` otherwise\n */\n function drain(timeout?: number): PromiseLike<boolean> {\n if (!buffer.size) {\n return resolvedSyncPromise(true);\n }\n\n // We want to resolve even if one of the promises rejects\n const drainPromise = Promise.allSettled(Array.from(buffer)).then(() => true);\n\n if (!timeout) {\n return drainPromise;\n }\n\n const promises = [drainPromise, new Promise<boolean>(resolve => setTimeout(() => resolve(false), timeout))];\n\n // Promise.race will resolve to the first promise that resolves or rejects\n // So if the drainPromise resolves, the timeout promise will be ignored\n return Promise.race(promises);\n }\n\n return {\n get $(): PromiseLike<T>[] {\n return Array.from(buffer);\n },\n add,\n drain,\n };\n}\n"],"names":[],"mappings":";;AAUO,MAAM,2BAA2B,MAAM,CAAC,GAAG,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EJ,IAAI,MAAM,QAAA,GAAW,CAAC,YAAY,EAAE,IAAI,OAAO,CAAU,OAAA,IAAW,UAAU,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;;AAE/G;AACA;AACA,IAAI,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;AACjC,EAAE;;AAEF,EAAE,OAAO;AACT,IAAI,IAAI,CAAC,GAAqB;AAC9B,MAAM,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;AAC/B,IAAI,CAAC;AACL,IAAI,GAAG;AACP,IAAI,KAAK;AACT,GAAG;AACH;;;;"}
1
+ {"version":3,"file":"promisebuffer.js","sources":["../../../src/utils/promisebuffer.ts"],"sourcesContent":["import { rejectedSyncPromise, resolvedSyncPromise } from './syncpromise';\nimport { safeUnref } from './timer';\n\nexport interface PromiseBuffer<T> {\n // exposes the internal array so tests can assert on the state of it.\n // XXX: this really should not be public api.\n $: PromiseLike<T>[];\n add(taskProducer: () => PromiseLike<T>): PromiseLike<T>;\n drain(timeout?: number): PromiseLike<boolean>;\n}\n\nexport const SENTRY_BUFFER_FULL_ERROR = Symbol.for('SentryBufferFullError');\n\n/**\n * Creates an new PromiseBuffer object with the specified limit\n * @param limit max number of promises that can be stored in the buffer\n */\nexport function makePromiseBuffer<T>(limit: number = 100): PromiseBuffer<T> {\n const buffer: Set<PromiseLike<T>> = new Set();\n\n function isReady(): boolean {\n return buffer.size < limit;\n }\n\n /**\n * Remove a promise from the queue.\n *\n * @param task Can be any PromiseLike<T>\n * @returns Removed promise.\n */\n function remove(task: PromiseLike<T>): void {\n buffer.delete(task);\n }\n\n /**\n * Add a promise (representing an in-flight action) to the queue, and set it to remove itself on fulfillment.\n *\n * @param taskProducer A function producing any PromiseLike<T>; In previous versions this used to be `task:\n * PromiseLike<T>`, but under that model, Promises were instantly created on the call-site and their executor\n * functions therefore ran immediately. Thus, even if the buffer was full, the action still happened. By\n * requiring the promise to be wrapped in a function, we can defer promise creation until after the buffer\n * limit check.\n * @returns The original promise.\n */\n function add(taskProducer: () => PromiseLike<T>): PromiseLike<T> {\n if (!isReady()) {\n return rejectedSyncPromise(SENTRY_BUFFER_FULL_ERROR);\n }\n\n // start the task and add its promise to the queue\n const task = taskProducer();\n buffer.add(task);\n void task.then(\n () => remove(task),\n () => remove(task),\n );\n return task;\n }\n\n /**\n * Wait for all promises in the queue to resolve or for timeout to expire, whichever comes first.\n *\n * @param timeout The time, in ms, after which to resolve to `false` if the queue is still non-empty. Passing `0` (or\n * not passing anything) will make the promise wait as long as it takes for the queue to drain before resolving to\n * `true`.\n * @returns A promise which will resolve to `true` if the queue is already empty or drains before the timeout, and\n * `false` otherwise\n */\n function drain(timeout?: number): PromiseLike<boolean> {\n if (!buffer.size) {\n return resolvedSyncPromise(true);\n }\n\n // We want to resolve even if one of the promises rejects\n const drainPromise = Promise.allSettled(Array.from(buffer)).then(() => true);\n\n if (!timeout) {\n return drainPromise;\n }\n\n const promises = [\n drainPromise,\n new Promise<boolean>(resolve => safeUnref(setTimeout(() => resolve(false), timeout))),\n ];\n\n return Promise.race(promises);\n }\n\n return {\n get $(): PromiseLike<T>[] {\n return Array.from(buffer);\n },\n add,\n drain,\n };\n}\n"],"names":[],"mappings":";;;AAWO,MAAM,2BAA2B,MAAM,CAAC,GAAG,CAAC,uBAAuB;;AAE1E;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAI,KAAK,GAAW,GAAG,EAAoB;AAC5E,EAAE,MAAM,MAAM,GAAwB,IAAI,GAAG,EAAE;;AAE/C,EAAE,SAAS,OAAO,GAAY;AAC9B,IAAI,OAAO,MAAM,CAAC,IAAA,GAAO,KAAK;AAC9B,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,SAAS,MAAM,CAAC,IAAI,EAAwB;AAC9C,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;AACvB,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AAC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AAK;AACT,GAAG;AACH;;;;"}
@@ -79,6 +79,10 @@ function mergeScopeData(data, mergeData) {
79
79
  data.attachments = [...data.attachments, ...attachments];
80
80
  }
81
81
 
82
+ if (attributes) {
83
+ data.attributes = { ...data.attributes, ...attributes };
84
+ }
85
+
82
86
  data.propagationContext = { ...data.propagationContext, ...propagationContext };
83
87
  }
84
88
 
@@ -1 +1 @@
1
- {"version":3,"file":"scopeData.js","sources":["../../../src/utils/scopeData.ts"],"sourcesContent":["import { getGlobalScope } from '../currentScopes';\nimport type { Scope, ScopeData } from '../scope';\nimport { getDynamicSamplingContextFromSpan } from '../tracing/dynamicSamplingContext';\nimport type { Breadcrumb } from '../types-hoist/breadcrumb';\nimport type { Event } from '../types-hoist/event';\nimport type { Span } from '../types-hoist/span';\nimport { merge } from './merge';\nimport { getRootSpan, spanToJSON, spanToTraceContext } from './spanUtils';\n\n/**\n * Applies data from the scope to the event and runs all event processors on it.\n */\nexport function applyScopeDataToEvent(event: Event, data: ScopeData): void {\n const { fingerprint, span, breadcrumbs, sdkProcessingMetadata } = data;\n\n // Apply general data\n applyDataToEvent(event, data);\n\n // We want to set the trace context for normal events only if there isn't already\n // a trace context on the event. There is a product feature in place where we link\n // errors with transaction and it relies on that.\n if (span) {\n applySpanToEvent(event, span);\n }\n\n applyFingerprintToEvent(event, fingerprint);\n applyBreadcrumbsToEvent(event, breadcrumbs);\n applySdkMetadataToEvent(event, sdkProcessingMetadata);\n}\n\n/** Merge data of two scopes together. */\nexport function mergeScopeData(data: ScopeData, mergeData: ScopeData): void {\n const {\n extra,\n tags,\n attributes,\n user,\n contexts,\n level,\n sdkProcessingMetadata,\n breadcrumbs,\n fingerprint,\n eventProcessors,\n attachments,\n propagationContext,\n transactionName,\n span,\n } = mergeData;\n\n mergeAndOverwriteScopeData(data, 'extra', extra);\n mergeAndOverwriteScopeData(data, 'tags', tags);\n mergeAndOverwriteScopeData(data, 'attributes', attributes);\n mergeAndOverwriteScopeData(data, 'user', user);\n mergeAndOverwriteScopeData(data, 'contexts', contexts);\n\n data.sdkProcessingMetadata = merge(data.sdkProcessingMetadata, sdkProcessingMetadata, 2);\n\n if (level) {\n data.level = level;\n }\n\n if (transactionName) {\n data.transactionName = transactionName;\n }\n\n if (span) {\n data.span = span;\n }\n\n if (breadcrumbs.length) {\n data.breadcrumbs = [...data.breadcrumbs, ...breadcrumbs];\n }\n\n if (fingerprint.length) {\n data.fingerprint = [...data.fingerprint, ...fingerprint];\n }\n\n if (eventProcessors.length) {\n data.eventProcessors = [...data.eventProcessors, ...eventProcessors];\n }\n\n if (attachments.length) {\n data.attachments = [...data.attachments, ...attachments];\n }\n\n data.propagationContext = { ...data.propagationContext, ...propagationContext };\n}\n\n/**\n * Merges certain scope data. Undefined values will overwrite any existing values.\n * Exported only for tests.\n */\nexport function mergeAndOverwriteScopeData<\n Prop extends 'extra' | 'tags' | 'attributes' | 'user' | 'contexts' | 'sdkProcessingMetadata',\n Data extends ScopeData,\n>(data: Data, prop: Prop, mergeVal: Data[Prop]): void {\n data[prop] = merge(data[prop], mergeVal, 1);\n}\n\n/** Exported only for tests */\nexport function mergeArray<Prop extends 'breadcrumbs' | 'fingerprint'>(\n event: Event,\n prop: Prop,\n mergeVal: ScopeData[Prop],\n): void {\n const prevVal = event[prop];\n // If we are not merging any new values,\n // we only need to proceed if there was an empty array before (as we want to replace it with undefined)\n if (!mergeVal.length && (!prevVal || prevVal.length)) {\n return;\n }\n\n const merged = [...(prevVal || []), ...mergeVal] as ScopeData[Prop];\n event[prop] = merged.length ? merged : undefined;\n}\n\n/**\n * Get the scope data for the current scope after merging with the\n * global scope and isolation scope.\n *\n * @param currentScope - The current scope.\n * @returns The scope data.\n */\nexport function getCombinedScopeData(isolationScope: Scope | undefined, currentScope: Scope | undefined): ScopeData {\n const scopeData = getGlobalScope().getScopeData();\n isolationScope && mergeScopeData(scopeData, isolationScope.getScopeData());\n currentScope && mergeScopeData(scopeData, currentScope.getScopeData());\n return scopeData;\n}\n\nfunction applyDataToEvent(event: Event, data: ScopeData): void {\n const { extra, tags, user, contexts, level, transactionName } = data;\n\n if (Object.keys(extra).length) {\n event.extra = { ...extra, ...event.extra };\n }\n\n if (Object.keys(tags).length) {\n event.tags = { ...tags, ...event.tags };\n }\n\n if (Object.keys(user).length) {\n event.user = { ...user, ...event.user };\n }\n\n if (Object.keys(contexts).length) {\n event.contexts = { ...contexts, ...event.contexts };\n }\n\n if (level) {\n event.level = level;\n }\n\n // transaction events get their `transaction` from the root span name\n if (transactionName && event.type !== 'transaction') {\n event.transaction = transactionName;\n }\n}\n\nfunction applyBreadcrumbsToEvent(event: Event, breadcrumbs: Breadcrumb[]): void {\n const mergedBreadcrumbs = [...(event.breadcrumbs || []), ...breadcrumbs];\n event.breadcrumbs = mergedBreadcrumbs.length ? mergedBreadcrumbs : undefined;\n}\n\nfunction applySdkMetadataToEvent(event: Event, sdkProcessingMetadata: ScopeData['sdkProcessingMetadata']): void {\n event.sdkProcessingMetadata = {\n ...event.sdkProcessingMetadata,\n ...sdkProcessingMetadata,\n };\n}\n\nfunction applySpanToEvent(event: Event, span: Span): void {\n event.contexts = {\n trace: spanToTraceContext(span),\n ...event.contexts,\n };\n\n event.sdkProcessingMetadata = {\n dynamicSamplingContext: getDynamicSamplingContextFromSpan(span),\n ...event.sdkProcessingMetadata,\n };\n\n const rootSpan = getRootSpan(span);\n const transactionName = spanToJSON(rootSpan).description;\n if (transactionName && !event.transaction && event.type === 'transaction') {\n event.transaction = transactionName;\n }\n}\n\n/**\n * Applies fingerprint from the scope to the event if there's one,\n * uses message if there's one instead or get rid of empty fingerprint\n */\nfunction applyFingerprintToEvent(event: Event, fingerprint: ScopeData['fingerprint'] | undefined): void {\n // Make sure it's an array first and we actually have something in place\n event.fingerprint = event.fingerprint\n ? Array.isArray(event.fingerprint)\n ? event.fingerprint\n : [event.fingerprint]\n : [];\n\n // If we have something on the scope, then merge it with event\n if (fingerprint) {\n event.fingerprint = event.fingerprint.concat(fingerprint);\n }\n\n // If we have no data at all, remove empty array default\n if (!event.fingerprint.length) {\n delete event.fingerprint;\n }\n}\n"],"names":[],"mappings":";;;;;AASA;AACA;AACA;AACO,SAAS,qBAAqB,CAAC,KAAK,EAAS,IAAI,EAAmB;AAC3E,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,qBAAA,EAAsB,GAAI,IAAI;;AAExE;AACA,EAAE,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC;;AAE/B;AACA;AACA;AACA,EAAE,IAAI,IAAI,EAAE;AACZ,IAAI,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC;AACjC,EAAE;;AAEF,EAAE,uBAAuB,CAAC,KAAK,EAAE,WAAW,CAAC;AAC7C,EAAE,uBAAuB,CAAC,KAAK,EAAE,WAAW,CAAC;AAC7C,EAAE,uBAAuB,CAAC,KAAK,EAAE,qBAAqB,CAAC;AACvD;;AAEA;AACO,SAAS,cAAc,CAAC,IAAI,EAAa,SAAS,EAAmB;AAC5E,EAAE,MAAM;AACR,IAAI,KAAK;AACT,IAAI,IAAI;AACR,IAAI,UAAU;AACd,IAAI,IAAI;AACR,IAAI,QAAQ;AACZ,IAAI,KAAK;AACT,IAAI,qBAAqB;AACzB,IAAI,WAAW;AACf,IAAI,WAAW;AACf,IAAI,eAAe;AACnB,IAAI,WAAW;AACf,IAAI,kBAAkB;AACtB,IAAI,eAAe;AACnB,IAAI,IAAI;AACR,GAAE,GAAI,SAAS;;AAEf,EAAE,0BAA0B,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC;AAClD,EAAE,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC;AAChD,EAAE,0BAA0B,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,CAAC;AAC5D,EAAE,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC;AAChD,EAAE,0BAA0B,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC;;AAExD,EAA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AAe;AACvC,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA,SAAS,uBAAuB,CAAC,KAAK,EAAS,WAAW,EAA8C;AACxG;AACA,EAAE,KAAK,CAAC,WAAA,GAAc,KAAK,CAAC;AAC5B,MAAM,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW;AACrC,QAAQ,KAAK,CAAC;AACd,QAAQ,CAAC,KAAK,CAAC,WAAW;AAC1B,MAAM,EAAE;;AAER;AACA,EAAE,IAAI,WAAW,EAAE;AACnB,IAAI,KAAK,CAAC,WAAA,GAAc,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC;AAC7D,EAAE;;AAEF;AACA,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE;AACjC,IAAI,OAAO,KAAK,CAAC,WAAW;AAC5B,EAAE;AACF;;;;"}
1
+ {"version":3,"file":"scopeData.js","sources":["../../../src/utils/scopeData.ts"],"sourcesContent":["import { getGlobalScope } from '../currentScopes';\nimport type { Scope, ScopeData } from '../scope';\nimport { getDynamicSamplingContextFromSpan } from '../tracing/dynamicSamplingContext';\nimport type { Breadcrumb } from '../types-hoist/breadcrumb';\nimport type { Event } from '../types-hoist/event';\nimport type { Span } from '../types-hoist/span';\nimport { merge } from './merge';\nimport { getRootSpan, spanToJSON, spanToTraceContext } from './spanUtils';\n\n/**\n * Applies data from the scope to the event and runs all event processors on it.\n */\nexport function applyScopeDataToEvent(event: Event, data: ScopeData): void {\n const { fingerprint, span, breadcrumbs, sdkProcessingMetadata } = data;\n\n // Apply general data\n applyDataToEvent(event, data);\n\n // We want to set the trace context for normal events only if there isn't already\n // a trace context on the event. There is a product feature in place where we link\n // errors with transaction and it relies on that.\n if (span) {\n applySpanToEvent(event, span);\n }\n\n applyFingerprintToEvent(event, fingerprint);\n applyBreadcrumbsToEvent(event, breadcrumbs);\n applySdkMetadataToEvent(event, sdkProcessingMetadata);\n}\n\n/** Merge data of two scopes together. */\nexport function mergeScopeData(data: ScopeData, mergeData: ScopeData): void {\n const {\n extra,\n tags,\n attributes,\n user,\n contexts,\n level,\n sdkProcessingMetadata,\n breadcrumbs,\n fingerprint,\n eventProcessors,\n attachments,\n propagationContext,\n transactionName,\n span,\n } = mergeData;\n\n mergeAndOverwriteScopeData(data, 'extra', extra);\n mergeAndOverwriteScopeData(data, 'tags', tags);\n mergeAndOverwriteScopeData(data, 'attributes', attributes);\n mergeAndOverwriteScopeData(data, 'user', user);\n mergeAndOverwriteScopeData(data, 'contexts', contexts);\n\n data.sdkProcessingMetadata = merge(data.sdkProcessingMetadata, sdkProcessingMetadata, 2);\n\n if (level) {\n data.level = level;\n }\n\n if (transactionName) {\n data.transactionName = transactionName;\n }\n\n if (span) {\n data.span = span;\n }\n\n if (breadcrumbs.length) {\n data.breadcrumbs = [...data.breadcrumbs, ...breadcrumbs];\n }\n\n if (fingerprint.length) {\n data.fingerprint = [...data.fingerprint, ...fingerprint];\n }\n\n if (eventProcessors.length) {\n data.eventProcessors = [...data.eventProcessors, ...eventProcessors];\n }\n\n if (attachments.length) {\n data.attachments = [...data.attachments, ...attachments];\n }\n\n if (attributes) {\n data.attributes = { ...data.attributes, ...attributes };\n }\n\n data.propagationContext = { ...data.propagationContext, ...propagationContext };\n}\n\n/**\n * Merges certain scope data. Undefined values will overwrite any existing values.\n * Exported only for tests.\n */\nexport function mergeAndOverwriteScopeData<\n Prop extends 'extra' | 'tags' | 'attributes' | 'user' | 'contexts' | 'sdkProcessingMetadata',\n Data extends ScopeData,\n>(data: Data, prop: Prop, mergeVal: Data[Prop]): void {\n data[prop] = merge(data[prop], mergeVal, 1);\n}\n\n/** Exported only for tests */\nexport function mergeArray<Prop extends 'breadcrumbs' | 'fingerprint'>(\n event: Event,\n prop: Prop,\n mergeVal: ScopeData[Prop],\n): void {\n const prevVal = event[prop];\n // If we are not merging any new values,\n // we only need to proceed if there was an empty array before (as we want to replace it with undefined)\n if (!mergeVal.length && (!prevVal || prevVal.length)) {\n return;\n }\n\n const merged = [...(prevVal || []), ...mergeVal] as ScopeData[Prop];\n event[prop] = merged.length ? merged : undefined;\n}\n\n/**\n * Get the scope data for the current scope after merging with the\n * global scope and isolation scope.\n *\n * @param currentScope - The current scope.\n * @returns The scope data.\n */\nexport function getCombinedScopeData(isolationScope: Scope | undefined, currentScope: Scope | undefined): ScopeData {\n const scopeData = getGlobalScope().getScopeData();\n isolationScope && mergeScopeData(scopeData, isolationScope.getScopeData());\n currentScope && mergeScopeData(scopeData, currentScope.getScopeData());\n return scopeData;\n}\n\nfunction applyDataToEvent(event: Event, data: ScopeData): void {\n const { extra, tags, user, contexts, level, transactionName } = data;\n\n if (Object.keys(extra).length) {\n event.extra = { ...extra, ...event.extra };\n }\n\n if (Object.keys(tags).length) {\n event.tags = { ...tags, ...event.tags };\n }\n\n if (Object.keys(user).length) {\n event.user = { ...user, ...event.user };\n }\n\n if (Object.keys(contexts).length) {\n event.contexts = { ...contexts, ...event.contexts };\n }\n\n if (level) {\n event.level = level;\n }\n\n // transaction events get their `transaction` from the root span name\n if (transactionName && event.type !== 'transaction') {\n event.transaction = transactionName;\n }\n}\n\nfunction applyBreadcrumbsToEvent(event: Event, breadcrumbs: Breadcrumb[]): void {\n const mergedBreadcrumbs = [...(event.breadcrumbs || []), ...breadcrumbs];\n event.breadcrumbs = mergedBreadcrumbs.length ? mergedBreadcrumbs : undefined;\n}\n\nfunction applySdkMetadataToEvent(event: Event, sdkProcessingMetadata: ScopeData['sdkProcessingMetadata']): void {\n event.sdkProcessingMetadata = {\n ...event.sdkProcessingMetadata,\n ...sdkProcessingMetadata,\n };\n}\n\nfunction applySpanToEvent(event: Event, span: Span): void {\n event.contexts = {\n trace: spanToTraceContext(span),\n ...event.contexts,\n };\n\n event.sdkProcessingMetadata = {\n dynamicSamplingContext: getDynamicSamplingContextFromSpan(span),\n ...event.sdkProcessingMetadata,\n };\n\n const rootSpan = getRootSpan(span);\n const transactionName = spanToJSON(rootSpan).description;\n if (transactionName && !event.transaction && event.type === 'transaction') {\n event.transaction = transactionName;\n }\n}\n\n/**\n * Applies fingerprint from the scope to the event if there's one,\n * uses message if there's one instead or get rid of empty fingerprint\n */\nfunction applyFingerprintToEvent(event: Event, fingerprint: ScopeData['fingerprint'] | undefined): void {\n // Make sure it's an array first and we actually have something in place\n event.fingerprint = event.fingerprint\n ? Array.isArray(event.fingerprint)\n ? event.fingerprint\n : [event.fingerprint]\n : [];\n\n // If we have something on the scope, then merge it with event\n if (fingerprint) {\n event.fingerprint = event.fingerprint.concat(fingerprint);\n }\n\n // If we have no data at all, remove empty array default\n if (!event.fingerprint.length) {\n delete event.fingerprint;\n }\n}\n"],"names":[],"mappings":";;;;;AASA;AACA;AACA;AACO,SAAS,qBAAqB,CAAC,KAAK,EAAS,IAAI,EAAmB;AAC3E,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,qBAAA,EAAsB,GAAI,IAAI;;AAExE;AACA,EAAE,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC;;AAE/B;AACA;AACA;AACA,EAAE,IAAI,IAAI,EAAE;AACZ,IAAI,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC;AACjC,EAAE;;AAEF,EAAE,uBAAuB,CAAC,KAAK,EAAE,WAAW,CAAC;AAC7C,EAAE,uBAAuB,CAAC,KAAK,EAAE,WAAW,CAAC;AAC7C,EAAE,uBAAuB,CAAC,KAAK,EAAE,qBAAqB,CAAC;AACvD;;AAEA;AACO,SAAS,cAAc,CAAC,IAAI,EAAa,SAAS,EAAmB;AAC5E,EAAE,MAAM;AACR,IAAI,KAAK;AACT,IAAI,IAAI;AACR,IAAI,UAAU;AACd,IAAI,IAAI;AACR,IAAI,QAAQ;AACZ,IAAI,KAAK;AACT,IAAI,qBAAqB;AACzB,IAAI,WAAW;AACf,IAAI,WAAW;AACf,IAAI,eAAe;AACnB,IAAI,WAAW;AACf,IAAI,kBAAkB;AACtB,IAAI,eAAe;AACnB,IAAI,IAAI;AACR,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AAE,kBAAkB,CAAC,IAAI,CAAC;AACnC,IAAI,GAAG,KAAK,CAAC,QAAQ;AACrB,GAAG;;AAEH,EAAE,KAAK,CAAC,qBAAA,GAAwB;AAChC,IAAI,sBAAsB,EAAE,iCAAiC,CAAC,IAAI,CAAC;AACnE,IAAI,GAAG,KAAK,CAAC,qBAAqB;AAClC,GAAG;;AAEH,EAAE,MAAM,QAAA,GAAW,WAAW,CAAC,IAAI,CAAC;AACpC,EAAE,MAAM,kBAAkB,UAAU,CAAC,QAAQ,CAAC,CAAC,WAAW;AAC1D,EAAE,IAAI,eAAA,IAAmB,CAAC,KAAK,CAAC,WAAA,IAAe,KAAK,CAAC,IAAA,KAAS,aAAa,EAAE;AAC7E,IAAI,KAAK,CAAC,WAAA,GAAc,eAAe;AACvC,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA,SAAS,uBAAuB,CAAC,KAAK,EAAS,WAAW,EAA8C;AACxG;AACA,EAAE,KAAK,CAAC,WAAA,GAAc,KAAK,CAAC;AAC5B,MAAM,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW;AACrC,QAAQ,KAAK,CAAC;AACd,QAAQ,CAAC,KAAK,CAAC,WAAW;AAC1B,MAAM,EAAE;;AAER;AACA,EAAE,IAAI,WAAW,EAAE;AACnB,IAAI,KAAK,CAAC,WAAA,GAAc,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC;AAC7D,EAAE;;AAEF;AACA,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE;AACjC,IAAI,OAAO,KAAK,CAAC,WAAW;AAC5B,EAAE;AACF;;;;"}
@@ -14,20 +14,16 @@ import { SDK_VERSION } from './version.js';
14
14
  * @param names list of package names
15
15
  */
16
16
  function applySdkMetadata(options, name, names = [name], source = 'npm') {
17
- const metadata = options._metadata || {};
17
+ const sdk = ((options._metadata = options._metadata || {}).sdk = options._metadata.sdk || {});
18
18
 
19
- if (!metadata.sdk) {
20
- metadata.sdk = {
21
- name: `sentry.javascript.${name}`,
22
- packages: names.map(name => ({
23
- name: `${source}:@sentry/${name}`,
24
- version: SDK_VERSION,
25
- })),
19
+ if (!sdk.name) {
20
+ sdk.name = `sentry.javascript.${name}`;
21
+ sdk.packages = names.map(name => ({
22
+ name: `${source}:@sentry/${name}`,
26
23
  version: SDK_VERSION,
27
- };
24
+ }));
25
+ sdk.version = SDK_VERSION;
28
26
  }
29
-
30
- options._metadata = metadata;
31
27
  }
32
28
 
33
29
  export { applySdkMetadata };
@@ -1 +1 @@
1
- {"version":3,"file":"sdkMetadata.js","sources":["../../../src/utils/sdkMetadata.ts"],"sourcesContent":["import type { CoreOptions } from '../types-hoist/options';\nimport { SDK_VERSION } from '../utils/version';\n\n/**\n * A builder for the SDK metadata in the options for the SDK initialization.\n *\n * Note: This function is identical to `buildMetadata` in Remix and NextJS and SvelteKit.\n * We don't extract it for bundle size reasons.\n * @see https://github.com/getsentry/sentry-javascript/pull/7404\n * @see https://github.com/getsentry/sentry-javascript/pull/4196\n *\n * If you make changes to this function consider updating the others as well.\n *\n * @param options SDK options object that gets mutated\n * @param names list of package names\n */\nexport function applySdkMetadata(options: CoreOptions, name: string, names = [name], source = 'npm'): void {\n const metadata = options._metadata || {};\n\n if (!metadata.sdk) {\n metadata.sdk = {\n name: `sentry.javascript.${name}`,\n packages: names.map(name => ({\n name: `${source}:@sentry/${name}`,\n version: SDK_VERSION,\n })),\n version: SDK_VERSION,\n };\n }\n\n options._metadata = metadata;\n}\n"],"names":[],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAC,OAAO,EAAe,IAAI,EAAU,KAAA,GAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,KAAK,EAAQ;AAC3G,EAAE,MAAM,WAAW,OAAO,CAAC,SAAA,IAAa,EAAE;;AAE1C,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;AACrB,IAAI,QAAQ,CAAC,GAAA,GAAM;AACnB,MAAM,IAAI,EAAE,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAA;AACA,MAAA,QAAA,EAAA,KAAA,CAAA,GAAA,CAAA,IAAA,KAAA;AACA,QAAA,IAAA,EAAA,CAAA,EAAA,MAAA,CAAA,SAAA,EAAA,IAAA,CAAA,CAAA;AACA,QAAA,OAAA,EAAA,WAAA;AACA,OAAA,CAAA,CAAA;AACA,MAAA,OAAA,EAAA,WAAA;AACA,KAAA;AACA,EAAA;;AAEA,EAAA,OAAA,CAAA,SAAA,GAAA,QAAA;AACA;;;;"}
1
+ {"version":3,"file":"sdkMetadata.js","sources":["../../../src/utils/sdkMetadata.ts"],"sourcesContent":["import type { CoreOptions } from '../types-hoist/options';\nimport { SDK_VERSION } from '../utils/version';\n\n/**\n * A builder for the SDK metadata in the options for the SDK initialization.\n *\n * Note: This function is identical to `buildMetadata` in Remix and NextJS and SvelteKit.\n * We don't extract it for bundle size reasons.\n * @see https://github.com/getsentry/sentry-javascript/pull/7404\n * @see https://github.com/getsentry/sentry-javascript/pull/4196\n *\n * If you make changes to this function consider updating the others as well.\n *\n * @param options SDK options object that gets mutated\n * @param names list of package names\n */\nexport function applySdkMetadata(options: CoreOptions, name: string, names = [name], source = 'npm'): void {\n const sdk = ((options._metadata = options._metadata || {}).sdk = options._metadata.sdk || {});\n\n if (!sdk.name) {\n sdk.name = `sentry.javascript.${name}`;\n sdk.packages = names.map(name => ({\n name: `${source}:@sentry/${name}`,\n version: SDK_VERSION,\n }));\n sdk.version = SDK_VERSION;\n }\n}\n"],"names":[],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAC,OAAO,EAAe,IAAI,EAAU,KAAA,GAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,KAAK,EAAQ;AAC3G,EAAE,MAAM,GAAA,IAAO,CAAC,OAAO,CAAC,SAAA,GAAY,OAAO,CAAC,SAAA,IAAa,EAAE,EAAE,GAAA,GAAM,OAAO,CAAC,SAAS,CAAC,GAAA,IAAO,EAAE,CAAC;;AAE/F,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;AACjB,IAAI,GAAG,CAAC,IAAA,GAAO,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAA;AACA,IAAA,GAAA,CAAA,QAAA,GAAA,KAAA,CAAA,GAAA,CAAA,IAAA,KAAA;AACA,MAAA,IAAA,EAAA,CAAA,EAAA,MAAA,CAAA,SAAA,EAAA,IAAA,CAAA,CAAA;AACA,MAAA,OAAA,EAAA,WAAA;AACA,KAAA,CAAA,CAAA;AACA,IAAA,GAAA,CAAA,OAAA,GAAA,WAAA;AACA,EAAA;AACA;;;;"}