@sentry/core 10.50.0 → 10.52.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/client.js +33 -5
- package/build/cjs/client.js.map +1 -1
- package/build/cjs/envelope.js +4 -1
- package/build/cjs/envelope.js.map +1 -1
- package/build/cjs/fetch.js +7 -4
- package/build/cjs/fetch.js.map +1 -1
- package/build/cjs/index.js +37 -13
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/instrument/console.js +3 -1
- package/build/cjs/instrument/console.js.map +1 -1
- package/build/cjs/instrument/fetch.js +6 -2
- package/build/cjs/instrument/fetch.js.map +1 -1
- package/build/cjs/instrument/handlers.js +11 -1
- package/build/cjs/instrument/handlers.js.map +1 -1
- package/build/cjs/integrations/console.js +3 -1
- package/build/cjs/integrations/console.js.map +1 -1
- package/build/cjs/integrations/express/index.js +2 -4
- package/build/cjs/integrations/express/index.js.map +1 -1
- package/build/cjs/integrations/express/utils.js +0 -7
- package/build/cjs/integrations/express/utils.js.map +1 -1
- package/build/cjs/integrations/extraerrordata.js +2 -2
- package/build/cjs/integrations/extraerrordata.js.map +1 -1
- package/build/cjs/integrations/http/add-outgoing-request-breadcrumb.js +43 -0
- package/build/cjs/integrations/http/add-outgoing-request-breadcrumb.js.map +1 -0
- package/build/cjs/integrations/http/client-patch.js +113 -0
- package/build/cjs/integrations/http/client-patch.js.map +1 -0
- package/build/cjs/integrations/http/client-subscriptions.js +166 -0
- package/build/cjs/integrations/http/client-subscriptions.js.map +1 -0
- package/build/cjs/integrations/http/constants.js +10 -0
- package/build/cjs/integrations/http/constants.js.map +1 -0
- package/build/cjs/integrations/http/double-wrap-warning.js +29 -0
- package/build/cjs/integrations/http/double-wrap-warning.js.map +1 -0
- package/build/cjs/integrations/http/get-outgoing-span-data.js +88 -0
- package/build/cjs/integrations/http/get-outgoing-span-data.js.map +1 -0
- package/build/cjs/integrations/http/get-request-url.js +54 -0
- package/build/cjs/integrations/http/get-request-url.js.map +1 -0
- package/build/cjs/integrations/http/inject-trace-propagation-headers.js +81 -0
- package/build/cjs/integrations/http/inject-trace-propagation-headers.js.map +1 -0
- package/build/cjs/integrations/postgresjs.js +10 -1
- package/build/cjs/integrations/postgresjs.js.map +1 -1
- package/build/cjs/integrations/requestdata.js +92 -6
- package/build/cjs/integrations/requestdata.js.map +1 -1
- package/build/cjs/integrations/supabase.js +39 -12
- package/build/cjs/integrations/supabase.js.map +1 -1
- package/build/cjs/logs/console-integration.js +3 -1
- package/build/cjs/logs/console-integration.js.map +1 -1
- package/build/cjs/logs/envelope.js +12 -2
- package/build/cjs/logs/envelope.js.map +1 -1
- package/build/cjs/logs/internal.js +7 -1
- package/build/cjs/logs/internal.js.map +1 -1
- package/build/cjs/metrics/envelope.js +15 -2
- package/build/cjs/metrics/envelope.js.map +1 -1
- package/build/cjs/metrics/internal.js +7 -1
- package/build/cjs/metrics/internal.js.map +1 -1
- package/build/cjs/server-runtime-client.js +20 -2
- package/build/cjs/server-runtime-client.js.map +1 -1
- package/build/cjs/tracing/ai/gen-ai-attributes.js +6 -0
- package/build/cjs/tracing/ai/gen-ai-attributes.js.map +1 -1
- package/build/cjs/tracing/idleSpan.js +7 -1
- package/build/cjs/tracing/idleSpan.js.map +1 -1
- package/build/cjs/tracing/langchain/index.js +43 -8
- package/build/cjs/tracing/langchain/index.js.map +1 -1
- package/build/cjs/tracing/langchain/utils.js +44 -10
- package/build/cjs/tracing/langchain/utils.js.map +1 -1
- package/build/cjs/tracing/langgraph/index.js +105 -2
- package/build/cjs/tracing/langgraph/index.js.map +1 -1
- package/build/cjs/tracing/langgraph/utils.js +168 -0
- package/build/cjs/tracing/langgraph/utils.js.map +1 -1
- package/build/cjs/tracing/spans/captureSpan.js +169 -9
- package/build/cjs/tracing/spans/captureSpan.js.map +1 -1
- package/build/cjs/tracing/spans/envelope.js +13 -3
- package/build/cjs/tracing/spans/envelope.js.map +1 -1
- package/build/cjs/tracing/trace.js +2 -0
- package/build/cjs/tracing/trace.js.map +1 -1
- package/build/cjs/tracing/vercel-ai/constants.js +8 -0
- package/build/cjs/tracing/vercel-ai/constants.js.map +1 -1
- package/build/cjs/tracing/vercel-ai/index.js +93 -14
- package/build/cjs/tracing/vercel-ai/index.js.map +1 -1
- package/build/cjs/trpc.js +2 -3
- package/build/cjs/trpc.js.map +1 -1
- package/build/cjs/utils/baggage.js +73 -0
- package/build/cjs/utils/baggage.js.map +1 -1
- package/build/cjs/utils/chain-and-copy-promiselike.js +1 -0
- package/build/cjs/utils/chain-and-copy-promiselike.js.map +1 -1
- package/build/cjs/utils/get-default-export.js +32 -0
- package/build/cjs/utils/get-default-export.js.map +1 -0
- package/build/cjs/utils/isSentryRequestUrl.js +9 -1
- package/build/cjs/utils/isSentryRequestUrl.js.map +1 -1
- package/build/cjs/utils/normalizationHints.js +38 -0
- package/build/cjs/utils/normalizationHints.js.map +1 -0
- package/build/cjs/utils/normalize.js +7 -11
- package/build/cjs/utils/normalize.js.map +1 -1
- package/build/cjs/utils/object.js +1 -1
- package/build/cjs/utils/object.js.map +1 -1
- package/build/cjs/utils/request.js +192 -12
- package/build/cjs/utils/request.js.map +1 -1
- package/build/cjs/utils/should-ignore-span.js +27 -8
- package/build/cjs/utils/should-ignore-span.js.map +1 -1
- package/build/cjs/utils/spanUtils.js +1 -1
- package/build/cjs/utils/spanUtils.js.map +1 -1
- package/build/cjs/utils/version.js +1 -1
- package/build/esm/client.js +33 -5
- package/build/esm/client.js.map +1 -1
- package/build/esm/envelope.js +4 -1
- package/build/esm/envelope.js.map +1 -1
- package/build/esm/fetch.js +7 -4
- package/build/esm/fetch.js.map +1 -1
- package/build/esm/index.js +11 -5
- package/build/esm/index.js.map +1 -1
- package/build/esm/instrument/console.js +3 -1
- package/build/esm/instrument/console.js.map +1 -1
- package/build/esm/instrument/fetch.js +6 -2
- package/build/esm/instrument/fetch.js.map +1 -1
- package/build/esm/instrument/handlers.js +11 -1
- package/build/esm/instrument/handlers.js.map +1 -1
- package/build/esm/integrations/console.js +3 -1
- package/build/esm/integrations/console.js.map +1 -1
- package/build/esm/integrations/express/index.js +3 -5
- package/build/esm/integrations/express/index.js.map +1 -1
- package/build/esm/integrations/express/utils.js +1 -7
- package/build/esm/integrations/express/utils.js.map +1 -1
- package/build/esm/integrations/extraerrordata.js +2 -2
- package/build/esm/integrations/extraerrordata.js.map +1 -1
- package/build/esm/integrations/http/add-outgoing-request-breadcrumb.js +41 -0
- package/build/esm/integrations/http/add-outgoing-request-breadcrumb.js.map +1 -0
- package/build/esm/integrations/http/client-patch.js +111 -0
- package/build/esm/integrations/http/client-patch.js.map +1 -0
- package/build/esm/integrations/http/client-subscriptions.js +164 -0
- package/build/esm/integrations/http/client-subscriptions.js.map +1 -0
- package/build/esm/integrations/http/constants.js +6 -0
- package/build/esm/integrations/http/constants.js.map +1 -0
- package/build/esm/integrations/http/double-wrap-warning.js +26 -0
- package/build/esm/integrations/http/double-wrap-warning.js.map +1 -0
- package/build/esm/integrations/http/get-outgoing-span-data.js +85 -0
- package/build/esm/integrations/http/get-outgoing-span-data.js.map +1 -0
- package/build/esm/integrations/http/get-request-url.js +49 -0
- package/build/esm/integrations/http/get-request-url.js.map +1 -0
- package/build/esm/integrations/http/inject-trace-propagation-headers.js +79 -0
- package/build/esm/integrations/http/inject-trace-propagation-headers.js.map +1 -0
- package/build/esm/integrations/postgresjs.js +10 -1
- package/build/esm/integrations/postgresjs.js.map +1 -1
- package/build/esm/integrations/requestdata.js +92 -6
- package/build/esm/integrations/requestdata.js.map +1 -1
- package/build/esm/integrations/supabase.js +39 -12
- package/build/esm/integrations/supabase.js.map +1 -1
- package/build/esm/logs/console-integration.js +3 -1
- package/build/esm/logs/console-integration.js.map +1 -1
- package/build/esm/logs/envelope.js +12 -2
- package/build/esm/logs/envelope.js.map +1 -1
- package/build/esm/logs/internal.js +7 -1
- package/build/esm/logs/internal.js.map +1 -1
- package/build/esm/metrics/envelope.js +15 -2
- package/build/esm/metrics/envelope.js.map +1 -1
- package/build/esm/metrics/internal.js +7 -1
- package/build/esm/metrics/internal.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/server-runtime-client.js +20 -2
- package/build/esm/server-runtime-client.js.map +1 -1
- package/build/esm/tracing/ai/gen-ai-attributes.js +6 -1
- package/build/esm/tracing/ai/gen-ai-attributes.js.map +1 -1
- package/build/esm/tracing/idleSpan.js +7 -1
- package/build/esm/tracing/idleSpan.js.map +1 -1
- package/build/esm/tracing/langchain/index.js +45 -10
- package/build/esm/tracing/langchain/index.js.map +1 -1
- package/build/esm/tracing/langchain/utils.js +44 -12
- package/build/esm/tracing/langchain/utils.js.map +1 -1
- package/build/esm/tracing/langgraph/index.js +107 -5
- package/build/esm/tracing/langgraph/index.js.map +1 -1
- package/build/esm/tracing/langgraph/utils.js +166 -2
- package/build/esm/tracing/langgraph/utils.js.map +1 -1
- package/build/esm/tracing/spans/captureSpan.js +170 -11
- package/build/esm/tracing/spans/captureSpan.js.map +1 -1
- package/build/esm/tracing/spans/envelope.js +13 -3
- package/build/esm/tracing/spans/envelope.js.map +1 -1
- package/build/esm/tracing/trace.js +2 -1
- package/build/esm/tracing/trace.js.map +1 -1
- package/build/esm/tracing/vercel-ai/constants.js +8 -1
- package/build/esm/tracing/vercel-ai/constants.js.map +1 -1
- package/build/esm/tracing/vercel-ai/index.js +95 -17
- package/build/esm/tracing/vercel-ai/index.js.map +1 -1
- package/build/esm/trpc.js +2 -3
- package/build/esm/trpc.js.map +1 -1
- package/build/esm/utils/baggage.js +73 -1
- package/build/esm/utils/baggage.js.map +1 -1
- package/build/esm/utils/chain-and-copy-promiselike.js +1 -0
- package/build/esm/utils/chain-and-copy-promiselike.js.map +1 -1
- package/build/esm/utils/get-default-export.js +30 -0
- package/build/esm/utils/get-default-export.js.map +1 -0
- package/build/esm/utils/isSentryRequestUrl.js +9 -1
- package/build/esm/utils/isSentryRequestUrl.js.map +1 -1
- package/build/esm/utils/normalizationHints.js +33 -0
- package/build/esm/utils/normalizationHints.js.map +1 -0
- package/build/esm/utils/normalize.js +7 -11
- package/build/esm/utils/normalize.js.map +1 -1
- package/build/esm/utils/object.js +1 -1
- package/build/esm/utils/object.js.map +1 -1
- package/build/esm/utils/request.js +190 -13
- package/build/esm/utils/request.js.map +1 -1
- package/build/esm/utils/should-ignore-span.js +27 -8
- package/build/esm/utils/should-ignore-span.js.map +1 -1
- package/build/esm/utils/spanUtils.js +1 -1
- package/build/esm/utils/spanUtils.js.map +1 -1
- package/build/esm/utils/version.js +1 -1
- package/build/types/client.d.ts +12 -1
- package/build/types/client.d.ts.map +1 -1
- package/build/types/envelope.d.ts.map +1 -1
- package/build/types/fetch.d.ts.map +1 -1
- package/build/types/index.d.ts +17 -6
- package/build/types/index.d.ts.map +1 -1
- package/build/types/instrument/console.d.ts +2 -1
- package/build/types/instrument/console.d.ts.map +1 -1
- package/build/types/instrument/fetch.d.ts +4 -2
- package/build/types/instrument/fetch.d.ts.map +1 -1
- package/build/types/instrument/handlers.d.ts +2 -2
- package/build/types/instrument/handlers.d.ts.map +1 -1
- package/build/types/integrations/console.d.ts.map +1 -1
- package/build/types/integrations/express/index.d.ts.map +1 -1
- package/build/types/integrations/express/utils.d.ts +1 -5
- package/build/types/integrations/express/utils.d.ts.map +1 -1
- package/build/types/integrations/http/add-outgoing-request-breadcrumb.d.ts +6 -0
- package/build/types/integrations/http/add-outgoing-request-breadcrumb.d.ts.map +1 -0
- package/build/types/integrations/http/client-patch.d.ts +46 -0
- package/build/types/integrations/http/client-patch.d.ts.map +1 -0
- package/build/types/integrations/http/client-subscriptions.d.ts +21 -0
- package/build/types/integrations/http/client-subscriptions.d.ts.map +1 -0
- package/build/types/integrations/http/constants.d.ts +6 -0
- package/build/types/integrations/http/constants.d.ts.map +1 -0
- package/build/types/integrations/http/double-wrap-warning.d.ts +4 -0
- package/build/types/integrations/http/double-wrap-warning.d.ts.map +1 -0
- package/build/types/integrations/http/get-outgoing-span-data.d.ts +13 -0
- package/build/types/integrations/http/get-outgoing-span-data.d.ts.map +1 -0
- package/build/types/integrations/http/get-request-url.d.ts +10 -0
- package/build/types/integrations/http/get-request-url.d.ts.map +1 -0
- package/build/types/integrations/http/index.d.ts +4 -0
- package/build/types/integrations/http/index.d.ts.map +1 -0
- package/build/types/integrations/http/inject-trace-propagation-headers.d.ts +12 -0
- package/build/types/integrations/http/inject-trace-propagation-headers.d.ts.map +1 -0
- package/build/types/integrations/http/types.d.ts +249 -0
- package/build/types/integrations/http/types.d.ts.map +1 -0
- package/build/types/integrations/postgresjs.d.ts.map +1 -1
- package/build/types/integrations/requestdata.d.ts.map +1 -1
- package/build/types/integrations/supabase.d.ts.map +1 -1
- package/build/types/logs/console-integration.d.ts.map +1 -1
- package/build/types/logs/envelope.d.ts +5 -2
- package/build/types/logs/envelope.d.ts.map +1 -1
- package/build/types/logs/internal.d.ts.map +1 -1
- package/build/types/metrics/envelope.d.ts +5 -2
- package/build/types/metrics/envelope.d.ts.map +1 -1
- package/build/types/metrics/internal.d.ts.map +1 -1
- package/build/types/server-runtime-client.d.ts +5 -0
- package/build/types/server-runtime-client.d.ts.map +1 -1
- package/build/types/tracing/idleSpan.d.ts.map +1 -1
- package/build/types/tracing/index.d.ts +1 -1
- package/build/types/tracing/index.d.ts.map +1 -1
- package/build/types/tracing/langchain/index.d.ts.map +1 -1
- package/build/types/tracing/langchain/types.d.ts +8 -0
- package/build/types/tracing/langchain/types.d.ts.map +1 -1
- package/build/types/tracing/langchain/utils.d.ts +2 -0
- package/build/types/tracing/langchain/utils.d.ts.map +1 -1
- package/build/types/tracing/langgraph/index.d.ts +4 -0
- package/build/types/tracing/langgraph/index.d.ts.map +1 -1
- package/build/types/tracing/langgraph/utils.d.ts +18 -2
- package/build/types/tracing/langgraph/utils.d.ts.map +1 -1
- package/build/types/tracing/spans/captureSpan.d.ts +13 -3
- package/build/types/tracing/spans/captureSpan.d.ts.map +1 -1
- package/build/types/tracing/spans/envelope.d.ts.map +1 -1
- package/build/types/tracing/trace.d.ts +1 -0
- package/build/types/tracing/trace.d.ts.map +1 -1
- package/build/types/tracing/vercel-ai/constants.d.ts +1 -0
- package/build/types/tracing/vercel-ai/constants.d.ts.map +1 -1
- package/build/types/tracing/vercel-ai/index.d.ts +9 -0
- package/build/types/tracing/vercel-ai/index.d.ts.map +1 -1
- package/build/types/trpc.d.ts.map +1 -1
- package/build/types/types-hoist/feedback/config.d.ts +20 -0
- package/build/types/types-hoist/feedback/config.d.ts.map +1 -1
- package/build/types/types-hoist/feedback/index.d.ts +2 -2
- package/build/types/types-hoist/feedback/index.d.ts.map +1 -1
- package/build/types/types-hoist/feedback/sendFeedback.d.ts +3 -0
- package/build/types/types-hoist/feedback/sendFeedback.d.ts.map +1 -1
- package/build/types/types-hoist/log.d.ts +5 -0
- package/build/types/types-hoist/log.d.ts.map +1 -1
- package/build/types/types-hoist/metric.d.ts +5 -0
- package/build/types/types-hoist/metric.d.ts.map +1 -1
- package/build/types/types-hoist/options.d.ts +37 -2
- package/build/types/types-hoist/options.d.ts.map +1 -1
- package/build/types/types-hoist/span.d.ts +5 -0
- package/build/types/types-hoist/span.d.ts.map +1 -1
- package/build/types/types-hoist/webfetchapi.d.ts +2 -0
- package/build/types/types-hoist/webfetchapi.d.ts.map +1 -1
- package/build/types/utils/baggage.d.ts +13 -0
- package/build/types/utils/baggage.d.ts.map +1 -1
- package/build/types/utils/get-default-export.d.ts +22 -0
- package/build/types/utils/get-default-export.d.ts.map +1 -0
- package/build/types/utils/normalizationHints.d.ts +9 -0
- package/build/types/utils/normalizationHints.d.ts.map +1 -0
- package/build/types/utils/normalize.d.ts.map +1 -1
- package/build/types/utils/object.d.ts +1 -1
- package/build/types/utils/object.d.ts.map +1 -1
- package/build/types/utils/request.d.ts +30 -0
- package/build/types/utils/request.d.ts.map +1 -1
- package/build/types/utils/should-ignore-span.d.ts +3 -1
- package/build/types/utils/should-ignore-span.d.ts.map +1 -1
- package/build/types/utils/spanUtils.d.ts +1 -1
- package/build/types-ts3.8/client.d.ts +12 -1
- package/build/types-ts3.8/index.d.ts +17 -6
- package/build/types-ts3.8/instrument/console.d.ts +2 -1
- package/build/types-ts3.8/instrument/fetch.d.ts +4 -2
- package/build/types-ts3.8/instrument/handlers.d.ts +2 -2
- package/build/types-ts3.8/integrations/express/utils.d.ts +1 -5
- package/build/types-ts3.8/integrations/http/add-outgoing-request-breadcrumb.d.ts +6 -0
- package/build/types-ts3.8/integrations/http/client-patch.d.ts +46 -0
- package/build/types-ts3.8/integrations/http/client-subscriptions.d.ts +21 -0
- package/build/types-ts3.8/integrations/http/constants.d.ts +6 -0
- package/build/types-ts3.8/integrations/http/double-wrap-warning.d.ts +4 -0
- package/build/types-ts3.8/integrations/http/get-outgoing-span-data.d.ts +13 -0
- package/build/types-ts3.8/integrations/http/get-request-url.d.ts +10 -0
- package/build/types-ts3.8/integrations/http/index.d.ts +4 -0
- package/build/types-ts3.8/integrations/http/inject-trace-propagation-headers.d.ts +12 -0
- package/build/types-ts3.8/integrations/http/types.d.ts +252 -0
- package/build/types-ts3.8/logs/envelope.d.ts +5 -2
- package/build/types-ts3.8/metrics/envelope.d.ts +5 -2
- package/build/types-ts3.8/server-runtime-client.d.ts +5 -0
- package/build/types-ts3.8/tracing/index.d.ts +1 -1
- package/build/types-ts3.8/tracing/langchain/types.d.ts +8 -0
- package/build/types-ts3.8/tracing/langchain/utils.d.ts +2 -0
- package/build/types-ts3.8/tracing/langgraph/index.d.ts +4 -0
- package/build/types-ts3.8/tracing/langgraph/utils.d.ts +18 -2
- package/build/types-ts3.8/tracing/spans/captureSpan.d.ts +13 -3
- package/build/types-ts3.8/tracing/trace.d.ts +1 -0
- package/build/types-ts3.8/tracing/vercel-ai/constants.d.ts +1 -0
- package/build/types-ts3.8/tracing/vercel-ai/index.d.ts +9 -0
- package/build/types-ts3.8/types-hoist/feedback/config.d.ts +20 -0
- package/build/types-ts3.8/types-hoist/feedback/index.d.ts +2 -2
- package/build/types-ts3.8/types-hoist/feedback/sendFeedback.d.ts +3 -0
- package/build/types-ts3.8/types-hoist/log.d.ts +5 -0
- package/build/types-ts3.8/types-hoist/metric.d.ts +5 -0
- package/build/types-ts3.8/types-hoist/options.d.ts +37 -2
- package/build/types-ts3.8/types-hoist/span.d.ts +5 -0
- package/build/types-ts3.8/types-hoist/webfetchapi.d.ts +2 -0
- package/build/types-ts3.8/utils/baggage.d.ts +13 -0
- package/build/types-ts3.8/utils/get-default-export.d.ts +22 -0
- package/build/types-ts3.8/utils/normalizationHints.d.ts +9 -0
- package/build/types-ts3.8/utils/object.d.ts +1 -1
- package/build/types-ts3.8/utils/request.d.ts +30 -0
- package/build/types-ts3.8/utils/should-ignore-span.d.ts +3 -1
- package/build/types-ts3.8/utils/spanUtils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestdata.js","sources":["../../../src/integrations/requestdata.ts"],"sourcesContent":["import { defineIntegration } from '../integration';\nimport type { Event } from '../types-hoist/event';\nimport type { IntegrationFn } from '../types-hoist/integration';\nimport type { RequestEventData } from '../types-hoist/request';\nimport { parseCookie } from '../utils/cookie';\nimport { getClientIPAddress, ipHeaderNames } from '../vendor/getIpAddress';\n\ninterface RequestDataIncludeOptions {\n cookies?: boolean;\n data?: boolean;\n headers?: boolean;\n ip?: boolean;\n query_string?: boolean;\n url?: boolean;\n}\n\ntype RequestDataIntegrationOptions = {\n /**\n * Controls what data is pulled from the request and added to the event.\n */\n include?: RequestDataIncludeOptions;\n};\n\n// TODO(v11): Change defaults based on `sendDefaultPii`\nconst DEFAULT_INCLUDE: RequestDataIncludeOptions = {\n cookies: true,\n data: true,\n headers: true,\n query_string: true,\n url: true,\n};\n\nconst INTEGRATION_NAME = 'RequestData';\n\nconst _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) => {\n const include = {\n ...DEFAULT_INCLUDE,\n ...options.include,\n };\n\n return {\n name: INTEGRATION_NAME,\n processEvent(event, _hint, client) {\n const { sdkProcessingMetadata = {} } = event;\n const { normalizedRequest, ipAddress } = sdkProcessingMetadata;\n\n const includeWithDefaultPiiApplied: RequestDataIncludeOptions = {\n ...include,\n ip: include.ip ?? client.getOptions().sendDefaultPii,\n };\n\n if (normalizedRequest) {\n addNormalizedRequestDataToEvent(event, normalizedRequest, { ipAddress }, includeWithDefaultPiiApplied);\n }\n\n return event;\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/core`\n * so it can be used in cross-platform SDKs like `@sentry/nextjs`.\n */\nexport const requestDataIntegration = defineIntegration(_requestDataIntegration);\n\n/**\n * Add already normalized request data to an event.\n * This mutates the passed in event.\n */\nfunction addNormalizedRequestDataToEvent(\n event: Event,\n req: RequestEventData,\n // Data that should not go into `event.request` but is somehow related to requests\n additionalData: { ipAddress?: string },\n include: RequestDataIncludeOptions,\n): void {\n event.request = {\n ...event.request,\n ...extractNormalizedRequestData(req, include),\n };\n\n if (include.ip) {\n const ip = (req.headers && getClientIPAddress(req.headers)) || additionalData.ipAddress;\n if (ip) {\n event.user = {\n ...event.user,\n ip_address: ip,\n };\n }\n }\n}\n\nfunction extractNormalizedRequestData(\n normalizedRequest: RequestEventData,\n include: RequestDataIncludeOptions,\n): RequestEventData {\n const requestData: RequestEventData = {};\n const headers = { ...normalizedRequest.headers };\n\n if (include.headers) {\n requestData.headers = headers;\n\n // Remove the Cookie header in case cookie data should not be included in the event\n if (!include.cookies) {\n delete (headers as { cookie?: string }).cookie;\n }\n\n // Remove IP headers in case IP data should not be included in the event\n if (!include.ip) {\n ipHeaderNames.forEach(ipHeaderName => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete (headers as Record<string, unknown>)[ipHeaderName];\n });\n }\n }\n\n requestData.method = normalizedRequest.method;\n\n if (include.url) {\n requestData.url = normalizedRequest.url;\n }\n\n if (include.cookies) {\n const cookies = normalizedRequest.cookies || (headers?.cookie ? parseCookie(headers.cookie) : undefined);\n requestData.cookies = cookies || {};\n }\n\n if (include.query_string) {\n requestData.query_string = normalizedRequest.query_string;\n }\n\n if (include.data) {\n requestData.data = normalizedRequest.data;\n }\n\n return requestData;\n}\n"],"names":["defineIntegration","getClientIPAddress","ipHeaderNames","parseCookie"],"mappings":";;;;;;AAuBA;AACA,MAAM,eAAe,GAA8B;AACnD,EAAE,OAAO,EAAE,IAAI;AACf,EAAE,IAAI,EAAE,IAAI;AACZ,EAAE,OAAO,EAAE,IAAI;AACf,EAAE,YAAY,EAAE,IAAI;AACpB,EAAE,GAAG,EAAE,IAAI;AACX,CAAC;;AAED,MAAM,gBAAA,GAAmB,aAAa;;AAEtC,MAAM,uBAAA,IAA2B,CAAC,OAAO,GAAkC,EAAE,KAAK;AAClF,EAAE,MAAM,UAAU;AAClB,IAAI,GAAG,eAAe;AACtB,IAAI,GAAG,OAAO,CAAC,OAAO;AACtB,GAAG;;AAEH,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE;AACvC,MAAM,MAAM,EAAE,qBAAA,GAAwB,EAAC,EAAE,GAAI,KAAK;AAClD,MAAM,MAAM,EAAE,iBAAiB,EAAE,SAAA,EAAU,GAAI,qBAAqB;;AAEpE,MAAM,MAAM,4BAA4B,GAA8B;AACtE,QAAQ,GAAG,OAAO;AAClB,QAAQ,EAAE,EAAE,OAAO,CAAC,EAAA,IAAM,MAAM,CAAC,UAAU,EAAE,CAAC,cAAc;AAC5D,OAAO;;AAEP,MAAM,IAAI,iBAAiB,EAAE;AAC7B,QAAQ,+BAA+B,CAAC,KAAK,EAAE,iBAAiB,EAAE,EAAE,SAAA,EAAW,EAAE,4BAA4B,CAAC;AAC9G,MAAM;;AAEN,MAAM,OAAO,KAAK;AAClB,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;AACA;MACa,sBAAA,GAAyBA,6BAAiB,CAAC,uBAAuB;;AAE/E;AACA;AACA;AACA;AACA,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CAAC,GAAG,EAAE;AACnB,IAAI,WAAW,CAAC,GAAA,GAAM,iBAAiB,CAAC,GAAG;AAC3C,EAAE;;AAEF,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE;AACvB,IAAI,MAAM,UAAU,iBAAiB,CAAC,OAAA,KAAY,OAAO,EAAE,SAASC,kBAAW,CAAC,OAAO,CAAC,MAAM,CAAA,GAAI,SAAS,CAAC;AAC5G,IAAI,WAAW,CAAC,OAAA,GAAU,OAAA,IAAW,EAAE;AACvC,EAAE;;AAEF,EAAE,IAAI,OAAO,CAAC,YAAY,EAAE;AAC5B,IAAI,WAAW,CAAC,YAAA,GAAe,iBAAiB,CAAC,YAAY;AAC7D,EAAE;;AAEF,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE;AACpB,IAAI,WAAW,CAAC,IAAA,GAAO,iBAAiB,CAAC,IAAI;AAC7C,EAAE;;AAEF,EAAE,OAAO,WAAW;AACpB;;;;"}
|
|
1
|
+
{"version":3,"file":"requestdata.js","sources":["../../../src/integrations/requestdata.ts"],"sourcesContent":["import { getIsolationScope } from '../currentScopes';\nimport { defineIntegration } from '../integration';\nimport { SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS } from '../semanticAttributes';\nimport type { Event } from '../types-hoist/event';\nimport type { IntegrationFn } from '../types-hoist/integration';\nimport type { QueryParams, RequestEventData } from '../types-hoist/request';\nimport type { StreamedSpanJSON } from '../types-hoist/span';\nimport { parseCookie } from '../utils/cookie';\nimport { httpHeadersToSpanAttributes } from '../utils/request';\nimport { getClientIPAddress, ipHeaderNames } from '../vendor/getIpAddress';\nimport { safeSetSpanJSONAttributes } from '../tracing/spans/captureSpan';\n\ninterface RequestDataIncludeOptions {\n cookies?: boolean;\n data?: boolean;\n headers?: boolean;\n ip?: boolean;\n query_string?: boolean;\n url?: boolean;\n}\n\ntype RequestDataIntegrationOptions = {\n /**\n * Controls what data is pulled from the request and added to the event.\n */\n include?: RequestDataIncludeOptions;\n};\n\n// TODO(v11): Change defaults based on `sendDefaultPii`\nconst DEFAULT_INCLUDE: RequestDataIncludeOptions = {\n cookies: true,\n data: true,\n headers: true,\n query_string: true,\n url: true,\n};\n\nconst INTEGRATION_NAME = 'RequestData';\n\nconst _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) => {\n const include = {\n ...DEFAULT_INCLUDE,\n ...options.include,\n };\n\n return {\n name: INTEGRATION_NAME,\n processEvent(event, _hint, client) {\n const { sdkProcessingMetadata = {} } = event;\n const { normalizedRequest, ipAddress } = sdkProcessingMetadata;\n\n const includeWithDefaultPiiApplied: RequestDataIncludeOptions = {\n ...include,\n ip: include.ip ?? client.getOptions().sendDefaultPii,\n };\n\n if (normalizedRequest) {\n addNormalizedRequestDataToEvent(event, normalizedRequest, { ipAddress }, includeWithDefaultPiiApplied);\n }\n\n return event;\n },\n processSegmentSpan(span, client) {\n const { sdkProcessingMetadata = {} } = getIsolationScope().getScopeData();\n const { normalizedRequest, ipAddress } = sdkProcessingMetadata;\n\n if (!normalizedRequest) {\n return;\n }\n\n const { sendDefaultPii } = client.getOptions();\n const includeWithDefaultPiiApplied: RequestDataIncludeOptions = {\n ...include,\n ip: include.ip ?? sendDefaultPii,\n };\n\n addNormalizedRequestDataToSpan(span, normalizedRequest, ipAddress, includeWithDefaultPiiApplied, sendDefaultPii);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/core`\n * so it can be used in cross-platform SDKs like `@sentry/nextjs`.\n */\nexport const requestDataIntegration = defineIntegration(_requestDataIntegration);\n\n/**\n * Add already normalized request data to an event.\n * This mutates the passed in event.\n */\nfunction addNormalizedRequestDataToEvent(\n event: Event,\n req: RequestEventData,\n // Data that should not go into `event.request` but is somehow related to requests\n additionalData: { ipAddress?: string },\n include: RequestDataIncludeOptions,\n): void {\n event.request = {\n ...event.request,\n ...extractNormalizedRequestData(req, include),\n };\n\n if (include.ip) {\n const ip = (req.headers && getClientIPAddress(req.headers)) || additionalData.ipAddress;\n if (ip) {\n event.user = {\n ...event.user,\n ip_address: ip,\n };\n }\n }\n}\n\nfunction addNormalizedRequestDataToSpan(\n span: StreamedSpanJSON,\n normalizedRequest: RequestEventData,\n ipAddress: string | undefined,\n include: RequestDataIncludeOptions,\n sendDefaultPii: boolean | undefined,\n): void {\n const requestData = extractNormalizedRequestData(normalizedRequest, include);\n const attributes: Record<string, unknown> = {};\n\n if (requestData.url) {\n attributes['url.full'] = requestData.url;\n }\n\n if (requestData.method) {\n attributes['http.request.method'] = requestData.method;\n }\n\n if (requestData.query_string) {\n attributes['url.query'] = normalizeQueryString(requestData.query_string);\n }\n\n safeSetSpanJSONAttributes(span, attributes);\n\n // Process cookies before headers so normalizedRequest.cookies takes precedence\n // over the raw cookie header (matching the processEvent path).\n if (requestData.cookies && Object.keys(requestData.cookies).length > 0) {\n const cookieString = Object.entries(requestData.cookies)\n .map(([name, value]) => `${name}=${value}`)\n .join('; ');\n const cookieAttributes = httpHeadersToSpanAttributes({ cookie: cookieString }, sendDefaultPii ?? false, 'request');\n safeSetSpanJSONAttributes(span, cookieAttributes);\n }\n\n if (requestData.headers) {\n const headerAttributes = httpHeadersToSpanAttributes(requestData.headers, sendDefaultPii ?? false, 'request');\n safeSetSpanJSONAttributes(span, headerAttributes);\n }\n\n if (requestData.data != null) {\n const serialized = typeof requestData.data === 'string' ? requestData.data : JSON.stringify(requestData.data);\n if (serialized) {\n safeSetSpanJSONAttributes(span, { 'http.request.body.data': serialized });\n }\n }\n\n if (include.ip) {\n const ip = (normalizedRequest.headers && getClientIPAddress(normalizedRequest.headers)) || ipAddress || undefined;\n if (ip) {\n safeSetSpanJSONAttributes(span, { [SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS]: ip });\n }\n }\n}\n\nfunction extractNormalizedRequestData(\n normalizedRequest: RequestEventData,\n include: RequestDataIncludeOptions,\n): RequestEventData {\n const requestData: RequestEventData = {};\n const headers = { ...normalizedRequest.headers };\n\n if (include.headers) {\n requestData.headers = headers;\n\n if (!include.cookies) {\n delete (headers as { cookie?: string }).cookie;\n }\n\n if (!include.ip) {\n const ipHeaderNamesLower = new Set(ipHeaderNames.map(name => name.toLowerCase()));\n for (const key of Object.keys(headers)) {\n if (ipHeaderNamesLower.has(key.toLowerCase())) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete (headers as Record<string, unknown>)[key];\n }\n }\n }\n }\n\n requestData.method = normalizedRequest.method;\n\n if (include.url) {\n requestData.url = normalizedRequest.url;\n }\n\n if (include.cookies) {\n const cookies = normalizedRequest.cookies || (headers?.cookie ? parseCookie(headers.cookie) : undefined);\n requestData.cookies = cookies || {};\n }\n\n if (include.query_string) {\n requestData.query_string = normalizedRequest.query_string;\n }\n\n if (include.data) {\n requestData.data = normalizedRequest.data;\n }\n\n return requestData;\n}\n\nfunction normalizeQueryString(queryString: QueryParams): string | undefined {\n if (typeof queryString === 'string') {\n return queryString || undefined;\n }\n\n const pairs = Array.isArray(queryString) ? queryString : Object.entries(queryString);\n const result = pairs.map(([key, value]) => `${key}=${value}`).join('&');\n\n return result || undefined;\n}\n"],"names":["getIsolationScope","defineIntegration","getClientIPAddress","safeSetSpanJSONAttributes","httpHeadersToSpanAttributes","SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS","ipHeaderNames","parseCookie"],"mappings":";;;;;;;;;;AA4BA;AACA,MAAM,eAAe,GAA8B;AACnD,EAAE,OAAO,EAAE,IAAI;AACf,EAAE,IAAI,EAAE,IAAI;AACZ,EAAE,OAAO,EAAE,IAAI;AACf,EAAE,YAAY,EAAE,IAAI;AACpB,EAAE,GAAG,EAAE,IAAI;AACX,CAAC;;AAED,MAAM,gBAAA,GAAmB,aAAa;;AAEtC,MAAM,uBAAA,IAA2B,CAAC,OAAO,GAAkC,EAAE,KAAK;AAClF,EAAE,MAAM,UAAU;AAClB,IAAI,GAAG,eAAe;AACtB,IAAI,GAAG,OAAO,CAAC,OAAO;AACtB,GAAG;;AAEH,EAAE,OAAO;A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AA,CAAA,MAAA,CAAA,GAAA,SAAA,CAAA;AACA,IAAA,WAAA,CAAA,OAAA,GAAA,OAAA,IAAA,EAAA;AACA,EAAA;;AAEA,EAAA,IAAA,OAAA,CAAA,YAAA,EAAA;AACA,IAAA,WAAA,CAAA,YAAA,GAAA,iBAAA,CAAA,YAAA;AACA,EAAA;;AAEA,EAAA,IAAA,OAAA,CAAA,IAAA,EAAA;AACA,IAAA,WAAA,CAAA,IAAA,GAAA,iBAAA,CAAA,IAAA;AACA,EAAA;;AAEA,EAAA,OAAA,WAAA;AACA;;AAEA,SAAA,oBAAA,CAAA,WAAA,EAAA;AACA,EAAA,IAAA,OAAA,WAAA,KAAA,QAAA,EAAA;AACA,IAAA,OAAA,WAAA,IAAA,SAAA;AACA,EAAA;;AAEA,EAAA,MAAA,KAAA,GAAA,KAAA,CAAA,OAAA,CAAA,WAAA,CAAA,GAAA,WAAA,GAAA,MAAA,CAAA,OAAA,CAAA,WAAA,CAAA;AACA,EAAA,MAAA,MAAA,GAAA,KAAA,CAAA,GAAA,CAAA,CAAA,CAAA,GAAA,EAAA,KAAA,CAAA,KAAA,CAAA,EAAA,GAAA,CAAA,CAAA,EAAA,KAAA,CAAA,CAAA,CAAA,CAAA,IAAA,CAAA,GAAA,CAAA;;AAEA,EAAA,OAAA,MAAA,IAAA,SAAA;AACA;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const breadcrumbs = require('../breadcrumbs.js');
|
|
4
|
+
const currentScopes = require('../currentScopes.js');
|
|
4
5
|
const debugBuild = require('../debug-build.js');
|
|
5
6
|
const _exports = require('../exports.js');
|
|
6
7
|
const integration = require('../integration.js');
|
|
@@ -85,6 +86,25 @@ function isInstrumented(fn) {
|
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Plain-object bodies are copied into `plainBody`; array inserts (and other non-plain shapes) stay only on `rawBody`.
|
|
91
|
+
* Returns a payload suitable for span attributes / breadcrumbs when the client has `sendDefaultPii` enabled.
|
|
92
|
+
*/
|
|
93
|
+
function getMutationBodyPayloadForTelemetry(rawBody, plainBody) {
|
|
94
|
+
if (Object.keys(plainBody).length > 0) {
|
|
95
|
+
return plainBody;
|
|
96
|
+
}
|
|
97
|
+
if (Array.isArray(rawBody) && rawBody.length > 0) {
|
|
98
|
+
return rawBody;
|
|
99
|
+
}
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** True when the PostgREST builder carries a mutation body (for `insert(...)`, etc. in span descriptions). */
|
|
104
|
+
function hasMutationBodyForDescription(rawBody, plainBody) {
|
|
105
|
+
return getMutationBodyPayloadForTelemetry(rawBody, plainBody) !== undefined;
|
|
106
|
+
}
|
|
107
|
+
|
|
88
108
|
/**
|
|
89
109
|
* Extracts the database operation type from the HTTP method and headers
|
|
90
110
|
* @param method - The HTTP method of the request
|
|
@@ -298,12 +318,19 @@ function instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder) {
|
|
|
298
318
|
}
|
|
299
319
|
}
|
|
300
320
|
|
|
321
|
+
const sendDefaultPii = Boolean(currentScopes.getClient()?.getOptions().sendDefaultPii);
|
|
322
|
+
const bodyPayload = getMutationBodyPayloadForTelemetry(typedThis.body, body);
|
|
323
|
+
|
|
301
324
|
// Adding operation to the beginning of the description if it's not a `select` operation
|
|
302
325
|
// For example, it can be an `insert` or `update` operation but the query can be `select(...)`
|
|
303
326
|
// For `select` operations, we don't need repeat it in the description
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
327
|
+
const mutationPart =
|
|
328
|
+
operation === 'select'
|
|
329
|
+
? ''
|
|
330
|
+
: `${operation}${hasMutationBodyForDescription(typedThis.body, body) ? '(...) ' : ''}`;
|
|
331
|
+
const queryPart = sendDefaultPii ? queryItems.join(' ') : queryItems.length > 0 ? '[redacted]' : '';
|
|
332
|
+
const descriptionMiddle = [mutationPart.trimEnd(), queryPart].filter(Boolean).join(' ');
|
|
333
|
+
const description = descriptionMiddle ? `${descriptionMiddle} from(${table})` : `from(${table})`;
|
|
307
334
|
|
|
308
335
|
const attributes = {
|
|
309
336
|
'db.table': table,
|
|
@@ -316,12 +343,12 @@ function instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder) {
|
|
|
316
343
|
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',
|
|
317
344
|
};
|
|
318
345
|
|
|
319
|
-
if (queryItems.length) {
|
|
346
|
+
if (queryItems.length && sendDefaultPii) {
|
|
320
347
|
attributes['db.query'] = queryItems;
|
|
321
348
|
}
|
|
322
349
|
|
|
323
|
-
if (
|
|
324
|
-
attributes['db.body'] =
|
|
350
|
+
if (bodyPayload !== undefined && sendDefaultPii) {
|
|
351
|
+
attributes['db.body'] = bodyPayload;
|
|
325
352
|
}
|
|
326
353
|
|
|
327
354
|
return trace.startSpan(
|
|
@@ -350,11 +377,11 @@ function instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder) {
|
|
|
350
377
|
}
|
|
351
378
|
|
|
352
379
|
const supabaseContext = {};
|
|
353
|
-
if (queryItems.length) {
|
|
380
|
+
if (queryItems.length && sendDefaultPii) {
|
|
354
381
|
supabaseContext.query = queryItems;
|
|
355
382
|
}
|
|
356
|
-
if (
|
|
357
|
-
supabaseContext.body =
|
|
383
|
+
if (bodyPayload !== undefined && sendDefaultPii) {
|
|
384
|
+
supabaseContext.body = bodyPayload;
|
|
358
385
|
}
|
|
359
386
|
|
|
360
387
|
_exports.captureException(err, scope => {
|
|
@@ -381,12 +408,12 @@ function instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder) {
|
|
|
381
408
|
|
|
382
409
|
const data = {};
|
|
383
410
|
|
|
384
|
-
if (queryItems.length) {
|
|
411
|
+
if (queryItems.length && sendDefaultPii) {
|
|
385
412
|
data.query = queryItems;
|
|
386
413
|
}
|
|
387
414
|
|
|
388
|
-
if (
|
|
389
|
-
data.body =
|
|
415
|
+
if (bodyPayload !== undefined && sendDefaultPii) {
|
|
416
|
+
data.body = bodyPayload;
|
|
390
417
|
}
|
|
391
418
|
|
|
392
419
|
if (Object.keys(data).length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supabase.js","sources":["../../../src/integrations/supabase.ts"],"sourcesContent":["// Based on Kamil Ogórek's work on:\n// https://github.com/supabase-community/sentry-integration-js\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable max-lines */\nimport { addBreadcrumb } from '../breadcrumbs';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { captureException } from '../exports';\nimport { defineIntegration } from '../integration';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';\nimport { setHttpStatus, SPAN_STATUS_ERROR, SPAN_STATUS_OK, startSpan } from '../tracing';\nimport type { IntegrationFn } from '../types-hoist/integration';\nimport { debug } from '../utils/debug-logger';\nimport { isPlainObject } from '../utils/is';\nimport { addExceptionMechanism } from '../utils/misc';\n\nconst AUTH_OPERATIONS_TO_INSTRUMENT = [\n 'reauthenticate',\n 'signInAnonymously',\n 'signInWithOAuth',\n 'signInWithIdToken',\n 'signInWithOtp',\n 'signInWithPassword',\n 'signInWithSSO',\n 'signOut',\n 'signUp',\n 'verifyOtp',\n];\n\nconst AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT = [\n 'createUser',\n 'deleteUser',\n 'listUsers',\n 'getUserById',\n 'updateUserById',\n 'inviteUserByEmail',\n];\n\nexport const FILTER_MAPPINGS = {\n eq: 'eq',\n neq: 'neq',\n gt: 'gt',\n gte: 'gte',\n lt: 'lt',\n lte: 'lte',\n like: 'like',\n 'like(all)': 'likeAllOf',\n 'like(any)': 'likeAnyOf',\n ilike: 'ilike',\n 'ilike(all)': 'ilikeAllOf',\n 'ilike(any)': 'ilikeAnyOf',\n is: 'is',\n in: 'in',\n cs: 'contains',\n cd: 'containedBy',\n sr: 'rangeGt',\n nxl: 'rangeGte',\n sl: 'rangeLt',\n nxr: 'rangeLte',\n adj: 'rangeAdjacent',\n ov: 'overlaps',\n fts: '',\n plfts: 'plain',\n phfts: 'phrase',\n wfts: 'websearch',\n not: 'not',\n};\n\nexport const DB_OPERATIONS_TO_INSTRUMENT = ['select', 'insert', 'upsert', 'update', 'delete'];\n\ntype AuthOperationFn = (...args: unknown[]) => Promise<unknown>;\ntype AuthOperationName = (typeof AUTH_OPERATIONS_TO_INSTRUMENT)[number];\ntype AuthAdminOperationName = (typeof AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT)[number];\ntype PostgRESTQueryOperationFn = (...args: unknown[]) => PostgRESTFilterBuilder;\n\nexport interface SupabaseClientInstance {\n auth: {\n admin: Record<AuthAdminOperationName, AuthOperationFn>;\n } & Record<AuthOperationName, AuthOperationFn>;\n}\n\nexport interface PostgRESTQueryBuilder {\n [key: string]: PostgRESTQueryOperationFn;\n}\n\nexport interface PostgRESTFilterBuilder {\n method: string;\n headers: Record<string, string>;\n url: URL;\n schema: string;\n body: any;\n}\n\nexport interface SupabaseResponse {\n status?: number;\n error?: {\n message: string;\n code?: string;\n details?: unknown;\n };\n}\n\nexport interface SupabaseError extends Error {\n code?: string;\n details?: unknown;\n}\n\nexport interface SupabaseBreadcrumb {\n type: string;\n category: string;\n message: string;\n data?: {\n query?: string[];\n body?: Record<string, unknown>;\n };\n}\n\nexport interface SupabaseClientConstructor {\n prototype: {\n from: (table: string) => PostgRESTQueryBuilder;\n };\n}\n\nexport interface PostgRESTProtoThenable {\n then: <T>(\n onfulfilled?: ((value: T) => T | PromiseLike<T>) | null,\n onrejected?: ((reason: any) => T | PromiseLike<T>) | null,\n ) => Promise<T>;\n}\n\ntype SentryInstrumented<T> = T & {\n __SENTRY_INSTRUMENTED__?: boolean;\n};\n\nfunction markAsInstrumented<T>(fn: T): void {\n try {\n (fn as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__ = true;\n } catch {\n // ignore errors here\n }\n}\n\nfunction isInstrumented<T>(fn: T): boolean | undefined {\n try {\n return (fn as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__;\n } catch {\n return false;\n }\n}\n\n/**\n * Extracts the database operation type from the HTTP method and headers\n * @param method - The HTTP method of the request\n * @param headers - The request headers\n * @returns The database operation type ('select', 'insert', 'upsert', 'update', or 'delete')\n */\nexport function extractOperation(method: string, headers: Record<string, string> = {}): string {\n switch (method) {\n case 'GET': {\n return 'select';\n }\n case 'POST': {\n if (headers['Prefer']?.includes('resolution=')) {\n return 'upsert';\n } else {\n return 'insert';\n }\n }\n case 'PATCH': {\n return 'update';\n }\n case 'DELETE': {\n return 'delete';\n }\n default: {\n return '<unknown-op>';\n }\n }\n}\n\n/**\n * Translates Supabase filter parameters into readable method names for tracing\n * @param key - The filter key from the URL search parameters\n * @param query - The filter value from the URL search parameters\n * @returns A string representation of the filter as a method call\n */\nexport function translateFiltersIntoMethods(key: string, query: string): string {\n if (query === '' || query === '*') {\n return 'select(*)';\n }\n\n if (key === 'select') {\n return `select(${query})`;\n }\n\n if (key === 'or' || key.endsWith('.or')) {\n return `${key}${query}`;\n }\n\n const [filter, ...value] = query.split('.');\n\n let method;\n // Handle optional `configPart` of the filter\n if (filter?.startsWith('fts')) {\n method = 'textSearch';\n } else if (filter?.startsWith('plfts')) {\n method = 'textSearch[plain]';\n } else if (filter?.startsWith('phfts')) {\n method = 'textSearch[phrase]';\n } else if (filter?.startsWith('wfts')) {\n method = 'textSearch[websearch]';\n } else {\n method = (filter && FILTER_MAPPINGS[filter as keyof typeof FILTER_MAPPINGS]) || 'filter';\n }\n\n return `${method}(${key}, ${value.join('.')})`;\n}\n\nfunction instrumentAuthOperation(operation: AuthOperationFn, isAdmin = false): AuthOperationFn {\n return new Proxy(operation, {\n apply(target, thisArg, argumentsList) {\n return startSpan(\n {\n name: `auth ${isAdmin ? '(admin) ' : ''}${operation.name}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n 'db.system': 'postgresql',\n 'db.operation': `auth.${isAdmin ? 'admin.' : ''}${operation.name}`,\n },\n },\n span => {\n return Reflect.apply(target, thisArg, argumentsList)\n .then((res: unknown) => {\n if (res && typeof res === 'object' && 'error' in res && res.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n\n captureException(res.error, {\n mechanism: {\n handled: false,\n type: 'auto.db.supabase.auth',\n },\n });\n } else {\n span.setStatus({ code: SPAN_STATUS_OK });\n }\n\n span.end();\n return res;\n })\n .catch((err: unknown) => {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n span.end();\n\n captureException(err, {\n mechanism: {\n handled: false,\n type: 'auto.db.supabase.auth',\n },\n });\n\n throw err;\n })\n .then(...argumentsList);\n },\n );\n },\n });\n}\n\nfunction instrumentSupabaseAuthClient(supabaseClientInstance: SupabaseClientInstance): void {\n const auth = supabaseClientInstance.auth;\n\n if (!auth || isInstrumented(supabaseClientInstance.auth)) {\n return;\n }\n\n for (const operation of AUTH_OPERATIONS_TO_INSTRUMENT) {\n const authOperation = auth[operation];\n\n if (!authOperation) {\n continue;\n }\n\n if (typeof supabaseClientInstance.auth[operation] === 'function') {\n supabaseClientInstance.auth[operation] = instrumentAuthOperation(authOperation);\n }\n }\n\n for (const operation of AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT) {\n const authOperation = auth.admin[operation];\n\n if (!authOperation) {\n continue;\n }\n\n if (typeof supabaseClientInstance.auth.admin[operation] === 'function') {\n supabaseClientInstance.auth.admin[operation] = instrumentAuthOperation(authOperation, true);\n }\n }\n\n markAsInstrumented(supabaseClientInstance.auth);\n}\n\nfunction instrumentSupabaseClientConstructor(SupabaseClient: unknown): void {\n if (isInstrumented((SupabaseClient as SupabaseClientConstructor).prototype.from)) {\n return;\n }\n\n (SupabaseClient as SupabaseClientConstructor).prototype.from = new Proxy(\n (SupabaseClient as SupabaseClientConstructor).prototype.from,\n {\n apply(target, thisArg, argumentsList) {\n const rv = Reflect.apply(target, thisArg, argumentsList);\n const PostgRESTQueryBuilder = (rv as PostgRESTQueryBuilder).constructor;\n\n instrumentPostgRESTQueryBuilder(PostgRESTQueryBuilder as unknown as new () => PostgRESTQueryBuilder);\n\n return rv;\n },\n },\n );\n\n markAsInstrumented((SupabaseClient as SupabaseClientConstructor).prototype.from);\n}\n\nfunction instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder: PostgRESTFilterBuilder['constructor']): void {\n if (isInstrumented((PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then)) {\n return;\n }\n\n (PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then = new Proxy(\n (PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then,\n {\n apply(target, thisArg, argumentsList) {\n const operations = DB_OPERATIONS_TO_INSTRUMENT;\n const typedThis = thisArg as PostgRESTFilterBuilder;\n const operation = extractOperation(typedThis.method, typedThis.headers);\n\n if (!operations.includes(operation)) {\n return Reflect.apply(target, thisArg, argumentsList);\n }\n\n if (!typedThis?.url?.pathname || typeof typedThis.url.pathname !== 'string') {\n return Reflect.apply(target, thisArg, argumentsList);\n }\n\n const pathParts = typedThis.url.pathname.split('/');\n const table = pathParts.length > 0 ? pathParts[pathParts.length - 1] : '';\n\n const queryItems: string[] = [];\n for (const [key, value] of typedThis.url.searchParams.entries()) {\n // It's possible to have multiple entries for the same key, eg. `id=eq.7&id=eq.3`,\n // so we need to use array instead of object to collect them.\n queryItems.push(translateFiltersIntoMethods(key, value));\n }\n const body: Record<string, unknown> = Object.create(null);\n if (isPlainObject(typedThis.body)) {\n for (const [key, value] of Object.entries(typedThis.body)) {\n body[key] = value;\n }\n }\n\n // Adding operation to the beginning of the description if it's not a `select` operation\n // For example, it can be an `insert` or `update` operation but the query can be `select(...)`\n // For `select` operations, we don't need repeat it in the description\n const description = `${operation === 'select' ? '' : `${operation}${body ? '(...) ' : ''}`}${queryItems.join(\n ' ',\n )} from(${table})`;\n\n const attributes: Record<string, any> = {\n 'db.table': table,\n 'db.schema': typedThis.schema,\n 'db.url': typedThis.url.origin,\n 'db.sdk': typedThis.headers['X-Client-Info'],\n 'db.system': 'postgresql',\n 'db.operation': operation,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n };\n\n if (queryItems.length) {\n attributes['db.query'] = queryItems;\n }\n\n if (Object.keys(body).length) {\n attributes['db.body'] = body;\n }\n\n return startSpan(\n {\n name: description,\n attributes,\n },\n span => {\n return (Reflect.apply(target, thisArg, []) as Promise<SupabaseResponse>)\n .then(\n (res: SupabaseResponse) => {\n if (span) {\n if (res && typeof res === 'object' && 'status' in res) {\n setHttpStatus(span, res.status || 500);\n }\n span.end();\n }\n\n if (res?.error) {\n const err = new Error(res.error.message) as SupabaseError;\n if (res.error.code) {\n err.code = res.error.code;\n }\n if (res.error.details) {\n err.details = res.error.details;\n }\n\n const supabaseContext: Record<string, any> = {};\n if (queryItems.length) {\n supabaseContext.query = queryItems;\n }\n if (Object.keys(body).length) {\n supabaseContext.body = body;\n }\n\n captureException(err, scope => {\n scope.addEventProcessor(e => {\n addExceptionMechanism(e, {\n handled: false,\n type: 'auto.db.supabase.postgres',\n });\n\n return e;\n });\n\n scope.setContext('supabase', supabaseContext);\n\n return scope;\n });\n }\n\n const breadcrumb: SupabaseBreadcrumb = {\n type: 'supabase',\n category: `db.${operation}`,\n message: description,\n };\n\n const data: Record<string, unknown> = {};\n\n if (queryItems.length) {\n data.query = queryItems;\n }\n\n if (Object.keys(body).length) {\n data.body = body;\n }\n\n if (Object.keys(data).length) {\n breadcrumb.data = data;\n }\n\n addBreadcrumb(breadcrumb);\n\n return res;\n },\n (err: Error) => {\n // TODO: shouldn't we capture this error?\n if (span) {\n setHttpStatus(span, 500);\n span.end();\n }\n throw err;\n },\n )\n .then(...argumentsList);\n },\n );\n },\n },\n );\n\n markAsInstrumented((PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then);\n}\n\nfunction instrumentPostgRESTQueryBuilder(PostgRESTQueryBuilder: new () => PostgRESTQueryBuilder): void {\n // We need to wrap _all_ operations despite them sharing the same `PostgRESTFilterBuilder`\n // constructor, as we don't know which method will be called first, and we don't want to miss any calls.\n for (const operation of DB_OPERATIONS_TO_INSTRUMENT) {\n if (isInstrumented((PostgRESTQueryBuilder.prototype as Record<string, any>)[operation])) {\n continue;\n }\n\n type PostgRESTOperation = keyof Pick<PostgRESTQueryBuilder, 'select' | 'insert' | 'upsert' | 'update' | 'delete'>;\n (PostgRESTQueryBuilder.prototype as Record<string, any>)[operation as PostgRESTOperation] = new Proxy(\n (PostgRESTQueryBuilder.prototype as Record<string, any>)[operation as PostgRESTOperation],\n {\n apply(target, thisArg, argumentsList) {\n const rv = Reflect.apply(target, thisArg, argumentsList);\n const PostgRESTFilterBuilder = (rv as PostgRESTFilterBuilder).constructor;\n\n DEBUG_BUILD && debug.log(`Instrumenting ${operation} operation's PostgRESTFilterBuilder`);\n\n instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder);\n\n return rv;\n },\n },\n );\n\n markAsInstrumented((PostgRESTQueryBuilder.prototype as Record<string, any>)[operation]);\n }\n}\n\nexport const instrumentSupabaseClient = (supabaseClient: unknown): void => {\n if (!supabaseClient) {\n DEBUG_BUILD && debug.warn('Supabase integration was not installed because no Supabase client was provided.');\n return;\n }\n const SupabaseClientConstructor =\n supabaseClient.constructor === Function ? supabaseClient : supabaseClient.constructor;\n\n instrumentSupabaseClientConstructor(SupabaseClientConstructor);\n instrumentSupabaseAuthClient(supabaseClient as SupabaseClientInstance);\n};\n\nconst INTEGRATION_NAME = 'Supabase';\n\nconst _supabaseIntegration = ((supabaseClient: unknown) => {\n return {\n setupOnce() {\n instrumentSupabaseClient(supabaseClient);\n },\n name: INTEGRATION_NAME,\n };\n}) satisfies IntegrationFn;\n\nexport const supabaseIntegration = defineIntegration((options: { supabaseClient: any }) => {\n return _supabaseIntegration(options.supabaseClient);\n}) satisfies IntegrationFn;\n"],"names":["startSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","SPAN_STATUS_ERROR","captureException","SPAN_STATUS_OK","isPlainObject","setHttpStatus","addExceptionMechanism","addBreadcrumb","DEBUG_BUILD","debug","defineIntegration"],"mappings":";;;;;;;;;;;;;AAAA;AACA;;;AAeA,MAAM,gCAAgC;AACtC,EAAE,gBAAgB;AAClB,EAAE,mBAAmB;AACrB,EAAE,iBAAiB;AACnB,EAAE,mBAAmB;AACrB,EAAE,eAAe;AACjB,EAAE,oBAAoB;AACtB,EAAE,eAAe;AACjB,EAAE,SAAS;AACX,EAAE,QAAQ;AACV,EAAE,WAAW;AACb,CAAC;;AAED,MAAM,sCAAsC;AAC5C,EAAE,YAAY;AACd,EAAE,YAAY;AACd,EAAE,WAAW;AACb,EAAE,aAAa;AACf,EAAE,gBAAgB;AAClB,EAAE,mBAAmB;AACrB,CAAC;;AAEM,MAAM,kBAAkB;AAC/B,EAAE,EAAE,EAAE,IAAI;AACV,EAAE,GAAG,EAAE,KAAK;AACZ,EAAE,EAAE,EAAE,IAAI;AACV,EAAE,GAAG,EAAE,KAAK;AACZ,EAAE,EAAE,EAAE,IAAI;AACV,EAAE,GAAG,EAAE,KAAK;AACZ,EAAE,IAAI,EAAE,MAAM;AACd,EAAE,WAAW,EAAE,WAAW;AAC1B,EAAE,WAAW,EAAE,WAAW;AAC1B,EAAE,KAAK,EAAE,OAAO;AAChB,EAAE,YAAY,EAAE,YAAY;AAC5B,EAAE,YAAY,EAAE,YAAY;AAC5B,EAAE,EAAE,EAAE,IAAI;AACV,EAAE,EAAE,EAAE,IAAI;AACV,EAAE,EAAE,EAAE,UAAU;AAChB,EAAE,EAAE,EAAE,aAAa;AACnB,EAAE,EAAE,EAAE,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AA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA,MAAA,mBAAA,GAAAC,6BAAA,CAAA,CAAA,OAAA,KAAA;AACA,EAAA,OAAA,oBAAA,CAAA,OAAA,CAAA,cAAA,CAAA;AACA,CAAA,CAAA;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"supabase.js","sources":["../../../src/integrations/supabase.ts"],"sourcesContent":["// Based on Kamil Ogórek's work on:\n// https://github.com/supabase-community/sentry-integration-js\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable max-lines */\nimport { addBreadcrumb } from '../breadcrumbs';\nimport { getClient } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { captureException } from '../exports';\nimport { defineIntegration } from '../integration';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';\nimport { setHttpStatus, SPAN_STATUS_ERROR, SPAN_STATUS_OK, startSpan } from '../tracing';\nimport type { IntegrationFn } from '../types-hoist/integration';\nimport { debug } from '../utils/debug-logger';\nimport { isPlainObject } from '../utils/is';\nimport { addExceptionMechanism } from '../utils/misc';\n\nconst AUTH_OPERATIONS_TO_INSTRUMENT = [\n 'reauthenticate',\n 'signInAnonymously',\n 'signInWithOAuth',\n 'signInWithIdToken',\n 'signInWithOtp',\n 'signInWithPassword',\n 'signInWithSSO',\n 'signOut',\n 'signUp',\n 'verifyOtp',\n];\n\nconst AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT = [\n 'createUser',\n 'deleteUser',\n 'listUsers',\n 'getUserById',\n 'updateUserById',\n 'inviteUserByEmail',\n];\n\nexport const FILTER_MAPPINGS = {\n eq: 'eq',\n neq: 'neq',\n gt: 'gt',\n gte: 'gte',\n lt: 'lt',\n lte: 'lte',\n like: 'like',\n 'like(all)': 'likeAllOf',\n 'like(any)': 'likeAnyOf',\n ilike: 'ilike',\n 'ilike(all)': 'ilikeAllOf',\n 'ilike(any)': 'ilikeAnyOf',\n is: 'is',\n in: 'in',\n cs: 'contains',\n cd: 'containedBy',\n sr: 'rangeGt',\n nxl: 'rangeGte',\n sl: 'rangeLt',\n nxr: 'rangeLte',\n adj: 'rangeAdjacent',\n ov: 'overlaps',\n fts: '',\n plfts: 'plain',\n phfts: 'phrase',\n wfts: 'websearch',\n not: 'not',\n};\n\nexport const DB_OPERATIONS_TO_INSTRUMENT = ['select', 'insert', 'upsert', 'update', 'delete'];\n\ntype AuthOperationFn = (...args: unknown[]) => Promise<unknown>;\ntype AuthOperationName = (typeof AUTH_OPERATIONS_TO_INSTRUMENT)[number];\ntype AuthAdminOperationName = (typeof AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT)[number];\ntype PostgRESTQueryOperationFn = (...args: unknown[]) => PostgRESTFilterBuilder;\n\nexport interface SupabaseClientInstance {\n auth: {\n admin: Record<AuthAdminOperationName, AuthOperationFn>;\n } & Record<AuthOperationName, AuthOperationFn>;\n}\n\nexport interface PostgRESTQueryBuilder {\n [key: string]: PostgRESTQueryOperationFn;\n}\n\nexport interface PostgRESTFilterBuilder {\n method: string;\n headers: Record<string, string>;\n url: URL;\n schema: string;\n body: any;\n}\n\nexport interface SupabaseResponse {\n status?: number;\n error?: {\n message: string;\n code?: string;\n details?: unknown;\n };\n}\n\nexport interface SupabaseError extends Error {\n code?: string;\n details?: unknown;\n}\n\nexport interface SupabaseBreadcrumb {\n type: string;\n category: string;\n message: string;\n data?: {\n query?: string[];\n body?: Record<string, unknown>;\n };\n}\n\nexport interface SupabaseClientConstructor {\n prototype: {\n from: (table: string) => PostgRESTQueryBuilder;\n };\n}\n\nexport interface PostgRESTProtoThenable {\n then: <T>(\n onfulfilled?: ((value: T) => T | PromiseLike<T>) | null,\n onrejected?: ((reason: any) => T | PromiseLike<T>) | null,\n ) => Promise<T>;\n}\n\ntype SentryInstrumented<T> = T & {\n __SENTRY_INSTRUMENTED__?: boolean;\n};\n\nfunction markAsInstrumented<T>(fn: T): void {\n try {\n (fn as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__ = true;\n } catch {\n // ignore errors here\n }\n}\n\nfunction isInstrumented<T>(fn: T): boolean | undefined {\n try {\n return (fn as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__;\n } catch {\n return false;\n }\n}\n\n/**\n * Plain-object bodies are copied into `plainBody`; array inserts (and other non-plain shapes) stay only on `rawBody`.\n * Returns a payload suitable for span attributes / breadcrumbs when the client has `sendDefaultPii` enabled.\n */\nfunction getMutationBodyPayloadForTelemetry(rawBody: unknown, plainBody: Record<string, unknown>): unknown | undefined {\n if (Object.keys(plainBody).length > 0) {\n return plainBody;\n }\n if (Array.isArray(rawBody) && rawBody.length > 0) {\n return rawBody;\n }\n return undefined;\n}\n\n/** True when the PostgREST builder carries a mutation body (for `insert(...)`, etc. in span descriptions). */\nfunction hasMutationBodyForDescription(rawBody: unknown, plainBody: Record<string, unknown>): boolean {\n return getMutationBodyPayloadForTelemetry(rawBody, plainBody) !== undefined;\n}\n\n/**\n * Extracts the database operation type from the HTTP method and headers\n * @param method - The HTTP method of the request\n * @param headers - The request headers\n * @returns The database operation type ('select', 'insert', 'upsert', 'update', or 'delete')\n */\nexport function extractOperation(method: string, headers: Record<string, string> = {}): string {\n switch (method) {\n case 'GET': {\n return 'select';\n }\n case 'POST': {\n if (headers['Prefer']?.includes('resolution=')) {\n return 'upsert';\n } else {\n return 'insert';\n }\n }\n case 'PATCH': {\n return 'update';\n }\n case 'DELETE': {\n return 'delete';\n }\n default: {\n return '<unknown-op>';\n }\n }\n}\n\n/**\n * Translates Supabase filter parameters into readable method names for tracing\n * @param key - The filter key from the URL search parameters\n * @param query - The filter value from the URL search parameters\n * @returns A string representation of the filter as a method call\n */\nexport function translateFiltersIntoMethods(key: string, query: string): string {\n if (query === '' || query === '*') {\n return 'select(*)';\n }\n\n if (key === 'select') {\n return `select(${query})`;\n }\n\n if (key === 'or' || key.endsWith('.or')) {\n return `${key}${query}`;\n }\n\n const [filter, ...value] = query.split('.');\n\n let method;\n // Handle optional `configPart` of the filter\n if (filter?.startsWith('fts')) {\n method = 'textSearch';\n } else if (filter?.startsWith('plfts')) {\n method = 'textSearch[plain]';\n } else if (filter?.startsWith('phfts')) {\n method = 'textSearch[phrase]';\n } else if (filter?.startsWith('wfts')) {\n method = 'textSearch[websearch]';\n } else {\n method = (filter && FILTER_MAPPINGS[filter as keyof typeof FILTER_MAPPINGS]) || 'filter';\n }\n\n return `${method}(${key}, ${value.join('.')})`;\n}\n\nfunction instrumentAuthOperation(operation: AuthOperationFn, isAdmin = false): AuthOperationFn {\n return new Proxy(operation, {\n apply(target, thisArg, argumentsList) {\n return startSpan(\n {\n name: `auth ${isAdmin ? '(admin) ' : ''}${operation.name}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n 'db.system': 'postgresql',\n 'db.operation': `auth.${isAdmin ? 'admin.' : ''}${operation.name}`,\n },\n },\n span => {\n return Reflect.apply(target, thisArg, argumentsList)\n .then((res: unknown) => {\n if (res && typeof res === 'object' && 'error' in res && res.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n\n captureException(res.error, {\n mechanism: {\n handled: false,\n type: 'auto.db.supabase.auth',\n },\n });\n } else {\n span.setStatus({ code: SPAN_STATUS_OK });\n }\n\n span.end();\n return res;\n })\n .catch((err: unknown) => {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n span.end();\n\n captureException(err, {\n mechanism: {\n handled: false,\n type: 'auto.db.supabase.auth',\n },\n });\n\n throw err;\n })\n .then(...argumentsList);\n },\n );\n },\n });\n}\n\nfunction instrumentSupabaseAuthClient(supabaseClientInstance: SupabaseClientInstance): void {\n const auth = supabaseClientInstance.auth;\n\n if (!auth || isInstrumented(supabaseClientInstance.auth)) {\n return;\n }\n\n for (const operation of AUTH_OPERATIONS_TO_INSTRUMENT) {\n const authOperation = auth[operation];\n\n if (!authOperation) {\n continue;\n }\n\n if (typeof supabaseClientInstance.auth[operation] === 'function') {\n supabaseClientInstance.auth[operation] = instrumentAuthOperation(authOperation);\n }\n }\n\n for (const operation of AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT) {\n const authOperation = auth.admin[operation];\n\n if (!authOperation) {\n continue;\n }\n\n if (typeof supabaseClientInstance.auth.admin[operation] === 'function') {\n supabaseClientInstance.auth.admin[operation] = instrumentAuthOperation(authOperation, true);\n }\n }\n\n markAsInstrumented(supabaseClientInstance.auth);\n}\n\nfunction instrumentSupabaseClientConstructor(SupabaseClient: unknown): void {\n if (isInstrumented((SupabaseClient as SupabaseClientConstructor).prototype.from)) {\n return;\n }\n\n (SupabaseClient as SupabaseClientConstructor).prototype.from = new Proxy(\n (SupabaseClient as SupabaseClientConstructor).prototype.from,\n {\n apply(target, thisArg, argumentsList) {\n const rv = Reflect.apply(target, thisArg, argumentsList);\n const PostgRESTQueryBuilder = (rv as PostgRESTQueryBuilder).constructor;\n\n instrumentPostgRESTQueryBuilder(PostgRESTQueryBuilder as unknown as new () => PostgRESTQueryBuilder);\n\n return rv;\n },\n },\n );\n\n markAsInstrumented((SupabaseClient as SupabaseClientConstructor).prototype.from);\n}\n\nfunction instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder: PostgRESTFilterBuilder['constructor']): void {\n if (isInstrumented((PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then)) {\n return;\n }\n\n (PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then = new Proxy(\n (PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then,\n {\n apply(target, thisArg, argumentsList) {\n const operations = DB_OPERATIONS_TO_INSTRUMENT;\n const typedThis = thisArg as PostgRESTFilterBuilder;\n const operation = extractOperation(typedThis.method, typedThis.headers);\n\n if (!operations.includes(operation)) {\n return Reflect.apply(target, thisArg, argumentsList);\n }\n\n if (!typedThis?.url?.pathname || typeof typedThis.url.pathname !== 'string') {\n return Reflect.apply(target, thisArg, argumentsList);\n }\n\n const pathParts = typedThis.url.pathname.split('/');\n const table = pathParts.length > 0 ? pathParts[pathParts.length - 1] : '';\n\n const queryItems: string[] = [];\n for (const [key, value] of typedThis.url.searchParams.entries()) {\n // It's possible to have multiple entries for the same key, eg. `id=eq.7&id=eq.3`,\n // so we need to use array instead of object to collect them.\n queryItems.push(translateFiltersIntoMethods(key, value));\n }\n const body: Record<string, unknown> = Object.create(null);\n if (isPlainObject(typedThis.body)) {\n for (const [key, value] of Object.entries(typedThis.body)) {\n body[key] = value;\n }\n }\n\n const sendDefaultPii = Boolean(getClient()?.getOptions().sendDefaultPii);\n const bodyPayload = getMutationBodyPayloadForTelemetry(typedThis.body, body);\n\n // Adding operation to the beginning of the description if it's not a `select` operation\n // For example, it can be an `insert` or `update` operation but the query can be `select(...)`\n // For `select` operations, we don't need repeat it in the description\n const mutationPart =\n operation === 'select'\n ? ''\n : `${operation}${hasMutationBodyForDescription(typedThis.body, body) ? '(...) ' : ''}`;\n const queryPart = sendDefaultPii ? queryItems.join(' ') : queryItems.length > 0 ? '[redacted]' : '';\n const descriptionMiddle = [mutationPart.trimEnd(), queryPart].filter(Boolean).join(' ');\n const description = descriptionMiddle ? `${descriptionMiddle} from(${table})` : `from(${table})`;\n\n const attributes: Record<string, any> = {\n 'db.table': table,\n 'db.schema': typedThis.schema,\n 'db.url': typedThis.url.origin,\n 'db.sdk': typedThis.headers['X-Client-Info'],\n 'db.system': 'postgresql',\n 'db.operation': operation,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n };\n\n if (queryItems.length && sendDefaultPii) {\n attributes['db.query'] = queryItems;\n }\n\n if (bodyPayload !== undefined && sendDefaultPii) {\n attributes['db.body'] = bodyPayload;\n }\n\n return startSpan(\n {\n name: description,\n attributes,\n },\n span => {\n return (Reflect.apply(target, thisArg, []) as Promise<SupabaseResponse>)\n .then(\n (res: SupabaseResponse) => {\n if (span) {\n if (res && typeof res === 'object' && 'status' in res) {\n setHttpStatus(span, res.status || 500);\n }\n span.end();\n }\n\n if (res?.error) {\n const err = new Error(res.error.message) as SupabaseError;\n if (res.error.code) {\n err.code = res.error.code;\n }\n if (res.error.details) {\n err.details = res.error.details;\n }\n\n const supabaseContext: Record<string, any> = {};\n if (queryItems.length && sendDefaultPii) {\n supabaseContext.query = queryItems;\n }\n if (bodyPayload !== undefined && sendDefaultPii) {\n supabaseContext.body = bodyPayload;\n }\n\n captureException(err, scope => {\n scope.addEventProcessor(e => {\n addExceptionMechanism(e, {\n handled: false,\n type: 'auto.db.supabase.postgres',\n });\n\n return e;\n });\n\n scope.setContext('supabase', supabaseContext);\n\n return scope;\n });\n }\n\n const breadcrumb: SupabaseBreadcrumb = {\n type: 'supabase',\n category: `db.${operation}`,\n message: description,\n };\n\n const data: Record<string, unknown> = {};\n\n if (queryItems.length && sendDefaultPii) {\n data.query = queryItems;\n }\n\n if (bodyPayload !== undefined && sendDefaultPii) {\n data.body = bodyPayload;\n }\n\n if (Object.keys(data).length) {\n breadcrumb.data = data;\n }\n\n addBreadcrumb(breadcrumb);\n\n return res;\n },\n (err: Error) => {\n // TODO: shouldn't we capture this error?\n if (span) {\n setHttpStatus(span, 500);\n span.end();\n }\n throw err;\n },\n )\n .then(...argumentsList);\n },\n );\n },\n },\n );\n\n markAsInstrumented((PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then);\n}\n\nfunction instrumentPostgRESTQueryBuilder(PostgRESTQueryBuilder: new () => PostgRESTQueryBuilder): void {\n // We need to wrap _all_ operations despite them sharing the same `PostgRESTFilterBuilder`\n // constructor, as we don't know which method will be called first, and we don't want to miss any calls.\n for (const operation of DB_OPERATIONS_TO_INSTRUMENT) {\n if (isInstrumented((PostgRESTQueryBuilder.prototype as Record<string, any>)[operation])) {\n continue;\n }\n\n type PostgRESTOperation = keyof Pick<PostgRESTQueryBuilder, 'select' | 'insert' | 'upsert' | 'update' | 'delete'>;\n (PostgRESTQueryBuilder.prototype as Record<string, any>)[operation as PostgRESTOperation] = new Proxy(\n (PostgRESTQueryBuilder.prototype as Record<string, any>)[operation as PostgRESTOperation],\n {\n apply(target, thisArg, argumentsList) {\n const rv = Reflect.apply(target, thisArg, argumentsList);\n const PostgRESTFilterBuilder = (rv as PostgRESTFilterBuilder).constructor;\n\n DEBUG_BUILD && debug.log(`Instrumenting ${operation} operation's PostgRESTFilterBuilder`);\n\n instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder);\n\n return rv;\n },\n },\n );\n\n markAsInstrumented((PostgRESTQueryBuilder.prototype as Record<string, any>)[operation]);\n }\n}\n\nexport const instrumentSupabaseClient = (supabaseClient: unknown): void => {\n if (!supabaseClient) {\n DEBUG_BUILD && debug.warn('Supabase integration was not installed because no Supabase client was provided.');\n return;\n }\n const SupabaseClientConstructor =\n supabaseClient.constructor === Function ? supabaseClient : supabaseClient.constructor;\n\n instrumentSupabaseClientConstructor(SupabaseClientConstructor);\n instrumentSupabaseAuthClient(supabaseClient as SupabaseClientInstance);\n};\n\nconst INTEGRATION_NAME = 'Supabase';\n\nconst _supabaseIntegration = ((supabaseClient: unknown) => {\n return {\n setupOnce() {\n instrumentSupabaseClient(supabaseClient);\n },\n name: INTEGRATION_NAME,\n };\n}) satisfies IntegrationFn;\n\nexport const supabaseIntegration = defineIntegration((options: { supabaseClient: any }) => {\n return _supabaseIntegration(options.supabaseClient);\n}) satisfies IntegrationFn;\n"],"names":["startSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","SPAN_STATUS_ERROR","captureException","SPAN_STATUS_OK","isPlainObject","getClient","setHttpStatus","addExceptionMechanism","addBreadcrumb","DEBUG_BUILD","debug","defineIntegration"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;;;AAgBA,MAAM,gCAAgC;AACtC,EAAE,gBAAgB;AAClB,EAAE,mBAAmB;AACrB,EAAE,iBA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,GAAA,SAAA,CAAA,CAAA;AACA,EAAA;AACA;;AAEA,MAAA,wBAAA,GAAA,CAAA,cAAA,KAAA;AACA,EAAA,IAAA,CAAA,cAAA,EAAA;AACA,IAAAD,sBAAA,IAAAC,iBAAA,CAAA,IAAA,CAAA,iFAAA,CAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA,MAAA,yBAAA;AACA,IAAA,cAAA,CAAA,WAAA,KAAA,QAAA,GAAA,cAAA,GAAA,cAAA,CAAA,WAAA;;AAEA,EAAA,mCAAA,CAAA,yBAAA,CAAA;AACA,EAAA,4BAAA,CAAA,cAAA,EAAA;AACA;;AAEA,MAAA,gBAAA,GAAA,UAAA;;AAEA,MAAA,oBAAA,IAAA,CAAA,cAAA,KAAA;AACA,EAAA,OAAA;AACA,IAAA,SAAA,GAAA;AACA,MAAA,wBAAA,CAAA,cAAA,CAAA;AACA,IAAA,CAAA;AACA,IAAA,IAAA,EAAA,gBAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA,MAAA,mBAAA,GAAAC,6BAAA,CAAA,CAAA,OAAA,KAAA;AACA,EAAA,OAAA,oBAAA,CAAA,OAAA,CAAA,cAAA,CAAA;AACA,CAAA,CAAA;;;;;;;;;"}
|
|
@@ -27,7 +27,7 @@ const _consoleLoggingIntegration = ((options = {}) => {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
console.addConsoleInstrumentationHandler(({ args, level }) => {
|
|
30
|
+
const unsubscribe = console.addConsoleInstrumentationHandler(({ args, level }) => {
|
|
31
31
|
if (currentScopes.getClient() !== client || !levels.includes(level)) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
@@ -62,6 +62,8 @@ const _consoleLoggingIntegration = ((options = {}) => {
|
|
|
62
62
|
attributes,
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
|
+
|
|
66
|
+
client.registerCleanup(unsubscribe);
|
|
65
67
|
},
|
|
66
68
|
};
|
|
67
69
|
}) ;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console-integration.js","sources":["../../../src/logs/console-integration.ts"],"sourcesContent":["import { getClient } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { addConsoleInstrumentationHandler } from '../instrument/console';\nimport { defineIntegration } from '../integration';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';\nimport type { ConsoleLevel } from '../types-hoist/instrument';\nimport type { IntegrationFn } from '../types-hoist/integration';\nimport { CONSOLE_LEVELS, debug } from '../utils/debug-logger';\nimport { _INTERNAL_captureLog } from './internal';\nimport { createConsoleTemplateAttributes, formatConsoleArgs, hasConsoleSubstitutions } from './utils';\n\ninterface CaptureConsoleOptions {\n levels: ConsoleLevel[];\n}\n\nconst INTEGRATION_NAME = 'ConsoleLogs';\n\nconst DEFAULT_ATTRIBUTES = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.log.console',\n};\n\nconst _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {}) => {\n const levels = options.levels || CONSOLE_LEVELS;\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const { enableLogs, normalizeDepth = 3, normalizeMaxBreadth = 1_000 } = client.getOptions();\n if (!enableLogs) {\n DEBUG_BUILD && debug.warn('`enableLogs` is not enabled, ConsoleLogs integration disabled');\n return;\n }\n\n addConsoleInstrumentationHandler(({ args, level }) => {\n if (getClient() !== client || !levels.includes(level)) {\n return;\n }\n\n const firstArg = args[0];\n const followingArgs = args.slice(1);\n\n if (level === 'assert') {\n if (!firstArg) {\n const assertionMessage =\n followingArgs.length > 0\n ? `Assertion failed: ${formatConsoleArgs(followingArgs, normalizeDepth, normalizeMaxBreadth)}`\n : 'Assertion failed';\n _INTERNAL_captureLog({ level: 'error', message: assertionMessage, attributes: DEFAULT_ATTRIBUTES });\n }\n return;\n }\n\n const isLevelLog = level === 'log';\n\n const shouldGenerateTemplate =\n args.length > 1 && typeof args[0] === 'string' && !hasConsoleSubstitutions(args[0]);\n const attributes = {\n ...DEFAULT_ATTRIBUTES,\n ...(shouldGenerateTemplate ? createConsoleTemplateAttributes(firstArg, followingArgs) : {}),\n };\n\n _INTERNAL_captureLog({\n level: isLevelLog ? 'info' : level,\n message: formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth),\n severityNumber: isLevelLog ? 10 : undefined,\n attributes,\n });\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Captures calls to the `console` API as logs in Sentry. Requires the `enableLogs` option to be enabled.\n *\n * @experimental This feature is experimental and may be changed or removed in future versions.\n *\n * By default the integration instruments `console.debug`, `console.info`, `console.warn`, `console.error`,\n * `console.log`, `console.trace`, and `console.assert`. You can use the `levels` option to customize which\n * levels are captured.\n *\n * @example\n *\n * ```ts\n * import * as Sentry from '@sentry/browser';\n *\n * Sentry.init({\n * enableLogs: true,\n * integrations: [Sentry.consoleLoggingIntegration({ levels: ['error', 'warn'] })],\n * });\n * ```\n */\nexport const consoleLoggingIntegration = defineIntegration(_consoleLoggingIntegration);\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","CONSOLE_LEVELS","DEBUG_BUILD","debug","addConsoleInstrumentationHandler","getClient","formatConsoleArgs","_INTERNAL_captureLog","hasConsoleSubstitutions","createConsoleTemplateAttributes","defineIntegration"],"mappings":";;;;;;;;;;;AAeA,MAAM,gBAAA,GAAmB,aAAa;;AAEtC,MAAM,qBAAqB;AAC3B,EAAE,CAACA,mDAAgC,GAAG,kBAAkB;AACxD,CAAC;;AAED,MAAM,0BAAA,IAA8B,CAAC,OAAO,GAAmC,EAAE,KAAK;AACtF,EAAE,MAAM,MAAA,GAAS,OAAO,CAAC,MAAA,IAAUC,0BAAc;;AAEjD,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,EAAE,UAAU,EAAE,cAAA,GAAiB,CAAC,EAAE,mBAAA,GAAsB,MAAM,GAAI,MAAM,CAAC,UAAU,EAAE;AACjG,MAAM,IAAI,CAAC,UAAU,EAAE;AACvB,QAAQC,0BAAeC,iBAAK,CAAC,IAAI,CAAC,+DAA+D,CAAC;AAClG,QAAQ;AACR,MAAM;;AAEN,
|
|
1
|
+
{"version":3,"file":"console-integration.js","sources":["../../../src/logs/console-integration.ts"],"sourcesContent":["import { getClient } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { addConsoleInstrumentationHandler } from '../instrument/console';\nimport { defineIntegration } from '../integration';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';\nimport type { ConsoleLevel } from '../types-hoist/instrument';\nimport type { IntegrationFn } from '../types-hoist/integration';\nimport { CONSOLE_LEVELS, debug } from '../utils/debug-logger';\nimport { _INTERNAL_captureLog } from './internal';\nimport { createConsoleTemplateAttributes, formatConsoleArgs, hasConsoleSubstitutions } from './utils';\n\ninterface CaptureConsoleOptions {\n levels: ConsoleLevel[];\n}\n\nconst INTEGRATION_NAME = 'ConsoleLogs';\n\nconst DEFAULT_ATTRIBUTES = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.log.console',\n};\n\nconst _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {}) => {\n const levels = options.levels || CONSOLE_LEVELS;\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const { enableLogs, normalizeDepth = 3, normalizeMaxBreadth = 1_000 } = client.getOptions();\n if (!enableLogs) {\n DEBUG_BUILD && debug.warn('`enableLogs` is not enabled, ConsoleLogs integration disabled');\n return;\n }\n\n const unsubscribe = addConsoleInstrumentationHandler(({ args, level }) => {\n if (getClient() !== client || !levels.includes(level)) {\n return;\n }\n\n const firstArg = args[0];\n const followingArgs = args.slice(1);\n\n if (level === 'assert') {\n if (!firstArg) {\n const assertionMessage =\n followingArgs.length > 0\n ? `Assertion failed: ${formatConsoleArgs(followingArgs, normalizeDepth, normalizeMaxBreadth)}`\n : 'Assertion failed';\n _INTERNAL_captureLog({ level: 'error', message: assertionMessage, attributes: DEFAULT_ATTRIBUTES });\n }\n return;\n }\n\n const isLevelLog = level === 'log';\n\n const shouldGenerateTemplate =\n args.length > 1 && typeof args[0] === 'string' && !hasConsoleSubstitutions(args[0]);\n const attributes = {\n ...DEFAULT_ATTRIBUTES,\n ...(shouldGenerateTemplate ? createConsoleTemplateAttributes(firstArg, followingArgs) : {}),\n };\n\n _INTERNAL_captureLog({\n level: isLevelLog ? 'info' : level,\n message: formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth),\n severityNumber: isLevelLog ? 10 : undefined,\n attributes,\n });\n });\n\n client.registerCleanup(unsubscribe);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Captures calls to the `console` API as logs in Sentry. Requires the `enableLogs` option to be enabled.\n *\n * @experimental This feature is experimental and may be changed or removed in future versions.\n *\n * By default the integration instruments `console.debug`, `console.info`, `console.warn`, `console.error`,\n * `console.log`, `console.trace`, and `console.assert`. You can use the `levels` option to customize which\n * levels are captured.\n *\n * @example\n *\n * ```ts\n * import * as Sentry from '@sentry/browser';\n *\n * Sentry.init({\n * enableLogs: true,\n * integrations: [Sentry.consoleLoggingIntegration({ levels: ['error', 'warn'] })],\n * });\n * ```\n */\nexport const consoleLoggingIntegration = defineIntegration(_consoleLoggingIntegration);\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","CONSOLE_LEVELS","DEBUG_BUILD","debug","addConsoleInstrumentationHandler","getClient","formatConsoleArgs","_INTERNAL_captureLog","hasConsoleSubstitutions","createConsoleTemplateAttributes","defineIntegration"],"mappings":";;;;;;;;;;;AAeA,MAAM,gBAAA,GAAmB,aAAa;;AAEtC,MAAM,qBAAqB;AAC3B,EAAE,CAACA,mDAAgC,GAAG,kBAAkB;AACxD,CAAC;;AAED,MAAM,0BAAA,IAA8B,CAAC,OAAO,GAAmC,EAAE,KAAK;AACtF,EAAE,MAAM,MAAA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CAAA,CAAA,CAAA,KAAA,QAAA,IAAA,CAAAC,6BAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA;AACA,QAAA,MAAA,UAAA,GAAA;AACA,UAAA,GAAA,kBAAA;AACA,UAAA,IAAA,sBAAA,GAAAC,qCAAA,CAAA,QAAA,EAAA,aAAA,CAAA,GAAA,EAAA,CAAA;AACA,SAAA;;AAEA,QAAAF,6BAAA,CAAA;AACA,UAAA,KAAA,EAAA,UAAA,GAAA,MAAA,GAAA,KAAA;AACA,UAAA,OAAA,EAAAD,uBAAA,CAAA,IAAA,EAAA,cAAA,EAAA,mBAAA,CAAA;AACA,UAAA,cAAA,EAAA,UAAA,GAAA,EAAA,GAAA,SAAA;AACA,UAAA,UAAA;AACA,SAAA,CAAA;AACA,MAAA,CAAA,CAAA;;AAEA,MAAA,MAAA,CAAA,eAAA,CAAA,WAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAA,yBAAA,GAAAI,6BAAA,CAAA,0BAAA;;;;"}
|
|
@@ -2,14 +2,18 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const dsn = require('../utils/dsn.js');
|
|
4
4
|
const envelope = require('../utils/envelope.js');
|
|
5
|
+
const isBrowser = require('../utils/isBrowser.js');
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Creates a log container envelope item for a list of logs.
|
|
8
9
|
*
|
|
9
10
|
* @param items - The logs to include in the envelope.
|
|
11
|
+
* @param inferUserData - If true, tells Relay to infer the end-user IP and User-Agent from the incoming request.
|
|
12
|
+
* Only emitted as `ingest_settings` in browser environments.
|
|
10
13
|
* @returns The created log container envelope item.
|
|
11
14
|
*/
|
|
12
|
-
function createLogContainerEnvelopeItem(items) {
|
|
15
|
+
function createLogContainerEnvelopeItem(items, inferUserData) {
|
|
16
|
+
const inferSetting = inferUserData ? 'auto' : 'never';
|
|
13
17
|
return [
|
|
14
18
|
{
|
|
15
19
|
type: 'log',
|
|
@@ -17,6 +21,10 @@ function createLogContainerEnvelopeItem(items) {
|
|
|
17
21
|
content_type: 'application/vnd.sentry.items.log+json',
|
|
18
22
|
},
|
|
19
23
|
{
|
|
24
|
+
version: 2,
|
|
25
|
+
...(isBrowser.isBrowser() && {
|
|
26
|
+
ingest_settings: { infer_ip: inferSetting, infer_user_agent: inferSetting },
|
|
27
|
+
}),
|
|
20
28
|
items,
|
|
21
29
|
},
|
|
22
30
|
];
|
|
@@ -31,6 +39,7 @@ function createLogContainerEnvelopeItem(items) {
|
|
|
31
39
|
* @param metadata - The metadata to include in the envelope.
|
|
32
40
|
* @param tunnel - The tunnel to include in the envelope.
|
|
33
41
|
* @param dsn - The DSN to include in the envelope.
|
|
42
|
+
* @param inferUserData - If true, tells Relay to infer the end-user IP and User-Agent from the incoming request.
|
|
34
43
|
* @returns The created envelope.
|
|
35
44
|
*/
|
|
36
45
|
function createLogEnvelope(
|
|
@@ -38,6 +47,7 @@ function createLogEnvelope(
|
|
|
38
47
|
metadata,
|
|
39
48
|
tunnel,
|
|
40
49
|
dsn$1,
|
|
50
|
+
inferUserData,
|
|
41
51
|
) {
|
|
42
52
|
const headers = {};
|
|
43
53
|
|
|
@@ -52,7 +62,7 @@ function createLogEnvelope(
|
|
|
52
62
|
headers.dsn = dsn.dsnToString(dsn$1);
|
|
53
63
|
}
|
|
54
64
|
|
|
55
|
-
return envelope.createEnvelope(headers, [createLogContainerEnvelopeItem(logs)]);
|
|
65
|
+
return envelope.createEnvelope(headers, [createLogContainerEnvelopeItem(logs, inferUserData)]);
|
|
56
66
|
}
|
|
57
67
|
|
|
58
68
|
exports.createLogContainerEnvelopeItem = createLogContainerEnvelopeItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.js","sources":["../../../src/logs/envelope.ts"],"sourcesContent":["import type { DsnComponents } from '../types-hoist/dsn';\nimport type { LogContainerItem, LogEnvelope } from '../types-hoist/envelope';\nimport type { SerializedLog } from '../types-hoist/log';\nimport type { SdkMetadata } from '../types-hoist/sdkmetadata';\nimport { dsnToString } from '../utils/dsn';\nimport { createEnvelope } from '../utils/envelope';\n\n/**\n * Creates a log container envelope item for a list of logs.\n *\n * @param items - The logs to include in the envelope.\n * @returns The created log container envelope item.\n */\nexport function createLogContainerEnvelopeItem(items: Array<SerializedLog
|
|
1
|
+
{"version":3,"file":"envelope.js","sources":["../../../src/logs/envelope.ts"],"sourcesContent":["import type { DsnComponents } from '../types-hoist/dsn';\nimport type { LogContainerItem, LogEnvelope } from '../types-hoist/envelope';\nimport type { SerializedLog } from '../types-hoist/log';\nimport type { SdkMetadata } from '../types-hoist/sdkmetadata';\nimport { dsnToString } from '../utils/dsn';\nimport { createEnvelope } from '../utils/envelope';\nimport { isBrowser } from '../utils/isBrowser';\n\n/**\n * Creates a log container envelope item for a list of logs.\n *\n * @param items - The logs to include in the envelope.\n * @param inferUserData - If true, tells Relay to infer the end-user IP and User-Agent from the incoming request.\n * Only emitted as `ingest_settings` in browser environments.\n * @returns The created log container envelope item.\n */\nexport function createLogContainerEnvelopeItem(items: Array<SerializedLog>, inferUserData?: boolean): LogContainerItem {\n const inferSetting = inferUserData ? 'auto' : 'never';\n return [\n {\n type: 'log',\n item_count: items.length,\n content_type: 'application/vnd.sentry.items.log+json',\n },\n {\n version: 2,\n ...(isBrowser() && {\n ingest_settings: { infer_ip: inferSetting, infer_user_agent: inferSetting },\n }),\n items,\n },\n ];\n}\n\n/**\n * Creates an envelope for a list of logs.\n *\n * Logs from multiple traces can be included in the same envelope.\n *\n * @param logs - The logs to include in the envelope.\n * @param metadata - The metadata to include in the envelope.\n * @param tunnel - The tunnel to include in the envelope.\n * @param dsn - The DSN to include in the envelope.\n * @param inferUserData - If true, tells Relay to infer the end-user IP and User-Agent from the incoming request.\n * @returns The created envelope.\n */\nexport function createLogEnvelope(\n logs: Array<SerializedLog>,\n metadata?: SdkMetadata,\n tunnel?: string,\n dsn?: DsnComponents,\n inferUserData?: boolean,\n): LogEnvelope {\n const headers: LogEnvelope[0] = {};\n\n if (metadata?.sdk) {\n headers.sdk = {\n name: metadata.sdk.name,\n version: metadata.sdk.version,\n };\n }\n\n if (!!tunnel && !!dsn) {\n headers.dsn = dsnToString(dsn);\n }\n\n return createEnvelope<LogEnvelope>(headers, [createLogContainerEnvelopeItem(logs, inferUserData)]);\n}\n"],"names":["isBrowser","dsn","dsnToString","createEnvelope"],"mappings":";;;;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,8BAA8B,CAAC,KAAK,EAAwB,aAAa,EAA8B;AACvH,EAAE,MAAM,YAAA,GAAe,gBAAgB,MAAA,GAAS,OAAO;AACvD,EAAE,OAAO;AACT,IAAI;AACJ,MAAM,IAAI,EAAE,KAAK;AACjB,MAAM,UAAU,EAAE,KAAK,CAAC,MAAM;AAC9B,MAAM,YAAY,EAAE,uCAAuC;AAC3D,KAAK;AACL,IAAI;AACJ,MAAM,OAAO,EAAE,CAAC;AAChB,MAAM,IAAIA,mBAAS,MAAM;AACzB,QAAQ,eAAe,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAA,EAAc;AACnF,OAAO,CAAC;AACR,MAAM,KAAK;AACX,KAAK;AACL,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB;AACjC,EAAE,IAAI;AACN,EAAE,QAAQ;AACV,EAAE,MAAM;AACR,EAAEC,KAAG;AACL,EAAE,aAAa;AACf,EAAe;AACf,EAAE,MAAM,OAAO,GAAmB,EAAE;;AAEpC,EAAE,IAAI,QAAQ,EAAE,GAAG,EAAE;AACrB,IAAI,OAAO,CAAC,GAAA,GAAM;AAClB,MAAM,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI;AAC7B,MAAM,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO;AACnC,KAAK;AACL,EAAE;;AAEF,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC,CAACA,KAAG,EAAE;AACzB,IAAI,OAAO,CAAC,GAAA,GAAMC,eAAW,CAACD,KAAG,CAAC;AAClC,EAAE;;AAEF,EAAE,OAAOE,uBAAc,CAAc,OAAO,EAAE,CAAC,8BAA8B,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC;AACpG;;;;;"}
|
|
@@ -188,7 +188,13 @@ function _INTERNAL_flushLogsBuffer(client, maybeLogBuffer) {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
const clientOptions = client.getOptions();
|
|
191
|
-
const envelope$1 = envelope.createLogEnvelope(
|
|
191
|
+
const envelope$1 = envelope.createLogEnvelope(
|
|
192
|
+
logBuffer,
|
|
193
|
+
clientOptions._metadata,
|
|
194
|
+
clientOptions.tunnel,
|
|
195
|
+
client.getDsn(),
|
|
196
|
+
clientOptions.sendDefaultPii,
|
|
197
|
+
);
|
|
192
198
|
|
|
193
199
|
// Clear the log buffer after envelopes have been constructed.
|
|
194
200
|
_getBufferMap().set(client, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sources":["../../../src/logs/internal.ts"],"sourcesContent":["import { serializeAttributes } from '../attributes';\nimport { getGlobalSingleton } from '../carrier';\nimport type { Client } from '../client';\nimport { getClient, getCurrentScope, getIsolationScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Integration } from '../types-hoist/integration';\nimport type { Log, SerializedLog } from '../types-hoist/log';\nimport { consoleSandbox, debug } from '../utils/debug-logger';\nimport { isParameterizedString } from '../utils/is';\nimport { getCombinedScopeData } from '../utils/scopeData';\nimport { _getSpanForScope } from '../utils/spanOnScope';\nimport { timestampInSeconds } from '../utils/time';\nimport { getSequenceAttribute } from '../utils/timestampSequence';\nimport { _getTraceInfoFromScope } from '../utils/trace-info';\nimport { SEVERITY_TEXT_TO_SEVERITY_NUMBER } from './constants';\nimport { createLogEnvelope } from './envelope';\n\nconst MAX_LOG_BUFFER_SIZE = 100;\n\n/**\n * Sets a log attribute if the value exists and the attribute key is not already present.\n *\n * @param logAttributes - The log attributes object to modify.\n * @param key - The attribute key to set.\n * @param value - The value to set (only sets if truthy and key not present).\n * @param setEvenIfPresent - Whether to set the attribute if it is present. Defaults to true.\n */\nfunction setLogAttribute(\n logAttributes: Record<string, unknown>,\n key: string,\n value: unknown,\n setEvenIfPresent = true,\n): void {\n if (value && (!logAttributes[key] || setEvenIfPresent)) {\n logAttributes[key] = value;\n }\n}\n\n/**\n * Captures a serialized log event and adds it to the log buffer for the given client.\n *\n * @param client - A client. Uses the current client if not provided.\n * @param serializedLog - The serialized log event to capture.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_captureSerializedLog(client: Client, serializedLog: SerializedLog): void {\n const bufferMap = _getBufferMap();\n const logBuffer = _INTERNAL_getLogBuffer(client);\n\n if (logBuffer === undefined) {\n bufferMap.set(client, [serializedLog]);\n } else {\n if (logBuffer.length >= MAX_LOG_BUFFER_SIZE) {\n _INTERNAL_flushLogsBuffer(client, logBuffer);\n bufferMap.set(client, [serializedLog]);\n } else {\n bufferMap.set(client, [...logBuffer, serializedLog]);\n }\n }\n}\n\n/**\n * Captures a log event and sends it to Sentry.\n *\n * @param log - The log event to capture.\n * @param scope - A scope. Uses the current scope if not provided.\n * @param client - A client. Uses the current client if not provided.\n * @param captureSerializedLog - A function to capture the serialized log.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_captureLog(\n beforeLog: Log,\n currentScope = getCurrentScope(),\n captureSerializedLog: (client: Client, log: SerializedLog) => void = _INTERNAL_captureSerializedLog,\n): void {\n const client = currentScope?.getClient() ?? getClient();\n if (!client) {\n DEBUG_BUILD && debug.warn('No client available to capture log.');\n return;\n }\n\n const { release, environment, enableLogs = false, beforeSendLog } = client.getOptions();\n if (!enableLogs) {\n DEBUG_BUILD && debug.warn('logging option not enabled, log will not be captured.');\n return;\n }\n\n const [, traceContext] = _getTraceInfoFromScope(client, currentScope);\n\n const processedLogAttributes = {\n ...beforeLog.attributes,\n };\n\n const {\n user: { id, email, username },\n attributes: scopeAttributes = {},\n } = getCombinedScopeData(getIsolationScope(), currentScope);\n\n setLogAttribute(processedLogAttributes, 'user.id', id, false);\n setLogAttribute(processedLogAttributes, 'user.email', email, false);\n setLogAttribute(processedLogAttributes, 'user.name', username, false);\n\n setLogAttribute(processedLogAttributes, 'sentry.release', release);\n setLogAttribute(processedLogAttributes, 'sentry.environment', environment);\n\n const { name, version } = client.getSdkMetadata()?.sdk ?? {};\n setLogAttribute(processedLogAttributes, 'sentry.sdk.name', name);\n setLogAttribute(processedLogAttributes, 'sentry.sdk.version', version);\n\n const replay = client.getIntegrationByName<\n Integration & {\n getReplayId: (onlyIfSampled?: boolean) => string;\n getRecordingMode: () => 'session' | 'buffer' | undefined;\n }\n >('Replay');\n\n const replayId = replay?.getReplayId(true);\n setLogAttribute(processedLogAttributes, 'sentry.replay_id', replayId);\n\n if (replayId && replay?.getRecordingMode() === 'buffer') {\n // We send this so we can identify cases where the replayId is attached but the replay itself might not have been sent to Sentry\n setLogAttribute(processedLogAttributes, 'sentry._internal.replay_is_buffering', true);\n }\n\n const beforeLogMessage = beforeLog.message;\n if (isParameterizedString(beforeLogMessage)) {\n const { __sentry_template_string__, __sentry_template_values__ = [] } = beforeLogMessage;\n if (__sentry_template_values__?.length) {\n processedLogAttributes['sentry.message.template'] = __sentry_template_string__;\n }\n __sentry_template_values__.forEach((param, index) => {\n processedLogAttributes[`sentry.message.parameter.${index}`] = param;\n });\n }\n\n const span = _getSpanForScope(currentScope);\n // Add the parent span ID to the log attributes for trace context\n setLogAttribute(processedLogAttributes, 'sentry.trace.parent_span_id', span?.spanContext().spanId);\n\n const processedLog = { ...beforeLog, attributes: processedLogAttributes };\n\n client.emit('beforeCaptureLog', processedLog);\n\n // We need to wrap this in `consoleSandbox` to avoid recursive calls to `beforeSendLog`\n const log = beforeSendLog ? consoleSandbox(() => beforeSendLog(processedLog)) : processedLog;\n if (!log) {\n client.recordDroppedEvent('before_send', 'log_item', 1);\n DEBUG_BUILD && debug.warn('beforeSendLog returned null, log will not be captured.');\n return;\n }\n\n const { level, message, attributes: logAttributes = {}, severityNumber } = log;\n\n const timestamp = timestampInSeconds();\n const sequenceAttr = getSequenceAttribute(timestamp);\n\n const serializedLog: SerializedLog = {\n timestamp,\n level,\n body: message,\n trace_id: traceContext?.trace_id,\n severity_number: severityNumber ?? SEVERITY_TEXT_TO_SEVERITY_NUMBER[level],\n attributes: {\n ...serializeAttributes(scopeAttributes),\n ...serializeAttributes(logAttributes, true),\n [sequenceAttr.key]: sequenceAttr.value,\n },\n };\n\n captureSerializedLog(client, serializedLog);\n\n client.emit('afterCaptureLog', log);\n}\n\n/**\n * Flushes the logs buffer to Sentry.\n *\n * @param client - A client.\n * @param maybeLogBuffer - A log buffer. Uses the log buffer for the given client if not provided.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_flushLogsBuffer(client: Client, maybeLogBuffer?: Array<SerializedLog>): void {\n const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];\n if (logBuffer.length === 0) {\n return;\n }\n\n const clientOptions = client.getOptions();\n const envelope = createLogEnvelope(logBuffer, clientOptions._metadata, clientOptions.tunnel, client.getDsn());\n\n // Clear the log buffer after envelopes have been constructed.\n _getBufferMap().set(client, []);\n\n client.emit('flushLogs');\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n\n/**\n * Returns the log buffer for a given client.\n *\n * Exported for testing purposes.\n *\n * @param client - The client to get the log buffer for.\n * @returns The log buffer for the given client.\n */\nexport function _INTERNAL_getLogBuffer(client: Client): Array<SerializedLog> | undefined {\n return _getBufferMap().get(client);\n}\n\nfunction _getBufferMap(): WeakMap<Client, Array<SerializedLog>> {\n // The reference to the Client <> LogBuffer map is stored on the carrier to ensure it's always the same\n return getGlobalSingleton('clientToLogBufferMap', () => new WeakMap<Client, Array<SerializedLog>>());\n}\n"],"names":["getCurrentScope","getClient","DEBUG_BUILD","debug","_getTraceInfoFromScope","getCombinedScopeData","getIsolationScope","isParameterizedString","_getSpanForScope","consoleSandbox","timestampInSeconds","getSequenceAttribute","SEVERITY_TEXT_TO_SEVERITY_NUMBER","serializeAttributes","envelope","createLogEnvelope","getGlobalSingleton"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,mBAAA,GAAsB,GAAG;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe;AACxB,EAAE,aAAa;AACf,EAAE,GAAG;AACL,EAAE,KAAK;AACP,EAAE,gBAAA,GAAmB,IAAI;AACzB,EAAQ;AACR,EAAE,IAAI,KAAA,KAAU,CAAC,aAAa,CAAC,GAAG,CAAA,IAAK,gBAAgB,CAAC,EAAE;AAC1D,IAAI,aAAa,CAAC,GAAG,CAAA,GAAI,KAAK;AAC9B,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,8BAA8B,CAAC,MAAM,EAAU,aAAa,EAAuB;AACnG,EAAE,MAAM,SAAA,GAAY,aAAa,EAAE;AACnC,EAAE,MAAM,SAAA,GAAY,sBAAsB,CAAC,MAAM,CAAC;;AAElD,EAAE,IAAI,SAAA,KAAc,SAAS,EAAE;AAC/B,IAAI,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,aAAa,CAAC,CAAC;AAC1C,EAAE,OAAO;AACT,IAAI,IAAI,SAAS,CAAC,MAAA,IAAU,mBAAmB,EAAE;AACjD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8BAAA,CAAA,eAAA,CAAA;AACA,MAAA,GAAAA,8BAAA,CAAA,aAAA,EAAA,IAAA,CAAA;AACA,MAAA,CAAA,YAAA,CAAA,GAAA,GAAA,YAAA,CAAA,KAAA;AACA,KAAA;AACA,GAAA;;AAEA,EAAA,oBAAA,CAAA,MAAA,EAAA,aAAA,CAAA;;AAEA,EAAA,MAAA,CAAA,IAAA,CAAA,iBAAA,EAAA,GAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,yBAAA,CAAA,MAAA,EAAA,cAAA,EAAA;AACA,EAAA,MAAA,SAAA,GAAA,cAAA,IAAA,sBAAA,CAAA,MAAA,CAAA,IAAA,EAAA;AACA,EAAA,IAAA,SAAA,CAAA,MAAA,KAAA,CAAA,EAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,MAAA,aAAA,GAAA,MAAA,CAAA,UAAA,EAAA;AACA,EAAA,MAAAC,UAAA,GAAAC,0BAAA,CAAA,SAAA,EAAA,aAAA,CAAA,SAAA,EAAA,aAAA,CAAA,MAAA,EAAA,MAAA,CAAA,MAAA,EAAA,CAAA;;AAEA;AACA,EAAA,aAAA,EAAA,CAAA,GAAA,CAAA,MAAA,EAAA,EAAA,CAAA;;AAEA,EAAA,MAAA,CAAA,IAAA,CAAA,WAAA,CAAA;;AAEA;AACA;AACA,EAAA,MAAA,CAAA,YAAA,CAAAD,UAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,sBAAA,CAAA,MAAA,EAAA;AACA,EAAA,OAAA,aAAA,EAAA,CAAA,GAAA,CAAA,MAAA,CAAA;AACA;;AAEA,SAAA,aAAA,GAAA;AACA;AACA,EAAA,OAAAE,0BAAA,CAAA,sBAAA,EAAA,MAAA,IAAA,OAAA,EAAA,CAAA;AACA;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"internal.js","sources":["../../../src/logs/internal.ts"],"sourcesContent":["import { serializeAttributes } from '../attributes';\nimport { getGlobalSingleton } from '../carrier';\nimport type { Client } from '../client';\nimport { getClient, getCurrentScope, getIsolationScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Integration } from '../types-hoist/integration';\nimport type { Log, SerializedLog } from '../types-hoist/log';\nimport { consoleSandbox, debug } from '../utils/debug-logger';\nimport { isParameterizedString } from '../utils/is';\nimport { getCombinedScopeData } from '../utils/scopeData';\nimport { _getSpanForScope } from '../utils/spanOnScope';\nimport { timestampInSeconds } from '../utils/time';\nimport { getSequenceAttribute } from '../utils/timestampSequence';\nimport { _getTraceInfoFromScope } from '../utils/trace-info';\nimport { SEVERITY_TEXT_TO_SEVERITY_NUMBER } from './constants';\nimport { createLogEnvelope } from './envelope';\n\nconst MAX_LOG_BUFFER_SIZE = 100;\n\n/**\n * Sets a log attribute if the value exists and the attribute key is not already present.\n *\n * @param logAttributes - The log attributes object to modify.\n * @param key - The attribute key to set.\n * @param value - The value to set (only sets if truthy and key not present).\n * @param setEvenIfPresent - Whether to set the attribute if it is present. Defaults to true.\n */\nfunction setLogAttribute(\n logAttributes: Record<string, unknown>,\n key: string,\n value: unknown,\n setEvenIfPresent = true,\n): void {\n if (value && (!logAttributes[key] || setEvenIfPresent)) {\n logAttributes[key] = value;\n }\n}\n\n/**\n * Captures a serialized log event and adds it to the log buffer for the given client.\n *\n * @param client - A client. Uses the current client if not provided.\n * @param serializedLog - The serialized log event to capture.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_captureSerializedLog(client: Client, serializedLog: SerializedLog): void {\n const bufferMap = _getBufferMap();\n const logBuffer = _INTERNAL_getLogBuffer(client);\n\n if (logBuffer === undefined) {\n bufferMap.set(client, [serializedLog]);\n } else {\n if (logBuffer.length >= MAX_LOG_BUFFER_SIZE) {\n _INTERNAL_flushLogsBuffer(client, logBuffer);\n bufferMap.set(client, [serializedLog]);\n } else {\n bufferMap.set(client, [...logBuffer, serializedLog]);\n }\n }\n}\n\n/**\n * Captures a log event and sends it to Sentry.\n *\n * @param log - The log event to capture.\n * @param scope - A scope. Uses the current scope if not provided.\n * @param client - A client. Uses the current client if not provided.\n * @param captureSerializedLog - A function to capture the serialized log.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_captureLog(\n beforeLog: Log,\n currentScope = getCurrentScope(),\n captureSerializedLog: (client: Client, log: SerializedLog) => void = _INTERNAL_captureSerializedLog,\n): void {\n const client = currentScope?.getClient() ?? getClient();\n if (!client) {\n DEBUG_BUILD && debug.warn('No client available to capture log.');\n return;\n }\n\n const { release, environment, enableLogs = false, beforeSendLog } = client.getOptions();\n if (!enableLogs) {\n DEBUG_BUILD && debug.warn('logging option not enabled, log will not be captured.');\n return;\n }\n\n const [, traceContext] = _getTraceInfoFromScope(client, currentScope);\n\n const processedLogAttributes = {\n ...beforeLog.attributes,\n };\n\n const {\n user: { id, email, username },\n attributes: scopeAttributes = {},\n } = getCombinedScopeData(getIsolationScope(), currentScope);\n\n setLogAttribute(processedLogAttributes, 'user.id', id, false);\n setLogAttribute(processedLogAttributes, 'user.email', email, false);\n setLogAttribute(processedLogAttributes, 'user.name', username, false);\n\n setLogAttribute(processedLogAttributes, 'sentry.release', release);\n setLogAttribute(processedLogAttributes, 'sentry.environment', environment);\n\n const { name, version } = client.getSdkMetadata()?.sdk ?? {};\n setLogAttribute(processedLogAttributes, 'sentry.sdk.name', name);\n setLogAttribute(processedLogAttributes, 'sentry.sdk.version', version);\n\n const replay = client.getIntegrationByName<\n Integration & {\n getReplayId: (onlyIfSampled?: boolean) => string;\n getRecordingMode: () => 'session' | 'buffer' | undefined;\n }\n >('Replay');\n\n const replayId = replay?.getReplayId(true);\n setLogAttribute(processedLogAttributes, 'sentry.replay_id', replayId);\n\n if (replayId && replay?.getRecordingMode() === 'buffer') {\n // We send this so we can identify cases where the replayId is attached but the replay itself might not have been sent to Sentry\n setLogAttribute(processedLogAttributes, 'sentry._internal.replay_is_buffering', true);\n }\n\n const beforeLogMessage = beforeLog.message;\n if (isParameterizedString(beforeLogMessage)) {\n const { __sentry_template_string__, __sentry_template_values__ = [] } = beforeLogMessage;\n if (__sentry_template_values__?.length) {\n processedLogAttributes['sentry.message.template'] = __sentry_template_string__;\n }\n __sentry_template_values__.forEach((param, index) => {\n processedLogAttributes[`sentry.message.parameter.${index}`] = param;\n });\n }\n\n const span = _getSpanForScope(currentScope);\n // Add the parent span ID to the log attributes for trace context\n setLogAttribute(processedLogAttributes, 'sentry.trace.parent_span_id', span?.spanContext().spanId);\n\n const processedLog = { ...beforeLog, attributes: processedLogAttributes };\n\n client.emit('beforeCaptureLog', processedLog);\n\n // We need to wrap this in `consoleSandbox` to avoid recursive calls to `beforeSendLog`\n const log = beforeSendLog ? consoleSandbox(() => beforeSendLog(processedLog)) : processedLog;\n if (!log) {\n client.recordDroppedEvent('before_send', 'log_item', 1);\n DEBUG_BUILD && debug.warn('beforeSendLog returned null, log will not be captured.');\n return;\n }\n\n const { level, message, attributes: logAttributes = {}, severityNumber } = log;\n\n const timestamp = timestampInSeconds();\n const sequenceAttr = getSequenceAttribute(timestamp);\n\n const serializedLog: SerializedLog = {\n timestamp,\n level,\n body: message,\n trace_id: traceContext?.trace_id,\n severity_number: severityNumber ?? SEVERITY_TEXT_TO_SEVERITY_NUMBER[level],\n attributes: {\n ...serializeAttributes(scopeAttributes),\n ...serializeAttributes(logAttributes, true),\n [sequenceAttr.key]: sequenceAttr.value,\n },\n };\n\n captureSerializedLog(client, serializedLog);\n\n client.emit('afterCaptureLog', log);\n}\n\n/**\n * Flushes the logs buffer to Sentry.\n *\n * @param client - A client.\n * @param maybeLogBuffer - A log buffer. Uses the log buffer for the given client if not provided.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_flushLogsBuffer(client: Client, maybeLogBuffer?: Array<SerializedLog>): void {\n const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];\n if (logBuffer.length === 0) {\n return;\n }\n\n const clientOptions = client.getOptions();\n const envelope = createLogEnvelope(\n logBuffer,\n clientOptions._metadata,\n clientOptions.tunnel,\n client.getDsn(),\n clientOptions.sendDefaultPii,\n );\n\n // Clear the log buffer after envelopes have been constructed.\n _getBufferMap().set(client, []);\n\n client.emit('flushLogs');\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n\n/**\n * Returns the log buffer for a given client.\n *\n * Exported for testing purposes.\n *\n * @param client - The client to get the log buffer for.\n * @returns The log buffer for the given client.\n */\nexport function _INTERNAL_getLogBuffer(client: Client): Array<SerializedLog> | undefined {\n return _getBufferMap().get(client);\n}\n\nfunction _getBufferMap(): WeakMap<Client, Array<SerializedLog>> {\n // The reference to the Client <> LogBuffer map is stored on the carrier to ensure it's always the same\n return getGlobalSingleton('clientToLogBufferMap', () => new WeakMap<Client, Array<SerializedLog>>());\n}\n"],"names":["getCurrentScope","getClient","DEBUG_BUILD","debug","_getTraceInfoFromScope","getCombinedScopeData","getIsolationScope","isParameterizedString","_getSpanForScope","consoleSandbox","timestampInSeconds","getSequenceAttribute","SEVERITY_TEXT_TO_SEVERITY_NUMBER","serializeAttributes","envelope","createLogEnvelope","getGlobalSingleton"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,mBAAA,GAAsB,GAAG;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe;AACxB,EAAE,aAAa;AACf,EAAE,GAAG;AACL,EAAE,KAAK;AACP,EAAE,gBAAA,GAAmB,IAAI;AACzB,EAAQ;AACR,EAAE,IAAI,KAAA,KAAU,CAAC,aAAa,CAAC,GAAG,CAAA,IAAK,gBAAgB,CAAC,EAAE;AAC1D,IAAI,aAAa,CAAC,GAAG,CAAA,GAAI,KAAK;AAC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A,EAAA,CAAA;;AAEA,EAAA,MAAA,CAAA,IAAA,CAAA,WAAA,CAAA;;AAEA;AACA;AACA,EAAA,MAAA,CAAA,YAAA,CAAAD,UAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,sBAAA,CAAA,MAAA,EAAA;AACA,EAAA,OAAA,aAAA,EAAA,CAAA,GAAA,CAAA,MAAA,CAAA;AACA;;AAEA,SAAA,aAAA,GAAA;AACA;AACA,EAAA,OAAAE,0BAAA,CAAA,sBAAA,EAAA,MAAA,IAAA,OAAA,EAAA,CAAA;AACA;;;;;;;"}
|
|
@@ -2,14 +2,21 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const dsn = require('../utils/dsn.js');
|
|
4
4
|
const envelope = require('../utils/envelope.js');
|
|
5
|
+
const isBrowser = require('../utils/isBrowser.js');
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Creates a metric container envelope item for a list of metrics.
|
|
8
9
|
*
|
|
9
10
|
* @param items - The metrics to include in the envelope.
|
|
11
|
+
* @param inferUserData - If true, tells Relay to infer the end-user IP and User-Agent from the incoming request.
|
|
12
|
+
* Only emitted as `ingest_settings` in browser environments.
|
|
10
13
|
* @returns The created metric container envelope item.
|
|
11
14
|
*/
|
|
12
|
-
function createMetricContainerEnvelopeItem(
|
|
15
|
+
function createMetricContainerEnvelopeItem(
|
|
16
|
+
items,
|
|
17
|
+
inferUserData,
|
|
18
|
+
) {
|
|
19
|
+
const inferSetting = inferUserData ? 'auto' : 'never';
|
|
13
20
|
return [
|
|
14
21
|
{
|
|
15
22
|
type: 'trace_metric',
|
|
@@ -17,6 +24,10 @@ function createMetricContainerEnvelopeItem(items) {
|
|
|
17
24
|
content_type: 'application/vnd.sentry.items.trace-metric+json',
|
|
18
25
|
} ,
|
|
19
26
|
{
|
|
27
|
+
version: 2,
|
|
28
|
+
...(isBrowser.isBrowser() && {
|
|
29
|
+
ingest_settings: { infer_ip: inferSetting, infer_user_agent: inferSetting },
|
|
30
|
+
}),
|
|
20
31
|
items,
|
|
21
32
|
},
|
|
22
33
|
];
|
|
@@ -31,6 +42,7 @@ function createMetricContainerEnvelopeItem(items) {
|
|
|
31
42
|
* @param metadata - The metadata to include in the envelope.
|
|
32
43
|
* @param tunnel - The tunnel to include in the envelope.
|
|
33
44
|
* @param dsn - The DSN to include in the envelope.
|
|
45
|
+
* @param inferUserData - If true, tells Relay to infer the end-user IP and User-Agent from the incoming request.
|
|
34
46
|
* @returns The created envelope.
|
|
35
47
|
*/
|
|
36
48
|
function createMetricEnvelope(
|
|
@@ -38,6 +50,7 @@ function createMetricEnvelope(
|
|
|
38
50
|
metadata,
|
|
39
51
|
tunnel,
|
|
40
52
|
dsn$1,
|
|
53
|
+
inferUserData,
|
|
41
54
|
) {
|
|
42
55
|
const headers = {};
|
|
43
56
|
|
|
@@ -52,7 +65,7 @@ function createMetricEnvelope(
|
|
|
52
65
|
headers.dsn = dsn.dsnToString(dsn$1);
|
|
53
66
|
}
|
|
54
67
|
|
|
55
|
-
return envelope.createEnvelope(headers, [createMetricContainerEnvelopeItem(metrics)]);
|
|
68
|
+
return envelope.createEnvelope(headers, [createMetricContainerEnvelopeItem(metrics, inferUserData)]);
|
|
56
69
|
}
|
|
57
70
|
|
|
58
71
|
exports.createMetricContainerEnvelopeItem = createMetricContainerEnvelopeItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.js","sources":["../../../src/metrics/envelope.ts"],"sourcesContent":["import type { DsnComponents } from '../types-hoist/dsn';\nimport type { MetricContainerItem, MetricEnvelope } from '../types-hoist/envelope';\nimport type { SerializedMetric } from '../types-hoist/metric';\nimport type { SdkMetadata } from '../types-hoist/sdkmetadata';\nimport { dsnToString } from '../utils/dsn';\nimport { createEnvelope } from '../utils/envelope';\n\n/**\n * Creates a metric container envelope item for a list of metrics.\n *\n * @param items - The metrics to include in the envelope.\n * @returns The created metric container envelope item.\n */\nexport function createMetricContainerEnvelopeItem(items: Array<SerializedMetric
|
|
1
|
+
{"version":3,"file":"envelope.js","sources":["../../../src/metrics/envelope.ts"],"sourcesContent":["import type { DsnComponents } from '../types-hoist/dsn';\nimport type { MetricContainerItem, MetricEnvelope } from '../types-hoist/envelope';\nimport type { SerializedMetric } from '../types-hoist/metric';\nimport type { SdkMetadata } from '../types-hoist/sdkmetadata';\nimport { dsnToString } from '../utils/dsn';\nimport { createEnvelope } from '../utils/envelope';\nimport { isBrowser } from '../utils/isBrowser';\n\n/**\n * Creates a metric container envelope item for a list of metrics.\n *\n * @param items - The metrics to include in the envelope.\n * @param inferUserData - If true, tells Relay to infer the end-user IP and User-Agent from the incoming request.\n * Only emitted as `ingest_settings` in browser environments.\n * @returns The created metric container envelope item.\n */\nexport function createMetricContainerEnvelopeItem(\n items: Array<SerializedMetric>,\n inferUserData?: boolean,\n): MetricContainerItem {\n const inferSetting = inferUserData ? 'auto' : 'never';\n return [\n {\n type: 'trace_metric',\n item_count: items.length,\n content_type: 'application/vnd.sentry.items.trace-metric+json',\n } as MetricContainerItem[0],\n {\n version: 2,\n ...(isBrowser() && {\n ingest_settings: { infer_ip: inferSetting, infer_user_agent: inferSetting },\n }),\n items,\n },\n ];\n}\n\n/**\n * Creates an envelope for a list of metrics.\n *\n * Metrics from multiple traces can be included in the same envelope.\n *\n * @param metrics - The metrics to include in the envelope.\n * @param metadata - The metadata to include in the envelope.\n * @param tunnel - The tunnel to include in the envelope.\n * @param dsn - The DSN to include in the envelope.\n * @param inferUserData - If true, tells Relay to infer the end-user IP and User-Agent from the incoming request.\n * @returns The created envelope.\n */\nexport function createMetricEnvelope(\n metrics: Array<SerializedMetric>,\n metadata?: SdkMetadata,\n tunnel?: string,\n dsn?: DsnComponents,\n inferUserData?: boolean,\n): MetricEnvelope {\n const headers: MetricEnvelope[0] = {};\n\n if (metadata?.sdk) {\n headers.sdk = {\n name: metadata.sdk.name,\n version: metadata.sdk.version,\n };\n }\n\n if (!!tunnel && !!dsn) {\n headers.dsn = dsnToString(dsn);\n }\n\n return createEnvelope<MetricEnvelope>(headers, [createMetricContainerEnvelopeItem(metrics, inferUserData)]);\n}\n"],"names":["isBrowser","dsn","dsnToString","createEnvelope"],"mappings":";;;;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iCAAiC;AACjD,EAAE,KAAK;AACP,EAAE,aAAa;AACf,EAAuB;AACvB,EAAE,MAAM,YAAA,GAAe,gBAAgB,MAAA,GAAS,OAAO;AACvD,EAAE,OAAO;AACT,IAAI;AACJ,MAAM,IAAI,EAAE,cAAc;AAC1B,MAAM,UAAU,EAAE,KAAK,CAAC,MAAM;AAC9B,MAAM,YAAY,EAAE,gDAAgD;AACpE,KAAI;AACJ,IAAI;AACJ,MAAM,OAAO,EAAE,CAAC;AAChB,MAAM,IAAIA,mBAAS,MAAM;AACzB,QAAQ,eAAe,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAA,EAAc;AACnF,OAAO,CAAC;AACR,MAAM,KAAK;AACX,KAAK;AACL,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB;AACpC,EAAE,OAAO;AACT,EAAE,QAAQ;AACV,EAAE,MAAM;AACR,EAAEC,KAAG;AACL,EAAE,aAAa;AACf,EAAkB;AAClB,EAAE,MAAM,OAAO,GAAsB,EAAE;;AAEvC,EAAE,IAAI,QAAQ,EAAE,GAAG,EAAE;AACrB,IAAI,OAAO,CAAC,GAAA,GAAM;AAClB,MAAM,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI;AAC7B,MAAM,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO;AACnC,KAAK;AACL,EAAE;;AAEF,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC,CAACA,KAAG,EAAE;AACzB,IAAI,OAAO,CAAC,GAAA,GAAMC,eAAW,CAACD,KAAG,CAAC;AAClC,EAAE;;AAEF,EAAE,OAAOE,uBAAc,CAAiB,OAAO,EAAE,CAAC,iCAAiC,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;AAC7G;;;;;"}
|
|
@@ -208,7 +208,13 @@ function _INTERNAL_flushMetricsBuffer(client, maybeMetricBuffer) {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
const clientOptions = client.getOptions();
|
|
211
|
-
const envelope$1 = envelope.createMetricEnvelope(
|
|
211
|
+
const envelope$1 = envelope.createMetricEnvelope(
|
|
212
|
+
metricBuffer,
|
|
213
|
+
clientOptions._metadata,
|
|
214
|
+
clientOptions.tunnel,
|
|
215
|
+
client.getDsn(),
|
|
216
|
+
clientOptions.sendDefaultPii,
|
|
217
|
+
);
|
|
212
218
|
|
|
213
219
|
// Clear the metric buffer after envelopes have been constructed.
|
|
214
220
|
_getBufferMap().set(client, []);
|