@sentry/core 10.46.0 → 10.48.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/api.js +1 -0
- package/build/cjs/api.js.map +1 -1
- package/build/cjs/attributes.js +43 -0
- package/build/cjs/attributes.js.map +1 -1
- package/build/cjs/client.js +13 -6
- package/build/cjs/client.js.map +1 -1
- package/build/cjs/currentScopes.js +33 -0
- package/build/cjs/currentScopes.js.map +1 -1
- package/build/cjs/envelope.js +4 -3
- package/build/cjs/envelope.js.map +1 -1
- package/build/cjs/index.js +50 -13
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integration.js +6 -0
- package/build/cjs/integration.js.map +1 -1
- package/build/cjs/integrations/express/index.js +206 -0
- package/build/cjs/integrations/express/index.js.map +1 -0
- package/build/cjs/integrations/express/patch-layer.js +251 -0
- package/build/cjs/integrations/express/patch-layer.js.map +1 -0
- package/build/cjs/integrations/express/request-layer-store.js +25 -0
- package/build/cjs/integrations/express/request-layer-store.js.map +1 -0
- package/build/cjs/integrations/express/set-sdk-processing-metadata.js +17 -0
- package/build/cjs/integrations/express/set-sdk-processing-metadata.js.map +1 -0
- package/build/cjs/integrations/express/types.js +17 -0
- package/build/cjs/integrations/express/types.js.map +1 -0
- package/build/cjs/integrations/express/utils.js +238 -0
- package/build/cjs/integrations/express/utils.js.map +1 -0
- package/build/cjs/integrations/mcp-server/correlation.js +5 -1
- package/build/cjs/integrations/mcp-server/correlation.js.map +1 -1
- package/build/cjs/integrations/mcp-server/handlers.js +18 -10
- package/build/cjs/integrations/mcp-server/handlers.js.map +1 -1
- package/build/cjs/integrations/mcp-server/index.js +2 -1
- package/build/cjs/integrations/mcp-server/index.js.map +1 -1
- package/build/cjs/integrations/mcp-server/transport.js +1 -1
- package/build/cjs/integrations/mcp-server/transport.js.map +1 -1
- package/build/cjs/integrations/mcp-server/validation.js +7 -5
- package/build/cjs/integrations/mcp-server/validation.js.map +1 -1
- package/build/cjs/integrations/spanStreaming.js +48 -0
- package/build/cjs/integrations/spanStreaming.js.map +1 -0
- package/build/cjs/integrations/supabase.js +1 -1
- package/build/cjs/integrations/supabase.js.map +1 -1
- package/build/cjs/semanticAttributes.js +35 -3
- package/build/cjs/semanticAttributes.js.map +1 -1
- package/build/cjs/tracing/ai/gen-ai-attributes.js +9 -79
- package/build/cjs/tracing/ai/gen-ai-attributes.js.map +1 -1
- package/build/cjs/tracing/ai/utils.js +50 -35
- package/build/cjs/tracing/ai/utils.js.map +1 -1
- package/build/cjs/tracing/anthropic-ai/constants.js +10 -10
- package/build/cjs/tracing/anthropic-ai/constants.js.map +1 -1
- package/build/cjs/tracing/anthropic-ai/index.js +18 -20
- package/build/cjs/tracing/anthropic-ai/index.js.map +1 -1
- package/build/cjs/tracing/anthropic-ai/streaming.js +2 -100
- package/build/cjs/tracing/anthropic-ai/streaming.js.map +1 -1
- package/build/cjs/tracing/anthropic-ai/utils.js +0 -9
- package/build/cjs/tracing/anthropic-ai/utils.js.map +1 -1
- package/build/cjs/tracing/dynamicSamplingContext.js +2 -1
- package/build/cjs/tracing/dynamicSamplingContext.js.map +1 -1
- package/build/cjs/tracing/google-genai/constants.js +9 -12
- package/build/cjs/tracing/google-genai/constants.js.map +1 -1
- package/build/cjs/tracing/google-genai/index.js +49 -27
- package/build/cjs/tracing/google-genai/index.js.map +1 -1
- package/build/cjs/tracing/google-genai/streaming.js +2 -23
- package/build/cjs/tracing/google-genai/streaming.js.map +1 -1
- package/build/cjs/tracing/google-genai/utils.js +0 -25
- package/build/cjs/tracing/google-genai/utils.js.map +1 -1
- package/build/cjs/tracing/langchain/embeddings.js +132 -0
- package/build/cjs/tracing/langchain/embeddings.js.map +1 -0
- package/build/cjs/tracing/langchain/index.js.map +1 -1
- package/build/cjs/tracing/openai/constants.js +7 -7
- package/build/cjs/tracing/openai/constants.js.map +1 -1
- package/build/cjs/tracing/openai/index.js +19 -37
- package/build/cjs/tracing/openai/index.js.map +1 -1
- package/build/cjs/tracing/openai/streaming.js +3 -34
- package/build/cjs/tracing/openai/streaming.js.map +1 -1
- package/build/cjs/tracing/openai/utils.js +78 -243
- package/build/cjs/tracing/openai/utils.js.map +1 -1
- package/build/cjs/tracing/sentryNonRecordingSpan.js +7 -0
- package/build/cjs/tracing/sentryNonRecordingSpan.js.map +1 -1
- package/build/cjs/tracing/sentrySpan.js +39 -0
- package/build/cjs/tracing/sentrySpan.js.map +1 -1
- package/build/cjs/tracing/spans/beforeSendSpan.js +43 -0
- package/build/cjs/tracing/spans/beforeSendSpan.js.map +1 -0
- package/build/cjs/tracing/spans/captureSpan.js +126 -0
- package/build/cjs/tracing/spans/captureSpan.js.map +1 -0
- package/build/cjs/tracing/spans/envelope.js +38 -0
- package/build/cjs/tracing/spans/envelope.js.map +1 -0
- package/build/cjs/tracing/spans/estimateSize.js +41 -0
- package/build/cjs/tracing/spans/estimateSize.js.map +1 -0
- package/build/cjs/tracing/spans/hasSpanStreamingEnabled.js +11 -0
- package/build/cjs/tracing/spans/hasSpanStreamingEnabled.js.map +1 -0
- package/build/cjs/tracing/spans/spanBuffer.js +158 -0
- package/build/cjs/tracing/spans/spanBuffer.js.map +1 -0
- package/build/cjs/tracing/trace.js +88 -13
- package/build/cjs/tracing/trace.js.map +1 -1
- package/build/cjs/tracing/vercel-ai/utils.js +1 -4
- package/build/cjs/tracing/vercel-ai/utils.js.map +1 -1
- package/build/cjs/utils/featureFlags.js +6 -0
- package/build/cjs/utils/featureFlags.js.map +1 -1
- package/build/cjs/utils/object.js +33 -0
- package/build/cjs/utils/object.js.map +1 -1
- package/build/cjs/utils/spanUtils.js +116 -13
- package/build/cjs/utils/spanUtils.js.map +1 -1
- package/build/cjs/utils/stacktrace.js +3 -1
- package/build/cjs/utils/stacktrace.js.map +1 -1
- package/build/cjs/utils/string.js +3 -0
- package/build/cjs/utils/string.js.map +1 -1
- package/build/cjs/utils/traceData.js +11 -0
- package/build/cjs/utils/traceData.js.map +1 -1
- package/build/cjs/utils/version.js +1 -1
- package/build/esm/api.js +1 -1
- package/build/esm/api.js.map +1 -1
- package/build/esm/attributes.js +43 -1
- package/build/esm/attributes.js.map +1 -1
- package/build/esm/client.js +8 -1
- package/build/esm/client.js.map +1 -1
- package/build/esm/currentScopes.js +31 -1
- package/build/esm/currentScopes.js.map +1 -1
- package/build/esm/envelope.js +2 -1
- package/build/esm/envelope.js.map +1 -1
- package/build/esm/index.js +13 -4
- package/build/esm/index.js.map +1 -1
- package/build/esm/integration.js +6 -0
- package/build/esm/integration.js.map +1 -1
- package/build/esm/integrations/express/index.js +202 -0
- package/build/esm/integrations/express/index.js.map +1 -0
- package/build/esm/integrations/express/patch-layer.js +249 -0
- package/build/esm/integrations/express/patch-layer.js.map +1 -0
- package/build/esm/integrations/express/request-layer-store.js +22 -0
- package/build/esm/integrations/express/request-layer-store.js.map +1 -0
- package/build/esm/integrations/express/set-sdk-processing-metadata.js +15 -0
- package/build/esm/integrations/express/set-sdk-processing-metadata.js.map +1 -0
- package/build/esm/integrations/express/types.js +10 -0
- package/build/esm/integrations/express/types.js.map +1 -0
- package/build/esm/integrations/express/utils.js +225 -0
- package/build/esm/integrations/express/utils.js.map +1 -0
- package/build/esm/integrations/mcp-server/correlation.js +5 -1
- package/build/esm/integrations/mcp-server/correlation.js.map +1 -1
- package/build/esm/integrations/mcp-server/handlers.js +18 -10
- package/build/esm/integrations/mcp-server/handlers.js.map +1 -1
- package/build/esm/integrations/mcp-server/index.js +2 -1
- package/build/esm/integrations/mcp-server/index.js.map +1 -1
- package/build/esm/integrations/mcp-server/transport.js +1 -1
- package/build/esm/integrations/mcp-server/transport.js.map +1 -1
- package/build/esm/integrations/mcp-server/validation.js +7 -5
- package/build/esm/integrations/mcp-server/validation.js.map +1 -1
- package/build/esm/integrations/spanStreaming.js +46 -0
- package/build/esm/integrations/spanStreaming.js.map +1 -0
- package/build/esm/integrations/supabase.js +1 -1
- package/build/esm/integrations/supabase.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/semanticAttributes.js +26 -4
- package/build/esm/semanticAttributes.js.map +1 -1
- package/build/esm/tracing/ai/gen-ai-attributes.js +8 -69
- package/build/esm/tracing/ai/gen-ai-attributes.js.map +1 -1
- package/build/esm/tracing/ai/utils.js +51 -35
- package/build/esm/tracing/ai/utils.js.map +1 -1
- package/build/esm/tracing/anthropic-ai/constants.js +10 -10
- package/build/esm/tracing/anthropic-ai/constants.js.map +1 -1
- package/build/esm/tracing/anthropic-ai/index.js +21 -23
- package/build/esm/tracing/anthropic-ai/index.js.map +1 -1
- package/build/esm/tracing/anthropic-ai/streaming.js +3 -101
- package/build/esm/tracing/anthropic-ai/streaming.js.map +1 -1
- package/build/esm/tracing/anthropic-ai/utils.js +1 -9
- package/build/esm/tracing/anthropic-ai/utils.js.map +1 -1
- package/build/esm/tracing/dynamicSamplingContext.js +2 -1
- package/build/esm/tracing/dynamicSamplingContext.js.map +1 -1
- package/build/esm/tracing/google-genai/constants.js +9 -10
- package/build/esm/tracing/google-genai/constants.js.map +1 -1
- package/build/esm/tracing/google-genai/index.js +53 -31
- package/build/esm/tracing/google-genai/index.js.map +1 -1
- package/build/esm/tracing/google-genai/streaming.js +2 -23
- package/build/esm/tracing/google-genai/streaming.js.map +1 -1
- package/build/esm/tracing/google-genai/utils.js +1 -24
- package/build/esm/tracing/google-genai/utils.js.map +1 -1
- package/build/esm/tracing/langchain/embeddings.js +129 -0
- package/build/esm/tracing/langchain/embeddings.js.map +1 -0
- package/build/esm/tracing/langchain/index.js.map +1 -1
- package/build/esm/tracing/openai/constants.js +7 -7
- package/build/esm/tracing/openai/constants.js.map +1 -1
- package/build/esm/tracing/openai/index.js +21 -39
- package/build/esm/tracing/openai/index.js.map +1 -1
- package/build/esm/tracing/openai/streaming.js +4 -35
- package/build/esm/tracing/openai/streaming.js.map +1 -1
- package/build/esm/tracing/openai/utils.js +79 -232
- package/build/esm/tracing/openai/utils.js.map +1 -1
- package/build/esm/tracing/sentryNonRecordingSpan.js +7 -0
- package/build/esm/tracing/sentryNonRecordingSpan.js.map +1 -1
- package/build/esm/tracing/sentrySpan.js +40 -1
- package/build/esm/tracing/sentrySpan.js.map +1 -1
- package/build/esm/tracing/spans/beforeSendSpan.js +40 -0
- package/build/esm/tracing/spans/beforeSendSpan.js.map +1 -0
- package/build/esm/tracing/spans/captureSpan.js +122 -0
- package/build/esm/tracing/spans/captureSpan.js.map +1 -0
- package/build/esm/tracing/spans/envelope.js +36 -0
- package/build/esm/tracing/spans/envelope.js.map +1 -0
- package/build/esm/tracing/spans/estimateSize.js +39 -0
- package/build/esm/tracing/spans/estimateSize.js.map +1 -0
- package/build/esm/tracing/spans/hasSpanStreamingEnabled.js +9 -0
- package/build/esm/tracing/spans/hasSpanStreamingEnabled.js.map +1 -0
- package/build/esm/tracing/spans/spanBuffer.js +156 -0
- package/build/esm/tracing/spans/spanBuffer.js.map +1 -0
- package/build/esm/tracing/trace.js +89 -14
- package/build/esm/tracing/trace.js.map +1 -1
- package/build/esm/tracing/vercel-ai/utils.js +2 -5
- package/build/esm/tracing/vercel-ai/utils.js.map +1 -1
- package/build/esm/utils/featureFlags.js +6 -0
- package/build/esm/utils/featureFlags.js.map +1 -1
- package/build/esm/utils/object.js +33 -1
- package/build/esm/utils/object.js.map +1 -1
- package/build/esm/utils/spanUtils.js +112 -14
- package/build/esm/utils/spanUtils.js.map +1 -1
- package/build/esm/utils/stacktrace.js +3 -1
- package/build/esm/utils/stacktrace.js.map +1 -1
- package/build/esm/utils/string.js +3 -0
- package/build/esm/utils/string.js.map +1 -1
- package/build/esm/utils/traceData.js +12 -1
- package/build/esm/utils/traceData.js.map +1 -1
- package/build/esm/utils/version.js +1 -1
- package/build/types/api.d.ts +1 -0
- package/build/types/api.d.ts.map +1 -1
- package/build/types/asyncContext/types.d.ts +3 -1
- package/build/types/asyncContext/types.d.ts.map +1 -1
- package/build/types/attributes.d.ts +5 -0
- package/build/types/attributes.d.ts.map +1 -1
- package/build/types/client.d.ts +35 -1
- package/build/types/client.d.ts.map +1 -1
- package/build/types/currentScopes.d.ts +20 -0
- package/build/types/currentScopes.d.ts.map +1 -1
- package/build/types/envelope.d.ts.map +1 -1
- package/build/types/index.d.ts +15 -6
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integration.d.ts.map +1 -1
- package/build/types/integrations/express/index.d.ts +75 -0
- package/build/types/integrations/express/index.d.ts.map +1 -0
- package/build/types/integrations/express/patch-layer.d.ts +32 -0
- package/build/types/integrations/express/patch-layer.d.ts.map +1 -0
- package/build/types/integrations/express/request-layer-store.d.ts +32 -0
- package/build/types/integrations/express/request-layer-store.d.ts.map +1 -0
- package/build/types/integrations/express/set-sdk-processing-metadata.d.ts +35 -0
- package/build/types/integrations/express/set-sdk-processing-metadata.d.ts.map +1 -0
- package/build/types/integrations/express/types.d.ts +154 -0
- package/build/types/integrations/express/types.d.ts.map +1 -0
- package/build/types/integrations/express/utils.d.ts +93 -0
- package/build/types/integrations/express/utils.d.ts.map +1 -0
- package/build/types/integrations/mcp-server/correlation.d.ts +2 -1
- package/build/types/integrations/mcp-server/correlation.d.ts.map +1 -1
- package/build/types/integrations/mcp-server/handlers.d.ts +9 -4
- package/build/types/integrations/mcp-server/handlers.d.ts.map +1 -1
- package/build/types/integrations/mcp-server/index.d.ts +2 -1
- package/build/types/integrations/mcp-server/index.d.ts.map +1 -1
- package/build/types/integrations/mcp-server/types.d.ts +40 -7
- package/build/types/integrations/mcp-server/types.d.ts.map +1 -1
- package/build/types/integrations/mcp-server/validation.d.ts +4 -1
- package/build/types/integrations/mcp-server/validation.d.ts.map +1 -1
- package/build/types/integrations/spanStreaming.d.ts +2 -0
- package/build/types/integrations/spanStreaming.d.ts.map +1 -0
- package/build/types/semanticAttributes.d.ts +23 -3
- package/build/types/semanticAttributes.d.ts.map +1 -1
- package/build/types/tracing/ai/gen-ai-attributes.d.ts +6 -46
- package/build/types/tracing/ai/gen-ai-attributes.d.ts.map +1 -1
- package/build/types/tracing/ai/utils.d.ts +34 -9
- package/build/types/tracing/ai/utils.d.ts.map +1 -1
- package/build/types/tracing/anthropic-ai/constants.d.ts +24 -1
- package/build/types/tracing/anthropic-ai/constants.d.ts.map +1 -1
- package/build/types/tracing/anthropic-ai/index.d.ts.map +1 -1
- package/build/types/tracing/anthropic-ai/streaming.d.ts.map +1 -1
- package/build/types/tracing/anthropic-ai/types.d.ts +5 -2
- package/build/types/tracing/anthropic-ai/types.d.ts.map +1 -1
- package/build/types/tracing/anthropic-ai/utils.d.ts +1 -5
- package/build/types/tracing/anthropic-ai/utils.d.ts.map +1 -1
- package/build/types/tracing/dynamicSamplingContext.d.ts.map +1 -1
- package/build/types/tracing/google-genai/constants.d.ts +22 -3
- package/build/types/tracing/google-genai/constants.d.ts.map +1 -1
- package/build/types/tracing/google-genai/index.d.ts.map +1 -1
- package/build/types/tracing/google-genai/streaming.d.ts.map +1 -1
- package/build/types/tracing/google-genai/types.d.ts +6 -2
- package/build/types/tracing/google-genai/types.d.ts.map +1 -1
- package/build/types/tracing/google-genai/utils.d.ts +0 -9
- package/build/types/tracing/google-genai/utils.d.ts.map +1 -1
- package/build/types/tracing/index.d.ts +1 -0
- package/build/types/tracing/index.d.ts.map +1 -1
- package/build/types/tracing/langchain/embeddings.d.ts +27 -0
- package/build/types/tracing/langchain/embeddings.d.ts.map +1 -0
- package/build/types/tracing/langchain/index.d.ts +1 -0
- package/build/types/tracing/langchain/index.d.ts.map +1 -1
- package/build/types/tracing/openai/constants.d.ts +14 -1
- package/build/types/tracing/openai/constants.d.ts.map +1 -1
- package/build/types/tracing/openai/index.d.ts.map +1 -1
- package/build/types/tracing/openai/streaming.d.ts.map +1 -1
- package/build/types/tracing/openai/types.d.ts +5 -2
- package/build/types/tracing/openai/types.d.ts.map +1 -1
- package/build/types/tracing/openai/utils.d.ts +4 -63
- package/build/types/tracing/openai/utils.d.ts.map +1 -1
- package/build/types/tracing/sentryNonRecordingSpan.d.ts +12 -1
- package/build/types/tracing/sentryNonRecordingSpan.d.ts.map +1 -1
- package/build/types/tracing/sentrySpan.d.ts +10 -1
- package/build/types/tracing/sentrySpan.d.ts.map +1 -1
- package/build/types/tracing/spans/beforeSendSpan.d.ts +35 -0
- package/build/types/tracing/spans/beforeSendSpan.d.ts.map +1 -0
- package/build/types/tracing/spans/captureSpan.d.ts +26 -0
- package/build/types/tracing/spans/captureSpan.d.ts.map +1 -0
- package/build/types/tracing/spans/envelope.d.ts +8 -0
- package/build/types/tracing/spans/envelope.d.ts.map +1 -0
- package/build/types/tracing/spans/estimateSize.d.ts +12 -0
- package/build/types/tracing/spans/estimateSize.d.ts.map +1 -0
- package/build/types/tracing/spans/hasSpanStreamingEnabled.d.ts +6 -0
- package/build/types/tracing/spans/hasSpanStreamingEnabled.d.ts.map +1 -0
- package/build/types/tracing/spans/spanBuffer.d.ts +60 -0
- package/build/types/tracing/spans/spanBuffer.d.ts.map +1 -0
- package/build/types/tracing/trace.d.ts.map +1 -1
- package/build/types/tracing/vercel-ai/utils.d.ts.map +1 -1
- package/build/types/types-hoist/envelope.d.ts +22 -2
- package/build/types/types-hoist/envelope.d.ts.map +1 -1
- package/build/types/types-hoist/integration.d.ts +8 -0
- package/build/types/types-hoist/integration.d.ts.map +1 -1
- package/build/types/types-hoist/link.d.ts +2 -2
- package/build/types/types-hoist/link.d.ts.map +1 -1
- package/build/types/types-hoist/options.d.ts +26 -2
- package/build/types/types-hoist/options.d.ts.map +1 -1
- package/build/types/types-hoist/span.d.ts +35 -0
- package/build/types/types-hoist/span.d.ts.map +1 -1
- package/build/types/utils/featureFlags.d.ts.map +1 -1
- package/build/types/utils/object.d.ts +10 -0
- package/build/types/utils/object.d.ts.map +1 -1
- package/build/types/utils/spanUtils.d.ts +27 -2
- package/build/types/utils/spanUtils.d.ts.map +1 -1
- package/build/types/utils/stacktrace.d.ts.map +1 -1
- package/build/types/utils/string.d.ts +2 -2
- package/build/types/utils/string.d.ts.map +1 -1
- package/build/types/utils/traceData.d.ts +4 -0
- package/build/types/utils/traceData.d.ts.map +1 -1
- package/build/types-ts3.8/api.d.ts +1 -0
- package/build/types-ts3.8/asyncContext/types.d.ts +3 -1
- package/build/types-ts3.8/attributes.d.ts +5 -0
- package/build/types-ts3.8/client.d.ts +35 -1
- package/build/types-ts3.8/currentScopes.d.ts +20 -0
- package/build/types-ts3.8/index.d.ts +15 -6
- package/build/types-ts3.8/integrations/express/index.d.ts +75 -0
- package/build/types-ts3.8/integrations/express/patch-layer.d.ts +32 -0
- package/build/types-ts3.8/integrations/express/request-layer-store.d.ts +32 -0
- package/build/types-ts3.8/integrations/express/set-sdk-processing-metadata.d.ts +35 -0
- package/build/types-ts3.8/integrations/express/types.d.ts +154 -0
- package/build/types-ts3.8/integrations/express/utils.d.ts +96 -0
- package/build/types-ts3.8/integrations/mcp-server/correlation.d.ts +2 -1
- package/build/types-ts3.8/integrations/mcp-server/handlers.d.ts +9 -4
- package/build/types-ts3.8/integrations/mcp-server/index.d.ts +2 -1
- package/build/types-ts3.8/integrations/mcp-server/types.d.ts +40 -7
- package/build/types-ts3.8/integrations/mcp-server/validation.d.ts +4 -1
- package/build/types-ts3.8/integrations/spanStreaming.d.ts +2 -0
- package/build/types-ts3.8/semanticAttributes.d.ts +23 -3
- package/build/types-ts3.8/tracing/ai/gen-ai-attributes.d.ts +6 -46
- package/build/types-ts3.8/tracing/ai/utils.d.ts +34 -9
- package/build/types-ts3.8/tracing/anthropic-ai/constants.d.ts +24 -9
- package/build/types-ts3.8/tracing/anthropic-ai/types.d.ts +5 -2
- package/build/types-ts3.8/tracing/anthropic-ai/utils.d.ts +1 -5
- package/build/types-ts3.8/tracing/google-genai/constants.d.ts +22 -9
- package/build/types-ts3.8/tracing/google-genai/types.d.ts +6 -2
- package/build/types-ts3.8/tracing/google-genai/utils.d.ts +0 -9
- package/build/types-ts3.8/tracing/index.d.ts +1 -0
- package/build/types-ts3.8/tracing/langchain/embeddings.d.ts +27 -0
- package/build/types-ts3.8/tracing/langchain/index.d.ts +1 -0
- package/build/types-ts3.8/tracing/openai/constants.d.ts +14 -6
- package/build/types-ts3.8/tracing/openai/types.d.ts +5 -2
- package/build/types-ts3.8/tracing/openai/utils.d.ts +4 -63
- package/build/types-ts3.8/tracing/sentryNonRecordingSpan.d.ts +12 -1
- package/build/types-ts3.8/tracing/sentrySpan.d.ts +10 -1
- package/build/types-ts3.8/tracing/spans/beforeSendSpan.d.ts +35 -0
- package/build/types-ts3.8/tracing/spans/captureSpan.d.ts +26 -0
- package/build/types-ts3.8/tracing/spans/envelope.d.ts +8 -0
- package/build/types-ts3.8/tracing/spans/estimateSize.d.ts +12 -0
- package/build/types-ts3.8/tracing/spans/hasSpanStreamingEnabled.d.ts +6 -0
- package/build/types-ts3.8/tracing/spans/spanBuffer.d.ts +60 -0
- package/build/types-ts3.8/types-hoist/envelope.d.ts +22 -2
- package/build/types-ts3.8/types-hoist/integration.d.ts +8 -0
- package/build/types-ts3.8/types-hoist/link.d.ts +2 -2
- package/build/types-ts3.8/types-hoist/options.d.ts +26 -2
- package/build/types-ts3.8/types-hoist/span.d.ts +35 -0
- package/build/types-ts3.8/utils/object.d.ts +10 -0
- package/build/types-ts3.8/utils/spanUtils.d.ts +27 -2
- package/build/types-ts3.8/utils/string.d.ts +2 -2
- package/build/types-ts3.8/utils/traceData.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.js","sources":["../../src/envelope.ts"],"sourcesContent":["import type { Client } from './client';\nimport { getDynamicSamplingContextFromSpan } from './tracing/dynamicSamplingContext';\nimport type { SentrySpan } from './tracing/sentrySpan';\nimport type { LegacyCSPReport } from './types-hoist/csp';\nimport type { DsnComponents } from './types-hoist/dsn';\nimport type {\n DynamicSamplingContext,\n EventEnvelope,\n EventItem,\n RawSecurityEnvelope,\n RawSecurityItem,\n SessionEnvelope,\n SessionItem,\n SpanEnvelope,\n SpanItem,\n} from './types-hoist/envelope';\nimport type { Event } from './types-hoist/event';\nimport type { SdkInfo } from './types-hoist/sdkinfo';\nimport type { SdkMetadata } from './types-hoist/sdkmetadata';\nimport type { Session, SessionAggregates } from './types-hoist/session';\nimport { dsnToString } from './utils/dsn';\nimport {\n createEnvelope,\n createEventEnvelopeHeaders,\n createSpanEnvelopeItem,\n getSdkMetadataForEnvelopeHeader,\n} from './utils/envelope';\nimport { uuid4 } from './utils/misc';\nimport { shouldIgnoreSpan } from './utils/should-ignore-span';\nimport { showSpanDropWarning, spanToJSON } from './utils/spanUtils';\n\n/**\n * Apply SdkInfo (name, version, packages, integrations) to the corresponding event key.\n * Merge with existing data if any.\n *\n * @internal, exported only for testing\n **/\nexport function _enhanceEventWithSdkInfo(event: Event, newSdkInfo?: SdkInfo): Event {\n if (!newSdkInfo) {\n return event;\n }\n\n const eventSdkInfo = event.sdk || {};\n\n event.sdk = {\n ...eventSdkInfo,\n name: eventSdkInfo.name || newSdkInfo.name,\n version: eventSdkInfo.version || newSdkInfo.version,\n integrations: [...(event.sdk?.integrations || []), ...(newSdkInfo.integrations || [])],\n packages: [...(event.sdk?.packages || []), ...(newSdkInfo.packages || [])],\n settings:\n event.sdk?.settings || newSdkInfo.settings\n ? {\n ...event.sdk?.settings,\n ...newSdkInfo.settings,\n }\n : undefined,\n };\n\n return event;\n}\n\n/** Creates an envelope from a Session */\nexport function createSessionEnvelope(\n session: Session | SessionAggregates,\n dsn?: DsnComponents,\n metadata?: SdkMetadata,\n tunnel?: string,\n): SessionEnvelope {\n const sdkInfo = getSdkMetadataForEnvelopeHeader(metadata);\n const envelopeHeaders = {\n sent_at: new Date().toISOString(),\n ...(sdkInfo && { sdk: sdkInfo }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n };\n\n const envelopeItem: SessionItem =\n 'aggregates' in session ? [{ type: 'sessions' }, session] : [{ type: 'session' }, session.toJSON()];\n\n return createEnvelope<SessionEnvelope>(envelopeHeaders, [envelopeItem]);\n}\n\n/**\n * Create an Envelope from an event.\n */\nexport function createEventEnvelope(\n event: Event,\n dsn?: DsnComponents,\n metadata?: SdkMetadata,\n tunnel?: string,\n): EventEnvelope {\n const sdkInfo = getSdkMetadataForEnvelopeHeader(metadata);\n\n /*\n Note: Due to TS, event.type may be `replay_event`, theoretically.\n In practice, we never call `createEventEnvelope` with `replay_event` type,\n and we'd have to adjust a looot of types to make this work properly.\n We want to avoid casting this around, as that could lead to bugs (e.g. when we add another type)\n So the safe choice is to really guard against the replay_event type here.\n */\n const eventType = event.type && event.type !== 'replay_event' ? event.type : 'event';\n\n _enhanceEventWithSdkInfo(event, metadata?.sdk);\n\n const envelopeHeaders = createEventEnvelopeHeaders(event, sdkInfo, tunnel, dsn);\n\n // Prevent this data (which, if it exists, was used in earlier steps in the processing pipeline) from being sent to\n // sentry. (Note: Our use of this property comes and goes with whatever we might be debugging, whatever hacks we may\n // have temporarily added, etc. Even if we don't happen to be using it at some point in the future, let's not get rid\n // of this `delete`, lest we miss putting it back in the next time the property is in use.)\n delete event.sdkProcessingMetadata;\n\n const eventItem: EventItem = [{ type: eventType }, event];\n return createEnvelope<EventEnvelope>(envelopeHeaders, [eventItem]);\n}\n\n/**\n * Create envelope from Span item.\n *\n * Takes an optional client and runs spans through `beforeSendSpan` if available.\n */\nexport function createSpanEnvelope(spans: [SentrySpan, ...SentrySpan[]], client?: Client): SpanEnvelope {\n function dscHasRequiredProps(dsc: Partial<DynamicSamplingContext>): dsc is DynamicSamplingContext {\n return !!dsc.trace_id && !!dsc.public_key;\n }\n\n // For the moment we'll obtain the DSC from the first span in the array\n // This might need to be changed if we permit sending multiple spans from\n // different segments in one envelope\n const dsc = getDynamicSamplingContextFromSpan(spans[0]);\n\n const dsn = client?.getDsn();\n const tunnel = client?.getOptions().tunnel;\n\n const headers: SpanEnvelope[0] = {\n sent_at: new Date().toISOString(),\n ...(dscHasRequiredProps(dsc) && { trace: dsc }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n };\n\n const { beforeSendSpan, ignoreSpans } = client?.getOptions() || {};\n\n const filteredSpans = ignoreSpans?.length\n ? spans.filter(span => !shouldIgnoreSpan(spanToJSON(span), ignoreSpans))\n : spans;\n const droppedSpans = spans.length - filteredSpans.length;\n\n if (droppedSpans) {\n client?.recordDroppedEvent('before_send', 'span', droppedSpans);\n }\n\n const convertToSpanJSON = beforeSendSpan\n ? (span: SentrySpan) => {\n const spanJson = spanToJSON(span);\n const processedSpan = beforeSendSpan(spanJson);\n\n if (!processedSpan) {\n showSpanDropWarning();\n return spanJson;\n }\n\n return processedSpan;\n }\n : spanToJSON;\n\n const items: SpanItem[] = [];\n for (const span of filteredSpans) {\n const spanJson = convertToSpanJSON(span);\n if (spanJson) {\n items.push(createSpanEnvelopeItem(spanJson));\n }\n }\n\n return createEnvelope<SpanEnvelope>(headers, items);\n}\n\n/**\n * Create an Envelope from a CSP report.\n */\nexport function createRawSecurityEnvelope(\n report: LegacyCSPReport,\n dsn: DsnComponents,\n tunnel?: string,\n release?: string,\n environment?: string,\n): RawSecurityEnvelope {\n const envelopeHeaders = {\n event_id: uuid4(),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n };\n\n const eventItem: RawSecurityItem = [\n { type: 'raw_security', sentry_release: release, sentry_environment: environment },\n report,\n ];\n\n return createEnvelope<RawSecurityEnvelope>(envelopeHeaders, [eventItem]);\n}\n"],"names":["dsn","getSdkMetadataForEnvelopeHeader","dsnToString","createEnvelope","createEventEnvelopeHeaders","getDynamicSamplingContextFromSpan","shouldIgnoreSpan","spanToJSON","showSpanDropWarning","createSpanEnvelopeItem"],"mappings":";;;;;;;;AA+BA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,wBAAwB,CAAC,KAAK,EAAS,UAAU,EAAmB;AACpF,EAAE,IAAI,CAAC,UAAU,EAAE;AACnB,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,MAAM,eAAe,KAAK,CAAC,GAAA,IAAO,EAAE;;AAEtC,EAAE,KAAK,CAAC,GAAA,GAAM;AACd,IAAI,GAAG,YAAY;AACnB,IAAI,IAAI,EAAE,YAA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CAAC;AAC5C,IAAI,IAAI,QAAQ,EAAE;AAClB,MAAM,KAAK,CAAC,IAAI,CAACE,+BAAsB,CAAC,QAAQ,CAAC,CAAC;AAClD,IAAI;AACJ,EAAE;;AAEF,EAAE,OAAON,uBAAc,CAAe,OAAO,EAAE,KAAK,CAAC;AACrD;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"envelope.js","sources":["../../src/envelope.ts"],"sourcesContent":["import type { Client } from './client';\nimport { getDynamicSamplingContextFromSpan } from './tracing/dynamicSamplingContext';\nimport type { SentrySpan } from './tracing/sentrySpan';\nimport { isStreamedBeforeSendSpanCallback } from './tracing/spans/beforeSendSpan';\nimport type { LegacyCSPReport } from './types-hoist/csp';\nimport type { DsnComponents } from './types-hoist/dsn';\nimport type {\n DynamicSamplingContext,\n EventEnvelope,\n EventItem,\n RawSecurityEnvelope,\n RawSecurityItem,\n SessionEnvelope,\n SessionItem,\n SpanEnvelope,\n SpanItem,\n} from './types-hoist/envelope';\nimport type { Event } from './types-hoist/event';\nimport type { SdkInfo } from './types-hoist/sdkinfo';\nimport type { SdkMetadata } from './types-hoist/sdkmetadata';\nimport type { Session, SessionAggregates } from './types-hoist/session';\nimport { dsnToString } from './utils/dsn';\nimport {\n createEnvelope,\n createEventEnvelopeHeaders,\n createSpanEnvelopeItem,\n getSdkMetadataForEnvelopeHeader,\n} from './utils/envelope';\nimport { uuid4 } from './utils/misc';\nimport { shouldIgnoreSpan } from './utils/should-ignore-span';\nimport { showSpanDropWarning, spanToJSON } from './utils/spanUtils';\n\n/**\n * Apply SdkInfo (name, version, packages, integrations) to the corresponding event key.\n * Merge with existing data if any.\n *\n * @internal, exported only for testing\n **/\nexport function _enhanceEventWithSdkInfo(event: Event, newSdkInfo?: SdkInfo): Event {\n if (!newSdkInfo) {\n return event;\n }\n\n const eventSdkInfo = event.sdk || {};\n\n event.sdk = {\n ...eventSdkInfo,\n name: eventSdkInfo.name || newSdkInfo.name,\n version: eventSdkInfo.version || newSdkInfo.version,\n integrations: [...(event.sdk?.integrations || []), ...(newSdkInfo.integrations || [])],\n packages: [...(event.sdk?.packages || []), ...(newSdkInfo.packages || [])],\n settings:\n event.sdk?.settings || newSdkInfo.settings\n ? {\n ...event.sdk?.settings,\n ...newSdkInfo.settings,\n }\n : undefined,\n };\n\n return event;\n}\n\n/** Creates an envelope from a Session */\nexport function createSessionEnvelope(\n session: Session | SessionAggregates,\n dsn?: DsnComponents,\n metadata?: SdkMetadata,\n tunnel?: string,\n): SessionEnvelope {\n const sdkInfo = getSdkMetadataForEnvelopeHeader(metadata);\n const envelopeHeaders = {\n sent_at: new Date().toISOString(),\n ...(sdkInfo && { sdk: sdkInfo }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n };\n\n const envelopeItem: SessionItem =\n 'aggregates' in session ? [{ type: 'sessions' }, session] : [{ type: 'session' }, session.toJSON()];\n\n return createEnvelope<SessionEnvelope>(envelopeHeaders, [envelopeItem]);\n}\n\n/**\n * Create an Envelope from an event.\n */\nexport function createEventEnvelope(\n event: Event,\n dsn?: DsnComponents,\n metadata?: SdkMetadata,\n tunnel?: string,\n): EventEnvelope {\n const sdkInfo = getSdkMetadataForEnvelopeHeader(metadata);\n\n /*\n Note: Due to TS, event.type may be `replay_event`, theoretically.\n In practice, we never call `createEventEnvelope` with `replay_event` type,\n and we'd have to adjust a looot of types to make this work properly.\n We want to avoid casting this around, as that could lead to bugs (e.g. when we add another type)\n So the safe choice is to really guard against the replay_event type here.\n */\n const eventType = event.type && event.type !== 'replay_event' ? event.type : 'event';\n\n _enhanceEventWithSdkInfo(event, metadata?.sdk);\n\n const envelopeHeaders = createEventEnvelopeHeaders(event, sdkInfo, tunnel, dsn);\n\n // Prevent this data (which, if it exists, was used in earlier steps in the processing pipeline) from being sent to\n // sentry. (Note: Our use of this property comes and goes with whatever we might be debugging, whatever hacks we may\n // have temporarily added, etc. Even if we don't happen to be using it at some point in the future, let's not get rid\n // of this `delete`, lest we miss putting it back in the next time the property is in use.)\n delete event.sdkProcessingMetadata;\n\n const eventItem: EventItem = [{ type: eventType }, event];\n return createEnvelope<EventEnvelope>(envelopeHeaders, [eventItem]);\n}\n\n/**\n * Create envelope from Span item.\n *\n * Takes an optional client and runs spans through `beforeSendSpan` if available.\n */\nexport function createSpanEnvelope(spans: [SentrySpan, ...SentrySpan[]], client?: Client): SpanEnvelope {\n function dscHasRequiredProps(dsc: Partial<DynamicSamplingContext>): dsc is DynamicSamplingContext {\n return !!dsc.trace_id && !!dsc.public_key;\n }\n\n // For the moment we'll obtain the DSC from the first span in the array\n // This might need to be changed if we permit sending multiple spans from\n // different segments in one envelope\n const dsc = getDynamicSamplingContextFromSpan(spans[0]);\n\n const dsn = client?.getDsn();\n const tunnel = client?.getOptions().tunnel;\n\n const headers: SpanEnvelope[0] = {\n sent_at: new Date().toISOString(),\n ...(dscHasRequiredProps(dsc) && { trace: dsc }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n };\n\n const { beforeSendSpan, ignoreSpans } = client?.getOptions() || {};\n\n const filteredSpans = ignoreSpans?.length\n ? spans.filter(span => !shouldIgnoreSpan(spanToJSON(span), ignoreSpans))\n : spans;\n const droppedSpans = spans.length - filteredSpans.length;\n\n if (droppedSpans) {\n client?.recordDroppedEvent('before_send', 'span', droppedSpans);\n }\n\n const convertToSpanJSON = beforeSendSpan\n ? (span: SentrySpan) => {\n const spanJson = spanToJSON(span);\n const processedSpan = !isStreamedBeforeSendSpanCallback(beforeSendSpan) ? beforeSendSpan(spanJson) : spanJson;\n\n if (!processedSpan) {\n showSpanDropWarning();\n return spanJson;\n }\n\n return processedSpan;\n }\n : spanToJSON;\n\n const items: SpanItem[] = [];\n for (const span of filteredSpans) {\n const spanJson = convertToSpanJSON(span);\n if (spanJson) {\n items.push(createSpanEnvelopeItem(spanJson));\n }\n }\n\n return createEnvelope<SpanEnvelope>(headers, items);\n}\n\n/**\n * Create an Envelope from a CSP report.\n */\nexport function createRawSecurityEnvelope(\n report: LegacyCSPReport,\n dsn: DsnComponents,\n tunnel?: string,\n release?: string,\n environment?: string,\n): RawSecurityEnvelope {\n const envelopeHeaders = {\n event_id: uuid4(),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n };\n\n const eventItem: RawSecurityItem = [\n { type: 'raw_security', sentry_release: release, sentry_environment: environment },\n report,\n ];\n\n return createEnvelope<RawSecurityEnvelope>(envelopeHeaders, [eventItem]);\n}\n"],"names":["dsn","getSdkMetadataForEnvelopeHeader","dsnToString","createEnvelope","createEventEnvelopeHeaders","getDynamicSamplingContextFromSpan","beforeSendSpan","shouldIgnoreSpan","spanToJSON","isStreamedBeforeSendSpanCallback","showSpanDropWarning","createSpanEnvelopeItem"],"mappings":";;;;;;;;;AAgCA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,wBAAwB,CAAC,KAAK,EAAS,UAAU,EAAmB;AACpF,EAAE,IAAI,CAAC,UAAU,EAAE;AACnB,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,MAAM,eAAe,KAAK,CAAC,GAAA,IAAO,EAAE;;AAEtC,EAAE,KAAK,CAAC,GAAA,GAAM;AACd,IAAI,GAAG,YAAY;AACnB,IAAI,IAAI,EAAE,YAAY,CAAC,QAAQ,UAAU,CAAC,IAAI;AAC9C,IAAI,OAAO,EAAE,YAAY,CAAC,WAAW,UAAU,CAAC,OAAO;AACvD,IAAI,YAAY,EAAE,CAAC,IAAI,KAAK,CAAC,GAAG,EAAE,YAAA,IAAgB,EAAE,CAAC,EAAE,IAAI,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC;AAC1F,IAAI,QAAQ,EAAE,CAAC,IAAI,KAAK,CAAC,GAAG,EAAE,QAAA,IAAY,EAAE,CAAC,EAAE,IAAI,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC;AAC9E,IAAI,QAAQ;AACZ,MAAM,KAAK,CAAC,GAAG,EAAE,QAAA,IAAY,UAAU,CAAC;AACxC,UAAU;AACV,YAAY,GAAG,KAAK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AAQ,CAACC,iCAAgB,CAACC,oBAAU,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC;AAC3E,MAAM,KAAK;AACX,EAAE,MAAM,eAAe,KAAK,CAAC,MAAA,GAAS,aAAa,CAAC,MAAM;;AAE1D,EAAE,IAAI,YAAY,EAAE;AACpB,IAAI,MAAM,EAAE,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,CAAC;AACnE,EAAE;;AAEF,EAAE,MAAM,oBAAoBF;AAC5B,MAAM,CAAC,IAAI,KAAiB;AAC5B,QAAQ,MAAM,QAAA,GAAWE,oBAAU,CAAC,IAAI,CAAC;AACzC,QAAQ,MAAM,aAAA,GAAgB,CAACC,+CAAgC,CAACH,gBAAc,CAAA,GAAIA,gBAAc,CAAC,QAAQ,CAAA,GAAI,QAAQ;;AAErH,QAAQ,IAAI,CAAC,aAAa,EAAE;AAC5B,UAAUI,6BAAmB,EAAE;AAC/B,UAAU,OAAO,QAAQ;AACzB,QAAQ;;AAER,QAAQ,OAAO,aAAa;AAC5B,MAAM;AACN,MAAMF,oBAAU;;AAEhB,EAAE,MAAM,KAAK,GAAe,EAAE;AAC9B,EAAE,KAAK,MAAM,IAAA,IAAQ,aAAa,EAAE;AACpC,IAAI,MAAM,QAAA,GAAW,iBAAiB,CAAC,IAAI,CAAC;AAC5C,IAAI,IAAI,QAAQ,EAAE;AAClB,MAAM,KAAK,CAAC,IAAI,CAACG,+BAAsB,CAAC,QAAQ,CAAC,CAAC;AAClD,IAAI;AACJ,EAAE;;AAEF,EAAE,OAAOR,uBAAc,CAAe,OAAO,EAAE,KAAK,CAAC;AACrD;;;;;;;"}
|
package/build/cjs/index.js
CHANGED
|
@@ -11,12 +11,13 @@ const dynamicSamplingContext = require('./tracing/dynamicSamplingContext.js');
|
|
|
11
11
|
const measurement = require('./tracing/measurement.js');
|
|
12
12
|
const sampling = require('./tracing/sampling.js');
|
|
13
13
|
const logSpans = require('./tracing/logSpans.js');
|
|
14
|
+
const captureSpan = require('./tracing/spans/captureSpan.js');
|
|
14
15
|
const semanticAttributes = require('./semanticAttributes.js');
|
|
15
16
|
const envelope$1 = require('./envelope.js');
|
|
16
17
|
const _exports = require('./exports.js');
|
|
17
18
|
const currentScopes = require('./currentScopes.js');
|
|
18
19
|
const defaultScopes = require('./defaultScopes.js');
|
|
19
|
-
const index$
|
|
20
|
+
const index$7 = require('./asyncContext/index.js');
|
|
20
21
|
const carrier = require('./carrier.js');
|
|
21
22
|
const session = require('./session.js');
|
|
22
23
|
const scope = require('./scope.js');
|
|
@@ -35,6 +36,7 @@ const scopeData = require('./utils/scopeData.js');
|
|
|
35
36
|
const prepareEvent = require('./utils/prepareEvent.js');
|
|
36
37
|
const checkin = require('./checkin.js');
|
|
37
38
|
const hasSpansEnabled = require('./utils/hasSpansEnabled.js');
|
|
39
|
+
const beforeSendSpan = require('./tracing/spans/beforeSendSpan.js');
|
|
38
40
|
const isSentryRequestUrl = require('./utils/isSentryRequestUrl.js');
|
|
39
41
|
const handleCallbackErrors = require('./utils/handleCallbackErrors.js');
|
|
40
42
|
const parameterize = require('./utils/parameterize.js');
|
|
@@ -48,6 +50,7 @@ const traceData = require('./utils/traceData.js');
|
|
|
48
50
|
const tracePropagationTargets = require('./utils/tracePropagationTargets.js');
|
|
49
51
|
const meta = require('./utils/meta.js');
|
|
50
52
|
const debounce = require('./utils/debounce.js');
|
|
53
|
+
const shouldIgnoreSpan = require('./utils/should-ignore-span.js');
|
|
51
54
|
const request = require('./utils/request.js');
|
|
52
55
|
const constants$1 = require('./constants.js');
|
|
53
56
|
const breadcrumbs = require('./breadcrumbs.js');
|
|
@@ -57,6 +60,7 @@ const linkederrors = require('./integrations/linkederrors.js');
|
|
|
57
60
|
const moduleMetadata = require('./integrations/moduleMetadata.js');
|
|
58
61
|
const requestdata = require('./integrations/requestdata.js');
|
|
59
62
|
const captureconsole = require('./integrations/captureconsole.js');
|
|
63
|
+
const index$2 = require('./integrations/express/index.js');
|
|
60
64
|
const dedupe = require('./integrations/dedupe.js');
|
|
61
65
|
const extraerrordata = require('./integrations/extraerrordata.js');
|
|
62
66
|
const rewriteframes = require('./integrations/rewriteframes.js');
|
|
@@ -71,7 +75,7 @@ const conversationId = require('./integrations/conversationId.js');
|
|
|
71
75
|
const profiling = require('./profiling.js');
|
|
72
76
|
const fetch$1 = require('./fetch.js');
|
|
73
77
|
const trpc = require('./trpc.js');
|
|
74
|
-
const index$
|
|
78
|
+
const index$8 = require('./integrations/mcp-server/index.js');
|
|
75
79
|
const feedback = require('./feedback.js');
|
|
76
80
|
const internal = require('./logs/internal.js');
|
|
77
81
|
const publicApi = require('./logs/public-api.js');
|
|
@@ -82,16 +86,19 @@ const consola = require('./integrations/consola.js');
|
|
|
82
86
|
const index = require('./tracing/vercel-ai/index.js');
|
|
83
87
|
const utils = require('./tracing/vercel-ai/utils.js');
|
|
84
88
|
const constants$6 = require('./tracing/vercel-ai/constants.js');
|
|
85
|
-
const index$
|
|
89
|
+
const index$6 = require('./tracing/openai/index.js');
|
|
86
90
|
const constants$5 = require('./tracing/openai/constants.js');
|
|
87
|
-
const index$
|
|
91
|
+
const index$3 = require('./tracing/anthropic-ai/index.js');
|
|
88
92
|
const constants = require('./tracing/anthropic-ai/constants.js');
|
|
89
|
-
const index$
|
|
93
|
+
const index$4 = require('./tracing/google-genai/index.js');
|
|
90
94
|
const constants$2 = require('./tracing/google-genai/constants.js');
|
|
91
95
|
const index$1 = require('./tracing/langchain/index.js');
|
|
92
96
|
const constants$3 = require('./tracing/langchain/constants.js');
|
|
93
|
-
const index$
|
|
97
|
+
const index$5 = require('./tracing/langgraph/index.js');
|
|
94
98
|
const constants$4 = require('./tracing/langgraph/constants.js');
|
|
99
|
+
const spanBuffer = require('./tracing/spans/spanBuffer.js');
|
|
100
|
+
const hasSpanStreamingEnabled = require('./tracing/spans/hasSpanStreamingEnabled.js');
|
|
101
|
+
const spanStreaming = require('./integrations/spanStreaming.js');
|
|
95
102
|
const featureFlags = require('./utils/featureFlags.js');
|
|
96
103
|
const aggregateErrors = require('./utils/aggregate-errors.js');
|
|
97
104
|
const breadcrumbLogLevel = require('./utils/breadcrumb-log-level.js');
|
|
@@ -139,6 +146,8 @@ const debugIds = require('./utils/debug-ids.js');
|
|
|
139
146
|
const metadata = require('./metadata.js');
|
|
140
147
|
const escapeStringForRegex = require('./vendor/escapeStringForRegex.js');
|
|
141
148
|
const randomSafeContext = require('./utils/randomSafeContext.js');
|
|
149
|
+
const timer = require('./utils/timer.js');
|
|
150
|
+
const embeddings = require('./tracing/langchain/embeddings.js');
|
|
142
151
|
|
|
143
152
|
|
|
144
153
|
|
|
@@ -170,6 +179,7 @@ exports.timedEventsToMeasurements = measurement.timedEventsToMeasurements;
|
|
|
170
179
|
exports.sampleSpan = sampling.sampleSpan;
|
|
171
180
|
exports.logSpanEnd = logSpans.logSpanEnd;
|
|
172
181
|
exports.logSpanStart = logSpans.logSpanStart;
|
|
182
|
+
exports.captureSpan = captureSpan.captureSpan;
|
|
173
183
|
exports.GEN_AI_CONVERSATION_ID_ATTRIBUTE = semanticAttributes.GEN_AI_CONVERSATION_ID_ATTRIBUTE;
|
|
174
184
|
exports.SEMANTIC_ATTRIBUTE_CACHE_HIT = semanticAttributes.SEMANTIC_ATTRIBUTE_CACHE_HIT;
|
|
175
185
|
exports.SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = semanticAttributes.SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE;
|
|
@@ -178,15 +188,25 @@ exports.SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = semanticAttributes.SEMANTIC_ATTRIBUT
|
|
|
178
188
|
exports.SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = semanticAttributes.SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD;
|
|
179
189
|
exports.SEMANTIC_ATTRIBUTE_PROFILE_ID = semanticAttributes.SEMANTIC_ATTRIBUTE_PROFILE_ID;
|
|
180
190
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME;
|
|
191
|
+
exports.SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT;
|
|
181
192
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON;
|
|
182
193
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT;
|
|
183
194
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE;
|
|
184
195
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_OP = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_OP;
|
|
185
196
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN;
|
|
186
197
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE;
|
|
198
|
+
exports.SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_RELEASE;
|
|
187
199
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE;
|
|
200
|
+
exports.SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME;
|
|
201
|
+
exports.SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION;
|
|
202
|
+
exports.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID;
|
|
203
|
+
exports.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME;
|
|
188
204
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE;
|
|
189
205
|
exports.SEMANTIC_ATTRIBUTE_URL_FULL = semanticAttributes.SEMANTIC_ATTRIBUTE_URL_FULL;
|
|
206
|
+
exports.SEMANTIC_ATTRIBUTE_USER_EMAIL = semanticAttributes.SEMANTIC_ATTRIBUTE_USER_EMAIL;
|
|
207
|
+
exports.SEMANTIC_ATTRIBUTE_USER_ID = semanticAttributes.SEMANTIC_ATTRIBUTE_USER_ID;
|
|
208
|
+
exports.SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = semanticAttributes.SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS;
|
|
209
|
+
exports.SEMANTIC_ATTRIBUTE_USER_USERNAME = semanticAttributes.SEMANTIC_ATTRIBUTE_USER_USERNAME;
|
|
190
210
|
exports.SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = semanticAttributes.SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE;
|
|
191
211
|
exports.createEventEnvelope = envelope$1.createEventEnvelope;
|
|
192
212
|
exports.createSessionEnvelope = envelope$1.createSessionEnvelope;
|
|
@@ -214,14 +234,17 @@ exports.startSession = _exports.startSession;
|
|
|
214
234
|
exports.withMonitor = _exports.withMonitor;
|
|
215
235
|
exports.getClient = currentScopes.getClient;
|
|
216
236
|
exports.getCurrentScope = currentScopes.getCurrentScope;
|
|
237
|
+
exports.getExternalPropagationContext = currentScopes.getExternalPropagationContext;
|
|
217
238
|
exports.getGlobalScope = currentScopes.getGlobalScope;
|
|
218
239
|
exports.getIsolationScope = currentScopes.getIsolationScope;
|
|
219
240
|
exports.getTraceContextFromScope = currentScopes.getTraceContextFromScope;
|
|
241
|
+
exports.hasExternalPropagationContext = currentScopes.hasExternalPropagationContext;
|
|
242
|
+
exports.registerExternalPropagationContext = currentScopes.registerExternalPropagationContext;
|
|
220
243
|
exports.withIsolationScope = currentScopes.withIsolationScope;
|
|
221
244
|
exports.withScope = currentScopes.withScope;
|
|
222
245
|
exports.getDefaultCurrentScope = defaultScopes.getDefaultCurrentScope;
|
|
223
246
|
exports.getDefaultIsolationScope = defaultScopes.getDefaultIsolationScope;
|
|
224
|
-
exports.setAsyncContextStrategy = index$
|
|
247
|
+
exports.setAsyncContextStrategy = index$7.setAsyncContextStrategy;
|
|
225
248
|
exports.getGlobalSingleton = carrier.getGlobalSingleton;
|
|
226
249
|
exports.getMainCarrier = carrier.getMainCarrier;
|
|
227
250
|
exports.closeSession = session.closeSession;
|
|
@@ -229,6 +252,7 @@ exports.makeSession = session.makeSession;
|
|
|
229
252
|
exports.updateSession = session.updateSession;
|
|
230
253
|
exports.Scope = scope.Scope;
|
|
231
254
|
exports.notifyEventProcessors = eventProcessors.notifyEventProcessors;
|
|
255
|
+
exports.SENTRY_API_VERSION = api.SENTRY_API_VERSION;
|
|
232
256
|
exports.getEnvelopeEndpointWithUrlEncodedAuth = api.getEnvelopeEndpointWithUrlEncodedAuth;
|
|
233
257
|
exports.getReportDialogEndpoint = api.getReportDialogEndpoint;
|
|
234
258
|
exports.Client = client.Client;
|
|
@@ -253,6 +277,8 @@ exports.mergeScopeData = scopeData.mergeScopeData;
|
|
|
253
277
|
exports.prepareEvent = prepareEvent.prepareEvent;
|
|
254
278
|
exports.createCheckInEnvelope = checkin.createCheckInEnvelope;
|
|
255
279
|
exports.hasSpansEnabled = hasSpansEnabled.hasSpansEnabled;
|
|
280
|
+
exports.isStreamedBeforeSendSpanCallback = beforeSendSpan.isStreamedBeforeSendSpanCallback;
|
|
281
|
+
exports.withStreamedSpan = beforeSendSpan.withStreamedSpan;
|
|
256
282
|
exports.isSentryRequestUrl = isSentryRequestUrl.isSentryRequestUrl;
|
|
257
283
|
exports.handleCallbackErrors = handleCallbackErrors.handleCallbackErrors;
|
|
258
284
|
exports.fmt = parameterize.fmt;
|
|
@@ -260,6 +286,7 @@ exports.parameterize = parameterize.parameterize;
|
|
|
260
286
|
exports.handleTunnelRequest = tunnel.handleTunnelRequest;
|
|
261
287
|
exports.addAutoIpAddressToSession = ipAddress.addAutoIpAddressToSession;
|
|
262
288
|
exports.addAutoIpAddressToUser = ipAddress.addAutoIpAddressToUser;
|
|
289
|
+
exports.INTERNAL_getSegmentSpan = spanUtils.INTERNAL_getSegmentSpan;
|
|
263
290
|
exports.addChildSpanToSpan = spanUtils.addChildSpanToSpan;
|
|
264
291
|
exports.convertSpanLinksForEnvelope = spanUtils.convertSpanLinksForEnvelope;
|
|
265
292
|
exports.getActiveSpan = spanUtils.getActiveSpan;
|
|
@@ -269,6 +296,7 @@ exports.getStatusMessage = spanUtils.getStatusMessage;
|
|
|
269
296
|
exports.spanIsSampled = spanUtils.spanIsSampled;
|
|
270
297
|
exports.spanTimeInputToSeconds = spanUtils.spanTimeInputToSeconds;
|
|
271
298
|
exports.spanToJSON = spanUtils.spanToJSON;
|
|
299
|
+
exports.spanToStreamedSpanJSON = spanUtils.spanToStreamedSpanJSON;
|
|
272
300
|
exports.spanToTraceContext = spanUtils.spanToTraceContext;
|
|
273
301
|
exports.spanToTraceHeader = spanUtils.spanToTraceHeader;
|
|
274
302
|
exports.updateSpanName = spanUtils.updateSpanName;
|
|
@@ -279,6 +307,7 @@ exports.getTraceData = traceData.getTraceData;
|
|
|
279
307
|
exports.shouldPropagateTraceForUrl = tracePropagationTargets.shouldPropagateTraceForUrl;
|
|
280
308
|
exports.getTraceMetaTags = meta.getTraceMetaTags;
|
|
281
309
|
exports.debounce = debounce.debounce;
|
|
310
|
+
exports.shouldIgnoreSpan = shouldIgnoreSpan.shouldIgnoreSpan;
|
|
282
311
|
exports.extractQueryParamsFromUrl = request.extractQueryParamsFromUrl;
|
|
283
312
|
exports.headersToDict = request.headersToDict;
|
|
284
313
|
exports.httpHeadersToSpanAttributes = request.httpHeadersToSpanAttributes;
|
|
@@ -295,6 +324,9 @@ exports.linkedErrorsIntegration = linkederrors.linkedErrorsIntegration;
|
|
|
295
324
|
exports.moduleMetadataIntegration = moduleMetadata.moduleMetadataIntegration;
|
|
296
325
|
exports.requestDataIntegration = requestdata.requestDataIntegration;
|
|
297
326
|
exports.captureConsoleIntegration = captureconsole.captureConsoleIntegration;
|
|
327
|
+
exports.expressErrorHandler = index$2.expressErrorHandler;
|
|
328
|
+
exports.patchExpressModule = index$2.patchExpressModule;
|
|
329
|
+
exports.setupExpressErrorHandler = index$2.setupExpressErrorHandler;
|
|
298
330
|
exports.dedupeIntegration = dedupe.dedupeIntegration;
|
|
299
331
|
exports.extraErrorDataIntegration = extraerrordata.extraErrorDataIntegration;
|
|
300
332
|
exports.rewriteFramesIntegration = rewriteframes.rewriteFramesIntegration;
|
|
@@ -310,7 +342,7 @@ exports.conversationIdIntegration = conversationId.conversationIdIntegration;
|
|
|
310
342
|
exports.profiler = profiling.profiler;
|
|
311
343
|
exports.instrumentFetchRequest = fetch$1.instrumentFetchRequest;
|
|
312
344
|
exports.trpcMiddleware = trpc.trpcMiddleware;
|
|
313
|
-
exports.wrapMcpServerWithSentry = index$
|
|
345
|
+
exports.wrapMcpServerWithSentry = index$8.wrapMcpServerWithSentry;
|
|
314
346
|
exports.captureFeedback = feedback.captureFeedback;
|
|
315
347
|
exports._INTERNAL_captureLog = internal._INTERNAL_captureLog;
|
|
316
348
|
exports._INTERNAL_captureSerializedLog = internal._INTERNAL_captureSerializedLog;
|
|
@@ -326,17 +358,20 @@ exports.addVercelAiProcessors = index.addVercelAiProcessors;
|
|
|
326
358
|
exports._INTERNAL_cleanupToolCallSpanContext = utils._INTERNAL_cleanupToolCallSpanContext;
|
|
327
359
|
exports._INTERNAL_getSpanContextForToolCallId = utils._INTERNAL_getSpanContextForToolCallId;
|
|
328
360
|
exports._INTERNAL_toolCallSpanContextMap = constants$6.toolCallSpanContextMap;
|
|
329
|
-
exports.instrumentOpenAiClient = index$
|
|
361
|
+
exports.instrumentOpenAiClient = index$6.instrumentOpenAiClient;
|
|
330
362
|
exports.OPENAI_INTEGRATION_NAME = constants$5.OPENAI_INTEGRATION_NAME;
|
|
331
|
-
exports.instrumentAnthropicAiClient = index$
|
|
363
|
+
exports.instrumentAnthropicAiClient = index$3.instrumentAnthropicAiClient;
|
|
332
364
|
exports.ANTHROPIC_AI_INTEGRATION_NAME = constants.ANTHROPIC_AI_INTEGRATION_NAME;
|
|
333
|
-
exports.instrumentGoogleGenAIClient = index$
|
|
365
|
+
exports.instrumentGoogleGenAIClient = index$4.instrumentGoogleGenAIClient;
|
|
334
366
|
exports.GOOGLE_GENAI_INTEGRATION_NAME = constants$2.GOOGLE_GENAI_INTEGRATION_NAME;
|
|
335
367
|
exports.createLangChainCallbackHandler = index$1.createLangChainCallbackHandler;
|
|
336
368
|
exports.LANGCHAIN_INTEGRATION_NAME = constants$3.LANGCHAIN_INTEGRATION_NAME;
|
|
337
|
-
exports.instrumentLangGraph = index$
|
|
338
|
-
exports.instrumentStateGraphCompile = index$
|
|
369
|
+
exports.instrumentLangGraph = index$5.instrumentLangGraph;
|
|
370
|
+
exports.instrumentStateGraphCompile = index$5.instrumentStateGraphCompile;
|
|
339
371
|
exports.LANGGRAPH_INTEGRATION_NAME = constants$4.LANGGRAPH_INTEGRATION_NAME;
|
|
372
|
+
exports.SpanBuffer = spanBuffer.SpanBuffer;
|
|
373
|
+
exports.hasSpanStreamingEnabled = hasSpanStreamingEnabled.hasSpanStreamingEnabled;
|
|
374
|
+
exports.spanStreamingIntegration = spanStreaming.spanStreamingIntegration;
|
|
340
375
|
exports._INTERNAL_FLAG_BUFFER_SIZE = featureFlags._INTERNAL_FLAG_BUFFER_SIZE;
|
|
341
376
|
exports._INTERNAL_MAX_FLAGS_PER_SPAN = featureFlags._INTERNAL_MAX_FLAGS_PER_SPAN;
|
|
342
377
|
exports._INTERNAL_addFeatureFlagToActiveSpan = featureFlags._INTERNAL_addFeatureFlagToActiveSpan;
|
|
@@ -502,4 +537,6 @@ exports.escapeStringForRegex = escapeStringForRegex.escapeStringForRegex;
|
|
|
502
537
|
exports._INTERNAL_safeDateNow = randomSafeContext.safeDateNow;
|
|
503
538
|
exports._INTERNAL_safeMathRandom = randomSafeContext.safeMathRandom;
|
|
504
539
|
exports._INTERNAL_withRandomSafeContext = randomSafeContext.withRandomSafeContext;
|
|
540
|
+
exports._INTERNAL_safeUnref = timer.safeUnref;
|
|
541
|
+
exports.instrumentLangChainEmbeddings = embeddings.instrumentLangChainEmbeddings;
|
|
505
542
|
//# sourceMappingURL=index.js.map
|
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/cjs/integration.js
CHANGED
|
@@ -69,6 +69,12 @@ function getIntegrationsToSetup(
|
|
|
69
69
|
function setupIntegrations(client, integrations) {
|
|
70
70
|
const integrationIndex = {};
|
|
71
71
|
|
|
72
|
+
integrations.forEach((integration) => {
|
|
73
|
+
if (integration?.beforeSetup) {
|
|
74
|
+
integration.beforeSetup(client);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
72
78
|
integrations.forEach((integration) => {
|
|
73
79
|
// guard against empty provided integrations
|
|
74
80
|
if (integration) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.js","sources":["../../src/integration.ts"],"sourcesContent":["import type { Client } from './client';\nimport { getClient } from './currentScopes';\nimport { DEBUG_BUILD } from './debug-build';\nimport type { Event, EventHint } from './types-hoist/event';\nimport type { Integration, IntegrationFn } from './types-hoist/integration';\nimport type { CoreOptions } from './types-hoist/options';\nimport { debug } from './utils/debug-logger';\n\nexport const installedIntegrations: string[] = [];\n\n/** Map of integrations assigned to a client */\nexport type IntegrationIndex = {\n [key: string]: Integration;\n};\n\ntype IntegrationWithDefaultInstance = Integration & { isDefaultInstance?: true };\n\n/**\n * Remove duplicates from the given array, preferring the last instance of any duplicate. Not guaranteed to\n * preserve the order of integrations in the array.\n *\n * @private\n */\nfunction filterDuplicates(integrations: Integration[]): Integration[] {\n const integrationsByName: { [key: string]: Integration } = {};\n\n integrations.forEach((currentInstance: IntegrationWithDefaultInstance) => {\n const { name } = currentInstance;\n\n const existingInstance: IntegrationWithDefaultInstance | undefined = integrationsByName[name];\n\n // We want integrations later in the array to overwrite earlier ones of the same type, except that we never want a\n // default instance to overwrite an existing user instance\n if (existingInstance && !existingInstance.isDefaultInstance && currentInstance.isDefaultInstance) {\n return;\n }\n\n integrationsByName[name] = currentInstance;\n });\n\n return Object.values(integrationsByName);\n}\n\n/** Gets integrations to install */\nexport function getIntegrationsToSetup(\n options: Pick<CoreOptions, 'defaultIntegrations' | 'integrations'>,\n): Integration[] {\n const defaultIntegrations = options.defaultIntegrations || [];\n const userIntegrations = options.integrations;\n\n // We flag default instances, so that later we can tell them apart from any user-created instances of the same class\n defaultIntegrations.forEach((integration: IntegrationWithDefaultInstance) => {\n integration.isDefaultInstance = true;\n });\n\n let integrations: Integration[];\n\n if (Array.isArray(userIntegrations)) {\n integrations = [...defaultIntegrations, ...userIntegrations];\n } else if (typeof userIntegrations === 'function') {\n const resolvedUserIntegrations = userIntegrations(defaultIntegrations);\n integrations = Array.isArray(resolvedUserIntegrations) ? resolvedUserIntegrations : [resolvedUserIntegrations];\n } else {\n integrations = defaultIntegrations;\n }\n\n return filterDuplicates(integrations);\n}\n\n/**\n * Given a list of integration instances this installs them all. When `withDefaults` is set to `true` then all default\n * integrations are added unless they were already provided before.\n * @param integrations array of integration instances\n * @param withDefault should enable default integrations\n */\nexport function setupIntegrations(client: Client, integrations: Integration[]): IntegrationIndex {\n const integrationIndex: IntegrationIndex = {};\n\n integrations.forEach((integration: Integration | undefined) => {\n // guard against empty provided integrations\n if (integration) {\n setupIntegration(client, integration, integrationIndex);\n }\n });\n\n return integrationIndex;\n}\n\n/**\n * Execute the `afterAllSetup` hooks of the given integrations.\n */\nexport function afterSetupIntegrations(client: Client, integrations: Integration[]): void {\n for (const integration of integrations) {\n // guard against empty provided integrations\n if (integration?.afterAllSetup) {\n integration.afterAllSetup(client);\n }\n }\n}\n\n/** Setup a single integration. */\nexport function setupIntegration(client: Client, integration: Integration, integrationIndex: IntegrationIndex): void {\n if (integrationIndex[integration.name]) {\n DEBUG_BUILD && debug.log(`Integration skipped because it was already installed: ${integration.name}`);\n return;\n }\n integrationIndex[integration.name] = integration;\n\n // `setupOnce` is only called the first time\n if (!installedIntegrations.includes(integration.name) && typeof integration.setupOnce === 'function') {\n integration.setupOnce();\n installedIntegrations.push(integration.name);\n }\n\n // `setup` is run for each client\n if (integration.setup && typeof integration.setup === 'function') {\n integration.setup(client);\n }\n\n if (typeof integration.preprocessEvent === 'function') {\n const callback = integration.preprocessEvent.bind(integration) as typeof integration.preprocessEvent;\n client.on('preprocessEvent', (event, hint) => callback(event, hint, client));\n }\n\n if (typeof integration.processEvent === 'function') {\n const callback = integration.processEvent.bind(integration) as typeof integration.processEvent;\n\n const processor = Object.assign((event: Event, hint: EventHint) => callback(event, hint, client), {\n id: integration.name,\n });\n\n client.addEventProcessor(processor);\n }\n\n DEBUG_BUILD && debug.log(`Integration installed: ${integration.name}`);\n}\n\n/** Add an integration to the current scope's client. */\nexport function addIntegration(integration: Integration): void {\n const client = getClient();\n\n if (!client) {\n DEBUG_BUILD && debug.warn(`Cannot add integration \"${integration.name}\" because no SDK Client is available.`);\n return;\n }\n\n client.addIntegration(integration);\n}\n\n/**\n * Define an integration function that can be used to create an integration instance.\n * Note that this by design hides the implementation details of the integration, as they are considered internal.\n */\nexport function defineIntegration<Fn extends IntegrationFn>(fn: Fn): (...args: Parameters<Fn>) => Integration {\n return fn;\n}\n"],"names":["DEBUG_BUILD","debug","getClient"],"mappings":";;;;;;AAQO,MAAM,qBAAqB,GAAa;;AAE/C;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,gBAAgB,CAAC,YAAY,EAAgC;AACtE,EAAE,MAAM,kBAAkB,GAAmC,EAAE;;AAE/D,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,eAAe,KAAqC;AAC5E,IAAI,MAAM,EAAE,IAAA,EAAK,GAAI,eAAe;;AAEpC,IAAI,MAAM,gBAAgB,GAA+C,kBAAkB,CAAC,IAAI,CAAC;;AAEjG;AACA;AACA,IAAI,IAAI,gBAAA,IAAoB,CAAC,gBAAgB,CAAC,iBAAA,IAAqB,eAAe,CAAC,iBAAiB,EAAE;AACtG,MAAM;AACN,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AA,KAAA,QAAA,CAAA,KAAA,EAAA,IAAA,EAAA,MAAA,CAAA,CAAA;AACA,EAAA;;AAEA,EAAA,IAAA,OAAA,WAAA,CAAA,YAAA,KAAA,UAAA,EAAA;AACA,IAAA,MAAA,QAAA,GAAA,WAAA,CAAA,YAAA,CAAA,IAAA,CAAA,WAAA,CAAA;;AAEA,IAAA,MAAA,SAAA,GAAA,MAAA,CAAA,MAAA,CAAA,CAAA,KAAA,EAAA,IAAA,KAAA,QAAA,CAAA,KAAA,EAAA,IAAA,EAAA,MAAA,CAAA,EAAA;AACA,MAAA,EAAA,EAAA,WAAA,CAAA,IAAA;AACA,KAAA,CAAA;;AAEA,IAAA,MAAA,CAAA,iBAAA,CAAA,SAAA,CAAA;AACA,EAAA;;AAEA,EAAAD,sBAAA,IAAAC,iBAAA,CAAA,GAAA,CAAA,CAAA,uBAAA,EAAA,WAAA,CAAA,IAAA,CAAA,CAAA,CAAA;AACA;;AAEA;AACA,SAAA,cAAA,CAAA,WAAA,EAAA;AACA,EAAA,MAAA,MAAA,GAAAC,uBAAA,EAAA;;AAEA,EAAA,IAAA,CAAA,MAAA,EAAA;AACA,IAAAF,sBAAA,IAAAC,iBAAA,CAAA,IAAA,CAAA,CAAA,wBAAA,EAAA,WAAA,CAAA,IAAA,CAAA,qCAAA,CAAA,CAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,MAAA,CAAA,cAAA,CAAA,WAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAA,iBAAA,CAAA,EAAA,EAAA;AACA,EAAA,OAAA,EAAA;AACA;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"integration.js","sources":["../../src/integration.ts"],"sourcesContent":["import type { Client } from './client';\nimport { getClient } from './currentScopes';\nimport { DEBUG_BUILD } from './debug-build';\nimport type { Event, EventHint } from './types-hoist/event';\nimport type { Integration, IntegrationFn } from './types-hoist/integration';\nimport type { CoreOptions } from './types-hoist/options';\nimport { debug } from './utils/debug-logger';\n\nexport const installedIntegrations: string[] = [];\n\n/** Map of integrations assigned to a client */\nexport type IntegrationIndex = {\n [key: string]: Integration;\n};\n\ntype IntegrationWithDefaultInstance = Integration & { isDefaultInstance?: true };\n\n/**\n * Remove duplicates from the given array, preferring the last instance of any duplicate. Not guaranteed to\n * preserve the order of integrations in the array.\n *\n * @private\n */\nfunction filterDuplicates(integrations: Integration[]): Integration[] {\n const integrationsByName: { [key: string]: Integration } = {};\n\n integrations.forEach((currentInstance: IntegrationWithDefaultInstance) => {\n const { name } = currentInstance;\n\n const existingInstance: IntegrationWithDefaultInstance | undefined = integrationsByName[name];\n\n // We want integrations later in the array to overwrite earlier ones of the same type, except that we never want a\n // default instance to overwrite an existing user instance\n if (existingInstance && !existingInstance.isDefaultInstance && currentInstance.isDefaultInstance) {\n return;\n }\n\n integrationsByName[name] = currentInstance;\n });\n\n return Object.values(integrationsByName);\n}\n\n/** Gets integrations to install */\nexport function getIntegrationsToSetup(\n options: Pick<CoreOptions, 'defaultIntegrations' | 'integrations'>,\n): Integration[] {\n const defaultIntegrations = options.defaultIntegrations || [];\n const userIntegrations = options.integrations;\n\n // We flag default instances, so that later we can tell them apart from any user-created instances of the same class\n defaultIntegrations.forEach((integration: IntegrationWithDefaultInstance) => {\n integration.isDefaultInstance = true;\n });\n\n let integrations: Integration[];\n\n if (Array.isArray(userIntegrations)) {\n integrations = [...defaultIntegrations, ...userIntegrations];\n } else if (typeof userIntegrations === 'function') {\n const resolvedUserIntegrations = userIntegrations(defaultIntegrations);\n integrations = Array.isArray(resolvedUserIntegrations) ? resolvedUserIntegrations : [resolvedUserIntegrations];\n } else {\n integrations = defaultIntegrations;\n }\n\n return filterDuplicates(integrations);\n}\n\n/**\n * Given a list of integration instances this installs them all. When `withDefaults` is set to `true` then all default\n * integrations are added unless they were already provided before.\n * @param integrations array of integration instances\n * @param withDefault should enable default integrations\n */\nexport function setupIntegrations(client: Client, integrations: Integration[]): IntegrationIndex {\n const integrationIndex: IntegrationIndex = {};\n\n integrations.forEach((integration: Integration | undefined) => {\n if (integration?.beforeSetup) {\n integration.beforeSetup(client);\n }\n });\n\n integrations.forEach((integration: Integration | undefined) => {\n // guard against empty provided integrations\n if (integration) {\n setupIntegration(client, integration, integrationIndex);\n }\n });\n\n return integrationIndex;\n}\n\n/**\n * Execute the `afterAllSetup` hooks of the given integrations.\n */\nexport function afterSetupIntegrations(client: Client, integrations: Integration[]): void {\n for (const integration of integrations) {\n // guard against empty provided integrations\n if (integration?.afterAllSetup) {\n integration.afterAllSetup(client);\n }\n }\n}\n\n/** Setup a single integration. */\nexport function setupIntegration(client: Client, integration: Integration, integrationIndex: IntegrationIndex): void {\n if (integrationIndex[integration.name]) {\n DEBUG_BUILD && debug.log(`Integration skipped because it was already installed: ${integration.name}`);\n return;\n }\n integrationIndex[integration.name] = integration;\n\n // `setupOnce` is only called the first time\n if (!installedIntegrations.includes(integration.name) && typeof integration.setupOnce === 'function') {\n integration.setupOnce();\n installedIntegrations.push(integration.name);\n }\n\n // `setup` is run for each client\n if (integration.setup && typeof integration.setup === 'function') {\n integration.setup(client);\n }\n\n if (typeof integration.preprocessEvent === 'function') {\n const callback = integration.preprocessEvent.bind(integration) as typeof integration.preprocessEvent;\n client.on('preprocessEvent', (event, hint) => callback(event, hint, client));\n }\n\n if (typeof integration.processEvent === 'function') {\n const callback = integration.processEvent.bind(integration) as typeof integration.processEvent;\n\n const processor = Object.assign((event: Event, hint: EventHint) => callback(event, hint, client), {\n id: integration.name,\n });\n\n client.addEventProcessor(processor);\n }\n\n DEBUG_BUILD && debug.log(`Integration installed: ${integration.name}`);\n}\n\n/** Add an integration to the current scope's client. */\nexport function addIntegration(integration: Integration): void {\n const client = getClient();\n\n if (!client) {\n DEBUG_BUILD && debug.warn(`Cannot add integration \"${integration.name}\" because no SDK Client is available.`);\n return;\n }\n\n client.addIntegration(integration);\n}\n\n/**\n * Define an integration function that can be used to create an integration instance.\n * Note that this by design hides the implementation details of the integration, as they are considered internal.\n */\nexport function define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iBAAA,CAAA,GAAA,CAAA,CAAA,uBAAA,EAAA,WAAA,CAAA,IAAA,CAAA,CAAA,CAAA;AACA;;AAEA;AACA,SAAA,cAAA,CAAA,WAAA,EAAA;AACA,EAAA,MAAA,MAAA,GAAAC,uBAAA,EAAA;;AAEA,EAAA,IAAA,CAAA,MAAA,EAAA;AACA,IAAAF,sBAAA,IAAAC,iBAAA,CAAA,IAAA,CAAA,CAAA,wBAAA,EAAA,WAAA,CAAA,IAAA,CAAA,qCAAA,CAAA,CAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,MAAA,CAAA,cAAA,CAAA,WAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAA,iBAAA,CAAA,EAAA,EAAA;AACA,EAAA,OAAA,EAAA;AACA;;;;;;;;;;"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const debugLogger = require('../../utils/debug-logger.js');
|
|
4
|
+
const _exports = require('../../exports.js');
|
|
5
|
+
const debugBuild = require('../../debug-build.js');
|
|
6
|
+
const utils = require('./utils.js');
|
|
7
|
+
const object = require('../../utils/object.js');
|
|
8
|
+
const patchLayer = require('./patch-layer.js');
|
|
9
|
+
const setSdkProcessingMetadata = require('./set-sdk-processing-metadata.js');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Platform-portable Express tracing integration.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*
|
|
16
|
+
* This Sentry integration is a derivative work based on the OpenTelemetry
|
|
17
|
+
* Express instrumentation.
|
|
18
|
+
*
|
|
19
|
+
* <https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-express>
|
|
20
|
+
*
|
|
21
|
+
* Extended under the terms of the Apache 2.0 license linked below:
|
|
22
|
+
*
|
|
23
|
+
* ----
|
|
24
|
+
*
|
|
25
|
+
* Copyright The OpenTelemetry Authors
|
|
26
|
+
*
|
|
27
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
28
|
+
* you may not use this file except in compliance with the License.
|
|
29
|
+
* You may obtain a copy of the License at
|
|
30
|
+
*
|
|
31
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
32
|
+
*
|
|
33
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
34
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
35
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
36
|
+
* See the License for the specific language governing permissions and
|
|
37
|
+
* limitations under the License.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const getExpressExport = (express) =>
|
|
42
|
+
utils.hasDefaultProp(express) ? express.default : (express );
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* This is a portable instrumentatiton function that works in any environment
|
|
46
|
+
* where Express can be loaded, without depending on OpenTelemetry.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```javascript
|
|
50
|
+
* import express from 'express';
|
|
51
|
+
* import * as Sentry from '@sentry/deno'; // or any SDK that extends core
|
|
52
|
+
*
|
|
53
|
+
* Sentry.patchExpressModule({ express })
|
|
54
|
+
*/
|
|
55
|
+
const patchExpressModule = (options) => {
|
|
56
|
+
// pass in the require() or import() result of express
|
|
57
|
+
const express = getExpressExport(options.express);
|
|
58
|
+
const routerProto = utils.isExpressWithRouterPrototype(express)
|
|
59
|
+
? express.Router.prototype // Express v5
|
|
60
|
+
: utils.isExpressWithoutRouterPrototype(express)
|
|
61
|
+
? express.Router // Express v4
|
|
62
|
+
: undefined;
|
|
63
|
+
|
|
64
|
+
if (!routerProto) {
|
|
65
|
+
throw new TypeError('no valid Express route function to instrument');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// oxlint-disable-next-line @typescript-eslint/unbound-method
|
|
69
|
+
const originalRouteMethod = routerProto.route;
|
|
70
|
+
try {
|
|
71
|
+
object.wrapMethod(
|
|
72
|
+
routerProto,
|
|
73
|
+
'route',
|
|
74
|
+
function routeTrace( ...args) {
|
|
75
|
+
const route = originalRouteMethod.apply(this, args);
|
|
76
|
+
const layer = this.stack[this.stack.length - 1] ;
|
|
77
|
+
patchLayer.patchLayer(options, layer, utils.getLayerPath(args));
|
|
78
|
+
return route;
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
} catch (e) {
|
|
82
|
+
debugBuild.DEBUG_BUILD && debugLogger.debug.error('Failed to patch express route method:', e);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// oxlint-disable-next-line @typescript-eslint/unbound-method
|
|
86
|
+
const originalRouterUse = routerProto.use;
|
|
87
|
+
try {
|
|
88
|
+
object.wrapMethod(
|
|
89
|
+
routerProto,
|
|
90
|
+
'use',
|
|
91
|
+
function useTrace( ...args) {
|
|
92
|
+
const route = originalRouterUse.apply(this, args);
|
|
93
|
+
const layer = this.stack[this.stack.length - 1];
|
|
94
|
+
if (!layer) {
|
|
95
|
+
return route;
|
|
96
|
+
}
|
|
97
|
+
patchLayer.patchLayer(options, layer, utils.getLayerPath(args));
|
|
98
|
+
return route;
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
debugBuild.DEBUG_BUILD && debugLogger.debug.error('Failed to patch express use method:', e);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const { application } = express;
|
|
106
|
+
const originalApplicationUse = application.use;
|
|
107
|
+
try {
|
|
108
|
+
object.wrapMethod(
|
|
109
|
+
application,
|
|
110
|
+
'use',
|
|
111
|
+
function appUseTrace(
|
|
112
|
+
|
|
113
|
+
...args
|
|
114
|
+
) {
|
|
115
|
+
// If we access app.router in express 4.x we trigger an assertion error.
|
|
116
|
+
// This property existed in v3, was removed in v4 and then re-added in v5.
|
|
117
|
+
const route = originalApplicationUse.apply(this, args);
|
|
118
|
+
const router = utils.isExpressWithRouterPrototype(express) ? this.router : this._router;
|
|
119
|
+
if (router) {
|
|
120
|
+
const layer = router.stack[router.stack.length - 1];
|
|
121
|
+
if (layer) {
|
|
122
|
+
patchLayer.patchLayer(options, layer, utils.getLayerPath(args));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return route;
|
|
126
|
+
},
|
|
127
|
+
);
|
|
128
|
+
} catch (e) {
|
|
129
|
+
debugBuild.DEBUG_BUILD && debugLogger.debug.error('Failed to patch express application.use method:', e);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return express;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* An Express-compatible error handler, used by setupExpressErrorHandler
|
|
137
|
+
*/
|
|
138
|
+
function expressErrorHandler(options) {
|
|
139
|
+
return function sentryErrorMiddleware(
|
|
140
|
+
error,
|
|
141
|
+
request,
|
|
142
|
+
res,
|
|
143
|
+
next,
|
|
144
|
+
) {
|
|
145
|
+
// When an error happens, the `expressRequestHandler` middleware does not run, so we set it here too
|
|
146
|
+
setSdkProcessingMetadata.setSDKProcessingMetadata(request);
|
|
147
|
+
const shouldHandleError = options?.shouldHandleError || utils.defaultShouldHandleError;
|
|
148
|
+
|
|
149
|
+
if (shouldHandleError(error)) {
|
|
150
|
+
const eventId = _exports.captureException(error, {
|
|
151
|
+
mechanism: { type: 'auto.middleware.express', handled: false },
|
|
152
|
+
});
|
|
153
|
+
(res ).sentry = eventId;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
next(error);
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Add an Express error handler to capture errors to Sentry.
|
|
162
|
+
*
|
|
163
|
+
* The error handler must be before any other middleware and after all controllers.
|
|
164
|
+
*
|
|
165
|
+
* @param app The Express instances
|
|
166
|
+
* @param options {ExpressHandlerOptions} Configuration options for the handler
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```javascript
|
|
170
|
+
* import * as Sentry from 'sentry/deno'; // or any other @sentry/<platform>
|
|
171
|
+
* import * as express from 'express';
|
|
172
|
+
*
|
|
173
|
+
* Sentry.instrumentExpress(express);
|
|
174
|
+
*
|
|
175
|
+
* const app = express();
|
|
176
|
+
*
|
|
177
|
+
* // Add your routes, etc.
|
|
178
|
+
*
|
|
179
|
+
* // Add this after all routes,
|
|
180
|
+
* // but before any and other error-handling middlewares are defined
|
|
181
|
+
* Sentry.setupExpressErrorHandler(app);
|
|
182
|
+
*
|
|
183
|
+
* app.listen(3000);
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
function setupExpressErrorHandler(
|
|
187
|
+
app
|
|
188
|
+
|
|
189
|
+
,
|
|
190
|
+
options,
|
|
191
|
+
) {
|
|
192
|
+
app.use(expressRequestHandler());
|
|
193
|
+
app.use(expressErrorHandler(options));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function expressRequestHandler() {
|
|
197
|
+
return function sentryRequestMiddleware(request, _res, next) {
|
|
198
|
+
setSdkProcessingMetadata.setSDKProcessingMetadata(request);
|
|
199
|
+
next();
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
exports.expressErrorHandler = expressErrorHandler;
|
|
204
|
+
exports.patchExpressModule = patchExpressModule;
|
|
205
|
+
exports.setupExpressErrorHandler = setupExpressErrorHandler;
|
|
206
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/integrations/express/index.ts"],"sourcesContent":["/**\n * Platform-portable Express tracing integration.\n *\n * @module\n *\n * This Sentry integration is a derivative work based on the OpenTelemetry\n * Express instrumentation.\n *\n * <https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-express>\n *\n * Extended under the terms of the Apache 2.0 license linked below:\n *\n * ----\n *\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { debug } from '../../utils/debug-logger';\nimport { captureException } from '../../exports';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport type {\n ExpressApplication,\n ExpressErrorMiddleware,\n ExpressExport,\n ExpressHandlerOptions,\n ExpressIntegrationOptions,\n ExpressLayer,\n ExpressMiddleware,\n ExpressModuleExport,\n ExpressRequest,\n ExpressResponse,\n ExpressRouter,\n ExpressRouterv4,\n ExpressRouterv5,\n MiddlewareError,\n} from './types';\nimport {\n defaultShouldHandleError,\n getLayerPath,\n hasDefaultProp,\n isExpressWithoutRouterPrototype,\n isExpressWithRouterPrototype,\n} from './utils';\nimport { wrapMethod } from '../../utils/object';\nimport { patchLayer } from './patch-layer';\nimport { setSDKProcessingMetadata } from './set-sdk-processing-metadata';\n\nconst getExpressExport = (express: ExpressModuleExport): ExpressExport =>\n hasDefaultProp(express) ? express.default : (express as ExpressExport);\n\n/**\n * This is a portable instrumentatiton function that works in any environment\n * where Express can be loaded, without depending on OpenTelemetry.\n *\n * @example\n * ```javascript\n * import express from 'express';\n * import * as Sentry from '@sentry/deno'; // or any SDK that extends core\n *\n * Sentry.patchExpressModule({ express })\n */\nexport const patchExpressModule = (options: ExpressIntegrationOptions) => {\n // pass in the require() or import() result of express\n const express = getExpressExport(options.express);\n const routerProto: ExpressRouterv4 | ExpressRouterv5 | undefined = isExpressWithRouterPrototype(express)\n ? express.Router.prototype // Express v5\n : isExpressWithoutRouterPrototype(express)\n ? express.Router // Express v4\n : undefined;\n\n if (!routerProto) {\n throw new TypeError('no valid Express route function to instrument');\n }\n\n // oxlint-disable-next-line @typescript-eslint/unbound-method\n const originalRouteMethod = routerProto.route;\n try {\n wrapMethod(\n routerProto,\n 'route',\n function routeTrace(this: ExpressRouter, ...args: Parameters<typeof originalRouteMethod>[]) {\n const route = originalRouteMethod.apply(this, args);\n const layer = this.stack[this.stack.length - 1] as ExpressLayer;\n patchLayer(options, layer, getLayerPath(args));\n return route;\n },\n );\n } catch (e) {\n DEBUG_BUILD && debug.error('Failed to patch express route method:', e);\n }\n\n // oxlint-disable-next-line @typescript-eslint/unbound-method\n const originalRouterUse = routerProto.use;\n try {\n wrapMethod(\n routerProto,\n 'use',\n function useTrace(this: ExpressApplication, ...args: Parameters<typeof originalRouterUse>) {\n const route = originalRouterUse.apply(this, args);\n const layer = this.stack[this.stack.length - 1];\n if (!layer) {\n return route;\n }\n patchLayer(options, layer, getLayerPath(args));\n return route;\n },\n );\n } catch (e) {\n DEBUG_BUILD && debug.error('Failed to patch express use method:', e);\n }\n\n const { application } = express;\n const originalApplicationUse = application.use;\n try {\n wrapMethod(\n application,\n 'use',\n function appUseTrace(\n this: ExpressApplication & {\n _router?: ExpressRouter;\n router?: ExpressRouter;\n },\n ...args: Parameters<ExpressApplication['use']>\n ) {\n // If we access app.router in express 4.x we trigger an assertion error.\n // This property existed in v3, was removed in v4 and then re-added in v5.\n const route = originalApplicationUse.apply(this, args);\n const router = isExpressWithRouterPrototype(express) ? this.router : this._router;\n if (router) {\n const layer = router.stack[router.stack.length - 1];\n if (layer) {\n patchLayer(options, layer, getLayerPath(args));\n }\n }\n return route;\n },\n );\n } catch (e) {\n DEBUG_BUILD && debug.error('Failed to patch express application.use method:', e);\n }\n\n return express;\n};\n\n/**\n * An Express-compatible error handler, used by setupExpressErrorHandler\n */\nexport function expressErrorHandler(options?: ExpressHandlerOptions): ExpressErrorMiddleware {\n return function sentryErrorMiddleware(\n error: MiddlewareError,\n request: ExpressRequest,\n res: ExpressResponse,\n next: (error: MiddlewareError) => void,\n ): void {\n // When an error happens, the `expressRequestHandler` middleware does not run, so we set it here too\n setSDKProcessingMetadata(request);\n const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;\n\n if (shouldHandleError(error)) {\n const eventId = captureException(error, {\n mechanism: { type: 'auto.middleware.express', handled: false },\n });\n (res as { sentry?: string }).sentry = eventId;\n }\n\n next(error);\n };\n}\n\n/**\n * Add an Express error handler to capture errors to Sentry.\n *\n * The error handler must be before any other middleware and after all controllers.\n *\n * @param app The Express instances\n * @param options {ExpressHandlerOptions} Configuration options for the handler\n *\n * @example\n * ```javascript\n * import * as Sentry from 'sentry/deno'; // or any other @sentry/<platform>\n * import * as express from 'express';\n *\n * Sentry.instrumentExpress(express);\n *\n * const app = express();\n *\n * // Add your routes, etc.\n *\n * // Add this after all routes,\n * // but before any and other error-handling middlewares are defined\n * Sentry.setupExpressErrorHandler(app);\n *\n * app.listen(3000);\n * ```\n */\nexport function setupExpressErrorHandler(\n app: {\n //oxlint-disable-next-line no-explicit-any\n use: (middleware: any) => unknown;\n },\n options?: ExpressHandlerOptions,\n): void {\n app.use(expressRequestHandler());\n app.use(expressErrorHandler(options));\n}\n\nfunction expressRequestHandler(): ExpressMiddleware {\n return function sentryRequestMiddleware(request: ExpressRequest, _res: ExpressResponse, next: () => void): void {\n setSDKProcessingMetadata(request);\n next();\n };\n}\n"],"names":["hasDefaultProp","isExpressWithRouterPrototype","isExpressWithoutRouterPrototype","wrapMethod","patchLayer","getLayerPath","DEBUG_BUILD","debug","setSDKProcessingMetadata","defaultShouldHandleError","captureException"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAgCA,MAAM,gBAAA,GAAmB,CAAC,OAAO;AACjC,EAAEA,oBAAc,CAAC,OAAO,CAAA,GAAI,OAAO,CAAC,OAAA,IAAW,OAAA,EAAyB;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,kBAAA,GAAqB,CAAC,OAAO,KAAgC;AAC1E;AACA,E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