@sentry/node 9.34.0-alpha.1 → 9.35.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 (474) hide show
  1. package/build/cjs/cron/common.js +56 -0
  2. package/build/cjs/cron/common.js.map +1 -0
  3. package/build/cjs/cron/cron.js +112 -0
  4. package/build/cjs/cron/cron.js.map +1 -0
  5. package/build/cjs/cron/index.js +15 -0
  6. package/build/cjs/cron/index.js.map +1 -0
  7. package/build/cjs/cron/node-cron.js +71 -0
  8. package/build/cjs/cron/node-cron.js.map +1 -0
  9. package/build/cjs/cron/node-schedule.js +65 -0
  10. package/build/cjs/cron/node-schedule.js.map +1 -0
  11. package/build/cjs/index.js +56 -38
  12. package/build/cjs/index.js.map +1 -1
  13. package/build/cjs/integrations/anr/index.js +238 -0
  14. package/build/cjs/integrations/anr/index.js.map +1 -0
  15. package/build/cjs/integrations/childProcess.js +100 -0
  16. package/build/cjs/integrations/childProcess.js.map +1 -0
  17. package/build/cjs/integrations/context.js +457 -0
  18. package/build/cjs/integrations/context.js.map +1 -0
  19. package/build/cjs/integrations/contextlines.js +405 -0
  20. package/build/cjs/integrations/contextlines.js.map +1 -0
  21. package/build/cjs/integrations/fs.js +2 -2
  22. package/build/cjs/integrations/fs.js.map +1 -1
  23. package/build/cjs/integrations/http/SentryHttpInstrumentation.js +558 -0
  24. package/build/cjs/integrations/http/SentryHttpInstrumentation.js.map +1 -0
  25. package/build/cjs/integrations/http/index.js +11 -7
  26. package/build/cjs/integrations/http/index.js.map +1 -1
  27. package/build/cjs/integrations/local-variables/common.js +69 -0
  28. package/build/cjs/integrations/local-variables/common.js.map +1 -0
  29. package/build/cjs/integrations/local-variables/index.js +12 -0
  30. package/build/cjs/integrations/local-variables/index.js.map +1 -0
  31. package/build/cjs/integrations/local-variables/local-variables-async.js +143 -0
  32. package/build/cjs/integrations/local-variables/local-variables-async.js.map +1 -0
  33. package/build/cjs/integrations/local-variables/local-variables-sync.js +410 -0
  34. package/build/cjs/integrations/local-variables/local-variables-sync.js.map +1 -0
  35. package/build/cjs/integrations/modules.js +135 -0
  36. package/build/cjs/integrations/modules.js.map +1 -0
  37. package/build/cjs/integrations/node-fetch/SentryNodeFetchInstrumentation.js +291 -0
  38. package/build/cjs/integrations/node-fetch/SentryNodeFetchInstrumentation.js.map +1 -0
  39. package/build/cjs/integrations/node-fetch/index.js +5 -4
  40. package/build/cjs/integrations/node-fetch/index.js.map +1 -1
  41. package/build/cjs/integrations/onuncaughtexception.js +134 -0
  42. package/build/cjs/integrations/onuncaughtexception.js.map +1 -0
  43. package/build/cjs/integrations/onunhandledrejection.js +89 -0
  44. package/build/cjs/integrations/onunhandledrejection.js.map +1 -0
  45. package/build/cjs/integrations/processSession.js +36 -0
  46. package/build/cjs/integrations/processSession.js.map +1 -0
  47. package/build/cjs/integrations/spotlight.js +101 -0
  48. package/build/cjs/integrations/spotlight.js.map +1 -0
  49. package/build/cjs/integrations/tracing/amqplib.js +5 -4
  50. package/build/cjs/integrations/tracing/amqplib.js.map +1 -1
  51. package/build/cjs/integrations/tracing/connect.js +4 -3
  52. package/build/cjs/integrations/tracing/connect.js.map +1 -1
  53. package/build/cjs/integrations/tracing/dataloader.js +3 -3
  54. package/build/cjs/integrations/tracing/dataloader.js.map +1 -1
  55. package/build/cjs/integrations/tracing/express.js +7 -5
  56. package/build/cjs/integrations/tracing/express.js.map +1 -1
  57. package/build/cjs/integrations/tracing/fastify/fastify-otel/index.js +3 -3
  58. package/build/cjs/integrations/tracing/fastify/fastify-otel/index.js.map +1 -1
  59. package/build/cjs/integrations/tracing/fastify/index.js +6 -6
  60. package/build/cjs/integrations/tracing/fastify/index.js.map +1 -1
  61. package/build/cjs/integrations/tracing/genericPool.js +3 -3
  62. package/build/cjs/integrations/tracing/genericPool.js.map +1 -1
  63. package/build/cjs/integrations/tracing/graphql.js +4 -3
  64. package/build/cjs/integrations/tracing/graphql.js.map +1 -1
  65. package/build/cjs/integrations/tracing/hapi/index.js +4 -3
  66. package/build/cjs/integrations/tracing/hapi/index.js.map +1 -1
  67. package/build/cjs/integrations/tracing/kafka.js +5 -4
  68. package/build/cjs/integrations/tracing/kafka.js.map +1 -1
  69. package/build/cjs/integrations/tracing/knex.js +3 -3
  70. package/build/cjs/integrations/tracing/knex.js.map +1 -1
  71. package/build/cjs/integrations/tracing/koa.js +6 -4
  72. package/build/cjs/integrations/tracing/koa.js.map +1 -1
  73. package/build/cjs/integrations/tracing/lrumemoizer.js +2 -2
  74. package/build/cjs/integrations/tracing/lrumemoizer.js.map +1 -1
  75. package/build/cjs/integrations/tracing/mongo.js +4 -3
  76. package/build/cjs/integrations/tracing/mongo.js.map +1 -1
  77. package/build/cjs/integrations/tracing/mongoose.js +4 -3
  78. package/build/cjs/integrations/tracing/mongoose.js.map +1 -1
  79. package/build/cjs/integrations/tracing/mysql.js +2 -2
  80. package/build/cjs/integrations/tracing/mysql.js.map +1 -1
  81. package/build/cjs/integrations/tracing/mysql2.js +4 -3
  82. package/build/cjs/integrations/tracing/mysql2.js.map +1 -1
  83. package/build/cjs/integrations/tracing/postgres.js +4 -3
  84. package/build/cjs/integrations/tracing/postgres.js.map +1 -1
  85. package/build/cjs/integrations/tracing/postgresjs.js +4 -3
  86. package/build/cjs/integrations/tracing/postgresjs.js.map +1 -1
  87. package/build/cjs/integrations/tracing/prisma.js +2 -2
  88. package/build/cjs/integrations/tracing/prisma.js.map +1 -1
  89. package/build/cjs/integrations/tracing/redis.js +3 -3
  90. package/build/cjs/integrations/tracing/redis.js.map +1 -1
  91. package/build/cjs/integrations/tracing/tedious.js +3 -3
  92. package/build/cjs/integrations/tracing/tedious.js.map +1 -1
  93. package/build/cjs/integrations/tracing/vercelai/index.js +2 -2
  94. package/build/cjs/integrations/tracing/vercelai/index.js.map +1 -1
  95. package/build/cjs/integrations/winston.js +151 -0
  96. package/build/cjs/integrations/winston.js.map +1 -0
  97. package/build/cjs/logs/capture.js +29 -0
  98. package/build/cjs/logs/capture.js.map +1 -0
  99. package/build/cjs/logs/exports.js +178 -0
  100. package/build/cjs/logs/exports.js.map +1 -0
  101. package/build/cjs/nodeVersion.js +12 -0
  102. package/build/cjs/nodeVersion.js.map +1 -0
  103. package/build/cjs/otel/contextManager.js +16 -0
  104. package/build/cjs/otel/contextManager.js.map +1 -0
  105. package/build/cjs/otel/instrument.js +139 -0
  106. package/build/cjs/otel/instrument.js.map +1 -0
  107. package/build/cjs/preload.js +2 -2
  108. package/build/cjs/preload.js.map +1 -1
  109. package/build/cjs/proxy/base.js +122 -0
  110. package/build/cjs/proxy/base.js.map +1 -0
  111. package/build/cjs/proxy/index.js +173 -0
  112. package/build/cjs/proxy/index.js.map +1 -0
  113. package/build/cjs/proxy/parse-proxy-response.js +104 -0
  114. package/build/cjs/proxy/parse-proxy-response.js.map +1 -0
  115. package/build/cjs/sdk/api.js +117 -0
  116. package/build/cjs/sdk/api.js.map +1 -0
  117. package/build/cjs/sdk/client.js +156 -0
  118. package/build/cjs/sdk/client.js.map +1 -0
  119. package/build/cjs/sdk/index.js +203 -22
  120. package/build/cjs/sdk/index.js.map +1 -1
  121. package/build/cjs/sdk/initOtel.js +22 -4
  122. package/build/cjs/sdk/initOtel.js.map +1 -1
  123. package/build/cjs/transports/http.js +158 -0
  124. package/build/cjs/transports/http.js.map +1 -0
  125. package/build/cjs/utils/addOriginToSpan.js +11 -0
  126. package/build/cjs/utils/addOriginToSpan.js.map +1 -0
  127. package/build/cjs/utils/baggage.js +36 -0
  128. package/build/cjs/utils/baggage.js.map +1 -0
  129. package/build/cjs/utils/commonjs.js +13 -0
  130. package/build/cjs/utils/commonjs.js.map +1 -0
  131. package/build/cjs/utils/createMissingInstrumentationContext.js +11 -0
  132. package/build/cjs/utils/createMissingInstrumentationContext.js.map +1 -0
  133. package/build/cjs/utils/debug.js +23 -0
  134. package/build/cjs/utils/debug.js.map +1 -0
  135. package/build/cjs/utils/ensureIsWrapped.js +41 -0
  136. package/build/cjs/utils/ensureIsWrapped.js.map +1 -0
  137. package/build/cjs/utils/envToBool.js +32 -0
  138. package/build/cjs/utils/envToBool.js.map +1 -0
  139. package/build/cjs/utils/errorhandling.js +42 -0
  140. package/build/cjs/utils/errorhandling.js.map +1 -0
  141. package/build/cjs/utils/getRequestUrl.js +18 -0
  142. package/build/cjs/utils/getRequestUrl.js.map +1 -0
  143. package/build/cjs/utils/module.js +60 -0
  144. package/build/cjs/utils/module.js.map +1 -0
  145. package/build/esm/cron/common.js +54 -0
  146. package/build/esm/cron/common.js.map +1 -0
  147. package/build/esm/cron/cron.js +110 -0
  148. package/build/esm/cron/cron.js.map +1 -0
  149. package/build/esm/cron/index.js +13 -0
  150. package/build/esm/cron/index.js.map +1 -0
  151. package/build/esm/cron/node-cron.js +69 -0
  152. package/build/esm/cron/node-cron.js.map +1 -0
  153. package/build/esm/cron/node-schedule.js +63 -0
  154. package/build/esm/cron/node-schedule.js.map +1 -0
  155. package/build/esm/index.js +21 -2
  156. package/build/esm/index.js.map +1 -1
  157. package/build/esm/integrations/anr/index.js +234 -0
  158. package/build/esm/integrations/anr/index.js.map +1 -0
  159. package/build/esm/integrations/anr/worker-script.js +2 -0
  160. package/build/esm/integrations/childProcess.js +98 -0
  161. package/build/esm/integrations/childProcess.js.map +1 -0
  162. package/build/esm/integrations/context.js +451 -0
  163. package/build/esm/integrations/context.js.map +1 -0
  164. package/build/esm/integrations/contextlines.js +399 -0
  165. package/build/esm/integrations/contextlines.js.map +1 -0
  166. package/build/esm/integrations/fs.js +1 -1
  167. package/build/esm/integrations/fs.js.map +1 -1
  168. package/build/esm/integrations/http/SentryHttpInstrumentation.js +555 -0
  169. package/build/esm/integrations/http/SentryHttpInstrumentation.js.map +1 -0
  170. package/build/esm/integrations/http/index.js +5 -1
  171. package/build/esm/integrations/http/index.js.map +1 -1
  172. package/build/esm/integrations/local-variables/common.js +64 -0
  173. package/build/esm/integrations/local-variables/common.js.map +1 -0
  174. package/build/esm/integrations/local-variables/index.js +10 -0
  175. package/build/esm/integrations/local-variables/index.js.map +1 -0
  176. package/build/esm/integrations/local-variables/local-variables-async.js +140 -0
  177. package/build/esm/integrations/local-variables/local-variables-async.js.map +1 -0
  178. package/build/esm/integrations/local-variables/local-variables-sync.js +405 -0
  179. package/build/esm/integrations/local-variables/local-variables-sync.js.map +1 -0
  180. package/build/esm/integrations/local-variables/worker-script.js +2 -0
  181. package/build/esm/integrations/modules.js +133 -0
  182. package/build/esm/integrations/modules.js.map +1 -0
  183. package/build/esm/integrations/node-fetch/SentryNodeFetchInstrumentation.js +289 -0
  184. package/build/esm/integrations/node-fetch/SentryNodeFetchInstrumentation.js.map +1 -0
  185. package/build/esm/integrations/node-fetch/index.js +3 -2
  186. package/build/esm/integrations/node-fetch/index.js.map +1 -1
  187. package/build/esm/integrations/onuncaughtexception.js +131 -0
  188. package/build/esm/integrations/onuncaughtexception.js.map +1 -0
  189. package/build/esm/integrations/onunhandledrejection.js +86 -0
  190. package/build/esm/integrations/onunhandledrejection.js.map +1 -0
  191. package/build/esm/integrations/processSession.js +34 -0
  192. package/build/esm/integrations/processSession.js.map +1 -0
  193. package/build/esm/integrations/spotlight.js +98 -0
  194. package/build/esm/integrations/spotlight.js.map +1 -0
  195. package/build/esm/integrations/tracing/amqplib.js +2 -1
  196. package/build/esm/integrations/tracing/amqplib.js.map +1 -1
  197. package/build/esm/integrations/tracing/connect.js +2 -1
  198. package/build/esm/integrations/tracing/connect.js.map +1 -1
  199. package/build/esm/integrations/tracing/dataloader.js +1 -1
  200. package/build/esm/integrations/tracing/dataloader.js.map +1 -1
  201. package/build/esm/integrations/tracing/express.js +4 -2
  202. package/build/esm/integrations/tracing/express.js.map +1 -1
  203. package/build/esm/integrations/tracing/fastify/fastify-otel/index.js +3 -3
  204. package/build/esm/integrations/tracing/fastify/fastify-otel/index.js.map +1 -1
  205. package/build/esm/integrations/tracing/fastify/index.js +5 -5
  206. package/build/esm/integrations/tracing/fastify/index.js.map +1 -1
  207. package/build/esm/integrations/tracing/genericPool.js +1 -1
  208. package/build/esm/integrations/tracing/genericPool.js.map +1 -1
  209. package/build/esm/integrations/tracing/graphql.js +3 -2
  210. package/build/esm/integrations/tracing/graphql.js.map +1 -1
  211. package/build/esm/integrations/tracing/hapi/index.js +2 -1
  212. package/build/esm/integrations/tracing/hapi/index.js.map +1 -1
  213. package/build/esm/integrations/tracing/kafka.js +2 -1
  214. package/build/esm/integrations/tracing/kafka.js.map +1 -1
  215. package/build/esm/integrations/tracing/knex.js +1 -1
  216. package/build/esm/integrations/tracing/knex.js.map +1 -1
  217. package/build/esm/integrations/tracing/koa.js +4 -2
  218. package/build/esm/integrations/tracing/koa.js.map +1 -1
  219. package/build/esm/integrations/tracing/lrumemoizer.js +1 -1
  220. package/build/esm/integrations/tracing/lrumemoizer.js.map +1 -1
  221. package/build/esm/integrations/tracing/mongo.js +2 -1
  222. package/build/esm/integrations/tracing/mongo.js.map +1 -1
  223. package/build/esm/integrations/tracing/mongoose.js +2 -1
  224. package/build/esm/integrations/tracing/mongoose.js.map +1 -1
  225. package/build/esm/integrations/tracing/mysql.js +1 -1
  226. package/build/esm/integrations/tracing/mysql.js.map +1 -1
  227. package/build/esm/integrations/tracing/mysql2.js +2 -1
  228. package/build/esm/integrations/tracing/mysql2.js.map +1 -1
  229. package/build/esm/integrations/tracing/postgres.js +2 -1
  230. package/build/esm/integrations/tracing/postgres.js.map +1 -1
  231. package/build/esm/integrations/tracing/postgresjs.js +3 -2
  232. package/build/esm/integrations/tracing/postgresjs.js.map +1 -1
  233. package/build/esm/integrations/tracing/prisma.js +1 -1
  234. package/build/esm/integrations/tracing/prisma.js.map +1 -1
  235. package/build/esm/integrations/tracing/redis.js +1 -1
  236. package/build/esm/integrations/tracing/redis.js.map +1 -1
  237. package/build/esm/integrations/tracing/tedious.js +1 -1
  238. package/build/esm/integrations/tracing/tedious.js.map +1 -1
  239. package/build/esm/integrations/tracing/vercelai/index.js +1 -1
  240. package/build/esm/integrations/tracing/vercelai/index.js.map +1 -1
  241. package/build/esm/integrations/winston.js +149 -0
  242. package/build/esm/integrations/winston.js.map +1 -0
  243. package/build/esm/logs/capture.js +27 -0
  244. package/build/esm/logs/capture.js.map +1 -0
  245. package/build/esm/logs/exports.js +170 -0
  246. package/build/esm/logs/exports.js.map +1 -0
  247. package/build/esm/nodeVersion.js +8 -0
  248. package/build/esm/nodeVersion.js.map +1 -0
  249. package/build/esm/otel/contextManager.js +14 -0
  250. package/build/esm/otel/contextManager.js.map +1 -0
  251. package/build/esm/otel/instrument.js +135 -0
  252. package/build/esm/otel/instrument.js.map +1 -0
  253. package/build/esm/package.json +1 -1
  254. package/build/esm/preload.js +1 -1
  255. package/build/esm/preload.js.map +1 -1
  256. package/build/esm/proxy/base.js +120 -0
  257. package/build/esm/proxy/base.js.map +1 -0
  258. package/build/esm/proxy/index.js +171 -0
  259. package/build/esm/proxy/index.js.map +1 -0
  260. package/build/esm/proxy/parse-proxy-response.js +102 -0
  261. package/build/esm/proxy/parse-proxy-response.js.map +1 -0
  262. package/build/esm/sdk/api.js +114 -0
  263. package/build/esm/sdk/api.js.map +1 -0
  264. package/build/esm/sdk/client.js +154 -0
  265. package/build/esm/sdk/client.js.map +1 -0
  266. package/build/esm/sdk/index.js +202 -22
  267. package/build/esm/sdk/index.js.map +1 -1
  268. package/build/esm/sdk/initOtel.js +21 -3
  269. package/build/esm/sdk/initOtel.js.map +1 -1
  270. package/build/esm/transports/http.js +156 -0
  271. package/build/esm/transports/http.js.map +1 -0
  272. package/build/esm/utils/addOriginToSpan.js +9 -0
  273. package/build/esm/utils/addOriginToSpan.js.map +1 -0
  274. package/build/esm/utils/baggage.js +34 -0
  275. package/build/esm/utils/baggage.js.map +1 -0
  276. package/build/esm/utils/commonjs.js +11 -0
  277. package/build/esm/utils/commonjs.js.map +1 -0
  278. package/build/esm/utils/createMissingInstrumentationContext.js +9 -0
  279. package/build/esm/utils/createMissingInstrumentationContext.js.map +1 -0
  280. package/build/esm/utils/debug.js +21 -0
  281. package/build/esm/utils/debug.js.map +1 -0
  282. package/build/esm/utils/ensureIsWrapped.js +39 -0
  283. package/build/esm/utils/ensureIsWrapped.js.map +1 -0
  284. package/build/esm/utils/envToBool.js +28 -0
  285. package/build/esm/utils/envToBool.js.map +1 -0
  286. package/build/esm/utils/errorhandling.js +40 -0
  287. package/build/esm/utils/errorhandling.js.map +1 -0
  288. package/build/esm/utils/getRequestUrl.js +16 -0
  289. package/build/esm/utils/getRequestUrl.js.map +1 -0
  290. package/build/esm/utils/module.js +58 -0
  291. package/build/esm/utils/module.js.map +1 -0
  292. package/build/types/cron/common.d.ts +5 -0
  293. package/build/types/cron/common.d.ts.map +1 -0
  294. package/build/types/cron/cron.d.ts +43 -0
  295. package/build/types/cron/cron.d.ts.map +1 -0
  296. package/build/types/cron/index.d.ts +10 -0
  297. package/build/types/cron/index.d.ts.map +1 -0
  298. package/build/types/cron/node-cron.d.ts +27 -0
  299. package/build/types/cron/node-cron.d.ts.map +1 -0
  300. package/build/types/cron/node-schedule.d.ts +19 -0
  301. package/build/types/cron/node-schedule.d.ts.map +1 -0
  302. package/build/types/index.d.ts +21 -2
  303. package/build/types/index.d.ts.map +1 -1
  304. package/build/types/integrations/anr/common.d.ts +52 -0
  305. package/build/types/integrations/anr/common.d.ts.map +1 -0
  306. package/build/types/integrations/anr/index.d.ts +13 -0
  307. package/build/types/integrations/anr/index.d.ts.map +1 -0
  308. package/build/types/integrations/anr/worker.d.ts +2 -0
  309. package/build/types/integrations/anr/worker.d.ts.map +1 -0
  310. package/build/types/integrations/childProcess.d.ts +20 -0
  311. package/build/types/integrations/childProcess.d.ts.map +1 -0
  312. package/build/types/integrations/context.d.ts +30 -0
  313. package/build/types/integrations/context.d.ts.map +1 -0
  314. package/build/types/integrations/contextlines.d.ts +31 -0
  315. package/build/types/integrations/contextlines.d.ts.map +1 -0
  316. package/build/types/integrations/http/SentryHttpInstrumentation.d.ts +131 -0
  317. package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -0
  318. package/build/types/integrations/http/index.d.ts +1 -1
  319. package/build/types/integrations/http/index.d.ts.map +1 -1
  320. package/build/types/integrations/local-variables/common.d.ts +66 -0
  321. package/build/types/integrations/local-variables/common.d.ts.map +1 -0
  322. package/build/types/integrations/local-variables/index.d.ts +4 -0
  323. package/build/types/integrations/local-variables/index.d.ts.map +1 -0
  324. package/build/types/integrations/local-variables/local-variables-async.d.ts +7 -0
  325. package/build/types/integrations/local-variables/local-variables-async.d.ts.map +1 -0
  326. package/build/types/integrations/local-variables/local-variables-sync.d.ts +34 -0
  327. package/build/types/integrations/local-variables/local-variables-sync.d.ts.map +1 -0
  328. package/build/types/integrations/local-variables/worker.d.ts +2 -0
  329. package/build/types/integrations/local-variables/worker.d.ts.map +1 -0
  330. package/build/types/integrations/modules.d.ts +17 -0
  331. package/build/types/integrations/modules.d.ts.map +1 -0
  332. package/build/types/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts +56 -0
  333. package/build/types/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts.map +1 -0
  334. package/build/types/integrations/node-fetch/index.d.ts.map +1 -1
  335. package/build/types/integrations/onuncaughtexception.d.ts +31 -0
  336. package/build/types/integrations/onuncaughtexception.d.ts.map +1 -0
  337. package/build/types/integrations/onunhandledrejection.d.ts +23 -0
  338. package/build/types/integrations/onunhandledrejection.d.ts.map +1 -0
  339. package/build/types/integrations/processSession.d.ts +5 -0
  340. package/build/types/integrations/processSession.d.ts.map +1 -0
  341. package/build/types/integrations/spotlight.d.ts +18 -0
  342. package/build/types/integrations/spotlight.d.ts.map +1 -0
  343. package/build/types/integrations/tracing/amqplib.d.ts.map +1 -1
  344. package/build/types/integrations/tracing/connect.d.ts.map +1 -1
  345. package/build/types/integrations/tracing/express.d.ts.map +1 -1
  346. package/build/types/integrations/tracing/graphql.d.ts.map +1 -1
  347. package/build/types/integrations/tracing/hapi/index.d.ts.map +1 -1
  348. package/build/types/integrations/tracing/kafka.d.ts.map +1 -1
  349. package/build/types/integrations/tracing/koa.d.ts.map +1 -1
  350. package/build/types/integrations/tracing/mongo.d.ts.map +1 -1
  351. package/build/types/integrations/tracing/mongoose.d.ts.map +1 -1
  352. package/build/types/integrations/tracing/mysql2.d.ts.map +1 -1
  353. package/build/types/integrations/tracing/postgres.d.ts.map +1 -1
  354. package/build/types/integrations/tracing/postgresjs.d.ts.map +1 -1
  355. package/build/types/integrations/tracing/vercelai/index.d.ts.map +1 -1
  356. package/build/types/integrations/winston.d.ts +44 -0
  357. package/build/types/integrations/winston.d.ts.map +1 -0
  358. package/build/types/logs/capture.d.ts +11 -0
  359. package/build/types/logs/capture.d.ts.map +1 -0
  360. package/build/types/logs/exports.d.ts +150 -0
  361. package/build/types/logs/exports.d.ts.map +1 -0
  362. package/build/types/nodeVersion.d.ts +8 -0
  363. package/build/types/nodeVersion.d.ts.map +1 -0
  364. package/build/types/otel/contextManager.d.ts +10 -0
  365. package/build/types/otel/contextManager.d.ts.map +1 -0
  366. package/build/types/otel/instrument.d.ts +23 -0
  367. package/build/types/otel/instrument.d.ts.map +1 -0
  368. package/build/types/proxy/base.d.ts +65 -0
  369. package/build/types/proxy/base.d.ts.map +1 -0
  370. package/build/types/proxy/helpers.d.ts +42 -0
  371. package/build/types/proxy/helpers.d.ts.map +1 -0
  372. package/build/types/proxy/index.d.ts +73 -0
  373. package/build/types/proxy/index.d.ts.map +1 -0
  374. package/build/types/proxy/parse-proxy-response.d.ts +43 -0
  375. package/build/types/proxy/parse-proxy-response.d.ts.map +1 -0
  376. package/build/types/sdk/api.d.ts +8 -0
  377. package/build/types/sdk/api.d.ts.map +1 -0
  378. package/build/types/sdk/client.d.ts +29 -0
  379. package/build/types/sdk/client.d.ts.map +1 -0
  380. package/build/types/sdk/index.d.ts +6 -2
  381. package/build/types/sdk/index.d.ts.map +1 -1
  382. package/build/types/sdk/initOtel.d.ts +1 -1
  383. package/build/types/sdk/initOtel.d.ts.map +1 -1
  384. package/build/types/sdk/scope.d.ts +7 -0
  385. package/build/types/sdk/scope.d.ts.map +1 -0
  386. package/build/types/transports/http-module.d.ts +31 -0
  387. package/build/types/transports/http-module.d.ts.map +1 -0
  388. package/build/types/transports/http.d.ts +21 -0
  389. package/build/types/transports/http.d.ts.map +1 -0
  390. package/build/types/transports/index.d.ts +3 -0
  391. package/build/types/transports/index.d.ts.map +1 -0
  392. package/build/types/types.d.ts +1 -1
  393. package/build/types/types.d.ts.map +1 -1
  394. package/build/types/utils/addOriginToSpan.d.ts +5 -0
  395. package/build/types/utils/addOriginToSpan.d.ts.map +1 -0
  396. package/build/types/utils/baggage.d.ts +6 -0
  397. package/build/types/utils/baggage.d.ts.map +1 -0
  398. package/build/types/utils/commonjs.d.ts +3 -0
  399. package/build/types/utils/commonjs.d.ts.map +1 -0
  400. package/build/types/utils/createMissingInstrumentationContext.d.ts +3 -0
  401. package/build/types/utils/createMissingInstrumentationContext.d.ts.map +1 -0
  402. package/build/types/utils/debug.d.ts +5 -0
  403. package/build/types/utils/debug.d.ts.map +1 -0
  404. package/build/types/utils/ensureIsWrapped.d.ts +5 -0
  405. package/build/types/utils/ensureIsWrapped.d.ts.map +1 -0
  406. package/build/types/utils/entry-point.d.ts +24 -0
  407. package/build/types/utils/entry-point.d.ts.map +1 -0
  408. package/build/types/utils/envToBool.d.ts +13 -0
  409. package/build/types/utils/envToBool.d.ts.map +1 -0
  410. package/build/types/utils/errorhandling.d.ts +5 -0
  411. package/build/types/utils/errorhandling.d.ts.map +1 -0
  412. package/build/types/utils/getRequestUrl.d.ts +5 -0
  413. package/build/types/utils/getRequestUrl.d.ts.map +1 -0
  414. package/build/types/utils/module.d.ts +3 -0
  415. package/build/types/utils/module.d.ts.map +1 -0
  416. package/build/types/utils/prepareEvent.d.ts +17 -0
  417. package/build/types/utils/prepareEvent.d.ts.map +1 -0
  418. package/build/types-ts3.8/cron/common.d.ts +5 -0
  419. package/build/types-ts3.8/cron/cron.d.ts +43 -0
  420. package/build/types-ts3.8/cron/index.d.ts +10 -0
  421. package/build/types-ts3.8/cron/node-cron.d.ts +27 -0
  422. package/build/types-ts3.8/cron/node-schedule.d.ts +19 -0
  423. package/build/types-ts3.8/index.d.ts +21 -2
  424. package/build/types-ts3.8/integrations/anr/common.d.ts +52 -0
  425. package/build/types-ts3.8/integrations/anr/index.d.ts +13 -0
  426. package/build/types-ts3.8/integrations/anr/worker.d.ts +2 -0
  427. package/build/types-ts3.8/integrations/childProcess.d.ts +20 -0
  428. package/build/types-ts3.8/integrations/context.d.ts +30 -0
  429. package/build/types-ts3.8/integrations/contextlines.d.ts +31 -0
  430. package/build/types-ts3.8/integrations/http/SentryHttpInstrumentation.d.ts +133 -0
  431. package/build/types-ts3.8/integrations/http/index.d.ts +1 -1
  432. package/build/types-ts3.8/integrations/local-variables/common.d.ts +66 -0
  433. package/build/types-ts3.8/integrations/local-variables/index.d.ts +4 -0
  434. package/build/types-ts3.8/integrations/local-variables/local-variables-async.d.ts +7 -0
  435. package/build/types-ts3.8/integrations/local-variables/local-variables-sync.d.ts +34 -0
  436. package/build/types-ts3.8/integrations/local-variables/worker.d.ts +2 -0
  437. package/build/types-ts3.8/integrations/modules.d.ts +17 -0
  438. package/build/types-ts3.8/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts +56 -0
  439. package/build/types-ts3.8/integrations/onuncaughtexception.d.ts +31 -0
  440. package/build/types-ts3.8/integrations/onunhandledrejection.d.ts +23 -0
  441. package/build/types-ts3.8/integrations/processSession.d.ts +5 -0
  442. package/build/types-ts3.8/integrations/spotlight.d.ts +18 -0
  443. package/build/types-ts3.8/integrations/winston.d.ts +44 -0
  444. package/build/types-ts3.8/logs/capture.d.ts +18 -0
  445. package/build/types-ts3.8/logs/exports.d.ts +150 -0
  446. package/build/types-ts3.8/nodeVersion.d.ts +8 -0
  447. package/build/types-ts3.8/otel/contextManager.d.ts +10 -0
  448. package/build/types-ts3.8/otel/instrument.d.ts +23 -0
  449. package/build/types-ts3.8/proxy/base.d.ts +60 -0
  450. package/build/types-ts3.8/proxy/helpers.d.ts +38 -0
  451. package/build/types-ts3.8/proxy/index.d.ts +74 -0
  452. package/build/types-ts3.8/proxy/parse-proxy-response.d.ts +40 -0
  453. package/build/types-ts3.8/sdk/api.d.ts +8 -0
  454. package/build/types-ts3.8/sdk/client.d.ts +32 -0
  455. package/build/types-ts3.8/sdk/index.d.ts +6 -2
  456. package/build/types-ts3.8/sdk/initOtel.d.ts +1 -1
  457. package/build/types-ts3.8/sdk/scope.d.ts +7 -0
  458. package/build/types-ts3.8/transports/http-module.d.ts +28 -0
  459. package/build/types-ts3.8/transports/http.d.ts +20 -0
  460. package/build/types-ts3.8/transports/index.d.ts +3 -0
  461. package/build/types-ts3.8/types.d.ts +1 -1
  462. package/build/types-ts3.8/utils/addOriginToSpan.d.ts +5 -0
  463. package/build/types-ts3.8/utils/baggage.d.ts +6 -0
  464. package/build/types-ts3.8/utils/commonjs.d.ts +3 -0
  465. package/build/types-ts3.8/utils/createMissingInstrumentationContext.d.ts +3 -0
  466. package/build/types-ts3.8/utils/debug.d.ts +5 -0
  467. package/build/types-ts3.8/utils/ensureIsWrapped.d.ts +5 -0
  468. package/build/types-ts3.8/utils/entry-point.d.ts +24 -0
  469. package/build/types-ts3.8/utils/envToBool.d.ts +13 -0
  470. package/build/types-ts3.8/utils/errorhandling.d.ts +5 -0
  471. package/build/types-ts3.8/utils/getRequestUrl.d.ts +5 -0
  472. package/build/types-ts3.8/utils/module.d.ts +3 -0
  473. package/build/types-ts3.8/utils/prepareEvent.d.ts +17 -0
  474. package/package.json +3 -4
@@ -0,0 +1,410 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const nodeVersion = require('../../nodeVersion.js');
5
+ const debug = require('../../utils/debug.js');
6
+ const common = require('./common.js');
7
+
8
+ /** Creates a unique hash from stack frames */
9
+ function hashFrames(frames) {
10
+ if (frames === undefined) {
11
+ return;
12
+ }
13
+
14
+ // Only hash the 10 most recent frames (ie. the last 10)
15
+ return frames.slice(-10).reduce((acc, frame) => `${acc},${frame.function},${frame.lineno},${frame.colno}`, '');
16
+ }
17
+
18
+ /**
19
+ * We use the stack parser to create a unique hash from the exception stack trace
20
+ * This is used to lookup vars when the exception passes through the event processor
21
+ */
22
+ function hashFromStack(stackParser, stack) {
23
+ if (stack === undefined) {
24
+ return undefined;
25
+ }
26
+
27
+ return hashFrames(stackParser(stack, 1));
28
+ }
29
+
30
+ /** Creates a container for callbacks to be called sequentially */
31
+ function createCallbackList(complete) {
32
+ // A collection of callbacks to be executed last to first
33
+ let callbacks = [];
34
+
35
+ let completedCalled = false;
36
+ function checkedComplete(result) {
37
+ callbacks = [];
38
+ if (completedCalled) {
39
+ return;
40
+ }
41
+ completedCalled = true;
42
+ complete(result);
43
+ }
44
+
45
+ // complete should be called last
46
+ callbacks.push(checkedComplete);
47
+
48
+ function add(fn) {
49
+ callbacks.push(fn);
50
+ }
51
+
52
+ function next(result) {
53
+ const popped = callbacks.pop() || checkedComplete;
54
+
55
+ try {
56
+ popped(result);
57
+ } catch (_) {
58
+ // If there is an error, we still want to call the complete callback
59
+ checkedComplete(result);
60
+ }
61
+ }
62
+
63
+ return { add, next };
64
+ }
65
+
66
+ /**
67
+ * Promise API is available as `Experimental` and in Node 19 only.
68
+ *
69
+ * Callback-based API is `Stable` since v14 and `Experimental` since v8.
70
+ * Because of that, we are creating our own `AsyncSession` class.
71
+ *
72
+ * https://nodejs.org/docs/latest-v19.x/api/inspector.html#promises-api
73
+ * https://nodejs.org/docs/latest-v14.x/api/inspector.html
74
+ */
75
+ class AsyncSession {
76
+ /** Throws if inspector API is not available */
77
+ constructor( _session) {this._session = _session;
78
+ //
79
+ }
80
+
81
+ static async create(orDefault) {
82
+ if (orDefault) {
83
+ return orDefault;
84
+ }
85
+
86
+ const inspector = await import('node:inspector');
87
+ return new AsyncSession(new inspector.Session());
88
+ }
89
+
90
+ /** @inheritdoc */
91
+ configureAndConnect(onPause, captureAll) {
92
+ this._session.connect();
93
+
94
+ this._session.on('Debugger.paused', event => {
95
+ onPause(event, () => {
96
+ // After the pause work is complete, resume execution or the exception context memory is leaked
97
+ this._session.post('Debugger.resume');
98
+ });
99
+ });
100
+
101
+ this._session.post('Debugger.enable');
102
+ this._session.post('Debugger.setPauseOnExceptions', { state: captureAll ? 'all' : 'uncaught' });
103
+ }
104
+
105
+ setPauseOnExceptions(captureAll) {
106
+ this._session.post('Debugger.setPauseOnExceptions', { state: captureAll ? 'all' : 'uncaught' });
107
+ }
108
+
109
+ /** @inheritdoc */
110
+ getLocalVariables(objectId, complete) {
111
+ this._getProperties(objectId, props => {
112
+ const { add, next } = createCallbackList(complete);
113
+
114
+ for (const prop of props) {
115
+ if (prop.value?.objectId && prop.value.className === 'Array') {
116
+ const id = prop.value.objectId;
117
+ add(vars => this._unrollArray(id, prop.name, vars, next));
118
+ } else if (prop.value?.objectId && prop.value.className === 'Object') {
119
+ const id = prop.value.objectId;
120
+ add(vars => this._unrollObject(id, prop.name, vars, next));
121
+ } else if (prop.value) {
122
+ add(vars => this._unrollOther(prop, vars, next));
123
+ }
124
+ }
125
+
126
+ next({});
127
+ });
128
+ }
129
+
130
+ /**
131
+ * Gets all the PropertyDescriptors of an object
132
+ */
133
+ _getProperties(objectId, next) {
134
+ this._session.post(
135
+ 'Runtime.getProperties',
136
+ {
137
+ objectId,
138
+ ownProperties: true,
139
+ },
140
+ (err, params) => {
141
+ if (err) {
142
+ next([]);
143
+ } else {
144
+ next(params.result);
145
+ }
146
+ },
147
+ );
148
+ }
149
+
150
+ /**
151
+ * Unrolls an array property
152
+ */
153
+ _unrollArray(objectId, name, vars, next) {
154
+ this._getProperties(objectId, props => {
155
+ vars[name] = props
156
+ .filter(v => v.name !== 'length' && !isNaN(parseInt(v.name, 10)))
157
+ .sort((a, b) => parseInt(a.name, 10) - parseInt(b.name, 10))
158
+ .map(v => v.value?.value);
159
+
160
+ next(vars);
161
+ });
162
+ }
163
+
164
+ /**
165
+ * Unrolls an object property
166
+ */
167
+ _unrollObject(objectId, name, vars, next) {
168
+ this._getProperties(objectId, props => {
169
+ vars[name] = props
170
+ .map(v => [v.name, v.value?.value])
171
+ .reduce((obj, [key, val]) => {
172
+ obj[key] = val;
173
+ return obj;
174
+ }, {} );
175
+
176
+ next(vars);
177
+ });
178
+ }
179
+
180
+ /**
181
+ * Unrolls other properties
182
+ */
183
+ _unrollOther(prop, vars, next) {
184
+ if (prop.value) {
185
+ if ('value' in prop.value) {
186
+ if (prop.value.value === undefined || prop.value.value === null) {
187
+ vars[prop.name] = `<${prop.value.value}>`;
188
+ } else {
189
+ vars[prop.name] = prop.value.value;
190
+ }
191
+ } else if ('description' in prop.value && prop.value.type !== 'function') {
192
+ vars[prop.name] = `<${prop.value.description}>`;
193
+ } else if (prop.value.type === 'undefined') {
194
+ vars[prop.name] = '<undefined>';
195
+ }
196
+ }
197
+
198
+ next(vars);
199
+ }
200
+ }
201
+
202
+ const INTEGRATION_NAME = 'LocalVariables';
203
+
204
+ /**
205
+ * Adds local variables to exception frames
206
+ */
207
+ const _localVariablesSyncIntegration = ((
208
+ options = {},
209
+ sessionOverride,
210
+ ) => {
211
+ const cachedFrames = new core.LRUMap(20);
212
+ let rateLimiter;
213
+ let shouldProcessEvent = false;
214
+
215
+ function addLocalVariablesToException(exception) {
216
+ const hash = hashFrames(exception.stacktrace?.frames);
217
+
218
+ if (hash === undefined) {
219
+ return;
220
+ }
221
+
222
+ // Check if we have local variables for an exception that matches the hash
223
+ // remove is identical to get but also removes the entry from the cache
224
+ const cachedFrame = cachedFrames.remove(hash);
225
+
226
+ if (cachedFrame === undefined) {
227
+ return;
228
+ }
229
+
230
+ // Filter out frames where the function name is `new Promise` since these are in the error.stack frames
231
+ // but do not appear in the debugger call frames
232
+ const frames = (exception.stacktrace?.frames || []).filter(frame => frame.function !== 'new Promise');
233
+
234
+ for (let i = 0; i < frames.length; i++) {
235
+ // Sentry frames are in reverse order
236
+ const frameIndex = frames.length - i - 1;
237
+
238
+ const cachedFrameVariable = cachedFrame[i];
239
+ const frameVariable = frames[frameIndex];
240
+
241
+ // Drop out if we run out of frames to match up
242
+ if (!frameVariable || !cachedFrameVariable) {
243
+ break;
244
+ }
245
+
246
+ if (
247
+ // We need to have vars to add
248
+ cachedFrameVariable.vars === undefined ||
249
+ // We're not interested in frames that are not in_app because the vars are not relevant
250
+ frameVariable.in_app === false ||
251
+ // The function names need to match
252
+ !common.functionNamesMatch(frameVariable.function, cachedFrameVariable.function)
253
+ ) {
254
+ continue;
255
+ }
256
+
257
+ frameVariable.vars = cachedFrameVariable.vars;
258
+ }
259
+ }
260
+
261
+ function addLocalVariablesToEvent(event) {
262
+ for (const exception of event.exception?.values || []) {
263
+ addLocalVariablesToException(exception);
264
+ }
265
+
266
+ return event;
267
+ }
268
+
269
+ return {
270
+ name: INTEGRATION_NAME,
271
+ async setupOnce() {
272
+ const client = core.getClient();
273
+ const clientOptions = client?.getOptions();
274
+
275
+ if (!clientOptions?.includeLocalVariables) {
276
+ return;
277
+ }
278
+
279
+ // Only setup this integration if the Node version is >= v18
280
+ // https://github.com/getsentry/sentry-javascript/issues/7697
281
+ const unsupportedNodeVersion = nodeVersion.NODE_MAJOR < 18;
282
+
283
+ if (unsupportedNodeVersion) {
284
+ core.logger.log('The `LocalVariables` integration is only supported on Node >= v18.');
285
+ return;
286
+ }
287
+
288
+ if (await debug.isDebuggerEnabled()) {
289
+ core.logger.warn('Local variables capture has been disabled because the debugger was already enabled');
290
+ return;
291
+ }
292
+
293
+ AsyncSession.create(sessionOverride).then(
294
+ session => {
295
+ function handlePaused(
296
+ stackParser,
297
+ { params: { reason, data, callFrames } },
298
+ complete,
299
+ ) {
300
+ if (reason !== 'exception' && reason !== 'promiseRejection') {
301
+ complete();
302
+ return;
303
+ }
304
+
305
+ rateLimiter?.();
306
+
307
+ // data.description contains the original error.stack
308
+ const exceptionHash = hashFromStack(stackParser, data.description);
309
+
310
+ if (exceptionHash == undefined) {
311
+ complete();
312
+ return;
313
+ }
314
+
315
+ const { add, next } = createCallbackList(frames => {
316
+ cachedFrames.set(exceptionHash, frames);
317
+ complete();
318
+ });
319
+
320
+ // Because we're queuing up and making all these calls synchronously, we can potentially overflow the stack
321
+ // For this reason we only attempt to get local variables for the first 5 frames
322
+ for (let i = 0; i < Math.min(callFrames.length, 5); i++) {
323
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
324
+ const { scopeChain, functionName, this: obj } = callFrames[i];
325
+
326
+ const localScope = scopeChain.find(scope => scope.type === 'local');
327
+
328
+ // obj.className is undefined in ESM modules
329
+ const fn =
330
+ obj.className === 'global' || !obj.className ? functionName : `${obj.className}.${functionName}`;
331
+
332
+ if (localScope?.object.objectId === undefined) {
333
+ add(frames => {
334
+ frames[i] = { function: fn };
335
+ next(frames);
336
+ });
337
+ } else {
338
+ const id = localScope.object.objectId;
339
+ add(frames =>
340
+ session.getLocalVariables(id, vars => {
341
+ frames[i] = { function: fn, vars };
342
+ next(frames);
343
+ }),
344
+ );
345
+ }
346
+ }
347
+
348
+ next([]);
349
+ }
350
+
351
+ const captureAll = options.captureAllExceptions !== false;
352
+
353
+ session.configureAndConnect(
354
+ (ev, complete) =>
355
+ handlePaused(clientOptions.stackParser, ev , complete),
356
+ captureAll,
357
+ );
358
+
359
+ if (captureAll) {
360
+ const max = options.maxExceptionsPerSecond || 50;
361
+
362
+ rateLimiter = common.createRateLimiter(
363
+ max,
364
+ () => {
365
+ core.logger.log('Local variables rate-limit lifted.');
366
+ session.setPauseOnExceptions(true);
367
+ },
368
+ seconds => {
369
+ core.logger.log(
370
+ `Local variables rate-limit exceeded. Disabling capturing of caught exceptions for ${seconds} seconds.`,
371
+ );
372
+ session.setPauseOnExceptions(false);
373
+ },
374
+ );
375
+ }
376
+
377
+ shouldProcessEvent = true;
378
+ },
379
+ error => {
380
+ core.logger.log('The `LocalVariables` integration failed to start.', error);
381
+ },
382
+ );
383
+ },
384
+ processEvent(event) {
385
+ if (shouldProcessEvent) {
386
+ return addLocalVariablesToEvent(event);
387
+ }
388
+
389
+ return event;
390
+ },
391
+ // These are entirely for testing
392
+ _getCachedFramesCount() {
393
+ return cachedFrames.size;
394
+ },
395
+ _getFirstCachedFrame() {
396
+ return cachedFrames.values()[0];
397
+ },
398
+ };
399
+ }) ;
400
+
401
+ /**
402
+ * Adds local variables to exception frames.
403
+ */
404
+ const localVariablesSyncIntegration = core.defineIntegration(_localVariablesSyncIntegration);
405
+
406
+ exports.createCallbackList = createCallbackList;
407
+ exports.hashFrames = hashFrames;
408
+ exports.hashFromStack = hashFromStack;
409
+ exports.localVariablesSyncIntegration = localVariablesSyncIntegration;
410
+ //# sourceMappingURL=local-variables-sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-variables-sync.js","sources":["../../../../src/integrations/local-variables/local-variables-sync.ts"],"sourcesContent":["import type { Debugger, InspectorNotification, Runtime, Session } from 'node:inspector';\nimport type { Event, Exception, IntegrationFn, StackFrame, StackParser } from '@sentry/core';\nimport { defineIntegration, getClient, logger, LRUMap } from '@sentry/core';\nimport { NODE_MAJOR } from '../../nodeVersion';\nimport type { NodeClient } from '../../sdk/client';\nimport { isDebuggerEnabled } from '../../utils/debug';\nimport type {\n FrameVariables,\n LocalVariablesIntegrationOptions,\n PausedExceptionEvent,\n RateLimitIncrement,\n Variables,\n} from './common';\nimport { createRateLimiter, functionNamesMatch } from './common';\n\n/** Creates a unique hash from stack frames */\nexport function hashFrames(frames: StackFrame[] | undefined): string | undefined {\n if (frames === undefined) {\n return;\n }\n\n // Only hash the 10 most recent frames (ie. the last 10)\n return frames.slice(-10).reduce((acc, frame) => `${acc},${frame.function},${frame.lineno},${frame.colno}`, '');\n}\n\n/**\n * We use the stack parser to create a unique hash from the exception stack trace\n * This is used to lookup vars when the exception passes through the event processor\n */\nexport function hashFromStack(stackParser: StackParser, stack: string | undefined): string | undefined {\n if (stack === undefined) {\n return undefined;\n }\n\n return hashFrames(stackParser(stack, 1));\n}\n\ntype OnPauseEvent = InspectorNotification<Debugger.PausedEventDataType>;\nexport interface DebugSession {\n /** Configures and connects to the debug session */\n configureAndConnect(onPause: (message: OnPauseEvent, complete: () => void) => void, captureAll: boolean): void;\n /** Updates which kind of exceptions to capture */\n setPauseOnExceptions(captureAll: boolean): void;\n /** Gets local variables for an objectId */\n getLocalVariables(objectId: string, callback: (vars: Variables) => void): void;\n}\n\ntype Next<T> = (result: T) => void;\ntype Add<T> = (fn: Next<T>) => void;\ntype CallbackWrapper<T> = { add: Add<T>; next: Next<T> };\n\n/** Creates a container for callbacks to be called sequentially */\nexport function createCallbackList<T>(complete: Next<T>): CallbackWrapper<T> {\n // A collection of callbacks to be executed last to first\n let callbacks: Next<T>[] = [];\n\n let completedCalled = false;\n function checkedComplete(result: T): void {\n callbacks = [];\n if (completedCalled) {\n return;\n }\n completedCalled = true;\n complete(result);\n }\n\n // complete should be called last\n callbacks.push(checkedComplete);\n\n function add(fn: Next<T>): void {\n callbacks.push(fn);\n }\n\n function next(result: T): void {\n const popped = callbacks.pop() || checkedComplete;\n\n try {\n popped(result);\n } catch (_) {\n // If there is an error, we still want to call the complete callback\n checkedComplete(result);\n }\n }\n\n return { add, next };\n}\n\n/**\n * Promise API is available as `Experimental` and in Node 19 only.\n *\n * Callback-based API is `Stable` since v14 and `Experimental` since v8.\n * Because of that, we are creating our own `AsyncSession` class.\n *\n * https://nodejs.org/docs/latest-v19.x/api/inspector.html#promises-api\n * https://nodejs.org/docs/latest-v14.x/api/inspector.html\n */\nclass AsyncSession implements DebugSession {\n /** Throws if inspector API is not available */\n private constructor(private readonly _session: Session) {\n //\n }\n\n public static async create(orDefault?: DebugSession | undefined): Promise<DebugSession> {\n if (orDefault) {\n return orDefault;\n }\n\n const inspector = await import('node:inspector');\n return new AsyncSession(new inspector.Session());\n }\n\n /** @inheritdoc */\n public configureAndConnect(onPause: (event: OnPauseEvent, complete: () => void) => void, captureAll: boolean): void {\n this._session.connect();\n\n this._session.on('Debugger.paused', event => {\n onPause(event, () => {\n // After the pause work is complete, resume execution or the exception context memory is leaked\n this._session.post('Debugger.resume');\n });\n });\n\n this._session.post('Debugger.enable');\n this._session.post('Debugger.setPauseOnExceptions', { state: captureAll ? 'all' : 'uncaught' });\n }\n\n public setPauseOnExceptions(captureAll: boolean): void {\n this._session.post('Debugger.setPauseOnExceptions', { state: captureAll ? 'all' : 'uncaught' });\n }\n\n /** @inheritdoc */\n public getLocalVariables(objectId: string, complete: (vars: Variables) => void): void {\n this._getProperties(objectId, props => {\n const { add, next } = createCallbackList<Variables>(complete);\n\n for (const prop of props) {\n if (prop.value?.objectId && prop.value.className === 'Array') {\n const id = prop.value.objectId;\n add(vars => this._unrollArray(id, prop.name, vars, next));\n } else if (prop.value?.objectId && prop.value.className === 'Object') {\n const id = prop.value.objectId;\n add(vars => this._unrollObject(id, prop.name, vars, next));\n } else if (prop.value) {\n add(vars => this._unrollOther(prop, vars, next));\n }\n }\n\n next({});\n });\n }\n\n /**\n * Gets all the PropertyDescriptors of an object\n */\n private _getProperties(objectId: string, next: (result: Runtime.PropertyDescriptor[]) => void): void {\n this._session.post(\n 'Runtime.getProperties',\n {\n objectId,\n ownProperties: true,\n },\n (err, params) => {\n if (err) {\n next([]);\n } else {\n next(params.result);\n }\n },\n );\n }\n\n /**\n * Unrolls an array property\n */\n private _unrollArray(objectId: string, name: string, vars: Variables, next: (vars: Variables) => void): void {\n this._getProperties(objectId, props => {\n vars[name] = props\n .filter(v => v.name !== 'length' && !isNaN(parseInt(v.name, 10)))\n .sort((a, b) => parseInt(a.name, 10) - parseInt(b.name, 10))\n .map(v => v.value?.value);\n\n next(vars);\n });\n }\n\n /**\n * Unrolls an object property\n */\n private _unrollObject(objectId: string, name: string, vars: Variables, next: (obj: Variables) => void): void {\n this._getProperties(objectId, props => {\n vars[name] = props\n .map<[string, unknown]>(v => [v.name, v.value?.value])\n .reduce((obj, [key, val]) => {\n obj[key] = val;\n return obj;\n }, {} as Variables);\n\n next(vars);\n });\n }\n\n /**\n * Unrolls other properties\n */\n private _unrollOther(prop: Runtime.PropertyDescriptor, vars: Variables, next: (vars: Variables) => void): void {\n if (prop.value) {\n if ('value' in prop.value) {\n if (prop.value.value === undefined || prop.value.value === null) {\n vars[prop.name] = `<${prop.value.value}>`;\n } else {\n vars[prop.name] = prop.value.value;\n }\n } else if ('description' in prop.value && prop.value.type !== 'function') {\n vars[prop.name] = `<${prop.value.description}>`;\n } else if (prop.value.type === 'undefined') {\n vars[prop.name] = '<undefined>';\n }\n }\n\n next(vars);\n }\n}\n\nconst INTEGRATION_NAME = 'LocalVariables';\n\n/**\n * Adds local variables to exception frames\n */\nconst _localVariablesSyncIntegration = ((\n options: LocalVariablesIntegrationOptions = {},\n sessionOverride?: DebugSession,\n) => {\n const cachedFrames: LRUMap<string, FrameVariables[]> = new LRUMap(20);\n let rateLimiter: RateLimitIncrement | undefined;\n let shouldProcessEvent = false;\n\n function addLocalVariablesToException(exception: Exception): void {\n const hash = hashFrames(exception.stacktrace?.frames);\n\n if (hash === undefined) {\n return;\n }\n\n // Check if we have local variables for an exception that matches the hash\n // remove is identical to get but also removes the entry from the cache\n const cachedFrame = cachedFrames.remove(hash);\n\n if (cachedFrame === undefined) {\n return;\n }\n\n // Filter out frames where the function name is `new Promise` since these are in the error.stack frames\n // but do not appear in the debugger call frames\n const frames = (exception.stacktrace?.frames || []).filter(frame => frame.function !== 'new Promise');\n\n for (let i = 0; i < frames.length; i++) {\n // Sentry frames are in reverse order\n const frameIndex = frames.length - i - 1;\n\n const cachedFrameVariable = cachedFrame[i];\n const frameVariable = frames[frameIndex];\n\n // Drop out if we run out of frames to match up\n if (!frameVariable || !cachedFrameVariable) {\n break;\n }\n\n if (\n // We need to have vars to add\n cachedFrameVariable.vars === undefined ||\n // We're not interested in frames that are not in_app because the vars are not relevant\n frameVariable.in_app === false ||\n // The function names need to match\n !functionNamesMatch(frameVariable.function, cachedFrameVariable.function)\n ) {\n continue;\n }\n\n frameVariable.vars = cachedFrameVariable.vars;\n }\n }\n\n function addLocalVariablesToEvent(event: Event): Event {\n for (const exception of event.exception?.values || []) {\n addLocalVariablesToException(exception);\n }\n\n return event;\n }\n\n return {\n name: INTEGRATION_NAME,\n async setupOnce() {\n const client = getClient<NodeClient>();\n const clientOptions = client?.getOptions();\n\n if (!clientOptions?.includeLocalVariables) {\n return;\n }\n\n // Only setup this integration if the Node version is >= v18\n // https://github.com/getsentry/sentry-javascript/issues/7697\n const unsupportedNodeVersion = NODE_MAJOR < 18;\n\n if (unsupportedNodeVersion) {\n logger.log('The `LocalVariables` integration is only supported on Node >= v18.');\n return;\n }\n\n if (await isDebuggerEnabled()) {\n logger.warn('Local variables capture has been disabled because the debugger was already enabled');\n return;\n }\n\n AsyncSession.create(sessionOverride).then(\n session => {\n function handlePaused(\n stackParser: StackParser,\n { params: { reason, data, callFrames } }: InspectorNotification<PausedExceptionEvent>,\n complete: () => void,\n ): void {\n if (reason !== 'exception' && reason !== 'promiseRejection') {\n complete();\n return;\n }\n\n rateLimiter?.();\n\n // data.description contains the original error.stack\n const exceptionHash = hashFromStack(stackParser, data.description);\n\n if (exceptionHash == undefined) {\n complete();\n return;\n }\n\n const { add, next } = createCallbackList<FrameVariables[]>(frames => {\n cachedFrames.set(exceptionHash, frames);\n complete();\n });\n\n // Because we're queuing up and making all these calls synchronously, we can potentially overflow the stack\n // For this reason we only attempt to get local variables for the first 5 frames\n for (let i = 0; i < Math.min(callFrames.length, 5); i++) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const { scopeChain, functionName, this: obj } = callFrames[i]!;\n\n const localScope = scopeChain.find(scope => scope.type === 'local');\n\n // obj.className is undefined in ESM modules\n const fn =\n obj.className === 'global' || !obj.className ? functionName : `${obj.className}.${functionName}`;\n\n if (localScope?.object.objectId === undefined) {\n add(frames => {\n frames[i] = { function: fn };\n next(frames);\n });\n } else {\n const id = localScope.object.objectId;\n add(frames =>\n session.getLocalVariables(id, vars => {\n frames[i] = { function: fn, vars };\n next(frames);\n }),\n );\n }\n }\n\n next([]);\n }\n\n const captureAll = options.captureAllExceptions !== false;\n\n session.configureAndConnect(\n (ev, complete) =>\n handlePaused(clientOptions.stackParser, ev as InspectorNotification<PausedExceptionEvent>, complete),\n captureAll,\n );\n\n if (captureAll) {\n const max = options.maxExceptionsPerSecond || 50;\n\n rateLimiter = createRateLimiter(\n max,\n () => {\n logger.log('Local variables rate-limit lifted.');\n session.setPauseOnExceptions(true);\n },\n seconds => {\n logger.log(\n `Local variables rate-limit exceeded. Disabling capturing of caught exceptions for ${seconds} seconds.`,\n );\n session.setPauseOnExceptions(false);\n },\n );\n }\n\n shouldProcessEvent = true;\n },\n error => {\n logger.log('The `LocalVariables` integration failed to start.', error);\n },\n );\n },\n processEvent(event: Event): Event {\n if (shouldProcessEvent) {\n return addLocalVariablesToEvent(event);\n }\n\n return event;\n },\n // These are entirely for testing\n _getCachedFramesCount(): number {\n return cachedFrames.size;\n },\n _getFirstCachedFrame(): FrameVariables[] | undefined {\n return cachedFrames.values()[0];\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds local variables to exception frames.\n */\nexport const localVariablesSyncIntegration = defineIntegration(_localVariablesSyncIntegration);\n"],"names":["LRUMap","functionNamesMatch","getClient","NODE_MAJOR","logger","isDebuggerEnabled","createRateLimiter","defineIntegration"],"mappings":";;;;;;;AAeA;AACO,SAAS,UAAU,CAAC,MAAM,EAAgD;AACjF,EAAE,IAAI,MAAO,KAAI,SAAS,EAAE;AAC5B,IAAI;AACJ;;AAEA;AACA,EAAE,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,KAAK,CAAC,EAAA,GAAA,CAAA,CAAA,EAAA,KAAA,CAAA,QAAA,CAAA,CAAA,EAAA,KAAA,CAAA,MAAA,CAAA,CAAA,EAAA,KAAA,CAAA,KAAA,CAAA,CAAA,EAAA,EAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAA,aAAA,CAAA,WAAA,EAAA,KAAA,EAAA;AACA,EAAA,IAAA,KAAA,KA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,IAAA;AACA,gBAAAA,WAAA,CAAA,GAAA;AACA,kBAAA,CAAA,kFAAA,EAAA,OAAA,CAAA,SAAA,CAAA;AACA,iBAAA;AACA,gBAAA,OAAA,CAAA,oBAAA,CAAA,KAAA,CAAA;AACA,eAAA;AACA,aAAA;AACA;;AAEA,UAAA,kBAAA,GAAA,IAAA;AACA,SAAA;AACA,QAAA,KAAA,IAAA;AACA,UAAAA,WAAA,CAAA,GAAA,CAAA,mDAAA,EAAA,KAAA,CAAA;AACA,SAAA;AACA,OAAA;AACA,KAAA;AACA,IAAA,YAAA,CAAA,KAAA,EAAA;AACA,MAAA,IAAA,kBAAA,EAAA;AACA,QAAA,OAAA,wBAAA,CAAA,KAAA,CAAA;AACA;;AAEA,MAAA,OAAA,KAAA;AACA,KAAA;AACA;AACA,IAAA,qBAAA,GAAA;AACA,MAAA,OAAA,YAAA,CAAA,IAAA;AACA,KAAA;AACA,IAAA,oBAAA,GAAA;AACA,MAAA,OAAA,YAAA,CAAA,MAAA,EAAA,CAAA,CAAA,CAAA;AACA,KAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA,MAAA,6BAAA,GAAAG,sBAAA,CAAA,8BAAA;;;;;;;"}
@@ -0,0 +1,135 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const node_fs = require('node:fs');
4
+ const node_path = require('node:path');
5
+ const commonjs = require('../utils/commonjs.js');
6
+
7
+ let moduleCache;
8
+
9
+ const INTEGRATION_NAME = 'Modules';
10
+
11
+ /**
12
+ * `__SENTRY_SERVER_MODULES__` can be replaced at build time with the modules loaded by the server.
13
+ * Right now, we leverage this in Next.js to circumvent the problem that we do not get access to these things at runtime.
14
+ */
15
+ const SERVER_MODULES = typeof __SENTRY_SERVER_MODULES__ === 'undefined' ? {} : __SENTRY_SERVER_MODULES__;
16
+
17
+ const _modulesIntegration = (() => {
18
+ return {
19
+ name: INTEGRATION_NAME,
20
+ processEvent(event) {
21
+ event.modules = {
22
+ ...event.modules,
23
+ ..._getModules(),
24
+ };
25
+
26
+ return event;
27
+ },
28
+ getModules: _getModules,
29
+ };
30
+ }) ;
31
+
32
+ /**
33
+ * Add node modules / packages to the event.
34
+ * For this, multiple sources are used:
35
+ * - They can be injected at build time into the __SENTRY_SERVER_MODULES__ variable (e.g. in Next.js)
36
+ * - They are extracted from the dependencies & devDependencies in the package.json file
37
+ * - They are extracted from the require.cache (CJS only)
38
+ */
39
+ const modulesIntegration = _modulesIntegration;
40
+
41
+ function getRequireCachePaths() {
42
+ try {
43
+ return require.cache ? Object.keys(require.cache ) : [];
44
+ } catch (e) {
45
+ return [];
46
+ }
47
+ }
48
+
49
+ /** Extract information about package.json modules */
50
+ function collectModules() {
51
+ return {
52
+ ...SERVER_MODULES,
53
+ ...getModulesFromPackageJson(),
54
+ ...(commonjs.isCjs() ? collectRequireModules() : {}),
55
+ };
56
+ }
57
+
58
+ /** Extract information about package.json modules from require.cache */
59
+ function collectRequireModules() {
60
+ const mainPaths = require.main?.paths || [];
61
+ const paths = getRequireCachePaths();
62
+
63
+ // We start with the modules from package.json (if possible)
64
+ // These may be overwritten by more specific versions from the require.cache
65
+ const infos = {};
66
+ const seen = new Set();
67
+
68
+ paths.forEach(path => {
69
+ let dir = path;
70
+
71
+ /** Traverse directories upward in the search of package.json file */
72
+ const updir = () => {
73
+ const orig = dir;
74
+ dir = node_path.dirname(orig);
75
+
76
+ if (!dir || orig === dir || seen.has(orig)) {
77
+ return undefined;
78
+ }
79
+ if (mainPaths.indexOf(dir) < 0) {
80
+ return updir();
81
+ }
82
+
83
+ const pkgfile = node_path.join(orig, 'package.json');
84
+ seen.add(orig);
85
+
86
+ if (!node_fs.existsSync(pkgfile)) {
87
+ return updir();
88
+ }
89
+
90
+ try {
91
+ const info = JSON.parse(node_fs.readFileSync(pkgfile, 'utf8'))
92
+
93
+ ;
94
+ infos[info.name] = info.version;
95
+ } catch (_oO) {
96
+ // no-empty
97
+ }
98
+ };
99
+
100
+ updir();
101
+ });
102
+
103
+ return infos;
104
+ }
105
+
106
+ /** Fetches the list of modules and the versions loaded by the entry file for your node.js app. */
107
+ function _getModules() {
108
+ if (!moduleCache) {
109
+ moduleCache = collectModules();
110
+ }
111
+ return moduleCache;
112
+ }
113
+
114
+ function getPackageJson() {
115
+ try {
116
+ const filePath = node_path.join(process.cwd(), 'package.json');
117
+ const packageJson = JSON.parse(node_fs.readFileSync(filePath, 'utf8')) ;
118
+
119
+ return packageJson;
120
+ } catch (e) {
121
+ return {};
122
+ }
123
+ }
124
+
125
+ function getModulesFromPackageJson() {
126
+ const packageJson = getPackageJson();
127
+
128
+ return {
129
+ ...packageJson.dependencies,
130
+ ...packageJson.devDependencies,
131
+ };
132
+ }
133
+
134
+ exports.modulesIntegration = modulesIntegration;
135
+ //# sourceMappingURL=modules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules.js","sources":["../../../src/integrations/modules.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport type { IntegrationFn } from '@sentry/core';\nimport { isCjs } from '../utils/commonjs';\n\ntype ModuleInfo = Record<string, string>;\n\nlet moduleCache: ModuleInfo | undefined;\n\nconst INTEGRATION_NAME = 'Modules';\n\ndeclare const __SENTRY_SERVER_MODULES__: Record<string, string>;\n\n/**\n * `__SENTRY_SERVER_MODULES__` can be replaced at build time with the modules loaded by the server.\n * Right now, we leverage this in Next.js to circumvent the problem that we do not get access to these things at runtime.\n */\nconst SERVER_MODULES = typeof __SENTRY_SERVER_MODULES__ === 'undefined' ? {} : __SENTRY_SERVER_MODULES__;\n\nconst _modulesIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n processEvent(event) {\n event.modules = {\n ...event.modules,\n ..._getModules(),\n };\n\n return event;\n },\n getModules: _getModules,\n };\n}) satisfies IntegrationFn;\n\n/**\n * Add node modules / packages to the event.\n * For this, multiple sources are used:\n * - They can be injected at build time into the __SENTRY_SERVER_MODULES__ variable (e.g. in Next.js)\n * - They are extracted from the dependencies & devDependencies in the package.json file\n * - They are extracted from the require.cache (CJS only)\n */\nexport const modulesIntegration = _modulesIntegration;\n\nfunction getRequireCachePaths(): string[] {\n try {\n return require.cache ? Object.keys(require.cache as Record<string, unknown>) : [];\n } catch (e) {\n return [];\n }\n}\n\n/** Extract information about package.json modules */\nfunction collectModules(): ModuleInfo {\n return {\n ...SERVER_MODULES,\n ...getModulesFromPackageJson(),\n ...(isCjs() ? collectRequireModules() : {}),\n };\n}\n\n/** Extract information about package.json modules from require.cache */\nfunction collectRequireModules(): ModuleInfo {\n const mainPaths = require.main?.paths || [];\n const paths = getRequireCachePaths();\n\n // We start with the modules from package.json (if possible)\n // These may be overwritten by more specific versions from the require.cache\n const infos: ModuleInfo = {};\n const seen = new Set<string>();\n\n paths.forEach(path => {\n let dir = path;\n\n /** Traverse directories upward in the search of package.json file */\n const updir = (): void | (() => void) => {\n const orig = dir;\n dir = dirname(orig);\n\n if (!dir || orig === dir || seen.has(orig)) {\n return undefined;\n }\n if (mainPaths.indexOf(dir) < 0) {\n return updir();\n }\n\n const pkgfile = join(orig, 'package.json');\n seen.add(orig);\n\n if (!existsSync(pkgfile)) {\n return updir();\n }\n\n try {\n const info = JSON.parse(readFileSync(pkgfile, 'utf8')) as {\n name: string;\n version: string;\n };\n infos[info.name] = info.version;\n } catch (_oO) {\n // no-empty\n }\n };\n\n updir();\n });\n\n return infos;\n}\n\n/** Fetches the list of modules and the versions loaded by the entry file for your node.js app. */\nfunction _getModules(): ModuleInfo {\n if (!moduleCache) {\n moduleCache = collectModules();\n }\n return moduleCache;\n}\n\ninterface PackageJson {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n}\n\nfunction getPackageJson(): PackageJson {\n try {\n const filePath = join(process.cwd(), 'package.json');\n const packageJson = JSON.parse(readFileSync(filePath, 'utf8')) as PackageJson;\n\n return packageJson;\n } catch (e) {\n return {};\n }\n}\n\nfunction getModulesFromPackageJson(): ModuleInfo {\n const packageJson = getPackageJson();\n\n return {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n}\n"],"names":["isCjs","dirname","join","existsSync","readFileSync"],"mappings":";;;;;;AAOA,IAAI,WAAW;;AAEf,MAAM,gBAAA,GAAmB,SAAS;;AAIlC;AACA;AACA;AACA;AACA,MAAM,cAAA,GAAiB,OAAO,yBAA0B,KAAI,cAAc,EAAG,GAAE,yBAAyB;;AAExG,MAAM,mBAAoB,IAAG,MAAM;AACnC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,YAAY,CAAC,KAAK,EAAE;AACxB,MAAM,KAAK,CAAC,OAAA,GAAU;AACtB,QAAQ,GAAG,KAAK,CAAC,OAAO;AACxB,QAAQ,GAAG,WAAW,EAAE;AACxB,OAAO;;AAEP,MAAM,OAAO,KAAK;AAClB,KAAK;AACL,IAAI,UAAU,EAAE,WAAW;AAC3B,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,kBAAmB,GAAE;;AAElC,SAAS,oBAAoB,GAAa;AAC1C,EAAE,IAAI;AACN,IAAI,OAAO,OAAO,CAAC,KAAA,GAAQ,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAA,EAAkC,GAAE,EAAE;AACrF,GAAI,CAAA,OAAO,CAAC,EAAE;AACd,IAAI,OAAO,EAAE;AACb;AACA;;AAEA;AACA,SAAS,cAAc,GAAe;AACtC,EAAE,OAAO;AACT,IAAI,GAAG,cAAc;AACrB,IAAI,GAAG,yBAAyB,EAAE;AAClC,IAAI,IAAIA,cAAK,EAAG,GAAE,qBAAqB,EAAG,GAAE,EAAE,CAAC;AAC/C,GAAG;AACH;;AAEA;AACA,SAAS,qBAAqB,GAAe;AAC7C,EAAE,MAAM,SAAU,GAAE,OAAO,CAAC,IAAI,EAAE,KAAA,IAAS,EAAE;AAC7C,EAAE,MAAM,KAAA,GAAQ,oBAAoB,EAAE;;AAEt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