@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.
- package/build/cjs/cron/common.js +56 -0
- package/build/cjs/cron/common.js.map +1 -0
- package/build/cjs/cron/cron.js +112 -0
- package/build/cjs/cron/cron.js.map +1 -0
- package/build/cjs/cron/index.js +15 -0
- package/build/cjs/cron/index.js.map +1 -0
- package/build/cjs/cron/node-cron.js +71 -0
- package/build/cjs/cron/node-cron.js.map +1 -0
- package/build/cjs/cron/node-schedule.js +65 -0
- package/build/cjs/cron/node-schedule.js.map +1 -0
- package/build/cjs/index.js +56 -38
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/anr/index.js +238 -0
- package/build/cjs/integrations/anr/index.js.map +1 -0
- package/build/cjs/integrations/childProcess.js +100 -0
- package/build/cjs/integrations/childProcess.js.map +1 -0
- package/build/cjs/integrations/context.js +457 -0
- package/build/cjs/integrations/context.js.map +1 -0
- package/build/cjs/integrations/contextlines.js +405 -0
- package/build/cjs/integrations/contextlines.js.map +1 -0
- package/build/cjs/integrations/fs.js +2 -2
- package/build/cjs/integrations/fs.js.map +1 -1
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js +558 -0
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js.map +1 -0
- package/build/cjs/integrations/http/index.js +11 -7
- package/build/cjs/integrations/http/index.js.map +1 -1
- package/build/cjs/integrations/local-variables/common.js +69 -0
- package/build/cjs/integrations/local-variables/common.js.map +1 -0
- package/build/cjs/integrations/local-variables/index.js +12 -0
- package/build/cjs/integrations/local-variables/index.js.map +1 -0
- package/build/cjs/integrations/local-variables/local-variables-async.js +143 -0
- package/build/cjs/integrations/local-variables/local-variables-async.js.map +1 -0
- package/build/cjs/integrations/local-variables/local-variables-sync.js +410 -0
- package/build/cjs/integrations/local-variables/local-variables-sync.js.map +1 -0
- package/build/cjs/integrations/modules.js +135 -0
- package/build/cjs/integrations/modules.js.map +1 -0
- package/build/cjs/integrations/node-fetch/SentryNodeFetchInstrumentation.js +291 -0
- package/build/cjs/integrations/node-fetch/SentryNodeFetchInstrumentation.js.map +1 -0
- package/build/cjs/integrations/node-fetch/index.js +5 -4
- package/build/cjs/integrations/node-fetch/index.js.map +1 -1
- package/build/cjs/integrations/onuncaughtexception.js +134 -0
- package/build/cjs/integrations/onuncaughtexception.js.map +1 -0
- package/build/cjs/integrations/onunhandledrejection.js +89 -0
- package/build/cjs/integrations/onunhandledrejection.js.map +1 -0
- package/build/cjs/integrations/processSession.js +36 -0
- package/build/cjs/integrations/processSession.js.map +1 -0
- package/build/cjs/integrations/spotlight.js +101 -0
- package/build/cjs/integrations/spotlight.js.map +1 -0
- package/build/cjs/integrations/tracing/amqplib.js +5 -4
- package/build/cjs/integrations/tracing/amqplib.js.map +1 -1
- package/build/cjs/integrations/tracing/connect.js +4 -3
- package/build/cjs/integrations/tracing/connect.js.map +1 -1
- package/build/cjs/integrations/tracing/dataloader.js +3 -3
- package/build/cjs/integrations/tracing/dataloader.js.map +1 -1
- package/build/cjs/integrations/tracing/express.js +7 -5
- package/build/cjs/integrations/tracing/express.js.map +1 -1
- package/build/cjs/integrations/tracing/fastify/fastify-otel/index.js +3 -3
- package/build/cjs/integrations/tracing/fastify/fastify-otel/index.js.map +1 -1
- package/build/cjs/integrations/tracing/fastify/index.js +6 -6
- package/build/cjs/integrations/tracing/fastify/index.js.map +1 -1
- package/build/cjs/integrations/tracing/genericPool.js +3 -3
- package/build/cjs/integrations/tracing/genericPool.js.map +1 -1
- package/build/cjs/integrations/tracing/graphql.js +4 -3
- package/build/cjs/integrations/tracing/graphql.js.map +1 -1
- package/build/cjs/integrations/tracing/hapi/index.js +4 -3
- package/build/cjs/integrations/tracing/hapi/index.js.map +1 -1
- package/build/cjs/integrations/tracing/kafka.js +5 -4
- package/build/cjs/integrations/tracing/kafka.js.map +1 -1
- package/build/cjs/integrations/tracing/knex.js +3 -3
- package/build/cjs/integrations/tracing/knex.js.map +1 -1
- package/build/cjs/integrations/tracing/koa.js +6 -4
- package/build/cjs/integrations/tracing/koa.js.map +1 -1
- package/build/cjs/integrations/tracing/lrumemoizer.js +2 -2
- package/build/cjs/integrations/tracing/lrumemoizer.js.map +1 -1
- package/build/cjs/integrations/tracing/mongo.js +4 -3
- package/build/cjs/integrations/tracing/mongo.js.map +1 -1
- package/build/cjs/integrations/tracing/mongoose.js +4 -3
- package/build/cjs/integrations/tracing/mongoose.js.map +1 -1
- package/build/cjs/integrations/tracing/mysql.js +2 -2
- package/build/cjs/integrations/tracing/mysql.js.map +1 -1
- package/build/cjs/integrations/tracing/mysql2.js +4 -3
- package/build/cjs/integrations/tracing/mysql2.js.map +1 -1
- package/build/cjs/integrations/tracing/postgres.js +4 -3
- package/build/cjs/integrations/tracing/postgres.js.map +1 -1
- package/build/cjs/integrations/tracing/postgresjs.js +4 -3
- package/build/cjs/integrations/tracing/postgresjs.js.map +1 -1
- package/build/cjs/integrations/tracing/prisma.js +2 -2
- package/build/cjs/integrations/tracing/prisma.js.map +1 -1
- package/build/cjs/integrations/tracing/redis.js +3 -3
- package/build/cjs/integrations/tracing/redis.js.map +1 -1
- package/build/cjs/integrations/tracing/tedious.js +3 -3
- package/build/cjs/integrations/tracing/tedious.js.map +1 -1
- package/build/cjs/integrations/tracing/vercelai/index.js +2 -2
- package/build/cjs/integrations/tracing/vercelai/index.js.map +1 -1
- package/build/cjs/integrations/winston.js +151 -0
- package/build/cjs/integrations/winston.js.map +1 -0
- package/build/cjs/logs/capture.js +29 -0
- package/build/cjs/logs/capture.js.map +1 -0
- package/build/cjs/logs/exports.js +178 -0
- package/build/cjs/logs/exports.js.map +1 -0
- package/build/cjs/nodeVersion.js +12 -0
- package/build/cjs/nodeVersion.js.map +1 -0
- package/build/cjs/otel/contextManager.js +16 -0
- package/build/cjs/otel/contextManager.js.map +1 -0
- package/build/cjs/otel/instrument.js +139 -0
- package/build/cjs/otel/instrument.js.map +1 -0
- package/build/cjs/preload.js +2 -2
- package/build/cjs/preload.js.map +1 -1
- package/build/cjs/proxy/base.js +122 -0
- package/build/cjs/proxy/base.js.map +1 -0
- package/build/cjs/proxy/index.js +173 -0
- package/build/cjs/proxy/index.js.map +1 -0
- package/build/cjs/proxy/parse-proxy-response.js +104 -0
- package/build/cjs/proxy/parse-proxy-response.js.map +1 -0
- package/build/cjs/sdk/api.js +117 -0
- package/build/cjs/sdk/api.js.map +1 -0
- package/build/cjs/sdk/client.js +156 -0
- package/build/cjs/sdk/client.js.map +1 -0
- package/build/cjs/sdk/index.js +203 -22
- package/build/cjs/sdk/index.js.map +1 -1
- package/build/cjs/sdk/initOtel.js +22 -4
- package/build/cjs/sdk/initOtel.js.map +1 -1
- package/build/cjs/transports/http.js +158 -0
- package/build/cjs/transports/http.js.map +1 -0
- package/build/cjs/utils/addOriginToSpan.js +11 -0
- package/build/cjs/utils/addOriginToSpan.js.map +1 -0
- package/build/cjs/utils/baggage.js +36 -0
- package/build/cjs/utils/baggage.js.map +1 -0
- package/build/cjs/utils/commonjs.js +13 -0
- package/build/cjs/utils/commonjs.js.map +1 -0
- package/build/cjs/utils/createMissingInstrumentationContext.js +11 -0
- package/build/cjs/utils/createMissingInstrumentationContext.js.map +1 -0
- package/build/cjs/utils/debug.js +23 -0
- package/build/cjs/utils/debug.js.map +1 -0
- package/build/cjs/utils/ensureIsWrapped.js +41 -0
- package/build/cjs/utils/ensureIsWrapped.js.map +1 -0
- package/build/cjs/utils/envToBool.js +32 -0
- package/build/cjs/utils/envToBool.js.map +1 -0
- package/build/cjs/utils/errorhandling.js +42 -0
- package/build/cjs/utils/errorhandling.js.map +1 -0
- package/build/cjs/utils/getRequestUrl.js +18 -0
- package/build/cjs/utils/getRequestUrl.js.map +1 -0
- package/build/cjs/utils/module.js +60 -0
- package/build/cjs/utils/module.js.map +1 -0
- package/build/esm/cron/common.js +54 -0
- package/build/esm/cron/common.js.map +1 -0
- package/build/esm/cron/cron.js +110 -0
- package/build/esm/cron/cron.js.map +1 -0
- package/build/esm/cron/index.js +13 -0
- package/build/esm/cron/index.js.map +1 -0
- package/build/esm/cron/node-cron.js +69 -0
- package/build/esm/cron/node-cron.js.map +1 -0
- package/build/esm/cron/node-schedule.js +63 -0
- package/build/esm/cron/node-schedule.js.map +1 -0
- package/build/esm/index.js +21 -2
- package/build/esm/index.js.map +1 -1
- package/build/esm/integrations/anr/index.js +234 -0
- package/build/esm/integrations/anr/index.js.map +1 -0
- package/build/esm/integrations/anr/worker-script.js +2 -0
- package/build/esm/integrations/childProcess.js +98 -0
- package/build/esm/integrations/childProcess.js.map +1 -0
- package/build/esm/integrations/context.js +451 -0
- package/build/esm/integrations/context.js.map +1 -0
- package/build/esm/integrations/contextlines.js +399 -0
- package/build/esm/integrations/contextlines.js.map +1 -0
- package/build/esm/integrations/fs.js +1 -1
- package/build/esm/integrations/fs.js.map +1 -1
- package/build/esm/integrations/http/SentryHttpInstrumentation.js +555 -0
- package/build/esm/integrations/http/SentryHttpInstrumentation.js.map +1 -0
- package/build/esm/integrations/http/index.js +5 -1
- package/build/esm/integrations/http/index.js.map +1 -1
- package/build/esm/integrations/local-variables/common.js +64 -0
- package/build/esm/integrations/local-variables/common.js.map +1 -0
- package/build/esm/integrations/local-variables/index.js +10 -0
- package/build/esm/integrations/local-variables/index.js.map +1 -0
- package/build/esm/integrations/local-variables/local-variables-async.js +140 -0
- package/build/esm/integrations/local-variables/local-variables-async.js.map +1 -0
- package/build/esm/integrations/local-variables/local-variables-sync.js +405 -0
- package/build/esm/integrations/local-variables/local-variables-sync.js.map +1 -0
- package/build/esm/integrations/local-variables/worker-script.js +2 -0
- package/build/esm/integrations/modules.js +133 -0
- package/build/esm/integrations/modules.js.map +1 -0
- package/build/esm/integrations/node-fetch/SentryNodeFetchInstrumentation.js +289 -0
- package/build/esm/integrations/node-fetch/SentryNodeFetchInstrumentation.js.map +1 -0
- package/build/esm/integrations/node-fetch/index.js +3 -2
- package/build/esm/integrations/node-fetch/index.js.map +1 -1
- package/build/esm/integrations/onuncaughtexception.js +131 -0
- package/build/esm/integrations/onuncaughtexception.js.map +1 -0
- package/build/esm/integrations/onunhandledrejection.js +86 -0
- package/build/esm/integrations/onunhandledrejection.js.map +1 -0
- package/build/esm/integrations/processSession.js +34 -0
- package/build/esm/integrations/processSession.js.map +1 -0
- package/build/esm/integrations/spotlight.js +98 -0
- package/build/esm/integrations/spotlight.js.map +1 -0
- package/build/esm/integrations/tracing/amqplib.js +2 -1
- package/build/esm/integrations/tracing/amqplib.js.map +1 -1
- package/build/esm/integrations/tracing/connect.js +2 -1
- package/build/esm/integrations/tracing/connect.js.map +1 -1
- package/build/esm/integrations/tracing/dataloader.js +1 -1
- package/build/esm/integrations/tracing/dataloader.js.map +1 -1
- package/build/esm/integrations/tracing/express.js +4 -2
- package/build/esm/integrations/tracing/express.js.map +1 -1
- package/build/esm/integrations/tracing/fastify/fastify-otel/index.js +3 -3
- package/build/esm/integrations/tracing/fastify/fastify-otel/index.js.map +1 -1
- package/build/esm/integrations/tracing/fastify/index.js +5 -5
- package/build/esm/integrations/tracing/fastify/index.js.map +1 -1
- package/build/esm/integrations/tracing/genericPool.js +1 -1
- package/build/esm/integrations/tracing/genericPool.js.map +1 -1
- package/build/esm/integrations/tracing/graphql.js +3 -2
- package/build/esm/integrations/tracing/graphql.js.map +1 -1
- package/build/esm/integrations/tracing/hapi/index.js +2 -1
- package/build/esm/integrations/tracing/hapi/index.js.map +1 -1
- package/build/esm/integrations/tracing/kafka.js +2 -1
- package/build/esm/integrations/tracing/kafka.js.map +1 -1
- package/build/esm/integrations/tracing/knex.js +1 -1
- package/build/esm/integrations/tracing/knex.js.map +1 -1
- package/build/esm/integrations/tracing/koa.js +4 -2
- package/build/esm/integrations/tracing/koa.js.map +1 -1
- package/build/esm/integrations/tracing/lrumemoizer.js +1 -1
- package/build/esm/integrations/tracing/lrumemoizer.js.map +1 -1
- package/build/esm/integrations/tracing/mongo.js +2 -1
- package/build/esm/integrations/tracing/mongo.js.map +1 -1
- package/build/esm/integrations/tracing/mongoose.js +2 -1
- package/build/esm/integrations/tracing/mongoose.js.map +1 -1
- package/build/esm/integrations/tracing/mysql.js +1 -1
- package/build/esm/integrations/tracing/mysql.js.map +1 -1
- package/build/esm/integrations/tracing/mysql2.js +2 -1
- package/build/esm/integrations/tracing/mysql2.js.map +1 -1
- package/build/esm/integrations/tracing/postgres.js +2 -1
- package/build/esm/integrations/tracing/postgres.js.map +1 -1
- package/build/esm/integrations/tracing/postgresjs.js +3 -2
- package/build/esm/integrations/tracing/postgresjs.js.map +1 -1
- package/build/esm/integrations/tracing/prisma.js +1 -1
- package/build/esm/integrations/tracing/prisma.js.map +1 -1
- package/build/esm/integrations/tracing/redis.js +1 -1
- package/build/esm/integrations/tracing/redis.js.map +1 -1
- package/build/esm/integrations/tracing/tedious.js +1 -1
- package/build/esm/integrations/tracing/tedious.js.map +1 -1
- package/build/esm/integrations/tracing/vercelai/index.js +1 -1
- package/build/esm/integrations/tracing/vercelai/index.js.map +1 -1
- package/build/esm/integrations/winston.js +149 -0
- package/build/esm/integrations/winston.js.map +1 -0
- package/build/esm/logs/capture.js +27 -0
- package/build/esm/logs/capture.js.map +1 -0
- package/build/esm/logs/exports.js +170 -0
- package/build/esm/logs/exports.js.map +1 -0
- package/build/esm/nodeVersion.js +8 -0
- package/build/esm/nodeVersion.js.map +1 -0
- package/build/esm/otel/contextManager.js +14 -0
- package/build/esm/otel/contextManager.js.map +1 -0
- package/build/esm/otel/instrument.js +135 -0
- package/build/esm/otel/instrument.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/preload.js +1 -1
- package/build/esm/preload.js.map +1 -1
- package/build/esm/proxy/base.js +120 -0
- package/build/esm/proxy/base.js.map +1 -0
- package/build/esm/proxy/index.js +171 -0
- package/build/esm/proxy/index.js.map +1 -0
- package/build/esm/proxy/parse-proxy-response.js +102 -0
- package/build/esm/proxy/parse-proxy-response.js.map +1 -0
- package/build/esm/sdk/api.js +114 -0
- package/build/esm/sdk/api.js.map +1 -0
- package/build/esm/sdk/client.js +154 -0
- package/build/esm/sdk/client.js.map +1 -0
- package/build/esm/sdk/index.js +202 -22
- package/build/esm/sdk/index.js.map +1 -1
- package/build/esm/sdk/initOtel.js +21 -3
- package/build/esm/sdk/initOtel.js.map +1 -1
- package/build/esm/transports/http.js +156 -0
- package/build/esm/transports/http.js.map +1 -0
- package/build/esm/utils/addOriginToSpan.js +9 -0
- package/build/esm/utils/addOriginToSpan.js.map +1 -0
- package/build/esm/utils/baggage.js +34 -0
- package/build/esm/utils/baggage.js.map +1 -0
- package/build/esm/utils/commonjs.js +11 -0
- package/build/esm/utils/commonjs.js.map +1 -0
- package/build/esm/utils/createMissingInstrumentationContext.js +9 -0
- package/build/esm/utils/createMissingInstrumentationContext.js.map +1 -0
- package/build/esm/utils/debug.js +21 -0
- package/build/esm/utils/debug.js.map +1 -0
- package/build/esm/utils/ensureIsWrapped.js +39 -0
- package/build/esm/utils/ensureIsWrapped.js.map +1 -0
- package/build/esm/utils/envToBool.js +28 -0
- package/build/esm/utils/envToBool.js.map +1 -0
- package/build/esm/utils/errorhandling.js +40 -0
- package/build/esm/utils/errorhandling.js.map +1 -0
- package/build/esm/utils/getRequestUrl.js +16 -0
- package/build/esm/utils/getRequestUrl.js.map +1 -0
- package/build/esm/utils/module.js +58 -0
- package/build/esm/utils/module.js.map +1 -0
- package/build/types/cron/common.d.ts +5 -0
- package/build/types/cron/common.d.ts.map +1 -0
- package/build/types/cron/cron.d.ts +43 -0
- package/build/types/cron/cron.d.ts.map +1 -0
- package/build/types/cron/index.d.ts +10 -0
- package/build/types/cron/index.d.ts.map +1 -0
- package/build/types/cron/node-cron.d.ts +27 -0
- package/build/types/cron/node-cron.d.ts.map +1 -0
- package/build/types/cron/node-schedule.d.ts +19 -0
- package/build/types/cron/node-schedule.d.ts.map +1 -0
- package/build/types/index.d.ts +21 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/anr/common.d.ts +52 -0
- package/build/types/integrations/anr/common.d.ts.map +1 -0
- package/build/types/integrations/anr/index.d.ts +13 -0
- package/build/types/integrations/anr/index.d.ts.map +1 -0
- package/build/types/integrations/anr/worker.d.ts +2 -0
- package/build/types/integrations/anr/worker.d.ts.map +1 -0
- package/build/types/integrations/childProcess.d.ts +20 -0
- package/build/types/integrations/childProcess.d.ts.map +1 -0
- package/build/types/integrations/context.d.ts +30 -0
- package/build/types/integrations/context.d.ts.map +1 -0
- package/build/types/integrations/contextlines.d.ts +31 -0
- package/build/types/integrations/contextlines.d.ts.map +1 -0
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts +131 -0
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -0
- package/build/types/integrations/http/index.d.ts +1 -1
- package/build/types/integrations/http/index.d.ts.map +1 -1
- package/build/types/integrations/local-variables/common.d.ts +66 -0
- package/build/types/integrations/local-variables/common.d.ts.map +1 -0
- package/build/types/integrations/local-variables/index.d.ts +4 -0
- package/build/types/integrations/local-variables/index.d.ts.map +1 -0
- package/build/types/integrations/local-variables/local-variables-async.d.ts +7 -0
- package/build/types/integrations/local-variables/local-variables-async.d.ts.map +1 -0
- package/build/types/integrations/local-variables/local-variables-sync.d.ts +34 -0
- package/build/types/integrations/local-variables/local-variables-sync.d.ts.map +1 -0
- package/build/types/integrations/local-variables/worker.d.ts +2 -0
- package/build/types/integrations/local-variables/worker.d.ts.map +1 -0
- package/build/types/integrations/modules.d.ts +17 -0
- package/build/types/integrations/modules.d.ts.map +1 -0
- package/build/types/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts +56 -0
- package/build/types/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts.map +1 -0
- package/build/types/integrations/node-fetch/index.d.ts.map +1 -1
- package/build/types/integrations/onuncaughtexception.d.ts +31 -0
- package/build/types/integrations/onuncaughtexception.d.ts.map +1 -0
- package/build/types/integrations/onunhandledrejection.d.ts +23 -0
- package/build/types/integrations/onunhandledrejection.d.ts.map +1 -0
- package/build/types/integrations/processSession.d.ts +5 -0
- package/build/types/integrations/processSession.d.ts.map +1 -0
- package/build/types/integrations/spotlight.d.ts +18 -0
- package/build/types/integrations/spotlight.d.ts.map +1 -0
- package/build/types/integrations/tracing/amqplib.d.ts.map +1 -1
- package/build/types/integrations/tracing/connect.d.ts.map +1 -1
- package/build/types/integrations/tracing/express.d.ts.map +1 -1
- package/build/types/integrations/tracing/graphql.d.ts.map +1 -1
- package/build/types/integrations/tracing/hapi/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/kafka.d.ts.map +1 -1
- package/build/types/integrations/tracing/koa.d.ts.map +1 -1
- package/build/types/integrations/tracing/mongo.d.ts.map +1 -1
- package/build/types/integrations/tracing/mongoose.d.ts.map +1 -1
- package/build/types/integrations/tracing/mysql2.d.ts.map +1 -1
- package/build/types/integrations/tracing/postgres.d.ts.map +1 -1
- package/build/types/integrations/tracing/postgresjs.d.ts.map +1 -1
- package/build/types/integrations/tracing/vercelai/index.d.ts.map +1 -1
- package/build/types/integrations/winston.d.ts +44 -0
- package/build/types/integrations/winston.d.ts.map +1 -0
- package/build/types/logs/capture.d.ts +11 -0
- package/build/types/logs/capture.d.ts.map +1 -0
- package/build/types/logs/exports.d.ts +150 -0
- package/build/types/logs/exports.d.ts.map +1 -0
- package/build/types/nodeVersion.d.ts +8 -0
- package/build/types/nodeVersion.d.ts.map +1 -0
- package/build/types/otel/contextManager.d.ts +10 -0
- package/build/types/otel/contextManager.d.ts.map +1 -0
- package/build/types/otel/instrument.d.ts +23 -0
- package/build/types/otel/instrument.d.ts.map +1 -0
- package/build/types/proxy/base.d.ts +65 -0
- package/build/types/proxy/base.d.ts.map +1 -0
- package/build/types/proxy/helpers.d.ts +42 -0
- package/build/types/proxy/helpers.d.ts.map +1 -0
- package/build/types/proxy/index.d.ts +73 -0
- package/build/types/proxy/index.d.ts.map +1 -0
- package/build/types/proxy/parse-proxy-response.d.ts +43 -0
- package/build/types/proxy/parse-proxy-response.d.ts.map +1 -0
- package/build/types/sdk/api.d.ts +8 -0
- package/build/types/sdk/api.d.ts.map +1 -0
- package/build/types/sdk/client.d.ts +29 -0
- package/build/types/sdk/client.d.ts.map +1 -0
- package/build/types/sdk/index.d.ts +6 -2
- package/build/types/sdk/index.d.ts.map +1 -1
- package/build/types/sdk/initOtel.d.ts +1 -1
- package/build/types/sdk/initOtel.d.ts.map +1 -1
- package/build/types/sdk/scope.d.ts +7 -0
- package/build/types/sdk/scope.d.ts.map +1 -0
- package/build/types/transports/http-module.d.ts +31 -0
- package/build/types/transports/http-module.d.ts.map +1 -0
- package/build/types/transports/http.d.ts +21 -0
- package/build/types/transports/http.d.ts.map +1 -0
- package/build/types/transports/index.d.ts +3 -0
- package/build/types/transports/index.d.ts.map +1 -0
- package/build/types/types.d.ts +1 -1
- package/build/types/types.d.ts.map +1 -1
- package/build/types/utils/addOriginToSpan.d.ts +5 -0
- package/build/types/utils/addOriginToSpan.d.ts.map +1 -0
- package/build/types/utils/baggage.d.ts +6 -0
- package/build/types/utils/baggage.d.ts.map +1 -0
- package/build/types/utils/commonjs.d.ts +3 -0
- package/build/types/utils/commonjs.d.ts.map +1 -0
- package/build/types/utils/createMissingInstrumentationContext.d.ts +3 -0
- package/build/types/utils/createMissingInstrumentationContext.d.ts.map +1 -0
- package/build/types/utils/debug.d.ts +5 -0
- package/build/types/utils/debug.d.ts.map +1 -0
- package/build/types/utils/ensureIsWrapped.d.ts +5 -0
- package/build/types/utils/ensureIsWrapped.d.ts.map +1 -0
- package/build/types/utils/entry-point.d.ts +24 -0
- package/build/types/utils/entry-point.d.ts.map +1 -0
- package/build/types/utils/envToBool.d.ts +13 -0
- package/build/types/utils/envToBool.d.ts.map +1 -0
- package/build/types/utils/errorhandling.d.ts +5 -0
- package/build/types/utils/errorhandling.d.ts.map +1 -0
- package/build/types/utils/getRequestUrl.d.ts +5 -0
- package/build/types/utils/getRequestUrl.d.ts.map +1 -0
- package/build/types/utils/module.d.ts +3 -0
- package/build/types/utils/module.d.ts.map +1 -0
- package/build/types/utils/prepareEvent.d.ts +17 -0
- package/build/types/utils/prepareEvent.d.ts.map +1 -0
- package/build/types-ts3.8/cron/common.d.ts +5 -0
- package/build/types-ts3.8/cron/cron.d.ts +43 -0
- package/build/types-ts3.8/cron/index.d.ts +10 -0
- package/build/types-ts3.8/cron/node-cron.d.ts +27 -0
- package/build/types-ts3.8/cron/node-schedule.d.ts +19 -0
- package/build/types-ts3.8/index.d.ts +21 -2
- package/build/types-ts3.8/integrations/anr/common.d.ts +52 -0
- package/build/types-ts3.8/integrations/anr/index.d.ts +13 -0
- package/build/types-ts3.8/integrations/anr/worker.d.ts +2 -0
- package/build/types-ts3.8/integrations/childProcess.d.ts +20 -0
- package/build/types-ts3.8/integrations/context.d.ts +30 -0
- package/build/types-ts3.8/integrations/contextlines.d.ts +31 -0
- package/build/types-ts3.8/integrations/http/SentryHttpInstrumentation.d.ts +133 -0
- package/build/types-ts3.8/integrations/http/index.d.ts +1 -1
- package/build/types-ts3.8/integrations/local-variables/common.d.ts +66 -0
- package/build/types-ts3.8/integrations/local-variables/index.d.ts +4 -0
- package/build/types-ts3.8/integrations/local-variables/local-variables-async.d.ts +7 -0
- package/build/types-ts3.8/integrations/local-variables/local-variables-sync.d.ts +34 -0
- package/build/types-ts3.8/integrations/local-variables/worker.d.ts +2 -0
- package/build/types-ts3.8/integrations/modules.d.ts +17 -0
- package/build/types-ts3.8/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts +56 -0
- package/build/types-ts3.8/integrations/onuncaughtexception.d.ts +31 -0
- package/build/types-ts3.8/integrations/onunhandledrejection.d.ts +23 -0
- package/build/types-ts3.8/integrations/processSession.d.ts +5 -0
- package/build/types-ts3.8/integrations/spotlight.d.ts +18 -0
- package/build/types-ts3.8/integrations/winston.d.ts +44 -0
- package/build/types-ts3.8/logs/capture.d.ts +18 -0
- package/build/types-ts3.8/logs/exports.d.ts +150 -0
- package/build/types-ts3.8/nodeVersion.d.ts +8 -0
- package/build/types-ts3.8/otel/contextManager.d.ts +10 -0
- package/build/types-ts3.8/otel/instrument.d.ts +23 -0
- package/build/types-ts3.8/proxy/base.d.ts +60 -0
- package/build/types-ts3.8/proxy/helpers.d.ts +38 -0
- package/build/types-ts3.8/proxy/index.d.ts +74 -0
- package/build/types-ts3.8/proxy/parse-proxy-response.d.ts +40 -0
- package/build/types-ts3.8/sdk/api.d.ts +8 -0
- package/build/types-ts3.8/sdk/client.d.ts +32 -0
- package/build/types-ts3.8/sdk/index.d.ts +6 -2
- package/build/types-ts3.8/sdk/initOtel.d.ts +1 -1
- package/build/types-ts3.8/sdk/scope.d.ts +7 -0
- package/build/types-ts3.8/transports/http-module.d.ts +28 -0
- package/build/types-ts3.8/transports/http.d.ts +20 -0
- package/build/types-ts3.8/transports/index.d.ts +3 -0
- package/build/types-ts3.8/types.d.ts +1 -1
- package/build/types-ts3.8/utils/addOriginToSpan.d.ts +5 -0
- package/build/types-ts3.8/utils/baggage.d.ts +6 -0
- package/build/types-ts3.8/utils/commonjs.d.ts +3 -0
- package/build/types-ts3.8/utils/createMissingInstrumentationContext.d.ts +3 -0
- package/build/types-ts3.8/utils/debug.d.ts +5 -0
- package/build/types-ts3.8/utils/ensureIsWrapped.d.ts +5 -0
- package/build/types-ts3.8/utils/entry-point.d.ts +24 -0
- package/build/types-ts3.8/utils/envToBool.d.ts +13 -0
- package/build/types-ts3.8/utils/errorhandling.d.ts +5 -0
- package/build/types-ts3.8/utils/getRequestUrl.d.ts +5 -0
- package/build/types-ts3.8/utils/module.d.ts +3 -0
- package/build/types-ts3.8/utils/prepareEvent.d.ts +17 -0
- package/package.json +3 -4
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
import { defineIntegration, LRUMap, getClient, logger } from '@sentry/core';
|
|
2
|
+
import { NODE_MAJOR } from '../../nodeVersion.js';
|
|
3
|
+
import { isDebuggerEnabled } from '../../utils/debug.js';
|
|
4
|
+
import { createRateLimiter, functionNamesMatch } from './common.js';
|
|
5
|
+
|
|
6
|
+
/** Creates a unique hash from stack frames */
|
|
7
|
+
function hashFrames(frames) {
|
|
8
|
+
if (frames === undefined) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Only hash the 10 most recent frames (ie. the last 10)
|
|
13
|
+
return frames.slice(-10).reduce((acc, frame) => `${acc},${frame.function},${frame.lineno},${frame.colno}`, '');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* We use the stack parser to create a unique hash from the exception stack trace
|
|
18
|
+
* This is used to lookup vars when the exception passes through the event processor
|
|
19
|
+
*/
|
|
20
|
+
function hashFromStack(stackParser, stack) {
|
|
21
|
+
if (stack === undefined) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return hashFrames(stackParser(stack, 1));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Creates a container for callbacks to be called sequentially */
|
|
29
|
+
function createCallbackList(complete) {
|
|
30
|
+
// A collection of callbacks to be executed last to first
|
|
31
|
+
let callbacks = [];
|
|
32
|
+
|
|
33
|
+
let completedCalled = false;
|
|
34
|
+
function checkedComplete(result) {
|
|
35
|
+
callbacks = [];
|
|
36
|
+
if (completedCalled) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
completedCalled = true;
|
|
40
|
+
complete(result);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// complete should be called last
|
|
44
|
+
callbacks.push(checkedComplete);
|
|
45
|
+
|
|
46
|
+
function add(fn) {
|
|
47
|
+
callbacks.push(fn);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function next(result) {
|
|
51
|
+
const popped = callbacks.pop() || checkedComplete;
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
popped(result);
|
|
55
|
+
} catch (_) {
|
|
56
|
+
// If there is an error, we still want to call the complete callback
|
|
57
|
+
checkedComplete(result);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return { add, next };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Promise API is available as `Experimental` and in Node 19 only.
|
|
66
|
+
*
|
|
67
|
+
* Callback-based API is `Stable` since v14 and `Experimental` since v8.
|
|
68
|
+
* Because of that, we are creating our own `AsyncSession` class.
|
|
69
|
+
*
|
|
70
|
+
* https://nodejs.org/docs/latest-v19.x/api/inspector.html#promises-api
|
|
71
|
+
* https://nodejs.org/docs/latest-v14.x/api/inspector.html
|
|
72
|
+
*/
|
|
73
|
+
class AsyncSession {
|
|
74
|
+
/** Throws if inspector API is not available */
|
|
75
|
+
constructor( _session) {this._session = _session;
|
|
76
|
+
//
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static async create(orDefault) {
|
|
80
|
+
if (orDefault) {
|
|
81
|
+
return orDefault;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const inspector = await import('node:inspector');
|
|
85
|
+
return new AsyncSession(new inspector.Session());
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** @inheritdoc */
|
|
89
|
+
configureAndConnect(onPause, captureAll) {
|
|
90
|
+
this._session.connect();
|
|
91
|
+
|
|
92
|
+
this._session.on('Debugger.paused', event => {
|
|
93
|
+
onPause(event, () => {
|
|
94
|
+
// After the pause work is complete, resume execution or the exception context memory is leaked
|
|
95
|
+
this._session.post('Debugger.resume');
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
this._session.post('Debugger.enable');
|
|
100
|
+
this._session.post('Debugger.setPauseOnExceptions', { state: captureAll ? 'all' : 'uncaught' });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
setPauseOnExceptions(captureAll) {
|
|
104
|
+
this._session.post('Debugger.setPauseOnExceptions', { state: captureAll ? 'all' : 'uncaught' });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** @inheritdoc */
|
|
108
|
+
getLocalVariables(objectId, complete) {
|
|
109
|
+
this._getProperties(objectId, props => {
|
|
110
|
+
const { add, next } = createCallbackList(complete);
|
|
111
|
+
|
|
112
|
+
for (const prop of props) {
|
|
113
|
+
if (prop.value?.objectId && prop.value.className === 'Array') {
|
|
114
|
+
const id = prop.value.objectId;
|
|
115
|
+
add(vars => this._unrollArray(id, prop.name, vars, next));
|
|
116
|
+
} else if (prop.value?.objectId && prop.value.className === 'Object') {
|
|
117
|
+
const id = prop.value.objectId;
|
|
118
|
+
add(vars => this._unrollObject(id, prop.name, vars, next));
|
|
119
|
+
} else if (prop.value) {
|
|
120
|
+
add(vars => this._unrollOther(prop, vars, next));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
next({});
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Gets all the PropertyDescriptors of an object
|
|
130
|
+
*/
|
|
131
|
+
_getProperties(objectId, next) {
|
|
132
|
+
this._session.post(
|
|
133
|
+
'Runtime.getProperties',
|
|
134
|
+
{
|
|
135
|
+
objectId,
|
|
136
|
+
ownProperties: true,
|
|
137
|
+
},
|
|
138
|
+
(err, params) => {
|
|
139
|
+
if (err) {
|
|
140
|
+
next([]);
|
|
141
|
+
} else {
|
|
142
|
+
next(params.result);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Unrolls an array property
|
|
150
|
+
*/
|
|
151
|
+
_unrollArray(objectId, name, vars, next) {
|
|
152
|
+
this._getProperties(objectId, props => {
|
|
153
|
+
vars[name] = props
|
|
154
|
+
.filter(v => v.name !== 'length' && !isNaN(parseInt(v.name, 10)))
|
|
155
|
+
.sort((a, b) => parseInt(a.name, 10) - parseInt(b.name, 10))
|
|
156
|
+
.map(v => v.value?.value);
|
|
157
|
+
|
|
158
|
+
next(vars);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Unrolls an object property
|
|
164
|
+
*/
|
|
165
|
+
_unrollObject(objectId, name, vars, next) {
|
|
166
|
+
this._getProperties(objectId, props => {
|
|
167
|
+
vars[name] = props
|
|
168
|
+
.map(v => [v.name, v.value?.value])
|
|
169
|
+
.reduce((obj, [key, val]) => {
|
|
170
|
+
obj[key] = val;
|
|
171
|
+
return obj;
|
|
172
|
+
}, {} );
|
|
173
|
+
|
|
174
|
+
next(vars);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Unrolls other properties
|
|
180
|
+
*/
|
|
181
|
+
_unrollOther(prop, vars, next) {
|
|
182
|
+
if (prop.value) {
|
|
183
|
+
if ('value' in prop.value) {
|
|
184
|
+
if (prop.value.value === undefined || prop.value.value === null) {
|
|
185
|
+
vars[prop.name] = `<${prop.value.value}>`;
|
|
186
|
+
} else {
|
|
187
|
+
vars[prop.name] = prop.value.value;
|
|
188
|
+
}
|
|
189
|
+
} else if ('description' in prop.value && prop.value.type !== 'function') {
|
|
190
|
+
vars[prop.name] = `<${prop.value.description}>`;
|
|
191
|
+
} else if (prop.value.type === 'undefined') {
|
|
192
|
+
vars[prop.name] = '<undefined>';
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
next(vars);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const INTEGRATION_NAME = 'LocalVariables';
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Adds local variables to exception frames
|
|
204
|
+
*/
|
|
205
|
+
const _localVariablesSyncIntegration = ((
|
|
206
|
+
options = {},
|
|
207
|
+
sessionOverride,
|
|
208
|
+
) => {
|
|
209
|
+
const cachedFrames = new LRUMap(20);
|
|
210
|
+
let rateLimiter;
|
|
211
|
+
let shouldProcessEvent = false;
|
|
212
|
+
|
|
213
|
+
function addLocalVariablesToException(exception) {
|
|
214
|
+
const hash = hashFrames(exception.stacktrace?.frames);
|
|
215
|
+
|
|
216
|
+
if (hash === undefined) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Check if we have local variables for an exception that matches the hash
|
|
221
|
+
// remove is identical to get but also removes the entry from the cache
|
|
222
|
+
const cachedFrame = cachedFrames.remove(hash);
|
|
223
|
+
|
|
224
|
+
if (cachedFrame === undefined) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Filter out frames where the function name is `new Promise` since these are in the error.stack frames
|
|
229
|
+
// but do not appear in the debugger call frames
|
|
230
|
+
const frames = (exception.stacktrace?.frames || []).filter(frame => frame.function !== 'new Promise');
|
|
231
|
+
|
|
232
|
+
for (let i = 0; i < frames.length; i++) {
|
|
233
|
+
// Sentry frames are in reverse order
|
|
234
|
+
const frameIndex = frames.length - i - 1;
|
|
235
|
+
|
|
236
|
+
const cachedFrameVariable = cachedFrame[i];
|
|
237
|
+
const frameVariable = frames[frameIndex];
|
|
238
|
+
|
|
239
|
+
// Drop out if we run out of frames to match up
|
|
240
|
+
if (!frameVariable || !cachedFrameVariable) {
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (
|
|
245
|
+
// We need to have vars to add
|
|
246
|
+
cachedFrameVariable.vars === undefined ||
|
|
247
|
+
// We're not interested in frames that are not in_app because the vars are not relevant
|
|
248
|
+
frameVariable.in_app === false ||
|
|
249
|
+
// The function names need to match
|
|
250
|
+
!functionNamesMatch(frameVariable.function, cachedFrameVariable.function)
|
|
251
|
+
) {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
frameVariable.vars = cachedFrameVariable.vars;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function addLocalVariablesToEvent(event) {
|
|
260
|
+
for (const exception of event.exception?.values || []) {
|
|
261
|
+
addLocalVariablesToException(exception);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return event;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return {
|
|
268
|
+
name: INTEGRATION_NAME,
|
|
269
|
+
async setupOnce() {
|
|
270
|
+
const client = getClient();
|
|
271
|
+
const clientOptions = client?.getOptions();
|
|
272
|
+
|
|
273
|
+
if (!clientOptions?.includeLocalVariables) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Only setup this integration if the Node version is >= v18
|
|
278
|
+
// https://github.com/getsentry/sentry-javascript/issues/7697
|
|
279
|
+
const unsupportedNodeVersion = NODE_MAJOR < 18;
|
|
280
|
+
|
|
281
|
+
if (unsupportedNodeVersion) {
|
|
282
|
+
logger.log('The `LocalVariables` integration is only supported on Node >= v18.');
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (await isDebuggerEnabled()) {
|
|
287
|
+
logger.warn('Local variables capture has been disabled because the debugger was already enabled');
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
AsyncSession.create(sessionOverride).then(
|
|
292
|
+
session => {
|
|
293
|
+
function handlePaused(
|
|
294
|
+
stackParser,
|
|
295
|
+
{ params: { reason, data, callFrames } },
|
|
296
|
+
complete,
|
|
297
|
+
) {
|
|
298
|
+
if (reason !== 'exception' && reason !== 'promiseRejection') {
|
|
299
|
+
complete();
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
rateLimiter?.();
|
|
304
|
+
|
|
305
|
+
// data.description contains the original error.stack
|
|
306
|
+
const exceptionHash = hashFromStack(stackParser, data.description);
|
|
307
|
+
|
|
308
|
+
if (exceptionHash == undefined) {
|
|
309
|
+
complete();
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const { add, next } = createCallbackList(frames => {
|
|
314
|
+
cachedFrames.set(exceptionHash, frames);
|
|
315
|
+
complete();
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
// Because we're queuing up and making all these calls synchronously, we can potentially overflow the stack
|
|
319
|
+
// For this reason we only attempt to get local variables for the first 5 frames
|
|
320
|
+
for (let i = 0; i < Math.min(callFrames.length, 5); i++) {
|
|
321
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
322
|
+
const { scopeChain, functionName, this: obj } = callFrames[i];
|
|
323
|
+
|
|
324
|
+
const localScope = scopeChain.find(scope => scope.type === 'local');
|
|
325
|
+
|
|
326
|
+
// obj.className is undefined in ESM modules
|
|
327
|
+
const fn =
|
|
328
|
+
obj.className === 'global' || !obj.className ? functionName : `${obj.className}.${functionName}`;
|
|
329
|
+
|
|
330
|
+
if (localScope?.object.objectId === undefined) {
|
|
331
|
+
add(frames => {
|
|
332
|
+
frames[i] = { function: fn };
|
|
333
|
+
next(frames);
|
|
334
|
+
});
|
|
335
|
+
} else {
|
|
336
|
+
const id = localScope.object.objectId;
|
|
337
|
+
add(frames =>
|
|
338
|
+
session.getLocalVariables(id, vars => {
|
|
339
|
+
frames[i] = { function: fn, vars };
|
|
340
|
+
next(frames);
|
|
341
|
+
}),
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
next([]);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const captureAll = options.captureAllExceptions !== false;
|
|
350
|
+
|
|
351
|
+
session.configureAndConnect(
|
|
352
|
+
(ev, complete) =>
|
|
353
|
+
handlePaused(clientOptions.stackParser, ev , complete),
|
|
354
|
+
captureAll,
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
if (captureAll) {
|
|
358
|
+
const max = options.maxExceptionsPerSecond || 50;
|
|
359
|
+
|
|
360
|
+
rateLimiter = createRateLimiter(
|
|
361
|
+
max,
|
|
362
|
+
() => {
|
|
363
|
+
logger.log('Local variables rate-limit lifted.');
|
|
364
|
+
session.setPauseOnExceptions(true);
|
|
365
|
+
},
|
|
366
|
+
seconds => {
|
|
367
|
+
logger.log(
|
|
368
|
+
`Local variables rate-limit exceeded. Disabling capturing of caught exceptions for ${seconds} seconds.`,
|
|
369
|
+
);
|
|
370
|
+
session.setPauseOnExceptions(false);
|
|
371
|
+
},
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
shouldProcessEvent = true;
|
|
376
|
+
},
|
|
377
|
+
error => {
|
|
378
|
+
logger.log('The `LocalVariables` integration failed to start.', error);
|
|
379
|
+
},
|
|
380
|
+
);
|
|
381
|
+
},
|
|
382
|
+
processEvent(event) {
|
|
383
|
+
if (shouldProcessEvent) {
|
|
384
|
+
return addLocalVariablesToEvent(event);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
return event;
|
|
388
|
+
},
|
|
389
|
+
// These are entirely for testing
|
|
390
|
+
_getCachedFramesCount() {
|
|
391
|
+
return cachedFrames.size;
|
|
392
|
+
},
|
|
393
|
+
_getFirstCachedFrame() {
|
|
394
|
+
return cachedFrames.values()[0];
|
|
395
|
+
},
|
|
396
|
+
};
|
|
397
|
+
}) ;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Adds local variables to exception frames.
|
|
401
|
+
*/
|
|
402
|
+
const localVariablesSyncIntegration = defineIntegration(_localVariablesSyncIntegration);
|
|
403
|
+
|
|
404
|
+
export { createCallbackList, hashFrames, hashFromStack, localVariablesSyncIntegration };
|
|
405
|
+
//# 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":[],"mappings":";;;;;AAeA;AACO,SAAS,UAAU,CAAC,MAAM,EAAgD;AACjF,EAAE,IAAI,MAAO,KAAI,SA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
+
import{Session as e}from"node:inspector/promises";import{workerData as t}from"node:worker_threads";const n="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,o=globalThis,i="9.35.0";const a=["debug","info","warn","error","log","assert","trace"],s={};function c(e){if(!("console"in o))return e();const t=o.console,n={},i=Object.keys(s);i.forEach((e=>{const o=s[e];n[e]=t[e],t[e]=o}));try{return e()}finally{i.forEach((e=>{t[e]=n[e]}))}}!function(e,t,n=o){const a=n.__SENTRY__=n.__SENTRY__||{},s=a[i]=a[i]||{};s[e]||(s[e]=t())}("logger",(function(){let e=!1;const t={enable:()=>{e=!0},disable:()=>{e=!1},isEnabled:()=>e};return n?a.forEach((n=>{t[n]=(...t)=>{e&&c((()=>{o.console[n](`Sentry Logger [${n}]:`,...t)}))}})):a.forEach((e=>{t[e]=()=>{}})),t}));const r="__SENTRY_ERROR_LOCAL_VARIABLES__";const u=t;function l(...e){u.debug&&c((()=>console.log("[LocalVariables Worker]",...e)))}async function f(e,t,n,o){const i=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});o[n]=i.result.filter((e=>"length"!==e.name&&!isNaN(parseInt(e.name,10)))).sort(((e,t)=>parseInt(e.name,10)-parseInt(t.name,10))).map((e=>e.value?.value))}async function g(e,t,n,o){const i=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});o[n]=i.result.map((e=>[e.name,e.value?.value])).reduce(((e,[t,n])=>(e[t]=n,e)),{})}function d(e,t){e.value&&("value"in e.value?void 0===e.value.value||null===e.value.value?t[e.name]=`<${e.value.value}>`:t[e.name]=e.value.value:"description"in e.value&&"function"!==e.value.type?t[e.name]=`<${e.value.description}>`:"undefined"===e.value.type&&(t[e.name]="<undefined>"))}async function b(e,t){const n=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0}),o={};for(const t of n.result)if(t.value?.objectId&&"Array"===t.value.className){const n=t.value.objectId;await f(e,n,t.name,o)}else if(t.value?.objectId&&"Object"===t.value.className){const n=t.value.objectId;await g(e,n,t.name,o)}else t.value&&d(t,o);return o}let p;(async function(){const t=new e;t.connectToMainThread(),l("Connected to main thread");let n=!1;t.on("Debugger.resumed",(()=>{n=!1})),t.on("Debugger.paused",(e=>{n=!0,async function(e,{reason:t,data:{objectId:n},callFrames:o}){if("exception"!==t&&"promiseRejection"!==t)return;if(p?.(),null==n)return;const i=[];for(let t=0;t<o.length;t++){const{scopeChain:n,functionName:a,this:s}=o[t],c=n.find((e=>"local"===e.type)),r="global"!==s.className&&s.className?`${s.className}.${a}`:a;if(void 0===c?.object.objectId)i[t]={function:r};else{const n=await b(e,c.object.objectId);i[t]={function:r,vars:n}}}await e.post("Runtime.callFunctionOn",{functionDeclaration:`function() { this.${r} = this.${r} || ${JSON.stringify(i)}; }`,silent:!0,objectId:n}),await e.post("Runtime.releaseObject",{objectId:n})}(t,e.params).then((async()=>{n&&await t.post("Debugger.resume")}),(async e=>{n&&await t.post("Debugger.resume")}))})),await t.post("Debugger.enable");const o=!1!==u.captureAllExceptions;if(await t.post("Debugger.setPauseOnExceptions",{state:o?"all":"uncaught"}),o){const e=u.maxExceptionsPerSecond||50;p=function(e,t,n){let o=0,i=5,a=0;return setInterval((()=>{0===a?o>e&&(i*=2,n(i),i>86400&&(i=86400),a=i):(a-=1,0===a&&t()),o=0}),1e3).unref(),()=>{o+=1}}(e,(async()=>{l("Rate-limit lifted."),await t.post("Debugger.setPauseOnExceptions",{state:"all"})}),(async e=>{l(`Rate-limit exceeded. Disabling capturing of caught exceptions for ${e} seconds.`),await t.post("Debugger.setPauseOnExceptions",{state:"uncaught"})}))}})().catch((e=>{l("Failed to start debugger",e)})),setInterval((()=>{}),1e4);
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { isCjs } from '../utils/commonjs.js';
|
|
4
|
+
|
|
5
|
+
let moduleCache;
|
|
6
|
+
|
|
7
|
+
const INTEGRATION_NAME = 'Modules';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* `__SENTRY_SERVER_MODULES__` can be replaced at build time with the modules loaded by the server.
|
|
11
|
+
* Right now, we leverage this in Next.js to circumvent the problem that we do not get access to these things at runtime.
|
|
12
|
+
*/
|
|
13
|
+
const SERVER_MODULES = typeof __SENTRY_SERVER_MODULES__ === 'undefined' ? {} : __SENTRY_SERVER_MODULES__;
|
|
14
|
+
|
|
15
|
+
const _modulesIntegration = (() => {
|
|
16
|
+
return {
|
|
17
|
+
name: INTEGRATION_NAME,
|
|
18
|
+
processEvent(event) {
|
|
19
|
+
event.modules = {
|
|
20
|
+
...event.modules,
|
|
21
|
+
..._getModules(),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return event;
|
|
25
|
+
},
|
|
26
|
+
getModules: _getModules,
|
|
27
|
+
};
|
|
28
|
+
}) ;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Add node modules / packages to the event.
|
|
32
|
+
* For this, multiple sources are used:
|
|
33
|
+
* - They can be injected at build time into the __SENTRY_SERVER_MODULES__ variable (e.g. in Next.js)
|
|
34
|
+
* - They are extracted from the dependencies & devDependencies in the package.json file
|
|
35
|
+
* - They are extracted from the require.cache (CJS only)
|
|
36
|
+
*/
|
|
37
|
+
const modulesIntegration = _modulesIntegration;
|
|
38
|
+
|
|
39
|
+
function getRequireCachePaths() {
|
|
40
|
+
try {
|
|
41
|
+
return require.cache ? Object.keys(require.cache ) : [];
|
|
42
|
+
} catch (e) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Extract information about package.json modules */
|
|
48
|
+
function collectModules() {
|
|
49
|
+
return {
|
|
50
|
+
...SERVER_MODULES,
|
|
51
|
+
...getModulesFromPackageJson(),
|
|
52
|
+
...(isCjs() ? collectRequireModules() : {}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Extract information about package.json modules from require.cache */
|
|
57
|
+
function collectRequireModules() {
|
|
58
|
+
const mainPaths = require.main?.paths || [];
|
|
59
|
+
const paths = getRequireCachePaths();
|
|
60
|
+
|
|
61
|
+
// We start with the modules from package.json (if possible)
|
|
62
|
+
// These may be overwritten by more specific versions from the require.cache
|
|
63
|
+
const infos = {};
|
|
64
|
+
const seen = new Set();
|
|
65
|
+
|
|
66
|
+
paths.forEach(path => {
|
|
67
|
+
let dir = path;
|
|
68
|
+
|
|
69
|
+
/** Traverse directories upward in the search of package.json file */
|
|
70
|
+
const updir = () => {
|
|
71
|
+
const orig = dir;
|
|
72
|
+
dir = dirname(orig);
|
|
73
|
+
|
|
74
|
+
if (!dir || orig === dir || seen.has(orig)) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
if (mainPaths.indexOf(dir) < 0) {
|
|
78
|
+
return updir();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const pkgfile = join(orig, 'package.json');
|
|
82
|
+
seen.add(orig);
|
|
83
|
+
|
|
84
|
+
if (!existsSync(pkgfile)) {
|
|
85
|
+
return updir();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
const info = JSON.parse(readFileSync(pkgfile, 'utf8'))
|
|
90
|
+
|
|
91
|
+
;
|
|
92
|
+
infos[info.name] = info.version;
|
|
93
|
+
} catch (_oO) {
|
|
94
|
+
// no-empty
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
updir();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return infos;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Fetches the list of modules and the versions loaded by the entry file for your node.js app. */
|
|
105
|
+
function _getModules() {
|
|
106
|
+
if (!moduleCache) {
|
|
107
|
+
moduleCache = collectModules();
|
|
108
|
+
}
|
|
109
|
+
return moduleCache;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function getPackageJson() {
|
|
113
|
+
try {
|
|
114
|
+
const filePath = join(process.cwd(), 'package.json');
|
|
115
|
+
const packageJson = JSON.parse(readFileSync(filePath, 'utf8')) ;
|
|
116
|
+
|
|
117
|
+
return packageJson;
|
|
118
|
+
} catch (e) {
|
|
119
|
+
return {};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function getModulesFromPackageJson() {
|
|
124
|
+
const packageJson = getPackageJson();
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
...packageJson.dependencies,
|
|
128
|
+
...packageJson.devDependencies,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export { modulesIntegration };
|
|
133
|
+
//# 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":[],"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