@sentry/core
Advanced tools
| // This file is a compatibility shim for bundlers (e.g. webpack 4) that do not | ||
| // support the package.json `exports` field for resolving subpath exports. | ||
| module.exports = require('./build/cjs/browser.js'); |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const errors = require('./tracing/errors.js'); | ||
| const utils$1 = require('./tracing/utils.js'); | ||
| const idleSpan = require('./tracing/idleSpan.js'); | ||
| const sentrySpan = require('./tracing/sentrySpan.js'); | ||
| const sentryNonRecordingSpan = require('./tracing/sentryNonRecordingSpan.js'); | ||
| const spanstatus = require('./tracing/spanstatus.js'); | ||
| const trace = require('./tracing/trace.js'); | ||
| const dynamicSamplingContext = require('./tracing/dynamicSamplingContext.js'); | ||
| const measurement = require('./tracing/measurement.js'); | ||
| const sampling = require('./tracing/sampling.js'); | ||
| const logSpans = require('./tracing/logSpans.js'); | ||
| const captureSpan = require('./tracing/spans/captureSpan.js'); | ||
| const semanticAttributes = require('./semanticAttributes.js'); | ||
| const envelope$1 = require('./envelope.js'); | ||
| const exports$1 = require('./exports.js'); | ||
| const currentScopes = require('./currentScopes.js'); | ||
| const defaultScopes = require('./defaultScopes.js'); | ||
| const index$6 = require('./asyncContext/index.js'); | ||
| const carrier = require('./carrier.js'); | ||
| const session = require('./session.js'); | ||
| const scope = require('./scope.js'); | ||
| const eventProcessors = require('./eventProcessors.js'); | ||
| const api = require('./api.js'); | ||
| const client = require('./client.js'); | ||
| const sdk = require('./sdk.js'); | ||
| const base = require('./transports/base.js'); | ||
| const offline = require('./transports/offline.js'); | ||
| const multiplexed = require('./transports/multiplexed.js'); | ||
| const integration = require('./integration.js'); | ||
| const providerSkip = require('./utils/ai/providerSkip.js'); | ||
| const envToBool = require('./utils/envToBool.js'); | ||
| const scopeData = require('./utils/scopeData.js'); | ||
| const prepareEvent = require('./utils/prepareEvent.js'); | ||
| const checkin = require('./checkin.js'); | ||
| const hasSpansEnabled = require('./utils/hasSpansEnabled.js'); | ||
| const beforeSendSpan = require('./tracing/spans/beforeSendSpan.js'); | ||
| const isSentryRequestUrl = require('./utils/isSentryRequestUrl.js'); | ||
| const handleCallbackErrors = require('./utils/handleCallbackErrors.js'); | ||
| const parameterize = require('./utils/parameterize.js'); | ||
| const tunnel = require('./utils/tunnel.js'); | ||
| const ipAddress = require('./utils/ipAddress.js'); | ||
| const spanUtils = require('./utils/spanUtils.js'); | ||
| const spanOnScope = require('./utils/spanOnScope.js'); | ||
| const parseSampleRate = require('./utils/parseSampleRate.js'); | ||
| const sdkMetadata = require('./utils/sdkMetadata.js'); | ||
| const traceData = require('./utils/traceData.js'); | ||
| const tracePropagationTargets = require('./utils/tracePropagationTargets.js'); | ||
| const meta = require('./utils/meta.js'); | ||
| const debounce = require('./utils/debounce.js'); | ||
| const weakRef = require('./utils/weakRef.js'); | ||
| const shouldIgnoreSpan = require('./utils/should-ignore-span.js'); | ||
| const request = require('./utils/request.js'); | ||
| const constants$1 = require('./constants.js'); | ||
| const breadcrumbs = require('./breadcrumbs.js'); | ||
| const functiontostring = require('./integrations/functiontostring.js'); | ||
| const eventFilters = require('./integrations/eventFilters.js'); | ||
| const linkederrors = require('./integrations/linkederrors.js'); | ||
| const moduleMetadata = require('./integrations/moduleMetadata.js'); | ||
| const requestdata = require('./integrations/requestdata.js'); | ||
| const captureconsole = require('./integrations/captureconsole.js'); | ||
| const dedupe = require('./integrations/dedupe.js'); | ||
| const extraerrordata = require('./integrations/extraerrordata.js'); | ||
| const rewriteframes = require('./integrations/rewriteframes.js'); | ||
| const supabase = require('./integrations/supabase.js'); | ||
| const zoderrors = require('./integrations/zoderrors.js'); | ||
| const thirdPartyErrorsFilter = require('./integrations/third-party-errors-filter.js'); | ||
| const console$1 = require('./integrations/console.js'); | ||
| const featureFlagsIntegration = require('./integrations/featureFlags/featureFlagsIntegration.js'); | ||
| const growthbook = require('./integrations/featureFlags/growthbook.js'); | ||
| const conversationId = require('./integrations/conversationId.js'); | ||
| const profiling = require('./profiling.js'); | ||
| const fetch = require('./fetch.js'); | ||
| const feedback = require('./feedback.js'); | ||
| const internal = require('./logs/internal.js'); | ||
| const publicApi = require('./logs/public-api.js'); | ||
| const consoleIntegration = require('./logs/console-integration.js'); | ||
| const internal$1 = require('./metrics/internal.js'); | ||
| const publicApi$1 = require('./metrics/public-api.js'); | ||
| const consola = require('./integrations/consola.js'); | ||
| const index = require('./tracing/vercel-ai/index.js'); | ||
| const utils = require('./tracing/vercel-ai/utils.js'); | ||
| const constants$6 = require('./tracing/vercel-ai/constants.js'); | ||
| const index$5 = require('./tracing/openai/index.js'); | ||
| const constants$5 = require('./tracing/openai/constants.js'); | ||
| const index$2 = require('./tracing/anthropic-ai/index.js'); | ||
| const constants = require('./tracing/anthropic-ai/constants.js'); | ||
| const index$4 = require('./tracing/google-genai/index.js'); | ||
| const constants$2 = require('./tracing/google-genai/constants.js'); | ||
| const index$1 = require('./tracing/langchain/index.js'); | ||
| const constants$3 = require('./tracing/langchain/constants.js'); | ||
| const index$3 = require('./tracing/langgraph/index.js'); | ||
| const constants$4 = require('./tracing/langgraph/constants.js'); | ||
| const spanBuffer = require('./tracing/spans/spanBuffer.js'); | ||
| const hasSpanStreamingEnabled = require('./tracing/spans/hasSpanStreamingEnabled.js'); | ||
| const spanStreaming = require('./integrations/spanStreaming.js'); | ||
| const featureFlags = require('./utils/featureFlags.js'); | ||
| const aggregateErrors = require('./utils/aggregate-errors.js'); | ||
| const breadcrumbLogLevel = require('./utils/breadcrumb-log-level.js'); | ||
| const dsn = require('./utils/dsn.js'); | ||
| const error = require('./utils/error.js'); | ||
| const worldwide = require('./utils/worldwide.js'); | ||
| const console = require('./instrument/console.js'); | ||
| const fetch$1 = require('./instrument/fetch.js'); | ||
| const globalError = require('./instrument/globalError.js'); | ||
| const globalUnhandledRejection = require('./instrument/globalUnhandledRejection.js'); | ||
| const handlers = require('./instrument/handlers.js'); | ||
| const is = require('./utils/is.js'); | ||
| const isBrowser = require('./utils/isBrowser.js'); | ||
| const debugLogger = require('./utils/debug-logger.js'); | ||
| const misc = require('./utils/misc.js'); | ||
| const normalize = require('./utils/normalize.js'); | ||
| const normalizationHints = require('./utils/normalizationHints.js'); | ||
| const object = require('./utils/object.js'); | ||
| const path = require('./utils/path.js'); | ||
| const promisebuffer = require('./utils/promisebuffer.js'); | ||
| const severity = require('./utils/severity.js'); | ||
| const exports$2 = require('./utils/exports.js'); | ||
| const stacktrace = require('./utils/stacktrace.js'); | ||
| const string = require('./utils/string.js'); | ||
| const supports = require('./utils/supports.js'); | ||
| const syncpromise = require('./utils/syncpromise.js'); | ||
| const time = require('./utils/time.js'); | ||
| const tracing = require('./utils/tracing.js'); | ||
| const env = require('./utils/env.js'); | ||
| const envelope = require('./utils/envelope.js'); | ||
| const clientreport = require('./utils/clientreport.js'); | ||
| const ratelimit = require('./utils/ratelimit.js'); | ||
| const baggage = require('./utils/baggage.js'); | ||
| const url = require('./utils/url.js'); | ||
| const eventbuilder = require('./utils/eventbuilder.js'); | ||
| const lru = require('./utils/lru.js'); | ||
| const propagationContext = require('./utils/propagationContext.js'); | ||
| const version = require('./utils/version.js'); | ||
| const debugIds = require('./utils/debug-ids.js'); | ||
| const metadata = require('./metadata.js'); | ||
| const escapeStringForRegex = require('./vendor/escapeStringForRegex.js'); | ||
| const randomSafeContext = require('./utils/randomSafeContext.js'); | ||
| const browser = require('./utils/browser.js'); | ||
| const embeddings = require('./tracing/langchain/embeddings.js'); | ||
| exports.registerSpanErrorInstrumentation = errors.registerSpanErrorInstrumentation; | ||
| exports.getCapturedScopesOnSpan = utils$1.getCapturedScopesOnSpan; | ||
| exports.setCapturedScopesOnSpan = utils$1.setCapturedScopesOnSpan; | ||
| exports.TRACING_DEFAULTS = idleSpan.TRACING_DEFAULTS; | ||
| exports.startIdleSpan = idleSpan.startIdleSpan; | ||
| exports.SentrySpan = sentrySpan.SentrySpan; | ||
| exports.SentryNonRecordingSpan = sentryNonRecordingSpan.SentryNonRecordingSpan; | ||
| exports.SPAN_STATUS_ERROR = spanstatus.SPAN_STATUS_ERROR; | ||
| exports.SPAN_STATUS_OK = spanstatus.SPAN_STATUS_OK; | ||
| exports.SPAN_STATUS_UNSET = spanstatus.SPAN_STATUS_UNSET; | ||
| exports.getSpanStatusFromHttpCode = spanstatus.getSpanStatusFromHttpCode; | ||
| exports.setHttpStatus = spanstatus.setHttpStatus; | ||
| exports.SUPPRESS_TRACING_KEY = trace.SUPPRESS_TRACING_KEY; | ||
| exports.continueTrace = trace.continueTrace; | ||
| exports.startInactiveSpan = trace.startInactiveSpan; | ||
| exports.startNewTrace = trace.startNewTrace; | ||
| exports.startSpan = trace.startSpan; | ||
| exports.startSpanManual = trace.startSpanManual; | ||
| exports.suppressTracing = trace.suppressTracing; | ||
| exports.withActiveSpan = trace.withActiveSpan; | ||
| exports.getDynamicSamplingContextFromClient = dynamicSamplingContext.getDynamicSamplingContextFromClient; | ||
| exports.getDynamicSamplingContextFromScope = dynamicSamplingContext.getDynamicSamplingContextFromScope; | ||
| exports.getDynamicSamplingContextFromSpan = dynamicSamplingContext.getDynamicSamplingContextFromSpan; | ||
| exports.spanToBaggageHeader = dynamicSamplingContext.spanToBaggageHeader; | ||
| exports.setMeasurement = measurement.setMeasurement; | ||
| exports.timedEventsToMeasurements = measurement.timedEventsToMeasurements; | ||
| exports.sampleSpan = sampling.sampleSpan; | ||
| exports.logSpanEnd = logSpans.logSpanEnd; | ||
| exports.logSpanStart = logSpans.logSpanStart; | ||
| exports.captureSpan = captureSpan.captureSpan; | ||
| exports.safeSetSpanJSONAttributes = captureSpan.safeSetSpanJSONAttributes; | ||
| exports.GEN_AI_CONVERSATION_ID_ATTRIBUTE = semanticAttributes.GEN_AI_CONVERSATION_ID_ATTRIBUTE; | ||
| exports.SEMANTIC_ATTRIBUTE_CACHE_HIT = semanticAttributes.SEMANTIC_ATTRIBUTE_CACHE_HIT; | ||
| exports.SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = semanticAttributes.SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE; | ||
| exports.SEMANTIC_ATTRIBUTE_CACHE_KEY = semanticAttributes.SEMANTIC_ATTRIBUTE_CACHE_KEY; | ||
| exports.SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = semanticAttributes.SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME; | ||
| exports.SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = semanticAttributes.SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD; | ||
| exports.SEMANTIC_ATTRIBUTE_PROFILE_ID = semanticAttributes.SEMANTIC_ATTRIBUTE_PROFILE_ID; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_OP = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_OP; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_RELEASE; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE; | ||
| exports.SEMANTIC_ATTRIBUTE_URL_FULL = semanticAttributes.SEMANTIC_ATTRIBUTE_URL_FULL; | ||
| exports.SEMANTIC_ATTRIBUTE_USER_EMAIL = semanticAttributes.SEMANTIC_ATTRIBUTE_USER_EMAIL; | ||
| exports.SEMANTIC_ATTRIBUTE_USER_ID = semanticAttributes.SEMANTIC_ATTRIBUTE_USER_ID; | ||
| exports.SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = semanticAttributes.SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS; | ||
| exports.SEMANTIC_ATTRIBUTE_USER_USERNAME = semanticAttributes.SEMANTIC_ATTRIBUTE_USER_USERNAME; | ||
| exports.SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = semanticAttributes.SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE; | ||
| exports.createEventEnvelope = envelope$1.createEventEnvelope; | ||
| exports.createSessionEnvelope = envelope$1.createSessionEnvelope; | ||
| exports.createSpanEnvelope = envelope$1.createSpanEnvelope; | ||
| exports.addEventProcessor = exports$1.addEventProcessor; | ||
| exports.captureCheckIn = exports$1.captureCheckIn; | ||
| exports.captureEvent = exports$1.captureEvent; | ||
| exports.captureException = exports$1.captureException; | ||
| exports.captureMessage = exports$1.captureMessage; | ||
| exports.captureSession = exports$1.captureSession; | ||
| exports.close = exports$1.close; | ||
| exports.endSession = exports$1.endSession; | ||
| exports.flush = exports$1.flush; | ||
| exports.isEnabled = exports$1.isEnabled; | ||
| exports.isInitialized = exports$1.isInitialized; | ||
| exports.lastEventId = exports$1.lastEventId; | ||
| exports.setContext = exports$1.setContext; | ||
| exports.setConversationId = exports$1.setConversationId; | ||
| exports.setExtra = exports$1.setExtra; | ||
| exports.setExtras = exports$1.setExtras; | ||
| exports.setTag = exports$1.setTag; | ||
| exports.setTags = exports$1.setTags; | ||
| exports.setUser = exports$1.setUser; | ||
| exports.startSession = exports$1.startSession; | ||
| exports.withMonitor = exports$1.withMonitor; | ||
| exports.getClient = currentScopes.getClient; | ||
| exports.getCurrentScope = currentScopes.getCurrentScope; | ||
| exports.getExternalPropagationContext = currentScopes.getExternalPropagationContext; | ||
| exports.getGlobalScope = currentScopes.getGlobalScope; | ||
| exports.getIsolationScope = currentScopes.getIsolationScope; | ||
| exports.getTraceContextFromScope = currentScopes.getTraceContextFromScope; | ||
| exports.hasExternalPropagationContext = currentScopes.hasExternalPropagationContext; | ||
| exports.registerExternalPropagationContext = currentScopes.registerExternalPropagationContext; | ||
| exports.withIsolationScope = currentScopes.withIsolationScope; | ||
| exports.withScope = currentScopes.withScope; | ||
| exports.getDefaultCurrentScope = defaultScopes.getDefaultCurrentScope; | ||
| exports.getDefaultIsolationScope = defaultScopes.getDefaultIsolationScope; | ||
| exports.setAsyncContextStrategy = index$6.setAsyncContextStrategy; | ||
| exports.getGlobalSingleton = carrier.getGlobalSingleton; | ||
| exports.getMainCarrier = carrier.getMainCarrier; | ||
| exports.closeSession = session.closeSession; | ||
| exports.makeSession = session.makeSession; | ||
| exports.updateSession = session.updateSession; | ||
| exports.Scope = scope.Scope; | ||
| exports.notifyEventProcessors = eventProcessors.notifyEventProcessors; | ||
| exports.SENTRY_API_VERSION = api.SENTRY_API_VERSION; | ||
| exports.getEnvelopeEndpointWithUrlEncodedAuth = api.getEnvelopeEndpointWithUrlEncodedAuth; | ||
| exports.getReportDialogEndpoint = api.getReportDialogEndpoint; | ||
| exports.Client = client.Client; | ||
| exports.initAndBind = sdk.initAndBind; | ||
| exports.setCurrentClient = sdk.setCurrentClient; | ||
| exports.createTransport = base.createTransport; | ||
| exports.makeOfflineTransport = offline.makeOfflineTransport; | ||
| exports.MULTIPLEXED_TRANSPORT_EXTRA_KEY = multiplexed.MULTIPLEXED_TRANSPORT_EXTRA_KEY; | ||
| exports.makeMultiplexedTransport = multiplexed.makeMultiplexedTransport; | ||
| exports.addIntegration = integration.addIntegration; | ||
| exports.defineIntegration = integration.defineIntegration; | ||
| exports.getIntegrationsToSetup = integration.getIntegrationsToSetup; | ||
| exports.installedIntegrations = integration.installedIntegrations; | ||
| exports._INTERNAL_clearAiProviderSkips = providerSkip._INTERNAL_clearAiProviderSkips; | ||
| exports._INTERNAL_shouldSkipAiProviderWrapping = providerSkip._INTERNAL_shouldSkipAiProviderWrapping; | ||
| exports._INTERNAL_skipAiProviderWrapping = providerSkip._INTERNAL_skipAiProviderWrapping; | ||
| exports.envToBool = envToBool.envToBool; | ||
| exports.applyScopeDataToEvent = scopeData.applyScopeDataToEvent; | ||
| exports.getCombinedScopeData = scopeData.getCombinedScopeData; | ||
| exports.mergeScopeData = scopeData.mergeScopeData; | ||
| exports.prepareEvent = prepareEvent.prepareEvent; | ||
| exports.createCheckInEnvelope = checkin.createCheckInEnvelope; | ||
| exports.hasSpansEnabled = hasSpansEnabled.hasSpansEnabled; | ||
| exports.isStreamedBeforeSendSpanCallback = beforeSendSpan.isStreamedBeforeSendSpanCallback; | ||
| exports.withStreamedSpan = beforeSendSpan.withStreamedSpan; | ||
| exports.isSentryRequestUrl = isSentryRequestUrl.isSentryRequestUrl; | ||
| exports.handleCallbackErrors = handleCallbackErrors.handleCallbackErrors; | ||
| exports.fmt = parameterize.fmt; | ||
| exports.parameterize = parameterize.parameterize; | ||
| exports.handleTunnelRequest = tunnel.handleTunnelRequest; | ||
| exports.addAutoIpAddressToSession = ipAddress.addAutoIpAddressToSession; | ||
| exports.addAutoIpAddressToUser = ipAddress.addAutoIpAddressToUser; | ||
| exports.INTERNAL_getSegmentSpan = spanUtils.INTERNAL_getSegmentSpan; | ||
| exports.addChildSpanToSpan = spanUtils.addChildSpanToSpan; | ||
| exports.convertSpanLinksForEnvelope = spanUtils.convertSpanLinksForEnvelope; | ||
| exports.getActiveSpan = spanUtils.getActiveSpan; | ||
| exports.getRootSpan = spanUtils.getRootSpan; | ||
| exports.getSpanDescendants = spanUtils.getSpanDescendants; | ||
| exports.getStatusMessage = spanUtils.getStatusMessage; | ||
| exports.spanIsSampled = spanUtils.spanIsSampled; | ||
| exports.spanTimeInputToSeconds = spanUtils.spanTimeInputToSeconds; | ||
| exports.spanToJSON = spanUtils.spanToJSON; | ||
| exports.spanToStreamedSpanJSON = spanUtils.spanToStreamedSpanJSON; | ||
| exports.spanToTraceContext = spanUtils.spanToTraceContext; | ||
| exports.spanToTraceHeader = spanUtils.spanToTraceHeader; | ||
| exports.updateSpanName = spanUtils.updateSpanName; | ||
| exports._INTERNAL_setSpanForScope = spanOnScope._setSpanForScope; | ||
| exports.parseSampleRate = parseSampleRate.parseSampleRate; | ||
| exports.applySdkMetadata = sdkMetadata.applySdkMetadata; | ||
| exports.getTraceData = traceData.getTraceData; | ||
| exports.shouldPropagateTraceForUrl = tracePropagationTargets.shouldPropagateTraceForUrl; | ||
| exports.getTraceMetaTags = meta.getTraceMetaTags; | ||
| exports.debounce = debounce.debounce; | ||
| exports.derefWeakRef = weakRef.derefWeakRef; | ||
| exports.makeWeakRef = weakRef.makeWeakRef; | ||
| exports.shouldIgnoreSpan = shouldIgnoreSpan.shouldIgnoreSpan; | ||
| exports.MAX_BODY_BYTE_LENGTH = request.MAX_BODY_BYTE_LENGTH; | ||
| exports.captureBodyFromWinterCGRequest = request.captureBodyFromWinterCGRequest; | ||
| exports.extractQueryParamsFromUrl = request.extractQueryParamsFromUrl; | ||
| exports.getMaxBodyByteLength = request.getMaxBodyByteLength; | ||
| exports.headersToDict = request.headersToDict; | ||
| exports.httpHeadersToSpanAttributes = request.httpHeadersToSpanAttributes; | ||
| exports.httpRequestToRequestData = request.httpRequestToRequestData; | ||
| exports.winterCGHeadersToDict = request.winterCGHeadersToDict; | ||
| exports.winterCGRequestToRequestData = request.winterCGRequestToRequestData; | ||
| exports.DEFAULT_ENVIRONMENT = constants$1.DEFAULT_ENVIRONMENT; | ||
| exports.DEV_ENVIRONMENT = constants$1.DEV_ENVIRONMENT; | ||
| exports.addBreadcrumb = breadcrumbs.addBreadcrumb; | ||
| exports.functionToStringIntegration = functiontostring.functionToStringIntegration; | ||
| exports.eventFiltersIntegration = eventFilters.eventFiltersIntegration; | ||
| exports.inboundFiltersIntegration = eventFilters.inboundFiltersIntegration; | ||
| exports.linkedErrorsIntegration = linkederrors.linkedErrorsIntegration; | ||
| exports.moduleMetadataIntegration = moduleMetadata.moduleMetadataIntegration; | ||
| exports.requestDataIntegration = requestdata.requestDataIntegration; | ||
| exports.captureConsoleIntegration = captureconsole.captureConsoleIntegration; | ||
| exports.dedupeIntegration = dedupe.dedupeIntegration; | ||
| exports.extraErrorDataIntegration = extraerrordata.extraErrorDataIntegration; | ||
| exports.rewriteFramesIntegration = rewriteframes.rewriteFramesIntegration; | ||
| exports.instrumentSupabaseClient = supabase.instrumentSupabaseClient; | ||
| exports.supabaseIntegration = supabase.supabaseIntegration; | ||
| exports.zodErrorsIntegration = zoderrors.zodErrorsIntegration; | ||
| exports.thirdPartyErrorFilterIntegration = thirdPartyErrorsFilter.thirdPartyErrorFilterIntegration; | ||
| exports.consoleIntegration = console$1.consoleIntegration; | ||
| exports.featureFlagsIntegration = featureFlagsIntegration.featureFlagsIntegration; | ||
| exports.growthbookIntegration = growthbook.growthbookIntegration; | ||
| exports.conversationIdIntegration = conversationId.conversationIdIntegration; | ||
| exports.profiler = profiling.profiler; | ||
| exports._INTERNAL_getTracingHeadersForFetchRequest = fetch._INTERNAL_getTracingHeadersForFetchRequest; | ||
| exports.instrumentFetchRequest = fetch.instrumentFetchRequest; | ||
| exports.captureFeedback = feedback.captureFeedback; | ||
| exports._INTERNAL_captureLog = internal._INTERNAL_captureLog; | ||
| exports._INTERNAL_captureSerializedLog = internal._INTERNAL_captureSerializedLog; | ||
| exports._INTERNAL_flushLogsBuffer = internal._INTERNAL_flushLogsBuffer; | ||
| exports.logger = publicApi; | ||
| exports.consoleLoggingIntegration = consoleIntegration.consoleLoggingIntegration; | ||
| exports._INTERNAL_captureMetric = internal$1._INTERNAL_captureMetric; | ||
| exports._INTERNAL_captureSerializedMetric = internal$1._INTERNAL_captureSerializedMetric; | ||
| exports._INTERNAL_flushMetricsBuffer = internal$1._INTERNAL_flushMetricsBuffer; | ||
| exports.metrics = publicApi$1; | ||
| exports.createConsolaReporter = consola.createConsolaReporter; | ||
| exports.addVercelAiProcessors = index.addVercelAiProcessors; | ||
| exports._INTERNAL_cleanupToolCallSpanContext = utils._INTERNAL_cleanupToolCallSpanContext; | ||
| exports._INTERNAL_getSpanContextForToolCallId = utils._INTERNAL_getSpanContextForToolCallId; | ||
| exports._INTERNAL_toolCallSpanContextMap = constants$6.toolCallSpanContextMap; | ||
| exports.instrumentOpenAiClient = index$5.instrumentOpenAiClient; | ||
| exports.OPENAI_INTEGRATION_NAME = constants$5.OPENAI_INTEGRATION_NAME; | ||
| exports.instrumentAnthropicAiClient = index$2.instrumentAnthropicAiClient; | ||
| exports.ANTHROPIC_AI_INTEGRATION_NAME = constants.ANTHROPIC_AI_INTEGRATION_NAME; | ||
| exports.instrumentGoogleGenAIClient = index$4.instrumentGoogleGenAIClient; | ||
| exports.GOOGLE_GENAI_INTEGRATION_NAME = constants$2.GOOGLE_GENAI_INTEGRATION_NAME; | ||
| exports.createLangChainCallbackHandler = index$1.createLangChainCallbackHandler; | ||
| exports.LANGCHAIN_INTEGRATION_NAME = constants$3.LANGCHAIN_INTEGRATION_NAME; | ||
| exports.instrumentCreateReactAgent = index$3.instrumentCreateReactAgent; | ||
| exports.instrumentLangGraph = index$3.instrumentLangGraph; | ||
| exports.instrumentStateGraphCompile = index$3.instrumentStateGraphCompile; | ||
| exports.LANGGRAPH_INTEGRATION_NAME = constants$4.LANGGRAPH_INTEGRATION_NAME; | ||
| exports.SpanBuffer = spanBuffer.SpanBuffer; | ||
| exports.hasSpanStreamingEnabled = hasSpanStreamingEnabled.hasSpanStreamingEnabled; | ||
| exports.spanStreamingIntegration = spanStreaming.spanStreamingIntegration; | ||
| exports._INTERNAL_FLAG_BUFFER_SIZE = featureFlags._INTERNAL_FLAG_BUFFER_SIZE; | ||
| exports._INTERNAL_MAX_FLAGS_PER_SPAN = featureFlags._INTERNAL_MAX_FLAGS_PER_SPAN; | ||
| exports._INTERNAL_addFeatureFlagToActiveSpan = featureFlags._INTERNAL_addFeatureFlagToActiveSpan; | ||
| exports._INTERNAL_copyFlagsFromScopeToEvent = featureFlags._INTERNAL_copyFlagsFromScopeToEvent; | ||
| exports._INTERNAL_insertFlagToScope = featureFlags._INTERNAL_insertFlagToScope; | ||
| exports.applyAggregateErrorsToEvent = aggregateErrors.applyAggregateErrorsToEvent; | ||
| exports.getBreadcrumbLogLevelFromHttpStatusCode = breadcrumbLogLevel.getBreadcrumbLogLevelFromHttpStatusCode; | ||
| exports.dsnFromString = dsn.dsnFromString; | ||
| exports.dsnToString = dsn.dsnToString; | ||
| exports.makeDsn = dsn.makeDsn; | ||
| exports.SentryError = error.SentryError; | ||
| exports.GLOBAL_OBJ = worldwide.GLOBAL_OBJ; | ||
| exports.addConsoleInstrumentationFilter = console.addConsoleInstrumentationFilter; | ||
| exports.addConsoleInstrumentationHandler = console.addConsoleInstrumentationHandler; | ||
| exports.addFetchEndInstrumentationHandler = fetch$1.addFetchEndInstrumentationHandler; | ||
| exports.addFetchInstrumentationHandler = fetch$1.addFetchInstrumentationHandler; | ||
| exports.addGlobalErrorInstrumentationHandler = globalError.addGlobalErrorInstrumentationHandler; | ||
| exports.addGlobalUnhandledRejectionInstrumentationHandler = globalUnhandledRejection.addGlobalUnhandledRejectionInstrumentationHandler; | ||
| exports.addHandler = handlers.addHandler; | ||
| exports.maybeInstrument = handlers.maybeInstrument; | ||
| exports.resetInstrumentationHandlers = handlers.resetInstrumentationHandlers; | ||
| exports.triggerHandlers = handlers.triggerHandlers; | ||
| exports.isDOMError = is.isDOMError; | ||
| exports.isDOMException = is.isDOMException; | ||
| exports.isElement = is.isElement; | ||
| exports.isError = is.isError; | ||
| exports.isErrorEvent = is.isErrorEvent; | ||
| exports.isEvent = is.isEvent; | ||
| exports.isInstanceOf = is.isInstanceOf; | ||
| exports.isParameterizedString = is.isParameterizedString; | ||
| exports.isPlainObject = is.isPlainObject; | ||
| exports.isPrimitive = is.isPrimitive; | ||
| exports.isRegExp = is.isRegExp; | ||
| exports.isString = is.isString; | ||
| exports.isSyntheticEvent = is.isSyntheticEvent; | ||
| exports.isThenable = is.isThenable; | ||
| exports.isVueViewModel = is.isVueViewModel; | ||
| exports.isBrowser = isBrowser.isBrowser; | ||
| exports.CONSOLE_LEVELS = debugLogger.CONSOLE_LEVELS; | ||
| exports.consoleSandbox = debugLogger.consoleSandbox; | ||
| exports.debug = debugLogger.debug; | ||
| exports.originalConsoleMethods = debugLogger.originalConsoleMethods; | ||
| exports.addContextToFrame = misc.addContextToFrame; | ||
| exports.addExceptionMechanism = misc.addExceptionMechanism; | ||
| exports.addExceptionTypeValue = misc.addExceptionTypeValue; | ||
| exports.checkOrSetAlreadyCaught = misc.checkOrSetAlreadyCaught; | ||
| exports.getEventDescription = misc.getEventDescription; | ||
| exports.isAlreadyCaptured = misc.isAlreadyCaptured; | ||
| exports.parseSemver = misc.parseSemver; | ||
| exports.uuid4 = misc.uuid4; | ||
| exports.normalize = normalize.normalize; | ||
| exports.normalizeToSize = normalize.normalizeToSize; | ||
| exports.normalizeUrlToBase = normalize.normalizeUrlToBase; | ||
| exports.setNormalizationDepthOverrideHint = normalizationHints.setNormalizationDepthOverrideHint; | ||
| exports.setSkipNormalizationHint = normalizationHints.setSkipNormalizationHint; | ||
| exports.addNonEnumerableProperty = object.addNonEnumerableProperty; | ||
| exports.convertToPlainObject = object.convertToPlainObject; | ||
| exports.dropUndefinedKeys = object.dropUndefinedKeys; | ||
| exports.extractExceptionKeysForMessage = object.extractExceptionKeysForMessage; | ||
| exports.fill = object.fill; | ||
| exports.getOriginalFunction = object.getOriginalFunction; | ||
| exports.markFunctionWrapped = object.markFunctionWrapped; | ||
| exports.objectify = object.objectify; | ||
| exports.basename = path.basename; | ||
| exports.dirname = path.dirname; | ||
| exports.isAbsolute = path.isAbsolute; | ||
| exports.join = path.join; | ||
| exports.normalizePath = path.normalizePath; | ||
| exports.relative = path.relative; | ||
| exports.resolve = path.resolve; | ||
| exports.SENTRY_BUFFER_FULL_ERROR = promisebuffer.SENTRY_BUFFER_FULL_ERROR; | ||
| exports.makePromiseBuffer = promisebuffer.makePromiseBuffer; | ||
| exports.severityLevelFromString = severity.severityLevelFromString; | ||
| exports.replaceExports = exports$2.replaceExports; | ||
| exports.UNKNOWN_FUNCTION = stacktrace.UNKNOWN_FUNCTION; | ||
| exports.createStackParser = stacktrace.createStackParser; | ||
| exports.getFramesFromEvent = stacktrace.getFramesFromEvent; | ||
| exports.getFunctionName = stacktrace.getFunctionName; | ||
| exports.stackParserFromStackParserOptions = stacktrace.stackParserFromStackParserOptions; | ||
| exports.stripSentryFramesAndReverse = stacktrace.stripSentryFramesAndReverse; | ||
| exports.isMatchingPattern = string.isMatchingPattern; | ||
| exports.safeJoin = string.safeJoin; | ||
| exports.snipLine = string.snipLine; | ||
| exports.stringMatchesSomePattern = string.stringMatchesSomePattern; | ||
| exports.truncate = string.truncate; | ||
| exports.isNativeFunction = supports.isNativeFunction; | ||
| exports.supportsDOMError = supports.supportsDOMError; | ||
| exports.supportsDOMException = supports.supportsDOMException; | ||
| exports.supportsErrorEvent = supports.supportsErrorEvent; | ||
| exports.supportsFetch = supports.supportsFetch; | ||
| exports.supportsHistory = supports.supportsHistory; | ||
| exports.supportsNativeFetch = supports.supportsNativeFetch; | ||
| exports.supportsReferrerPolicy = supports.supportsReferrerPolicy; | ||
| exports.supportsReportingObserver = supports.supportsReportingObserver; | ||
| exports.SyncPromise = syncpromise.SyncPromise; | ||
| exports.rejectedSyncPromise = syncpromise.rejectedSyncPromise; | ||
| exports.resolvedSyncPromise = syncpromise.resolvedSyncPromise; | ||
| exports.browserPerformanceTimeOrigin = time.browserPerformanceTimeOrigin; | ||
| exports.dateTimestampInSeconds = time.dateTimestampInSeconds; | ||
| exports.timestampInSeconds = time.timestampInSeconds; | ||
| exports.TRACEPARENT_REGEXP = tracing.TRACEPARENT_REGEXP; | ||
| exports.extractTraceparentData = tracing.extractTraceparentData; | ||
| exports.generateSentryTraceHeader = tracing.generateSentryTraceHeader; | ||
| exports.generateTraceparentHeader = tracing.generateTraceparentHeader; | ||
| exports.propagationContextFromHeaders = tracing.propagationContextFromHeaders; | ||
| exports.shouldContinueTrace = tracing.shouldContinueTrace; | ||
| exports.getSDKSource = env.getSDKSource; | ||
| exports.isBrowserBundle = env.isBrowserBundle; | ||
| exports.addItemToEnvelope = envelope.addItemToEnvelope; | ||
| exports.createAttachmentEnvelopeItem = envelope.createAttachmentEnvelopeItem; | ||
| exports.createEnvelope = envelope.createEnvelope; | ||
| exports.createEventEnvelopeHeaders = envelope.createEventEnvelopeHeaders; | ||
| exports.createSpanEnvelopeItem = envelope.createSpanEnvelopeItem; | ||
| exports.envelopeContainsItemType = envelope.envelopeContainsItemType; | ||
| exports.envelopeItemTypeToDataCategory = envelope.envelopeItemTypeToDataCategory; | ||
| exports.forEachEnvelopeItem = envelope.forEachEnvelopeItem; | ||
| exports.getSdkMetadataForEnvelopeHeader = envelope.getSdkMetadataForEnvelopeHeader; | ||
| exports.parseEnvelope = envelope.parseEnvelope; | ||
| exports.serializeEnvelope = envelope.serializeEnvelope; | ||
| exports.createClientReportEnvelope = clientreport.createClientReportEnvelope; | ||
| exports.DEFAULT_RETRY_AFTER = ratelimit.DEFAULT_RETRY_AFTER; | ||
| exports.disabledUntil = ratelimit.disabledUntil; | ||
| exports.isRateLimited = ratelimit.isRateLimited; | ||
| exports.parseRetryAfterHeader = ratelimit.parseRetryAfterHeader; | ||
| exports.updateRateLimits = ratelimit.updateRateLimits; | ||
| exports.MAX_BAGGAGE_STRING_LENGTH = baggage.MAX_BAGGAGE_STRING_LENGTH; | ||
| exports.SENTRY_BAGGAGE_KEY_PREFIX = baggage.SENTRY_BAGGAGE_KEY_PREFIX; | ||
| exports.SENTRY_BAGGAGE_KEY_PREFIX_REGEX = baggage.SENTRY_BAGGAGE_KEY_PREFIX_REGEX; | ||
| exports.baggageHeaderToDynamicSamplingContext = baggage.baggageHeaderToDynamicSamplingContext; | ||
| exports.dynamicSamplingContextToSentryBaggageHeader = baggage.dynamicSamplingContextToSentryBaggageHeader; | ||
| exports.mergeBaggageHeaders = baggage.mergeBaggageHeaders; | ||
| exports.objectToBaggageHeader = baggage.objectToBaggageHeader; | ||
| exports.parseBaggageHeader = baggage.parseBaggageHeader; | ||
| exports.getHttpSpanDetailsFromUrlObject = url.getHttpSpanDetailsFromUrlObject; | ||
| exports.getSanitizedUrlString = url.getSanitizedUrlString; | ||
| exports.getSanitizedUrlStringFromUrlObject = url.getSanitizedUrlStringFromUrlObject; | ||
| exports.isURLObjectRelative = url.isURLObjectRelative; | ||
| exports.parseStringToURLObject = url.parseStringToURLObject; | ||
| exports.parseUrl = url.parseUrl; | ||
| exports.stripDataUrlContent = url.stripDataUrlContent; | ||
| exports.stripUrlQueryAndFragment = url.stripUrlQueryAndFragment; | ||
| exports._INTERNAL_enhanceErrorWithSentryInfo = eventbuilder._enhanceErrorWithSentryInfo; | ||
| exports.eventFromMessage = eventbuilder.eventFromMessage; | ||
| exports.eventFromUnknownInput = eventbuilder.eventFromUnknownInput; | ||
| exports.exceptionFromError = eventbuilder.exceptionFromError; | ||
| exports.parseStackFrames = eventbuilder.parseStackFrames; | ||
| exports.LRUMap = lru.LRUMap; | ||
| exports.generateSpanId = propagationContext.generateSpanId; | ||
| exports.generateTraceId = propagationContext.generateTraceId; | ||
| exports.SDK_VERSION = version.SDK_VERSION; | ||
| exports.getDebugImagesForResources = debugIds.getDebugImagesForResources; | ||
| exports.getFilenameToDebugIdMap = debugIds.getFilenameToDebugIdMap; | ||
| exports.getFilenameToMetadataMap = metadata.getFilenameToMetadataMap; | ||
| exports.escapeStringForRegex = escapeStringForRegex.escapeStringForRegex; | ||
| exports._INTERNAL_safeDateNow = randomSafeContext.safeDateNow; | ||
| exports._INTERNAL_safeMathRandom = randomSafeContext.safeMathRandom; | ||
| exports._INTERNAL_withRandomSafeContext = randomSafeContext.withRandomSafeContext; | ||
| exports.getComponentName = browser.getComponentName; | ||
| exports.getLocationHref = browser.getLocationHref; | ||
| exports.htmlTreeAsString = browser.htmlTreeAsString; | ||
| exports.instrumentLangChainEmbeddings = embeddings.instrumentLangChainEmbeddings; | ||
| //# sourceMappingURL=browser.js.map |
| {"version":3,"file":"browser.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const errors = require('./tracing/errors.js'); | ||
| const utils$1 = require('./tracing/utils.js'); | ||
| const idleSpan = require('./tracing/idleSpan.js'); | ||
| const sentrySpan = require('./tracing/sentrySpan.js'); | ||
| const sentryNonRecordingSpan = require('./tracing/sentryNonRecordingSpan.js'); | ||
| const spanstatus = require('./tracing/spanstatus.js'); | ||
| const trace = require('./tracing/trace.js'); | ||
| const dynamicSamplingContext = require('./tracing/dynamicSamplingContext.js'); | ||
| const measurement = require('./tracing/measurement.js'); | ||
| const sampling = require('./tracing/sampling.js'); | ||
| const logSpans = require('./tracing/logSpans.js'); | ||
| const captureSpan = require('./tracing/spans/captureSpan.js'); | ||
| const semanticAttributes = require('./semanticAttributes.js'); | ||
| const envelope$1 = require('./envelope.js'); | ||
| const exports$1 = require('./exports.js'); | ||
| const currentScopes = require('./currentScopes.js'); | ||
| const defaultScopes = require('./defaultScopes.js'); | ||
| const index$7 = require('./asyncContext/index.js'); | ||
| const carrier = require('./carrier.js'); | ||
| const session = require('./session.js'); | ||
| const scope = require('./scope.js'); | ||
| const eventProcessors = require('./eventProcessors.js'); | ||
| const api = require('./api.js'); | ||
| const client = require('./client.js'); | ||
| const sdk = require('./sdk.js'); | ||
| const base = require('./transports/base.js'); | ||
| const offline = require('./transports/offline.js'); | ||
| const multiplexed = require('./transports/multiplexed.js'); | ||
| const integration = require('./integration.js'); | ||
| const providerSkip = require('./utils/ai/providerSkip.js'); | ||
| const envToBool = require('./utils/envToBool.js'); | ||
| const scopeData = require('./utils/scopeData.js'); | ||
| const prepareEvent = require('./utils/prepareEvent.js'); | ||
| const checkin = require('./checkin.js'); | ||
| const hasSpansEnabled = require('./utils/hasSpansEnabled.js'); | ||
| const beforeSendSpan = require('./tracing/spans/beforeSendSpan.js'); | ||
| const isSentryRequestUrl = require('./utils/isSentryRequestUrl.js'); | ||
| const handleCallbackErrors = require('./utils/handleCallbackErrors.js'); | ||
| const parameterize = require('./utils/parameterize.js'); | ||
| const tunnel = require('./utils/tunnel.js'); | ||
| const ipAddress = require('./utils/ipAddress.js'); | ||
| const spanUtils = require('./utils/spanUtils.js'); | ||
| const spanOnScope = require('./utils/spanOnScope.js'); | ||
| const parseSampleRate = require('./utils/parseSampleRate.js'); | ||
| const sdkMetadata = require('./utils/sdkMetadata.js'); | ||
| const traceData = require('./utils/traceData.js'); | ||
| const tracePropagationTargets = require('./utils/tracePropagationTargets.js'); | ||
| const meta = require('./utils/meta.js'); | ||
| const debounce = require('./utils/debounce.js'); | ||
| const weakRef = require('./utils/weakRef.js'); | ||
| const shouldIgnoreSpan = require('./utils/should-ignore-span.js'); | ||
| const request = require('./utils/request.js'); | ||
| const constants$1 = require('./constants.js'); | ||
| const breadcrumbs = require('./breadcrumbs.js'); | ||
| const functiontostring = require('./integrations/functiontostring.js'); | ||
| const eventFilters = require('./integrations/eventFilters.js'); | ||
| const linkederrors = require('./integrations/linkederrors.js'); | ||
| const moduleMetadata = require('./integrations/moduleMetadata.js'); | ||
| const requestdata = require('./integrations/requestdata.js'); | ||
| const captureconsole = require('./integrations/captureconsole.js'); | ||
| const dedupe = require('./integrations/dedupe.js'); | ||
| const extraerrordata = require('./integrations/extraerrordata.js'); | ||
| const rewriteframes = require('./integrations/rewriteframes.js'); | ||
| const supabase = require('./integrations/supabase.js'); | ||
| const zoderrors = require('./integrations/zoderrors.js'); | ||
| const thirdPartyErrorsFilter = require('./integrations/third-party-errors-filter.js'); | ||
| const console$1 = require('./integrations/console.js'); | ||
| const featureFlagsIntegration = require('./integrations/featureFlags/featureFlagsIntegration.js'); | ||
| const growthbook = require('./integrations/featureFlags/growthbook.js'); | ||
| const conversationId = require('./integrations/conversationId.js'); | ||
| const profiling = require('./profiling.js'); | ||
| const fetch = require('./fetch.js'); | ||
| const feedback = require('./feedback.js'); | ||
| const internal = require('./logs/internal.js'); | ||
| const publicApi = require('./logs/public-api.js'); | ||
| const consoleIntegration = require('./logs/console-integration.js'); | ||
| const internal$1 = require('./metrics/internal.js'); | ||
| const publicApi$1 = require('./metrics/public-api.js'); | ||
| const consola = require('./integrations/consola.js'); | ||
| const index = require('./tracing/vercel-ai/index.js'); | ||
| const utils = require('./tracing/vercel-ai/utils.js'); | ||
| const constants$7 = require('./tracing/vercel-ai/constants.js'); | ||
| const index$6 = require('./tracing/openai/index.js'); | ||
| const constants$6 = require('./tracing/openai/constants.js'); | ||
| const index$3 = require('./tracing/anthropic-ai/index.js'); | ||
| const constants = require('./tracing/anthropic-ai/constants.js'); | ||
| const index$5 = require('./tracing/google-genai/index.js'); | ||
| const constants$2 = require('./tracing/google-genai/constants.js'); | ||
| const index$1 = require('./tracing/langchain/index.js'); | ||
| const constants$4 = require('./tracing/langchain/constants.js'); | ||
| const index$4 = require('./tracing/langgraph/index.js'); | ||
| const constants$5 = require('./tracing/langgraph/constants.js'); | ||
| const spanBuffer = require('./tracing/spans/spanBuffer.js'); | ||
| const hasSpanStreamingEnabled = require('./tracing/spans/hasSpanStreamingEnabled.js'); | ||
| const spanStreaming = require('./integrations/spanStreaming.js'); | ||
| const featureFlags = require('./utils/featureFlags.js'); | ||
| const aggregateErrors = require('./utils/aggregate-errors.js'); | ||
| const breadcrumbLogLevel = require('./utils/breadcrumb-log-level.js'); | ||
| const dsn = require('./utils/dsn.js'); | ||
| const error = require('./utils/error.js'); | ||
| const worldwide = require('./utils/worldwide.js'); | ||
| const console = require('./instrument/console.js'); | ||
| const fetch$1 = require('./instrument/fetch.js'); | ||
| const globalError = require('./instrument/globalError.js'); | ||
| const globalUnhandledRejection = require('./instrument/globalUnhandledRejection.js'); | ||
| const handlers = require('./instrument/handlers.js'); | ||
| const is = require('./utils/is.js'); | ||
| const isBrowser = require('./utils/isBrowser.js'); | ||
| const debugLogger = require('./utils/debug-logger.js'); | ||
| const misc = require('./utils/misc.js'); | ||
| const normalize = require('./utils/normalize.js'); | ||
| const normalizationHints = require('./utils/normalizationHints.js'); | ||
| const object = require('./utils/object.js'); | ||
| const path = require('./utils/path.js'); | ||
| const promisebuffer = require('./utils/promisebuffer.js'); | ||
| const severity = require('./utils/severity.js'); | ||
| const exports$2 = require('./utils/exports.js'); | ||
| const stacktrace = require('./utils/stacktrace.js'); | ||
| const string = require('./utils/string.js'); | ||
| const supports = require('./utils/supports.js'); | ||
| const syncpromise = require('./utils/syncpromise.js'); | ||
| const time = require('./utils/time.js'); | ||
| const tracing = require('./utils/tracing.js'); | ||
| const env = require('./utils/env.js'); | ||
| const envelope = require('./utils/envelope.js'); | ||
| const clientreport = require('./utils/clientreport.js'); | ||
| const ratelimit = require('./utils/ratelimit.js'); | ||
| const baggage = require('./utils/baggage.js'); | ||
| const url = require('./utils/url.js'); | ||
| const eventbuilder = require('./utils/eventbuilder.js'); | ||
| const lru = require('./utils/lru.js'); | ||
| const propagationContext = require('./utils/propagationContext.js'); | ||
| const version = require('./utils/version.js'); | ||
| const debugIds = require('./utils/debug-ids.js'); | ||
| const metadata = require('./metadata.js'); | ||
| const escapeStringForRegex = require('./vendor/escapeStringForRegex.js'); | ||
| const randomSafeContext = require('./utils/randomSafeContext.js'); | ||
| const serverRuntimeClient = require('./server-runtime-client.js'); | ||
| const trpc = require('./trpc.js'); | ||
| const index$8 = require('./integrations/mcp-server/index.js'); | ||
| const node = require('./utils/node.js'); | ||
| const nodeStackTrace = require('./utils/node-stack-trace.js'); | ||
| const vercelWaitUntil = require('./utils/vercelWaitUntil.js'); | ||
| const flushIfServerless = require('./utils/flushIfServerless.js'); | ||
| const anr = require('./utils/anr.js'); | ||
| const timer = require('./utils/timer.js'); | ||
| const index$2 = require('./integrations/express/index.js'); | ||
| const postgresjs = require('./integrations/postgresjs.js'); | ||
| const clientPatch = require('./integrations/http/client-patch.js'); | ||
| const clientSubscriptions = require('./integrations/http/client-subscriptions.js'); | ||
| const addOutgoingRequestBreadcrumb = require('./integrations/http/add-outgoing-request-breadcrumb.js'); | ||
| const getRequestUrl = require('./integrations/http/get-request-url.js'); | ||
| const constants$3 = require('./integrations/http/constants.js'); | ||
| const embeddings = require('./tracing/langchain/embeddings.js'); | ||
| exports.registerSpanErrorInstrumentation = errors.registerSpanErrorInstrumentation; | ||
| exports.getCapturedScopesOnSpan = utils$1.getCapturedScopesOnSpan; | ||
| exports.setCapturedScopesOnSpan = utils$1.setCapturedScopesOnSpan; | ||
| exports.TRACING_DEFAULTS = idleSpan.TRACING_DEFAULTS; | ||
| exports.startIdleSpan = idleSpan.startIdleSpan; | ||
| exports.SentrySpan = sentrySpan.SentrySpan; | ||
| exports.SentryNonRecordingSpan = sentryNonRecordingSpan.SentryNonRecordingSpan; | ||
| exports.SPAN_STATUS_ERROR = spanstatus.SPAN_STATUS_ERROR; | ||
| exports.SPAN_STATUS_OK = spanstatus.SPAN_STATUS_OK; | ||
| exports.SPAN_STATUS_UNSET = spanstatus.SPAN_STATUS_UNSET; | ||
| exports.getSpanStatusFromHttpCode = spanstatus.getSpanStatusFromHttpCode; | ||
| exports.setHttpStatus = spanstatus.setHttpStatus; | ||
| exports.SUPPRESS_TRACING_KEY = trace.SUPPRESS_TRACING_KEY; | ||
| exports.continueTrace = trace.continueTrace; | ||
| exports.startInactiveSpan = trace.startInactiveSpan; | ||
| exports.startNewTrace = trace.startNewTrace; | ||
| exports.startSpan = trace.startSpan; | ||
| exports.startSpanManual = trace.startSpanManual; | ||
| exports.suppressTracing = trace.suppressTracing; | ||
| exports.withActiveSpan = trace.withActiveSpan; | ||
| exports.getDynamicSamplingContextFromClient = dynamicSamplingContext.getDynamicSamplingContextFromClient; | ||
| exports.getDynamicSamplingContextFromScope = dynamicSamplingContext.getDynamicSamplingContextFromScope; | ||
| exports.getDynamicSamplingContextFromSpan = dynamicSamplingContext.getDynamicSamplingContextFromSpan; | ||
| exports.spanToBaggageHeader = dynamicSamplingContext.spanToBaggageHeader; | ||
| exports.setMeasurement = measurement.setMeasurement; | ||
| exports.timedEventsToMeasurements = measurement.timedEventsToMeasurements; | ||
| exports.sampleSpan = sampling.sampleSpan; | ||
| exports.logSpanEnd = logSpans.logSpanEnd; | ||
| exports.logSpanStart = logSpans.logSpanStart; | ||
| exports.captureSpan = captureSpan.captureSpan; | ||
| exports.safeSetSpanJSONAttributes = captureSpan.safeSetSpanJSONAttributes; | ||
| exports.GEN_AI_CONVERSATION_ID_ATTRIBUTE = semanticAttributes.GEN_AI_CONVERSATION_ID_ATTRIBUTE; | ||
| exports.SEMANTIC_ATTRIBUTE_CACHE_HIT = semanticAttributes.SEMANTIC_ATTRIBUTE_CACHE_HIT; | ||
| exports.SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = semanticAttributes.SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE; | ||
| exports.SEMANTIC_ATTRIBUTE_CACHE_KEY = semanticAttributes.SEMANTIC_ATTRIBUTE_CACHE_KEY; | ||
| exports.SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = semanticAttributes.SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME; | ||
| exports.SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = semanticAttributes.SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD; | ||
| exports.SEMANTIC_ATTRIBUTE_PROFILE_ID = semanticAttributes.SEMANTIC_ATTRIBUTE_PROFILE_ID; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_OP = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_OP; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_RELEASE; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME; | ||
| exports.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE; | ||
| exports.SEMANTIC_ATTRIBUTE_URL_FULL = semanticAttributes.SEMANTIC_ATTRIBUTE_URL_FULL; | ||
| exports.SEMANTIC_ATTRIBUTE_USER_EMAIL = semanticAttributes.SEMANTIC_ATTRIBUTE_USER_EMAIL; | ||
| exports.SEMANTIC_ATTRIBUTE_USER_ID = semanticAttributes.SEMANTIC_ATTRIBUTE_USER_ID; | ||
| exports.SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = semanticAttributes.SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS; | ||
| exports.SEMANTIC_ATTRIBUTE_USER_USERNAME = semanticAttributes.SEMANTIC_ATTRIBUTE_USER_USERNAME; | ||
| exports.SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = semanticAttributes.SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE; | ||
| exports.createEventEnvelope = envelope$1.createEventEnvelope; | ||
| exports.createSessionEnvelope = envelope$1.createSessionEnvelope; | ||
| exports.createSpanEnvelope = envelope$1.createSpanEnvelope; | ||
| exports.addEventProcessor = exports$1.addEventProcessor; | ||
| exports.captureCheckIn = exports$1.captureCheckIn; | ||
| exports.captureEvent = exports$1.captureEvent; | ||
| exports.captureException = exports$1.captureException; | ||
| exports.captureMessage = exports$1.captureMessage; | ||
| exports.captureSession = exports$1.captureSession; | ||
| exports.close = exports$1.close; | ||
| exports.endSession = exports$1.endSession; | ||
| exports.flush = exports$1.flush; | ||
| exports.isEnabled = exports$1.isEnabled; | ||
| exports.isInitialized = exports$1.isInitialized; | ||
| exports.lastEventId = exports$1.lastEventId; | ||
| exports.setContext = exports$1.setContext; | ||
| exports.setConversationId = exports$1.setConversationId; | ||
| exports.setExtra = exports$1.setExtra; | ||
| exports.setExtras = exports$1.setExtras; | ||
| exports.setTag = exports$1.setTag; | ||
| exports.setTags = exports$1.setTags; | ||
| exports.setUser = exports$1.setUser; | ||
| exports.startSession = exports$1.startSession; | ||
| exports.withMonitor = exports$1.withMonitor; | ||
| exports.getClient = currentScopes.getClient; | ||
| exports.getCurrentScope = currentScopes.getCurrentScope; | ||
| exports.getExternalPropagationContext = currentScopes.getExternalPropagationContext; | ||
| exports.getGlobalScope = currentScopes.getGlobalScope; | ||
| exports.getIsolationScope = currentScopes.getIsolationScope; | ||
| exports.getTraceContextFromScope = currentScopes.getTraceContextFromScope; | ||
| exports.hasExternalPropagationContext = currentScopes.hasExternalPropagationContext; | ||
| exports.registerExternalPropagationContext = currentScopes.registerExternalPropagationContext; | ||
| exports.withIsolationScope = currentScopes.withIsolationScope; | ||
| exports.withScope = currentScopes.withScope; | ||
| exports.getDefaultCurrentScope = defaultScopes.getDefaultCurrentScope; | ||
| exports.getDefaultIsolationScope = defaultScopes.getDefaultIsolationScope; | ||
| exports.setAsyncContextStrategy = index$7.setAsyncContextStrategy; | ||
| exports.getGlobalSingleton = carrier.getGlobalSingleton; | ||
| exports.getMainCarrier = carrier.getMainCarrier; | ||
| exports.closeSession = session.closeSession; | ||
| exports.makeSession = session.makeSession; | ||
| exports.updateSession = session.updateSession; | ||
| exports.Scope = scope.Scope; | ||
| exports.notifyEventProcessors = eventProcessors.notifyEventProcessors; | ||
| exports.SENTRY_API_VERSION = api.SENTRY_API_VERSION; | ||
| exports.getEnvelopeEndpointWithUrlEncodedAuth = api.getEnvelopeEndpointWithUrlEncodedAuth; | ||
| exports.getReportDialogEndpoint = api.getReportDialogEndpoint; | ||
| exports.Client = client.Client; | ||
| exports.initAndBind = sdk.initAndBind; | ||
| exports.setCurrentClient = sdk.setCurrentClient; | ||
| exports.createTransport = base.createTransport; | ||
| exports.makeOfflineTransport = offline.makeOfflineTransport; | ||
| exports.MULTIPLEXED_TRANSPORT_EXTRA_KEY = multiplexed.MULTIPLEXED_TRANSPORT_EXTRA_KEY; | ||
| exports.makeMultiplexedTransport = multiplexed.makeMultiplexedTransport; | ||
| exports.addIntegration = integration.addIntegration; | ||
| exports.defineIntegration = integration.defineIntegration; | ||
| exports.getIntegrationsToSetup = integration.getIntegrationsToSetup; | ||
| exports.installedIntegrations = integration.installedIntegrations; | ||
| exports._INTERNAL_clearAiProviderSkips = providerSkip._INTERNAL_clearAiProviderSkips; | ||
| exports._INTERNAL_shouldSkipAiProviderWrapping = providerSkip._INTERNAL_shouldSkipAiProviderWrapping; | ||
| exports._INTERNAL_skipAiProviderWrapping = providerSkip._INTERNAL_skipAiProviderWrapping; | ||
| exports.envToBool = envToBool.envToBool; | ||
| exports.applyScopeDataToEvent = scopeData.applyScopeDataToEvent; | ||
| exports.getCombinedScopeData = scopeData.getCombinedScopeData; | ||
| exports.mergeScopeData = scopeData.mergeScopeData; | ||
| exports.prepareEvent = prepareEvent.prepareEvent; | ||
| exports.createCheckInEnvelope = checkin.createCheckInEnvelope; | ||
| exports.hasSpansEnabled = hasSpansEnabled.hasSpansEnabled; | ||
| exports.isStreamedBeforeSendSpanCallback = beforeSendSpan.isStreamedBeforeSendSpanCallback; | ||
| exports.withStreamedSpan = beforeSendSpan.withStreamedSpan; | ||
| exports.isSentryRequestUrl = isSentryRequestUrl.isSentryRequestUrl; | ||
| exports.handleCallbackErrors = handleCallbackErrors.handleCallbackErrors; | ||
| exports.fmt = parameterize.fmt; | ||
| exports.parameterize = parameterize.parameterize; | ||
| exports.handleTunnelRequest = tunnel.handleTunnelRequest; | ||
| exports.addAutoIpAddressToSession = ipAddress.addAutoIpAddressToSession; | ||
| exports.addAutoIpAddressToUser = ipAddress.addAutoIpAddressToUser; | ||
| exports.INTERNAL_getSegmentSpan = spanUtils.INTERNAL_getSegmentSpan; | ||
| exports.addChildSpanToSpan = spanUtils.addChildSpanToSpan; | ||
| exports.convertSpanLinksForEnvelope = spanUtils.convertSpanLinksForEnvelope; | ||
| exports.getActiveSpan = spanUtils.getActiveSpan; | ||
| exports.getRootSpan = spanUtils.getRootSpan; | ||
| exports.getSpanDescendants = spanUtils.getSpanDescendants; | ||
| exports.getStatusMessage = spanUtils.getStatusMessage; | ||
| exports.spanIsSampled = spanUtils.spanIsSampled; | ||
| exports.spanTimeInputToSeconds = spanUtils.spanTimeInputToSeconds; | ||
| exports.spanToJSON = spanUtils.spanToJSON; | ||
| exports.spanToStreamedSpanJSON = spanUtils.spanToStreamedSpanJSON; | ||
| exports.spanToTraceContext = spanUtils.spanToTraceContext; | ||
| exports.spanToTraceHeader = spanUtils.spanToTraceHeader; | ||
| exports.updateSpanName = spanUtils.updateSpanName; | ||
| exports._INTERNAL_setSpanForScope = spanOnScope._setSpanForScope; | ||
| exports.parseSampleRate = parseSampleRate.parseSampleRate; | ||
| exports.applySdkMetadata = sdkMetadata.applySdkMetadata; | ||
| exports.getTraceData = traceData.getTraceData; | ||
| exports.shouldPropagateTraceForUrl = tracePropagationTargets.shouldPropagateTraceForUrl; | ||
| exports.getTraceMetaTags = meta.getTraceMetaTags; | ||
| exports.debounce = debounce.debounce; | ||
| exports.derefWeakRef = weakRef.derefWeakRef; | ||
| exports.makeWeakRef = weakRef.makeWeakRef; | ||
| exports.shouldIgnoreSpan = shouldIgnoreSpan.shouldIgnoreSpan; | ||
| exports.MAX_BODY_BYTE_LENGTH = request.MAX_BODY_BYTE_LENGTH; | ||
| exports.captureBodyFromWinterCGRequest = request.captureBodyFromWinterCGRequest; | ||
| exports.extractQueryParamsFromUrl = request.extractQueryParamsFromUrl; | ||
| exports.getMaxBodyByteLength = request.getMaxBodyByteLength; | ||
| exports.headersToDict = request.headersToDict; | ||
| exports.httpHeadersToSpanAttributes = request.httpHeadersToSpanAttributes; | ||
| exports.httpRequestToRequestData = request.httpRequestToRequestData; | ||
| exports.winterCGHeadersToDict = request.winterCGHeadersToDict; | ||
| exports.winterCGRequestToRequestData = request.winterCGRequestToRequestData; | ||
| exports.DEFAULT_ENVIRONMENT = constants$1.DEFAULT_ENVIRONMENT; | ||
| exports.DEV_ENVIRONMENT = constants$1.DEV_ENVIRONMENT; | ||
| exports.addBreadcrumb = breadcrumbs.addBreadcrumb; | ||
| exports.functionToStringIntegration = functiontostring.functionToStringIntegration; | ||
| exports.eventFiltersIntegration = eventFilters.eventFiltersIntegration; | ||
| exports.inboundFiltersIntegration = eventFilters.inboundFiltersIntegration; | ||
| exports.linkedErrorsIntegration = linkederrors.linkedErrorsIntegration; | ||
| exports.moduleMetadataIntegration = moduleMetadata.moduleMetadataIntegration; | ||
| exports.requestDataIntegration = requestdata.requestDataIntegration; | ||
| exports.captureConsoleIntegration = captureconsole.captureConsoleIntegration; | ||
| exports.dedupeIntegration = dedupe.dedupeIntegration; | ||
| exports.extraErrorDataIntegration = extraerrordata.extraErrorDataIntegration; | ||
| exports.rewriteFramesIntegration = rewriteframes.rewriteFramesIntegration; | ||
| exports.instrumentSupabaseClient = supabase.instrumentSupabaseClient; | ||
| exports.supabaseIntegration = supabase.supabaseIntegration; | ||
| exports.zodErrorsIntegration = zoderrors.zodErrorsIntegration; | ||
| exports.thirdPartyErrorFilterIntegration = thirdPartyErrorsFilter.thirdPartyErrorFilterIntegration; | ||
| exports.consoleIntegration = console$1.consoleIntegration; | ||
| exports.featureFlagsIntegration = featureFlagsIntegration.featureFlagsIntegration; | ||
| exports.growthbookIntegration = growthbook.growthbookIntegration; | ||
| exports.conversationIdIntegration = conversationId.conversationIdIntegration; | ||
| exports.profiler = profiling.profiler; | ||
| exports._INTERNAL_getTracingHeadersForFetchRequest = fetch._INTERNAL_getTracingHeadersForFetchRequest; | ||
| exports.instrumentFetchRequest = fetch.instrumentFetchRequest; | ||
| exports.captureFeedback = feedback.captureFeedback; | ||
| exports._INTERNAL_captureLog = internal._INTERNAL_captureLog; | ||
| exports._INTERNAL_captureSerializedLog = internal._INTERNAL_captureSerializedLog; | ||
| exports._INTERNAL_flushLogsBuffer = internal._INTERNAL_flushLogsBuffer; | ||
| exports.logger = publicApi; | ||
| exports.consoleLoggingIntegration = consoleIntegration.consoleLoggingIntegration; | ||
| exports._INTERNAL_captureMetric = internal$1._INTERNAL_captureMetric; | ||
| exports._INTERNAL_captureSerializedMetric = internal$1._INTERNAL_captureSerializedMetric; | ||
| exports._INTERNAL_flushMetricsBuffer = internal$1._INTERNAL_flushMetricsBuffer; | ||
| exports.metrics = publicApi$1; | ||
| exports.createConsolaReporter = consola.createConsolaReporter; | ||
| exports.addVercelAiProcessors = index.addVercelAiProcessors; | ||
| exports._INTERNAL_cleanupToolCallSpanContext = utils._INTERNAL_cleanupToolCallSpanContext; | ||
| exports._INTERNAL_getSpanContextForToolCallId = utils._INTERNAL_getSpanContextForToolCallId; | ||
| exports._INTERNAL_toolCallSpanContextMap = constants$7.toolCallSpanContextMap; | ||
| exports.instrumentOpenAiClient = index$6.instrumentOpenAiClient; | ||
| exports.OPENAI_INTEGRATION_NAME = constants$6.OPENAI_INTEGRATION_NAME; | ||
| exports.instrumentAnthropicAiClient = index$3.instrumentAnthropicAiClient; | ||
| exports.ANTHROPIC_AI_INTEGRATION_NAME = constants.ANTHROPIC_AI_INTEGRATION_NAME; | ||
| exports.instrumentGoogleGenAIClient = index$5.instrumentGoogleGenAIClient; | ||
| exports.GOOGLE_GENAI_INTEGRATION_NAME = constants$2.GOOGLE_GENAI_INTEGRATION_NAME; | ||
| exports.createLangChainCallbackHandler = index$1.createLangChainCallbackHandler; | ||
| exports.LANGCHAIN_INTEGRATION_NAME = constants$4.LANGCHAIN_INTEGRATION_NAME; | ||
| exports.instrumentCreateReactAgent = index$4.instrumentCreateReactAgent; | ||
| exports.instrumentLangGraph = index$4.instrumentLangGraph; | ||
| exports.instrumentStateGraphCompile = index$4.instrumentStateGraphCompile; | ||
| exports.LANGGRAPH_INTEGRATION_NAME = constants$5.LANGGRAPH_INTEGRATION_NAME; | ||
| exports.SpanBuffer = spanBuffer.SpanBuffer; | ||
| exports.hasSpanStreamingEnabled = hasSpanStreamingEnabled.hasSpanStreamingEnabled; | ||
| exports.spanStreamingIntegration = spanStreaming.spanStreamingIntegration; | ||
| exports._INTERNAL_FLAG_BUFFER_SIZE = featureFlags._INTERNAL_FLAG_BUFFER_SIZE; | ||
| exports._INTERNAL_MAX_FLAGS_PER_SPAN = featureFlags._INTERNAL_MAX_FLAGS_PER_SPAN; | ||
| exports._INTERNAL_addFeatureFlagToActiveSpan = featureFlags._INTERNAL_addFeatureFlagToActiveSpan; | ||
| exports._INTERNAL_copyFlagsFromScopeToEvent = featureFlags._INTERNAL_copyFlagsFromScopeToEvent; | ||
| exports._INTERNAL_insertFlagToScope = featureFlags._INTERNAL_insertFlagToScope; | ||
| exports.applyAggregateErrorsToEvent = aggregateErrors.applyAggregateErrorsToEvent; | ||
| exports.getBreadcrumbLogLevelFromHttpStatusCode = breadcrumbLogLevel.getBreadcrumbLogLevelFromHttpStatusCode; | ||
| exports.dsnFromString = dsn.dsnFromString; | ||
| exports.dsnToString = dsn.dsnToString; | ||
| exports.makeDsn = dsn.makeDsn; | ||
| exports.SentryError = error.SentryError; | ||
| exports.GLOBAL_OBJ = worldwide.GLOBAL_OBJ; | ||
| exports.addConsoleInstrumentationFilter = console.addConsoleInstrumentationFilter; | ||
| exports.addConsoleInstrumentationHandler = console.addConsoleInstrumentationHandler; | ||
| exports.addFetchEndInstrumentationHandler = fetch$1.addFetchEndInstrumentationHandler; | ||
| exports.addFetchInstrumentationHandler = fetch$1.addFetchInstrumentationHandler; | ||
| exports.addGlobalErrorInstrumentationHandler = globalError.addGlobalErrorInstrumentationHandler; | ||
| exports.addGlobalUnhandledRejectionInstrumentationHandler = globalUnhandledRejection.addGlobalUnhandledRejectionInstrumentationHandler; | ||
| exports.addHandler = handlers.addHandler; | ||
| exports.maybeInstrument = handlers.maybeInstrument; | ||
| exports.resetInstrumentationHandlers = handlers.resetInstrumentationHandlers; | ||
| exports.triggerHandlers = handlers.triggerHandlers; | ||
| exports.isDOMError = is.isDOMError; | ||
| exports.isDOMException = is.isDOMException; | ||
| exports.isElement = is.isElement; | ||
| exports.isError = is.isError; | ||
| exports.isErrorEvent = is.isErrorEvent; | ||
| exports.isEvent = is.isEvent; | ||
| exports.isInstanceOf = is.isInstanceOf; | ||
| exports.isParameterizedString = is.isParameterizedString; | ||
| exports.isPlainObject = is.isPlainObject; | ||
| exports.isPrimitive = is.isPrimitive; | ||
| exports.isRegExp = is.isRegExp; | ||
| exports.isString = is.isString; | ||
| exports.isSyntheticEvent = is.isSyntheticEvent; | ||
| exports.isThenable = is.isThenable; | ||
| exports.isVueViewModel = is.isVueViewModel; | ||
| exports.isBrowser = isBrowser.isBrowser; | ||
| exports.CONSOLE_LEVELS = debugLogger.CONSOLE_LEVELS; | ||
| exports.consoleSandbox = debugLogger.consoleSandbox; | ||
| exports.debug = debugLogger.debug; | ||
| exports.originalConsoleMethods = debugLogger.originalConsoleMethods; | ||
| exports.addContextToFrame = misc.addContextToFrame; | ||
| exports.addExceptionMechanism = misc.addExceptionMechanism; | ||
| exports.addExceptionTypeValue = misc.addExceptionTypeValue; | ||
| exports.checkOrSetAlreadyCaught = misc.checkOrSetAlreadyCaught; | ||
| exports.getEventDescription = misc.getEventDescription; | ||
| exports.isAlreadyCaptured = misc.isAlreadyCaptured; | ||
| exports.parseSemver = misc.parseSemver; | ||
| exports.uuid4 = misc.uuid4; | ||
| exports.normalize = normalize.normalize; | ||
| exports.normalizeToSize = normalize.normalizeToSize; | ||
| exports.normalizeUrlToBase = normalize.normalizeUrlToBase; | ||
| exports.setNormalizationDepthOverrideHint = normalizationHints.setNormalizationDepthOverrideHint; | ||
| exports.setSkipNormalizationHint = normalizationHints.setSkipNormalizationHint; | ||
| exports.addNonEnumerableProperty = object.addNonEnumerableProperty; | ||
| exports.convertToPlainObject = object.convertToPlainObject; | ||
| exports.dropUndefinedKeys = object.dropUndefinedKeys; | ||
| exports.extractExceptionKeysForMessage = object.extractExceptionKeysForMessage; | ||
| exports.fill = object.fill; | ||
| exports.getOriginalFunction = object.getOriginalFunction; | ||
| exports.markFunctionWrapped = object.markFunctionWrapped; | ||
| exports.objectify = object.objectify; | ||
| exports.basename = path.basename; | ||
| exports.dirname = path.dirname; | ||
| exports.isAbsolute = path.isAbsolute; | ||
| exports.join = path.join; | ||
| exports.normalizePath = path.normalizePath; | ||
| exports.relative = path.relative; | ||
| exports.resolve = path.resolve; | ||
| exports.SENTRY_BUFFER_FULL_ERROR = promisebuffer.SENTRY_BUFFER_FULL_ERROR; | ||
| exports.makePromiseBuffer = promisebuffer.makePromiseBuffer; | ||
| exports.severityLevelFromString = severity.severityLevelFromString; | ||
| exports.replaceExports = exports$2.replaceExports; | ||
| exports.UNKNOWN_FUNCTION = stacktrace.UNKNOWN_FUNCTION; | ||
| exports.createStackParser = stacktrace.createStackParser; | ||
| exports.getFramesFromEvent = stacktrace.getFramesFromEvent; | ||
| exports.getFunctionName = stacktrace.getFunctionName; | ||
| exports.stackParserFromStackParserOptions = stacktrace.stackParserFromStackParserOptions; | ||
| exports.stripSentryFramesAndReverse = stacktrace.stripSentryFramesAndReverse; | ||
| exports.isMatchingPattern = string.isMatchingPattern; | ||
| exports.safeJoin = string.safeJoin; | ||
| exports.snipLine = string.snipLine; | ||
| exports.stringMatchesSomePattern = string.stringMatchesSomePattern; | ||
| exports.truncate = string.truncate; | ||
| exports.isNativeFunction = supports.isNativeFunction; | ||
| exports.supportsDOMException = supports.supportsDOMException; | ||
| exports.supportsErrorEvent = supports.supportsErrorEvent; | ||
| exports.supportsFetch = supports.supportsFetch; | ||
| exports.supportsReferrerPolicy = supports.supportsReferrerPolicy; | ||
| exports.SyncPromise = syncpromise.SyncPromise; | ||
| exports.rejectedSyncPromise = syncpromise.rejectedSyncPromise; | ||
| exports.resolvedSyncPromise = syncpromise.resolvedSyncPromise; | ||
| exports.browserPerformanceTimeOrigin = time.browserPerformanceTimeOrigin; | ||
| exports.dateTimestampInSeconds = time.dateTimestampInSeconds; | ||
| exports.timestampInSeconds = time.timestampInSeconds; | ||
| exports.TRACEPARENT_REGEXP = tracing.TRACEPARENT_REGEXP; | ||
| exports.extractTraceparentData = tracing.extractTraceparentData; | ||
| exports.generateSentryTraceHeader = tracing.generateSentryTraceHeader; | ||
| exports.generateTraceparentHeader = tracing.generateTraceparentHeader; | ||
| exports.propagationContextFromHeaders = tracing.propagationContextFromHeaders; | ||
| exports.shouldContinueTrace = tracing.shouldContinueTrace; | ||
| exports.getSDKSource = env.getSDKSource; | ||
| exports.isBrowserBundle = env.isBrowserBundle; | ||
| exports.addItemToEnvelope = envelope.addItemToEnvelope; | ||
| exports.createAttachmentEnvelopeItem = envelope.createAttachmentEnvelopeItem; | ||
| exports.createEnvelope = envelope.createEnvelope; | ||
| exports.createEventEnvelopeHeaders = envelope.createEventEnvelopeHeaders; | ||
| exports.createSpanEnvelopeItem = envelope.createSpanEnvelopeItem; | ||
| exports.envelopeContainsItemType = envelope.envelopeContainsItemType; | ||
| exports.envelopeItemTypeToDataCategory = envelope.envelopeItemTypeToDataCategory; | ||
| exports.forEachEnvelopeItem = envelope.forEachEnvelopeItem; | ||
| exports.getSdkMetadataForEnvelopeHeader = envelope.getSdkMetadataForEnvelopeHeader; | ||
| exports.parseEnvelope = envelope.parseEnvelope; | ||
| exports.serializeEnvelope = envelope.serializeEnvelope; | ||
| exports.createClientReportEnvelope = clientreport.createClientReportEnvelope; | ||
| exports.DEFAULT_RETRY_AFTER = ratelimit.DEFAULT_RETRY_AFTER; | ||
| exports.disabledUntil = ratelimit.disabledUntil; | ||
| exports.isRateLimited = ratelimit.isRateLimited; | ||
| exports.parseRetryAfterHeader = ratelimit.parseRetryAfterHeader; | ||
| exports.updateRateLimits = ratelimit.updateRateLimits; | ||
| exports.MAX_BAGGAGE_STRING_LENGTH = baggage.MAX_BAGGAGE_STRING_LENGTH; | ||
| exports.SENTRY_BAGGAGE_KEY_PREFIX = baggage.SENTRY_BAGGAGE_KEY_PREFIX; | ||
| exports.SENTRY_BAGGAGE_KEY_PREFIX_REGEX = baggage.SENTRY_BAGGAGE_KEY_PREFIX_REGEX; | ||
| exports.baggageHeaderToDynamicSamplingContext = baggage.baggageHeaderToDynamicSamplingContext; | ||
| exports.dynamicSamplingContextToSentryBaggageHeader = baggage.dynamicSamplingContextToSentryBaggageHeader; | ||
| exports.mergeBaggageHeaders = baggage.mergeBaggageHeaders; | ||
| exports.objectToBaggageHeader = baggage.objectToBaggageHeader; | ||
| exports.parseBaggageHeader = baggage.parseBaggageHeader; | ||
| exports.getHttpSpanDetailsFromUrlObject = url.getHttpSpanDetailsFromUrlObject; | ||
| exports.getSanitizedUrlString = url.getSanitizedUrlString; | ||
| exports.getSanitizedUrlStringFromUrlObject = url.getSanitizedUrlStringFromUrlObject; | ||
| exports.isURLObjectRelative = url.isURLObjectRelative; | ||
| exports.parseStringToURLObject = url.parseStringToURLObject; | ||
| exports.parseUrl = url.parseUrl; | ||
| exports.stripDataUrlContent = url.stripDataUrlContent; | ||
| exports.stripUrlQueryAndFragment = url.stripUrlQueryAndFragment; | ||
| exports._INTERNAL_enhanceErrorWithSentryInfo = eventbuilder._enhanceErrorWithSentryInfo; | ||
| exports.eventFromMessage = eventbuilder.eventFromMessage; | ||
| exports.eventFromUnknownInput = eventbuilder.eventFromUnknownInput; | ||
| exports.exceptionFromError = eventbuilder.exceptionFromError; | ||
| exports.parseStackFrames = eventbuilder.parseStackFrames; | ||
| exports.LRUMap = lru.LRUMap; | ||
| exports.generateSpanId = propagationContext.generateSpanId; | ||
| exports.generateTraceId = propagationContext.generateTraceId; | ||
| exports.SDK_VERSION = version.SDK_VERSION; | ||
| exports.getDebugImagesForResources = debugIds.getDebugImagesForResources; | ||
| exports.getFilenameToDebugIdMap = debugIds.getFilenameToDebugIdMap; | ||
| exports.getFilenameToMetadataMap = metadata.getFilenameToMetadataMap; | ||
| exports.escapeStringForRegex = escapeStringForRegex.escapeStringForRegex; | ||
| exports._INTERNAL_safeDateNow = randomSafeContext.safeDateNow; | ||
| exports._INTERNAL_safeMathRandom = randomSafeContext.safeMathRandom; | ||
| exports._INTERNAL_withRandomSafeContext = randomSafeContext.withRandomSafeContext; | ||
| exports.ServerRuntimeClient = serverRuntimeClient.ServerRuntimeClient; | ||
| exports.trpcMiddleware = trpc.trpcMiddleware; | ||
| exports.wrapMcpServerWithSentry = index$8.wrapMcpServerWithSentry; | ||
| exports.isNodeEnv = node.isNodeEnv; | ||
| exports.loadModule = node.loadModule; | ||
| exports.filenameIsInApp = nodeStackTrace.filenameIsInApp; | ||
| exports.node = nodeStackTrace.node; | ||
| exports.nodeStackLineParser = nodeStackTrace.nodeStackLineParser; | ||
| exports.vercelWaitUntil = vercelWaitUntil.vercelWaitUntil; | ||
| exports.flushIfServerless = flushIfServerless.flushIfServerless; | ||
| exports.callFrameToStackFrame = anr.callFrameToStackFrame; | ||
| exports.watchdogTimer = anr.watchdogTimer; | ||
| exports._INTERNAL_safeUnref = timer.safeUnref; | ||
| exports.expressErrorHandler = index$2.expressErrorHandler; | ||
| exports.patchExpressModule = index$2.patchExpressModule; | ||
| exports.setupExpressErrorHandler = index$2.setupExpressErrorHandler; | ||
| exports.instrumentPostgresJsSql = postgresjs.instrumentPostgresJsSql; | ||
| exports.patchHttpModuleClient = clientPatch.patchHttpModuleClient; | ||
| exports.getHttpClientSubscriptions = clientSubscriptions.getHttpClientSubscriptions; | ||
| exports.addOutgoingRequestBreadcrumb = addOutgoingRequestBreadcrumb.addOutgoingRequestBreadcrumb; | ||
| exports.getRequestOptions = getRequestUrl.getRequestOptions; | ||
| exports.getRequestUrl = getRequestUrl.getRequestUrl; | ||
| exports.getRequestUrlFromClientRequest = getRequestUrl.getRequestUrlFromClientRequest; | ||
| exports.getRequestUrlObject = getRequestUrl.getRequestUrlObject; | ||
| exports.HTTP_ON_CLIENT_REQUEST = constants$3.HTTP_ON_CLIENT_REQUEST; | ||
| exports.HTTP_ON_SERVER_REQUEST = constants$3.HTTP_ON_SERVER_REQUEST; | ||
| exports.instrumentLangChainEmbeddings = embeddings.instrumentLangChainEmbeddings; | ||
| //# sourceMappingURL=server.js.map |
| {"version":3,"file":"server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const isBrowser = require('../../utils/isBrowser.js'); | ||
| const hasSpanStreamingEnabled = require('./hasSpanStreamingEnabled.js'); | ||
| const spanJsonToStreamedSpan = require('./spanJsonToStreamedSpan.js'); | ||
| /** | ||
| * Extracts gen_ai spans from a transaction event, converts them to span v2 format, | ||
| * and returns them as a SpanContainerItem. | ||
| * | ||
| * Only applies to static mode (non-streaming) transactions. | ||
| * | ||
| * WARNING: This function mutates `event.spans` by removing the extracted gen_ai spans | ||
| * from the array. Call this before creating the event envelope so the transaction | ||
| * item does not include the extracted spans. | ||
| */ | ||
| function extractGenAiSpansFromEvent(event, client) { | ||
| if ( | ||
| event.type !== 'transaction' || | ||
| !event.spans?.length || | ||
| !event.sdkProcessingMetadata?.hasGenAiSpans || | ||
| !client.getOptions().streamGenAiSpans || | ||
| hasSpanStreamingEnabled.hasSpanStreamingEnabled(client) | ||
| ) { | ||
| return undefined; | ||
| } | ||
| const genAiSpans = []; | ||
| const remainingSpans = []; | ||
| for (const span of event.spans) { | ||
| if (span.op?.startsWith('gen_ai.')) { | ||
| genAiSpans.push(spanJsonToStreamedSpan.spanJsonToSerializedStreamedSpan(span)); | ||
| } else { | ||
| remainingSpans.push(span); | ||
| } | ||
| } | ||
| if (genAiSpans.length === 0) { | ||
| return undefined; | ||
| } | ||
| event.spans = remainingSpans; | ||
| const inferSetting = client.getOptions().sendDefaultPii ? 'auto' : 'never'; | ||
| return [ | ||
| { type: 'span', item_count: genAiSpans.length, content_type: 'application/vnd.sentry.items.span.v2+json' }, | ||
| { | ||
| version: 2, | ||
| ...(isBrowser.isBrowser() && { | ||
| ingest_settings: { infer_ip: inferSetting, infer_user_agent: inferSetting }, | ||
| }), | ||
| items: genAiSpans, | ||
| }, | ||
| ]; | ||
| } | ||
| exports.extractGenAiSpansFromEvent = extractGenAiSpansFromEvent; | ||
| //# sourceMappingURL=extractGenAiSpans.js.map |
| {"version":3,"file":"extractGenAiSpans.js","sources":["../../../../src/tracing/spans/extractGenAiSpans.ts"],"sourcesContent":["import type { Client } from '../../client';\nimport type { SpanContainerItem } from '../../types-hoist/envelope';\nimport type { Event } from '../../types-hoist/event';\nimport { isBrowser } from '../../utils/isBrowser';\nimport { hasSpanStreamingEnabled } from './hasSpanStreamingEnabled';\nimport { spanJsonToSerializedStreamedSpan } from './spanJsonToStreamedSpan';\n\n/**\n * Extracts gen_ai spans from a transaction event, converts them to span v2 format,\n * and returns them as a SpanContainerItem.\n *\n * Only applies to static mode (non-streaming) transactions.\n *\n * WARNING: This function mutates `event.spans` by removing the extracted gen_ai spans\n * from the array. Call this before creating the event envelope so the transaction\n * item does not include the extracted spans.\n */\nexport function extractGenAiSpansFromEvent(event: Event, client: Client): SpanContainerItem | undefined {\n if (\n event.type !== 'transaction' ||\n !event.spans?.length ||\n !event.sdkProcessingMetadata?.hasGenAiSpans ||\n !client.getOptions().streamGenAiSpans ||\n hasSpanStreamingEnabled(client)\n ) {\n return undefined;\n }\n\n const genAiSpans = [];\n const remainingSpans = [];\n\n for (const span of event.spans) {\n if (span.op?.startsWith('gen_ai.')) {\n genAiSpans.push(spanJsonToSerializedStreamedSpan(span));\n } else {\n remainingSpans.push(span);\n }\n }\n\n if (genAiSpans.length === 0) {\n return undefined;\n }\n\n event.spans = remainingSpans;\n\n const inferSetting = client.getOptions().sendDefaultPii ? 'auto' : 'never';\n\n return [\n { type: 'span', item_count: genAiSpans.length, content_type: 'application/vnd.sentry.items.span.v2+json' },\n {\n version: 2,\n ...(isBrowser() && {\n ingest_settings: { infer_ip: inferSetting, infer_user_agent: inferSetting },\n }),\n items: genAiSpans,\n },\n ];\n}\n"],"names":["hasSpanStreamingEnabled","spanJsonToSerializedStreamedSpan","isBrowser"],"mappings":";;;;;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,0BAA0B,CAAC,KAAK,EAAS,MAAM,EAAyC;AACxG,EAAE;AACF,IAAI,KAAK,CAAC,IAAA,KAAS,aAAA;AACnB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,MAAA;AAClB,IAAI,CAAC,KAAK,CAAC,qBAAqB,EAAE,aAAA;AAClC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,gBAAA;AACzB,IAAIA,+CAAuB,CAAC,MAAM;AAClC,IAAI;AACJ,IAAI,OAAO,SAAS;AACpB,EAAE;;AAEF,EAAE,MAAM,UAAA,GAAa,EAAE;AACvB,EAAE,MAAM,cAAA,GAAiB,EAAE;;AAE3B,EAAE,KAAK,MAAM,IAAA,IAAQ,KAAK,CAAC,KAAK,EAAE;AAClC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE;AACxC,MAAM,UAAU,CAAC,IAAI,CAACC,uDAAgC,CAAC,IAAI,CAAC,CAAC;AAC7D,IAAI,OAAO;AACX,MAAM,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;AAC/B,IAAI;AACJ,EAAE;;AAEF,EAAE,IAAI,UAAU,CAAC,MAAA,KAAW,CAAC,EAAE;AAC/B,IAAI,OAAO,SAAS;AACpB,EAAE;;AAEF,EAAE,KAAK,CAAC,KAAA,GAAQ,cAAc;;AAE9B,EAAE,MAAM,YAAA,GAAe,MAAM,CAAC,UAAU,EAAE,CAAC,cAAA,GAAiB,MAAA,GAAS,OAAO;;AAE5E,EAAE,OAAO;AACT,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,6CAA6C;AAC9G,IAAI;AACJ,MAAM,OAAO,EAAE,CAAC;AAChB,MAAM,IAAIC,mBAAS,MAAM;AACzB,QAAQ,eAAe,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAA,EAAc;AACnF,OAAO,CAAC;AACR,MAAM,KAAK,EAAE,UAAU;AACvB,KAAK;AACL,GAAG;AACH;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const spanUtils = require('../../utils/spanUtils.js'); | ||
| /** | ||
| * Converts a v1 SpanJSON (from a legacy transaction) to a serialized v2 StreamedSpan. | ||
| */ | ||
| function spanJsonToSerializedStreamedSpan(span) { | ||
| const streamedSpan = { | ||
| trace_id: span.trace_id, | ||
| span_id: span.span_id, | ||
| parent_span_id: span.parent_span_id, | ||
| name: span.description || '', | ||
| start_timestamp: span.start_timestamp, | ||
| end_timestamp: span.timestamp || span.start_timestamp, | ||
| status: !span.status || span.status === 'ok' || span.status === 'cancelled' ? 'ok' : 'error', | ||
| is_segment: false, | ||
| attributes: { ...(span.data ) }, | ||
| links: span.links, | ||
| }; | ||
| return spanUtils.streamedSpanJsonToSerializedSpan(streamedSpan); | ||
| } | ||
| exports.spanJsonToSerializedStreamedSpan = spanJsonToSerializedStreamedSpan; | ||
| //# sourceMappingURL=spanJsonToStreamedSpan.js.map |
| {"version":3,"file":"spanJsonToStreamedSpan.js","sources":["../../../../src/tracing/spans/spanJsonToStreamedSpan.ts"],"sourcesContent":["import type { RawAttributes } from '../../attributes';\nimport type { SerializedStreamedSpan, SpanJSON, StreamedSpanJSON } from '../../types-hoist/span';\nimport { streamedSpanJsonToSerializedSpan } from '../../utils/spanUtils';\n\n/**\n * Converts a v1 SpanJSON (from a legacy transaction) to a serialized v2 StreamedSpan.\n */\nexport function spanJsonToSerializedStreamedSpan(span: SpanJSON): SerializedStreamedSpan {\n const streamedSpan: StreamedSpanJSON = {\n trace_id: span.trace_id,\n span_id: span.span_id,\n parent_span_id: span.parent_span_id,\n name: span.description || '',\n start_timestamp: span.start_timestamp,\n end_timestamp: span.timestamp || span.start_timestamp,\n status: !span.status || span.status === 'ok' || span.status === 'cancelled' ? 'ok' : 'error',\n is_segment: false,\n attributes: { ...(span.data as RawAttributes<Record<string, unknown>>) },\n links: span.links,\n };\n\n return streamedSpanJsonToSerializedSpan(streamedSpan);\n}\n"],"names":["streamedSpanJsonToSerializedSpan"],"mappings":";;;;AAIA;AACA;AACA;AACO,SAAS,gCAAgC,CAAC,IAAI,EAAoC;AACzF,EAAE,MAAM,YAAY,GAAqB;AACzC,IAAI,QAAQ,EAAE,IAAI,CAAC,QAAQ;AAC3B,IAAI,OAAO,EAAE,IAAI,CAAC,OAAO;AACzB,IAAI,cAAc,EAAE,IAAI,CAAC,cAAc;AACvC,IAAI,IAAI,EAAE,IAAI,CAAC,WAAA,IAAe,EAAE;AAChC,IAAI,eAAe,EAAE,IAAI,CAAC,eAAe;AACzC,IAAI,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,CAAC,eAAe;AACzD,IAAI,MAAM,EAAE,CAAC,IAAI,CAAC,MAAA,IAAU,IAAI,CAAC,MAAA,KAAW,IAAA,IAAQ,IAAI,CAAC,MAAA,KAAW,WAAA,GAAc,IAAA,GAAO,OAAO;AAChG,IAAI,UAAU,EAAE,KAAK;AACrB,IAAI,UAAU,EAAE,EAAE,IAAI,IAAI,CAAC,IAAA,EAAK,EAA4C;AAC5E,IAAI,KAAK,EAAE,IAAI,CAAC,KAAK;AACrB,GAAG;;AAEH,EAAE,OAAOA,0CAAgC,CAAC,YAAY,CAAC;AACvD;;;;"} |
| export { registerSpanErrorInstrumentation } from './tracing/errors.js'; | ||
| export { getCapturedScopesOnSpan, setCapturedScopesOnSpan } from './tracing/utils.js'; | ||
| export { TRACING_DEFAULTS, startIdleSpan } from './tracing/idleSpan.js'; | ||
| export { SentrySpan } from './tracing/sentrySpan.js'; | ||
| export { SentryNonRecordingSpan } from './tracing/sentryNonRecordingSpan.js'; | ||
| export { SPAN_STATUS_ERROR, SPAN_STATUS_OK, SPAN_STATUS_UNSET, getSpanStatusFromHttpCode, setHttpStatus } from './tracing/spanstatus.js'; | ||
| export { SUPPRESS_TRACING_KEY, continueTrace, startInactiveSpan, startNewTrace, startSpan, startSpanManual, suppressTracing, withActiveSpan } from './tracing/trace.js'; | ||
| export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromScope, getDynamicSamplingContextFromSpan, spanToBaggageHeader } from './tracing/dynamicSamplingContext.js'; | ||
| export { setMeasurement, timedEventsToMeasurements } from './tracing/measurement.js'; | ||
| export { sampleSpan } from './tracing/sampling.js'; | ||
| export { logSpanEnd, logSpanStart } from './tracing/logSpans.js'; | ||
| export { captureSpan, safeSetSpanJSONAttributes } from './tracing/spans/captureSpan.js'; | ||
| export { GEN_AI_CONVERSATION_ID_ATTRIBUTE, SEMANTIC_ATTRIBUTE_CACHE_HIT, SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE, SEMANTIC_ATTRIBUTE_CACHE_KEY, SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME, SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD, SEMANTIC_ATTRIBUTE_PROFILE_ID, SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME, SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT, SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_RELEASE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME, SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID, SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_URL_FULL, SEMANTIC_ATTRIBUTE_USER_EMAIL, SEMANTIC_ATTRIBUTE_USER_ID, SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS, SEMANTIC_ATTRIBUTE_USER_USERNAME, SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE } from './semanticAttributes.js'; | ||
| export { createEventEnvelope, createSessionEnvelope, createSpanEnvelope } from './envelope.js'; | ||
| export { addEventProcessor, captureCheckIn, captureEvent, captureException, captureMessage, captureSession, close, endSession, flush, isEnabled, isInitialized, lastEventId, setContext, setConversationId, setExtra, setExtras, setTag, setTags, setUser, startSession, withMonitor } from './exports.js'; | ||
| export { getClient, getCurrentScope, getExternalPropagationContext, getGlobalScope, getIsolationScope, getTraceContextFromScope, hasExternalPropagationContext, registerExternalPropagationContext, withIsolationScope, withScope } from './currentScopes.js'; | ||
| export { getDefaultCurrentScope, getDefaultIsolationScope } from './defaultScopes.js'; | ||
| export { setAsyncContextStrategy } from './asyncContext/index.js'; | ||
| export { getGlobalSingleton, getMainCarrier } from './carrier.js'; | ||
| export { closeSession, makeSession, updateSession } from './session.js'; | ||
| export { Scope } from './scope.js'; | ||
| export { notifyEventProcessors } from './eventProcessors.js'; | ||
| export { SENTRY_API_VERSION, getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint } from './api.js'; | ||
| export { Client } from './client.js'; | ||
| export { initAndBind, setCurrentClient } from './sdk.js'; | ||
| export { createTransport } from './transports/base.js'; | ||
| export { makeOfflineTransport } from './transports/offline.js'; | ||
| export { MULTIPLEXED_TRANSPORT_EXTRA_KEY, makeMultiplexedTransport } from './transports/multiplexed.js'; | ||
| export { addIntegration, defineIntegration, getIntegrationsToSetup, installedIntegrations } from './integration.js'; | ||
| export { _INTERNAL_clearAiProviderSkips, _INTERNAL_shouldSkipAiProviderWrapping, _INTERNAL_skipAiProviderWrapping } from './utils/ai/providerSkip.js'; | ||
| export { envToBool } from './utils/envToBool.js'; | ||
| export { applyScopeDataToEvent, getCombinedScopeData, mergeScopeData } from './utils/scopeData.js'; | ||
| export { prepareEvent } from './utils/prepareEvent.js'; | ||
| export { createCheckInEnvelope } from './checkin.js'; | ||
| export { hasSpansEnabled } from './utils/hasSpansEnabled.js'; | ||
| export { isStreamedBeforeSendSpanCallback, withStreamedSpan } from './tracing/spans/beforeSendSpan.js'; | ||
| export { isSentryRequestUrl } from './utils/isSentryRequestUrl.js'; | ||
| export { handleCallbackErrors } from './utils/handleCallbackErrors.js'; | ||
| export { fmt, parameterize } from './utils/parameterize.js'; | ||
| export { handleTunnelRequest } from './utils/tunnel.js'; | ||
| export { addAutoIpAddressToSession, addAutoIpAddressToUser } from './utils/ipAddress.js'; | ||
| export { INTERNAL_getSegmentSpan, addChildSpanToSpan, convertSpanLinksForEnvelope, getActiveSpan, getRootSpan, getSpanDescendants, getStatusMessage, spanIsSampled, spanTimeInputToSeconds, spanToJSON, spanToStreamedSpanJSON, spanToTraceContext, spanToTraceHeader, updateSpanName } from './utils/spanUtils.js'; | ||
| export { _setSpanForScope as _INTERNAL_setSpanForScope } from './utils/spanOnScope.js'; | ||
| export { parseSampleRate } from './utils/parseSampleRate.js'; | ||
| export { applySdkMetadata } from './utils/sdkMetadata.js'; | ||
| export { getTraceData } from './utils/traceData.js'; | ||
| export { shouldPropagateTraceForUrl } from './utils/tracePropagationTargets.js'; | ||
| export { getTraceMetaTags } from './utils/meta.js'; | ||
| export { debounce } from './utils/debounce.js'; | ||
| export { derefWeakRef, makeWeakRef } from './utils/weakRef.js'; | ||
| export { shouldIgnoreSpan } from './utils/should-ignore-span.js'; | ||
| export { MAX_BODY_BYTE_LENGTH, captureBodyFromWinterCGRequest, extractQueryParamsFromUrl, getMaxBodyByteLength, headersToDict, httpHeadersToSpanAttributes, httpRequestToRequestData, winterCGHeadersToDict, winterCGRequestToRequestData } from './utils/request.js'; | ||
| export { DEFAULT_ENVIRONMENT, DEV_ENVIRONMENT } from './constants.js'; | ||
| export { addBreadcrumb } from './breadcrumbs.js'; | ||
| export { functionToStringIntegration } from './integrations/functiontostring.js'; | ||
| export { eventFiltersIntegration, inboundFiltersIntegration } from './integrations/eventFilters.js'; | ||
| export { linkedErrorsIntegration } from './integrations/linkederrors.js'; | ||
| export { moduleMetadataIntegration } from './integrations/moduleMetadata.js'; | ||
| export { requestDataIntegration } from './integrations/requestdata.js'; | ||
| export { captureConsoleIntegration } from './integrations/captureconsole.js'; | ||
| export { dedupeIntegration } from './integrations/dedupe.js'; | ||
| export { extraErrorDataIntegration } from './integrations/extraerrordata.js'; | ||
| export { rewriteFramesIntegration } from './integrations/rewriteframes.js'; | ||
| export { instrumentSupabaseClient, supabaseIntegration } from './integrations/supabase.js'; | ||
| export { zodErrorsIntegration } from './integrations/zoderrors.js'; | ||
| export { thirdPartyErrorFilterIntegration } from './integrations/third-party-errors-filter.js'; | ||
| export { consoleIntegration } from './integrations/console.js'; | ||
| export { featureFlagsIntegration } from './integrations/featureFlags/featureFlagsIntegration.js'; | ||
| export { growthbookIntegration } from './integrations/featureFlags/growthbook.js'; | ||
| export { conversationIdIntegration } from './integrations/conversationId.js'; | ||
| export { profiler } from './profiling.js'; | ||
| export { _INTERNAL_getTracingHeadersForFetchRequest, instrumentFetchRequest } from './fetch.js'; | ||
| export { captureFeedback } from './feedback.js'; | ||
| export { _INTERNAL_captureLog, _INTERNAL_captureSerializedLog, _INTERNAL_flushLogsBuffer } from './logs/internal.js'; | ||
| import * as publicApi from './logs/public-api.js'; | ||
| export { publicApi as logger }; | ||
| export { consoleLoggingIntegration } from './logs/console-integration.js'; | ||
| export { _INTERNAL_captureMetric, _INTERNAL_captureSerializedMetric, _INTERNAL_flushMetricsBuffer } from './metrics/internal.js'; | ||
| import * as publicApi$1 from './metrics/public-api.js'; | ||
| export { publicApi$1 as metrics }; | ||
| export { createConsolaReporter } from './integrations/consola.js'; | ||
| export { addVercelAiProcessors } from './tracing/vercel-ai/index.js'; | ||
| export { _INTERNAL_cleanupToolCallSpanContext, _INTERNAL_getSpanContextForToolCallId } from './tracing/vercel-ai/utils.js'; | ||
| export { toolCallSpanContextMap as _INTERNAL_toolCallSpanContextMap } from './tracing/vercel-ai/constants.js'; | ||
| export { instrumentOpenAiClient } from './tracing/openai/index.js'; | ||
| export { OPENAI_INTEGRATION_NAME } from './tracing/openai/constants.js'; | ||
| export { instrumentAnthropicAiClient } from './tracing/anthropic-ai/index.js'; | ||
| export { ANTHROPIC_AI_INTEGRATION_NAME } from './tracing/anthropic-ai/constants.js'; | ||
| export { instrumentGoogleGenAIClient } from './tracing/google-genai/index.js'; | ||
| export { GOOGLE_GENAI_INTEGRATION_NAME } from './tracing/google-genai/constants.js'; | ||
| export { createLangChainCallbackHandler } from './tracing/langchain/index.js'; | ||
| export { LANGCHAIN_INTEGRATION_NAME } from './tracing/langchain/constants.js'; | ||
| export { instrumentCreateReactAgent, instrumentLangGraph, instrumentStateGraphCompile } from './tracing/langgraph/index.js'; | ||
| export { LANGGRAPH_INTEGRATION_NAME } from './tracing/langgraph/constants.js'; | ||
| export { SpanBuffer } from './tracing/spans/spanBuffer.js'; | ||
| export { hasSpanStreamingEnabled } from './tracing/spans/hasSpanStreamingEnabled.js'; | ||
| export { spanStreamingIntegration } from './integrations/spanStreaming.js'; | ||
| export { _INTERNAL_FLAG_BUFFER_SIZE, _INTERNAL_MAX_FLAGS_PER_SPAN, _INTERNAL_addFeatureFlagToActiveSpan, _INTERNAL_copyFlagsFromScopeToEvent, _INTERNAL_insertFlagToScope } from './utils/featureFlags.js'; | ||
| export { applyAggregateErrorsToEvent } from './utils/aggregate-errors.js'; | ||
| export { getBreadcrumbLogLevelFromHttpStatusCode } from './utils/breadcrumb-log-level.js'; | ||
| export { dsnFromString, dsnToString, makeDsn } from './utils/dsn.js'; | ||
| export { SentryError } from './utils/error.js'; | ||
| export { GLOBAL_OBJ } from './utils/worldwide.js'; | ||
| export { addConsoleInstrumentationFilter, addConsoleInstrumentationHandler } from './instrument/console.js'; | ||
| export { addFetchEndInstrumentationHandler, addFetchInstrumentationHandler } from './instrument/fetch.js'; | ||
| export { addGlobalErrorInstrumentationHandler } from './instrument/globalError.js'; | ||
| export { addGlobalUnhandledRejectionInstrumentationHandler } from './instrument/globalUnhandledRejection.js'; | ||
| export { addHandler, maybeInstrument, resetInstrumentationHandlers, triggerHandlers } from './instrument/handlers.js'; | ||
| export { isDOMError, isDOMException, isElement, isError, isErrorEvent, isEvent, isInstanceOf, isParameterizedString, isPlainObject, isPrimitive, isRegExp, isString, isSyntheticEvent, isThenable, isVueViewModel } from './utils/is.js'; | ||
| export { isBrowser } from './utils/isBrowser.js'; | ||
| export { CONSOLE_LEVELS, consoleSandbox, debug, originalConsoleMethods } from './utils/debug-logger.js'; | ||
| export { addContextToFrame, addExceptionMechanism, addExceptionTypeValue, checkOrSetAlreadyCaught, getEventDescription, isAlreadyCaptured, parseSemver, uuid4 } from './utils/misc.js'; | ||
| export { normalize, normalizeToSize, normalizeUrlToBase } from './utils/normalize.js'; | ||
| export { setNormalizationDepthOverrideHint, setSkipNormalizationHint } from './utils/normalizationHints.js'; | ||
| export { addNonEnumerableProperty, convertToPlainObject, dropUndefinedKeys, extractExceptionKeysForMessage, fill, getOriginalFunction, markFunctionWrapped, objectify } from './utils/object.js'; | ||
| export { basename, dirname, isAbsolute, join, normalizePath, relative, resolve } from './utils/path.js'; | ||
| export { SENTRY_BUFFER_FULL_ERROR, makePromiseBuffer } from './utils/promisebuffer.js'; | ||
| export { severityLevelFromString } from './utils/severity.js'; | ||
| export { replaceExports } from './utils/exports.js'; | ||
| export { UNKNOWN_FUNCTION, createStackParser, getFramesFromEvent, getFunctionName, stackParserFromStackParserOptions, stripSentryFramesAndReverse } from './utils/stacktrace.js'; | ||
| export { isMatchingPattern, safeJoin, snipLine, stringMatchesSomePattern, truncate } from './utils/string.js'; | ||
| export { isNativeFunction, supportsDOMError, supportsDOMException, supportsErrorEvent, supportsFetch, supportsHistory, supportsNativeFetch, supportsReferrerPolicy, supportsReportingObserver } from './utils/supports.js'; | ||
| export { SyncPromise, rejectedSyncPromise, resolvedSyncPromise } from './utils/syncpromise.js'; | ||
| export { browserPerformanceTimeOrigin, dateTimestampInSeconds, timestampInSeconds } from './utils/time.js'; | ||
| export { TRACEPARENT_REGEXP, extractTraceparentData, generateSentryTraceHeader, generateTraceparentHeader, propagationContextFromHeaders, shouldContinueTrace } from './utils/tracing.js'; | ||
| export { getSDKSource, isBrowserBundle } from './utils/env.js'; | ||
| export { addItemToEnvelope, createAttachmentEnvelopeItem, createEnvelope, createEventEnvelopeHeaders, createSpanEnvelopeItem, envelopeContainsItemType, envelopeItemTypeToDataCategory, forEachEnvelopeItem, getSdkMetadataForEnvelopeHeader, parseEnvelope, serializeEnvelope } from './utils/envelope.js'; | ||
| export { createClientReportEnvelope } from './utils/clientreport.js'; | ||
| export { DEFAULT_RETRY_AFTER, disabledUntil, isRateLimited, parseRetryAfterHeader, updateRateLimits } from './utils/ratelimit.js'; | ||
| export { MAX_BAGGAGE_STRING_LENGTH, SENTRY_BAGGAGE_KEY_PREFIX, SENTRY_BAGGAGE_KEY_PREFIX_REGEX, baggageHeaderToDynamicSamplingContext, dynamicSamplingContextToSentryBaggageHeader, mergeBaggageHeaders, objectToBaggageHeader, parseBaggageHeader } from './utils/baggage.js'; | ||
| export { getHttpSpanDetailsFromUrlObject, getSanitizedUrlString, getSanitizedUrlStringFromUrlObject, isURLObjectRelative, parseStringToURLObject, parseUrl, stripDataUrlContent, stripUrlQueryAndFragment } from './utils/url.js'; | ||
| export { _enhanceErrorWithSentryInfo as _INTERNAL_enhanceErrorWithSentryInfo, eventFromMessage, eventFromUnknownInput, exceptionFromError, parseStackFrames } from './utils/eventbuilder.js'; | ||
| export { LRUMap } from './utils/lru.js'; | ||
| export { generateSpanId, generateTraceId } from './utils/propagationContext.js'; | ||
| export { SDK_VERSION } from './utils/version.js'; | ||
| export { getDebugImagesForResources, getFilenameToDebugIdMap } from './utils/debug-ids.js'; | ||
| export { getFilenameToMetadataMap } from './metadata.js'; | ||
| export { escapeStringForRegex } from './vendor/escapeStringForRegex.js'; | ||
| export { safeDateNow as _INTERNAL_safeDateNow, safeMathRandom as _INTERNAL_safeMathRandom, withRandomSafeContext as _INTERNAL_withRandomSafeContext } from './utils/randomSafeContext.js'; | ||
| export { getComponentName, getLocationHref, htmlTreeAsString } from './utils/browser.js'; | ||
| export { instrumentLangChainEmbeddings } from './tracing/langchain/embeddings.js'; | ||
| //# sourceMappingURL=browser.js.map |
| {"version":3,"file":"browser.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
| export { registerSpanErrorInstrumentation } from './tracing/errors.js'; | ||
| export { getCapturedScopesOnSpan, setCapturedScopesOnSpan } from './tracing/utils.js'; | ||
| export { TRACING_DEFAULTS, startIdleSpan } from './tracing/idleSpan.js'; | ||
| export { SentrySpan } from './tracing/sentrySpan.js'; | ||
| export { SentryNonRecordingSpan } from './tracing/sentryNonRecordingSpan.js'; | ||
| export { SPAN_STATUS_ERROR, SPAN_STATUS_OK, SPAN_STATUS_UNSET, getSpanStatusFromHttpCode, setHttpStatus } from './tracing/spanstatus.js'; | ||
| export { SUPPRESS_TRACING_KEY, continueTrace, startInactiveSpan, startNewTrace, startSpan, startSpanManual, suppressTracing, withActiveSpan } from './tracing/trace.js'; | ||
| export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromScope, getDynamicSamplingContextFromSpan, spanToBaggageHeader } from './tracing/dynamicSamplingContext.js'; | ||
| export { setMeasurement, timedEventsToMeasurements } from './tracing/measurement.js'; | ||
| export { sampleSpan } from './tracing/sampling.js'; | ||
| export { logSpanEnd, logSpanStart } from './tracing/logSpans.js'; | ||
| export { captureSpan, safeSetSpanJSONAttributes } from './tracing/spans/captureSpan.js'; | ||
| export { GEN_AI_CONVERSATION_ID_ATTRIBUTE, SEMANTIC_ATTRIBUTE_CACHE_HIT, SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE, SEMANTIC_ATTRIBUTE_CACHE_KEY, SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME, SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD, SEMANTIC_ATTRIBUTE_PROFILE_ID, SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME, SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT, SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_RELEASE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME, SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID, SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_URL_FULL, SEMANTIC_ATTRIBUTE_USER_EMAIL, SEMANTIC_ATTRIBUTE_USER_ID, SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS, SEMANTIC_ATTRIBUTE_USER_USERNAME, SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE } from './semanticAttributes.js'; | ||
| export { createEventEnvelope, createSessionEnvelope, createSpanEnvelope } from './envelope.js'; | ||
| export { addEventProcessor, captureCheckIn, captureEvent, captureException, captureMessage, captureSession, close, endSession, flush, isEnabled, isInitialized, lastEventId, setContext, setConversationId, setExtra, setExtras, setTag, setTags, setUser, startSession, withMonitor } from './exports.js'; | ||
| export { getClient, getCurrentScope, getExternalPropagationContext, getGlobalScope, getIsolationScope, getTraceContextFromScope, hasExternalPropagationContext, registerExternalPropagationContext, withIsolationScope, withScope } from './currentScopes.js'; | ||
| export { getDefaultCurrentScope, getDefaultIsolationScope } from './defaultScopes.js'; | ||
| export { setAsyncContextStrategy } from './asyncContext/index.js'; | ||
| export { getGlobalSingleton, getMainCarrier } from './carrier.js'; | ||
| export { closeSession, makeSession, updateSession } from './session.js'; | ||
| export { Scope } from './scope.js'; | ||
| export { notifyEventProcessors } from './eventProcessors.js'; | ||
| export { SENTRY_API_VERSION, getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint } from './api.js'; | ||
| export { Client } from './client.js'; | ||
| export { initAndBind, setCurrentClient } from './sdk.js'; | ||
| export { createTransport } from './transports/base.js'; | ||
| export { makeOfflineTransport } from './transports/offline.js'; | ||
| export { MULTIPLEXED_TRANSPORT_EXTRA_KEY, makeMultiplexedTransport } from './transports/multiplexed.js'; | ||
| export { addIntegration, defineIntegration, getIntegrationsToSetup, installedIntegrations } from './integration.js'; | ||
| export { _INTERNAL_clearAiProviderSkips, _INTERNAL_shouldSkipAiProviderWrapping, _INTERNAL_skipAiProviderWrapping } from './utils/ai/providerSkip.js'; | ||
| export { envToBool } from './utils/envToBool.js'; | ||
| export { applyScopeDataToEvent, getCombinedScopeData, mergeScopeData } from './utils/scopeData.js'; | ||
| export { prepareEvent } from './utils/prepareEvent.js'; | ||
| export { createCheckInEnvelope } from './checkin.js'; | ||
| export { hasSpansEnabled } from './utils/hasSpansEnabled.js'; | ||
| export { isStreamedBeforeSendSpanCallback, withStreamedSpan } from './tracing/spans/beforeSendSpan.js'; | ||
| export { isSentryRequestUrl } from './utils/isSentryRequestUrl.js'; | ||
| export { handleCallbackErrors } from './utils/handleCallbackErrors.js'; | ||
| export { fmt, parameterize } from './utils/parameterize.js'; | ||
| export { handleTunnelRequest } from './utils/tunnel.js'; | ||
| export { addAutoIpAddressToSession, addAutoIpAddressToUser } from './utils/ipAddress.js'; | ||
| export { INTERNAL_getSegmentSpan, addChildSpanToSpan, convertSpanLinksForEnvelope, getActiveSpan, getRootSpan, getSpanDescendants, getStatusMessage, spanIsSampled, spanTimeInputToSeconds, spanToJSON, spanToStreamedSpanJSON, spanToTraceContext, spanToTraceHeader, updateSpanName } from './utils/spanUtils.js'; | ||
| export { _setSpanForScope as _INTERNAL_setSpanForScope } from './utils/spanOnScope.js'; | ||
| export { parseSampleRate } from './utils/parseSampleRate.js'; | ||
| export { applySdkMetadata } from './utils/sdkMetadata.js'; | ||
| export { getTraceData } from './utils/traceData.js'; | ||
| export { shouldPropagateTraceForUrl } from './utils/tracePropagationTargets.js'; | ||
| export { getTraceMetaTags } from './utils/meta.js'; | ||
| export { debounce } from './utils/debounce.js'; | ||
| export { derefWeakRef, makeWeakRef } from './utils/weakRef.js'; | ||
| export { shouldIgnoreSpan } from './utils/should-ignore-span.js'; | ||
| export { MAX_BODY_BYTE_LENGTH, captureBodyFromWinterCGRequest, extractQueryParamsFromUrl, getMaxBodyByteLength, headersToDict, httpHeadersToSpanAttributes, httpRequestToRequestData, winterCGHeadersToDict, winterCGRequestToRequestData } from './utils/request.js'; | ||
| export { DEFAULT_ENVIRONMENT, DEV_ENVIRONMENT } from './constants.js'; | ||
| export { addBreadcrumb } from './breadcrumbs.js'; | ||
| export { functionToStringIntegration } from './integrations/functiontostring.js'; | ||
| export { eventFiltersIntegration, inboundFiltersIntegration } from './integrations/eventFilters.js'; | ||
| export { linkedErrorsIntegration } from './integrations/linkederrors.js'; | ||
| export { moduleMetadataIntegration } from './integrations/moduleMetadata.js'; | ||
| export { requestDataIntegration } from './integrations/requestdata.js'; | ||
| export { captureConsoleIntegration } from './integrations/captureconsole.js'; | ||
| export { dedupeIntegration } from './integrations/dedupe.js'; | ||
| export { extraErrorDataIntegration } from './integrations/extraerrordata.js'; | ||
| export { rewriteFramesIntegration } from './integrations/rewriteframes.js'; | ||
| export { instrumentSupabaseClient, supabaseIntegration } from './integrations/supabase.js'; | ||
| export { zodErrorsIntegration } from './integrations/zoderrors.js'; | ||
| export { thirdPartyErrorFilterIntegration } from './integrations/third-party-errors-filter.js'; | ||
| export { consoleIntegration } from './integrations/console.js'; | ||
| export { featureFlagsIntegration } from './integrations/featureFlags/featureFlagsIntegration.js'; | ||
| export { growthbookIntegration } from './integrations/featureFlags/growthbook.js'; | ||
| export { conversationIdIntegration } from './integrations/conversationId.js'; | ||
| export { profiler } from './profiling.js'; | ||
| export { _INTERNAL_getTracingHeadersForFetchRequest, instrumentFetchRequest } from './fetch.js'; | ||
| export { captureFeedback } from './feedback.js'; | ||
| export { _INTERNAL_captureLog, _INTERNAL_captureSerializedLog, _INTERNAL_flushLogsBuffer } from './logs/internal.js'; | ||
| import * as publicApi from './logs/public-api.js'; | ||
| export { publicApi as logger }; | ||
| export { consoleLoggingIntegration } from './logs/console-integration.js'; | ||
| export { _INTERNAL_captureMetric, _INTERNAL_captureSerializedMetric, _INTERNAL_flushMetricsBuffer } from './metrics/internal.js'; | ||
| import * as publicApi$1 from './metrics/public-api.js'; | ||
| export { publicApi$1 as metrics }; | ||
| export { createConsolaReporter } from './integrations/consola.js'; | ||
| export { addVercelAiProcessors } from './tracing/vercel-ai/index.js'; | ||
| export { _INTERNAL_cleanupToolCallSpanContext, _INTERNAL_getSpanContextForToolCallId } from './tracing/vercel-ai/utils.js'; | ||
| export { toolCallSpanContextMap as _INTERNAL_toolCallSpanContextMap } from './tracing/vercel-ai/constants.js'; | ||
| export { instrumentOpenAiClient } from './tracing/openai/index.js'; | ||
| export { OPENAI_INTEGRATION_NAME } from './tracing/openai/constants.js'; | ||
| export { instrumentAnthropicAiClient } from './tracing/anthropic-ai/index.js'; | ||
| export { ANTHROPIC_AI_INTEGRATION_NAME } from './tracing/anthropic-ai/constants.js'; | ||
| export { instrumentGoogleGenAIClient } from './tracing/google-genai/index.js'; | ||
| export { GOOGLE_GENAI_INTEGRATION_NAME } from './tracing/google-genai/constants.js'; | ||
| export { createLangChainCallbackHandler } from './tracing/langchain/index.js'; | ||
| export { LANGCHAIN_INTEGRATION_NAME } from './tracing/langchain/constants.js'; | ||
| export { instrumentCreateReactAgent, instrumentLangGraph, instrumentStateGraphCompile } from './tracing/langgraph/index.js'; | ||
| export { LANGGRAPH_INTEGRATION_NAME } from './tracing/langgraph/constants.js'; | ||
| export { SpanBuffer } from './tracing/spans/spanBuffer.js'; | ||
| export { hasSpanStreamingEnabled } from './tracing/spans/hasSpanStreamingEnabled.js'; | ||
| export { spanStreamingIntegration } from './integrations/spanStreaming.js'; | ||
| export { _INTERNAL_FLAG_BUFFER_SIZE, _INTERNAL_MAX_FLAGS_PER_SPAN, _INTERNAL_addFeatureFlagToActiveSpan, _INTERNAL_copyFlagsFromScopeToEvent, _INTERNAL_insertFlagToScope } from './utils/featureFlags.js'; | ||
| export { applyAggregateErrorsToEvent } from './utils/aggregate-errors.js'; | ||
| export { getBreadcrumbLogLevelFromHttpStatusCode } from './utils/breadcrumb-log-level.js'; | ||
| export { dsnFromString, dsnToString, makeDsn } from './utils/dsn.js'; | ||
| export { SentryError } from './utils/error.js'; | ||
| export { GLOBAL_OBJ } from './utils/worldwide.js'; | ||
| export { addConsoleInstrumentationFilter, addConsoleInstrumentationHandler } from './instrument/console.js'; | ||
| export { addFetchEndInstrumentationHandler, addFetchInstrumentationHandler } from './instrument/fetch.js'; | ||
| export { addGlobalErrorInstrumentationHandler } from './instrument/globalError.js'; | ||
| export { addGlobalUnhandledRejectionInstrumentationHandler } from './instrument/globalUnhandledRejection.js'; | ||
| export { addHandler, maybeInstrument, resetInstrumentationHandlers, triggerHandlers } from './instrument/handlers.js'; | ||
| export { isDOMError, isDOMException, isElement, isError, isErrorEvent, isEvent, isInstanceOf, isParameterizedString, isPlainObject, isPrimitive, isRegExp, isString, isSyntheticEvent, isThenable, isVueViewModel } from './utils/is.js'; | ||
| export { isBrowser } from './utils/isBrowser.js'; | ||
| export { CONSOLE_LEVELS, consoleSandbox, debug, originalConsoleMethods } from './utils/debug-logger.js'; | ||
| export { addContextToFrame, addExceptionMechanism, addExceptionTypeValue, checkOrSetAlreadyCaught, getEventDescription, isAlreadyCaptured, parseSemver, uuid4 } from './utils/misc.js'; | ||
| export { normalize, normalizeToSize, normalizeUrlToBase } from './utils/normalize.js'; | ||
| export { setNormalizationDepthOverrideHint, setSkipNormalizationHint } from './utils/normalizationHints.js'; | ||
| export { addNonEnumerableProperty, convertToPlainObject, dropUndefinedKeys, extractExceptionKeysForMessage, fill, getOriginalFunction, markFunctionWrapped, objectify } from './utils/object.js'; | ||
| export { basename, dirname, isAbsolute, join, normalizePath, relative, resolve } from './utils/path.js'; | ||
| export { SENTRY_BUFFER_FULL_ERROR, makePromiseBuffer } from './utils/promisebuffer.js'; | ||
| export { severityLevelFromString } from './utils/severity.js'; | ||
| export { replaceExports } from './utils/exports.js'; | ||
| export { UNKNOWN_FUNCTION, createStackParser, getFramesFromEvent, getFunctionName, stackParserFromStackParserOptions, stripSentryFramesAndReverse } from './utils/stacktrace.js'; | ||
| export { isMatchingPattern, safeJoin, snipLine, stringMatchesSomePattern, truncate } from './utils/string.js'; | ||
| export { isNativeFunction, supportsDOMException, supportsErrorEvent, supportsFetch, supportsReferrerPolicy } from './utils/supports.js'; | ||
| export { SyncPromise, rejectedSyncPromise, resolvedSyncPromise } from './utils/syncpromise.js'; | ||
| export { browserPerformanceTimeOrigin, dateTimestampInSeconds, timestampInSeconds } from './utils/time.js'; | ||
| export { TRACEPARENT_REGEXP, extractTraceparentData, generateSentryTraceHeader, generateTraceparentHeader, propagationContextFromHeaders, shouldContinueTrace } from './utils/tracing.js'; | ||
| export { getSDKSource, isBrowserBundle } from './utils/env.js'; | ||
| export { addItemToEnvelope, createAttachmentEnvelopeItem, createEnvelope, createEventEnvelopeHeaders, createSpanEnvelopeItem, envelopeContainsItemType, envelopeItemTypeToDataCategory, forEachEnvelopeItem, getSdkMetadataForEnvelopeHeader, parseEnvelope, serializeEnvelope } from './utils/envelope.js'; | ||
| export { createClientReportEnvelope } from './utils/clientreport.js'; | ||
| export { DEFAULT_RETRY_AFTER, disabledUntil, isRateLimited, parseRetryAfterHeader, updateRateLimits } from './utils/ratelimit.js'; | ||
| export { MAX_BAGGAGE_STRING_LENGTH, SENTRY_BAGGAGE_KEY_PREFIX, SENTRY_BAGGAGE_KEY_PREFIX_REGEX, baggageHeaderToDynamicSamplingContext, dynamicSamplingContextToSentryBaggageHeader, mergeBaggageHeaders, objectToBaggageHeader, parseBaggageHeader } from './utils/baggage.js'; | ||
| export { getHttpSpanDetailsFromUrlObject, getSanitizedUrlString, getSanitizedUrlStringFromUrlObject, isURLObjectRelative, parseStringToURLObject, parseUrl, stripDataUrlContent, stripUrlQueryAndFragment } from './utils/url.js'; | ||
| export { _enhanceErrorWithSentryInfo as _INTERNAL_enhanceErrorWithSentryInfo, eventFromMessage, eventFromUnknownInput, exceptionFromError, parseStackFrames } from './utils/eventbuilder.js'; | ||
| export { LRUMap } from './utils/lru.js'; | ||
| export { generateSpanId, generateTraceId } from './utils/propagationContext.js'; | ||
| export { SDK_VERSION } from './utils/version.js'; | ||
| export { getDebugImagesForResources, getFilenameToDebugIdMap } from './utils/debug-ids.js'; | ||
| export { getFilenameToMetadataMap } from './metadata.js'; | ||
| export { escapeStringForRegex } from './vendor/escapeStringForRegex.js'; | ||
| export { safeDateNow as _INTERNAL_safeDateNow, safeMathRandom as _INTERNAL_safeMathRandom, withRandomSafeContext as _INTERNAL_withRandomSafeContext } from './utils/randomSafeContext.js'; | ||
| export { ServerRuntimeClient } from './server-runtime-client.js'; | ||
| export { trpcMiddleware } from './trpc.js'; | ||
| export { wrapMcpServerWithSentry } from './integrations/mcp-server/index.js'; | ||
| export { isNodeEnv, loadModule } from './utils/node.js'; | ||
| export { filenameIsInApp, node, nodeStackLineParser } from './utils/node-stack-trace.js'; | ||
| export { vercelWaitUntil } from './utils/vercelWaitUntil.js'; | ||
| export { flushIfServerless } from './utils/flushIfServerless.js'; | ||
| export { callFrameToStackFrame, watchdogTimer } from './utils/anr.js'; | ||
| export { safeUnref as _INTERNAL_safeUnref } from './utils/timer.js'; | ||
| export { expressErrorHandler, patchExpressModule, setupExpressErrorHandler } from './integrations/express/index.js'; | ||
| export { instrumentPostgresJsSql } from './integrations/postgresjs.js'; | ||
| export { patchHttpModuleClient } from './integrations/http/client-patch.js'; | ||
| export { getHttpClientSubscriptions } from './integrations/http/client-subscriptions.js'; | ||
| export { addOutgoingRequestBreadcrumb } from './integrations/http/add-outgoing-request-breadcrumb.js'; | ||
| export { getRequestOptions, getRequestUrl, getRequestUrlFromClientRequest, getRequestUrlObject } from './integrations/http/get-request-url.js'; | ||
| export { HTTP_ON_CLIENT_REQUEST, HTTP_ON_SERVER_REQUEST } from './integrations/http/constants.js'; | ||
| export { instrumentLangChainEmbeddings } from './tracing/langchain/embeddings.js'; | ||
| //# sourceMappingURL=server.js.map |
| {"version":3,"file":"server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
| import { isBrowser } from '../../utils/isBrowser.js'; | ||
| import { hasSpanStreamingEnabled } from './hasSpanStreamingEnabled.js'; | ||
| import { spanJsonToSerializedStreamedSpan } from './spanJsonToStreamedSpan.js'; | ||
| /** | ||
| * Extracts gen_ai spans from a transaction event, converts them to span v2 format, | ||
| * and returns them as a SpanContainerItem. | ||
| * | ||
| * Only applies to static mode (non-streaming) transactions. | ||
| * | ||
| * WARNING: This function mutates `event.spans` by removing the extracted gen_ai spans | ||
| * from the array. Call this before creating the event envelope so the transaction | ||
| * item does not include the extracted spans. | ||
| */ | ||
| function extractGenAiSpansFromEvent(event, client) { | ||
| if ( | ||
| event.type !== 'transaction' || | ||
| !event.spans?.length || | ||
| !event.sdkProcessingMetadata?.hasGenAiSpans || | ||
| !client.getOptions().streamGenAiSpans || | ||
| hasSpanStreamingEnabled(client) | ||
| ) { | ||
| return undefined; | ||
| } | ||
| const genAiSpans = []; | ||
| const remainingSpans = []; | ||
| for (const span of event.spans) { | ||
| if (span.op?.startsWith('gen_ai.')) { | ||
| genAiSpans.push(spanJsonToSerializedStreamedSpan(span)); | ||
| } else { | ||
| remainingSpans.push(span); | ||
| } | ||
| } | ||
| if (genAiSpans.length === 0) { | ||
| return undefined; | ||
| } | ||
| event.spans = remainingSpans; | ||
| const inferSetting = client.getOptions().sendDefaultPii ? 'auto' : 'never'; | ||
| return [ | ||
| { type: 'span', item_count: genAiSpans.length, content_type: 'application/vnd.sentry.items.span.v2+json' }, | ||
| { | ||
| version: 2, | ||
| ...(isBrowser() && { | ||
| ingest_settings: { infer_ip: inferSetting, infer_user_agent: inferSetting }, | ||
| }), | ||
| items: genAiSpans, | ||
| }, | ||
| ]; | ||
| } | ||
| export { extractGenAiSpansFromEvent }; | ||
| //# sourceMappingURL=extractGenAiSpans.js.map |
| {"version":3,"file":"extractGenAiSpans.js","sources":["../../../../src/tracing/spans/extractGenAiSpans.ts"],"sourcesContent":["import type { Client } from '../../client';\nimport type { SpanContainerItem } from '../../types-hoist/envelope';\nimport type { Event } from '../../types-hoist/event';\nimport { isBrowser } from '../../utils/isBrowser';\nimport { hasSpanStreamingEnabled } from './hasSpanStreamingEnabled';\nimport { spanJsonToSerializedStreamedSpan } from './spanJsonToStreamedSpan';\n\n/**\n * Extracts gen_ai spans from a transaction event, converts them to span v2 format,\n * and returns them as a SpanContainerItem.\n *\n * Only applies to static mode (non-streaming) transactions.\n *\n * WARNING: This function mutates `event.spans` by removing the extracted gen_ai spans\n * from the array. Call this before creating the event envelope so the transaction\n * item does not include the extracted spans.\n */\nexport function extractGenAiSpansFromEvent(event: Event, client: Client): SpanContainerItem | undefined {\n if (\n event.type !== 'transaction' ||\n !event.spans?.length ||\n !event.sdkProcessingMetadata?.hasGenAiSpans ||\n !client.getOptions().streamGenAiSpans ||\n hasSpanStreamingEnabled(client)\n ) {\n return undefined;\n }\n\n const genAiSpans = [];\n const remainingSpans = [];\n\n for (const span of event.spans) {\n if (span.op?.startsWith('gen_ai.')) {\n genAiSpans.push(spanJsonToSerializedStreamedSpan(span));\n } else {\n remainingSpans.push(span);\n }\n }\n\n if (genAiSpans.length === 0) {\n return undefined;\n }\n\n event.spans = remainingSpans;\n\n const inferSetting = client.getOptions().sendDefaultPii ? 'auto' : 'never';\n\n return [\n { type: 'span', item_count: genAiSpans.length, content_type: 'application/vnd.sentry.items.span.v2+json' },\n {\n version: 2,\n ...(isBrowser() && {\n ingest_settings: { infer_ip: inferSetting, infer_user_agent: inferSetting },\n }),\n items: genAiSpans,\n },\n ];\n}\n"],"names":[],"mappings":";;;;AAOA;AACA;AACA;A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E,YAAA,EAAc;AACnF,OAAO,CAAC;AACR,MAAM,KAAK,EAAE,UAAU;AACvB,KAAK;AACL,GAAG;AACH;;;;"} |
| import { streamedSpanJsonToSerializedSpan } from '../../utils/spanUtils.js'; | ||
| /** | ||
| * Converts a v1 SpanJSON (from a legacy transaction) to a serialized v2 StreamedSpan. | ||
| */ | ||
| function spanJsonToSerializedStreamedSpan(span) { | ||
| const streamedSpan = { | ||
| trace_id: span.trace_id, | ||
| span_id: span.span_id, | ||
| parent_span_id: span.parent_span_id, | ||
| name: span.description || '', | ||
| start_timestamp: span.start_timestamp, | ||
| end_timestamp: span.timestamp || span.start_timestamp, | ||
| status: !span.status || span.status === 'ok' || span.status === 'cancelled' ? 'ok' : 'error', | ||
| is_segment: false, | ||
| attributes: { ...(span.data ) }, | ||
| links: span.links, | ||
| }; | ||
| return streamedSpanJsonToSerializedSpan(streamedSpan); | ||
| } | ||
| export { spanJsonToSerializedStreamedSpan }; | ||
| //# sourceMappingURL=spanJsonToStreamedSpan.js.map |
| {"version":3,"file":"spanJsonToStreamedSpan.js","sources":["../../../../src/tracing/spans/spanJsonToStreamedSpan.ts"],"sourcesContent":["import type { RawAttributes } from '../../attributes';\nimport type { SerializedStreamedSpan, SpanJSON, StreamedSpanJSON } from '../../types-hoist/span';\nimport { streamedSpanJsonToSerializedSpan } from '../../utils/spanUtils';\n\n/**\n * Converts a v1 SpanJSON (from a legacy transaction) to a serialized v2 StreamedSpan.\n */\nexport function spanJsonToSerializedStreamedSpan(span: SpanJSON): SerializedStreamedSpan {\n const streamedSpan: StreamedSpanJSON = {\n trace_id: span.trace_id,\n span_id: span.span_id,\n parent_span_id: span.parent_span_id,\n name: span.description || '',\n start_timestamp: span.start_timestamp,\n end_timestamp: span.timestamp || span.start_timestamp,\n status: !span.status || span.status === 'ok' || span.status === 'cancelled' ? 'ok' : 'error',\n is_segment: false,\n attributes: { ...(span.data as RawAttributes<Record<string, unknown>>) },\n links: span.links,\n };\n\n return streamedSpanJsonToSerializedSpan(streamedSpan);\n}\n"],"names":[],"mappings":";;AAIA;AACA;AACA;AACO,SAAS,gCAAgC,CAAC,IAAI,EAAoC;AACzF,EAAE,MAAM,YAAY,GAAqB;AACzC,IAAI,QAAQ,EAAE,IAAI,CAAC,QAAQ;AAC3B,IAAI,OAAO,EAAE,IAAI,CAAC,OAAO;AACzB,IAAI,cAAc,EAAE,IAAI,CAAC,cAAc;AACvC,IAAI,IAAI,EAAE,IAAI,CAAC,WAAA,IAAe,EAAE;AAChC,IAAI,eAAe,EAAE,IAAI,CAAC,eAAe;AACzC,IAAI,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,CAAC,eAAe;AACzD,IAAI,MAAM,EAAE,CAAC,IAAI,CAAC,MAAA,IAAU,IAAI,CAAC,MAAA,KAAW,IAAA,IAAQ,IAAI,CAAC,MAAA,KAAW,WAAA,GAAc,IAAA,GAAO,OAAO;AAChG,IAAI,UAAU,EAAE,KAAK;AACrB,IAAI,UAAU,EAAE,EAAE,IAAI,IAAI,CAAC,IAAA,EAAK,EAA4C;AAC5E,IAAI,KAAK,EAAE,IAAI,CAAC,KAAK;AACrB,GAAG;;AAEH,EAAE,OAAO,gCAAgC,CAAC,YAAY,CAAC;AACvD;;;;"} |
| /** | ||
| * Browser-specific utilities for Sentry SDKs | ||
| * | ||
| * @module | ||
| */ | ||
| export { getComponentName, getLocationHref, htmlTreeAsString } from './utils/browser'; | ||
| export { supportsDOMError, supportsHistory, supportsNativeFetch, supportsReportingObserver } from './utils/supports'; | ||
| export { XhrBreadcrumbData, XhrBreadcrumbHint } from './types-hoist/breadcrumb'; | ||
| export { HandlerDataXhr, HandlerDataDom, HandlerDataHistory, SentryXhrData, SentryWrappedXMLHttpRequest, } from './types-hoist/instrument'; | ||
| export { BrowserClientReplayOptions, BrowserClientProfilingOptions } from './types-hoist/browseroptions'; | ||
| //# sourceMappingURL=browser-exports.d.ts.map |
| export * from './shared-exports'; | ||
| export * from './browser-exports'; | ||
| //# sourceMappingURL=browser.d.ts.map |
| export { ServerRuntimeClientOptions } from './server-runtime-client'; | ||
| export { ServerRuntimeClient } from './server-runtime-client'; | ||
| export { ServerRuntimeOptions } from './types-hoist/options'; | ||
| export { trpcMiddleware } from './trpc'; | ||
| export { wrapMcpServerWithSentry } from './integrations/mcp-server'; | ||
| export { isNodeEnv, loadModule } from './utils/node'; | ||
| export { filenameIsInApp, node, nodeStackLineParser } from './utils/node-stack-trace'; | ||
| export { vercelWaitUntil } from './utils/vercelWaitUntil'; | ||
| export { flushIfServerless } from './utils/flushIfServerless'; | ||
| export { callFrameToStackFrame, watchdogTimer } from './utils/anr'; | ||
| export { safeUnref as _INTERNAL_safeUnref } from './utils/timer'; | ||
| export { patchExpressModule, setupExpressErrorHandler, expressErrorHandler } from './integrations/express/index'; | ||
| export { ExpressIntegrationOptions, ExpressHandlerOptions, ExpressMiddleware, ExpressErrorMiddleware, } from './integrations/express/types'; | ||
| export { instrumentPostgresJsSql } from './integrations/postgresjs'; | ||
| export { patchHttpModuleClient } from './integrations/http/client-patch'; | ||
| export { getHttpClientSubscriptions } from './integrations/http/client-subscriptions'; | ||
| export { addOutgoingRequestBreadcrumb } from './integrations/http/add-outgoing-request-breadcrumb'; | ||
| export { getRequestUrl, getRequestUrlObject, getRequestUrlFromClientRequest, getRequestOptions, } from './integrations/http/get-request-url'; | ||
| export { HTTP_ON_CLIENT_REQUEST, HTTP_ON_SERVER_REQUEST } from './integrations/http/constants'; | ||
| export { HttpInstrumentationOptions, HttpClientRequest, HttpIncomingMessage, HttpServerResponse, HttpModuleExport, } from './integrations/http/types'; | ||
| //# sourceMappingURL=server-exports.d.ts.map |
| /** | ||
| * The Sentry core SDK and integrations used by node, node-core, cloudflare, | ||
| * bun, deno, aws lambda, and other server-side platforms, where bundle size | ||
| * is less of an issue. | ||
| * | ||
| * This export should not contain anything strictly browser-specific. | ||
| */ | ||
| export * from './shared-exports'; | ||
| export * from './server-exports'; | ||
| //# sourceMappingURL=server.d.ts.map |
| export { ClientClass as SentryCoreCurrentScopes } from './sdk'; | ||
| export { AsyncContextStrategy } from './asyncContext/types'; | ||
| export { Carrier } from './carrier'; | ||
| export { OfflineStore, OfflineTransportOptions } from './transports/offline'; | ||
| export { IntegrationIndex } from './integration'; | ||
| export * from './tracing'; | ||
| export * from './semanticAttributes'; | ||
| export { createEventEnvelope, createSessionEnvelope, createSpanEnvelope } from './envelope'; | ||
| export { captureCheckIn, withMonitor, captureException, captureEvent, captureMessage, lastEventId, close, flush, setContext, setExtra, setExtras, setTag, setTags, setUser, setConversationId, isInitialized, isEnabled, startSession, endSession, captureSession, addEventProcessor, } from './exports'; | ||
| export { getCurrentScope, getIsolationScope, getGlobalScope, withScope, withIsolationScope, getClient, getTraceContextFromScope, registerExternalPropagationContext, getExternalPropagationContext, hasExternalPropagationContext, } from './currentScopes'; | ||
| export { getDefaultCurrentScope, getDefaultIsolationScope } from './defaultScopes'; | ||
| export { setAsyncContextStrategy } from './asyncContext'; | ||
| export { getGlobalSingleton, getMainCarrier } from './carrier'; | ||
| export { makeSession, closeSession, updateSession } from './session'; | ||
| export { Scope } from './scope'; | ||
| export { CaptureContext, ScopeContext, ScopeData } from './scope'; | ||
| export { notifyEventProcessors } from './eventProcessors'; | ||
| export { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint, SENTRY_API_VERSION } from './api'; | ||
| export { Client } from './client'; | ||
| export { initAndBind, setCurrentClient } from './sdk'; | ||
| export { createTransport } from './transports/base'; | ||
| export { makeOfflineTransport } from './transports/offline'; | ||
| export { makeMultiplexedTransport, MULTIPLEXED_TRANSPORT_EXTRA_KEY } from './transports/multiplexed'; | ||
| export { getIntegrationsToSetup, addIntegration, defineIntegration, installedIntegrations } from './integration'; | ||
| export { _INTERNAL_skipAiProviderWrapping, _INTERNAL_shouldSkipAiProviderWrapping, _INTERNAL_clearAiProviderSkips, } from './utils/ai/providerSkip'; | ||
| export { envToBool } from './utils/envToBool'; | ||
| export { applyScopeDataToEvent, mergeScopeData, getCombinedScopeData } from './utils/scopeData'; | ||
| export { prepareEvent } from './utils/prepareEvent'; | ||
| export { ExclusiveEventHintOrCaptureContext } from './utils/prepareEvent'; | ||
| export { createCheckInEnvelope } from './checkin'; | ||
| export { hasSpansEnabled } from './utils/hasSpansEnabled'; | ||
| export { withStreamedSpan } from './tracing/spans/beforeSendSpan'; | ||
| export { isStreamedBeforeSendSpanCallback } from './tracing/spans/beforeSendSpan'; | ||
| export { safeSetSpanJSONAttributes } from './tracing/spans/captureSpan'; | ||
| export { isSentryRequestUrl } from './utils/isSentryRequestUrl'; | ||
| export { handleCallbackErrors } from './utils/handleCallbackErrors'; | ||
| export { parameterize, fmt } from './utils/parameterize'; | ||
| export { HandleTunnelRequestOptions } from './utils/tunnel'; | ||
| export { handleTunnelRequest } from './utils/tunnel'; | ||
| export { addAutoIpAddressToSession } from './utils/ipAddress'; | ||
| export { addAutoIpAddressToUser } from './utils/ipAddress'; | ||
| export { convertSpanLinksForEnvelope, spanToTraceHeader, spanToJSON, spanToStreamedSpanJSON, spanIsSampled, spanToTraceContext, getSpanDescendants, getStatusMessage, getRootSpan, INTERNAL_getSegmentSpan, getActiveSpan, addChildSpanToSpan, spanTimeInputToSeconds, updateSpanName, } from './utils/spanUtils'; | ||
| export { _setSpanForScope as _INTERNAL_setSpanForScope } from './utils/spanOnScope'; | ||
| export { parseSampleRate } from './utils/parseSampleRate'; | ||
| export { applySdkMetadata } from './utils/sdkMetadata'; | ||
| export { getTraceData } from './utils/traceData'; | ||
| export { shouldPropagateTraceForUrl } from './utils/tracePropagationTargets'; | ||
| export { getTraceMetaTags } from './utils/meta'; | ||
| export { debounce } from './utils/debounce'; | ||
| export { makeWeakRef, derefWeakRef } from './utils/weakRef'; | ||
| export { MaybeWeakRef } from './utils/weakRef'; | ||
| export { shouldIgnoreSpan } from './utils/should-ignore-span'; | ||
| export { winterCGHeadersToDict, winterCGRequestToRequestData, captureBodyFromWinterCGRequest, httpRequestToRequestData, extractQueryParamsFromUrl, headersToDict, httpHeadersToSpanAttributes, getMaxBodyByteLength, MAX_BODY_BYTE_LENGTH, } from './utils/request'; | ||
| export { MaxRequestBodySize } from './utils/request'; | ||
| export { DEFAULT_ENVIRONMENT, DEV_ENVIRONMENT } from './constants'; | ||
| export { addBreadcrumb } from './breadcrumbs'; | ||
| export { functionToStringIntegration } from './integrations/functiontostring'; | ||
| export { inboundFiltersIntegration } from './integrations/eventFilters'; | ||
| export { eventFiltersIntegration } from './integrations/eventFilters'; | ||
| export { linkedErrorsIntegration } from './integrations/linkederrors'; | ||
| export { moduleMetadataIntegration } from './integrations/moduleMetadata'; | ||
| export { requestDataIntegration } from './integrations/requestdata'; | ||
| export { captureConsoleIntegration } from './integrations/captureconsole'; | ||
| export { dedupeIntegration } from './integrations/dedupe'; | ||
| export { extraErrorDataIntegration } from './integrations/extraerrordata'; | ||
| export { rewriteFramesIntegration } from './integrations/rewriteframes'; | ||
| export { supabaseIntegration, instrumentSupabaseClient } from './integrations/supabase'; | ||
| export { zodErrorsIntegration } from './integrations/zoderrors'; | ||
| export { thirdPartyErrorFilterIntegration } from './integrations/third-party-errors-filter'; | ||
| export { consoleIntegration } from './integrations/console'; | ||
| export { FeatureFlagsIntegration } from './integrations/featureFlags'; | ||
| export { featureFlagsIntegration } from './integrations/featureFlags'; | ||
| export { growthbookIntegration } from './integrations/featureFlags'; | ||
| export { conversationIdIntegration } from './integrations/conversationId'; | ||
| export { profiler } from './profiling'; | ||
| export { instrumentFetchRequest, _INTERNAL_getTracingHeadersForFetchRequest } from './fetch'; | ||
| export { captureFeedback } from './feedback'; | ||
| export { ReportDialogOptions } from './report-dialog'; | ||
| export { _INTERNAL_captureLog, _INTERNAL_flushLogsBuffer, _INTERNAL_captureSerializedLog } from './logs/internal'; | ||
| import * as logger_1 from './logs/public-api'; | ||
| export { logger_1 as logger }; | ||
| export { consoleLoggingIntegration } from './logs/console-integration'; | ||
| export { _INTERNAL_captureMetric, _INTERNAL_flushMetricsBuffer, _INTERNAL_captureSerializedMetric, } from './metrics/internal'; | ||
| import * as metrics_1 from './metrics/public-api'; | ||
| export { metrics_1 as metrics }; | ||
| export { MetricOptions } from './metrics/public-api'; | ||
| export { createConsolaReporter } from './integrations/consola'; | ||
| export { addVercelAiProcessors } from './tracing/vercel-ai'; | ||
| export { _INTERNAL_getSpanContextForToolCallId, _INTERNAL_cleanupToolCallSpanContext } from './tracing/vercel-ai/utils'; | ||
| export { toolCallSpanContextMap as _INTERNAL_toolCallSpanContextMap } from './tracing/vercel-ai/constants'; | ||
| export { instrumentOpenAiClient } from './tracing/openai'; | ||
| export { OPENAI_INTEGRATION_NAME } from './tracing/openai/constants'; | ||
| export { instrumentAnthropicAiClient } from './tracing/anthropic-ai'; | ||
| export { ANTHROPIC_AI_INTEGRATION_NAME } from './tracing/anthropic-ai/constants'; | ||
| export { instrumentGoogleGenAIClient } from './tracing/google-genai'; | ||
| export { GOOGLE_GENAI_INTEGRATION_NAME } from './tracing/google-genai/constants'; | ||
| export { GoogleGenAIResponse } from './tracing/google-genai/types'; | ||
| export { createLangChainCallbackHandler, instrumentLangChainEmbeddings } from './tracing/langchain'; | ||
| export { LANGCHAIN_INTEGRATION_NAME } from './tracing/langchain/constants'; | ||
| export { LangChainOptions, LangChainIntegration } from './tracing/langchain/types'; | ||
| export { instrumentStateGraphCompile, instrumentCreateReactAgent, instrumentLangGraph } from './tracing/langgraph'; | ||
| export { LANGGRAPH_INTEGRATION_NAME } from './tracing/langgraph/constants'; | ||
| export { LangGraphOptions, LangGraphIntegration, CompiledGraph } from './tracing/langgraph/types'; | ||
| export { OpenAiClient, OpenAiOptions, InstrumentedMethod } from './tracing/openai/types'; | ||
| export { AnthropicAiClient, AnthropicAiOptions, AnthropicAiInstrumentedMethod, AnthropicAiResponse, } from './tracing/anthropic-ai/types'; | ||
| export { GoogleGenAIClient, GoogleGenAIChat, GoogleGenAIOptions, GoogleGenAIInstrumentedMethod, } from './tracing/google-genai/types'; | ||
| export { GoogleGenAIIstrumentedMethod } from './tracing/google-genai/types'; | ||
| export { SpanBuffer } from './tracing/spans/spanBuffer'; | ||
| export { hasSpanStreamingEnabled } from './tracing/spans/hasSpanStreamingEnabled'; | ||
| export { spanStreamingIntegration } from './integrations/spanStreaming'; | ||
| export { FeatureFlag } from './utils/featureFlags'; | ||
| export { _INTERNAL_copyFlagsFromScopeToEvent, _INTERNAL_insertFlagToScope, _INTERNAL_addFeatureFlagToActiveSpan, _INTERNAL_FLAG_BUFFER_SIZE, _INTERNAL_MAX_FLAGS_PER_SPAN, } from './utils/featureFlags'; | ||
| export { applyAggregateErrorsToEvent } from './utils/aggregate-errors'; | ||
| export { getBreadcrumbLogLevelFromHttpStatusCode } from './utils/breadcrumb-log-level'; | ||
| export { dsnFromString, dsnToString, makeDsn } from './utils/dsn'; | ||
| export { SentryError } from './utils/error'; | ||
| export { GLOBAL_OBJ } from './utils/worldwide'; | ||
| export { InternalGlobal } from './utils/worldwide'; | ||
| export { addConsoleInstrumentationHandler, addConsoleInstrumentationFilter } from './instrument/console'; | ||
| export { addFetchEndInstrumentationHandler, addFetchInstrumentationHandler } from './instrument/fetch'; | ||
| export { addGlobalErrorInstrumentationHandler } from './instrument/globalError'; | ||
| export { addGlobalUnhandledRejectionInstrumentationHandler } from './instrument/globalUnhandledRejection'; | ||
| export { addHandler, maybeInstrument, resetInstrumentationHandlers, triggerHandlers } from './instrument/handlers'; | ||
| export { isDOMError, isDOMException, isElement, isError, isErrorEvent, isEvent, isInstanceOf, isParameterizedString, isPlainObject, isPrimitive, isRegExp, isString, isSyntheticEvent, isThenable, isVueViewModel, } from './utils/is'; | ||
| export { isBrowser } from './utils/isBrowser'; | ||
| export { CONSOLE_LEVELS, consoleSandbox, debug, originalConsoleMethods } from './utils/debug-logger'; | ||
| export { SentryDebugLogger } from './utils/debug-logger'; | ||
| export { addContextToFrame, addExceptionMechanism, addExceptionTypeValue, checkOrSetAlreadyCaught, isAlreadyCaptured, getEventDescription, parseSemver, uuid4, } from './utils/misc'; | ||
| export { normalize, normalizeToSize, normalizeUrlToBase } from './utils/normalize'; | ||
| export { setNormalizationDepthOverrideHint, setSkipNormalizationHint } from './utils/normalizationHints'; | ||
| export { addNonEnumerableProperty, convertToPlainObject, dropUndefinedKeys, extractExceptionKeysForMessage, fill, getOriginalFunction, markFunctionWrapped, objectify, } from './utils/object'; | ||
| export { basename, dirname, isAbsolute, join, normalizePath, relative, resolve } from './utils/path'; | ||
| export { makePromiseBuffer, SENTRY_BUFFER_FULL_ERROR } from './utils/promisebuffer'; | ||
| export { PromiseBuffer } from './utils/promisebuffer'; | ||
| export { severityLevelFromString } from './utils/severity'; | ||
| export { replaceExports } from './utils/exports'; | ||
| export { UNKNOWN_FUNCTION, createStackParser, getFramesFromEvent, getFunctionName, stackParserFromStackParserOptions, stripSentryFramesAndReverse, } from './utils/stacktrace'; | ||
| export { isMatchingPattern, safeJoin, snipLine, stringMatchesSomePattern, truncate } from './utils/string'; | ||
| export { isNativeFunction, supportsDOMException, supportsErrorEvent, supportsFetch, supportsReferrerPolicy, } from './utils/supports'; | ||
| export { SyncPromise, rejectedSyncPromise, resolvedSyncPromise } from './utils/syncpromise'; | ||
| export { browserPerformanceTimeOrigin, dateTimestampInSeconds, timestampInSeconds } from './utils/time'; | ||
| export { TRACEPARENT_REGEXP, extractTraceparentData, generateSentryTraceHeader, propagationContextFromHeaders, shouldContinueTrace, generateTraceparentHeader, } from './utils/tracing'; | ||
| export { getSDKSource, isBrowserBundle } from './utils/env'; | ||
| export { SdkSource } from './utils/env'; | ||
| export { addItemToEnvelope, createAttachmentEnvelopeItem, createEnvelope, createEventEnvelopeHeaders, createSpanEnvelopeItem, envelopeContainsItemType, envelopeItemTypeToDataCategory, forEachEnvelopeItem, getSdkMetadataForEnvelopeHeader, parseEnvelope, serializeEnvelope, } from './utils/envelope'; | ||
| export { createClientReportEnvelope } from './utils/clientreport'; | ||
| export { DEFAULT_RETRY_AFTER, disabledUntil, isRateLimited, parseRetryAfterHeader, updateRateLimits, } from './utils/ratelimit'; | ||
| export { RateLimits } from './utils/ratelimit'; | ||
| export { MAX_BAGGAGE_STRING_LENGTH, SENTRY_BAGGAGE_KEY_PREFIX, SENTRY_BAGGAGE_KEY_PREFIX_REGEX, baggageHeaderToDynamicSamplingContext, dynamicSamplingContextToSentryBaggageHeader, parseBaggageHeader, objectToBaggageHeader, mergeBaggageHeaders, } from './utils/baggage'; | ||
| export { getSanitizedUrlString, parseUrl, stripUrlQueryAndFragment, parseStringToURLObject, getHttpSpanDetailsFromUrlObject, isURLObjectRelative, getSanitizedUrlStringFromUrlObject, stripDataUrlContent, } from './utils/url'; | ||
| export { eventFromMessage, eventFromUnknownInput, exceptionFromError, parseStackFrames, _enhanceErrorWithSentryInfo as _INTERNAL_enhanceErrorWithSentryInfo, } from './utils/eventbuilder'; | ||
| export { LRUMap } from './utils/lru'; | ||
| export { generateTraceId, generateSpanId } from './utils/propagationContext'; | ||
| export { SDK_VERSION } from './utils/version'; | ||
| export { getDebugImagesForResources, getFilenameToDebugIdMap } from './utils/debug-ids'; | ||
| export { getFilenameToMetadataMap } from './metadata'; | ||
| export { escapeStringForRegex } from './vendor/escapeStringForRegex'; | ||
| export { Attachment } from './types-hoist/attachment'; | ||
| export { Breadcrumb, BreadcrumbHint, FetchBreadcrumbData, FetchBreadcrumbHint } from './types-hoist/breadcrumb'; | ||
| export { ClientReport, Outcome, EventDropReason } from './types-hoist/clientreport'; | ||
| export { Context, Contexts, DeviceContext, OsContext, AppContext, CultureContext, TraceContext, CloudResourceContext, MissingInstrumentationContext, } from './types-hoist/context'; | ||
| export { DataCategory } from './types-hoist/datacategory'; | ||
| export { DsnComponents, DsnLike, DsnProtocol } from './types-hoist/dsn'; | ||
| export { DebugImage, DebugMeta } from './types-hoist/debugMeta'; | ||
| export { AttachmentItem, BaseEnvelopeHeaders, BaseEnvelopeItemHeaders, ClientReportEnvelope, ClientReportItem, DynamicSamplingContext, Envelope, EnvelopeItemType, EnvelopeItem, EventEnvelope, EventEnvelopeHeaders, EventItem, ReplayEnvelope, FeedbackItem, SessionEnvelope, SessionItem, UserFeedbackItem, CheckInItem, CheckInEnvelope, RawSecurityEnvelope, RawSecurityItem, ProfileItem, ProfileChunkEnvelope, ProfileChunkItem, SpanEnvelope, StreamedSpanEnvelope, SpanItem, LogEnvelope, MetricEnvelope, } from './types-hoist/envelope'; | ||
| export { ExtendedError } from './types-hoist/error'; | ||
| export { Event, EventHint, EventType, ErrorEvent, TransactionEvent } from './types-hoist/event'; | ||
| export { EventProcessor } from './types-hoist/eventprocessor'; | ||
| export { Exception } from './types-hoist/exception'; | ||
| export { Extra, Extras } from './types-hoist/extra'; | ||
| export { Integration, IntegrationFn } from './types-hoist/integration'; | ||
| export { Mechanism } from './types-hoist/mechanism'; | ||
| export { ExtractedNodeRequestData, HttpHeaderValue, Primitive, WorkerLocation } from './types-hoist/misc'; | ||
| export { ClientOptions, CoreOptions as Options } from './types-hoist/options'; | ||
| export { Package } from './types-hoist/package'; | ||
| export { PolymorphicEvent, PolymorphicRequest } from './types-hoist/polymorphics'; | ||
| export { ThreadId, FrameId, StackId, ThreadCpuSample, ThreadCpuStack, ThreadCpuFrame, ThreadCpuProfile, ContinuousThreadCpuProfile, Profile, ProfileChunk, } from './types-hoist/profiling'; | ||
| export { ReplayEndEvent, ReplayEvent, ReplayRecordingData, ReplayRecordingMode, ReplayStartEvent, ReplayStopReason, } from './types-hoist/replay'; | ||
| export { FeedbackErrorCode, FeedbackErrorMessages, FeedbackEvent, FeedbackFormData, FeedbackInternalOptions, FeedbackModalIntegration, FeedbackScreenshotIntegration, SendFeedback, SendFeedbackParams, UserFeedback, } from './types-hoist/feedback'; | ||
| export { QueryParams, RequestEventData, RequestHookInfo, ResponseHookInfo, SanitizedRequestData, } from './types-hoist/request'; | ||
| export { Runtime } from './types-hoist/runtime'; | ||
| export { SdkInfo } from './types-hoist/sdkinfo'; | ||
| export { SdkMetadata } from './types-hoist/sdkmetadata'; | ||
| export { SessionAggregates, AggregationCounts, Session, SessionContext, SessionStatus, SerializedSession, } from './types-hoist/session'; | ||
| export { SeverityLevel } from './types-hoist/severity'; | ||
| export { Span, SentrySpanArguments, SpanOrigin, SpanAttributeValue, SpanAttributes, SpanTimeInput, SpanJSON, SpanContextData, TraceFlag, SerializedStreamedSpan, SerializedStreamedSpanContainer, StreamedSpanJSON, } from './types-hoist/span'; | ||
| export { SpanStatus } from './types-hoist/spanStatus'; | ||
| export { Log, LogSeverityLevel } from './types-hoist/log'; | ||
| export { SpanLink } from './types-hoist/link'; | ||
| export { Metric, MetricType, SerializedMetric, SerializedMetricContainer, SerializedMetricAttributeValue, } from './types-hoist/metric'; | ||
| export { TimedEvent } from './types-hoist/timedEvent'; | ||
| export { StackFrame } from './types-hoist/stackframe'; | ||
| export { Stacktrace, StackParser, StackLineParser, StackLineParserFn } from './types-hoist/stacktrace'; | ||
| export { PropagationContext, TracePropagationTargets, SerializedTraceData } from './types-hoist/tracing'; | ||
| export { StartSpanOptions } from './types-hoist/startSpanOptions'; | ||
| export { TraceparentData, TransactionSource } from './types-hoist/transaction'; | ||
| export { TracesSamplerSamplingContext, CustomSamplingContext, SamplingContext, } from './types-hoist/samplingcontext'; | ||
| export { DurationUnit, InformationUnit, FractionUnit, MeasurementUnit, NoneUnit, Measurements, } from './types-hoist/measurement'; | ||
| export { Thread } from './types-hoist/thread'; | ||
| export { Transport, TransportRequest, TransportMakeRequestResponse, InternalBaseTransportOptions, BaseTransportOptions, TransportRequestExecutor, } from './types-hoist/transport'; | ||
| export { User } from './types-hoist/user'; | ||
| export { WebFetchHeaders, WebFetchRequest } from './types-hoist/webfetchapi'; | ||
| export { WrappedFunction } from './types-hoist/wrappedfunction'; | ||
| export { HandlerDataFetch, HandlerDataConsole, HandlerDataError, HandlerDataUnhandledRejection, ConsoleLevel, } from './types-hoist/instrument'; | ||
| export { CheckIn, MonitorConfig, FinishedCheckIn, InProgressCheckIn, SerializedCheckIn, } from './types-hoist/checkin'; | ||
| export { ParameterizedString } from './types-hoist/parameterize'; | ||
| export { ContinuousProfiler, ProfilingIntegration, Profiler } from './types-hoist/profiling'; | ||
| export { ViewHierarchyData, ViewHierarchyWindow } from './types-hoist/view-hierarchy'; | ||
| export { LegacyCSPReport } from './types-hoist/csp'; | ||
| export { SerializedLog, SerializedLogContainer } from './types-hoist/log'; | ||
| export { BuildTimeOptionsBase, UnstableVitePluginOptions, UnstableRollupPluginOptions, UnstableWebpackPluginOptions, } from './build-time-plugins/buildTimeOptionsBase'; | ||
| export { RandomSafeContextRunner as _INTERNAL_RandomSafeContextRunner } from './utils/randomSafeContext'; | ||
| export { withRandomSafeContext as _INTERNAL_withRandomSafeContext, safeMathRandom as _INTERNAL_safeMathRandom, safeDateNow as _INTERNAL_safeDateNow, } from './utils/randomSafeContext'; | ||
| //# sourceMappingURL=shared-exports.d.ts.map |
| import { Client } from '../../client'; | ||
| import { SpanContainerItem } from '../../types-hoist/envelope'; | ||
| import { Event } from '../../types-hoist/event'; | ||
| /** | ||
| * Extracts gen_ai spans from a transaction event, converts them to span v2 format, | ||
| * and returns them as a SpanContainerItem. | ||
| * | ||
| * Only applies to static mode (non-streaming) transactions. | ||
| * | ||
| * WARNING: This function mutates `event.spans` by removing the extracted gen_ai spans | ||
| * from the array. Call this before creating the event envelope so the transaction | ||
| * item does not include the extracted spans. | ||
| */ | ||
| export declare function extractGenAiSpansFromEvent(event: Event, client: Client): SpanContainerItem | undefined; | ||
| //# sourceMappingURL=extractGenAiSpans.d.ts.map |
| import { SerializedStreamedSpan, SpanJSON } from '../../types-hoist/span'; | ||
| /** | ||
| * Converts a v1 SpanJSON (from a legacy transaction) to a serialized v2 StreamedSpan. | ||
| */ | ||
| export declare function spanJsonToSerializedStreamedSpan(span: SpanJSON): SerializedStreamedSpan; | ||
| //# sourceMappingURL=spanJsonToStreamedSpan.d.ts.map |
| /** | ||
| * Browser-specific utilities for Sentry SDKs | ||
| * | ||
| * @module | ||
| */ | ||
| export { getComponentName, getLocationHref, htmlTreeAsString } from './utils/browser'; | ||
| export { supportsDOMError, supportsHistory, supportsNativeFetch, supportsReportingObserver } from './utils/supports'; | ||
| export type { XhrBreadcrumbData, XhrBreadcrumbHint } from './types-hoist/breadcrumb'; | ||
| export type { HandlerDataXhr, HandlerDataDom, HandlerDataHistory, SentryXhrData, SentryWrappedXMLHttpRequest, } from './types-hoist/instrument'; | ||
| export type { BrowserClientReplayOptions, BrowserClientProfilingOptions } from './types-hoist/browseroptions'; | ||
| //# sourceMappingURL=browser-exports.d.ts.map |
| {"version":3,"file":"browser-exports.d.ts","sourceRoot":"","sources":["../../src/browser-exports.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AACrH,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACrF,YAAY,EACV,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,0BAA0B,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC"} |
| export * from './shared-exports'; | ||
| export * from './browser-exports'; | ||
| //# sourceMappingURL=browser.d.ts.map |
| {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"} |
| /** | ||
| * Server-only utilities for Sentry SDKs. | ||
| * | ||
| * @module | ||
| */ | ||
| export type { ServerRuntimeClientOptions } from './server-runtime-client'; | ||
| export { ServerRuntimeClient } from './server-runtime-client'; | ||
| export type { ServerRuntimeOptions } from './types-hoist/options'; | ||
| export { trpcMiddleware } from './trpc'; | ||
| export { wrapMcpServerWithSentry } from './integrations/mcp-server'; | ||
| export { isNodeEnv, loadModule } from './utils/node'; | ||
| export { filenameIsInApp, node, nodeStackLineParser } from './utils/node-stack-trace'; | ||
| export { vercelWaitUntil } from './utils/vercelWaitUntil'; | ||
| export { flushIfServerless } from './utils/flushIfServerless'; | ||
| export { callFrameToStackFrame, watchdogTimer } from './utils/anr'; | ||
| export { safeUnref as _INTERNAL_safeUnref } from './utils/timer'; | ||
| export { patchExpressModule, setupExpressErrorHandler, expressErrorHandler } from './integrations/express/index'; | ||
| export type { ExpressIntegrationOptions, ExpressHandlerOptions, ExpressMiddleware, ExpressErrorMiddleware, } from './integrations/express/types'; | ||
| export { instrumentPostgresJsSql } from './integrations/postgresjs'; | ||
| export { patchHttpModuleClient } from './integrations/http/client-patch'; | ||
| export { getHttpClientSubscriptions } from './integrations/http/client-subscriptions'; | ||
| export { addOutgoingRequestBreadcrumb } from './integrations/http/add-outgoing-request-breadcrumb'; | ||
| export { getRequestUrl, getRequestUrlObject, getRequestUrlFromClientRequest, getRequestOptions, } from './integrations/http/get-request-url'; | ||
| export { HTTP_ON_CLIENT_REQUEST, HTTP_ON_SERVER_REQUEST } from './integrations/http/constants'; | ||
| export type { HttpInstrumentationOptions, HttpClientRequest, HttpIncomingMessage, HttpServerResponse, HttpModuleExport, } from './integrations/http/types'; | ||
| //# sourceMappingURL=server-exports.d.ts.map |
| {"version":3,"file":"server-exports.d.ts","sourceRoot":"","sources":["../../src/server-exports.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,SAAS,IAAI,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACjH,YAAY,EACV,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,qDAAqD,CAAC;AACnG,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,8BAA8B,EAC9B,iBAAiB,GAClB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC/F,YAAY,EACV,0BAA0B,EAC1B,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC"} |
| /** | ||
| * The Sentry core SDK and integrations used by node, node-core, cloudflare, | ||
| * bun, deno, aws lambda, and other server-side platforms, where bundle size | ||
| * is less of an issue. | ||
| * | ||
| * This export should not contain anything strictly browser-specific. | ||
| */ | ||
| export * from './shared-exports'; | ||
| export * from './server-exports'; | ||
| //# sourceMappingURL=server.d.ts.map |
| {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"} |
| /** | ||
| * Utilites shared between server and browser SDKs. | ||
| */ | ||
| export type { ClientClass as SentryCoreCurrentScopes } from './sdk'; | ||
| export type { AsyncContextStrategy } from './asyncContext/types'; | ||
| export type { Carrier } from './carrier'; | ||
| export type { OfflineStore, OfflineTransportOptions } from './transports/offline'; | ||
| export type { IntegrationIndex } from './integration'; | ||
| export * from './tracing'; | ||
| export * from './semanticAttributes'; | ||
| export { createEventEnvelope, createSessionEnvelope, createSpanEnvelope } from './envelope'; | ||
| export { captureCheckIn, withMonitor, captureException, captureEvent, captureMessage, lastEventId, close, flush, setContext, setExtra, setExtras, setTag, setTags, setUser, setConversationId, isInitialized, isEnabled, startSession, endSession, captureSession, addEventProcessor, } from './exports'; | ||
| export { getCurrentScope, getIsolationScope, getGlobalScope, withScope, withIsolationScope, getClient, getTraceContextFromScope, registerExternalPropagationContext, getExternalPropagationContext, hasExternalPropagationContext, } from './currentScopes'; | ||
| export { getDefaultCurrentScope, getDefaultIsolationScope } from './defaultScopes'; | ||
| export { setAsyncContextStrategy } from './asyncContext'; | ||
| export { getGlobalSingleton, getMainCarrier } from './carrier'; | ||
| export { makeSession, closeSession, updateSession } from './session'; | ||
| export { Scope } from './scope'; | ||
| export type { CaptureContext, ScopeContext, ScopeData } from './scope'; | ||
| export { notifyEventProcessors } from './eventProcessors'; | ||
| export { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint, SENTRY_API_VERSION } from './api'; | ||
| export { Client } from './client'; | ||
| export { initAndBind, setCurrentClient } from './sdk'; | ||
| export { createTransport } from './transports/base'; | ||
| export { makeOfflineTransport } from './transports/offline'; | ||
| export { makeMultiplexedTransport, MULTIPLEXED_TRANSPORT_EXTRA_KEY } from './transports/multiplexed'; | ||
| export { getIntegrationsToSetup, addIntegration, defineIntegration, installedIntegrations } from './integration'; | ||
| export { _INTERNAL_skipAiProviderWrapping, _INTERNAL_shouldSkipAiProviderWrapping, _INTERNAL_clearAiProviderSkips, } from './utils/ai/providerSkip'; | ||
| export { envToBool } from './utils/envToBool'; | ||
| export { applyScopeDataToEvent, mergeScopeData, getCombinedScopeData } from './utils/scopeData'; | ||
| export { prepareEvent } from './utils/prepareEvent'; | ||
| export type { ExclusiveEventHintOrCaptureContext } from './utils/prepareEvent'; | ||
| export { createCheckInEnvelope } from './checkin'; | ||
| export { hasSpansEnabled } from './utils/hasSpansEnabled'; | ||
| export { withStreamedSpan } from './tracing/spans/beforeSendSpan'; | ||
| export { isStreamedBeforeSendSpanCallback } from './tracing/spans/beforeSendSpan'; | ||
| export { safeSetSpanJSONAttributes } from './tracing/spans/captureSpan'; | ||
| export { isSentryRequestUrl } from './utils/isSentryRequestUrl'; | ||
| export { handleCallbackErrors } from './utils/handleCallbackErrors'; | ||
| export { parameterize, fmt } from './utils/parameterize'; | ||
| export type { HandleTunnelRequestOptions } from './utils/tunnel'; | ||
| export { handleTunnelRequest } from './utils/tunnel'; | ||
| export { addAutoIpAddressToSession } from './utils/ipAddress'; | ||
| export { addAutoIpAddressToUser } from './utils/ipAddress'; | ||
| export { convertSpanLinksForEnvelope, spanToTraceHeader, spanToJSON, spanToStreamedSpanJSON, spanIsSampled, spanToTraceContext, getSpanDescendants, getStatusMessage, getRootSpan, INTERNAL_getSegmentSpan, getActiveSpan, addChildSpanToSpan, spanTimeInputToSeconds, updateSpanName, } from './utils/spanUtils'; | ||
| export { _setSpanForScope as _INTERNAL_setSpanForScope } from './utils/spanOnScope'; | ||
| export { parseSampleRate } from './utils/parseSampleRate'; | ||
| export { applySdkMetadata } from './utils/sdkMetadata'; | ||
| export { getTraceData } from './utils/traceData'; | ||
| export { shouldPropagateTraceForUrl } from './utils/tracePropagationTargets'; | ||
| export { getTraceMetaTags } from './utils/meta'; | ||
| export { debounce } from './utils/debounce'; | ||
| export { makeWeakRef, derefWeakRef } from './utils/weakRef'; | ||
| export type { MaybeWeakRef } from './utils/weakRef'; | ||
| export { shouldIgnoreSpan } from './utils/should-ignore-span'; | ||
| export { winterCGHeadersToDict, winterCGRequestToRequestData, captureBodyFromWinterCGRequest, httpRequestToRequestData, extractQueryParamsFromUrl, headersToDict, httpHeadersToSpanAttributes, getMaxBodyByteLength, MAX_BODY_BYTE_LENGTH, } from './utils/request'; | ||
| export type { MaxRequestBodySize } from './utils/request'; | ||
| export { DEFAULT_ENVIRONMENT, DEV_ENVIRONMENT } from './constants'; | ||
| export { addBreadcrumb } from './breadcrumbs'; | ||
| export { functionToStringIntegration } from './integrations/functiontostring'; | ||
| export { inboundFiltersIntegration } from './integrations/eventFilters'; | ||
| export { eventFiltersIntegration } from './integrations/eventFilters'; | ||
| export { linkedErrorsIntegration } from './integrations/linkederrors'; | ||
| export { moduleMetadataIntegration } from './integrations/moduleMetadata'; | ||
| export { requestDataIntegration } from './integrations/requestdata'; | ||
| export { captureConsoleIntegration } from './integrations/captureconsole'; | ||
| export { dedupeIntegration } from './integrations/dedupe'; | ||
| export { extraErrorDataIntegration } from './integrations/extraerrordata'; | ||
| export { rewriteFramesIntegration } from './integrations/rewriteframes'; | ||
| export { supabaseIntegration, instrumentSupabaseClient } from './integrations/supabase'; | ||
| export { zodErrorsIntegration } from './integrations/zoderrors'; | ||
| export { thirdPartyErrorFilterIntegration } from './integrations/third-party-errors-filter'; | ||
| export { consoleIntegration } from './integrations/console'; | ||
| export type { FeatureFlagsIntegration } from './integrations/featureFlags'; | ||
| export { featureFlagsIntegration } from './integrations/featureFlags'; | ||
| export { growthbookIntegration } from './integrations/featureFlags'; | ||
| export { conversationIdIntegration } from './integrations/conversationId'; | ||
| export { profiler } from './profiling'; | ||
| export { instrumentFetchRequest, _INTERNAL_getTracingHeadersForFetchRequest } from './fetch'; | ||
| export { captureFeedback } from './feedback'; | ||
| export type { ReportDialogOptions } from './report-dialog'; | ||
| export { _INTERNAL_captureLog, _INTERNAL_flushLogsBuffer, _INTERNAL_captureSerializedLog } from './logs/internal'; | ||
| export * as logger from './logs/public-api'; | ||
| export { consoleLoggingIntegration } from './logs/console-integration'; | ||
| export { _INTERNAL_captureMetric, _INTERNAL_flushMetricsBuffer, _INTERNAL_captureSerializedMetric, } from './metrics/internal'; | ||
| export * as metrics from './metrics/public-api'; | ||
| export type { MetricOptions } from './metrics/public-api'; | ||
| export { createConsolaReporter } from './integrations/consola'; | ||
| export { addVercelAiProcessors } from './tracing/vercel-ai'; | ||
| export { _INTERNAL_getSpanContextForToolCallId, _INTERNAL_cleanupToolCallSpanContext } from './tracing/vercel-ai/utils'; | ||
| export { toolCallSpanContextMap as _INTERNAL_toolCallSpanContextMap } from './tracing/vercel-ai/constants'; | ||
| export { instrumentOpenAiClient } from './tracing/openai'; | ||
| export { OPENAI_INTEGRATION_NAME } from './tracing/openai/constants'; | ||
| export { instrumentAnthropicAiClient } from './tracing/anthropic-ai'; | ||
| export { ANTHROPIC_AI_INTEGRATION_NAME } from './tracing/anthropic-ai/constants'; | ||
| export { instrumentGoogleGenAIClient } from './tracing/google-genai'; | ||
| export { GOOGLE_GENAI_INTEGRATION_NAME } from './tracing/google-genai/constants'; | ||
| export type { GoogleGenAIResponse } from './tracing/google-genai/types'; | ||
| export { createLangChainCallbackHandler, instrumentLangChainEmbeddings } from './tracing/langchain'; | ||
| export { LANGCHAIN_INTEGRATION_NAME } from './tracing/langchain/constants'; | ||
| export type { LangChainOptions, LangChainIntegration } from './tracing/langchain/types'; | ||
| export { instrumentStateGraphCompile, instrumentCreateReactAgent, instrumentLangGraph } from './tracing/langgraph'; | ||
| export { LANGGRAPH_INTEGRATION_NAME } from './tracing/langgraph/constants'; | ||
| export type { LangGraphOptions, LangGraphIntegration, CompiledGraph } from './tracing/langgraph/types'; | ||
| export type { OpenAiClient, OpenAiOptions, InstrumentedMethod } from './tracing/openai/types'; | ||
| export type { AnthropicAiClient, AnthropicAiOptions, AnthropicAiInstrumentedMethod, AnthropicAiResponse, } from './tracing/anthropic-ai/types'; | ||
| export type { GoogleGenAIClient, GoogleGenAIChat, GoogleGenAIOptions, GoogleGenAIInstrumentedMethod, } from './tracing/google-genai/types'; | ||
| export type { GoogleGenAIIstrumentedMethod } from './tracing/google-genai/types'; | ||
| export { SpanBuffer } from './tracing/spans/spanBuffer'; | ||
| export { hasSpanStreamingEnabled } from './tracing/spans/hasSpanStreamingEnabled'; | ||
| export { spanStreamingIntegration } from './integrations/spanStreaming'; | ||
| export type { FeatureFlag } from './utils/featureFlags'; | ||
| export { _INTERNAL_copyFlagsFromScopeToEvent, _INTERNAL_insertFlagToScope, _INTERNAL_addFeatureFlagToActiveSpan, _INTERNAL_FLAG_BUFFER_SIZE, _INTERNAL_MAX_FLAGS_PER_SPAN, } from './utils/featureFlags'; | ||
| export { applyAggregateErrorsToEvent } from './utils/aggregate-errors'; | ||
| export { getBreadcrumbLogLevelFromHttpStatusCode } from './utils/breadcrumb-log-level'; | ||
| export { dsnFromString, dsnToString, makeDsn } from './utils/dsn'; | ||
| export { SentryError } from './utils/error'; | ||
| export { GLOBAL_OBJ } from './utils/worldwide'; | ||
| export type { InternalGlobal } from './utils/worldwide'; | ||
| export { addConsoleInstrumentationHandler, addConsoleInstrumentationFilter } from './instrument/console'; | ||
| export { addFetchEndInstrumentationHandler, addFetchInstrumentationHandler } from './instrument/fetch'; | ||
| export { addGlobalErrorInstrumentationHandler } from './instrument/globalError'; | ||
| export { addGlobalUnhandledRejectionInstrumentationHandler } from './instrument/globalUnhandledRejection'; | ||
| export { addHandler, maybeInstrument, resetInstrumentationHandlers, triggerHandlers } from './instrument/handlers'; | ||
| export { isDOMError, isDOMException, isElement, isError, isErrorEvent, isEvent, isInstanceOf, isParameterizedString, isPlainObject, isPrimitive, isRegExp, isString, isSyntheticEvent, isThenable, isVueViewModel, } from './utils/is'; | ||
| export { isBrowser } from './utils/isBrowser'; | ||
| export { CONSOLE_LEVELS, consoleSandbox, debug, originalConsoleMethods } from './utils/debug-logger'; | ||
| export type { SentryDebugLogger } from './utils/debug-logger'; | ||
| export { addContextToFrame, addExceptionMechanism, addExceptionTypeValue, checkOrSetAlreadyCaught, isAlreadyCaptured, getEventDescription, parseSemver, uuid4, } from './utils/misc'; | ||
| export { normalize, normalizeToSize, normalizeUrlToBase } from './utils/normalize'; | ||
| export { setNormalizationDepthOverrideHint, setSkipNormalizationHint } from './utils/normalizationHints'; | ||
| export { addNonEnumerableProperty, convertToPlainObject, dropUndefinedKeys, extractExceptionKeysForMessage, fill, getOriginalFunction, markFunctionWrapped, objectify, } from './utils/object'; | ||
| export { basename, dirname, isAbsolute, join, normalizePath, relative, resolve } from './utils/path'; | ||
| export { makePromiseBuffer, SENTRY_BUFFER_FULL_ERROR } from './utils/promisebuffer'; | ||
| export type { PromiseBuffer } from './utils/promisebuffer'; | ||
| export { severityLevelFromString } from './utils/severity'; | ||
| export { replaceExports } from './utils/exports'; | ||
| export { UNKNOWN_FUNCTION, createStackParser, getFramesFromEvent, getFunctionName, stackParserFromStackParserOptions, stripSentryFramesAndReverse, } from './utils/stacktrace'; | ||
| export { isMatchingPattern, safeJoin, snipLine, stringMatchesSomePattern, truncate } from './utils/string'; | ||
| export { isNativeFunction, supportsDOMException, supportsErrorEvent, supportsFetch, supportsReferrerPolicy, } from './utils/supports'; | ||
| export { SyncPromise, rejectedSyncPromise, resolvedSyncPromise } from './utils/syncpromise'; | ||
| export { browserPerformanceTimeOrigin, dateTimestampInSeconds, timestampInSeconds } from './utils/time'; | ||
| export { TRACEPARENT_REGEXP, extractTraceparentData, generateSentryTraceHeader, propagationContextFromHeaders, shouldContinueTrace, generateTraceparentHeader, } from './utils/tracing'; | ||
| export { getSDKSource, isBrowserBundle } from './utils/env'; | ||
| export type { SdkSource } from './utils/env'; | ||
| export { addItemToEnvelope, createAttachmentEnvelopeItem, createEnvelope, createEventEnvelopeHeaders, createSpanEnvelopeItem, envelopeContainsItemType, envelopeItemTypeToDataCategory, forEachEnvelopeItem, getSdkMetadataForEnvelopeHeader, parseEnvelope, serializeEnvelope, } from './utils/envelope'; | ||
| export { createClientReportEnvelope } from './utils/clientreport'; | ||
| export { DEFAULT_RETRY_AFTER, disabledUntil, isRateLimited, parseRetryAfterHeader, updateRateLimits, } from './utils/ratelimit'; | ||
| export type { RateLimits } from './utils/ratelimit'; | ||
| export { MAX_BAGGAGE_STRING_LENGTH, SENTRY_BAGGAGE_KEY_PREFIX, SENTRY_BAGGAGE_KEY_PREFIX_REGEX, baggageHeaderToDynamicSamplingContext, dynamicSamplingContextToSentryBaggageHeader, parseBaggageHeader, objectToBaggageHeader, mergeBaggageHeaders, } from './utils/baggage'; | ||
| export { getSanitizedUrlString, parseUrl, stripUrlQueryAndFragment, parseStringToURLObject, getHttpSpanDetailsFromUrlObject, isURLObjectRelative, getSanitizedUrlStringFromUrlObject, stripDataUrlContent, } from './utils/url'; | ||
| export { eventFromMessage, eventFromUnknownInput, exceptionFromError, parseStackFrames, _enhanceErrorWithSentryInfo as _INTERNAL_enhanceErrorWithSentryInfo, } from './utils/eventbuilder'; | ||
| export { LRUMap } from './utils/lru'; | ||
| export { generateTraceId, generateSpanId } from './utils/propagationContext'; | ||
| export { SDK_VERSION } from './utils/version'; | ||
| export { getDebugImagesForResources, getFilenameToDebugIdMap } from './utils/debug-ids'; | ||
| export { getFilenameToMetadataMap } from './metadata'; | ||
| export { escapeStringForRegex } from './vendor/escapeStringForRegex'; | ||
| export type { Attachment } from './types-hoist/attachment'; | ||
| export type { Breadcrumb, BreadcrumbHint, FetchBreadcrumbData, FetchBreadcrumbHint } from './types-hoist/breadcrumb'; | ||
| export type { ClientReport, Outcome, EventDropReason } from './types-hoist/clientreport'; | ||
| export type { Context, Contexts, DeviceContext, OsContext, AppContext, CultureContext, TraceContext, CloudResourceContext, MissingInstrumentationContext, } from './types-hoist/context'; | ||
| export type { DataCategory } from './types-hoist/datacategory'; | ||
| export type { DsnComponents, DsnLike, DsnProtocol } from './types-hoist/dsn'; | ||
| export type { DebugImage, DebugMeta } from './types-hoist/debugMeta'; | ||
| export type { AttachmentItem, BaseEnvelopeHeaders, BaseEnvelopeItemHeaders, ClientReportEnvelope, ClientReportItem, DynamicSamplingContext, Envelope, EnvelopeItemType, EnvelopeItem, EventEnvelope, EventEnvelopeHeaders, EventItem, ReplayEnvelope, FeedbackItem, SessionEnvelope, SessionItem, UserFeedbackItem, CheckInItem, CheckInEnvelope, RawSecurityEnvelope, RawSecurityItem, ProfileItem, ProfileChunkEnvelope, ProfileChunkItem, SpanEnvelope, StreamedSpanEnvelope, SpanItem, LogEnvelope, MetricEnvelope, } from './types-hoist/envelope'; | ||
| export type { ExtendedError } from './types-hoist/error'; | ||
| export type { Event, EventHint, EventType, ErrorEvent, TransactionEvent } from './types-hoist/event'; | ||
| export type { EventProcessor } from './types-hoist/eventprocessor'; | ||
| export type { Exception } from './types-hoist/exception'; | ||
| export type { Extra, Extras } from './types-hoist/extra'; | ||
| export type { Integration, IntegrationFn } from './types-hoist/integration'; | ||
| export type { Mechanism } from './types-hoist/mechanism'; | ||
| export type { ExtractedNodeRequestData, HttpHeaderValue, Primitive, WorkerLocation } from './types-hoist/misc'; | ||
| export type { ClientOptions, CoreOptions as Options } from './types-hoist/options'; | ||
| export type { Package } from './types-hoist/package'; | ||
| export type { PolymorphicEvent, PolymorphicRequest } from './types-hoist/polymorphics'; | ||
| export type { ThreadId, FrameId, StackId, ThreadCpuSample, ThreadCpuStack, ThreadCpuFrame, ThreadCpuProfile, ContinuousThreadCpuProfile, Profile, ProfileChunk, } from './types-hoist/profiling'; | ||
| export type { ReplayEndEvent, ReplayEvent, ReplayRecordingData, ReplayRecordingMode, ReplayStartEvent, ReplayStopReason, } from './types-hoist/replay'; | ||
| export type { FeedbackErrorCode, FeedbackErrorMessages, FeedbackEvent, FeedbackFormData, FeedbackInternalOptions, FeedbackModalIntegration, FeedbackScreenshotIntegration, SendFeedback, SendFeedbackParams, UserFeedback, } from './types-hoist/feedback'; | ||
| export type { QueryParams, RequestEventData, RequestHookInfo, ResponseHookInfo, SanitizedRequestData, } from './types-hoist/request'; | ||
| export type { Runtime } from './types-hoist/runtime'; | ||
| export type { SdkInfo } from './types-hoist/sdkinfo'; | ||
| export type { SdkMetadata } from './types-hoist/sdkmetadata'; | ||
| export type { SessionAggregates, AggregationCounts, Session, SessionContext, SessionStatus, SerializedSession, } from './types-hoist/session'; | ||
| export type { SeverityLevel } from './types-hoist/severity'; | ||
| export type { Span, SentrySpanArguments, SpanOrigin, SpanAttributeValue, SpanAttributes, SpanTimeInput, SpanJSON, SpanContextData, TraceFlag, SerializedStreamedSpan, SerializedStreamedSpanContainer, StreamedSpanJSON, } from './types-hoist/span'; | ||
| export type { SpanStatus } from './types-hoist/spanStatus'; | ||
| export type { Log, LogSeverityLevel } from './types-hoist/log'; | ||
| export type { SpanLink } from './types-hoist/link'; | ||
| export type { Metric, MetricType, SerializedMetric, SerializedMetricContainer, SerializedMetricAttributeValue, } from './types-hoist/metric'; | ||
| export type { TimedEvent } from './types-hoist/timedEvent'; | ||
| export type { StackFrame } from './types-hoist/stackframe'; | ||
| export type { Stacktrace, StackParser, StackLineParser, StackLineParserFn } from './types-hoist/stacktrace'; | ||
| export type { PropagationContext, TracePropagationTargets, SerializedTraceData } from './types-hoist/tracing'; | ||
| export type { StartSpanOptions } from './types-hoist/startSpanOptions'; | ||
| export type { TraceparentData, TransactionSource } from './types-hoist/transaction'; | ||
| export type { TracesSamplerSamplingContext, CustomSamplingContext, SamplingContext, } from './types-hoist/samplingcontext'; | ||
| export type { DurationUnit, InformationUnit, FractionUnit, MeasurementUnit, NoneUnit, Measurements, } from './types-hoist/measurement'; | ||
| export type { Thread } from './types-hoist/thread'; | ||
| export type { Transport, TransportRequest, TransportMakeRequestResponse, InternalBaseTransportOptions, BaseTransportOptions, TransportRequestExecutor, } from './types-hoist/transport'; | ||
| export type { User } from './types-hoist/user'; | ||
| export type { WebFetchHeaders, WebFetchRequest } from './types-hoist/webfetchapi'; | ||
| export type { WrappedFunction } from './types-hoist/wrappedfunction'; | ||
| export type { HandlerDataFetch, HandlerDataConsole, HandlerDataError, HandlerDataUnhandledRejection, ConsoleLevel, } from './types-hoist/instrument'; | ||
| export type { CheckIn, MonitorConfig, FinishedCheckIn, InProgressCheckIn, SerializedCheckIn, } from './types-hoist/checkin'; | ||
| export type { ParameterizedString } from './types-hoist/parameterize'; | ||
| export type { ContinuousProfiler, ProfilingIntegration, Profiler } from './types-hoist/profiling'; | ||
| export type { ViewHierarchyData, ViewHierarchyWindow } from './types-hoist/view-hierarchy'; | ||
| export type { LegacyCSPReport } from './types-hoist/csp'; | ||
| export type { SerializedLog, SerializedLogContainer } from './types-hoist/log'; | ||
| export type { BuildTimeOptionsBase, UnstableVitePluginOptions, UnstableRollupPluginOptions, UnstableWebpackPluginOptions, } from './build-time-plugins/buildTimeOptionsBase'; | ||
| export type { RandomSafeContextRunner as _INTERNAL_RandomSafeContextRunner } from './utils/randomSafeContext'; | ||
| export { withRandomSafeContext as _INTERNAL_withRandomSafeContext, safeMathRandom as _INTERNAL_safeMathRandom, safeDateNow as _INTERNAL_safeDateNow, } from './utils/randomSafeContext'; | ||
| //# sourceMappingURL=shared-exports.d.ts.map |
| {"version":3,"file":"shared-exports.d.ts","sourceRoot":"","sources":["../../src/shared-exports.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EAAE,WAAW,IAAI,uBAAuB,EAAE,MAAM,OAAO,CAAC;AACpE,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAClF,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC5F,OAAO,EACL,cAAc,EACd,WAAW,EACX,gB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Y,EACV,oBAAoB,EACpB,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,2CAA2C,CAAC;AACnD,YAAY,EAAE,uBAAuB,IAAI,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAC9G,OAAO,EACL,qBAAqB,IAAI,+BAA+B,EACxD,cAAc,IAAI,wBAAwB,EAC1C,WAAW,IAAI,qBAAqB,GACrC,MAAM,2BAA2B,CAAC"} |
| import type { Client } from '../../client'; | ||
| import type { SpanContainerItem } from '../../types-hoist/envelope'; | ||
| import type { Event } from '../../types-hoist/event'; | ||
| /** | ||
| * Extracts gen_ai spans from a transaction event, converts them to span v2 format, | ||
| * and returns them as a SpanContainerItem. | ||
| * | ||
| * Only applies to static mode (non-streaming) transactions. | ||
| * | ||
| * WARNING: This function mutates `event.spans` by removing the extracted gen_ai spans | ||
| * from the array. Call this before creating the event envelope so the transaction | ||
| * item does not include the extracted spans. | ||
| */ | ||
| export declare function extractGenAiSpansFromEvent(event: Event, client: Client): SpanContainerItem | undefined; | ||
| //# sourceMappingURL=extractGenAiSpans.d.ts.map |
| {"version":3,"file":"extractGenAiSpans.d.ts","sourceRoot":"","sources":["../../../../src/tracing/spans/extractGenAiSpans.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAKrD;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAwCtG"} |
| import type { SerializedStreamedSpan, SpanJSON } from '../../types-hoist/span'; | ||
| /** | ||
| * Converts a v1 SpanJSON (from a legacy transaction) to a serialized v2 StreamedSpan. | ||
| */ | ||
| export declare function spanJsonToSerializedStreamedSpan(span: SpanJSON): SerializedStreamedSpan; | ||
| //# sourceMappingURL=spanJsonToStreamedSpan.d.ts.map |
| {"version":3,"file":"spanJsonToStreamedSpan.d.ts","sourceRoot":"","sources":["../../../../src/tracing/spans/spanJsonToStreamedSpan.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,QAAQ,EAAoB,MAAM,wBAAwB,CAAC;AAGjG;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,QAAQ,GAAG,sBAAsB,CAevF"} |
| // This file is a compatibility shim for bundlers (e.g. webpack 4) that do not | ||
| // support the package.json `exports` field for resolving subpath exports. | ||
| module.exports = require('./build/cjs/server.js'); |
@@ -14,2 +14,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const beforeSendSpan = require('./tracing/spans/beforeSendSpan.js'); | ||
| const extractGenAiSpans = require('./tracing/spans/extractGenAiSpans.js'); | ||
| const base = require('./transports/base.js'); | ||
@@ -484,2 +485,6 @@ const clientreport = require('./utils/clientreport.js'); | ||
| // Extract gen_ai spans from transaction and convert to span v2 format. | ||
| // This mutates event.spans to remove the extracted spans. | ||
| const genAiSpanItem = extractGenAiSpans.extractGenAiSpansFromEvent(event, this); | ||
| let env = envelope.createEventEnvelope(event, this._dsn, this._options._metadata, this._options.tunnel); | ||
@@ -491,2 +496,6 @@ | ||
| if (genAiSpanItem) { | ||
| env = envelope$1.addItemToEnvelope(env, genAiSpanItem); | ||
| } | ||
| // sendEnvelope should not throw | ||
@@ -493,0 +502,0 @@ // eslint-disable-next-line @typescript-eslint/no-floating-promises |
+69
-68
@@ -17,3 +17,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const envelope$1 = require('./envelope.js'); | ||
| const _exports = require('./exports.js'); | ||
| const exports$1 = require('./exports.js'); | ||
| const currentScopes = require('./currentScopes.js'); | ||
@@ -28,3 +28,2 @@ const defaultScopes = require('./defaultScopes.js'); | ||
| const client = require('./client.js'); | ||
| const serverRuntimeClient = require('./server-runtime-client.js'); | ||
| const sdk = require('./sdk.js'); | ||
@@ -66,3 +65,2 @@ const base = require('./transports/base.js'); | ||
| const captureconsole = require('./integrations/captureconsole.js'); | ||
| const index$2 = require('./integrations/express/index.js'); | ||
| const dedupe = require('./integrations/dedupe.js'); | ||
@@ -72,3 +70,2 @@ const extraerrordata = require('./integrations/extraerrordata.js'); | ||
| const supabase = require('./integrations/supabase.js'); | ||
| const postgresjs = require('./integrations/postgresjs.js'); | ||
| const zoderrors = require('./integrations/zoderrors.js'); | ||
@@ -80,11 +77,4 @@ const thirdPartyErrorsFilter = require('./integrations/third-party-errors-filter.js'); | ||
| const conversationId = require('./integrations/conversationId.js'); | ||
| const clientPatch = require('./integrations/http/client-patch.js'); | ||
| const clientSubscriptions = require('./integrations/http/client-subscriptions.js'); | ||
| const addOutgoingRequestBreadcrumb = require('./integrations/http/add-outgoing-request-breadcrumb.js'); | ||
| const getRequestUrl = require('./integrations/http/get-request-url.js'); | ||
| const constants$3 = require('./integrations/http/constants.js'); | ||
| const profiling = require('./profiling.js'); | ||
| const fetch = require('./fetch.js'); | ||
| const trpc = require('./trpc.js'); | ||
| const index$8 = require('./integrations/mcp-server/index.js'); | ||
| const feedback = require('./feedback.js'); | ||
@@ -116,3 +106,2 @@ const internal = require('./logs/internal.js'); | ||
| const breadcrumbLogLevel = require('./utils/breadcrumb-log-level.js'); | ||
| const browser = require('./utils/browser.js'); | ||
| const dsn = require('./utils/dsn.js'); | ||
@@ -130,3 +119,2 @@ const error = require('./utils/error.js'); | ||
| const misc = require('./utils/misc.js'); | ||
| const node = require('./utils/node.js'); | ||
| const normalize = require('./utils/normalize.js'); | ||
@@ -138,5 +126,4 @@ const normalizationHints = require('./utils/normalizationHints.js'); | ||
| const severity = require('./utils/severity.js'); | ||
| const _exports$1 = require('./utils/exports.js'); | ||
| const exports$2 = require('./utils/exports.js'); | ||
| const stacktrace = require('./utils/stacktrace.js'); | ||
| const nodeStackTrace = require('./utils/node-stack-trace.js'); | ||
| const string = require('./utils/string.js'); | ||
@@ -154,7 +141,4 @@ const supports = require('./utils/supports.js'); | ||
| const eventbuilder = require('./utils/eventbuilder.js'); | ||
| const anr = require('./utils/anr.js'); | ||
| const lru = require('./utils/lru.js'); | ||
| const propagationContext = require('./utils/propagationContext.js'); | ||
| const vercelWaitUntil = require('./utils/vercelWaitUntil.js'); | ||
| const flushIfServerless = require('./utils/flushIfServerless.js'); | ||
| const version = require('./utils/version.js'); | ||
@@ -165,3 +149,19 @@ const debugIds = require('./utils/debug-ids.js'); | ||
| const randomSafeContext = require('./utils/randomSafeContext.js'); | ||
| const serverRuntimeClient = require('./server-runtime-client.js'); | ||
| const trpc = require('./trpc.js'); | ||
| const index$8 = require('./integrations/mcp-server/index.js'); | ||
| const node = require('./utils/node.js'); | ||
| const nodeStackTrace = require('./utils/node-stack-trace.js'); | ||
| const vercelWaitUntil = require('./utils/vercelWaitUntil.js'); | ||
| const flushIfServerless = require('./utils/flushIfServerless.js'); | ||
| const anr = require('./utils/anr.js'); | ||
| const timer = require('./utils/timer.js'); | ||
| const index$2 = require('./integrations/express/index.js'); | ||
| const postgresjs = require('./integrations/postgresjs.js'); | ||
| const clientPatch = require('./integrations/http/client-patch.js'); | ||
| const clientSubscriptions = require('./integrations/http/client-subscriptions.js'); | ||
| const addOutgoingRequestBreadcrumb = require('./integrations/http/add-outgoing-request-breadcrumb.js'); | ||
| const getRequestUrl = require('./integrations/http/get-request-url.js'); | ||
| const constants$3 = require('./integrations/http/constants.js'); | ||
| const browser = require('./utils/browser.js'); | ||
| const embeddings = require('./tracing/langchain/embeddings.js'); | ||
@@ -233,23 +233,23 @@ | ||
| exports.createSpanEnvelope = envelope$1.createSpanEnvelope; | ||
| exports.addEventProcessor = _exports.addEventProcessor; | ||
| exports.captureCheckIn = _exports.captureCheckIn; | ||
| exports.captureEvent = _exports.captureEvent; | ||
| exports.captureException = _exports.captureException; | ||
| exports.captureMessage = _exports.captureMessage; | ||
| exports.captureSession = _exports.captureSession; | ||
| exports.close = _exports.close; | ||
| exports.endSession = _exports.endSession; | ||
| exports.flush = _exports.flush; | ||
| exports.isEnabled = _exports.isEnabled; | ||
| exports.isInitialized = _exports.isInitialized; | ||
| exports.lastEventId = _exports.lastEventId; | ||
| exports.setContext = _exports.setContext; | ||
| exports.setConversationId = _exports.setConversationId; | ||
| exports.setExtra = _exports.setExtra; | ||
| exports.setExtras = _exports.setExtras; | ||
| exports.setTag = _exports.setTag; | ||
| exports.setTags = _exports.setTags; | ||
| exports.setUser = _exports.setUser; | ||
| exports.startSession = _exports.startSession; | ||
| exports.withMonitor = _exports.withMonitor; | ||
| exports.addEventProcessor = exports$1.addEventProcessor; | ||
| exports.captureCheckIn = exports$1.captureCheckIn; | ||
| exports.captureEvent = exports$1.captureEvent; | ||
| exports.captureException = exports$1.captureException; | ||
| exports.captureMessage = exports$1.captureMessage; | ||
| exports.captureSession = exports$1.captureSession; | ||
| exports.close = exports$1.close; | ||
| exports.endSession = exports$1.endSession; | ||
| exports.flush = exports$1.flush; | ||
| exports.isEnabled = exports$1.isEnabled; | ||
| exports.isInitialized = exports$1.isInitialized; | ||
| exports.lastEventId = exports$1.lastEventId; | ||
| exports.setContext = exports$1.setContext; | ||
| exports.setConversationId = exports$1.setConversationId; | ||
| exports.setExtra = exports$1.setExtra; | ||
| exports.setExtras = exports$1.setExtras; | ||
| exports.setTag = exports$1.setTag; | ||
| exports.setTags = exports$1.setTags; | ||
| exports.setUser = exports$1.setUser; | ||
| exports.startSession = exports$1.startSession; | ||
| exports.withMonitor = exports$1.withMonitor; | ||
| exports.getClient = currentScopes.getClient; | ||
@@ -279,3 +279,2 @@ exports.getCurrentScope = currentScopes.getCurrentScope; | ||
| exports.Client = client.Client; | ||
| exports.ServerRuntimeClient = serverRuntimeClient.ServerRuntimeClient; | ||
| exports.initAndBind = sdk.initAndBind; | ||
@@ -353,5 +352,2 @@ exports.setCurrentClient = sdk.setCurrentClient; | ||
| exports.captureConsoleIntegration = captureconsole.captureConsoleIntegration; | ||
| exports.expressErrorHandler = index$2.expressErrorHandler; | ||
| exports.patchExpressModule = index$2.patchExpressModule; | ||
| exports.setupExpressErrorHandler = index$2.setupExpressErrorHandler; | ||
| exports.dedupeIntegration = dedupe.dedupeIntegration; | ||
@@ -362,3 +358,2 @@ exports.extraErrorDataIntegration = extraerrordata.extraErrorDataIntegration; | ||
| exports.supabaseIntegration = supabase.supabaseIntegration; | ||
| exports.instrumentPostgresJsSql = postgresjs.instrumentPostgresJsSql; | ||
| exports.zodErrorsIntegration = zoderrors.zodErrorsIntegration; | ||
@@ -370,16 +365,5 @@ exports.thirdPartyErrorFilterIntegration = thirdPartyErrorsFilter.thirdPartyErrorFilterIntegration; | ||
| exports.conversationIdIntegration = conversationId.conversationIdIntegration; | ||
| exports.patchHttpModuleClient = clientPatch.patchHttpModuleClient; | ||
| exports.getHttpClientSubscriptions = clientSubscriptions.getHttpClientSubscriptions; | ||
| exports.addOutgoingRequestBreadcrumb = addOutgoingRequestBreadcrumb.addOutgoingRequestBreadcrumb; | ||
| exports.getRequestOptions = getRequestUrl.getRequestOptions; | ||
| exports.getRequestUrl = getRequestUrl.getRequestUrl; | ||
| exports.getRequestUrlFromClientRequest = getRequestUrl.getRequestUrlFromClientRequest; | ||
| exports.getRequestUrlObject = getRequestUrl.getRequestUrlObject; | ||
| exports.HTTP_ON_CLIENT_REQUEST = constants$3.HTTP_ON_CLIENT_REQUEST; | ||
| exports.HTTP_ON_SERVER_REQUEST = constants$3.HTTP_ON_SERVER_REQUEST; | ||
| exports.profiler = profiling.profiler; | ||
| exports._INTERNAL_getTracingHeadersForFetchRequest = fetch._INTERNAL_getTracingHeadersForFetchRequest; | ||
| exports.instrumentFetchRequest = fetch.instrumentFetchRequest; | ||
| exports.trpcMiddleware = trpc.trpcMiddleware; | ||
| exports.wrapMcpServerWithSentry = index$8.wrapMcpServerWithSentry; | ||
| exports.captureFeedback = feedback.captureFeedback; | ||
@@ -422,5 +406,2 @@ exports._INTERNAL_captureLog = internal._INTERNAL_captureLog; | ||
| exports.getBreadcrumbLogLevelFromHttpStatusCode = breadcrumbLogLevel.getBreadcrumbLogLevelFromHttpStatusCode; | ||
| exports.getComponentName = browser.getComponentName; | ||
| exports.getLocationHref = browser.getLocationHref; | ||
| exports.htmlTreeAsString = browser.htmlTreeAsString; | ||
| exports.dsnFromString = dsn.dsnFromString; | ||
@@ -431,2 +412,3 @@ exports.dsnToString = dsn.dsnToString; | ||
| exports.GLOBAL_OBJ = worldwide.GLOBAL_OBJ; | ||
| exports.addConsoleInstrumentationFilter = console.addConsoleInstrumentationFilter; | ||
| exports.addConsoleInstrumentationHandler = console.addConsoleInstrumentationHandler; | ||
@@ -469,4 +451,2 @@ exports.addFetchEndInstrumentationHandler = fetch$1.addFetchEndInstrumentationHandler; | ||
| exports.uuid4 = misc.uuid4; | ||
| exports.isNodeEnv = node.isNodeEnv; | ||
| exports.loadModule = node.loadModule; | ||
| exports.normalize = normalize.normalize; | ||
@@ -495,3 +475,3 @@ exports.normalizeToSize = normalize.normalizeToSize; | ||
| exports.severityLevelFromString = severity.severityLevelFromString; | ||
| exports.replaceExports = _exports$1.replaceExports; | ||
| exports.replaceExports = exports$2.replaceExports; | ||
| exports.UNKNOWN_FUNCTION = stacktrace.UNKNOWN_FUNCTION; | ||
@@ -503,5 +483,2 @@ exports.createStackParser = stacktrace.createStackParser; | ||
| exports.stripSentryFramesAndReverse = stacktrace.stripSentryFramesAndReverse; | ||
| exports.filenameIsInApp = nodeStackTrace.filenameIsInApp; | ||
| exports.node = nodeStackTrace.node; | ||
| exports.nodeStackLineParser = nodeStackTrace.nodeStackLineParser; | ||
| exports.isMatchingPattern = string.isMatchingPattern; | ||
@@ -573,9 +550,5 @@ exports.safeJoin = string.safeJoin; | ||
| exports.parseStackFrames = eventbuilder.parseStackFrames; | ||
| exports.callFrameToStackFrame = anr.callFrameToStackFrame; | ||
| exports.watchdogTimer = anr.watchdogTimer; | ||
| exports.LRUMap = lru.LRUMap; | ||
| exports.generateSpanId = propagationContext.generateSpanId; | ||
| exports.generateTraceId = propagationContext.generateTraceId; | ||
| exports.vercelWaitUntil = vercelWaitUntil.vercelWaitUntil; | ||
| exports.flushIfServerless = flushIfServerless.flushIfServerless; | ||
| exports.SDK_VERSION = version.SDK_VERSION; | ||
@@ -589,4 +562,32 @@ exports.getDebugImagesForResources = debugIds.getDebugImagesForResources; | ||
| exports._INTERNAL_withRandomSafeContext = randomSafeContext.withRandomSafeContext; | ||
| exports.ServerRuntimeClient = serverRuntimeClient.ServerRuntimeClient; | ||
| exports.trpcMiddleware = trpc.trpcMiddleware; | ||
| exports.wrapMcpServerWithSentry = index$8.wrapMcpServerWithSentry; | ||
| exports.isNodeEnv = node.isNodeEnv; | ||
| exports.loadModule = node.loadModule; | ||
| exports.filenameIsInApp = nodeStackTrace.filenameIsInApp; | ||
| exports.node = nodeStackTrace.node; | ||
| exports.nodeStackLineParser = nodeStackTrace.nodeStackLineParser; | ||
| exports.vercelWaitUntil = vercelWaitUntil.vercelWaitUntil; | ||
| exports.flushIfServerless = flushIfServerless.flushIfServerless; | ||
| exports.callFrameToStackFrame = anr.callFrameToStackFrame; | ||
| exports.watchdogTimer = anr.watchdogTimer; | ||
| exports._INTERNAL_safeUnref = timer.safeUnref; | ||
| exports.expressErrorHandler = index$2.expressErrorHandler; | ||
| exports.patchExpressModule = index$2.patchExpressModule; | ||
| exports.setupExpressErrorHandler = index$2.setupExpressErrorHandler; | ||
| exports.instrumentPostgresJsSql = postgresjs.instrumentPostgresJsSql; | ||
| exports.patchHttpModuleClient = clientPatch.patchHttpModuleClient; | ||
| exports.getHttpClientSubscriptions = clientSubscriptions.getHttpClientSubscriptions; | ||
| exports.addOutgoingRequestBreadcrumb = addOutgoingRequestBreadcrumb.addOutgoingRequestBreadcrumb; | ||
| exports.getRequestOptions = getRequestUrl.getRequestOptions; | ||
| exports.getRequestUrl = getRequestUrl.getRequestUrl; | ||
| exports.getRequestUrlFromClientRequest = getRequestUrl.getRequestUrlFromClientRequest; | ||
| exports.getRequestUrlObject = getRequestUrl.getRequestUrlObject; | ||
| exports.HTTP_ON_CLIENT_REQUEST = constants$3.HTTP_ON_CLIENT_REQUEST; | ||
| exports.HTTP_ON_SERVER_REQUEST = constants$3.HTTP_ON_SERVER_REQUEST; | ||
| exports.getComponentName = browser.getComponentName; | ||
| exports.getLocationHref = browser.getLocationHref; | ||
| exports.htmlTreeAsString = browser.htmlTreeAsString; | ||
| exports.instrumentLangChainEmbeddings = embeddings.instrumentLangChainEmbeddings; | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const debugBuild = require('../debug-build.js'); | ||
| const debugLogger = require('../utils/debug-logger.js'); | ||
| const object = require('../utils/object.js'); | ||
| const string = require('../utils/string.js'); | ||
| const worldwide = require('../utils/worldwide.js'); | ||
| const handlers = require('./handlers.js'); | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| /* eslint-disable @typescript-eslint/ban-types */ | ||
| /** | ||
| * Filter out console messages that match the given strings or regular expressions. | ||
| * These will neither be passed to the handler, and they will also not be logged to the user, unless they have debug enabled. | ||
| * This is a set to avoid duplicate integration setups to add the same filter multiple times. | ||
| */ | ||
| const _filter = new Set([]); | ||
| /** | ||
| * Add an instrumentation handler for when a console.xxx method is called. | ||
@@ -22,2 +34,18 @@ * Returns a function to remove the handler. | ||
| /** | ||
| * Add a filter to the console instrumentation to filter out console messages that match the given strings or regular expressions. | ||
| * Returns a function to remove the filter. | ||
| */ | ||
| function addConsoleInstrumentationFilter(filter) { | ||
| for (const f of filter) { | ||
| _filter.add(f); | ||
| } | ||
| return () => { | ||
| for (const f of filter) { | ||
| _filter.delete(f); | ||
| } | ||
| }; | ||
| } | ||
| function instrumentConsole() { | ||
@@ -37,6 +65,17 @@ if (!('console' in worldwide.GLOBAL_OBJ)) { | ||
| return function (...args) { | ||
| handlers.triggerHandlers('console', { args, level } ); | ||
| const firstArg = args[0]; | ||
| const log = debugLogger.originalConsoleMethods[level]; | ||
| const log = debugLogger.originalConsoleMethods[level]; | ||
| log?.apply(worldwide.GLOBAL_OBJ.console, args); | ||
| const isFiltered = _filter.size && typeof firstArg === 'string' && string.stringMatchesSomePattern(firstArg, _filter); | ||
| // Only trigger handlers for non-filtered messages | ||
| if (!isFiltered) { | ||
| handlers.triggerHandlers('console', { args, level } ); | ||
| } | ||
| // Only log filtered messages in debug mode | ||
| if (!isFiltered || (debugBuild.DEBUG_BUILD && debugLogger.debug.isEnabled())) { | ||
| // Call original console method | ||
| log?.apply(worldwide.GLOBAL_OBJ.console, args); | ||
| } | ||
| }; | ||
@@ -47,3 +86,4 @@ }); | ||
| exports.addConsoleInstrumentationFilter = addConsoleInstrumentationFilter; | ||
| exports.addConsoleInstrumentationHandler = addConsoleInstrumentationHandler; | ||
| //# sourceMappingURL=console.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"console.js","sources":["../../../src/instrument/console.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/ban-types */\nimport type { ConsoleLevel, HandlerDataConsole } from '../types-hoist/instrument';\nimport { CONSOLE_LEVELS, originalConsoleMethods } from '../utils/debug-logger';\nimport { fill } from '../utils/object';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\nimport { addHandler, maybeInstrument, triggerHandlers } from './handlers';\n\n/**\n * Add an instrumentation handler for when a console.xxx method is called.\n * Returns a function to remove the handler.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nexport function addConsoleInstrumentationHandler(handler: (data: HandlerDataConsole) => void): () => void {\n const type = 'console';\n const removeHandler = addHandler(type, handler);\n maybeInstrument(type, instrumentConsole);\n return removeHandler;\n}\n\nfunction instrumentConsole(): void {\n if (!('console' in GLOBAL_OBJ)) {\n return;\n }\n\n CONSOLE_LEVELS.forEach(function (level: ConsoleLevel): void {\n if (!(level in GLOBAL_OBJ.console)) {\n return;\n }\n\n fill(GLOBAL_OBJ.console, level, function (originalConsoleMethod: () => any): Function {\n originalConsoleMethods[level] = originalConsoleMethod;\n\n return function (...args: any[]): void {\n triggerHandlers('console', { args, level } as HandlerDataConsole);\n\n const log = originalConsoleMethods[level];\n log?.apply(GLOBAL_OBJ.console, args);\n };\n });\n });\n}\n"],"names":["addHandler","maybeInstrument","GLOBAL_OBJ","CONSOLE_LEVELS","fill","originalConsoleMethods","triggerHandlers"],"mappings":";;;;;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gCAAgC,CAAC,OAAO,EAAkD;AAC1G,EAAE,MAAM,IAAA,GAAO,SAAS;AACxB,EAAE,MAAM,gBAAgBA,mBAAU,CAAC,IAAI,EAAE,OAAO,CAAC;AACjD,EAAEC,wBAAe,CAAC,IAAI,EAAE,iBAAiB,CAAC;AAC1C,EAAE,OAAO,aAAa;AACtB;;AAEA,SAAS,iBAAiB,GAAS;AACnC,EAAE,IAAI,EAAE,aAAaC,oBAAU,CAAC,EAAE;AAClC,IAAI;AACJ,EAAE;;AAEF,EAAEC,0BAAc,CAAC,OAAO,CAAC,UAAU,KAAK,EAAsB;AAC9D,IAAI,IAAI,EAAE,KAAA,IAASD,oBAAU,CAAC,OAAO,CAAC,EAAE;AACxC,MAAM;AACN,IAAI;;AAEJ,IAAIE,WAAI,CAACF,oBAAU,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,qBAAqB,EAAuB;AAC1F,MAAMG,kCAAsB,CAAC,KAAK,CAAA,GAAI,qBAAqB;;AAE3D,MAAM,OAAO,UAAU,GAAG,IAAI,EAAe;AAC7C,QAAQC,wBAAe,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,KAAA,EAAM,EAAwB;;AAEzE,QAAQ,MAAM,GAAA,GAAMD,kCAAsB,CAAC,KAAK,CAAC;AACjD,QAAQ,GAAG,EAAE,KAAK,CAACH,oBAAU,CAAC,OAAO,EAAE,IAAI,CAAC;AAC5C,MAAM,CAAC;AACP,IAAI,CAAC,CAAC;AACN,EAAE,CAAC,CAAC;AACJ;;;;"} | ||
| {"version":3,"file":"console.js","sources":["../../../src/instrument/console.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/ban-types */\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { ConsoleLevel, HandlerDataConsole } from '../types-hoist/instrument';\nimport { CONSOLE_LEVELS, originalConsoleMethods } from '../utils/debug-logger';\nimport { fill } from '../utils/object';\nimport { stringMatchesSomePattern } from '../utils/string';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\nimport { addHandler, maybeInstrument, triggerHandlers } from './handlers';\nimport { debug } from '../utils/debug-logger';\n\n/**\n * Filter out console messages that match the given strings or regular expressions.\n * These will neither be passed to the handler, and they will also not be logged to the user, unless they have debug enabled.\n * This is a set to avoid duplicate integration setups to add the same filter multiple times.\n */\nconst _filter = new Set<string | RegExp>([]);\n\n/**\n * Add an instrumentation handler for when a console.xxx method is called.\n * Returns a function to remove the handler.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nexport function addConsoleInstrumentationHandler(handler: (data: HandlerDataConsole) => void): () => void {\n const type = 'console';\n const removeHandler = addHandler(type, handler);\n maybeInstrument(type, instrumentConsole);\n return removeHandler;\n}\n\n/**\n * Add a filter to the console instrumentation to filter out console messages that match the given strings or regular expressions.\n * Returns a function to remove the filter.\n */\nexport function addConsoleInstrumentationFilter(filter: (string | RegExp)[]): () => void {\n for (const f of filter) {\n _filter.add(f);\n }\n\n return () => {\n for (const f of filter) {\n _filter.delete(f);\n }\n };\n}\n\n/** Only exported for tests. */\nexport function _INTERNAL_resetConsoleInstrumentationOptions(): void {\n _filter.clear();\n}\n\nfunction instrumentConsole(): void {\n if (!('console' in GLOBAL_OBJ)) {\n return;\n }\n\n CONSOLE_LEVELS.forEach(function (level: ConsoleLevel): void {\n if (!(level in GLOBAL_OBJ.console)) {\n return;\n }\n\n fill(GLOBAL_OBJ.console, level, function (originalConsoleMethod: () => any): Function {\n originalConsoleMethods[level] = originalConsoleMethod;\n\n return function (...args: any[]): void {\n const firstArg = args[0];\n const log = originalConsoleMethods[level];\n\n const isFiltered = _filter.size && typeof firstArg === 'string' && stringMatchesSomePattern(firstArg, _filter);\n\n // Only trigger handlers for non-filtered messages\n if (!isFiltered) {\n triggerHandlers('console', { args, level } as HandlerDataConsole);\n }\n\n // Only log filtered messages in debug mode\n if (!isFiltered || (DEBUG_BUILD && debug.isEnabled())) {\n // Call original console method\n log?.apply(GLOBAL_OBJ.console, args);\n }\n };\n });\n });\n}\n"],"names":["addHandler","maybeInstrument","GLOBAL_OBJ","CONSOLE_LEVELS","fill","originalConsoleMethods","stringMatchesSomePattern","triggerHandlers","DEBUG_BUILD","debug"],"mappings":";;;;;;;;;AAAA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA,MAAM,UAAU,IAAI,GAAG,CAAkB,EAAE,CAAC;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gCAAgC,CAAC,OAAO,EAAkD;AAC1G,EAAE,MAAM,IAAA,GAAO,SAAS;AACxB,EAAE,MAAM,gBAAgBA,mBAAU,CAAC,IAAI,EAAE,OAAO,CAAC;AACjD,EAAEC,wBAAe,CAAC,IAAI,EAAE,iBAAiB,CAAC;AAC1C,EAAE,OAAO,aAAa;AACtB;;AAEA;AACA;AACA;AACA;AACO,SAAS,+BAA+B,CAAC,MAAM,EAAmC;AACzF,EAAE,KAAK,MAAM,CAAA,IAAK,MAAM,EAAE;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ACP,IAAI,CAAC,CAAC;AACN,EAAE,CAAC,CAAC;AACJ;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const currentScopes = require('../currentScopes.js'); | ||
| const _exports = require('../exports.js'); | ||
| const exports$1 = require('../exports.js'); | ||
| const console = require('../instrument/console.js'); | ||
@@ -84,3 +84,3 @@ const integration = require('../integration.js'); | ||
| if (error) { | ||
| _exports.captureException(error, captureContext); | ||
| exports$1.captureException(error, captureContext); | ||
| return; | ||
@@ -87,0 +87,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"captureconsole.js","sources":["../../../src/integrations/captureconsole.ts"],"sourcesContent":["import { getClient, withScope } from '../currentScopes';\nimport { captureException } from '../exports';\nimport { addConsoleInstrumentationHandler } from '../instrument/console';\nimport { defineIntegration } from '../integration';\nimport type { CaptureContext } from '../scope';\nimport type { IntegrationFn } from '../types-hoist/integration';\nimport { CONSOLE_LEVELS } from '../utils/debug-logger';\nimport { addExceptionMechanism } from '../utils/misc';\nimport { severityLevelFromString } from '../utils/severity';\nimport { safeJoin } from '../utils/string';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\n\ninterface CaptureConsoleOptions {\n levels?: string[];\n\n /**\n * By default, Sentry will mark captured console messages as handled.\n * Set this to `false` if you want to mark them as unhandled instead.\n *\n * @default true\n */\n handled?: boolean;\n}\n\nconst INTEGRATION_NAME = 'CaptureConsole';\n\nconst _captureConsoleIntegration = ((options: CaptureConsoleOptions = {}) => {\n const levels = options.levels || CONSOLE_LEVELS;\n const handled = options.handled ?? true;\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n if (!('console' in GLOBAL_OBJ)) {\n return;\n }\n\n addConsoleInstrumentationHandler(({ args, level }) => {\n if (getClient() !== client || !levels.includes(level)) {\n return;\n }\n\n consoleHandler(args, level, handled);\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Send Console API calls as Sentry Events.\n */\nexport const captureConsoleIntegration = defineIntegration(_captureConsoleIntegration);\n\nfunction consoleHandler(args: unknown[], level: string, handled: boolean): void {\n const severityLevel = severityLevelFromString(level);\n\n /*\n We create this error here already to attach a stack trace to captured messages,\n if users set `attachStackTrace` to `true` in Sentry.init.\n We do this here already because we want to minimize the number of Sentry SDK stack frames\n within the error. Technically, Client.captureMessage will also do it but this happens several\n stack frames deeper.\n */\n const syntheticException = new Error();\n\n const captureContext: CaptureContext = {\n level: severityLevelFromString(level),\n extra: {\n arguments: args,\n },\n };\n\n withScope(scope => {\n scope.addEventProcessor(event => {\n event.logger = 'console';\n\n addExceptionMechanism(event, {\n handled,\n type: 'auto.core.capture_console',\n });\n\n return event;\n });\n\n if (level === 'assert') {\n if (!args[0]) {\n const message = `Assertion failed: ${safeJoin(args.slice(1), ' ') || 'console.assert'}`;\n scope.setExtra('arguments', args.slice(1));\n scope.captureMessage(message, severityLevel, { captureContext, syntheticException });\n }\n return;\n }\n\n const error = args.find(arg => arg instanceof Error);\n if (error) {\n captureException(error, captureContext);\n return;\n }\n\n const message = safeJoin(args, ' ');\n scope.captureMessage(message, severityLevel, { captureContext, syntheticException });\n });\n}\n"],"names":["CONSOLE_LEVELS","GLOBAL_OBJ","addConsoleInstrumentationHandler","getClient","defineIntegration","severityLevelFromString","withScope","addExceptionMechanism","safeJoin","captureException"],"mappings":";;;;;;;;;;;;AAwBA,MAAM,gBAAA,GAAmB,gBAAgB;;AAEzC,MAAM,0BAAA,IAA8B,CAAC,OAAO,GAA0B,EAAE,KAAK;AAC7E,EAAE,MAAM,MAAA,GAAS,OAAO,CAAC,MAAA,IAAUA,0BAAc;AACjD,EAAE,MAAM,OAAA,GAAU,OAAO,CAAC,OAAA,IAAW,IAAI;;AAEzC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,IAAI,EAAE,aAAaC,oBAAU,CAAC,EAAE;AACtC,QAAQ;AACR,MAAM;;AAEN,MAAMC,w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AK,gBAAgB,CAAC,CAAA;AACA,QAAA,KAAA,CAAA,QAAA,CAAA,WAAA,EAAA,IAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA;AACA,QAAA,KAAA,CAAA,cAAA,CAAA,OAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,kBAAA,EAAA,CAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;;AAEA,IAAA,MAAA,KAAA,GAAA,IAAA,CAAA,IAAA,CAAA,GAAA,IAAA,GAAA,YAAA,KAAA,CAAA;AACA,IAAA,IAAA,KAAA,EAAA;AACA,MAAAC,yBAAA,CAAA,KAAA,EAAA,cAAA,CAAA;AACA,MAAA;AACA,IAAA;;AAEA,IAAA,MAAA,OAAA,GAAAD,eAAA,CAAA,IAAA,EAAA,GAAA,CAAA;AACA,IAAA,KAAA,CAAA,cAAA,CAAA,OAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,kBAAA,EAAA,CAAA;AACA,EAAA,CAAA,CAAA;AACA;;;;"} | ||
| {"version":3,"file":"captureconsole.js","sources":["../../../src/integrations/captureconsole.ts"],"sourcesContent":["import { getClient, withScope } from '../currentScopes';\nimport { captureException } from '../exports';\nimport { addConsoleInstrumentationHandler } from '../instrument/console';\nimport { defineIntegration } from '../integration';\nimport type { CaptureContext } from '../scope';\nimport type { IntegrationFn } from '../types-hoist/integration';\nimport { CONSOLE_LEVELS } from '../utils/debug-logger';\nimport { addExceptionMechanism } from '../utils/misc';\nimport { severityLevelFromString } from '../utils/severity';\nimport { safeJoin } from '../utils/string';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\n\ninterface CaptureConsoleOptions {\n levels?: string[];\n\n /**\n * By default, Sentry will mark captured console messages as handled.\n * Set this to `false` if you want to mark them as unhandled instead.\n *\n * @default true\n */\n handled?: boolean;\n}\n\nconst INTEGRATION_NAME = 'CaptureConsole';\n\nconst _captureConsoleIntegration = ((options: CaptureConsoleOptions = {}) => {\n const levels = options.levels || CONSOLE_LEVELS;\n const handled = options.handled ?? true;\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n if (!('console' in GLOBAL_OBJ)) {\n return;\n }\n\n addConsoleInstrumentationHandler(({ args, level }) => {\n if (getClient() !== client || !levels.includes(level)) {\n return;\n }\n\n consoleHandler(args, level, handled);\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Send Console API calls as Sentry Events.\n */\nexport const captureConsoleIntegration = defineIntegration(_captureConsoleIntegration);\n\nfunction consoleHandler(args: unknown[], level: string, handled: boolean): void {\n const severityLevel = severityLevelFromString(level);\n\n /*\n We create this error here already to attach a stack trace to captured messages,\n if users set `attachStackTrace` to `true` in Sentry.init.\n We do this here already because we want to minimize the number of Sentry SDK stack frames\n within the error. Technically, Client.captureMessage will also do it but this happens several\n stack frames deeper.\n */\n const syntheticException = new Error();\n\n const captureContext: CaptureContext = {\n level: severityLevelFromString(level),\n extra: {\n arguments: args,\n },\n };\n\n withScope(scope => {\n scope.addEventProcessor(event => {\n event.logger = 'console';\n\n addExceptionMechanism(event, {\n handled,\n type: 'auto.core.capture_console',\n });\n\n return event;\n });\n\n if (level === 'assert') {\n if (!args[0]) {\n const message = `Assertion failed: ${safeJoin(args.slice(1), ' ') || 'console.assert'}`;\n scope.setExtra('arguments', args.slice(1));\n scope.captureMessage(message, severityLevel, { captureContext, syntheticException });\n }\n return;\n }\n\n const error = args.find(arg => arg instanceof Error);\n if (error) {\n captureException(error, captureContext);\n return;\n }\n\n const message = safeJoin(args, ' ');\n scope.captureMessage(message, severityLevel, { captureContext, syntheticException });\n });\n}\n"],"names":["CONSOLE_LEVELS","GLOBAL_OBJ","addConsoleInstrumentationHandler","getClient","defineIntegration","severityLevelFromString","withScope","addExceptionMechanism","safeJoin","captureException"],"mappings":";;;;;;;;;;;;AAwBA,MAAM,gBAAA,GAAmB,gBAAgB;;AAEzC,MAAM,0BAAA,IAA8B,CAAC,OAAO,GAA0B,EAAE,KAAK;AAC7E,EAAE,MAAM,MAAA,GAAS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C,OAAO,CAAC;;AAER,MAAM,OAAO,KAAK;AAClB,IAAI,CAAC,CAAC;;AAEN,IAAI,IAAI,KAAA,KAAU,QAAQ,EAAE;AAC5B,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;AACpB,QAAQ,MAAM,UAAU,CAAC,kBAAkB,EAAEC,eAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,gBAAgB,CAAC,CAAA;AACA,QAAA,KAAA,CAAA,QAAA,CAAA,WAAA,EAAA,IAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA;AACA,QAAA,KAAA,CAAA,cAAA,CAAA,OAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,kBAAA,EAAA,CAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;;AAEA,IAAA,MAAA,KAAA,GAAA,IAAA,CAAA,IAAA,CAAA,GAAA,IAAA,GAAA,YAAA,KAAA,CAAA;AACA,IAAA,IAAA,KAAA,EAAA;AACA,MAAAC,0BAAA,CAAA,KAAA,EAAA,cAAA,CAAA;AACA,MAAA;AACA,IAAA;;AAEA,IAAA,MAAA,OAAA,GAAAD,eAAA,CAAA,IAAA,EAAA,GAAA,CAAA;AACA,IAAA,KAAA,CAAA,cAAA,CAAA,OAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,kBAAA,EAAA,CAAA;AACA,EAAA,CAAA,CAAA;AACA;;;;"} |
@@ -42,4 +42,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| }); | ||
| client.registerCleanup(unsubscribe); | ||
| client.registerCleanup(unsubscribe); | ||
| if (options.filter) { | ||
| const unsubscribe = console.addConsoleInstrumentationFilter(options.filter); | ||
| client.registerCleanup(unsubscribe); | ||
| } | ||
| }, | ||
@@ -46,0 +50,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"console.js","sources":["../../../src/integrations/console.ts"],"sourcesContent":["import { addBreadcrumb } from '../breadcrumbs';\nimport { getClient } from '../currentScopes';\nimport { addConsoleInstrumentationHandler } from '../instrument/console';\nimport { defineIntegration } from '../integration';\nimport type { ConsoleLevel } from '../types-hoist/instrument';\nimport { CONSOLE_LEVELS } from '../utils/debug-logger';\nimport { severityLevelFromString } from '../utils/severity';\nimport { safeJoin } from '../utils/string';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\n\ninterface ConsoleIntegrationOptions {\n levels: ConsoleLevel[];\n}\n\ntype GlobalObjectWithUtil = typeof GLOBAL_OBJ & {\n util: {\n format: (...args: unknown[]) => string;\n };\n};\n\nconst INTEGRATION_NAME = 'Console';\n\n/**\n * Captures calls to the `console` API as breadcrumbs in Sentry.\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 * ```js\n * Sentry.init({\n * integrations: [Sentry.consoleIntegration({ levels: ['error', 'warn'] })],\n * });\n * ```\n */\nexport const consoleIntegration = defineIntegration((options: Partial<ConsoleIntegrationOptions> = {}) => {\n const levels = new Set(options.levels || CONSOLE_LEVELS);\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const unsubscribe = addConsoleInstrumentationHandler(({ args, level }) => {\n if (getClient() !== client || !levels.has(level)) {\n return;\n }\n\n addConsoleBreadcrumb(level, args);\n });\n\n client.registerCleanup(unsubscribe);\n },\n };\n});\n\n/**\n * Capture a console breadcrumb.\n *\n * Exported just for tests.\n */\nexport function addConsoleBreadcrumb(level: ConsoleLevel, args: unknown[]): void {\n const breadcrumb = {\n category: 'console',\n data: {\n arguments: args,\n logger: 'console',\n },\n level: severityLevelFromString(level),\n message: formatConsoleArgs(args),\n };\n\n if (level === 'assert') {\n if (args[0] === false) {\n const assertionArgs = args.slice(1);\n breadcrumb.message =\n assertionArgs.length > 0 ? `Assertion failed: ${formatConsoleArgs(assertionArgs)}` : 'Assertion failed';\n breadcrumb.data.arguments = assertionArgs;\n } else {\n // Don't capture a breadcrumb for passed assertions\n return;\n }\n }\n\n addBreadcrumb(breadcrumb, {\n input: args,\n level,\n });\n}\n\nfunction formatConsoleArgs(values: unknown[]): string {\n return 'util' in GLOBAL_OBJ && typeof (GLOBAL_OBJ as GlobalObjectWithUtil).util.format === 'function'\n ? (GLOBAL_OBJ as GlobalObjectWithUtil).util.format(...values)\n : safeJoin(values, ' ');\n}\n"],"names":["defineIntegration","CONSOLE_LEVELS","addConsoleInstrumentationHandler","getClient","severityLevelFromString","addBreadcrumb","GLOBAL_OBJ","safeJoin"],"mappings":";;;;;;;;;;;AAoBA,MAAM,gBAAA,GAAmB,SAAS;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,kBAAA,GAAqBA,6BAAiB,CAAC,CAAC,OAAO,GAAuC,EAAE,KAAK;AAC1G,EAAE,MAAM,MAAA,GAAS,IAAI,GAAG,CAAC,OAAO,CAAC,MAAA,IAAUC,0BAAc,CAAC;;AAE1D,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,WAAA,GAAcC,wCAAgC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAA,EAAO,KAAK;AAChF,QAAQ,IAAIC,uBAAS,OAAO,MAAA,IAAU,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;AAC1D,UAAU;AACV,QAAQ;;AAER,QAAQ,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC;AACzC,MAAM,CAAC,CAAC;;AAER,MAAM,MAAM,CAAC,eAAe,CAAC,WAAW,CAAC;AACzC,IAAI,CAAC;AACL,GAAG;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,KAAK,EAAgB,IAAI,EAAmB;AACjF,EAAE,MAAM,aAAa;AACrB,IAAI,QAAQ,EAAE,SAAS;AACvB,IAAI,IAAI,EAAE;AACV,MAAM,SAAS,EAAE,IAAI;AACrB,MAAM,MAAM,EAAE,SAAS;AACvB,KAAK;AACL,IAAI,KAAK,EAAEC,gCAAuB,CAAC,KAAK,CAAC;AACzC,IAAI,OAAO,EAAE,iBAAiB,CAAC,IAAI,CAAC;AACpC,GAAG;;AAEH,EAAE,IAAI,KAAA,KAAU,QAAQ,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,CAAC,CAAA,KAAM,KAAK,EAAE;AAC3B,MAAM,MAAM,gBAAgB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACzC,MAAM,UAAU,CAAC,OAAA;AACjB,QAAQ,aAAa,CAAC,MAAA,GAAS,IAAI,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAA,GAAA,kBAAA;AACA,MAAA,UAAA,CAAA,IAAA,CAAA,SAAA,GAAA,aAAA;AACA,IAAA,CAAA,MAAA;AACA;AACA,MAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAAC,yBAAA,CAAA,UAAA,EAAA;AACA,IAAA,KAAA,EAAA,IAAA;AACA,IAAA,KAAA;AACA,GAAA,CAAA;AACA;;AAEA,SAAA,iBAAA,CAAA,MAAA,EAAA;AACA,EAAA,OAAA,MAAA,IAAAC,oBAAA,IAAA,OAAA,CAAAA,oBAAA,GAAA,IAAA,CAAA,MAAA,KAAA;AACA,MAAA,CAAAA,oBAAA,GAAA,IAAA,CAAA,MAAA,CAAA,GAAA,MAAA;AACA,MAAAC,eAAA,CAAA,MAAA,EAAA,GAAA,CAAA;AACA;;;;;"} | ||
| {"version":3,"file":"console.js","sources":["../../../src/integrations/console.ts"],"sourcesContent":["import { addBreadcrumb } from '../breadcrumbs';\nimport { getClient } from '../currentScopes';\nimport { addConsoleInstrumentationFilter, addConsoleInstrumentationHandler } from '../instrument/console';\nimport { defineIntegration } from '../integration';\nimport type { ConsoleLevel } from '../types-hoist/instrument';\nimport { CONSOLE_LEVELS } from '../utils/debug-logger';\nimport { severityLevelFromString } from '../utils/severity';\nimport { safeJoin } from '../utils/string';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\n\ninterface ConsoleIntegrationOptions {\n levels: ConsoleLevel[];\n /**\n * Filter out console messages that match the given strings or regular expressions.\n * These will neither be passed to the handler, and they will also not be logged to the user, unless they have debug enabled.\n */\n filter?: (string | RegExp)[];\n}\n\ntype GlobalObjectWithUtil = typeof GLOBAL_OBJ & {\n util: {\n format: (...args: unknown[]) => string;\n };\n};\n\nconst INTEGRATION_NAME = 'Console';\n\n/**\n * Captures calls to the `console` API as breadcrumbs in Sentry.\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 * ```js\n * Sentry.init({\n * integrations: [Sentry.consoleIntegration({ levels: ['error', 'warn'] })],\n * });\n * ```\n */\nexport const consoleIntegration = defineIntegration((options: Partial<ConsoleIntegrationOptions> = {}) => {\n const levels = new Set(options.levels || CONSOLE_LEVELS);\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const unsubscribe = addConsoleInstrumentationHandler(({ args, level }) => {\n if (getClient() !== client || !levels.has(level)) {\n return;\n }\n\n addConsoleBreadcrumb(level, args);\n });\n client.registerCleanup(unsubscribe);\n\n if (options.filter) {\n const unsubscribe = addConsoleInstrumentationFilter(options.filter);\n client.registerCleanup(unsubscribe);\n }\n },\n };\n});\n\n/**\n * Capture a console breadcrumb.\n *\n * Exported just for tests.\n */\nexport function addConsoleBreadcrumb(level: ConsoleLevel, args: unknown[]): void {\n const breadcrumb = {\n category: 'console',\n data: {\n arguments: args,\n logger: 'console',\n },\n level: severityLevelFromString(level),\n message: formatConsoleArgs(args),\n };\n\n if (level === 'assert') {\n if (args[0] === false) {\n const assertionArgs = args.slice(1);\n breadcrumb.message =\n assertionArgs.length > 0 ? `Assertion failed: ${formatConsoleArgs(assertionArgs)}` : 'Assertion failed';\n breadcrumb.data.arguments = assertionArgs;\n } else {\n // Don't capture a breadcrumb for passed assertions\n return;\n }\n }\n\n addBreadcrumb(breadcrumb, {\n input: args,\n level,\n });\n}\n\nfunction formatConsoleArgs(values: unknown[]): string {\n return 'util' in GLOBAL_OBJ && typeof (GLOBAL_OBJ as GlobalObjectWithUtil).util.format === 'function'\n ? (GLOBAL_OBJ as GlobalObjectWithUtil).util.format(...values)\n : safeJoin(values, ' ');\n}\n"],"names":["defineIntegration","CONSOLE_LEVELS","addConsoleInstrumentationHandler","getClient","addConsoleInstrumentationFilter","severityLevelFromString","addBreadcrumb","GLOBAL_OBJ","safeJoin"],"mappings":";;;;;;;;;;;AAyBA,MAAM,gBAAA,GAAmB,SAAS;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,kBAAA,GAAqBA,6BAAiB,CAAC,CAAC,OAAO,GAAuC,EAAE,KAAK;AAC1G,EAAE,MAAM,MAAA,GAAS,IAAI,GAAG,CAAC,OAAO,CAAC,MAAA,IAAUC,0BAAc,CAAC;;AAE1D,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,WAAA,GAAcC,wCAAgC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAA,EAAO,KAAK;AAChF,QAAQ,IAAIC,uBAAS,OAAO,MAAA,IAAU,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;AAC1D,UAAU;AACV,QAAQ;;AAER,QAAQ,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC;AACzC,MAAM,CAAC,CAAC;AACR,MAAM,MAAM,CAAC,eAAe,CAAC,WAAW,CAAC;;AAEzC,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE;AAC1B,QAAQ,MAAM,cAAcC,uCAA+B,CAAC,OA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AA,GAAA,CAAA;AACA;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const debugLogger = require('../../utils/debug-logger.js'); | ||
| const _exports = require('../../exports.js'); | ||
| const exports$1 = require('../../exports.js'); | ||
| const debugBuild = require('../../debug-build.js'); | ||
@@ -185,3 +185,3 @@ const utils = require('./utils.js'); | ||
| if (shouldHandleError(error)) { | ||
| const eventId = _exports.captureException(error, { | ||
| const eventId = exports$1.captureException(error, { | ||
| mechanism: { type: 'auto.middleware.express', handled: false }, | ||
@@ -188,0 +188,0 @@ }); |
@@ -1,1 +0,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 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 isExpressWithoutRouterPrototype,\n isExpressWithRouterPrototype,\n} from './utils';\nimport { wrapMethod } from '../../utils/object';\nimport { patchLayer } from './patch-layer';\nimport { setSDKProcessingMetadata } from './set-sdk-processing-metadata';\nimport { getDefaultExport } from '../../utils/get-default-export';\n\nfunction isLegacyOptions(\n options: ExpressModuleExport | (ExpressIntegrationOptions & { express: ExpressModuleExport }),\n): options is ExpressIntegrationOptions & { express: ExpressModuleExport } {\n return !!(options as { express: ExpressModuleExport }).express;\n}\n\n// TODO: remove this deprecation handling in v11\nlet didLegacyDeprecationWarning = false;\nfunction deprecationWarning() {\n if (!didLegacyDeprecationWarning) {\n didLegacyDeprecationWarning = true;\n DEBUG_BUILD &&\n debug.warn(\n '[Express] `patchExpressModule(options)` is deprecated. Use `patchExpressModule(moduleExports, getOptions)` instead.',\n );\n }\n}\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 * ```\n */\nexport function patchExpressModule(\n moduleExports: ExpressModuleExport,\n getOptions: () => ExpressIntegrationOptions,\n): ExpressModuleExport;\n/**\n * @deprecated Pass the Express module export as the first argument and options getter as the second argument.\n */\nexport function patchExpressModule(\n options: ExpressIntegrationOptions & { express: ExpressModuleExport },\n): ExpressModuleExport;\nexport function patchExpressModule(\n optionsOrExports: ExpressModuleExport | (ExpressIntegrationOptions & { express: ExpressModuleExport }),\n maybeGetOptions?: () => ExpressIntegrationOptions,\n): ExpressModuleExport {\n let getOptions: () => ExpressIntegrationOptions;\n let moduleExports: ExpressModuleExport;\n if (!maybeGetOptions && isLegacyOptions(optionsOrExports)) {\n const { express, ...options } = optionsOrExports;\n moduleExports = express;\n getOptions = () => options;\n deprecationWarning();\n } else if (typeof maybeGetOptions !== 'function') {\n throw new TypeError('`patchExpressModule(moduleExports, getOptions)` requires a `getOptions` callback');\n } else {\n getOptions = maybeGetOptions;\n moduleExports = optionsOrExports as ExpressModuleExport;\n }\n\n // pass in the require() or import() result of express\n const express = getDefaultExport(moduleExports);\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(getOptions, 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(getOptions, 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(getOptions, 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":["DEBUG_BUILD","debug","getDefaultExport","isExpressWithRouterPrototype","isExpressWithoutRouterPrototype","wrapMethod","patchLayer","getLayerPath","setSDKProcessingMetadata","defaultShouldHandleError","captureException"],"mapp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pF,EAAE;;AAEF,EAAE,OAAO,OAAO;AAChB;;AAEA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,OAAO,EAAkD;AAC7F,EAAE,OAAO,SAAS,qBAAqB;AACvC,IAAI,KAAK;AACT,IAAI,OAAO;AACX,IAAI,GAAG;AACP,IAAI,IAAI;AACR,IAAU;AACV;AACA,IAAIO,iDAAwB,CAAC,OAAO,CAAC;AACrC,IAAI,MAAM,iBAAA,GAAoB,OAAO,EAAE,iBAAA,IAAqBC,8BAAwB;;AAEpF,IAAI,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE;AAClC,MAAM,MAAM,OAAA,GAAUC,yBAAgB,CAAC,KAAK,EAAE;AAC9C,QAAQ,SAAS,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE,OAAO,EAAE,KAAA,EAAO;AACtE,OAAO,CAAC;AACR,MAAM,CAAC,GAAA,GAA4B,MAAA,GAAS,OAAO;AACnD,IAAI;;AAEJ,IAAI,IAAI,CAAC,KAAK,CAAC;AACf,EAAE,CAAC;AACH;;AAEA;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;AACO,SAAS,wBAAwB;AACxC,EAAE;;AAGA;AACF,EAAE,OAAO;AACT,EAAQ;AACR,EAAE,GAAG,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC;AAClC,EAAE,GAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;AACvC;;AAEA,SAAS,qBAAqB,GAAsB;AACpD,EAAE,OAAO,SAAS,uBAAuB,CAAC,OAAO,EAAkB,IAAI,EAAmB,IAAI,EAAoB;AAClH,IAAIF,iDAAwB,CAAC,OAAO,CAAC;AACrC,IAAI,IAAI,EAAE;AACV,EAAE,CAAC;AACH;;;;;;"} | ||
| {"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 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 isExpressWithoutRouterPrototype,\n isExpressWithRouterPrototype,\n} from './utils';\nimport { wrapMethod } from '../../utils/object';\nimport { patchLayer } from './patch-layer';\nimport { setSDKProcessingMetadata } from './set-sdk-processing-metadata';\nimport { getDefaultExport } from '../../utils/get-default-export';\n\nfunction isLegacyOptions(\n options: ExpressModuleExport | (ExpressIntegrationOptions & { express: ExpressModuleExport }),\n): options is ExpressIntegrationOptions & { express: ExpressModuleExport } {\n return !!(options as { express: ExpressModuleExport }).express;\n}\n\n// TODO: remove this deprecation handling in v11\nlet didLegacyDeprecationWarning = false;\nfunction deprecationWarning() {\n if (!didLegacyDeprecationWarning) {\n didLegacyDeprecationWarning = true;\n DEBUG_BUILD &&\n debug.warn(\n '[Express] `patchExpressModule(options)` is deprecated. Use `patchExpressModule(moduleExports, getOptions)` instead.',\n );\n }\n}\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 * ```\n */\nexport function patchExpressModule(\n moduleExports: ExpressModuleExport,\n getOptions: () => ExpressIntegrationOptions,\n): ExpressModuleExport;\n/**\n * @deprecated Pass the Express module export as the first argument and options getter as the second argument.\n */\nexport function patchExpressModule(\n options: ExpressIntegrationOptions & { express: ExpressModuleExport },\n): ExpressModuleExport;\nexport function patchExpressModule(\n optionsOrExports: ExpressModuleExport | (ExpressIntegrationOptions & { express: ExpressModuleExport }),\n maybeGetOptions?: () => ExpressIntegrationOptions,\n): ExpressModuleExport {\n let getOptions: () => ExpressIntegrationOptions;\n let moduleExports: ExpressModuleExport;\n if (!maybeGetOptions && isLegacyOptions(optionsOrExports)) {\n const { express, ...options } = optionsOrExports;\n moduleExports = express;\n getOptions = () => options;\n deprecationWarning();\n } else if (typeof maybeGetOptions !== 'function') {\n throw new TypeError('`patchExpressModule(moduleExports, getOptions)` requires a `getOptions` callback');\n } else {\n getOptions = maybeGetOptions;\n moduleExports = optionsOrExports as ExpressModuleExport;\n }\n\n // pass in the require() or import() result of express\n const express = getDefaultExport(moduleExports);\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(getOptions, 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(getOptions, 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(getOptions, 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":["DEBUG_BUILD","debug","getDefaultExport","isExpressWithRouterPrototype","isExpressWithoutRouterPrototype","wrapMethod","patchLayer","getLayerPath","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;;;AA+BA,SAAS,eAAe;AACxB,EAAE,OAAO;AACT,EAA2E;AAC3E,EAAE,OAAO,CAAC,CAAC,CAAC,OAAA,GAA6C,OAAO;AAChE;;AAEA;AACA,IAAI,2BAAA,GAA8B,KAAK;AACvC,SAAS,kBAAkB,GAAG;AAC9B,EAAE,IAAI,CAAC,2BAA2B,EAAE;AACpC,IAAI,2BAAA,GAA8B,IAAI;AACtC,IAAIA,sBAAA;AACJ,MAAMC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9C,QAAQ,SAAS,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE,OAAO,EAAE,KAAA,EAAO;AACtE,OAAO,CAAC;AACR,MAAM,CAAC,GAAA,GAA4B,MAAA,GAAS,OAAO;AACnD,IAAI;;AAEJ,IAAI,IAAI,CAAC,KAAK,CAAC;AACf,EAAE,CAAC;AACH;;AAEA;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;AACO,SAAS,wBAAwB;AACxC,EAAE;;AAGA;AACF,EAAE,OAAO;AACT,EAAQ;AACR,EAAE,GAAG,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC;AAClC,EAAE,GAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;AACvC;;AAEA,SAAS,qBAAqB,GAAsB;AACpD,EAAE,OAAO,SAAS,uBAAuB,CAAC,OAAO,EAAkB,IAAI,EAAmB,IAAI,EAAoB;AAClH,IAAIF,iDAAwB,CAAC,OAAO,CAAC;AACrC,IAAI,IAAI,EAAE;AACV,EAAE,CAAC;AACH;;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const currentScopes = require('../../currentScopes.js'); | ||
| const _exports = require('../../exports.js'); | ||
| const exports$1 = require('../../exports.js'); | ||
| const spanUtils = require('../../utils/spanUtils.js'); | ||
@@ -39,3 +39,3 @@ const spanstatus = require('../../tracing/spanstatus.js'); | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { | ||
@@ -42,0 +42,0 @@ type: 'auto.ai.mcp_server', |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"errorCapture.js","sources":["../../../../src/integrations/mcp-server/errorCapture.ts"],"sourcesContent":["/**\n * Safe error capture utilities for MCP server instrumentation\n *\n * Ensures error reporting never interferes with MCP server operation.\n * All capture operations are wrapped in try-catch to prevent side effects.\n */\n\nimport { getClient } from '../../currentScopes';\nimport { captureException } from '../../exports';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { getActiveSpan } from '../../utils/spanUtils';\nimport type { McpErrorType } from './types';\n\n/**\n * Captures an error without affecting MCP server operation.\n *\n * The active span already contains all MCP context (method, tool, arguments, etc.)\n * @param error - Error to capture\n * @param errorType - Classification of error type for filtering\n * @param extraData - Additional context data to include\n */\nexport function captureError(error: Error, errorType?: McpErrorType, extraData?: Record<string, unknown>): void {\n try {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const activeSpan = getActiveSpan();\n if (activeSpan?.isRecording()) {\n activeSpan.setStatus({\n code: SPAN_STATUS_ERROR,\n message: 'internal_error',\n });\n }\n\n captureException(error, {\n mechanism: {\n type: 'auto.ai.mcp_server',\n handled: false,\n data: {\n error_type: errorType || 'handler_execution',\n ...extraData,\n },\n },\n });\n } catch {\n // noop\n }\n}\n"],"names":["getClient","getActiveSpan","SPAN_STATUS_ERROR","captureException"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,YAAY,CAAC,KAAK,EAAS,SAAS,EAAiB,SAAS,EAAkC;AAChH,EAAE,IAAI;AACN,IAAI,MAAM,MAAA,GAASA,uBAAS,EAAE;AAC9B,IAAI,IAAI,CAAC,MAAM,EAAE;AACjB,MAAM;AACN,IAAI;;AAEJ,IAAI,MAAM,UAAA,GAAaC,uBAAa,EAAE;AACtC,IAAI,IAAI,UAAU,EAAE,WAAW,EAAE,EAAE;AACnC,MAAM,UAAU,CAAC,SAAS,CAAC;AAC3B,QAAQ,IAAI,EAAEC,4BAAiB;AAC/B,QAAQ,OAAO,EAAE,gBAAgB;AACjC,OAAO,CAAC;AACR,IAAI;;AAEJ,IAAIC,yBAAgB,CAAC,KAAK,EAAE;AAC5B,MAAM,SAAS,EAAE;AACjB,QAAQ,IAAI,EAAE,oBAAoB;AAClC,QAAQ,OAAO,EAAE,KAAK;AACtB,QAAQ,IAAI,EAAE;AACd,UAAU,UAAU,EAAE,SAAA,IAAa,mBAAmB;AACtD,UAAU,GAAG,SAAS;AACtB,SAAS;AACT,OAAO;AACP,KAAK,CAAC;AACN,EAAE,EAAE,MAAM;AACV;AACA,EAAE;AACF;;;;"} | ||
| {"version":3,"file":"errorCapture.js","sources":["../../../../src/integrations/mcp-server/errorCapture.ts"],"sourcesContent":["/**\n * Safe error capture utilities for MCP server instrumentation\n *\n * Ensures error reporting never interferes with MCP server operation.\n * All capture operations are wrapped in try-catch to prevent side effects.\n */\n\nimport { getClient } from '../../currentScopes';\nimport { captureException } from '../../exports';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { getActiveSpan } from '../../utils/spanUtils';\nimport type { McpErrorType } from './types';\n\n/**\n * Captures an error without affecting MCP server operation.\n *\n * The active span already contains all MCP context (method, tool, arguments, etc.)\n * @param error - Error to capture\n * @param errorType - Classification of error type for filtering\n * @param extraData - Additional context data to include\n */\nexport function captureError(error: Error, errorType?: McpErrorType, extraData?: Record<string, unknown>): void {\n try {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const activeSpan = getActiveSpan();\n if (activeSpan?.isRecording()) {\n activeSpan.setStatus({\n code: SPAN_STATUS_ERROR,\n message: 'internal_error',\n });\n }\n\n captureException(error, {\n mechanism: {\n type: 'auto.ai.mcp_server',\n handled: false,\n data: {\n error_type: errorType || 'handler_execution',\n ...extraData,\n },\n },\n });\n } catch {\n // noop\n }\n}\n"],"names":["getClient","getActiveSpan","SPAN_STATUS_ERROR","captureException"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,YAAY,CAAC,KAAK,EAAS,SAAS,EAAiB,SAAS,EAAkC;AAChH,EAAE,IAAI;AACN,IAAI,MAAM,MAAA,GAASA,uBAAS,EAAE;AAC9B,IAAI,IAAI,CAAC,MAAM,EAAE;AACjB,MAAM;AACN,IAAI;;AAEJ,IAAI,MAAM,UAAA,GAAaC,uBAAa,EAAE;AACtC,IAAI,IAAI,UAAU,EAAE,WAAW,EAAE,EAAE;AACnC,MAAM,UAAU,CAAC,SAAS,CAAC;AAC3B,QAAQ,IAAI,EAAEC,4BAAiB;AAC/B,QAAQ,OAAO,EAAE,gBAAgB;AACjC,OAAO,CAAC;AACR,IAAI;;AAEJ,IAAIC,0BAAgB,CAAC,KAAK,EAAE;AAC5B,MAAM,SAAS,EAAE;AACjB,QAAQ,IAAI,EAAE,oBAAoB;AAClC,QAAQ,OAAO,EAAE,KAAK;AACtB,QAAQ,IAAI,EAAE;AACd,UAAU,UAAU,EAAE,SAAA,IAAa,mBAAmB;AACtD,UAAU,GAAG,SAAS;AACtB,SAAS;AACT,OAAO;AACP,KAAK,CAAC;AACN,EAAE,EAAE,MAAM;AACV;AACA,EAAE;AACF;;;;"} |
@@ -173,3 +173,75 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| /** | ||
| * Retroactively wraps handlers on tools, resources, and prompts that were registered | ||
| * before `wrapMcpServerWithSentry` was called. | ||
| * | ||
| * The MCP SDK stores registered entries in private maps and invokes them via the entry's | ||
| * own property at call time — `executor` for tools, `readCallback` for resources, and | ||
| * `handler` for prompts. Replacing those properties | ||
| * in-place is therefore equivalent to having wrapped the original registration call. | ||
| * | ||
| * NOTE: This intentionally accesses private MCP SDK internals (`_registeredTools` etc.). | ||
| * The properties and their shapes are verified against @modelcontextprotocol/sdk source: | ||
| * https://github.com/modelcontextprotocol/typescript-sdk/blob/2c0c481cb9dbfd15c8613f765c940a5f5bace94d/packages/server/src/server/mcp.ts#L304 | ||
| * When upgrading the MCP SDK, re-verify that these internal maps and their callable | ||
| * properties still exist and are invoked directly (not captured by closure at registration). | ||
| * All access is defensive — if a property is absent or not a function we skip silently. | ||
| * @internal | ||
| */ | ||
| function wrapExistingHandlers(serverInstance) { | ||
| const server = serverInstance ; | ||
| // Tools: MCP SDK calls registeredTool.executor (generated from handler at registration time) | ||
| const registeredTools = server['_registeredTools']; | ||
| if (registeredTools && typeof registeredTools === 'object') { | ||
| for (const [name, tool] of Object.entries(registeredTools )) { | ||
| if (typeof tool['executor'] === 'function') { | ||
| tool['executor'] = createWrappedHandler(tool['executor'] , 'registerTool', name); | ||
| } | ||
| } | ||
| } | ||
| // Resources: MCP SDK calls registeredResource.readCallback | ||
| const registeredResources = server['_registeredResources']; | ||
| if (registeredResources && typeof registeredResources === 'object') { | ||
| for (const [name, resource] of Object.entries(registeredResources )) { | ||
| if (typeof resource['readCallback'] === 'function') { | ||
| resource['readCallback'] = createWrappedHandler( | ||
| resource['readCallback'] , | ||
| 'registerResource', | ||
| name, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| // Resource templates: MCP SDK calls registeredResourceTemplate.readCallback | ||
| const registeredResourceTemplates = server['_registeredResourceTemplates']; | ||
| if (registeredResourceTemplates && typeof registeredResourceTemplates === 'object') { | ||
| for (const [name, template] of Object.entries( | ||
| registeredResourceTemplates , | ||
| )) { | ||
| if (typeof template['readCallback'] === 'function') { | ||
| template['readCallback'] = createWrappedHandler( | ||
| template['readCallback'] , | ||
| 'registerResource', | ||
| name, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| // Prompts: MCP SDK calls registeredPrompt.handler | ||
| const registeredPrompts = server['_registeredPrompts']; | ||
| if (registeredPrompts && typeof registeredPrompts === 'object') { | ||
| for (const [name, prompt] of Object.entries(registeredPrompts )) { | ||
| if (typeof prompt['handler'] === 'function') { | ||
| prompt['handler'] = createWrappedHandler(prompt['handler'] , 'registerPrompt', name); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| exports.wrapAllMCPHandlers = wrapAllMCPHandlers; | ||
| exports.wrapExistingHandlers = wrapExistingHandlers; | ||
| exports.wrapPromptHandlers = wrapPromptHandlers; | ||
@@ -176,0 +248,0 @@ exports.wrapResourceHandlers = wrapResourceHandlers; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"handlers.js","sources":["../../../../src/integrations/mcp-server/handlers.ts"],"sourcesContent":["/**\n * Handler method wrapping for MCP server instrumentation\n *\n * Provides automatic error capture and span correlation for tool, resource,\n * and prompt handlers.\n */\n\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { debug } from '../../utils/debug-logger';\nimport { fill } from '../../utils/object';\nimport { captureError } from './errorCapture';\nimport type { MCPHandler, MCPServerInstance } from './types';\n\n/**\n * Generic function to wrap MCP server method handlers\n * @internal\n * @param serverInstance - MCP server instance\n * @param methodName - Method name to wrap (tool, resource, prompt)\n */\nfunction wrapMethodHandler(serverInstance: MCPServerInstance, methodName: keyof MCPServerInstance): void {\n fill(serverInstance, methodName, originalMethod => {\n return function (this: MCPServerInstance, name: string, ...args: unknown[]) {\n const handler = args[args.length - 1];\n\n if (typeof handler !== 'function') {\n return (originalMethod as (...args: unknown[]) => unknown).call(this, name, ...args);\n }\n\n const wrappedHandler = createWrappedHandler(handler as MCPHandler, methodName, name);\n return (originalMethod as (...args: unknown[]) => unknown).call(this, name, ...args.slice(0, -1), wrappedHandler);\n };\n });\n}\n\n/**\n * Creates a wrapped handler with span correlation and error capture\n * @internal\n * @param originalHandler - Original handler function\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n * @returns Wrapped handler function\n */\nfunction createWrappedHandler(originalHandler: MCPHandler, methodName: keyof MCPServerInstance, handlerName: string) {\n return function (this: unknown, ...handlerArgs: unknown[]): unknown {\n try {\n return createErrorCapturingHandler.call(this, originalHandler, methodName, handlerName, handlerArgs);\n } catch (error) {\n DEBUG_BUILD && debug.warn('MCP handler wrapping failed:', error);\n return originalHandler.apply(this, handlerArgs);\n }\n };\n}\n\n/**\n * Creates an error-capturing wrapper for handler execution\n * @internal\n * @param originalHandler - Original handler function\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n * @param handlerArgs - Handler arguments\n * @param extraHandlerData - Additional handler context\n * @returns Handler execution result\n */\nfunction createErrorCapturingHandler(\n this: MCPServerInstance,\n originalHandler: MCPHandler,\n methodName: keyof MCPServerInstance,\n handlerName: string,\n handlerArgs: unknown[],\n): unknown {\n try {\n const result = originalHandler.apply(this, handlerArgs);\n\n if (result && typeof result === 'object' && typeof (result as { then?: unknown }).then === 'function') {\n return Promise.resolve(result).catch(error => {\n captureHandlerError(error, methodName, handlerName);\n throw error;\n });\n }\n\n return result;\n } catch (error) {\n captureHandlerError(error as Error, methodName, handlerName);\n throw error;\n }\n}\n\n/**\n * Captures handler execution errors based on handler type\n * @internal\n * @param error - Error to capture\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n */\nfunction captureHandlerError(error: Error, methodName: keyof MCPServerInstance, handlerName: string): void {\n try {\n const extraData: Record<string, unknown> = {};\n\n if (methodName === 'tool' || methodName === 'registerTool') {\n extraData.tool_name = handlerName;\n\n if (\n error.name === 'ProtocolValidationError' ||\n error.message.includes('validation') ||\n error.message.includes('protocol')\n ) {\n captureError(error, 'validation', extraData);\n } else if (\n error.name === 'ServerTimeoutError' ||\n error.message.includes('timed out') ||\n error.message.includes('timeout')\n ) {\n captureError(error, 'timeout', extraData);\n } else {\n captureError(error, 'tool_execution', extraData);\n }\n } else if (methodName === 'resource' || methodName === 'registerResource') {\n extraData.resource_uri = handlerName;\n captureError(error, 'resource_execution', extraData);\n } else if (methodName === 'prompt' || methodName === 'registerPrompt') {\n extraData.prompt_name = handlerName;\n captureError(error, 'prompt_execution', extraData);\n }\n } catch (_captureErr) {\n // noop\n }\n}\n\n/**\n * Wraps tool handlers to associate them with request spans.\n * Instruments both `tool` (legacy API) and `registerTool` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapToolHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.tool === 'function') wrapMethodHandler(serverInstance, 'tool');\n if (typeof serverInstance.registerTool === 'function') wrapMethodHandler(serverInstance, 'registerTool');\n}\n\n/**\n * Wraps resource handlers to associate them with request spans.\n * Instruments both `resource` (legacy API) and `registerResource` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapResourceHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.resource === 'function') wrapMethodHandler(serverInstance, 'resource');\n if (typeof serverInstance.registerResource === 'function') wrapMethodHandler(serverInstance, 'registerResource');\n}\n\n/**\n * Wraps prompt handlers to associate them with request spans.\n * Instruments both `prompt` (legacy API) and `registerPrompt` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapPromptHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.prompt === 'function') wrapMethodHandler(serverInstance, 'prompt');\n if (typeof serverInstance.registerPrompt === 'function') wrapMethodHandler(serverInstance, 'registerPrompt');\n}\n\n/**\n * Wraps all MCP handler types for span correlation.\n * Supports both the legacy API (`tool`, `resource`, `prompt`) and the newer API\n * (`registerTool`, `registerResource`, `registerPrompt`), instrumenting whichever methods are present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapAllMCPHandlers(serverInstance: MCPServerInstance): void {\n wrapToolHandlers(serverInstance);\n wrapResourceHandlers(serverInstance);\n wrapPromptHandlers(serverInstance);\n}\n"],"names":["fill","DEBUG_BUILD","debug","captureError"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,cAAc,EAAqB,UAAU,EAAiC;AACzG,EAAEA,WAAI,CAAC,cAAc,EAAE,UAAU,EAAE,kBAAkB;AACrD,IAAI,OAAO,WAAmC,IAAI,EAAU,GAAG,IAAI,EAAa;AAChF,MAAM,MAAM,OAAA,GAAU,IAAI,CAAC,IAAI,CAAC,MAAA,GAAS,CAAC,CAAC;;AAE3C,MAAM,IAAI,OAAO,OAAA,KAAY,UAAU,EAAE;AACzC,QAAQ,OAAO,CAAC,cAAA,GAAmD,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;AAC5F,MAAM;;AAEN,MAAM,MAAM,cAAA,GAAi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EAAE,gBAAgB,CAAC,cAAc,CAAC;AAClC,EAAE,oBAAoB,CAAC,cAAc,CAAC;AACtC,EAAE,kBAAkB,CAAC,cAAc,CAAC;AACpC;;;;;;;"} | ||
| {"version":3,"file":"handlers.js","sources":["../../../../src/integrations/mcp-server/handlers.ts"],"sourcesContent":["/**\n * Handler method wrapping for MCP server instrumentation\n *\n * Provides automatic error capture and span correlation for tool, resource,\n * and prompt handlers.\n */\n\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { debug } from '../../utils/debug-logger';\nimport { fill } from '../../utils/object';\nimport { captureError } from './errorCapture';\nimport type { MCPHandler, MCPServerInstance } from './types';\n\n/**\n * Generic function to wrap MCP server method handlers\n * @internal\n * @param serverInstance - MCP server instance\n * @param methodName - Method name to wrap (tool, resource, prompt)\n */\nfunction wrapMethodHandler(serverInstance: MCPServerInstance, methodName: keyof MCPServerInstance): void {\n fill(serverInstance, methodName, originalMethod => {\n return function (this: MCPServerInstance, name: string, ...args: unknown[]) {\n const handler = args[args.length - 1];\n\n if (typeof handler !== 'function') {\n return (originalMethod as (...args: unknown[]) => unknown).call(this, name, ...args);\n }\n\n const wrappedHandler = createWrappedHandler(handler as MCPHandler, methodName, name);\n return (originalMethod as (...args: unknown[]) => unknown).call(this, name, ...args.slice(0, -1), wrappedHandler);\n };\n });\n}\n\n/**\n * Creates a wrapped handler with span correlation and error capture\n * @internal\n * @param originalHandler - Original handler function\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n * @returns Wrapped handler function\n */\nfunction createWrappedHandler(originalHandler: MCPHandler, methodName: keyof MCPServerInstance, handlerName: string) {\n return function (this: unknown, ...handlerArgs: unknown[]): unknown {\n try {\n return createErrorCapturingHandler.call(this, originalHandler, methodName, handlerName, handlerArgs);\n } catch (error) {\n DEBUG_BUILD && debug.warn('MCP handler wrapping failed:', error);\n return originalHandler.apply(this, handlerArgs);\n }\n };\n}\n\n/**\n * Creates an error-capturing wrapper for handler execution\n * @internal\n * @param originalHandler - Original handler function\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n * @param handlerArgs - Handler arguments\n * @param extraHandlerData - Additional handler context\n * @returns Handler execution result\n */\nfunction createErrorCapturingHandler(\n this: MCPServerInstance,\n originalHandler: MCPHandler,\n methodName: keyof MCPServerInstance,\n handlerName: string,\n handlerArgs: unknown[],\n): unknown {\n try {\n const result = originalHandler.apply(this, handlerArgs);\n\n if (result && typeof result === 'object' && typeof (result as { then?: unknown }).then === 'function') {\n return Promise.resolve(result).catch(error => {\n captureHandlerError(error, methodName, handlerName);\n throw error;\n });\n }\n\n return result;\n } catch (error) {\n captureHandlerError(error as Error, methodName, handlerName);\n throw error;\n }\n}\n\n/**\n * Captures handler execution errors based on handler type\n * @internal\n * @param error - Error to capture\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n */\nfunction captureHandlerError(error: Error, methodName: keyof MCPServerInstance, handlerName: string): void {\n try {\n const extraData: Record<string, unknown> = {};\n\n if (methodName === 'tool' || methodName === 'registerTool') {\n extraData.tool_name = handlerName;\n\n if (\n error.name === 'ProtocolValidationError' ||\n error.message.includes('validation') ||\n error.message.includes('protocol')\n ) {\n captureError(error, 'validation', extraData);\n } else if (\n error.name === 'ServerTimeoutError' ||\n error.message.includes('timed out') ||\n error.message.includes('timeout')\n ) {\n captureError(error, 'timeout', extraData);\n } else {\n captureError(error, 'tool_execution', extraData);\n }\n } else if (methodName === 'resource' || methodName === 'registerResource') {\n extraData.resource_uri = handlerName;\n captureError(error, 'resource_execution', extraData);\n } else if (methodName === 'prompt' || methodName === 'registerPrompt') {\n extraData.prompt_name = handlerName;\n captureError(error, 'prompt_execution', extraData);\n }\n } catch (_captureErr) {\n // noop\n }\n}\n\n/**\n * Wraps tool handlers to associate them with request spans.\n * Instruments both `tool` (legacy API) and `registerTool` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapToolHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.tool === 'function') wrapMethodHandler(serverInstance, 'tool');\n if (typeof serverInstance.registerTool === 'function') wrapMethodHandler(serverInstance, 'registerTool');\n}\n\n/**\n * Wraps resource handlers to associate them with request spans.\n * Instruments both `resource` (legacy API) and `registerResource` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapResourceHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.resource === 'function') wrapMethodHandler(serverInstance, 'resource');\n if (typeof serverInstance.registerResource === 'function') wrapMethodHandler(serverInstance, 'registerResource');\n}\n\n/**\n * Wraps prompt handlers to associate them with request spans.\n * Instruments both `prompt` (legacy API) and `registerPrompt` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapPromptHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.prompt === 'function') wrapMethodHandler(serverInstance, 'prompt');\n if (typeof serverInstance.registerPrompt === 'function') wrapMethodHandler(serverInstance, 'registerPrompt');\n}\n\n/**\n * Wraps all MCP handler types for span correlation.\n * Supports both the legacy API (`tool`, `resource`, `prompt`) and the newer API\n * (`registerTool`, `registerResource`, `registerPrompt`), instrumenting whichever methods are present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapAllMCPHandlers(serverInstance: MCPServerInstance): void {\n wrapToolHandlers(serverInstance);\n wrapResourceHandlers(serverInstance);\n wrapPromptHandlers(serverInstance);\n}\n\n/**\n * Retroactively wraps handlers on tools, resources, and prompts that were registered\n * before `wrapMcpServerWithSentry` was called.\n *\n * The MCP SDK stores registered entries in private maps and invokes them via the entry's\n * own property at call time — `executor` for tools, `readCallback` for resources, and\n * `handler` for prompts. Replacing those properties\n * in-place is therefore equivalent to having wrapped the original registration call.\n *\n * NOTE: This intentionally accesses private MCP SDK internals (`_registeredTools` etc.).\n * The properties and their shapes are verified against @modelcontextprotocol/sdk source:\n * https://github.com/modelcontextprotocol/typescript-sdk/blob/2c0c481cb9dbfd15c8613f765c940a5f5bace94d/packages/server/src/server/mcp.ts#L304\n * When upgrading the MCP SDK, re-verify that these internal maps and their callable\n * properties still exist and are invoked directly (not captured by closure at registration).\n * All access is defensive — if a property is absent or not a function we skip silently.\n * @internal\n */\nexport function wrapExistingHandlers(serverInstance: MCPServerInstance): void {\n const server = serverInstance as unknown as Record<string, unknown>;\n\n // Tools: MCP SDK calls registeredTool.executor (generated from handler at registration time)\n const registeredTools = server['_registeredTools'];\n if (registeredTools && typeof registeredTools === 'object') {\n for (const [name, tool] of Object.entries(registeredTools as Record<string, Record<string, unknown>>)) {\n if (typeof tool['executor'] === 'function') {\n tool['executor'] = createWrappedHandler(tool['executor'] as MCPHandler, 'registerTool', name);\n }\n }\n }\n\n // Resources: MCP SDK calls registeredResource.readCallback\n const registeredResources = server['_registeredResources'];\n if (registeredResources && typeof registeredResources === 'object') {\n for (const [name, resource] of Object.entries(registeredResources as Record<string, Record<string, unknown>>)) {\n if (typeof resource['readCallback'] === 'function') {\n resource['readCallback'] = createWrappedHandler(\n resource['readCallback'] as MCPHandler,\n 'registerResource',\n name,\n );\n }\n }\n }\n\n // Resource templates: MCP SDK calls registeredResourceTemplate.readCallback\n const registeredResourceTemplates = server['_registeredResourceTemplates'];\n if (registeredResourceTemplates && typeof registeredResourceTemplates === 'object') {\n for (const [name, template] of Object.entries(\n registeredResourceTemplates as Record<string, Record<string, unknown>>,\n )) {\n if (typeof template['readCallback'] === 'function') {\n template['readCallback'] = createWrappedHandler(\n template['readCallback'] as MCPHandler,\n 'registerResource',\n name,\n );\n }\n }\n }\n\n // Prompts: MCP SDK calls registeredPrompt.handler\n const registeredPrompts = server['_registeredPrompts'];\n if (registeredPrompts && typeof registeredPrompts === 'object') {\n for (const [name, prompt] of Object.entries(registeredPrompts as Record<string, Record<string, unknown>>)) {\n if (typeof prompt['handler'] === 'function') {\n prompt['handler'] = createWrappedHandler(prompt['handler'] as MCPHandler, 'registerPrompt', name);\n }\n }\n }\n}\n"],"names":["fill","DEBUG_BUILD","debug","captureError"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;;AAQA;AACA;AACA;A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C,SAAS,CAAA,GAAI,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAA,GAAiB,gBAAgB,EAAE,IAAI,CAAC;AACzG,MAAM;AACN,IAAI;AACJ,EAAE;AACF;;;;;;;;"} |
@@ -22,2 +22,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| * | ||
| * Both call orderings are supported: wrapping before or after registering tools, resources, | ||
| * and prompts. Sentry patches the registration methods for future handlers and retroactively | ||
| * wraps any already-registered ones. Wrapping at construction time is recommended by | ||
| * convention (consistent with other SDK integrations), but is not required. | ||
| * | ||
| * @example | ||
@@ -29,3 +34,3 @@ * ```typescript | ||
| * | ||
| * // Default: inputs/outputs captured based on sendDefaultPii option | ||
| * // Wrap first, then register tools — this is the correct order | ||
| * const server = Sentry.wrapMcpServerWithSentry( | ||
@@ -35,2 +40,4 @@ * new McpServer({ name: "my-server", version: "1.0.0" }) | ||
| * | ||
| * server.registerTool('my-tool', schema, handler); | ||
| * | ||
| * // Explicitly control input/output capture | ||
@@ -87,2 +94,4 @@ * const server = Sentry.wrapMcpServerWithSentry( | ||
| handlers.wrapExistingHandlers(serverInstance); | ||
| wrappedMcpServerInstances.add(mcpServerInstance); | ||
@@ -89,0 +98,0 @@ return mcpServerInstance; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/integrations/mcp-server/index.ts"],"sourcesContent":["import { getClient } from '../../currentScopes';\nimport { fill } from '../../utils/object';\nimport { wrapAllMCPHandlers } from './handlers';\nimport { wrapTransportError, wrapTransportOnClose, wrapTransportOnMessage, wrapTransportSend } from './transport';\nimport type { MCPServerInstance, McpServerWrapperOptions, MCPTransport, ResolvedMcpOptions } from './types';\nimport { validateMcpServerInstance } from './validation';\n\n/**\n * Tracks wrapped MCP server instances to prevent double-wrapping\n * @internal\n */\nconst wrappedMcpServerInstances = new WeakSet();\n\n/**\n * Wraps a MCP Server instance from the `@modelcontextprotocol/sdk` package with Sentry instrumentation.\n *\n * Compatible with versions `^1.9.0` of the `@modelcontextprotocol/sdk` package (legacy `tool`/`resource`/`prompt` API)\n * and versions that expose the newer `registerTool`/`registerResource`/`registerPrompt` API (introduced in 1.x, sole API in 2.x).\n * Automatically instruments transport methods and handler functions for comprehensive monitoring.\n *\n * @example\n * ```typescript\n * import * as Sentry from '@sentry/core';\n * import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n * import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\n *\n * // Default: inputs/outputs captured based on sendDefaultPii option\n * const server = Sentry.wrapMcpServerWithSentry(\n * new McpServer({ name: \"my-server\", version: \"1.0.0\" })\n * );\n *\n * // Explicitly control input/output capture\n * const server = Sentry.wrapMcpServerWithSentry(\n * new McpServer({ name: \"my-server\", version: \"1.0.0\" }),\n * { recordInputs: true, recordOutputs: false }\n * );\n *\n * const transport = new StreamableHTTPServerTransport();\n * await server.connect(transport);\n * ```\n *\n * @param mcpServerInstance - MCP server instance to instrument\n * @param options - Optional configuration for recording inputs and outputs\n * @returns Instrumented server instance (same reference)\n */\nexport function wrapMcpServerWithSentry<S extends object>(mcpServerInstance: S, options?: McpServerWrapperOptions): S {\n if (wrappedMcpServerInstances.has(mcpServerInstance)) {\n return mcpServerInstance;\n }\n\n if (!validateMcpServerInstance(mcpServerInstance)) {\n return mcpServerInstance;\n }\n\n const serverInstance = mcpServerInstance as MCPServerInstance;\n const client = getClient();\n const sendDefaultPii = Boolean(client?.getOptions().sendDefaultPii);\n\n const resolvedOptions: ResolvedMcpOptions = {\n recordInputs: options?.recordInputs ?? sendDefaultPii,\n recordOutputs: options?.recordOutputs ?? sendDefaultPii,\n };\n\n fill(serverInstance, 'connect', originalConnect => {\n return async function (this: MCPServerInstance, transport: MCPTransport, ...restArgs: unknown[]) {\n const result = await (originalConnect as (...args: unknown[]) => Promise<unknown>).call(\n this,\n transport,\n ...restArgs,\n );\n\n wrapTransportOnMessage(transport, resolvedOptions);\n wrapTransportSend(transport, resolvedOptions);\n wrapTransportOnClose(transport);\n wrapTransportError(transport);\n\n return result;\n };\n });\n\n wrapAllMCPHandlers(serverInstance);\n\n wrappedMcpServerInstances.add(mcpServerInstance);\n return mcpServerInstance;\n}\n"],"names":["validateMcpServerInstance","getClient","fill","transport","wrapTransportOnMessage","wrapTransportSend","wrapTransportOnClose","wrapTransportError","wrapAllMCPHandlers"],"mappings":";;;;;;;;AAOA;AACA;AACA;AACA;AACA,MAAM,yBAAA,GAA4B,IAAI,OAAO,EAAE;;AAE/C;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;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAmB,iBAAiB,EAAK,OAAO,EAA+B;AACtH,EAAE,IAAI,yBAAyB,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE;AACxD,IAAI,OAAO,iBAAiB;AAC5B,EAAE;;AAEF,EAAE,IAAI,CAACA,oCAAyB,CAAC,iBAAiB,CAAC,EAAE;AACrD,IAAI,OAAO,iBAAiB;AAC5B,EAAE;;AAEF,EAAE,MAAM,cAAA,GAAiB,iBAAA;AACzB,EAAE,MAAM,MAAA,GAASC,uBAAS,EAAE;AAC5B,EAAE,MAAM,cAAA,GAAiB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,cAAc,CAAC;;AAErE,EAAE,MAAM,eAAe,GAAuB;AAC9C,IAAI,YAAY,EAAE,OAAO,EAAE,YAAA,IAAgB,cAAc;AACzD,IAAI,aAAa,EAAE,OAAO,EAAE,aAAA,IAAiB,cAAc;AAC3D,GAAG;;AAEH,EAAEC,WAAI,CAAC,cAAc,EAAE,SAAS,EAAE,mBAAmB;AACrD,IAAI,OAAO,iBAAyCC,WAAS,EAAgB,GAAG,QAAQ,EAAa;AACrG,MAAM,MAAM,SAAS,MAAM,CAAC,eAAA,GAA6D,IAAI;AAC7F,QAAQ,IAAI;AACZ,QAAQA,WAAS;AACjB,QAAQ,GAAG,QAAQ;AACnB,OAAO;;AAEP,MAAMC,gCAAsB,CAACD,WAAS,EAAE,eAAe,CAAC;AACxD,MAAME,2BAAiB,CAACF,WAAS,EAAE,eAAe,CAAC;AACnD,MAAMG,8BAAoB,CAACH,WAAS,CAAC;AACrC,MAAMI,4BAAkB,CAACJ,WAAS,CAAC;;AAEnC,MAAM,OAAO,MAAM;AACnB,IAAI,CAAC;AACL,EAAE,CAAC,CAAC;;AAEJ,EAAEK,2BAAkB,CAAC,cAAc,CAAC;;AAEpC,EAAE,yBAAyB,CAAC,GAAG,CAAC,iBAAiB,CAAC;AAClD,EAAE,OAAO,iBAAiB;AAC1B;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../src/integrations/mcp-server/index.ts"],"sourcesContent":["import { getClient } from '../../currentScopes';\nimport { fill } from '../../utils/object';\nimport { wrapAllMCPHandlers, wrapExistingHandlers } from './handlers';\nimport { wrapTransportError, wrapTransportOnClose, wrapTransportOnMessage, wrapTransportSend } from './transport';\nimport type { MCPServerInstance, McpServerWrapperOptions, MCPTransport, ResolvedMcpOptions } from './types';\nimport { validateMcpServerInstance } from './validation';\n\n/**\n * Tracks wrapped MCP server instances to prevent double-wrapping\n * @internal\n */\nconst wrappedMcpServerInstances = new WeakSet();\n\n/**\n * Wraps a MCP Server instance from the `@modelcontextprotocol/sdk` package with Sentry instrumentation.\n *\n * Compatible with versions `^1.9.0` of the `@modelcontextprotocol/sdk` package (legacy `tool`/`resource`/`prompt` API)\n * and versions that expose the newer `registerTool`/`registerResource`/`registerPrompt` API (introduced in 1.x, sole API in 2.x).\n * Automatically instruments transport methods and handler functions for comprehensive monitoring.\n *\n * Both call orderings are supported: wrapping before or after registering tools, resources,\n * and prompts. Sentry patches the registration methods for future handlers and retroactively\n * wraps any already-registered ones. Wrapping at construction time is recommended by\n * convention (consistent with other SDK integrations), but is not required.\n *\n * @example\n * ```typescript\n * import * as Sentry from '@sentry/core';\n * import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n * import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\n *\n * // Wrap first, then register tools — this is the correct order\n * const server = Sentry.wrapMcpServerWithSentry(\n * new McpServer({ name: \"my-server\", version: \"1.0.0\" })\n * );\n *\n * server.registerTool('my-tool', schema, handler);\n *\n * // Explicitly control input/output capture\n * const server = Sentry.wrapMcpServerWithSentry(\n * new McpServer({ name: \"my-server\", version: \"1.0.0\" }),\n * { recordInputs: true, recordOutputs: false }\n * );\n *\n * const transport = new StreamableHTTPServerTransport();\n * await server.connect(transport);\n * ```\n *\n * @param mcpServerInstance - MCP server instance to instrument\n * @param options - Optional configuration for recording inputs and outputs\n * @returns Instrumented server instance (same reference)\n */\nexport function wrapMcpServerWithSentry<S extends object>(mcpServerInstance: S, options?: McpServerWrapperOptions): S {\n if (wrappedMcpServerInstances.has(mcpServerInstance)) {\n return mcpServerInstance;\n }\n\n if (!validateMcpServerInstance(mcpServerInstance)) {\n return mcpServerInstance;\n }\n\n const serverInstance = mcpServerInstance as MCPServerInstance;\n const client = getClient();\n const sendDefaultPii = Boolean(client?.getOptions().sendDefaultPii);\n\n const resolvedOptions: ResolvedMcpOptions = {\n recordInputs: options?.recordInputs ?? sendDefaultPii,\n recordOutputs: options?.recordOutputs ?? sendDefaultPii,\n };\n\n fill(serverInstance, 'connect', originalConnect => {\n return async function (this: MCPServerInstance, transport: MCPTransport, ...restArgs: unknown[]) {\n const result = await (originalConnect as (...args: unknown[]) => Promise<unknown>).call(\n this,\n transport,\n ...restArgs,\n );\n\n wrapTransportOnMessage(transport, resolvedOptions);\n wrapTransportSend(transport, resolvedOptions);\n wrapTransportOnClose(transport);\n wrapTransportError(transport);\n\n return result;\n };\n });\n\n wrapAllMCPHandlers(serverInstance);\n\n wrapExistingHandlers(serverInstance);\n\n wrappedMcpServerInstances.add(mcpServerInstance);\n return mcpServerInstance;\n}\n"],"names":["validateMcpServerInstance","getClient","fill","transport","wrapTransportOnMessage","wrapTransportSend","wrapTransportOnClose","wrapTransportError","wrapAllMCPHandlers","wrapExistingHandlers"],"mappings":";;;;;;;;AAOA;AACA;AACA;AACA;AACA,MAAM,yBAAA,GAA4B,IAAI,OAAO,EAAE;;AAE/C;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAmB,iBAAiB,EAAK,OAAO,EAA+B;AACtH,EAAE,IAAI,yBAAyB,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE;AACxD,IAAI,OAAO,iBAAiB;AAC5B,EAAE;;AAEF,EAAE,IAAI,CAACA,oCAAyB,CAAC,iBAAiB,CAAC,EAAE;AACrD,IAAI,OAAO,iBAAiB;AAC5B,EAAE;;AAEF,EAAE,MAAM,cAAA,GAAiB,iBAAA;AACzB,EAAE,MAAM,MAAA,GAASC,uBAAS,EAAE;AAC5B,EAAE,MAAM,cAAA,GAAiB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,cAAc,CAAC;;AAErE,EAAE,MAAM,eAAe,GAAuB;AAC9C,IAAI,YAAY,EAAE,OAAO,EAAE,YAAA,IAAgB,cAAc;AACzD,IAAI,aAAa,EAAE,OAAO,EAAE,aAAA,IAAiB,cAAc;AAC3D,GAAG;;AAEH,EAAEC,WAAI,CAAC,cAAc,EAAE,SAAS,EAAE,mBAAmB;AACrD,IAAI,OAAO,iBAAyCC,WAAS,EAAgB,GAAG,QAAQ,EAAa;AACrG,MAAM,MAAM,SAAS,MAAM,CAAC,eAAA,GAA6D,IAAI;AAC7F,QAAQ,IAAI;AACZ,QAAQA,WAAS;AACjB,QAAQ,GAAG,QAAQ;AACnB,OAAO;;AAEP,MAAMC,gCAAsB,CAACD,WAAS,EAAE,eAAe,CAAC;AACxD,MAAME,2BAAiB,CAACF,WAAS,EAAE,eAAe,CAAC;AACnD,MAAMG,8BAAoB,CAACH,WAAS,CAAC;AACrC,MAAMI,4BAAkB,CAACJ,WAAS,CAAC;;AAEnC,MAAM,OAAO,MAAM;AACnB,IAAI,CAAC;AACL,EAAE,CAAC,CAAC;;AAEJ,EAAEK,2BAAkB,CAAC,cAAc,CAAC;;AAEpC,EAAEC,6BAAoB,CAAC,cAAc,CAAC;;AAEtC,EAAE,yBAAyB,CAAC,GAAG,CAAC,iBAAiB,CAAC;AAClD,EAAE,OAAO,iBAAiB;AAC1B;;;;"} |
@@ -6,3 +6,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const debugBuild = require('../debug-build.js'); | ||
| const _exports = require('../exports.js'); | ||
| const exports$1 = require('../exports.js'); | ||
| const integration = require('../integration.js'); | ||
@@ -196,3 +196,3 @@ const semanticAttributes = require('../semanticAttributes.js'); | ||
| _exports.captureException(res.error, { | ||
| exports$1.captureException(res.error, { | ||
| mechanism: { | ||
@@ -214,3 +214,3 @@ handled: false, | ||
| _exports.captureException(err, { | ||
| exports$1.captureException(err, { | ||
| mechanism: { | ||
@@ -390,3 +390,3 @@ handled: false, | ||
| _exports.captureException(err, scope => { | ||
| exports$1.captureException(err, scope => { | ||
| scope.addEventProcessor(e => { | ||
@@ -393,0 +393,0 @@ misc.addExceptionMechanism(e, { |
@@ -1,1 +0,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,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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A,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;;;;;;;;;"} | ||
| {"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":";;;;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A,OAAA,EAAA;AACA,QAAA,CAAA;AACA,OAAA;AACA,KAAA;;AAEA,IAAA,kBAAA,CAAA,CAAA,qBAAA,CAAA,SAAA,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;;;;;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const _exports = require('../../exports.js'); | ||
| const exports$1 = require('../../exports.js'); | ||
| const currentScopes = require('../../currentScopes.js'); | ||
@@ -220,3 +220,3 @@ const hasSpanStreamingEnabled = require('../spans/hasSpanStreamingEnabled.js'); | ||
| const safeOriginalWithResponse = originalWithResponse.catch(error => { | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { | ||
@@ -223,0 +223,0 @@ handled: false, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"utils.js","sources":["../../../../src/tracing/ai/utils.ts"],"sourcesContent":["/**\n * Shared utils for AI integrations (OpenAI, Anthropic, Verce.AI, etc.)\n */\nimport { captureException } from '../../exports';\nimport { getClient } from '../../currentScopes';\nimport { hasSpanStreamingEnabled } from '../spans/hasSpanStreamingEnabled';\nimport type { Span } from '../../types-hoist/span';\nimport { isThenable } from '../../utils/is';\nimport {\n GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE,\n GEN_AI_RESPONSE_ID_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_STREAMING_ATTRIBUTE,\n GEN_AI_RESPONSE_TEXT_ATTRIBUTE,\n GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,\n} from './gen-ai-attributes';\nimport { truncateGenAiMessages, truncateGenAiStringInput } from './messageTruncation';\n\nexport interface AIRecordingOptions {\n recordInputs?: boolean;\n recordOutputs?: boolean;\n}\n\n/**\n * A method registry entry describes a single instrumented method:\n * which gen_ai operation it maps to and whether it is intrinsically streaming.\n */\nexport interface InstrumentedMethodEntry {\n /** Operation name (e.g. 'chat', 'embeddings', 'generate_content'). Omit for factory methods that only need result proxying. */\n operation?: string;\n /** True if the method itself is always streaming (not param-based) */\n streaming?: boolean;\n /** When set, the method's return value is re-proxied with this as the base path */\n proxyResultPath?: string;\n}\n\n/**\n * Maps method paths to their registry entries.\n * Used by proxy-based AI client instrumentations to determine which methods\n * to instrument, what operation name to use, and whether they stream.\n */\nexport type InstrumentedMethodRegistry = Record<string, InstrumentedMethodEntry>;\n\n/**\n * Resolves AI recording options by falling back to the client's `sendDefaultPii` setting.\n * Precedence: explicit option > sendDefaultPii > false\n */\nexport function resolveAIRecordingOptions<T extends AIRecordingOptions>(options?: T): T & Required<AIRecordingOptions> {\n const sendDefaultPii = Boolean(getClient()?.getOptions().sendDefaultPii);\n return {\n ...options,\n recordInputs: options?.recordInputs ?? sendDefaultPii,\n recordOutputs: options?.recordOutputs ?? sendDefaultPii,\n } as T & Required<AIRecordingOptions>;\n}\n\n/**\n * Resolves whether truncation should be enabled.\n * If the user explicitly set `enableTruncation`, that value is used.\n * Otherwise, truncation is disabled when span streaming is active.\n */\nexport function shouldEnableTruncation(enableTruncation: boolean | undefined): boolean {\n const client = getClient();\n return enableTruncation ?? !(client && hasSpanStreamingEnabled(client));\n}\n\n/**\n * Build method path from current traversal\n */\nexport function buildMethodPath(currentPath: string, prop: string): string {\n return currentPath ? `${currentPath}.${prop}` : prop;\n}\n\n/**\n * Set token usage attributes\n * @param span - The span to add attributes to\n * @param promptTokens - The number of prompt tokens\n * @param completionTokens - The number of completion tokens\n * @param cachedInputTokens - The number of cached input tokens\n * @param cachedOutputTokens - The number of cached output tokens\n */\nexport function setTokenUsageAttributes(\n span: Span,\n promptTokens?: number,\n completionTokens?: number,\n cachedInputTokens?: number,\n cachedOutputTokens?: number,\n): void {\n if (promptTokens !== undefined) {\n span.setAttributes({\n [GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: promptTokens,\n });\n }\n if (completionTokens !== undefined) {\n span.setAttributes({\n [GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: completionTokens,\n });\n }\n if (\n promptTokens !== undefined ||\n completionTokens !== undefined ||\n cachedInputTokens !== undefined ||\n cachedOutputTokens !== undefined\n ) {\n /**\n * Total input tokens in a request is the summation of `input_tokens`,\n * `cache_creation_input_tokens`, and `cache_read_input_tokens`.\n */\n const totalTokens =\n (promptTokens ?? 0) + (completionTokens ?? 0) + (cachedInputTokens ?? 0) + (cachedOutputTokens ?? 0);\n\n span.setAttributes({\n [GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE]: totalTokens,\n });\n }\n}\n\nexport interface StreamResponseState {\n responseId?: string;\n responseModel?: string;\n finishReasons: string[];\n responseTexts: string[];\n toolCalls: unknown[];\n promptTokens?: number;\n completionTokens?: number;\n totalTokens?: number;\n cacheCreationInputTokens?: number;\n cacheReadInputTokens?: number;\n}\n\n/**\n * Ends a streaming span by setting all accumulated response attributes and ending the span.\n * Shared across OpenAI, Anthropic, and Google GenAI streaming implementations.\n */\nexport function endStreamSpan(span: Span, state: StreamResponseState, recordOutputs: boolean): void {\n if (!span.isRecording()) {\n return;\n }\n\n const attrs: Record<string, string | number | boolean> = {\n [GEN_AI_RESPONSE_STREAMING_ATTRIBUTE]: true,\n };\n\n if (state.responseId) attrs[GEN_AI_RESPONSE_ID_ATTRIBUTE] = state.responseId;\n if (state.responseModel) attrs[GEN_AI_RESPONSE_MODEL_ATTRIBUTE] = state.responseModel;\n\n if (state.promptTokens !== undefined) attrs[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] = state.promptTokens;\n if (state.completionTokens !== undefined) attrs[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] = state.completionTokens;\n\n // Use explicit total if provided (OpenAI, Google), otherwise compute from cache tokens (Anthropic)\n if (state.totalTokens !== undefined) {\n attrs[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE] = state.totalTokens;\n } else if (\n state.promptTokens !== undefined ||\n state.completionTokens !== undefined ||\n state.cacheCreationInputTokens !== undefined ||\n state.cacheReadInputTokens !== undefined\n ) {\n attrs[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE] =\n (state.promptTokens ?? 0) +\n (state.completionTokens ?? 0) +\n (state.cacheCreationInputTokens ?? 0) +\n (state.cacheReadInputTokens ?? 0);\n }\n\n if (state.finishReasons.length) {\n attrs[GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE] = JSON.stringify(state.finishReasons);\n }\n if (recordOutputs && state.responseTexts.length) {\n attrs[GEN_AI_RESPONSE_TEXT_ATTRIBUTE] = state.responseTexts.join('');\n }\n if (recordOutputs && state.toolCalls.length) {\n attrs[GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE] = JSON.stringify(state.toolCalls);\n }\n\n span.setAttributes(attrs);\n span.end();\n}\n\n/**\n * Serialize a value to a JSON string without truncation.\n * Strings are returned as-is, arrays and objects are JSON-stringified.\n */\nexport function getJsonString<T>(value: T | T[]): string {\n if (typeof value === 'string') {\n return value;\n }\n return JSON.stringify(value);\n}\n\n/**\n * Get the truncated JSON string for a string or array of strings.\n *\n * @param value - The string or array of strings to truncate\n * @returns The truncated JSON string\n */\nexport function getTruncatedJsonString<T>(value: T | T[]): string {\n if (typeof value === 'string') {\n // Some values are already JSON strings, so we don't need to duplicate the JSON parsing\n return truncateGenAiStringInput(value);\n }\n if (Array.isArray(value)) {\n // truncateGenAiMessages returns an array of strings, so we need to stringify it\n const truncatedMessages = truncateGenAiMessages(value);\n return JSON.stringify(truncatedMessages);\n }\n // value is an object, so we need to stringify it\n return JSON.stringify(value);\n}\n\n/**\n * Extract system instructions from messages array.\n * Finds the first system message and formats it according to OpenTelemetry semantic conventions.\n *\n * @param messages - Array of messages to extract system instructions from\n * @returns systemInstructions (JSON string) and filteredMessages (without system message)\n */\nexport function extractSystemInstructions(messages: unknown[] | unknown): {\n systemInstructions: string | undefined;\n filteredMessages: unknown[] | unknown;\n} {\n if (!Array.isArray(messages)) {\n return { systemInstructions: undefined, filteredMessages: messages };\n }\n\n const systemMessageIndex = messages.findIndex(\n msg => msg && typeof msg === 'object' && 'role' in msg && (msg as { role: string }).role === 'system',\n );\n\n if (systemMessageIndex === -1) {\n return { systemInstructions: undefined, filteredMessages: messages };\n }\n\n const systemMessage = messages[systemMessageIndex] as { role: string; content?: string | unknown };\n const systemContent =\n typeof systemMessage.content === 'string'\n ? systemMessage.content\n : systemMessage.content !== undefined\n ? JSON.stringify(systemMessage.content)\n : undefined;\n\n if (!systemContent) {\n return { systemInstructions: undefined, filteredMessages: messages };\n }\n\n const systemInstructions = JSON.stringify([{ type: 'text', content: systemContent }]);\n const filteredMessages = [...messages.slice(0, systemMessageIndex), ...messages.slice(systemMessageIndex + 1)];\n\n return { systemInstructions, filteredMessages };\n}\n\n/**\n * Creates a wrapped version of .withResponse() that replaces the data field\n * with the instrumented result while preserving metadata (response, request_id).\n */\nasync function createWithResponseWrapper<T>(\n originalWithResponse: Promise<unknown>,\n instrumentedPromise: Promise<T>,\n mechanismType: string,\n): Promise<unknown> {\n // Attach catch handler to originalWithResponse immediately to prevent unhandled rejection\n // If instrumentedPromise rejects first, we still need this handled\n const safeOriginalWithResponse = originalWithResponse.catch(error => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: mechanismType,\n },\n });\n throw error;\n });\n\n const instrumentedResult = await instrumentedPromise;\n const originalWrapper = await safeOriginalWithResponse;\n\n // Combine instrumented result with original metadata\n if (originalWrapper && typeof originalWrapper === 'object' && 'data' in originalWrapper) {\n return {\n ...originalWrapper,\n data: instrumentedResult,\n };\n }\n return instrumentedResult;\n}\n\n/**\n * Wraps a promise-like object to preserve additional methods (like .withResponse())\n * that AI SDK clients (OpenAI, Anthropic) attach to their APIPromise return values.\n *\n * Standard Promise methods (.then, .catch, .finally) are routed to the instrumented\n * promise to preserve Sentry's span instrumentation, while custom SDK methods are\n * forwarded to the original promise to maintain the SDK's API surface.\n */\nexport function wrapPromiseWithMethods<R>(\n originalPromiseLike: Promise<R>,\n instrumentedPromise: Promise<R>,\n mechanismType: string,\n): Promise<R> {\n // If the original result is not thenable, return the instrumented promise\n if (!isThenable(originalPromiseLike)) {\n return instrumentedPromise;\n }\n\n // Create a proxy that forwards Promise methods to instrumentedPromise\n // and preserves additional methods from the original result\n return new Proxy(originalPromiseLike, {\n get(target: object, prop: string | symbol): unknown {\n // For standard Promise methods (.then, .catch, .finally, Symbol.toStringTag),\n // use instrumentedPromise to preserve Sentry instrumentation.\n // For custom methods (like .withResponse()), use the original target.\n const useInstrumentedPromise = prop in Promise.prototype || prop === Symbol.toStringTag;\n const source = useInstrumentedPromise ? instrumentedPromise : target;\n\n const value = Reflect.get(source, prop) as unknown;\n\n // Special handling for .withResponse() to preserve instrumentation\n // .withResponse() returns { data: T, response: Response, request_id: string }\n if (prop === 'withResponse' && typeof value === 'function') {\n return function wrappedWithResponse(this: unknown): unknown {\n const originalWithResponse = (value as (...args: unknown[]) => unknown).call(target);\n return createWithResponseWrapper(originalWithResponse, instrumentedPromise, mechanismType);\n };\n }\n\n return typeof value === 'function' ? value.bind(source) : value;\n },\n }) as Promise<R>;\n}\n"],"names":["getClient","hasSpanStreamingEnabled","GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE","GEN_AI_RESPONSE_STREAMING_ATTRIBUTE","GEN_AI_RESPONSE_ID_ATTRIBUTE","GEN_AI_RESPONSE_MODEL_ATTRIBUTE","GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE","GEN_AI_RESPONSE_TEXT_ATTRIBUTE","GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE","truncateGenAiStringInput","truncateGenAiMessages","captureException","isThenable"],"mappings":";;;;;;;;;AAAA;AACA;AACA;;AA4CA;AACA;AACA;AACA;AACO,SAAS,yBAAyB,CAA+B,OAAO,EAAwC;AACvH,EAAE,MAAM,cAAA,GAAiB,OAAO,CAACA,uBAAS,EAAE,EAAE,UAAU,EAAE,CAAC,cAAc,CAAC;AAC1E,EAAE,OAAO;AACT,IAAI,GAAG,OAAO;AACd,IAAI,YAAY,EAAE,OAAO,EAAE,YAAA,IAAgB,cAAc;AACzD,IAAI,aAAa,EAAE,OAAO,EAAE,aAAA,IAAiB,cAAc;AAC3D,GAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,sBAAsB,CAAC,gBAAgB,EAAgC;AACvF,EAAE,MAAM,MAAA,GAASA,uBAAS,EAAE;AAC5B,EAAE,OAAO,gBAAA,IAAoB,EAAE,MAAA,IAAUC,+CAAuB,CAAC,MAAM,CAAC,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AA,EAAA,aAAA,CAAA;AACA,QAAA,CAAA;AACA,MAAA;;AAEA,MAAA,OAAA,OAAA,KAAA,KAAA,UAAA,GAAA,KAAA,CAAA,IAAA,CAAA,MAAA,CAAA,GAAA,KAAA;AACA,IAAA,CAAA;AACA,GAAA,CAAA;AACA;;;;;;;;;;;;"} | ||
| {"version":3,"file":"utils.js","sources":["../../../../src/tracing/ai/utils.ts"],"sourcesContent":["/**\n * Shared utils for AI integrations (OpenAI, Anthropic, Verce.AI, etc.)\n */\nimport { captureException } from '../../exports';\nimport { getClient } from '../../currentScopes';\nimport { hasSpanStreamingEnabled } from '../spans/hasSpanStreamingEnabled';\nimport type { Span } from '../../types-hoist/span';\nimport { isThenable } from '../../utils/is';\nimport {\n GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE,\n GEN_AI_RESPONSE_ID_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_STREAMING_ATTRIBUTE,\n GEN_AI_RESPONSE_TEXT_ATTRIBUTE,\n GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,\n} from './gen-ai-attributes';\nimport { truncateGenAiMessages, truncateGenAiStringInput } from './messageTruncation';\n\nexport interface AIRecordingOptions {\n recordInputs?: boolean;\n recordOutputs?: boolean;\n}\n\n/**\n * A method registry entry describes a single instrumented method:\n * which gen_ai operation it maps to and whether it is intrinsically streaming.\n */\nexport interface InstrumentedMethodEntry {\n /** Operation name (e.g. 'chat', 'embeddings', 'generate_content'). Omit for factory methods that only need result proxying. */\n operation?: string;\n /** True if the method itself is always streaming (not param-based) */\n streaming?: boolean;\n /** When set, the method's return value is re-proxied with this as the base path */\n proxyResultPath?: string;\n}\n\n/**\n * Maps method paths to their registry entries.\n * Used by proxy-based AI client instrumentations to determine which methods\n * to instrument, what operation name to use, and whether they stream.\n */\nexport type InstrumentedMethodRegistry = Record<string, InstrumentedMethodEntry>;\n\n/**\n * Resolves AI recording options by falling back to the client's `sendDefaultPii` setting.\n * Precedence: explicit option > sendDefaultPii > false\n */\nexport function resolveAIRecordingOptions<T extends AIRecordingOptions>(options?: T): T & Required<AIRecordingOptions> {\n const sendDefaultPii = Boolean(getClient()?.getOptions().sendDefaultPii);\n return {\n ...options,\n recordInputs: options?.recordInputs ?? sendDefaultPii,\n recordOutputs: options?.recordOutputs ?? sendDefaultPii,\n } as T & Required<AIRecordingOptions>;\n}\n\n/**\n * Resolves whether truncation should be enabled.\n * If the user explicitly set `enableTruncation`, that value is used.\n * Otherwise, truncation is disabled when span streaming is active.\n */\nexport function shouldEnableTruncation(enableTruncation: boolean | undefined): boolean {\n const client = getClient();\n return enableTruncation ?? !(client && hasSpanStreamingEnabled(client));\n}\n\n/**\n * Build method path from current traversal\n */\nexport function buildMethodPath(currentPath: string, prop: string): string {\n return currentPath ? `${currentPath}.${prop}` : prop;\n}\n\n/**\n * Set token usage attributes\n * @param span - The span to add attributes to\n * @param promptTokens - The number of prompt tokens\n * @param completionTokens - The number of completion tokens\n * @param cachedInputTokens - The number of cached input tokens\n * @param cachedOutputTokens - The number of cached output tokens\n */\nexport function setTokenUsageAttributes(\n span: Span,\n promptTokens?: number,\n completionTokens?: number,\n cachedInputTokens?: number,\n cachedOutputTokens?: number,\n): void {\n if (promptTokens !== undefined) {\n span.setAttributes({\n [GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: promptTokens,\n });\n }\n if (completionTokens !== undefined) {\n span.setAttributes({\n [GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: completionTokens,\n });\n }\n if (\n promptTokens !== undefined ||\n completionTokens !== undefined ||\n cachedInputTokens !== undefined ||\n cachedOutputTokens !== undefined\n ) {\n /**\n * Total input tokens in a request is the summation of `input_tokens`,\n * `cache_creation_input_tokens`, and `cache_read_input_tokens`.\n */\n const totalTokens =\n (promptTokens ?? 0) + (completionTokens ?? 0) + (cachedInputTokens ?? 0) + (cachedOutputTokens ?? 0);\n\n span.setAttributes({\n [GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE]: totalTokens,\n });\n }\n}\n\nexport interface StreamResponseState {\n responseId?: string;\n responseModel?: string;\n finishReasons: string[];\n responseTexts: string[];\n toolCalls: unknown[];\n promptTokens?: number;\n completionTokens?: number;\n totalTokens?: number;\n cacheCreationInputTokens?: number;\n cacheReadInputTokens?: number;\n}\n\n/**\n * Ends a streaming span by setting all accumulated response attributes and ending the span.\n * Shared across OpenAI, Anthropic, and Google GenAI streaming implementations.\n */\nexport function endStreamSpan(span: Span, state: StreamResponseState, recordOutputs: boolean): void {\n if (!span.isRecording()) {\n return;\n }\n\n const attrs: Record<string, string | number | boolean> = {\n [GEN_AI_RESPONSE_STREAMING_ATTRIBUTE]: true,\n };\n\n if (state.responseId) attrs[GEN_AI_RESPONSE_ID_ATTRIBUTE] = state.responseId;\n if (state.responseModel) attrs[GEN_AI_RESPONSE_MODEL_ATTRIBUTE] = state.responseModel;\n\n if (state.promptTokens !== undefined) attrs[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] = state.promptTokens;\n if (state.completionTokens !== undefined) attrs[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] = state.completionTokens;\n\n // Use explicit total if provided (OpenAI, Google), otherwise compute from cache tokens (Anthropic)\n if (state.totalTokens !== undefined) {\n attrs[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE] = state.totalTokens;\n } else if (\n state.promptTokens !== undefined ||\n state.completionTokens !== undefined ||\n state.cacheCreationInputTokens !== undefined ||\n state.cacheReadInputTokens !== undefined\n ) {\n attrs[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE] =\n (state.promptTokens ?? 0) +\n (state.completionTokens ?? 0) +\n (state.cacheCreationInputTokens ?? 0) +\n (state.cacheReadInputTokens ?? 0);\n }\n\n if (state.finishReasons.length) {\n attrs[GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE] = JSON.stringify(state.finishReasons);\n }\n if (recordOutputs && state.responseTexts.length) {\n attrs[GEN_AI_RESPONSE_TEXT_ATTRIBUTE] = state.responseTexts.join('');\n }\n if (recordOutputs && state.toolCalls.length) {\n attrs[GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE] = JSON.stringify(state.toolCalls);\n }\n\n span.setAttributes(attrs);\n span.end();\n}\n\n/**\n * Serialize a value to a JSON string without truncation.\n * Strings are returned as-is, arrays and objects are JSON-stringified.\n */\nexport function getJsonString<T>(value: T | T[]): string {\n if (typeof value === 'string') {\n return value;\n }\n return JSON.stringify(value);\n}\n\n/**\n * Get the truncated JSON string for a string or array of strings.\n *\n * @param value - The string or array of strings to truncate\n * @returns The truncated JSON string\n */\nexport function getTruncatedJsonString<T>(value: T | T[]): string {\n if (typeof value === 'string') {\n // Some values are already JSON strings, so we don't need to duplicate the JSON parsing\n return truncateGenAiStringInput(value);\n }\n if (Array.isArray(value)) {\n // truncateGenAiMessages returns an array of strings, so we need to stringify it\n const truncatedMessages = truncateGenAiMessages(value);\n return JSON.stringify(truncatedMessages);\n }\n // value is an object, so we need to stringify it\n return JSON.stringify(value);\n}\n\n/**\n * Extract system instructions from messages array.\n * Finds the first system message and formats it according to OpenTelemetry semantic conventions.\n *\n * @param messages - Array of messages to extract system instructions from\n * @returns systemInstructions (JSON string) and filteredMessages (without system message)\n */\nexport function extractSystemInstructions(messages: unknown[] | unknown): {\n systemInstructions: string | undefined;\n filteredMessages: unknown[] | unknown;\n} {\n if (!Array.isArray(messages)) {\n return { systemInstructions: undefined, filteredMessages: messages };\n }\n\n const systemMessageIndex = messages.findIndex(\n msg => msg && typeof msg === 'object' && 'role' in msg && (msg as { role: string }).role === 'system',\n );\n\n if (systemMessageIndex === -1) {\n return { systemInstructions: undefined, filteredMessages: messages };\n }\n\n const systemMessage = messages[systemMessageIndex] as { role: string; content?: string | unknown };\n const systemContent =\n typeof systemMessage.content === 'string'\n ? systemMessage.content\n : systemMessage.content !== undefined\n ? JSON.stringify(systemMessage.content)\n : undefined;\n\n if (!systemContent) {\n return { systemInstructions: undefined, filteredMessages: messages };\n }\n\n const systemInstructions = JSON.stringify([{ type: 'text', content: systemContent }]);\n const filteredMessages = [...messages.slice(0, systemMessageIndex), ...messages.slice(systemMessageIndex + 1)];\n\n return { systemInstructions, filteredMessages };\n}\n\n/**\n * Creates a wrapped version of .withResponse() that replaces the data field\n * with the instrumented result while preserving metadata (response, request_id).\n */\nasync function createWithResponseWrapper<T>(\n originalWithResponse: Promise<unknown>,\n instrumentedPromise: Promise<T>,\n mechanismType: string,\n): Promise<unknown> {\n // Attach catch handler to originalWithResponse immediately to prevent unhandled rejection\n // If instrumentedPromise rejects first, we still need this handled\n const safeOriginalWithResponse = originalWithResponse.catch(error => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: mechanismType,\n },\n });\n throw error;\n });\n\n const instrumentedResult = await instrumentedPromise;\n const originalWrapper = await safeOriginalWithResponse;\n\n // Combine instrumented result with original metadata\n if (originalWrapper && typeof originalWrapper === 'object' && 'data' in originalWrapper) {\n return {\n ...originalWrapper,\n data: instrumentedResult,\n };\n }\n return instrumentedResult;\n}\n\n/**\n * Wraps a promise-like object to preserve additional methods (like .withResponse())\n * that AI SDK clients (OpenAI, Anthropic) attach to their APIPromise return values.\n *\n * Standard Promise methods (.then, .catch, .finally) are routed to the instrumented\n * promise to preserve Sentry's span instrumentation, while custom SDK methods are\n * forwarded to the original promise to maintain the SDK's API surface.\n */\nexport function wrapPromiseWithMethods<R>(\n originalPromiseLike: Promise<R>,\n instrumentedPromise: Promise<R>,\n mechanismType: string,\n): Promise<R> {\n // If the original result is not thenable, return the instrumented promise\n if (!isThenable(originalPromiseLike)) {\n return instrumentedPromise;\n }\n\n // Create a proxy that forwards Promise methods to instrumentedPromise\n // and preserves additional methods from the original result\n return new Proxy(originalPromiseLike, {\n get(target: object, prop: string | symbol): unknown {\n // For standard Promise methods (.then, .catch, .finally, Symbol.toStringTag),\n // use instrumentedPromise to preserve Sentry instrumentation.\n // For custom methods (like .withResponse()), use the original target.\n const useInstrumentedPromise = prop in Promise.prototype || prop === Symbol.toStringTag;\n const source = useInstrumentedPromise ? instrumentedPromise : target;\n\n const value = Reflect.get(source, prop) as unknown;\n\n // Special handling for .withResponse() to preserve instrumentation\n // .withResponse() returns { data: T, response: Response, request_id: string }\n if (prop === 'withResponse' && typeof value === 'function') {\n return function wrappedWithResponse(this: unknown): unknown {\n const originalWithResponse = (value as (...args: unknown[]) => unknown).call(target);\n return createWithResponseWrapper(originalWithResponse, instrumentedPromise, mechanismType);\n };\n }\n\n return typeof value === 'function' ? value.bind(source) : value;\n },\n }) as Promise<R>;\n}\n"],"names":["getClient","hasSpanStreamingEnabled","GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE","GEN_AI_RESPONSE_STREAMING_ATTRIBUTE","GEN_AI_RESPONSE_ID_ATTRIBUTE","GEN_AI_RESPONSE_MODEL_ATTRIBUTE","GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE","GEN_AI_RESPONSE_TEXT_ATTRIBUTE","GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE","truncateGenAiStringInput","truncateGenAiMessages","captureException","isThenable"],"mappings":";;;;;;;;;AAAA;AACA;AACA;;AA4CA;AACA;AACA;AACA;AACO,SAAS,yBAAyB,CAA+B,OAAO,EAAwC;AACvH,EAAE,MAAM,cAAA,GAAiB,OAAO,CAACA,uBAAS,EAAE,EAAE,UAAU,EAAE,CAAC,cAAc,CAAC;AAC1E,EAAE,OAAO;AACT,IAAI,GAAG,OAAO;AACd,IAAI,YAAY,EAAE,OAAO,EAAE,YAAA,IAAgB,cAAc;AACzD,IAAI,aAAa,EAAE,OAAO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EA;AACA;AACA,MAAA,IAAA,IAAA,KAAA,cAAA,IAAA,OAAA,KAAA,KAAA,UAAA,EAAA;AACA,QAAA,OAAA,SAAA,mBAAA,GAAA;AACA,UAAA,MAAA,oBAAA,GAAA,CAAA,KAAA,GAAA,IAAA,CAAA,MAAA,CAAA;AACA,UAAA,OAAA,yBAAA,CAAA,oBAAA,EAAA,mBAAA,EAAA,aAAA,CAAA;AACA,QAAA,CAAA;AACA,MAAA;;AAEA,MAAA,OAAA,OAAA,KAAA,KAAA,UAAA,GAAA,KAAA,CAAA,IAAA,CAAA,MAAA,CAAA,GAAA,KAAA;AACA,IAAA,CAAA;AACA,GAAA,CAAA;AACA;;;;;;;;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const _exports = require('../../exports.js'); | ||
| const exports$1 = require('../../exports.js'); | ||
| const semanticAttributes = require('../../semanticAttributes.js'); | ||
@@ -145,3 +145,3 @@ const spanstatus = require('../spanstatus.js'); | ||
| function handleStreamingError(error, span, methodPath) { | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { handled: false, type: 'auto.ai.anthropic', data: { function: methodPath } }, | ||
@@ -280,3 +280,3 @@ }); | ||
| error => { | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { | ||
@@ -283,0 +283,0 @@ handled: false, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/anthropic-ai/index.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpan, startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types-hoist/span';\nimport {\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_PROMPT_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_REQUEST_STREAM_ATTRIBUTE,\n GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_K_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_P_ATTRIBUTE,\n GEN_AI_RESPONSE_ID_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_TEXT_ATTRIBUTE,\n GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { InstrumentedMethodEntry } from '../ai/utils';\nimport {\n buildMethodPath,\n resolveAIRecordingOptions,\n setTokenUsageAttributes,\n shouldEnableTruncation,\n wrapPromiseWithMethods,\n} from '../ai/utils';\nimport { ANTHROPIC_METHOD_REGISTRY } from './constants';\nimport { instrumentAsyncIterableStream, instrumentMessageStream } from './streaming';\nimport type { AnthropicAiOptions, AnthropicAiResponse, AnthropicAiStreamingEvent, ContentBlock } from './types';\nimport { handleResponseError, messagesFromParams, setMessagesAttribute } from './utils';\n\n/**\n * Extract request attributes from method arguments\n */\nfunction extractRequestAttributes(args: unknown[], methodPath: string, operationName: string): Record<string, unknown> {\n const attributes: Record<string, unknown> = {\n [GEN_AI_SYSTEM_ATTRIBUTE]: 'anthropic',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: operationName,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.anthropic',\n };\n\n if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null) {\n const params = args[0] as Record<string, unknown>;\n if (params.tools && Array.isArray(params.tools)) {\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = JSON.stringify(params.tools);\n }\n\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = params.model ?? 'unknown';\n if ('temperature' in params) attributes[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE] = params.temperature;\n if ('top_p' in params) attributes[GEN_AI_REQUEST_TOP_P_ATTRIBUTE] = params.top_p;\n if ('stream' in params) attributes[GEN_AI_REQUEST_STREAM_ATTRIBUTE] = params.stream;\n if ('top_k' in params) attributes[GEN_AI_REQUEST_TOP_K_ATTRIBUTE] = params.top_k;\n if ('frequency_penalty' in params)\n attributes[GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE] = params.frequency_penalty;\n if ('max_tokens' in params) attributes[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE] = params.max_tokens;\n } else {\n if (methodPath === 'models.retrieve' || methodPath === 'models.get') {\n // models.retrieve(model-id) and models.get(model-id)\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = args[0];\n } else {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = 'unknown';\n }\n }\n\n return attributes;\n}\n\n/**\n * Add private request attributes to spans.\n * This is only recorded if recordInputs is true.\n */\nfunction addPrivateRequestAttributes(span: Span, params: Record<string, unknown>, enableTruncation: boolean): void {\n const messages = messagesFromParams(params);\n setMessagesAttribute(span, messages, enableTruncation);\n\n if ('prompt' in params) {\n span.setAttributes({ [GEN_AI_PROMPT_ATTRIBUTE]: JSON.stringify(params.prompt) });\n }\n}\n\n/**\n * Add content attributes when recordOutputs is enabled\n */\nfunction addContentAttributes(span: Span, response: AnthropicAiResponse): void {\n // Messages.create\n if ('content' in response) {\n if (Array.isArray(response.content)) {\n span.setAttributes({\n [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: response.content\n .map((item: ContentBlock) => item.text)\n .filter(text => !!text)\n .join(''),\n });\n\n const toolCalls: Array<ContentBlock> = [];\n\n for (const item of response.content) {\n if (item.type === 'tool_use' || item.type === 'server_tool_use') {\n toolCalls.push(item);\n }\n }\n if (toolCalls.length > 0) {\n span.setAttributes({ [GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE]: JSON.stringify(toolCalls) });\n }\n }\n }\n // Completions.create\n if ('completion' in response) {\n span.setAttributes({ [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: response.completion });\n }\n // Models.countTokens\n if ('input_tokens' in response) {\n span.setAttributes({ [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: JSON.stringify(response.input_tokens) });\n }\n}\n\n/**\n * Add basic metadata attributes from the response\n */\nfunction addMetadataAttributes(span: Span, response: AnthropicAiResponse): void {\n if ('id' in response && 'model' in response) {\n span.setAttributes({\n [GEN_AI_RESPONSE_ID_ATTRIBUTE]: response.id,\n [GEN_AI_RESPONSE_MODEL_ATTRIBUTE]: response.model,\n });\n\n if ('usage' in response && response.usage) {\n setTokenUsageAttributes(\n span,\n response.usage.input_tokens,\n response.usage.output_tokens,\n response.usage.cache_creation_input_tokens,\n response.usage.cache_read_input_tokens,\n );\n }\n }\n}\n\n/**\n * Add response attributes to spans\n */\nfunction addResponseAttributes(span: Span, response: AnthropicAiResponse, recordOutputs?: boolean): void {\n if (!response || typeof response !== 'object') return;\n\n // capture error, do not add attributes if error (they shouldn't exist)\n if ('type' in response && response.type === 'error') {\n handleResponseError(span, response);\n return;\n }\n\n // Private response attributes that are only recorded if recordOutputs is true.\n if (recordOutputs) {\n addContentAttributes(span, response);\n }\n\n // Add basic metadata attributes\n addMetadataAttributes(span, response);\n}\n\n/**\n * Handle common error catching and reporting for streaming requests\n */\nfunction handleStreamingError(error: unknown, span: Span, methodPath: string): never {\n captureException(error, {\n mechanism: { handled: false, type: 'auto.ai.anthropic', data: { function: methodPath } },\n });\n\n if (span.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n span.end();\n }\n throw error;\n}\n\n/**\n * Handle streaming cases with common logic\n */\nfunction handleStreamingRequest<T extends unknown[], R>(\n originalMethod: (...args: T) => R | Promise<R>,\n target: (...args: T) => R | Promise<R>,\n context: unknown,\n args: T,\n requestAttributes: Record<string, unknown>,\n operationName: string,\n methodPath: string,\n params: Record<string, unknown> | undefined,\n options: AnthropicAiOptions,\n isStreamRequested: boolean,\n isStreamingMethod: boolean,\n): R | Promise<R> {\n const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? 'unknown';\n const spanConfig = {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n };\n\n // messages.stream() always returns a sync MessageStream, even with stream: true param\n if (isStreamRequested && !isStreamingMethod) {\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpanManual(spanConfig, (span: Span) => {\n originalResult = originalMethod.apply(context, args) as Promise<R>;\n\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n\n return (async () => {\n try {\n const result = await originalResult;\n return instrumentAsyncIterableStream(\n result as AsyncIterable<AnthropicAiStreamingEvent>,\n span,\n options.recordOutputs ?? false,\n ) as unknown as R;\n } catch (error) {\n return handleStreamingError(error, span, methodPath);\n }\n })();\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.anthropic');\n } else {\n return startSpanManual(spanConfig, span => {\n try {\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n const messageStream = target.apply(context, args);\n return instrumentMessageStream(messageStream, span, options.recordOutputs ?? false);\n } catch (error) {\n return handleStreamingError(error, span, methodPath);\n }\n });\n }\n}\n\n/**\n * Instrument a method with Sentry spans\n * Following Sentry AI Agents Manual Instrumentation conventions\n * @see https://docs.sentry.io/platforms/javascript/guides/node/tracing/instrumentation/ai-agents-module/#manual-instrumentation\n */\nfunction instrumentMethod<T extends unknown[], R>(\n originalMethod: (...args: T) => R | Promise<R>,\n methodPath: string,\n instrumentedMethod: InstrumentedMethodEntry,\n context: unknown,\n options: AnthropicAiOptions,\n): (...args: T) => R | Promise<R> {\n return new Proxy(originalMethod, {\n apply(target, thisArg, args: T): R | Promise<R> {\n const operationName = instrumentedMethod.operation || 'unknown';\n const requestAttributes = extractRequestAttributes(args, methodPath, operationName);\n const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? 'unknown';\n\n const params = typeof args[0] === 'object' ? (args[0] as Record<string, unknown>) : undefined;\n const isStreamRequested = Boolean(params?.stream);\n const isStreamingMethod = instrumentedMethod.streaming === true;\n\n if (isStreamRequested || isStreamingMethod) {\n return handleStreamingRequest(\n originalMethod,\n target,\n context,\n args,\n requestAttributes,\n operationName,\n methodPath,\n params,\n options,\n isStreamRequested,\n isStreamingMethod,\n );\n }\n\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpan(\n {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n },\n span => {\n originalResult = target.apply(context, args) as Promise<R>;\n\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n\n return originalResult.then(\n result => {\n addResponseAttributes(span, result as AnthropicAiResponse, options.recordOutputs);\n return result;\n },\n error => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic',\n data: {\n function: methodPath,\n },\n },\n });\n throw error;\n },\n );\n },\n );\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.anthropic');\n },\n }) as (...args: T) => R | Promise<R>;\n}\n\n/**\n * Create a deep proxy for Anthropic AI client instrumentation\n */\nfunction createDeepProxy<T extends object>(target: T, currentPath = '', options: AnthropicAiOptions): T {\n return new Proxy(target, {\n get(obj: object, prop: string): unknown {\n const value = (obj as Record<string, unknown>)[prop];\n const methodPath = buildMethodPath(currentPath, String(prop));\n\n const instrumentedMethod = ANTHROPIC_METHOD_REGISTRY[methodPath as keyof typeof ANTHROPIC_METHOD_REGISTRY];\n if (typeof value === 'function' && instrumentedMethod) {\n return instrumentMethod(\n value as (...args: unknown[]) => unknown | Promise<unknown>,\n methodPath,\n instrumentedMethod,\n obj,\n options,\n );\n }\n\n if (typeof value === 'function') {\n // Bind non-instrumented functions to preserve the original `this` context,\n return value.bind(obj);\n }\n\n if (value && typeof value === 'object') {\n return createDeepProxy(value, methodPath, options);\n }\n\n return value;\n },\n }) as T;\n}\n\n/**\n * Instrument an Anthropic AI client with Sentry tracing\n * Can be used across Node.js, Cloudflare Workers, and Vercel Edge\n *\n * @template T - The type of the client that extends object\n * @param client - The Anthropic AI client to instrument\n * @param options - Optional configuration for recording inputs and outputs\n * @returns The instrumented client with the same type as the input\n */\nexport function instrumentAnthropicAiClient<T extends object>(anthropicAiClient: T, options?: AnthropicAiOptions): T {\n return createDeepProxy(anthropicAiClient, '', resolveAIRecordingOptions(options));\n}\n"],"names":["GEN_AI_SYSTEM_ATTRIBUTE","GEN_AI_OPERATION_NAME_ATTRIBUTE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE","GEN_AI_REQUEST_TOP_P_ATTRIBUTE","GEN_AI_REQUEST_STREAM_ATTRIBUTE","GEN_AI_REQUEST_TOP_K_ATTRIBUTE","GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE","GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE","messagesFromParams","setMessagesAttribute","GEN_AI_PROMPT_ATTRIBUTE","GEN_AI_RESPONSE_TEXT_ATTRIBUTE","GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE","GEN_AI_RESPONSE_ID_ATTRIBUTE","GEN_AI_RESPONSE_MODEL_ATTRIBUTE","setTokenUsageAttributes","handleResponseError","captureException","SPAN_STATUS_ERROR","startSpanManual","shouldEnableTruncation","instrumentAsyncIterableStream","wrapPromiseWithMethods","instrumentMessageStream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,EAAA,OAAA,EAAA;AACA,EAAA,OAAA,eAAA,CAAA,iBAAA,EAAA,EAAA,EAAAC,+BAAA,CAAA,OAAA,CAAA,CAAA;AACA;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/anthropic-ai/index.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpan, startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types-hoist/span';\nimport {\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_PROMPT_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_REQUEST_STREAM_ATTRIBUTE,\n GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_K_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_P_ATTRIBUTE,\n GEN_AI_RESPONSE_ID_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_TEXT_ATTRIBUTE,\n GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { InstrumentedMethodEntry } from '../ai/utils';\nimport {\n buildMethodPath,\n resolveAIRecordingOptions,\n setTokenUsageAttributes,\n shouldEnableTruncation,\n wrapPromiseWithMethods,\n} from '../ai/utils';\nimport { ANTHROPIC_METHOD_REGISTRY } from './constants';\nimport { instrumentAsyncIterableStream, instrumentMessageStream } from './streaming';\nimport type { AnthropicAiOptions, AnthropicAiResponse, AnthropicAiStreamingEvent, ContentBlock } from './types';\nimport { handleResponseError, messagesFromParams, setMessagesAttribute } from './utils';\n\n/**\n * Extract request attributes from method arguments\n */\nfunction extractRequestAttributes(args: unknown[], methodPath: string, operationName: string): Record<string, unknown> {\n const attributes: Record<string, unknown> = {\n [GEN_AI_SYSTEM_ATTRIBUTE]: 'anthropic',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: operationName,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.anthropic',\n };\n\n if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null) {\n const params = args[0] as Record<string, unknown>;\n if (params.tools && Array.isArray(params.tools)) {\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = JSON.stringify(params.tools);\n }\n\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = params.model ?? 'unknown';\n if ('temperature' in params) attributes[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE] = params.temperature;\n if ('top_p' in params) attributes[GEN_AI_REQUEST_TOP_P_ATTRIBUTE] = params.top_p;\n if ('stream' in params) attributes[GEN_AI_REQUEST_STREAM_ATTRIBUTE] = params.stream;\n if ('top_k' in params) attributes[GEN_AI_REQUEST_TOP_K_ATTRIBUTE] = params.top_k;\n if ('frequency_penalty' in params)\n attributes[GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE] = params.frequency_penalty;\n if ('max_tokens' in params) attributes[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE] = params.max_tokens;\n } else {\n if (methodPath === 'models.retrieve' || methodPath === 'models.get') {\n // models.retrieve(model-id) and models.get(model-id)\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = args[0];\n } else {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = 'unknown';\n }\n }\n\n return attributes;\n}\n\n/**\n * Add private request attributes to spans.\n * This is only recorded if recordInputs is true.\n */\nfunction addPrivateRequestAttributes(span: Span, params: Record<string, unknown>, enableTruncation: boolean): void {\n const messages = messagesFromParams(params);\n setMessagesAttribute(span, messages, enableTruncation);\n\n if ('prompt' in params) {\n span.setAttributes({ [GEN_AI_PROMPT_ATTRIBUTE]: JSON.stringify(params.prompt) });\n }\n}\n\n/**\n * Add content attributes when recordOutputs is enabled\n */\nfunction addContentAttributes(span: Span, response: AnthropicAiResponse): void {\n // Messages.create\n if ('content' in response) {\n if (Array.isArray(response.content)) {\n span.setAttributes({\n [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: response.content\n .map((item: ContentBlock) => item.text)\n .filter(text => !!text)\n .join(''),\n });\n\n const toolCalls: Array<ContentBlock> = [];\n\n for (const item of response.content) {\n if (item.type === 'tool_use' || item.type === 'server_tool_use') {\n toolCalls.push(item);\n }\n }\n if (toolCalls.length > 0) {\n span.setAttributes({ [GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE]: JSON.stringify(toolCalls) });\n }\n }\n }\n // Completions.create\n if ('completion' in response) {\n span.setAttributes({ [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: response.completion });\n }\n // Models.countTokens\n if ('input_tokens' in response) {\n span.setAttributes({ [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: JSON.stringify(response.input_tokens) });\n }\n}\n\n/**\n * Add basic metadata attributes from the response\n */\nfunction addMetadataAttributes(span: Span, response: AnthropicAiResponse): void {\n if ('id' in response && 'model' in response) {\n span.setAttributes({\n [GEN_AI_RESPONSE_ID_ATTRIBUTE]: response.id,\n [GEN_AI_RESPONSE_MODEL_ATTRIBUTE]: response.model,\n });\n\n if ('usage' in response && response.usage) {\n setTokenUsageAttributes(\n span,\n response.usage.input_tokens,\n response.usage.output_tokens,\n response.usage.cache_creation_input_tokens,\n response.usage.cache_read_input_tokens,\n );\n }\n }\n}\n\n/**\n * Add response attributes to spans\n */\nfunction addResponseAttributes(span: Span, response: AnthropicAiResponse, recordOutputs?: boolean): void {\n if (!response || typeof response !== 'object') return;\n\n // capture error, do not add attributes if error (they shouldn't exist)\n if ('type' in response && response.type === 'error') {\n handleResponseError(span, response);\n return;\n }\n\n // Private response attributes that are only recorded if recordOutputs is true.\n if (recordOutputs) {\n addContentAttributes(span, response);\n }\n\n // Add basic metadata attributes\n addMetadataAttributes(span, response);\n}\n\n/**\n * Handle common error catching and reporting for streaming requests\n */\nfunction handleStreamingError(error: unknown, span: Span, methodPath: string): never {\n captureException(error, {\n mechanism: { handled: false, type: 'auto.ai.anthropic', data: { function: methodPath } },\n });\n\n if (span.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n span.end();\n }\n throw error;\n}\n\n/**\n * Handle streaming cases with common logic\n */\nfunction handleStreamingRequest<T extends unknown[], R>(\n originalMethod: (...args: T) => R | Promise<R>,\n target: (...args: T) => R | Promise<R>,\n context: unknown,\n args: T,\n requestAttributes: Record<string, unknown>,\n operationName: string,\n methodPath: string,\n params: Record<string, unknown> | undefined,\n options: AnthropicAiOptions,\n isStreamRequested: boolean,\n isStreamingMethod: boolean,\n): R | Promise<R> {\n const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? 'unknown';\n const spanConfig = {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n };\n\n // messages.stream() always returns a sync MessageStream, even with stream: true param\n if (isStreamRequested && !isStreamingMethod) {\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpanManual(spanConfig, (span: Span) => {\n originalResult = originalMethod.apply(context, args) as Promise<R>;\n\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n\n return (async () => {\n try {\n const result = await originalResult;\n return instrumentAsyncIterableStream(\n result as AsyncIterable<AnthropicAiStreamingEvent>,\n span,\n options.recordOutputs ?? false,\n ) as unknown as R;\n } catch (error) {\n return handleStreamingError(error, span, methodPath);\n }\n })();\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.anthropic');\n } else {\n return startSpanManual(spanConfig, span => {\n try {\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n const messageStream = target.apply(context, args);\n return instrumentMessageStream(messageStream, span, options.recordOutputs ?? false);\n } catch (error) {\n return handleStreamingError(error, span, methodPath);\n }\n });\n }\n}\n\n/**\n * Instrument a method with Sentry spans\n * Following Sentry AI Agents Manual Instrumentation conventions\n * @see https://docs.sentry.io/platforms/javascript/guides/node/tracing/instrumentation/ai-agents-module/#manual-instrumentation\n */\nfunction instrumentMethod<T extends unknown[], R>(\n originalMethod: (...args: T) => R | Promise<R>,\n methodPath: string,\n instrumentedMethod: InstrumentedMethodEntry,\n context: unknown,\n options: AnthropicAiOptions,\n): (...args: T) => R | Promise<R> {\n return new Proxy(originalMethod, {\n apply(target, thisArg, args: T): R | Promise<R> {\n const operationName = instrumentedMethod.operation || 'unknown';\n const requestAttributes = extractRequestAttributes(args, methodPath, operationName);\n const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? 'unknown';\n\n const params = typeof args[0] === 'object' ? (args[0] as Record<string, unknown>) : undefined;\n const isStreamRequested = Boolean(params?.stream);\n const isStreamingMethod = instrumentedMethod.streaming === true;\n\n if (isStreamRequested || isStreamingMethod) {\n return handleStreamingRequest(\n originalMethod,\n target,\n context,\n args,\n requestAttributes,\n operationName,\n methodPath,\n params,\n options,\n isStreamRequested,\n isStreamingMethod,\n );\n }\n\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpan(\n {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n },\n span => {\n originalResult = target.apply(context, args) as Promise<R>;\n\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n\n return originalResult.then(\n result => {\n addResponseAttributes(span, result as AnthropicAiResponse, options.recordOutputs);\n return result;\n },\n error => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic',\n data: {\n function: methodPath,\n },\n },\n });\n throw error;\n },\n );\n },\n );\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.anthropic');\n },\n }) as (...args: T) => R | Promise<R>;\n}\n\n/**\n * Create a deep proxy for Anthropic AI client instrumentation\n */\nfunction createDeepProxy<T extends object>(target: T, currentPath = '', options: AnthropicAiOptions): T {\n return new Proxy(target, {\n get(obj: object, prop: string): unknown {\n const value = (obj as Record<string, unknown>)[prop];\n const methodPath = buildMethodPath(currentPath, String(prop));\n\n const instrumentedMethod = ANTHROPIC_METHOD_REGISTRY[methodPath as keyof typeof ANTHROPIC_METHOD_REGISTRY];\n if (typeof value === 'function' && instrumentedMethod) {\n return instrumentMethod(\n value as (...args: unknown[]) => unknown | Promise<unknown>,\n methodPath,\n instrumentedMethod,\n obj,\n options,\n );\n }\n\n if (typeof value === 'function') {\n // Bind non-instrumented functions to preserve the original `this` context,\n return value.bind(obj);\n }\n\n if (value && typeof value === 'object') {\n return createDeepProxy(value, methodPath, options);\n }\n\n return value;\n },\n }) as T;\n}\n\n/**\n * Instrument an Anthropic AI client with Sentry tracing\n * Can be used across Node.js, Cloudflare Workers, and Vercel Edge\n *\n * @template T - The type of the client that extends object\n * @param client - The Anthropic AI client to instrument\n * @param options - Optional configuration for recording inputs and outputs\n * @returns The instrumented client with the same type as the input\n */\nexport function instrumentAnthropicAiClient<T extends object>(anthropicAiClient: T, options?: AnthropicAiOptions): T {\n return createDeepProxy(anthropicAiClient, '', resolveAIRecordingOptions(options));\n}\n"],"names":["GEN_AI_SYSTEM_ATTRIBUTE","GEN_AI_OPERATION_NAME_ATTRIBUTE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE","GEN_AI_REQUEST_TOP_P_ATTRIBUTE","GEN_AI_REQUEST_STREAM_ATTRIBUTE","GEN_AI_REQUEST_TOP_K_ATTRIBUTE","GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE","GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE","messagesFromParams","setMessagesAttribute","GEN_AI_PROMPT_ATTRIBUTE","GEN_AI_RESPONSE_TEXT_ATTRIBUTE","GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE","GEN_AI_RESPONSE_ID_ATTRIBUTE","GEN_AI_RESPONSE_MODEL_ATTRIBUTE","setTokenUsageAttributes","handleResponseError","captureException","SPAN_STATUS_ERROR","startSpanManual","shouldEnableTruncation","instrumentAsyncIterableStream","wrapPromiseWithMethods","instrumentMessageStream","startSpan","buildMethodPath","ANTHROPIC_METHOD_REGISTRY","resolveAIRecordingOptions"],"mappings":";;;;;;;;;;;;AAmCA;AACA;AACA;AACA,SAAS,wBAAwB,CAAC,IAAI,EAAa,UAAU,EAAU,aAAa,EAAmC;AACvH,EAAE,MAAM,UAAU,GAA4B;AAC9C,IAAI,CAACA,uCAAuB,GAAG,WAAW;AAC1C,IAAI,CAACC,+CAA+B,GAAG,aAAa;AACpD,IAAI,CAACC,mDAAgC,GAAG,mBAAmB;AAC3D,GAAG;;AAEH,EAAE,IAAI,IAAI,CAAC,SAAS,CAAA,IAAK,OAAO,IAAI,CAAC,CAAC,CAAA,KAAM,YAAY,IAAI,CAAC,CAAC,CAAA,KAAM,IAAI,EAAE;AAC1E,IAAI,MAAM,MAAA,GAAS,IAAI,CAAC,CAAC,CAAA;AACzB,IAAI,IAAI,MAAM,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;AACrD,MAAM,UAAU,CAACC,wDAAwC,CAAA,GAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;AACzF,IAAI;;AAEJ,IAAI,UAAU,CAACC,8CAA8B,CAAA,GAAI,M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A,UAAA;AACA,UAAA,kBAAA;AACA,UAAA,GAAA;AACA,UAAA,OAAA;AACA,SAAA;AACA,MAAA;;AAEA,MAAA,IAAA,OAAA,KAAA,KAAA,UAAA,EAAA;AACA;AACA,QAAA,OAAA,KAAA,CAAA,IAAA,CAAA,GAAA,CAAA;AACA,MAAA;;AAEA,MAAA,IAAA,KAAA,IAAA,OAAA,KAAA,KAAA,QAAA,EAAA;AACA,QAAA,OAAA,eAAA,CAAA,KAAA,EAAA,UAAA,EAAA,OAAA,CAAA;AACA,MAAA;;AAEA,MAAA,OAAA,KAAA;AACA,IAAA,CAAA;AACA,GAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,2BAAA,CAAA,iBAAA,EAAA,OAAA,EAAA;AACA,EAAA,OAAA,eAAA,CAAA,iBAAA,EAAA,EAAA,EAAAC,+BAAA,CAAA,OAAA,CAAA,CAAA;AACA;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const _exports = require('../../exports.js'); | ||
| const exports$1 = require('../../exports.js'); | ||
| const spanstatus = require('../spanstatus.js'); | ||
@@ -27,3 +27,3 @@ const utils = require('../ai/utils.js'); | ||
| span.setStatus({ code: spanstatus.SPAN_STATUS_ERROR, message: utils$1.mapAnthropicErrorToStatusMessage(event.error?.type) }); | ||
| _exports.captureException(event.error, { | ||
| exports$1.captureException(event.error, { | ||
| mechanism: { | ||
@@ -240,3 +240,3 @@ handled: false, | ||
| stream.on('error', (error) => { | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { | ||
@@ -243,0 +243,0 @@ handled: false, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"streaming.js","sources":["../../../../src/tracing/anthropic-ai/streaming.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport type { Span } from '../../types-hoist/span';\nimport { endStreamSpan } from '../ai/utils';\nimport type { AnthropicAiStreamingEvent } from './types';\nimport { mapAnthropicErrorToStatusMessage } from './utils';\n\n/**\n * State object used to accumulate information from a stream of Anthropic AI events.\n */\ninterface StreamingState {\n /** Collected response text fragments (for output recording). */\n responseTexts: string[];\n /** Reasons for finishing the response, as reported by the API. */\n finishReasons: string[];\n /** The response ID. */\n responseId: string;\n /** The model name. */\n responseModel: string;\n /** Number of prompt/input tokens used. */\n promptTokens: number | undefined;\n /** Number of completion/output tokens used. */\n completionTokens: number | undefined;\n /** Number of cache creation input tokens used. */\n cacheCreationInputTokens: number | undefined;\n /** Number of cache read input tokens used. */\n cacheReadInputTokens: number | undefined;\n /** Accumulated tool calls (finalized) */\n toolCalls: Array<Record<string, unknown>>;\n /** In-progress tool call blocks keyed by index */\n activeToolBlocks: Record<\n number,\n {\n id?: string;\n name?: string;\n inputJsonParts: string[];\n }\n >;\n}\n\n/**\n * Checks if an event is an error event\n * @param event - The event to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n * @param span - The span to update\n * @returns Whether an error occurred\n */\n\nfunction isErrorEvent(event: AnthropicAiStreamingEvent, span: Span): boolean {\n if ('type' in event && typeof event.type === 'string') {\n // If the event is an error, set the span status and capture the error\n // These error events are not rejected by the API by default, but are sent as metadata of the response\n if (event.type === 'error') {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: mapAnthropicErrorToStatusMessage(event.error?.type) });\n captureException(event.error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic.anthropic_error',\n },\n });\n return true;\n }\n }\n return false;\n}\n\n/**\n * Processes the message metadata of an event\n * @param event - The event to process\n * @param state - The state of the streaming process\n */\n\nfunction handleMessageMetadata(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n // The token counts shown in the usage field of the message_delta event are cumulative.\n // @see https://docs.anthropic.com/en/docs/build-with-claude/streaming#event-types\n if (event.type === 'message_delta' && event.usage) {\n if ('output_tokens' in event.usage && typeof event.usage.output_tokens === 'number') {\n state.completionTokens = event.usage.output_tokens;\n }\n }\n\n if (event.message) {\n const message = event.message;\n\n if (message.id) state.responseId = message.id;\n if (message.model) state.responseModel = message.model;\n if (message.stop_reason) state.finishReasons.push(message.stop_reason);\n\n if (message.usage) {\n if (typeof message.usage.input_tokens === 'number') state.promptTokens = message.usage.input_tokens;\n if (typeof message.usage.cache_creation_input_tokens === 'number')\n state.cacheCreationInputTokens = message.usage.cache_creation_input_tokens;\n if (typeof message.usage.cache_read_input_tokens === 'number')\n state.cacheReadInputTokens = message.usage.cache_read_input_tokens;\n }\n }\n}\n\n/**\n * Handle start of a content block (e.g., tool_use)\n */\nfunction handleContentBlockStart(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n if (event.type !== 'content_block_start' || typeof event.index !== 'number' || !event.content_block) return;\n if (event.content_block.type === 'tool_use' || event.content_block.type === 'server_tool_use') {\n state.activeToolBlocks[event.index] = {\n id: event.content_block.id,\n name: event.content_block.name,\n inputJsonParts: [],\n };\n }\n}\n\n/**\n * Handle deltas of a content block, including input_json_delta for tool_use\n */\nfunction handleContentBlockDelta(\n event: AnthropicAiStreamingEvent,\n state: StreamingState,\n recordOutputs: boolean,\n): void {\n if (event.type !== 'content_block_delta' || !event.delta) return;\n\n // Accumulate tool_use input JSON deltas only when we have an index and an active tool block\n if (\n typeof event.index === 'number' &&\n 'partial_json' in event.delta &&\n typeof event.delta.partial_json === 'string'\n ) {\n const active = state.activeToolBlocks[event.index];\n if (active) {\n active.inputJsonParts.push(event.delta.partial_json);\n }\n }\n\n // Accumulate streamed response text regardless of index\n if (recordOutputs && typeof event.delta.text === 'string') {\n state.responseTexts.push(event.delta.text);\n }\n}\n\n/**\n * Handle stop of a content block; finalize tool_use entries\n */\nfunction handleContentBlockStop(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n if (event.type !== 'content_block_stop' || typeof event.index !== 'number') return;\n\n const active = state.activeToolBlocks[event.index];\n if (!active) return;\n\n const raw = active.inputJsonParts.join('');\n let parsedInput: unknown;\n\n try {\n parsedInput = raw ? JSON.parse(raw) : {};\n } catch {\n parsedInput = { __unparsed: raw };\n }\n\n state.toolCalls.push({\n type: 'tool_use',\n id: active.id,\n name: active.name,\n input: parsedInput,\n });\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete state.activeToolBlocks[event.index];\n}\n\n/**\n * Processes an event\n * @param event - The event to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n * @param span - The span to update\n */\nfunction processEvent(\n event: AnthropicAiStreamingEvent,\n state: StreamingState,\n recordOutputs: boolean,\n span: Span,\n): void {\n if (!(event && typeof event === 'object')) {\n return;\n }\n\n const isError = isErrorEvent(event, span);\n if (isError) return;\n\n handleMessageMetadata(event, state);\n\n // Tool call events are sent via 3 separate events:\n // - content_block_start (start of the tool call)\n // - content_block_delta (delta aka input of the tool call)\n // - content_block_stop (end of the tool call)\n // We need to handle them all to capture the full tool call.\n handleContentBlockStart(event, state);\n handleContentBlockDelta(event, state, recordOutputs);\n handleContentBlockStop(event, state);\n}\n\n/**\n * Instruments an async iterable stream of Anthropic events, updates the span with\n * streaming attributes and (optionally) the aggregated output text, and yields\n * each event from the input stream unchanged.\n */\nexport async function* instrumentAsyncIterableStream(\n stream: AsyncIterable<AnthropicAiStreamingEvent>,\n span: Span,\n recordOutputs: boolean,\n): AsyncGenerator<AnthropicAiStreamingEvent, void, unknown> {\n const state: StreamingState = {\n responseTexts: [],\n finishReasons: [],\n responseId: '',\n responseModel: '',\n promptTokens: undefined,\n completionTokens: undefined,\n cacheCreationInputTokens: undefined,\n cacheReadInputTokens: undefined,\n toolCalls: [],\n activeToolBlocks: {},\n };\n\n try {\n for await (const event of stream) {\n processEvent(event, state, recordOutputs, span);\n yield event;\n }\n } finally {\n endStreamSpan(span, state, recordOutputs);\n }\n}\n\n/**\n * Instruments a MessageStream by registering event handlers and preserving the original stream API.\n */\nexport function instrumentMessageStream<R extends { on: (...args: unknown[]) => void }>(\n stream: R,\n span: Span,\n recordOutputs: boolean,\n): R {\n const state: StreamingState = {\n responseTexts: [],\n finishReasons: [],\n responseId: '',\n responseModel: '',\n promptTokens: undefined,\n completionTokens: undefined,\n cacheCreationInputTokens: undefined,\n cacheReadInputTokens: undefined,\n toolCalls: [],\n activeToolBlocks: {},\n };\n\n stream.on('streamEvent', (event: unknown) => {\n processEvent(event as AnthropicAiStreamingEvent, state, recordOutputs, span);\n });\n\n // The event fired when a message is done being streamed by the API. Corresponds to the message_stop SSE event.\n // @see https://github.com/anthropics/anthropic-sdk-typescript/blob/d3be31f5a4e6ebb4c0a2f65dbb8f381ae73a9166/helpers.md?plain=1#L42-L44\n stream.on('message', () => {\n endStreamSpan(span, state, recordOutputs);\n });\n\n stream.on('error', (error: unknown) => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic.stream_error',\n },\n });\n\n if (span.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n span.end();\n }\n });\n\n return stream;\n}\n"],"names":["SPAN_STATUS_ERROR","mapAnthropicErrorToStatusMessage","captureException","endStreamSpan"],"mappings":";;;;;;;AAOA;AACA;AACA;;AA+BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAS,YAAY,CAAC,KAAK,EAA6B,IAAI,EAAiB;AAC7E,EAAE,IAAI,MAAA,IAAU,KAAA,IAAS,OAAO,KAAK,CAAC,IAAA,KAAS,QAAQ,EAAE;AACzD;AACA;AACA,IAAI,IAAI,KAAK,CAAC,IAAA,KAAS,OAAO,EAAE;AAChC,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAEA,4BAAiB,EAAE,OAAO,EAAEC,wCAAgC,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAA,EAAG,CAAC;AAC/G,MAAMC,yBAAgB,CAAC,KAAK,CAAC,KAAK,EAAE;AACpC,QAAQ,SAAS,EAAE;AACnB,UAAU,OAAO,EAAE,KAAK;AACxB,UAAU,IAAI,EAAE,mCAAmC;AAC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} from '../../exports';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport type { Span } from '../../types-hoist/span';\nimport { endStreamSpan } from '../ai/utils';\nimport type { AnthropicAiStreamingEvent } from './types';\nimport { mapAnthropicErrorToStatusMessage } from './utils';\n\n/**\n * State object used to accumulate information from a stream of Anthropic AI events.\n */\ninterface StreamingState {\n /** Collected response text fragments (for output recording). */\n responseTexts: string[];\n /** Reasons for finishing the response, as reported by the API. */\n finishReasons: string[];\n /** The response ID. */\n responseId: string;\n /** The model name. */\n responseModel: string;\n /** Number of prompt/input tokens used. */\n promptTokens: number | undefined;\n /** Number of completion/output tokens used. */\n completionTokens: number | undefined;\n /** Number of cache creation input tokens used. */\n cacheCreationInputTokens: number | undefined;\n /** Number of cache read input tokens used. */\n cacheReadInputTokens: number | undefined;\n /** Accumulated tool calls (finalized) */\n toolCalls: Array<Record<string, unknown>>;\n /** In-progress tool call blocks keyed by index */\n activeToolBlocks: Record<\n number,\n {\n id?: string;\n name?: string;\n inputJsonParts: string[];\n }\n >;\n}\n\n/**\n * Checks if an event is an error event\n * @param event - The event to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n * @param span - The span to update\n * @returns Whether an error occurred\n */\n\nfunction isErrorEvent(event: AnthropicAiStreamingEvent, span: Span): boolean {\n if ('type' in event && typeof event.type === 'string') {\n // If the event is an error, set the span status and capture the error\n // These error events are not rejected by the API by default, but are sent as metadata of the response\n if (event.type === 'error') {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: mapAnthropicErrorToStatusMessage(event.error?.type) });\n captureException(event.error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic.anthropic_error',\n },\n });\n return true;\n }\n }\n return false;\n}\n\n/**\n * Processes the message metadata of an event\n * @param event - The event to process\n * @param state - The state of the streaming process\n */\n\nfunction handleMessageMetadata(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n // The token counts shown in the usage field of the message_delta event are cumulative.\n // @see https://docs.anthropic.com/en/docs/build-with-claude/streaming#event-types\n if (event.type === 'message_delta' && event.usage) {\n if ('output_tokens' in event.usage && typeof event.usage.output_tokens === 'number') {\n state.completionTokens = event.usage.output_tokens;\n }\n }\n\n if (event.message) {\n const message = event.message;\n\n if (message.id) state.responseId = message.id;\n if (message.model) state.responseModel = message.model;\n if (message.stop_reason) state.finishReasons.push(message.stop_reason);\n\n if (message.usage) {\n if (typeof message.usage.input_tokens === 'number') state.promptTokens = message.usage.input_tokens;\n if (typeof message.usage.cache_creation_input_tokens === 'number')\n state.cacheCreationInputTokens = message.usage.cache_creation_input_tokens;\n if (typeof message.usage.cache_read_input_tokens === 'number')\n state.cacheReadInputTokens = message.usage.cache_read_input_tokens;\n }\n }\n}\n\n/**\n * Handle start of a content block (e.g., tool_use)\n */\nfunction handleContentBlockStart(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n if (event.type !== 'content_block_start' || typeof event.index !== 'number' || !event.content_block) return;\n if (event.content_block.type === 'tool_use' || event.content_block.type === 'server_tool_use') {\n state.activeToolBlocks[event.index] = {\n id: event.content_block.id,\n name: event.content_block.name,\n inputJsonParts: [],\n };\n }\n}\n\n/**\n * Handle deltas of a content block, including input_json_delta for tool_use\n */\nfunction handleContentBlockDelta(\n event: AnthropicAiStreamingEvent,\n state: StreamingState,\n recordOutputs: boolean,\n): void {\n if (event.type !== 'content_block_delta' || !event.delta) return;\n\n // Accumulate tool_use input JSON deltas only when we have an index and an active tool block\n if (\n typeof event.index === 'number' &&\n 'partial_json' in event.delta &&\n typeof event.delta.partial_json === 'string'\n ) {\n const active = state.activeToolBlocks[event.index];\n if (active) {\n active.inputJsonParts.push(event.delta.partial_json);\n }\n }\n\n // Accumulate streamed response text regardless of index\n if (recordOutputs && typeof event.delta.text === 'string') {\n state.responseTexts.push(event.delta.text);\n }\n}\n\n/**\n * Handle stop of a content block; finalize tool_use entries\n */\nfunction handleContentBlockStop(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n if (event.type !== 'content_block_stop' || typeof event.index !== 'number') return;\n\n const active = state.activeToolBlocks[event.index];\n if (!active) return;\n\n const raw = active.inputJsonParts.join('');\n let parsedInput: unknown;\n\n try {\n parsedInput = raw ? JSON.parse(raw) : {};\n } catch {\n parsedInput = { __unparsed: raw };\n }\n\n state.toolCalls.push({\n type: 'tool_use',\n id: active.id,\n name: active.name,\n input: parsedInput,\n });\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete state.activeToolBlocks[event.index];\n}\n\n/**\n * Processes an event\n * @param event - The event to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n * @param span - The span to update\n */\nfunction processEvent(\n event: AnthropicAiStreamingEvent,\n state: StreamingState,\n recordOutputs: boolean,\n span: Span,\n): void {\n if (!(event && typeof event === 'object')) {\n return;\n }\n\n const isError = isErrorEvent(event, span);\n if (isError) return;\n\n handleMessageMetadata(event, state);\n\n // Tool call events are sent via 3 separate events:\n // - content_block_start (start of the tool call)\n // - content_block_delta (delta aka input of the tool call)\n // - content_block_stop (end of the tool call)\n // We need to handle them all to capture the full tool call.\n handleContentBlockStart(event, state);\n handleContentBlockDelta(event, state, recordOutputs);\n handleContentBlockStop(event, state);\n}\n\n/**\n * Instruments an async iterable stream of Anthropic events, updates the span with\n * streaming attributes and (optionally) the aggregated output text, and yields\n * each event from the input stream unchanged.\n */\nexport async function* instrumentAsyncIterableStream(\n stream: AsyncIterable<AnthropicAiStreamingEvent>,\n span: Span,\n recordOutputs: boolean,\n): AsyncGenerator<AnthropicAiStreamingEvent, void, unknown> {\n const state: StreamingState = {\n responseTexts: [],\n finishReasons: [],\n responseId: '',\n responseModel: '',\n promptTokens: undefined,\n completionTokens: undefined,\n cacheCreationInputTokens: undefined,\n cacheReadInputTokens: undefined,\n toolCalls: [],\n activeToolBlocks: {},\n };\n\n try {\n for await (const event of stream) {\n processEvent(event, state, recordOutputs, span);\n yield event;\n }\n } finally {\n endStreamSpan(span, state, recordOutputs);\n }\n}\n\n/**\n * Instruments a MessageStream by registering event handlers and preserving the original stream API.\n */\nexport function instrumentMessageStream<R extends { on: (...args: unknown[]) => void }>(\n stream: R,\n span: Span,\n recordOutputs: boolean,\n): R {\n const state: StreamingState = {\n responseTexts: [],\n finishReasons: [],\n responseId: '',\n responseModel: '',\n promptTokens: undefined,\n completionTokens: undefined,\n cacheCreationInputTokens: undefined,\n cacheReadInputTokens: undefined,\n toolCalls: [],\n activeToolBlocks: {},\n };\n\n stream.on('streamEvent', (event: unknown) => {\n processEvent(event as AnthropicAiStreamingEvent, state, recordOutputs, span);\n });\n\n // The event fired when a message is done being streamed by the API. Corresponds to the message_stop SSE event.\n // @see https://github.com/anthropics/anthropic-sdk-typescript/blob/d3be31f5a4e6ebb4c0a2f65dbb8f381ae73a9166/helpers.md?plain=1#L42-L44\n stream.on('message', () => {\n endStreamSpan(span, state, recordOutputs);\n });\n\n stream.on('error', (error: unknown) => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic.stream_error',\n },\n });\n\n if (span.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n span.end();\n }\n });\n\n return stream;\n}\n"],"names":["SPAN_STATUS_ERROR","mapAnthropicErrorToStatusMessage","captureException","endStreamSpan"],"mappings":";;;;;;;AAOA;AACA;AACA;;AA+BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAS,YAAY,CAAC,KAAK,EAA6B,IAAI,EAAiB;AAC7E,EAAE,IAAI,MAAA,IAAU,KAAA,IAAS,OAAO,KAAK,CAAC,IAAA,KAAS,QAAQ,EAAE;AACzD;AACA;AACA,IAAI,IAAI,KAAK,CAAC,IAAA,KAAS,OAAO,EAAE;AAChC,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAEA,4BAAiB,EAAE,OAAO,EAAEC,wCAAgC,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAA,EAAG,CAAC;AAC/G,MAAMC,0BAAgB,CAAC,KAAK,CAAC,KAAK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,MAAM;AACf;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const _exports = require('../../exports.js'); | ||
| const exports$1 = require('../../exports.js'); | ||
| const spanstatus = require('../spanstatus.js'); | ||
@@ -64,3 +64,3 @@ const genAiAttributes = require('../ai/gen-ai-attributes.js'); | ||
| _exports.captureException(response.error, { | ||
| exports$1.captureException(response.error, { | ||
| mechanism: { | ||
@@ -67,0 +67,0 @@ handled: false, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"utils.js","sources":["../../../../src/tracing/anthropic-ai/utils.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport type { Span } from '../../types-hoist/span';\nimport type { SpanStatusType } from '../../types-hoist/spanStatus';\nimport {\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport { extractSystemInstructions, getJsonString, getTruncatedJsonString } from '../ai/utils';\nimport type { AnthropicAiResponse } from './types';\n\n/**\n * Set the messages and messages original length attributes.\n * Extracts system instructions before truncation.\n */\nexport function setMessagesAttribute(span: Span, messages: unknown, enableTruncation: boolean): void {\n if (Array.isArray(messages) && messages.length === 0) {\n return;\n }\n\n const { systemInstructions, filteredMessages } = extractSystemInstructions(messages);\n\n if (systemInstructions) {\n span.setAttributes({\n [GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE]: systemInstructions,\n });\n }\n\n const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 1;\n span.setAttributes({\n [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: enableTruncation\n ? getTruncatedJsonString(filteredMessages)\n : getJsonString(filteredMessages),\n [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: filteredLength,\n });\n}\n\nconst ANTHROPIC_ERROR_TYPE_TO_SPAN_STATUS: Record<string, SpanStatusType> = {\n invalid_request_error: 'invalid_argument',\n authentication_error: 'unauthenticated',\n permission_error: 'permission_denied',\n not_found_error: 'not_found',\n request_too_large: 'failed_precondition',\n rate_limit_error: 'resource_exhausted',\n api_error: 'internal_error',\n overloaded_error: 'unavailable',\n};\n\n/**\n * Map an Anthropic API error type to a SpanStatusType value.\n * @see https://docs.anthropic.com/en/api/errors#error-shapes\n */\nexport function mapAnthropicErrorToStatusMessage(errorType: string | undefined): SpanStatusType {\n if (!errorType) {\n return 'internal_error';\n }\n return ANTHROPIC_ERROR_TYPE_TO_SPAN_STATUS[errorType] || 'internal_error';\n}\n\n/**\n * Capture error information from the response\n * @see https://docs.anthropic.com/en/api/errors#error-shapes\n */\nexport function handleResponseError(span: Span, response: AnthropicAiResponse): void {\n if (response.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: mapAnthropicErrorToStatusMessage(response.error.type) });\n\n captureException(response.error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic.anthropic_error',\n },\n });\n }\n}\n\n/**\n * Include the system prompt in the messages list, if available\n */\nexport function messagesFromParams(params: Record<string, unknown>): unknown[] {\n const { system, messages, input } = params;\n\n const systemMessages = typeof system === 'string' ? [{ role: 'system', content: params.system }] : [];\n\n const inputParamMessages = Array.isArray(input) ? input : input != null ? [input] : undefined;\n\n const messagesParamMessages = Array.isArray(messages) ? messages : messages != null ? [messages] : [];\n\n const userMessages = inputParamMessages ?? messagesParamMessages;\n\n return [...systemMessages, ...userMessages];\n}\n"],"names":["extractSystemInstructions","GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE","GEN_AI_INPUT_MESSAGES_ATTRIBUTE","getTruncatedJsonString","getJsonString","GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE","SPAN_STATUS_ERROR","captureException"],"mappings":";;;;;;;AAYA;AACA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,IAAI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AACA;AACA;AACO,SAAS,mBAAmB,CAAC,IAAI,EAAQ,QAAQ,EAA6B;AACrF,EAAE,IAAI,QAAQ,CAAC,KAAK,EAAE;AACtB,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAEC,4BAAiB,EAAE,OAAO,EAAE,gCAAgC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAA,EAAG,CAAC;;AAE/G,IAAIC,yBAAgB,CAAC,QAAQ,CAAC,KAAK,EAAE;AACrC,MAAM,SAAS,EAAE;AACjB,QAAQ,OAAO,EAAE,KAAK;AACtB,QAAQ,IAAI,EAAE,mCAAmC;AACjD,OAAO;AACP,KAAK,CAAC;AACN,EAAE;AACF;;AAEA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,MAAM,EAAsC;AAC/E,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAA,EAAM,GAAI,MAAM;;AAE5C,EAAE,MAAM,iBAAiB,OAAO,WAAW,QAAA,GAAW,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAA,GAAI,EAAE;;AAEvG,EAAE,MAAM,qBAAqB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAA,GAAI,QAAQ,KAAA,IAAS,IAAA,GAAO,CAAC,KAAK,CAAA,GAAI,SAAS;;AAE/F,EAAE,MAAM,wBAAwB,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAA,GAAI,WAAW,QAAA,IAAY,IAAA,GAAO,CAAC,QAAQ,CAAA,GAAI,EAAE;;AAEvG,EAAE,MAAM,YAAA,GAAe,kBAAA,IAAsB,qBAAqB;;AAElE,EAAE,OAAO,CAAC,GAAG,cAAc,EAAE,GAAG,YAAY,CAAC;AAC7C;;;;;;;"} | ||
| {"version":3,"file":"utils.js","sources":["../../../../src/tracing/anthropic-ai/utils.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport type { Span } from '../../types-hoist/span';\nimport type { SpanStatusType } from '../../types-hoist/spanStatus';\nimport {\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport { extractSystemInstructions, getJsonString, getTruncatedJsonString } from '../ai/utils';\nimport type { AnthropicAiResponse } from './types';\n\n/**\n * Set the messages and messages original length attributes.\n * Extracts system instructions before truncation.\n */\nexport function setMessagesAttribute(span: Span, messages: unknown, enableTruncation: boolean): void {\n if (Array.isArray(messages) && messages.length === 0) {\n return;\n }\n\n const { systemInstructions, filteredMessages } = extractSystemInstructions(messages);\n\n if (systemInstructions) {\n span.setAttributes({\n [GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE]: systemInstructions,\n });\n }\n\n const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 1;\n span.setAttributes({\n [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: enableTruncation\n ? getTruncatedJsonString(filteredMessages)\n : getJsonString(filteredMessages),\n [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: filteredLength,\n });\n}\n\nconst ANTHROPIC_ERROR_TYPE_TO_SPAN_STATUS: Record<string, SpanStatusType> = {\n invalid_request_error: 'invalid_argument',\n authentication_error: 'unauthenticated',\n permission_error: 'permission_denied',\n not_found_error: 'not_found',\n request_too_large: 'failed_precondition',\n rate_limit_error: 'resource_exhausted',\n api_error: 'internal_error',\n overloaded_error: 'unavailable',\n};\n\n/**\n * Map an Anthropic API error type to a SpanStatusType value.\n * @see https://docs.anthropic.com/en/api/errors#error-shapes\n */\nexport function mapAnthropicErrorToStatusMessage(errorType: string | undefined): SpanStatusType {\n if (!errorType) {\n return 'internal_error';\n }\n return ANTHROPIC_ERROR_TYPE_TO_SPAN_STATUS[errorType] || 'internal_error';\n}\n\n/**\n * Capture error information from the response\n * @see https://docs.anthropic.com/en/api/errors#error-shapes\n */\nexport function handleResponseError(span: Span, response: AnthropicAiResponse): void {\n if (response.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: mapAnthropicErrorToStatusMessage(response.error.type) });\n\n captureException(response.error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic.anthropic_error',\n },\n });\n }\n}\n\n/**\n * Include the system prompt in the messages list, if available\n */\nexport function messagesFromParams(params: Record<string, unknown>): unknown[] {\n const { system, messages, input } = params;\n\n const systemMessages = typeof system === 'string' ? [{ role: 'system', content: params.system }] : [];\n\n const inputParamMessages = Array.isArray(input) ? input : input != null ? [input] : undefined;\n\n const messagesParamMessages = Array.isArray(messages) ? messages : messages != null ? [messages] : [];\n\n const userMessages = inputParamMessages ?? messagesParamMessages;\n\n return [...systemMessages, ...userMessages];\n}\n"],"names":["extractSystemInstructions","GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE","GEN_AI_INPUT_MESSAGES_ATTRIBUTE","getTruncatedJsonString","getJsonString","GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE","SPAN_STATUS_ERROR","captureException"],"mappings":";;;;;;;AAYA;AACA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,IAAI,EAAQ,QAAQ,EAAW,gBAAgB,EAAiB;AACrG,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAA,IAAK,QAAQ,CAAC,MAAA,KAAW,CAAC,EAAE;AACxD,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,EAAE,kBAAkB,EAAE,gBAAA,KAAqBA,+BAAyB,CAAC,QAAQ,CAAC;;AAEtF,EAAE,IAAI,kBAAkB,EAAE;AAC1B,IAAI,IAAI,CAAC,aAAa,CAAC;AACvB,MAAM,CAACC,oDAAoC,GAAG,kBAAkB;AAChE,KAAK,CAAC;AACN,EAAE;;AAEF,EAAE,MAAM,cAAA,GAAiB,KAAK,CAAC,OA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AE;AACF;;AAEA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,MAAM,EAAsC;AAC/E,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAA,EAAM,GAAI,MAAM;;AAE5C,EAAE,MAAM,iBAAiB,OAAO,WAAW,QAAA,GAAW,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAA,GAAI,EAAE;;AAEvG,EAAE,MAAM,qBAAqB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAA,GAAI,QAAQ,KAAA,IAAS,IAAA,GAAO,CAAC,KAAK,CAAA,GAAI,SAAS;;AAE/F,EAAE,MAAM,wBAAwB,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAA,GAAI,WAAW,QAAA,IAAY,IAAA,GAAO,CAAC,QAAQ,CAAA,GAAI,EAAE;;AAEvG,EAAE,MAAM,YAAA,GAAe,kBAAA,IAAsB,qBAAqB;;AAElE,EAAE,OAAO,CAAC,GAAG,cAAc,EAAE,GAAG,YAAY,CAAC;AAC7C;;;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const _exports = require('../../exports.js'); | ||
| const exports$1 = require('../../exports.js'); | ||
| const semanticAttributes = require('../../semanticAttributes.js'); | ||
@@ -283,3 +283,3 @@ const spanstatus = require('../spanstatus.js'); | ||
| span.setStatus({ code: spanstatus.SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { | ||
@@ -312,3 +312,3 @@ handled: false, | ||
| error => { | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { handled: false, type: 'auto.ai.google_genai', data: { function: methodPath } }, | ||
@@ -315,0 +315,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/google-genai/index.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpan, startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types-hoist/span';\nimport { handleCallbackErrors } from '../../utils/handleCallbackErrors';\nimport {\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_K_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_P_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_TEXT_ATTRIBUTE,\n GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { InstrumentedMethodEntry } from '../ai/utils';\nimport {\n buildMethodPath,\n extractSystemInstructions,\n getJsonString,\n getTruncatedJsonString,\n resolveAIRecordingOptions,\n shouldEnableTruncation,\n} from '../ai/utils';\nimport { GOOGLE_GENAI_METHOD_REGISTRY, GOOGLE_GENAI_SYSTEM_NAME } from './constants';\nimport { instrumentStream } from './streaming';\nimport type { Candidate, ContentPart, GoogleGenAIOptions, GoogleGenAIResponse } from './types';\nimport type { ContentListUnion, ContentUnion, Message, PartListUnion } from './utils';\nimport { contentUnionToMessages } from './utils';\n\n/**\n * Extract model from parameters or chat context object\n * For chat instances, the model is available on the chat object as 'model' (older versions) or 'modelVersion' (newer versions)\n */\nexport function extractModel(params: Record<string, unknown>, context?: unknown): string {\n if ('model' in params && typeof params.model === 'string') {\n return params.model;\n }\n\n // Try to get model from chat context object (chat instance has model property)\n if (context && typeof context === 'object') {\n const contextObj = context as Record<string, unknown>;\n\n // Check for 'model' property (older versions, and streaming)\n if ('model' in contextObj && typeof contextObj.model === 'string') {\n return contextObj.model;\n }\n\n // Check for 'modelVersion' property (newer versions)\n if ('modelVersion' in contextObj && typeof contextObj.modelVersion === 'string') {\n return contextObj.modelVersion;\n }\n }\n\n return 'unknown';\n}\n\n/**\n * Extract generation config parameters\n */\nfunction extractConfigAttributes(config: Record<string, unknown>): Record<string, SpanAttributeValue> {\n const attributes: Record<string, SpanAttributeValue> = {};\n\n if ('temperature' in config && typeof config.temperature === 'number') {\n attributes[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE] = config.temperature;\n }\n if ('topP' in config && typeof config.topP === 'number') {\n attributes[GEN_AI_REQUEST_TOP_P_ATTRIBUTE] = config.topP;\n }\n if ('topK' in config && typeof config.topK === 'number') {\n attributes[GEN_AI_REQUEST_TOP_K_ATTRIBUTE] = config.topK;\n }\n if ('maxOutputTokens' in config && typeof config.maxOutputTokens === 'number') {\n attributes[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE] = config.maxOutputTokens;\n }\n if ('frequencyPenalty' in config && typeof config.frequencyPenalty === 'number') {\n attributes[GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE] = config.frequencyPenalty;\n }\n if ('presencePenalty' in config && typeof config.presencePenalty === 'number') {\n attributes[GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE] = config.presencePenalty;\n }\n\n return attributes;\n}\n\n/**\n * Extract request attributes from method arguments\n * Builds the base attributes for span creation including system info, model, and config\n */\nfunction extractRequestAttributes(\n operationName: string,\n params?: Record<string, unknown>,\n context?: unknown,\n): Record<string, SpanAttributeValue> {\n const attributes: Record<string, SpanAttributeValue> = {\n [GEN_AI_SYSTEM_ATTRIBUTE]: GOOGLE_GENAI_SYSTEM_NAME,\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: operationName,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.google_genai',\n };\n\n if (params) {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = extractModel(params, context);\n\n // Extract generation config parameters\n if ('config' in params && typeof params.config === 'object' && params.config) {\n const config = params.config as Record<string, unknown>;\n Object.assign(attributes, extractConfigAttributes(config));\n\n // Extract available tools from config\n if ('tools' in config && Array.isArray(config.tools)) {\n const functionDeclarations = config.tools.flatMap(\n (tool: { functionDeclarations: unknown[] }) => tool.functionDeclarations,\n );\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = JSON.stringify(functionDeclarations);\n }\n }\n } else {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = extractModel({}, context);\n }\n\n return attributes;\n}\n\n/**\n * Add private request attributes to spans.\n * This is only recorded if recordInputs is true.\n * Handles different parameter formats for different Google GenAI methods.\n */\nfunction addPrivateRequestAttributes(\n span: Span,\n params: Record<string, unknown>,\n isEmbeddings: boolean,\n enableTruncation: boolean,\n): void {\n if (isEmbeddings) {\n const contents = params.contents;\n if (contents != null) {\n span.setAttribute(\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n typeof contents === 'string' ? contents : JSON.stringify(contents),\n );\n }\n return;\n }\n\n const messages: Message[] = [];\n\n // config.systemInstruction: ContentUnion\n if (\n 'config' in params &&\n params.config &&\n typeof params.config === 'object' &&\n 'systemInstruction' in params.config &&\n params.config.systemInstruction\n ) {\n messages.push(...contentUnionToMessages(params.config.systemInstruction as ContentUnion, 'system'));\n }\n\n // For chats.create: history contains the conversation history\n if ('history' in params) {\n messages.push(...contentUnionToMessages(params.history as PartListUnion, 'user'));\n }\n\n // For models.generateContent: ContentListUnion\n if ('contents' in params) {\n messages.push(...contentUnionToMessages(params.contents as ContentListUnion, 'user'));\n }\n\n // For chat.sendMessage: message can be PartListUnion\n if ('message' in params) {\n messages.push(...contentUnionToMessages(params.message as PartListUnion, 'user'));\n }\n\n if (Array.isArray(messages) && messages.length) {\n const { systemInstructions, filteredMessages } = extractSystemInstructions(messages);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 0;\n span.setAttributes({\n [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: filteredLength,\n [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: enableTruncation\n ? getTruncatedJsonString(filteredMessages)\n : getJsonString(filteredMessages),\n });\n }\n}\n\n/**\n * Add response attributes from the Google GenAI response\n * @see https://github.com/googleapis/js-genai/blob/v1.19.0/src/types.ts#L2313\n */\nfunction addResponseAttributes(span: Span, response: GoogleGenAIResponse, recordOutputs?: boolean): void {\n if (!response || typeof response !== 'object') return;\n\n if (response.modelVersion) {\n span.setAttribute(GEN_AI_RESPONSE_MODEL_ATTRIBUTE, response.modelVersion);\n }\n\n // Add usage metadata if present\n if (response.usageMetadata && typeof response.usageMetadata === 'object') {\n const usage = response.usageMetadata;\n if (typeof usage.promptTokenCount === 'number') {\n span.setAttributes({\n [GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: usage.promptTokenCount,\n });\n }\n if (typeof usage.candidatesTokenCount === 'number') {\n span.setAttributes({\n [GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: usage.candidatesTokenCount,\n });\n }\n if (typeof usage.totalTokenCount === 'number') {\n span.setAttributes({\n [GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE]: usage.totalTokenCount,\n });\n }\n }\n\n // Add response text if recordOutputs is enabled\n if (recordOutputs && Array.isArray(response.candidates) && response.candidates.length > 0) {\n const responseTexts = response.candidates\n .map((candidate: Candidate) => {\n if (candidate.content?.parts && Array.isArray(candidate.content.parts)) {\n return candidate.content.parts\n .map((part: ContentPart) => (typeof part.text === 'string' ? part.text : ''))\n .filter((text: string) => text.length > 0)\n .join('');\n }\n return '';\n })\n .filter((text: string) => text.length > 0);\n\n if (responseTexts.length > 0) {\n span.setAttributes({\n [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: responseTexts.join(''),\n });\n }\n }\n\n // Add tool calls if recordOutputs is enabled\n if (recordOutputs && response.functionCalls) {\n const functionCalls = response.functionCalls;\n if (Array.isArray(functionCalls) && functionCalls.length > 0) {\n span.setAttributes({\n [GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE]: JSON.stringify(functionCalls),\n });\n }\n }\n}\n\n/**\n * Instrument any async or synchronous genai method with Sentry spans\n * Handles operations like models.generateContent and chat.sendMessage and chats.create\n * @see https://docs.sentry.io/platforms/javascript/guides/node/tracing/instrumentation/ai-agents-module/#manual-instrumentation\n */\nfunction instrumentMethod<T extends unknown[], R>(\n originalMethod: (...args: T) => R | Promise<R>,\n methodPath: string,\n instrumentedMethod: InstrumentedMethodEntry,\n context: unknown,\n options: GoogleGenAIOptions,\n): (...args: T) => R | Promise<R> {\n const isEmbeddings = instrumentedMethod.operation === 'embeddings';\n\n return new Proxy(originalMethod, {\n apply(target, _, args: T): R | Promise<R> {\n const operationName = instrumentedMethod.operation || 'unknown';\n const params = args[0] as Record<string, unknown> | undefined;\n const requestAttributes = extractRequestAttributes(operationName, params, context);\n const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? 'unknown';\n\n // Check if this is a streaming method\n if (instrumentedMethod.streaming) {\n // Use startSpanManual for streaming methods to control span lifecycle\n return startSpanManual(\n {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes,\n },\n async (span: Span) => {\n try {\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(\n span,\n params,\n isEmbeddings,\n shouldEnableTruncation(options.enableTruncation),\n );\n }\n const stream = await target.apply(context, args);\n return instrumentStream(stream, span, Boolean(options.recordOutputs)) as R;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.google_genai',\n data: { function: methodPath },\n },\n });\n span.end();\n throw error;\n }\n },\n );\n }\n // Single span for both sync and async operations\n return startSpan(\n {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes,\n },\n (span: Span) => {\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, isEmbeddings, shouldEnableTruncation(options.enableTruncation));\n }\n\n return handleCallbackErrors(\n () => target.apply(context, args),\n error => {\n captureException(error, {\n mechanism: { handled: false, type: 'auto.ai.google_genai', data: { function: methodPath } },\n });\n },\n () => {},\n result => {\n // Only add response attributes for content-producing methods, not for embeddings\n if (!isEmbeddings) {\n addResponseAttributes(span, result, options.recordOutputs);\n }\n },\n );\n },\n );\n },\n }) as (...args: T) => R | Promise<R>;\n}\n\n/**\n * Create a deep proxy for Google GenAI client instrumentation\n * Recursively instruments methods and handles special cases like chats.create\n */\nfunction createDeepProxy<T extends object>(target: T, currentPath = '', options: GoogleGenAIOptions): T {\n return new Proxy(target, {\n get: (t, prop, receiver) => {\n const value = Reflect.get(t, prop, receiver);\n const methodPath = buildMethodPath(currentPath, String(prop));\n\n const instrumentedMethod: InstrumentedMethodEntry | undefined =\n GOOGLE_GENAI_METHOD_REGISTRY[methodPath as keyof typeof GOOGLE_GENAI_METHOD_REGISTRY];\n if (typeof value === 'function' && instrumentedMethod) {\n // If an operation is specified, we need to instrument the method itself\n const wrappedMethod = instrumentedMethod.operation\n ? instrumentMethod(value as (...args: unknown[]) => unknown, methodPath, instrumentedMethod, t, options)\n : value.bind(t);\n\n if (!instrumentedMethod.proxyResultPath) {\n return wrappedMethod;\n }\n\n // If a proxyResultPath is specified, we need to proxy the result of the method.\n // Note: This currently only properly handles synchronous methods. For async methods,\n // the Promise itself would be proxied instead of the resolved value. Currently we\n // don't have a case where this is needed, so I'll keep it simple for now.\n return function (...args: unknown[]): unknown {\n const result = wrappedMethod(...args);\n if (result && typeof result === 'object') {\n return createDeepProxy(result as object, instrumentedMethod.proxyResultPath, options);\n }\n return result;\n };\n }\n\n if (typeof value === 'function') {\n // Bind non-instrumented functions to preserve the original `this` context\n return value.bind(t);\n }\n\n if (value && typeof value === 'object') {\n return createDeepProxy(value, methodPath, options);\n }\n\n return value;\n },\n });\n}\n\n/**\n * Instrument a Google GenAI client with Sentry tracing\n * Can be used across Node.js, Cloudflare Workers, and Vercel Edge\n *\n * @template T - The type of the client that extends client object\n * @param client - The Google GenAI client to instrument\n * @param options - Optional configuration for recording inputs and outputs\n * @returns The instrumented client with the same type as the input\n *\n * @example\n * ```typescript\n * import { GoogleGenAI } from '@google/genai';\n * import { instrumentGoogleGenAIClient } from '@sentry/core';\n *\n * const genAI = new GoogleGenAI({ apiKey: process.env.GOOGLE_GENAI_API_KEY });\n * const instrumentedClient = instrumentGoogleGenAIClient(genAI);\n *\n * // Now both chats.create and sendMessage will be instrumented\n * const chat = instrumentedClient.chats.create({ model: 'gemini-1.5-pro' });\n * const response = await chat.sendMessage({ message: 'Hello' });\n * ```\n */\nexport function instrumentGoogleGenAIClient<T extends object>(client: T, options?: GoogleGenAIOptions): T {\n return createDeepProxy(client, '', resolveAIRecordingOptions(options));\n}\n"],"names":["GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE","GEN_AI_REQUEST_TOP_P_ATTRIBUTE","GEN_AI_REQUEST_TOP_K_ATTRIBUTE","GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE","GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE","GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE","GEN_AI_SYSTEM_ATTRIBUTE","GOOGLE_GENAI_SYSTEM_NAME","GEN_AI_OPERATION_NAME_ATTRIBUTE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE","contentUnionToMessages","extractSystemInstructions","GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE","GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE","GEN_AI_INPUT_MESSAGES_ATTRIBUTE","getTruncatedJsonString","getJsonString","GEN_AI_RESPONSE_MODEL_ATTRIBUTE","GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE","GEN_AI_RESPONSE_TEXT_ATTRIBUTE","GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE","startSpanManual","shouldEnableTruncation","instrumentStream","SPAN_STATUS_ERROR","captureException","startSpan","handleCallbackErrors","buildMethodPath","GOOGLE_GENAI_METHOD_REGISTRY","resolveAIRecordingOptions"],"mappings":";;;;;;;;;;;;;AAAA;;AA4CA;AACA;AACA;AACA;AACO,SAAS,YAAY,CAAC,MAAM,EAA2B,OAAO,EAAoB;AACzF,EAAE,IAAI,OAAA,IAAW,MAAA,IAAU,OAAO,MAAM,CAAC,KAAA,KAAU,QAAQ,EAAE;AAC7D,IAAI,OAAO,MAAM,CAAC,KAAK;AACvB,EAAE;;AAEF;AACA,EAAE,IAAI,OAAA,IAAW,OAAO,OAAA,KAAY,QAAQ,EAAE;AAC9C,IAAI,MAAM,UAAA,GAAa,OAAA;;AAEvB;A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A,CAAA,OAAA,CAAA,CAAA;AACA;;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/google-genai/index.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpan, startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types-hoist/span';\nimport { handleCallbackErrors } from '../../utils/handleCallbackErrors';\nimport {\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_K_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_P_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_TEXT_ATTRIBUTE,\n GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { InstrumentedMethodEntry } from '../ai/utils';\nimport {\n buildMethodPath,\n extractSystemInstructions,\n getJsonString,\n getTruncatedJsonString,\n resolveAIRecordingOptions,\n shouldEnableTruncation,\n} from '../ai/utils';\nimport { GOOGLE_GENAI_METHOD_REGISTRY, GOOGLE_GENAI_SYSTEM_NAME } from './constants';\nimport { instrumentStream } from './streaming';\nimport type { Candidate, ContentPart, GoogleGenAIOptions, GoogleGenAIResponse } from './types';\nimport type { ContentListUnion, ContentUnion, Message, PartListUnion } from './utils';\nimport { contentUnionToMessages } from './utils';\n\n/**\n * Extract model from parameters or chat context object\n * For chat instances, the model is available on the chat object as 'model' (older versions) or 'modelVersion' (newer versions)\n */\nexport function extractModel(params: Record<string, unknown>, context?: unknown): string {\n if ('model' in params && typeof params.model === 'string') {\n return params.model;\n }\n\n // Try to get model from chat context object (chat instance has model property)\n if (context && typeof context === 'object') {\n const contextObj = context as Record<string, unknown>;\n\n // Check for 'model' property (older versions, and streaming)\n if ('model' in contextObj && typeof contextObj.model === 'string') {\n return contextObj.model;\n }\n\n // Check for 'modelVersion' property (newer versions)\n if ('modelVersion' in contextObj && typeof contextObj.modelVersion === 'string') {\n return contextObj.modelVersion;\n }\n }\n\n return 'unknown';\n}\n\n/**\n * Extract generation config parameters\n */\nfunction extractConfigAttributes(config: Record<string, unknown>): Record<string, SpanAttributeValue> {\n const attributes: Record<string, SpanAttributeValue> = {};\n\n if ('temperature' in config && typeof config.temperature === 'number') {\n attributes[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE] = config.temperature;\n }\n if ('topP' in config && typeof config.topP === 'number') {\n attributes[GEN_AI_REQUEST_TOP_P_ATTRIBUTE] = config.topP;\n }\n if ('topK' in config && typeof config.topK === 'number') {\n attributes[GEN_AI_REQUEST_TOP_K_ATTRIBUTE] = config.topK;\n }\n if ('maxOutputTokens' in config && typeof config.maxOutputTokens === 'number') {\n attributes[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE] = config.maxOutputTokens;\n }\n if ('frequencyPenalty' in config && typeof config.frequencyPenalty === 'number') {\n attributes[GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE] = config.frequencyPenalty;\n }\n if ('presencePenalty' in config && typeof config.presencePenalty === 'number') {\n attributes[GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE] = config.presencePenalty;\n }\n\n return attributes;\n}\n\n/**\n * Extract request attributes from method arguments\n * Builds the base attributes for span creation including system info, model, and config\n */\nfunction extractRequestAttributes(\n operationName: string,\n params?: Record<string, unknown>,\n context?: unknown,\n): Record<string, SpanAttributeValue> {\n const attributes: Record<string, SpanAttributeValue> = {\n [GEN_AI_SYSTEM_ATTRIBUTE]: GOOGLE_GENAI_SYSTEM_NAME,\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: operationName,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.google_genai',\n };\n\n if (params) {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = extractModel(params, context);\n\n // Extract generation config parameters\n if ('config' in params && typeof params.config === 'object' && params.config) {\n const config = params.config as Record<string, unknown>;\n Object.assign(attributes, extractConfigAttributes(config));\n\n // Extract available tools from config\n if ('tools' in config && Array.isArray(config.tools)) {\n const functionDeclarations = config.tools.flatMap(\n (tool: { functionDeclarations: unknown[] }) => tool.functionDeclarations,\n );\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = JSON.stringify(functionDeclarations);\n }\n }\n } else {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = extractModel({}, context);\n }\n\n return attributes;\n}\n\n/**\n * Add private request attributes to spans.\n * This is only recorded if recordInputs is true.\n * Handles different parameter formats for different Google GenAI methods.\n */\nfunction addPrivateRequestAttributes(\n span: Span,\n params: Record<string, unknown>,\n isEmbeddings: boolean,\n enableTruncation: boolean,\n): void {\n if (isEmbeddings) {\n const contents = params.contents;\n if (contents != null) {\n span.setAttribute(\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n typeof contents === 'string' ? contents : JSON.stringify(contents),\n );\n }\n return;\n }\n\n const messages: Message[] = [];\n\n // config.systemInstruction: ContentUnion\n if (\n 'config' in params &&\n params.config &&\n typeof params.config === 'object' &&\n 'systemInstruction' in params.config &&\n params.config.systemInstruction\n ) {\n messages.push(...contentUnionToMessages(params.config.systemInstruction as ContentUnion, 'system'));\n }\n\n // For chats.create: history contains the conversation history\n if ('history' in params) {\n messages.push(...contentUnionToMessages(params.history as PartListUnion, 'user'));\n }\n\n // For models.generateContent: ContentListUnion\n if ('contents' in params) {\n messages.push(...contentUnionToMessages(params.contents as ContentListUnion, 'user'));\n }\n\n // For chat.sendMessage: message can be PartListUnion\n if ('message' in params) {\n messages.push(...contentUnionToMessages(params.message as PartListUnion, 'user'));\n }\n\n if (Array.isArray(messages) && messages.length) {\n const { systemInstructions, filteredMessages } = extractSystemInstructions(messages);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 0;\n span.setAttributes({\n [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: filteredLength,\n [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: enableTruncation\n ? getTruncatedJsonString(filteredMessages)\n : getJsonString(filteredMessages),\n });\n }\n}\n\n/**\n * Add response attributes from the Google GenAI response\n * @see https://github.com/googleapis/js-genai/blob/v1.19.0/src/types.ts#L2313\n */\nfunction addResponseAttributes(span: Span, response: GoogleGenAIResponse, recordOutputs?: boolean): void {\n if (!response || typeof response !== 'object') return;\n\n if (response.modelVersion) {\n span.setAttribute(GEN_AI_RESPONSE_MODEL_ATTRIBUTE, response.modelVersion);\n }\n\n // Add usage metadata if present\n if (response.usageMetadata && typeof response.usageMetadata === 'object') {\n const usage = response.usageMetadata;\n if (typeof usage.promptTokenCount === 'number') {\n span.setAttributes({\n [GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: usage.promptTokenCount,\n });\n }\n if (typeof usage.candidatesTokenCount === 'number') {\n span.setAttributes({\n [GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: usage.candidatesTokenCount,\n });\n }\n if (typeof usage.totalTokenCount === 'number') {\n span.setAttributes({\n [GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE]: usage.totalTokenCount,\n });\n }\n }\n\n // Add response text if recordOutputs is enabled\n if (recordOutputs && Array.isArray(response.candidates) && response.candidates.length > 0) {\n const responseTexts = response.candidates\n .map((candidate: Candidate) => {\n if (candidate.content?.parts && Array.isArray(candidate.content.parts)) {\n return candidate.content.parts\n .map((part: ContentPart) => (typeof part.text === 'string' ? part.text : ''))\n .filter((text: string) => text.length > 0)\n .join('');\n }\n return '';\n })\n .filter((text: string) => text.length > 0);\n\n if (responseTexts.length > 0) {\n span.setAttributes({\n [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: responseTexts.join(''),\n });\n }\n }\n\n // Add tool calls if recordOutputs is enabled\n if (recordOutputs && response.functionCalls) {\n const functionCalls = response.functionCalls;\n if (Array.isArray(functionCalls) && functionCalls.length > 0) {\n span.setAttributes({\n [GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE]: JSON.stringify(functionCalls),\n });\n }\n }\n}\n\n/**\n * Instrument any async or synchronous genai method with Sentry spans\n * Handles operations like models.generateContent and chat.sendMessage and chats.create\n * @see https://docs.sentry.io/platforms/javascript/guides/node/tracing/instrumentation/ai-agents-module/#manual-instrumentation\n */\nfunction instrumentMethod<T extends unknown[], R>(\n originalMethod: (...args: T) => R | Promise<R>,\n methodPath: string,\n instrumentedMethod: InstrumentedMethodEntry,\n context: unknown,\n options: GoogleGenAIOptions,\n): (...args: T) => R | Promise<R> {\n const isEmbeddings = instrumentedMethod.operation === 'embeddings';\n\n return new Proxy(originalMethod, {\n apply(target, _, args: T): R | Promise<R> {\n const operationName = instrumentedMethod.operation || 'unknown';\n const params = args[0] as Record<string, unknown> | undefined;\n const requestAttributes = extractRequestAttributes(operationName, params, context);\n const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? 'unknown';\n\n // Check if this is a streaming method\n if (instrumentedMethod.streaming) {\n // Use startSpanManual for streaming methods to control span lifecycle\n return startSpanManual(\n {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes,\n },\n async (span: Span) => {\n try {\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(\n span,\n params,\n isEmbeddings,\n shouldEnableTruncation(options.enableTruncation),\n );\n }\n const stream = await target.apply(context, args);\n return instrumentStream(stream, span, Boolean(options.recordOutputs)) as R;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.google_genai',\n data: { function: methodPath },\n },\n });\n span.end();\n throw error;\n }\n },\n );\n }\n // Single span for both sync and async operations\n return startSpan(\n {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes,\n },\n (span: Span) => {\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, isEmbeddings, shouldEnableTruncation(options.enableTruncation));\n }\n\n return handleCallbackErrors(\n () => target.apply(context, args),\n error => {\n captureException(error, {\n mechanism: { handled: false, type: 'auto.ai.google_genai', data: { function: methodPath } },\n });\n },\n () => {},\n result => {\n // Only add response attributes for content-producing methods, not for embeddings\n if (!isEmbeddings) {\n addResponseAttributes(span, result, options.recordOutputs);\n }\n },\n );\n },\n );\n },\n }) as (...args: T) => R | Promise<R>;\n}\n\n/**\n * Create a deep proxy for Google GenAI client instrumentation\n * Recursively instruments methods and handles special cases like chats.create\n */\nfunction createDeepProxy<T extends object>(target: T, currentPath = '', options: GoogleGenAIOptions): T {\n return new Proxy(target, {\n get: (t, prop, receiver) => {\n const value = Reflect.get(t, prop, receiver);\n const methodPath = buildMethodPath(currentPath, String(prop));\n\n const instrumentedMethod: InstrumentedMethodEntry | undefined =\n GOOGLE_GENAI_METHOD_REGISTRY[methodPath as keyof typeof GOOGLE_GENAI_METHOD_REGISTRY];\n if (typeof value === 'function' && instrumentedMethod) {\n // If an operation is specified, we need to instrument the method itself\n const wrappedMethod = instrumentedMethod.operation\n ? instrumentMethod(value as (...args: unknown[]) => unknown, methodPath, instrumentedMethod, t, options)\n : value.bind(t);\n\n if (!instrumentedMethod.proxyResultPath) {\n return wrappedMethod;\n }\n\n // If a proxyResultPath is specified, we need to proxy the result of the method.\n // Note: This currently only properly handles synchronous methods. For async methods,\n // the Promise itself would be proxied instead of the resolved value. Currently we\n // don't have a case where this is needed, so I'll keep it simple for now.\n return function (...args: unknown[]): unknown {\n const result = wrappedMethod(...args);\n if (result && typeof result === 'object') {\n return createDeepProxy(result as object, instrumentedMethod.proxyResultPath, options);\n }\n return result;\n };\n }\n\n if (typeof value === 'function') {\n // Bind non-instrumented functions to preserve the original `this` context\n return value.bind(t);\n }\n\n if (value && typeof value === 'object') {\n return createDeepProxy(value, methodPath, options);\n }\n\n return value;\n },\n });\n}\n\n/**\n * Instrument a Google GenAI client with Sentry tracing\n * Can be used across Node.js, Cloudflare Workers, and Vercel Edge\n *\n * @template T - The type of the client that extends client object\n * @param client - The Google GenAI client to instrument\n * @param options - Optional configuration for recording inputs and outputs\n * @returns The instrumented client with the same type as the input\n *\n * @example\n * ```typescript\n * import { GoogleGenAI } from '@google/genai';\n * import { instrumentGoogleGenAIClient } from '@sentry/core';\n *\n * const genAI = new GoogleGenAI({ apiKey: process.env.GOOGLE_GENAI_API_KEY });\n * const instrumentedClient = instrumentGoogleGenAIClient(genAI);\n *\n * // Now both chats.create and sendMessage will be instrumented\n * const chat = instrumentedClient.chats.create({ model: 'gemini-1.5-pro' });\n * const response = await chat.sendMessage({ message: 'Hello' });\n * ```\n */\nexport function instrumentGoogleGenAIClient<T extends object>(client: T, options?: GoogleGenAIOptions): T {\n return createDeepProxy(client, '', resolveAIRecordingOptions(options));\n}\n"],"names":["GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE","GEN_AI_REQUEST_TOP_P_ATTRIBUTE","GEN_AI_REQUEST_TOP_K_ATTRIBUTE","GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE","GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE","GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE","GEN_AI_SYSTEM_ATTRIBUTE","GOOGLE_GENAI_SYSTEM_NAME","GEN_AI_OPERATION_NAME_ATTRIBUTE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE","contentUnionToMessages","extractSystemInstructions","GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE","GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE","GEN_AI_INPUT_MESSAGES_ATTRIBUTE","getTruncatedJsonString","getJsonString","GEN_AI_RESPONSE_MODEL_ATTRIBUTE","GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE","GEN_AI_RESPONSE_TEXT_ATTRIBUTE","GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE","startSpanManual","shouldEnableTruncation","instrumentStream","SPAN_STATUS_ERROR","captureException","startSpan","handleCallbackErrors","buildMethodPath","GOOGLE_GENAI_METHOD_REGISTRY","resolveAIRecordingOptions"],"mappings":";;;;;;;;;;;;;AAAA;;AA4CA;AACA;AACA;AACA;AACO,SAAS,YAAY,CAAC,MAAM,EAA2B,OAAO,EAAoB;AACzF,EAAE,IAAI,OAAA,IAAW,MAAA,IAAU,OAAO,MAAM,CAAC,KAAA,KAAU,QAAQ,EAAE;AAC7D,IAAI,OAAO,MAAM,CAAC,KAA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A;AACA;AACA;AACA;AACA;AACA,SAAA,2BAAA,CAAA,MAAA,EAAA,OAAA,EAAA;AACA,EAAA,OAAA,eAAA,CAAA,MAAA,EAAA,EAAA,EAAAC,+BAAA,CAAA,OAAA,CAAA,CAAA;AACA;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const _exports = require('../../exports.js'); | ||
| const exports$1 = require('../../exports.js'); | ||
| const spanstatus = require('../spanstatus.js'); | ||
@@ -22,3 +22,3 @@ const utils = require('../ai/utils.js'); | ||
| span.setStatus({ code: spanstatus.SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
| _exports.captureException(`Content blocked: ${message}`, { | ||
| exports$1.captureException(`Content blocked: ${message}`, { | ||
| mechanism: { handled: false, type: 'auto.ai.google_genai' }, | ||
@@ -25,0 +25,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"streaming.js","sources":["../../../../src/tracing/google-genai/streaming.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport type { Span } from '../../types-hoist/span';\nimport { endStreamSpan } from '../ai/utils';\nimport type { GoogleGenAIResponse } from './types';\n\n/**\n * State object used to accumulate information from a stream of Google GenAI events.\n */\ninterface StreamingState {\n /** Collected response text fragments (for output recording). */\n responseTexts: string[];\n /** Reasons for finishing the response, as reported by the API. */\n finishReasons: string[];\n /** The response ID. */\n responseId?: string;\n /** The model name. */\n responseModel?: string;\n /** Number of prompt/input tokens used. */\n promptTokens?: number;\n /** Number of completion/output tokens used. */\n completionTokens?: number;\n /** Number of total tokens used. */\n totalTokens?: number;\n /** Accumulated tool calls (finalized) */\n toolCalls: Array<Record<string, unknown>>;\n}\n\n/**\n * Checks if a response chunk contains an error\n * @param chunk - The response chunk to check\n * @param span - The span to update if error is found\n * @returns Whether an error occurred\n */\nfunction isErrorChunk(chunk: GoogleGenAIResponse, span: Span): boolean {\n const feedback = chunk?.promptFeedback;\n if (feedback?.blockReason) {\n const message = feedback.blockReasonMessage ?? feedback.blockReason;\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(`Content blocked: ${message}`, {\n mechanism: { handled: false, type: 'auto.ai.google_genai' },\n });\n return true;\n }\n return false;\n}\n\n/**\n * Processes response metadata from a chunk\n * @param chunk - The response chunk to process\n * @param state - The state of the streaming process\n */\nfunction handleResponseMetadata(chunk: GoogleGenAIResponse, state: StreamingState): void {\n if (typeof chunk.responseId === 'string') state.responseId = chunk.responseId;\n if (typeof chunk.modelVersion === 'string') state.responseModel = chunk.modelVersion;\n\n const usage = chunk.usageMetadata;\n if (usage) {\n if (typeof usage.promptTokenCount === 'number') state.promptTokens = usage.promptTokenCount;\n if (typeof usage.candidatesTokenCount === 'number') state.completionTokens = usage.candidatesTokenCount;\n if (typeof usage.totalTokenCount === 'number') state.totalTokens = usage.totalTokenCount;\n }\n}\n\n/**\n * Processes candidate content from a response chunk\n * @param chunk - The response chunk to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n */\nfunction handleCandidateContent(chunk: GoogleGenAIResponse, state: StreamingState, recordOutputs: boolean): void {\n if (Array.isArray(chunk.functionCalls)) {\n state.toolCalls.push(...chunk.functionCalls);\n }\n\n for (const candidate of chunk.candidates ?? []) {\n if (candidate?.finishReason && !state.finishReasons.includes(candidate.finishReason)) {\n state.finishReasons.push(candidate.finishReason);\n }\n\n for (const part of candidate?.content?.parts ?? []) {\n if (recordOutputs && part.text) state.responseTexts.push(part.text);\n if (part.functionCall) {\n state.toolCalls.push({\n type: 'function',\n id: part.functionCall.id,\n name: part.functionCall.name,\n arguments: part.functionCall.args,\n });\n }\n }\n }\n}\n\n/**\n * Processes a single chunk from the Google GenAI stream\n * @param chunk - The chunk to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n * @param span - The span to update\n */\nfunction processChunk(chunk: GoogleGenAIResponse, state: StreamingState, recordOutputs: boolean, span: Span): void {\n if (!chunk || isErrorChunk(chunk, span)) return;\n handleResponseMetadata(chunk, state);\n handleCandidateContent(chunk, state, recordOutputs);\n}\n\n/**\n * Instruments an async iterable stream of Google GenAI response chunks, updates the span with\n * streaming attributes and (optionally) the aggregated output text, and yields\n * each chunk from the input stream unchanged.\n */\nexport async function* instrumentStream(\n stream: AsyncIterable<GoogleGenAIResponse>,\n span: Span,\n recordOutputs: boolean,\n): AsyncGenerator<GoogleGenAIResponse, void, unknown> {\n const state: StreamingState = {\n responseTexts: [],\n finishReasons: [],\n toolCalls: [],\n };\n\n try {\n for await (const chunk of stream) {\n processChunk(chunk, state, recordOutputs, span);\n yield chunk;\n }\n } finally {\n endStreamSpan(span, state, recordOutputs);\n }\n}\n"],"names":["SPAN_STATUS_ERROR","captureException","endStreamSpan"],"mappings":";;;;;;AAMA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,YAAY,CAAC,KAAK,EAAuB,IAAI,EAAiB;AACvE,EAAE,MAAM,QAAA,GAAW,KAAK,EAAE,cAAc;AACxC,EAAE,IAAI,QAAQ,EAAE,WAAW,EAAE;AAC7B,IAAI,MAAM,UAAU,QAAQ,CAAC,kBAAA,IAAsB,QAAQ,CAAC,WAAW;AACvE,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAEA,4BAAiB,EAAE,OAAO,EAAE,gBAAA,EAAkB,CAAC;AAC1E,IAAIC,yBAAgB,CAAC,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA,EAAA;AACA,MAAA,SAAA,EAAA,EAAA,OAAA,EAAA,KAAA,EAAA,IAAA,EAAA,sBAAA,EAAA;AACA,KAAA,CAAA;AACA,IAAA,OAAA,IAAA;AACA,EAAA;AACA,EAAA,OAAA,KAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAA,sBAAA,CAAA,KAAA,EAAA,KAAA,EAAA;AACA,EAAA,IAAA,OAAA,KAAA,CAAA,UAAA,KAAA,QAAA,EAAA,KAAA,CAA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AA,CAAA,IAAA,CAAA;AACA,MAAA,IAAA,IAAA,CAAA,YAAA,EAAA;AACA,QAAA,KAAA,CAAA,SAAA,CAAA,IAAA,CAAA;AACA,UAAA,IAAA,EAAA,UAAA;AACA,UAAA,EAAA,EAAA,IAAA,CAAA,YAAA,CAAA,EAAA;AACA,UAAA,IAAA,EAAA,IAAA,CAAA,YAAA,CAAA,IAAA;AACA,UAAA,SAAA,EAAA,IAAA,CAAA,YAAA,CAAA,IAAA;AACA,SAAA,CAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,YAAA,CAAA,KAAA,EAAA,KAAA,EAAA,aAAA,EAAA,IAAA,EAAA;AACA,EAAA,IAAA,CAAA,KAAA,IAAA,YAAA,CAAA,KAAA,EAAA,IAAA,CAAA,EAAA;AACA,EAAA,sBAAA,CAAA,KAAA,EAAA,KAAA,CAAA;AACA,EAAA,sBAAA,CAAA,KAAA,EAAA,KAAA,EAAA,aAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,gBAAA,gBAAA;AACA,EAAA,MAAA;AACA,EAAA,IAAA;AACA,EAAA,aAAA;AACA,EAAA;AACA,EAAA,MAAA,KAAA,GAAA;AACA,IAAA,aAAA,EAAA,EAAA;AACA,IAAA,aAAA,EAAA,EAAA;AACA,IAAA,SAAA,EAAA,EAAA;AACA,GAAA;;AAEA,EAAA,IAAA;AACA,IAAA,WAAA,MAAA,KAAA,IAAA,MAAA,EAAA;AACA,MAAA,YAAA,CAAA,KAAA,EAAA,KAAA,EAAA,aAAA,EAAA,IAAA,CAAA;AACA,MAAA,MAAA,KAAA;AACA,IAAA;AACA,EAAA,CAAA,SAAA;AACA,IAAAC,mBAAA,CAAA,IAAA,EAAA,KAAA,EAAA,aAAA,CAAA;AACA,EAAA;AACA;;;;"} | ||
| {"version":3,"file":"streaming.js","sources":["../../../../src/tracing/google-genai/streaming.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport type { Span } from '../../types-hoist/span';\nimport { endStreamSpan } from '../ai/utils';\nimport type { GoogleGenAIResponse } from './types';\n\n/**\n * State object used to accumulate information from a stream of Google GenAI events.\n */\ninterface StreamingState {\n /** Collected response text fragments (for output recording). */\n responseTexts: string[];\n /** Reasons for finishing the response, as reported by the API. */\n finishReasons: string[];\n /** The response ID. */\n responseId?: string;\n /** The model name. */\n responseModel?: string;\n /** Number of prompt/input tokens used. */\n promptTokens?: number;\n /** Number of completion/output tokens used. */\n completionTokens?: number;\n /** Number of total tokens used. */\n totalTokens?: number;\n /** Accumulated tool calls (finalized) */\n toolCalls: Array<Record<string, unknown>>;\n}\n\n/**\n * Checks if a response chunk contains an error\n * @param chunk - The response chunk to check\n * @param span - The span to update if error is found\n * @returns Whether an error occurred\n */\nfunction isErrorChunk(chunk: GoogleGenAIResponse, span: Span): boolean {\n const feedback = chunk?.promptFeedback;\n if (feedback?.blockReason) {\n const message = feedback.blockReasonMessage ?? feedback.blockReason;\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(`Content blocked: ${message}`, {\n mechanism: { handled: false, type: 'auto.ai.google_genai' },\n });\n return true;\n }\n return false;\n}\n\n/**\n * Processes response metadata from a chunk\n * @param chunk - The response chunk to process\n * @param state - The state of the streaming process\n */\nfunction handleResponseMetadata(chunk: GoogleGenAIResponse, state: StreamingState): void {\n if (typeof chunk.responseId === 'string') state.responseId = chunk.responseId;\n if (typeof chunk.modelVersion === 'string') state.responseModel = chunk.modelVersion;\n\n const usage = chunk.usageMetadata;\n if (usage) {\n if (typeof usage.promptTokenCount === 'number') state.promptTokens = usage.promptTokenCount;\n if (typeof usage.candidatesTokenCount === 'number') state.completionTokens = usage.candidatesTokenCount;\n if (typeof usage.totalTokenCount === 'number') state.totalTokens = usage.totalTokenCount;\n }\n}\n\n/**\n * Processes candidate content from a response chunk\n * @param chunk - The response chunk to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n */\nfunction handleCandidateContent(chunk: GoogleGenAIResponse, state: StreamingState, recordOutputs: boolean): void {\n if (Array.isArray(chunk.functionCalls)) {\n state.toolCalls.push(...chunk.functionCalls);\n }\n\n for (const candidate of chunk.candidates ?? []) {\n if (candidate?.finishReason && !state.finishReasons.includes(candidate.finishReason)) {\n state.finishReasons.push(candidate.finishReason);\n }\n\n for (const part of candidate?.content?.parts ?? []) {\n if (recordOutputs && part.text) state.responseTexts.push(part.text);\n if (part.functionCall) {\n state.toolCalls.push({\n type: 'function',\n id: part.functionCall.id,\n name: part.functionCall.name,\n arguments: part.functionCall.args,\n });\n }\n }\n }\n}\n\n/**\n * Processes a single chunk from the Google GenAI stream\n * @param chunk - The chunk to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n * @param span - The span to update\n */\nfunction processChunk(chunk: GoogleGenAIResponse, state: StreamingState, recordOutputs: boolean, span: Span): void {\n if (!chunk || isErrorChunk(chunk, span)) return;\n handleResponseMetadata(chunk, state);\n handleCandidateContent(chunk, state, recordOutputs);\n}\n\n/**\n * Instruments an async iterable stream of Google GenAI response chunks, updates the span with\n * streaming attributes and (optionally) the aggregated output text, and yields\n * each chunk from the input stream unchanged.\n */\nexport async function* instrumentStream(\n stream: AsyncIterable<GoogleGenAIResponse>,\n span: Span,\n recordOutputs: boolean,\n): AsyncGenerator<GoogleGenAIResponse, void, unknown> {\n const state: StreamingState = {\n responseTexts: [],\n finishReasons: [],\n toolCalls: [],\n };\n\n try {\n for await (const chunk of stream) {\n processChunk(chunk, state, recordOutputs, span);\n yield chunk;\n }\n } finally {\n endStreamSpan(span, state, recordOutputs);\n }\n}\n"],"names":["SPAN_STATUS_ERROR","captureException","endStreamSpan"],"mappings":";;;;;;AAMA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,YAAY,CAAC,KAAK,EAAuB,IAAI,EAAiB;AACvE,EAAE,MAAM,QAAA,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A,KAAA,EAAA,aAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,gBAAA,gBAAA;AACA,EAAA,MAAA;AACA,EAAA,IAAA;AACA,EAAA,aAAA;AACA,EAAA;AACA,EAAA,MAAA,KAAA,GAAA;AACA,IAAA,aAAA,EAAA,EAAA;AACA,IAAA,aAAA,EAAA,EAAA;AACA,IAAA,SAAA,EAAA,EAAA;AACA,GAAA;;AAEA,EAAA,IAAA;AACA,IAAA,WAAA,MAAA,KAAA,IAAA,MAAA,EAAA;AACA,MAAA,YAAA,CAAA,KAAA,EAAA,KAAA,EAAA,aAAA,EAAA,IAAA,CAAA;AACA,MAAA,MAAA,KAAA;AACA,IAAA;AACA,EAAA,CAAA,SAAA;AACA,IAAAC,mBAAA,CAAA,IAAA,EAAA,KAAA,EAAA,aAAA,CAAA;AACA,EAAA;AACA;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const _exports = require('../../exports.js'); | ||
| const exports$1 = require('../../exports.js'); | ||
| const semanticAttributes = require('../../semanticAttributes.js'); | ||
@@ -81,3 +81,3 @@ const trace = require('../trace.js'); | ||
| return Reflect.apply(target, thisArg, args).then(undefined, error => { | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { handled: false, type: 'auto.ai.langchain' }, | ||
@@ -84,0 +84,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"embeddings.js","sources":["../../../../src/tracing/langchain/embeddings.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { startSpan } from '../../tracing/trace';\nimport type { SpanAttributeValue } from '../../types-hoist/span';\nimport {\n GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE,\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_DIMENSIONS_ATTRIBUTE,\n GEN_AI_REQUEST_ENCODING_FORMAT_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport { resolveAIRecordingOptions } from '../ai/utils';\nimport { LANGCHAIN_ORIGIN } from './constants';\nimport type { LangChainOptions } from './types';\n\n/**\n * Infers the AI provider system name from the embedding class instance.\n */\nfunction inferSystemFromInstance(instance: Record<string, unknown>): string {\n const name = (instance.constructor as { name?: string })?.name ?? '';\n if (name.includes('OpenAI')) return 'openai';\n if (name.includes('Google')) return 'google_genai';\n if (name.includes('Mistral')) return 'mistralai';\n if (name.includes('Vertex')) return 'google_vertexai';\n if (name.includes('Bedrock')) return 'aws_bedrock';\n if (name.includes('Ollama')) return 'ollama';\n if (name.includes('Cloudflare')) return 'cloudflare';\n if (name.includes('Cohere')) return 'cohere';\n return 'langchain';\n}\n\n/**\n * Extracts span attributes from a LangChain embedding class instance.\n */\nfunction extractEmbeddingAttributes(instance: unknown): Record<string, unknown> {\n const embeddingsInstance = (instance ?? {}) as Record<string, unknown>;\n\n const attributes: Record<string, unknown> = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGCHAIN_ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE,\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'embeddings',\n [GEN_AI_REQUEST_MODEL_ATTRIBUTE]: embeddingsInstance.model ?? 'unknown',\n };\n\n attributes[GEN_AI_SYSTEM_ATTRIBUTE] = inferSystemFromInstance(embeddingsInstance);\n if ('dimensions' in embeddingsInstance) {\n attributes[GEN_AI_REQUEST_DIMENSIONS_ATTRIBUTE] = embeddingsInstance.dimensions;\n }\n if ('encodingFormat' in embeddingsInstance) {\n attributes[GEN_AI_REQUEST_ENCODING_FORMAT_ATTRIBUTE] = embeddingsInstance.encodingFormat;\n }\n\n return attributes;\n}\n\n/**\n * Wraps a LangChain embedding method (embedQuery or embedDocuments) to create Sentry spans.\n *\n * Used internally by the Node.js auto-instrumentation to patch embedding class prototypes.\n */\nexport function instrumentEmbeddingMethod(\n originalMethod: (...args: unknown[]) => Promise<unknown>,\n options: LangChainOptions = {},\n): (...args: unknown[]) => Promise<unknown> {\n const { recordInputs } = resolveAIRecordingOptions(options);\n\n return new Proxy(originalMethod, {\n apply(target, thisArg, args: unknown[]): Promise<unknown> {\n const attributes = extractEmbeddingAttributes(thisArg);\n const modelName = attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] || 'unknown';\n\n if (recordInputs) {\n const input = args[0];\n if (input != null) {\n attributes[GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE] = typeof input === 'string' ? input : JSON.stringify(input);\n }\n }\n\n return startSpan(\n {\n name: `embeddings ${modelName}`,\n op: GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE,\n attributes: attributes as Record<string, SpanAttributeValue>,\n },\n () => {\n return Reflect.apply(target, thisArg, args).then(undefined, error => {\n captureException(error, {\n mechanism: { handled: false, type: 'auto.ai.langchain' },\n });\n throw error;\n });\n },\n );\n },\n }) as (...args: unknown[]) => Promise<unknown>;\n}\n\n/**\n * Wraps a LangChain embeddings instance to create Sentry spans for `embedQuery` and `embedDocuments` calls.\n *\n * Use this in non-Node runtimes (Cloudflare, browser, etc.) where auto-instrumentation is not available.\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/cloudflare';\n * import { OpenAIEmbeddings } from '@langchain/openai';\n *\n * const embeddings = Sentry.instrumentLangChainEmbeddings(\n * new OpenAIEmbeddings({ model: 'text-embedding-3-small' })\n * );\n *\n * await embeddings.embedQuery('Hello world');\n * await embeddings.embedDocuments(['doc1', 'doc2']);\n * ```\n */\nexport function instrumentLangChainEmbeddings<T extends object>(instance: T, options?: LangChainOptions): T {\n const embeddingsInstance = instance as Record<string, unknown>;\n\n if (typeof embeddingsInstance.embedQuery === 'function') {\n embeddingsInstance.embedQuery = instrumentEmbeddingMethod(\n embeddingsInstance.embedQuery as (...args: unknown[]) => Promise<unknown>,\n options,\n );\n }\n\n if (typeof embeddingsInstance.embedDocuments === 'function') {\n embeddingsInstance.embedDocuments = instrumentEmbeddingMethod(\n embeddingsInstance.embedDocuments as (...args: unknown[]) => Promise<unknown>,\n options,\n );\n }\n\n return instance;\n}\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","LANGCHAIN_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE","GEN_AI_OPERATION_NAME_ATTRIBUTE","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_SYSTEM_ATTRIBUTE","GEN_AI_REQUEST_DIMENSIONS_ATTRIBUTE","GEN_AI_REQUEST_ENCODING_FORMAT_ATTRIBUTE","resolveAIRecordingOptions","GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE","startSpan","captureException"],"mappings":";;;;;;;;;AAiBA;AACA;AACA;AACA,SAAS,uBAAuB,CAAC,QAAQ,EAAmC;AAC5E,EAAE,MAAM,IAAA,GAAO,CAAC,QAAQ,CAAC,WAAA,IAAmC,IAAA,IAAQ,EAAE;AACtE,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,QAAQ;AAC9C,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,cAAc;AACpD,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,WAAW;AAClD,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,iBAAiB;AACvD,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,aAAa;AACpD,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,QAA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AA;AACA,EAAA;;AAEA,EAAA,IAAA,OAAA,kBAAA,CAAA,cAAA,KAAA,UAAA,EAAA;AACA,IAAA,kBAAA,CAAA,cAAA,GAAA,yBAAA;AACA,MAAA,kBAAA,CAAA,cAAA;AACA,MAAA,OAAA;AACA,KAAA;AACA,EAAA;;AAEA,EAAA,OAAA,QAAA;AACA;;;;;"} | ||
| {"version":3,"file":"embeddings.js","sources":["../../../../src/tracing/langchain/embeddings.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { startSpan } from '../../tracing/trace';\nimport type { SpanAttributeValue } from '../../types-hoist/span';\nimport {\n GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE,\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_DIMENSIONS_ATTRIBUTE,\n GEN_AI_REQUEST_ENCODING_FORMAT_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport { resolveAIRecordingOptions } from '../ai/utils';\nimport { LANGCHAIN_ORIGIN } from './constants';\nimport type { LangChainOptions } from './types';\n\n/**\n * Infers the AI provider system name from the embedding class instance.\n */\nfunction inferSystemFromInstance(instance: Record<string, unknown>): string {\n const name = (instance.constructor as { name?: string })?.name ?? '';\n if (name.includes('OpenAI')) return 'openai';\n if (name.includes('Google')) return 'google_genai';\n if (name.includes('Mistral')) return 'mistralai';\n if (name.includes('Vertex')) return 'google_vertexai';\n if (name.includes('Bedrock')) return 'aws_bedrock';\n if (name.includes('Ollama')) return 'ollama';\n if (name.includes('Cloudflare')) return 'cloudflare';\n if (name.includes('Cohere')) return 'cohere';\n return 'langchain';\n}\n\n/**\n * Extracts span attributes from a LangChain embedding class instance.\n */\nfunction extractEmbeddingAttributes(instance: unknown): Record<string, unknown> {\n const embeddingsInstance = (instance ?? {}) as Record<string, unknown>;\n\n const attributes: Record<string, unknown> = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGCHAIN_ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE,\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'embeddings',\n [GEN_AI_REQUEST_MODEL_ATTRIBUTE]: embeddingsInstance.model ?? 'unknown',\n };\n\n attributes[GEN_AI_SYSTEM_ATTRIBUTE] = inferSystemFromInstance(embeddingsInstance);\n if ('dimensions' in embeddingsInstance) {\n attributes[GEN_AI_REQUEST_DIMENSIONS_ATTRIBUTE] = embeddingsInstance.dimensions;\n }\n if ('encodingFormat' in embeddingsInstance) {\n attributes[GEN_AI_REQUEST_ENCODING_FORMAT_ATTRIBUTE] = embeddingsInstance.encodingFormat;\n }\n\n return attributes;\n}\n\n/**\n * Wraps a LangChain embedding method (embedQuery or embedDocuments) to create Sentry spans.\n *\n * Used internally by the Node.js auto-instrumentation to patch embedding class prototypes.\n */\nexport function instrumentEmbeddingMethod(\n originalMethod: (...args: unknown[]) => Promise<unknown>,\n options: LangChainOptions = {},\n): (...args: unknown[]) => Promise<unknown> {\n const { recordInputs } = resolveAIRecordingOptions(options);\n\n return new Proxy(originalMethod, {\n apply(target, thisArg, args: unknown[]): Promise<unknown> {\n const attributes = extractEmbeddingAttributes(thisArg);\n const modelName = attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] || 'unknown';\n\n if (recordInputs) {\n const input = args[0];\n if (input != null) {\n attributes[GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE] = typeof input === 'string' ? input : JSON.stringify(input);\n }\n }\n\n return startSpan(\n {\n name: `embeddings ${modelName}`,\n op: GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE,\n attributes: attributes as Record<string, SpanAttributeValue>,\n },\n () => {\n return Reflect.apply(target, thisArg, args).then(undefined, error => {\n captureException(error, {\n mechanism: { handled: false, type: 'auto.ai.langchain' },\n });\n throw error;\n });\n },\n );\n },\n }) as (...args: unknown[]) => Promise<unknown>;\n}\n\n/**\n * Wraps a LangChain embeddings instance to create Sentry spans for `embedQuery` and `embedDocuments` calls.\n *\n * Use this in non-Node runtimes (Cloudflare, browser, etc.) where auto-instrumentation is not available.\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/cloudflare';\n * import { OpenAIEmbeddings } from '@langchain/openai';\n *\n * const embeddings = Sentry.instrumentLangChainEmbeddings(\n * new OpenAIEmbeddings({ model: 'text-embedding-3-small' })\n * );\n *\n * await embeddings.embedQuery('Hello world');\n * await embeddings.embedDocuments(['doc1', 'doc2']);\n * ```\n */\nexport function instrumentLangChainEmbeddings<T extends object>(instance: T, options?: LangChainOptions): T {\n const embeddingsInstance = instance as Record<string, unknown>;\n\n if (typeof embeddingsInstance.embedQuery === 'function') {\n embeddingsInstance.embedQuery = instrumentEmbeddingMethod(\n embeddingsInstance.embedQuery as (...args: unknown[]) => Promise<unknown>,\n options,\n );\n }\n\n if (typeof embeddingsInstance.embedDocuments === 'function') {\n embeddingsInstance.embedDocuments = instrumentEmbeddingMethod(\n embeddingsInstance.embedDocuments as (...args: unknown[]) => Promise<unknown>,\n options,\n );\n }\n\n return instance;\n}\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","LANGCHAIN_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE","GEN_AI_OPERATION_NAME_ATTRIBUTE","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_SYSTEM_ATTRIBUTE","GEN_AI_REQUEST_DIMENSIONS_ATTRIBUTE","GEN_AI_REQUEST_ENCODING_FORMAT_ATTRIBUTE","resolveAIRecordingOptions","GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE","startSpan","capt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IAAA;AACA,YAAAS,0BAAA,CAAA,KAAA,EAAA;AACA,cAAA,SAAA,EAAA,EAAA,OAAA,EAAA,KAAA,EAAA,IAAA,EAAA,mBAAA,EAAA;AACA,aAAA,CAAA;AACA,YAAA,MAAA,KAAA;AACA,UAAA,CAAA,CAAA;AACA,QAAA,CAAA;AACA,OAAA;AACA,IAAA,CAAA;AACA,GAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,6BAAA,CAAA,QAAA,EAAA,OAAA,EAAA;AACA,EAAA,MAAA,kBAAA,GAAA,QAAA;;AAEA,EAAA,IAAA,OAAA,kBAAA,CAAA,UAAA,KAAA,UAAA,EAAA;AACA,IAAA,kBAAA,CAAA,UAAA,GAAA,yBAAA;AACA,MAAA,kBAAA,CAAA,UAAA;AACA,MAAA,OAAA;AACA,KAAA;AACA,EAAA;;AAEA,EAAA,IAAA,OAAA,kBAAA,CAAA,cAAA,KAAA,UAAA,EAAA;AACA,IAAA,kBAAA,CAAA,cAAA,GAAA,yBAAA;AACA,MAAA,kBAAA,CAAA,cAAA;AACA,MAAA,OAAA;AACA,KAAA;AACA,EAAA;;AAEA,EAAA,OAAA,QAAA;AACA;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const _exports = require('../../exports.js'); | ||
| const exports$1 = require('../../exports.js'); | ||
| const semanticAttributes = require('../../semanticAttributes.js'); | ||
@@ -174,3 +174,3 @@ const spanstatus = require('../spanstatus.js'); | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { | ||
@@ -249,3 +249,3 @@ handled: false, | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { | ||
@@ -328,3 +328,3 @@ handled: false, | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { | ||
@@ -331,0 +331,0 @@ handled: false, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/langchain/index.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types-hoist/span';\nimport {\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_TOOL_INPUT_ATTRIBUTE,\n GEN_AI_TOOL_NAME_ATTRIBUTE,\n GEN_AI_TOOL_OUTPUT_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport { resolveAIRecordingOptions, shouldEnableTruncation } from '../ai/utils';\nimport { LANGCHAIN_ORIGIN } from './constants';\nimport type {\n LangChainCallbackHandler,\n LangChainLLMResult,\n LangChainMessage,\n LangChainOptions,\n LangChainSerialized,\n} from './types';\nimport {\n extractChatModelRequestAttributes,\n extractLLMRequestAttributes,\n extractLlmResponseAttributes,\n extractToolDefinitions,\n getAgentNameFromMetadata,\n getInvocationParams,\n} from './utils';\n\n/**\n * Creates a Sentry callback handler for LangChain\n * Returns a plain object that LangChain will call via duck-typing\n *\n * This is a stateful handler that tracks spans across multiple LangChain executions.\n */\nexport function createLangChainCallbackHandler(options: LangChainOptions = {}): LangChainCallbackHandler {\n const { recordInputs, recordOutputs } = resolveAIRecordingOptions(options);\n const enableTruncation = shouldEnableTruncation(options.enableTruncation);\n\n // Internal state - single instance tracks all spans\n const spanMap = new Map<string, Span>();\n\n /**\n * Exit a span and clean up\n */\n const exitSpan = (runId: string): void => {\n const span = spanMap.get(runId);\n if (span?.isRecording()) {\n span.end();\n spanMap.delete(runId);\n }\n };\n\n /**\n * Handler for LLM Start\n * This handler will be called by LangChain's callback handler when an LLM event is detected.\n */\n const handler: LangChainCallbackHandler = {\n // Required LangChain BaseCallbackHandler properties\n lc_serializable: false,\n lc_namespace: ['langchain_core', 'callbacks', 'sentry'],\n lc_secrets: undefined,\n lc_attributes: undefined,\n lc_aliases: undefined,\n lc_serializable_keys: undefined,\n lc_id: ['langchain_core', 'callbacks', 'sentry'],\n lc_kwargs: {},\n name: 'SentryCallbackHandler',\n\n // BaseCallbackHandlerInput boolean flags\n ignoreLLM: false,\n ignoreChain: false,\n ignoreAgent: false,\n ignoreRetriever: false,\n ignoreCustomEvent: false,\n raiseError: false,\n awaitHandlers: true,\n\n handleLLMStart(\n llm: unknown,\n prompts: string[],\n runId: string,\n _parentRunId?: string,\n _extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n _runName?: string,\n ) {\n const invocationParams = getInvocationParams(tags);\n const attributes = extractLLMRequestAttributes(\n llm as LangChainSerialized,\n prompts,\n recordInputs,\n enableTruncation,\n invocationParams,\n metadata,\n );\n const modelName = attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE];\n const operationName = attributes[GEN_AI_OPERATION_NAME_ATTRIBUTE];\n\n startSpanManual(\n {\n name: `${operationName} ${modelName}`,\n op: 'gen_ai.chat',\n attributes: {\n ...getAgentNameFromMetadata(metadata),\n ...attributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'gen_ai.chat',\n },\n },\n span => {\n spanMap.set(runId, span);\n return span;\n },\n );\n },\n\n // Chat Model Start Handler\n handleChatModelStart(\n llm: unknown,\n messages: unknown,\n runId: string,\n _parentRunId?: string,\n extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n _runName?: string,\n ) {\n const invocationParams = getInvocationParams(tags);\n const attributes = extractChatModelRequestAttributes(\n llm as LangChainSerialized,\n messages as LangChainMessage[][],\n recordInputs,\n enableTruncation,\n invocationParams,\n metadata,\n );\n\n const toolDefsJson = extractToolDefinitions(extraParams);\n if (toolDefsJson) {\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = toolDefsJson;\n }\n\n const modelName = attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE];\n const operationName = attributes[GEN_AI_OPERATION_NAME_ATTRIBUTE];\n\n startSpanManual(\n {\n name: `${operationName} ${modelName}`,\n op: 'gen_ai.chat',\n attributes: {\n ...getAgentNameFromMetadata(metadata),\n ...attributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'gen_ai.chat',\n },\n },\n span => {\n spanMap.set(runId, span);\n return span;\n },\n );\n },\n\n // LLM End Handler - note: handleLLMEnd with capital LLM (used by both LLMs and chat models!)\n handleLLMEnd(\n output: unknown,\n runId: string,\n _parentRunId?: string,\n _tags?: string[],\n _extraParams?: Record<string, unknown>,\n ) {\n const span = spanMap.get(runId);\n if (span?.isRecording()) {\n const attributes = extractLlmResponseAttributes(output as LangChainLLMResult, recordOutputs);\n if (attributes) {\n span.setAttributes(attributes);\n }\n exitSpan(runId);\n }\n },\n\n // LLM Error Handler - note: handleLLMError with capital LLM\n handleLLMError(error: Error, runId: string) {\n const span = spanMap.get(runId);\n if (span?.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n exitSpan(runId);\n }\n\n captureException(error, {\n mechanism: {\n handled: false,\n type: `${LANGCHAIN_ORIGIN}.llm_error_handler`,\n },\n });\n },\n\n // Chain Start Handler\n handleChainStart(\n chain: { name?: string },\n inputs: Record<string, unknown>,\n runId: string,\n _parentRunId?: string,\n _tags?: string[],\n metadata?: Record<string, unknown>,\n _runType?: string,\n runName?: string,\n ) {\n // Skip chain spans when inside an agent context (createReactAgent).\n // The agent already creates an invoke_agent span; internal chain steps\n // (ChannelWrite, Branch, prompt, etc.) are noise.\n if (metadata?.__sentry_langgraph__) {\n return;\n }\n\n const chainName = runName || chain.name || 'unknown_chain';\n const attributes: Record<string, SpanAttributeValue> = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.langchain',\n 'langchain.chain.name': chainName,\n };\n\n if (recordInputs) {\n attributes['langchain.chain.inputs'] = JSON.stringify(inputs);\n }\n\n startSpanManual(\n {\n name: `chain ${chainName}`,\n op: 'gen_ai.invoke_agent',\n attributes: {\n ...attributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'gen_ai.invoke_agent',\n },\n },\n span => {\n spanMap.set(runId, span);\n return span;\n },\n );\n },\n\n // Chain End Handler\n handleChainEnd(outputs: unknown, runId: string) {\n const span = spanMap.get(runId);\n if (span?.isRecording()) {\n // Add outputs if recordOutputs is enabled\n if (recordOutputs) {\n span.setAttributes({\n 'langchain.chain.outputs': JSON.stringify(outputs),\n });\n }\n exitSpan(runId);\n }\n },\n\n // Chain Error Handler\n handleChainError(error: Error, runId: string) {\n const span = spanMap.get(runId);\n if (span?.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n exitSpan(runId);\n }\n\n captureException(error, {\n mechanism: {\n handled: false,\n type: `${LANGCHAIN_ORIGIN}.chain_error_handler`,\n },\n });\n },\n\n // Tool Start Handler\n handleToolStart(\n tool: { name?: string },\n input: string,\n runId: string,\n _parentRunId?: string,\n _tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string,\n ) {\n // Skip tool spans when inside an agent context (createReactAgent).\n // Tool spans are created by wrapToolsWithSpans with richer attributes.\n if (metadata?.__sentry_langgraph__) {\n return;\n }\n\n // runName is set to tool.name by LangChain's StructuredTool.call()\n const toolName = runName || tool.name || 'unknown_tool';\n const attributes: Record<string, SpanAttributeValue> = {\n ...getAgentNameFromMetadata(metadata),\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGCHAIN_ORIGIN,\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'execute_tool',\n [GEN_AI_TOOL_NAME_ATTRIBUTE]: toolName,\n };\n\n if (recordInputs) {\n attributes[GEN_AI_TOOL_INPUT_ATTRIBUTE] = input;\n }\n\n startSpanManual(\n {\n name: `execute_tool ${toolName}`,\n op: 'gen_ai.execute_tool',\n attributes: {\n ...attributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'gen_ai.execute_tool',\n },\n },\n span => {\n spanMap.set(runId, span);\n return span;\n },\n );\n },\n\n // Tool End Handler\n handleToolEnd(output: unknown, runId: string) {\n const span = spanMap.get(runId);\n if (span?.isRecording()) {\n if (recordOutputs) {\n // LangChain tools may return ToolMessage objects — extract the content\n const outputObj = output as Record<string, unknown> | undefined;\n const content =\n outputObj && typeof outputObj === 'object' && 'content' in outputObj ? outputObj.content : output;\n span.setAttributes({\n [GEN_AI_TOOL_OUTPUT_ATTRIBUTE]: typeof content === 'string' ? content : JSON.stringify(content),\n });\n }\n exitSpan(runId);\n }\n },\n\n // Tool Error Handler\n handleToolError(error: Error, runId: string) {\n const span = spanMap.get(runId);\n if (span?.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n exitSpan(runId);\n }\n\n captureException(error, {\n mechanism: {\n handled: false,\n type: `${LANGCHAIN_ORIGIN}.tool_error_handler`,\n },\n });\n },\n\n // LangChain BaseCallbackHandler required methods\n copy() {\n return handler;\n },\n\n toJSON() {\n return {\n lc: 1,\n type: 'not_implemented',\n id: handler.lc_id,\n };\n },\n\n toJSONNotImplemented() {\n return {\n lc: 1,\n type: 'not_implemented',\n id: handler.lc_id,\n };\n },\n };\n\n return handler;\n}\n\nexport { instrumentLangChainEmbeddings } from './embeddings';\n"],"names":["resolveAIRecordingOptions","shouldEnableTruncation","getInvocationParams","extractLLMRequestAttributes","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_OPERATION_NAME_ATTRIBUTE","startSpanManual","getAgentNameFromMetadata","SEMANTIC_ATTRIBUTE_SENTRY_OP","extractChatModelRequestAttributes","extractToolDefinitions","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","extractLlmRes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CAAA;AACA,QAAA,IAAA,EAAA,iBAAA;AACA,QAAA,EAAA,EAAA,OAAA,CAAA,KAAA;AACA,OAAA;AACA,IAAA,CAAA;AACA,GAAA;;AAEA,EAAA,OAAA,OAAA;AACA;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/langchain/index.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types-hoist/span';\nimport {\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_TOOL_INPUT_ATTRIBUTE,\n GEN_AI_TOOL_NAME_ATTRIBUTE,\n GEN_AI_TOOL_OUTPUT_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport { resolveAIRecordingOptions, shouldEnableTruncation } from '../ai/utils';\nimport { LANGCHAIN_ORIGIN } from './constants';\nimport type {\n LangChainCallbackHandler,\n LangChainLLMResult,\n LangChainMessage,\n LangChainOptions,\n LangChainSerialized,\n} from './types';\nimport {\n extractChatModelRequestAttributes,\n extractLLMRequestAttributes,\n extractLlmResponseAttributes,\n extractToolDefinitions,\n getAgentNameFromMetadata,\n getInvocationParams,\n} from './utils';\n\n/**\n * Creates a Sentry callback handler for LangChain\n * Returns a plain object that LangChain will call via duck-typing\n *\n * This is a stateful handler that tracks spans across multiple LangChain executions.\n */\nexport function createLangChainCallbackHandler(options: LangChainOptions = {}): LangChainCallbackHandler {\n const { recordInputs, recordOutputs } = resolveAIRecordingOptions(options);\n const enableTruncation = shouldEnableTruncation(options.enableTruncation);\n\n // Internal state - single instance tracks all spans\n const spanMap = new Map<string, Span>();\n\n /**\n * Exit a span and clean up\n */\n const exitSpan = (runId: string): void => {\n const span = spanMap.get(runId);\n if (span?.isRecording()) {\n span.end();\n spanMap.delete(runId);\n }\n };\n\n /**\n * Handler for LLM Start\n * This handler will be called by LangChain's callback handler when an LLM event is detected.\n */\n const handler: LangChainCallbackHandler = {\n // Required LangChain BaseCallbackHandler properties\n lc_serializable: false,\n lc_namespace: ['langchain_core', 'callbacks', 'sentry'],\n lc_secrets: undefined,\n lc_attributes: undefined,\n lc_aliases: undefined,\n lc_serializable_keys: undefined,\n lc_id: ['langchain_core', 'callbacks', 'sentry'],\n lc_kwargs: {},\n name: 'SentryCallbackHandler',\n\n // BaseCallbackHandlerInput boolean flags\n ignoreLLM: false,\n ignoreChain: false,\n ignoreAgent: false,\n ignoreRetriever: false,\n ignoreCustomEvent: false,\n raiseError: false,\n awaitHandlers: true,\n\n handleLLMStart(\n llm: unknown,\n prompts: string[],\n runId: string,\n _parentRunId?: string,\n _extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n _runName?: string,\n ) {\n const invocationParams = getInvocationParams(tags);\n const attributes = extractLLMRequestAttributes(\n llm as LangChainSerialized,\n prompts,\n recordInputs,\n enableTruncation,\n invocationParams,\n metadata,\n );\n const modelName = attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE];\n const operationName = attributes[GEN_AI_OPERATION_NAME_ATTRIBUTE];\n\n startSpanManual(\n {\n name: `${operationName} ${modelName}`,\n op: 'gen_ai.chat',\n attributes: {\n ...getAgentNameFromMetadata(metadata),\n ...attributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'gen_ai.chat',\n },\n },\n span => {\n spanMap.set(runId, span);\n return span;\n },\n );\n },\n\n // Chat Model Start Handler\n handleChatModelStart(\n llm: unknown,\n messages: unknown,\n runId: string,\n _parentRunId?: string,\n extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n _runName?: string,\n ) {\n const invocationParams = getInvocationParams(tags);\n const attributes = extractChatModelRequestAttributes(\n llm as LangChainSerialized,\n messages as LangChainMessage[][],\n recordInputs,\n enableTruncation,\n invocationParams,\n metadata,\n );\n\n const toolDefsJson = extractToolDefinitions(extraParams);\n if (toolDefsJson) {\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = toolDefsJson;\n }\n\n const modelName = attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE];\n const operationName = attributes[GEN_AI_OPERATION_NAME_ATTRIBUTE];\n\n startSpanManual(\n {\n name: `${operationName} ${modelName}`,\n op: 'gen_ai.chat',\n attributes: {\n ...getAgentNameFromMetadata(metadata),\n ...attributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'gen_ai.chat',\n },\n },\n span => {\n spanMap.set(runId, span);\n return span;\n },\n );\n },\n\n // LLM End Handler - note: handleLLMEnd with capital LLM (used by both LLMs and chat models!)\n handleLLMEnd(\n output: unknown,\n runId: string,\n _parentRunId?: string,\n _tags?: string[],\n _extraParams?: Record<string, unknown>,\n ) {\n const span = spanMap.get(runId);\n if (span?.isRecording()) {\n const attributes = extractLlmResponseAttributes(output as LangChainLLMResult, recordOutputs);\n if (attributes) {\n span.setAttributes(attributes);\n }\n exitSpan(runId);\n }\n },\n\n // LLM Error Handler - note: handleLLMError with capital LLM\n handleLLMError(error: Error, runId: string) {\n const span = spanMap.get(runId);\n if (span?.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n exitSpan(runId);\n }\n\n captureException(error, {\n mechanism: {\n handled: false,\n type: `${LANGCHAIN_ORIGIN}.llm_error_handler`,\n },\n });\n },\n\n // Chain Start Handler\n handleChainStart(\n chain: { name?: string },\n inputs: Record<string, unknown>,\n runId: string,\n _parentRunId?: string,\n _tags?: string[],\n metadata?: Record<string, unknown>,\n _runType?: string,\n runName?: string,\n ) {\n // Skip chain spans when inside an agent context (createReactAgent).\n // The agent already creates an invoke_agent span; internal chain steps\n // (ChannelWrite, Branch, prompt, etc.) are noise.\n if (metadata?.__sentry_langgraph__) {\n return;\n }\n\n const chainName = runName || chain.name || 'unknown_chain';\n const attributes: Record<string, SpanAttributeValue> = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.langchain',\n 'langchain.chain.name': chainName,\n };\n\n if (recordInputs) {\n attributes['langchain.chain.inputs'] = JSON.stringify(inputs);\n }\n\n startSpanManual(\n {\n name: `chain ${chainName}`,\n op: 'gen_ai.invoke_agent',\n attributes: {\n ...attributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'gen_ai.invoke_agent',\n },\n },\n span => {\n spanMap.set(runId, span);\n return span;\n },\n );\n },\n\n // Chain End Handler\n handleChainEnd(outputs: unknown, runId: string) {\n const span = spanMap.get(runId);\n if (span?.isRecording()) {\n // Add outputs if recordOutputs is enabled\n if (recordOutputs) {\n span.setAttributes({\n 'langchain.chain.outputs': JSON.stringify(outputs),\n });\n }\n exitSpan(runId);\n }\n },\n\n // Chain Error Handler\n handleChainError(error: Error, runId: string) {\n const span = spanMap.get(runId);\n if (span?.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n exitSpan(runId);\n }\n\n captureException(error, {\n mechanism: {\n handled: false,\n type: `${LANGCHAIN_ORIGIN}.chain_error_handler`,\n },\n });\n },\n\n // Tool Start Handler\n handleToolStart(\n tool: { name?: string },\n input: string,\n runId: string,\n _parentRunId?: string,\n _tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string,\n ) {\n // Skip tool spans when inside an agent context (createReactAgent).\n // Tool spans are created by wrapToolsWithSpans with richer attributes.\n if (metadata?.__sentry_langgraph__) {\n return;\n }\n\n // runName is set to tool.name by LangChain's StructuredTool.call()\n const toolName = runName || tool.name || 'unknown_tool';\n const attributes: Record<string, SpanAttributeValue> = {\n ...getAgentNameFromMetadata(metadata),\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGCHAIN_ORIGIN,\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'execute_tool',\n [GEN_AI_TOOL_NAME_ATTRIBUTE]: toolName,\n };\n\n if (recordInputs) {\n attributes[GEN_AI_TOOL_INPUT_ATTRIBUTE] = input;\n }\n\n startSpanManual(\n {\n name: `execute_tool ${toolName}`,\n op: 'gen_ai.execute_tool',\n attributes: {\n ...attributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'gen_ai.execute_tool',\n },\n },\n span => {\n spanMap.set(runId, span);\n return span;\n },\n );\n },\n\n // Tool End Handler\n handleToolEnd(output: unknown, runId: string) {\n const span = spanMap.get(runId);\n if (span?.isRecording()) {\n if (recordOutputs) {\n // LangChain tools may return ToolMessage objects — extract the content\n const outputObj = output as Record<string, unknown> | undefined;\n const content =\n outputObj && typeof outputObj === 'object' && 'content' in outputObj ? outputObj.content : output;\n span.setAttributes({\n [GEN_AI_TOOL_OUTPUT_ATTRIBUTE]: typeof content === 'string' ? content : JSON.stringify(content),\n });\n }\n exitSpan(runId);\n }\n },\n\n // Tool Error Handler\n handleToolError(error: Error, runId: string) {\n const span = spanMap.get(runId);\n if (span?.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n exitSpan(runId);\n }\n\n captureException(error, {\n mechanism: {\n handled: false,\n type: `${LANGCHAIN_ORIGIN}.tool_error_handler`,\n },\n });\n },\n\n // LangChain BaseCallbackHandler required methods\n copy() {\n return handler;\n },\n\n toJSON() {\n return {\n lc: 1,\n type: 'not_implemented',\n id: handler.lc_id,\n };\n },\n\n toJSONNotImplemented() {\n return {\n lc: 1,\n type: 'not_implemented',\n id: handler.lc_id,\n };\n },\n };\n\n return handler;\n}\n\nexport { instrumentLangChainEmbeddings } from './embeddings';\n"],"names":["resolveAIRecordingOptions","shouldEnableTruncation","getInvocationParams","extractLLMRequestAttributes","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_OPERATION_NAME_ATTRIBUTE","startSpanManual","getAgentNameFromMetadata","SEMANTIC_ATTRIBUTE_SENTRY_OP","extractChatModelRequestAttributes","extractToolDefinitions","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","extractLlmResponseAttributes","SPAN_STATUS_ERROR","captureException","LANGCHAIN_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","GEN_AI_TOOL_NAME_ATTRIBUTE","GEN_AI_TOOL_INPUT_ATTRIBUTE","GEN_AI_TOOL_OUTPUT_ATTRIBUTE"],"mappings":";;;;;;;;;;;AAAA;;AAgCA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,8BAA8B,CAAC,OAAO,GAAqB,EAAE,EAA4B;AACzG,EAAE,MAAM,EAAE,YAAY,EAAE,aAAA,KAAkBA,+BAAyB,CAAC,OAAO,CAAC;AAC5E,EAAE,MAAM,mBAAmBC,4BAAsB,CAAC,OAAO,CAAC,gBAAgB,CAAC;;AAE3E;AACA,EAAE,MAAM,OAAA,GAAU,IAAI,GAAG,EAAgB;;AAEzC;AACA;AACA;AACA,EAAE,MAAM,QAAA,GAAW,CAAC,KAAK,KAAmB;AAC5C,IAAI,MAAM,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;AACnC,IAAI,IAAI,IAAI,EAAE,WAAW,EAAE,EAAE;AAC7B,MAAM,IAAI,CAAC,GAAG,EAAE;AAChB,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;AAC3B,IAAI;AACJ,EAAE,CAAC;;AAEH;AACA;AACA;AACA;AACA,EAAE,MAAM,OAAO,GAA6B;AAC5C;AACA,IAAI,eAAe,EAAE,KAAK;AAC1B,IAAI,YAAY,EAAE,CAAC,gBAAgB,EAAE,WAAW,EAAE,QAAQ,CAAC;AAC3D,IAAI,UAAU,EAAE,SAAS;AACzB,IAAI,aAAa,EAAE,SAAS;AAC5B,IAAI,UAAU,EAAE,SAAS;AACzB,IAAI,oBAAoB,EAAE,SAAS;AACnC,IAAI,KAAK,EAAE,CAA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AA,EAAA,EAAA,OAAA,CAAA,KAAA;AACA,OAAA;AACA,IAAA,CAAA;;AAEA,IAAA,oBAAA,GAAA;AACA,MAAA,OAAA;AACA,QAAA,EAAA,EAAA,CAAA;AACA,QAAA,IAAA,EAAA,iBAAA;AACA,QAAA,EAAA,EAAA,OAAA,CAAA,KAAA;AACA,OAAA;AACA,IAAA,CAAA;AACA,GAAA;;AAEA,EAAA,OAAA,OAAA;AACA;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const _exports = require('../../exports.js'); | ||
| const exports$1 = require('../../exports.js'); | ||
| const semanticAttributes = require('../../semanticAttributes.js'); | ||
@@ -80,3 +80,3 @@ const spanstatus = require('../spanstatus.js'); | ||
| span.setStatus({ code: spanstatus.SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { | ||
@@ -202,3 +202,3 @@ handled: false, | ||
| span.setStatus({ code: spanstatus.SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { | ||
@@ -205,0 +205,0 @@ handled: false, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/langgraph/index.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport {\n GEN_AI_AGENT_NAME_ATTRIBUTE,\n GEN_AI_CONVERSATION_ID_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_PIPELINE_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport {\n extractSystemInstructions,\n getJsonString,\n getTruncatedJsonString,\n resolveAIRecordingOptions,\n shouldEnableTruncation,\n} from '../ai/utils';\nimport { createLangChainCallbackHandler } from '../langchain';\nimport type { BaseChatModel, LangChainMessage } from '../langchain/types';\nimport { normalizeLangChainMessages } from '../langchain/utils';\nimport { startSpan } from '../trace';\nimport { LANGGRAPH_ORIGIN } from './constants';\nimport type { CompiledGraph, LangGraphOptions } from './types';\nimport {\n extractAgentNameFromParams,\n extractLLMFromParams,\n extractToolsFromCompiledGraph,\n mergeSentryCallback,\n setResponseAttributes,\n wrapToolsWithSpans,\n} from './utils';\n\nlet _insideCreateReactAgent = false;\n\nconst SENTRY_PATCHED = '__sentry_patched__';\n\n/**\n * Instruments StateGraph's compile method to create spans for agent creation and invocation\n *\n * Wraps the compile() method to:\n * - Create a `gen_ai.create_agent` span when compile() is called\n * - Automatically wrap the invoke() method on the returned compiled graph with a `gen_ai.invoke_agent` span\n *\n */\nexport function instrumentStateGraphCompile(\n originalCompile: (...args: unknown[]) => CompiledGraph,\n options: LangGraphOptions,\n): (...args: unknown[]) => CompiledGraph {\n if (Object.prototype.hasOwnProperty.call(originalCompile, SENTRY_PATCHED)) {\n return originalCompile;\n }\n\n const sentryHandler = createLangChainCallbackHandler(options);\n\n const wrapped = new Proxy(originalCompile, {\n apply(target, thisArg, args: unknown[]): CompiledGraph {\n // Skip when called from within createReactAgent to avoid duplicate instrumentation\n if (_insideCreateReactAgent) {\n return Reflect.apply(target, thisArg, args);\n }\n\n return startSpan(\n {\n op: 'gen_ai.create_agent',\n name: 'create_agent',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGGRAPH_ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'gen_ai.create_agent',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'create_agent',\n },\n },\n span => {\n try {\n const compiledGraph = Reflect.apply(target, thisArg, args);\n const compileOptions = args.length > 0 ? (args[0] as Record<string, unknown>) : {};\n\n // Extract graph name\n if (compileOptions?.name && typeof compileOptions.name === 'string') {\n span.setAttribute(GEN_AI_AGENT_NAME_ATTRIBUTE, compileOptions.name);\n span.updateName(`create_agent ${compileOptions.name}`);\n }\n\n // Instrument agent invoke method on the compiled graph\n const originalInvoke = compiledGraph.invoke;\n if (originalInvoke && typeof originalInvoke === 'function') {\n compiledGraph.invoke = instrumentCompiledGraphInvoke(\n originalInvoke.bind(compiledGraph) as (...args: unknown[]) => Promise<unknown>,\n compiledGraph,\n compileOptions,\n options,\n undefined,\n sentryHandler,\n ) as typeof originalInvoke;\n }\n\n return compiledGraph;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.langgraph.error',\n },\n });\n throw error;\n }\n },\n );\n },\n }) as (...args: unknown[]) => CompiledGraph;\n\n Object.defineProperty(wrapped, SENTRY_PATCHED, { value: true, enumerable: false });\n return wrapped;\n}\n\n/**\n * Instruments CompiledGraph's invoke method to create spans for agent invocation\n *\n * Creates a `gen_ai.invoke_agent` span when invoke() is called\n */\nfunction instrumentCompiledGraphInvoke(\n originalInvoke: (...args: unknown[]) => Promise<unknown>,\n graphInstance: CompiledGraph,\n compileOptions: Record<string, unknown>,\n options: LangGraphOptions,\n llm?: BaseChatModel | null,\n sentryCallbackHandler?: unknown,\n): (...args: unknown[]) => Promise<unknown> {\n return new Proxy(originalInvoke, {\n apply(target, thisArg, args: unknown[]): Promise<unknown> {\n const modelName = llm?.modelName ?? llm?.model;\n return startSpan(\n {\n op: 'gen_ai.invoke_agent',\n name: 'invoke_agent',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGGRAPH_ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE,\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'invoke_agent',\n },\n },\n async span => {\n try {\n const graphName = compileOptions?.name;\n\n if (graphName && typeof graphName === 'string') {\n span.setAttribute(GEN_AI_PIPELINE_NAME_ATTRIBUTE, graphName);\n span.setAttribute(GEN_AI_AGENT_NAME_ATTRIBUTE, graphName);\n span.updateName(`invoke_agent ${graphName}`);\n }\n\n if (modelName) {\n span.setAttribute(GEN_AI_REQUEST_MODEL_ATTRIBUTE, modelName);\n }\n\n // Extract thread_id from the config (second argument)\n // LangGraph uses config.configurable.thread_id for conversation/session linking\n const config = args.length > 1 ? (args[1] as Record<string, unknown> | undefined) : undefined;\n const configurable = config?.configurable as Record<string, unknown> | undefined;\n const threadId = configurable?.thread_id;\n if (threadId && typeof threadId === 'string') {\n span.setAttribute(GEN_AI_CONVERSATION_ID_ATTRIBUTE, threadId);\n }\n\n // Inject callback handler and agent name into invoke config\n if (sentryCallbackHandler) {\n const invokeConfig = (args[1] ?? {}) as Record<string, unknown>;\n args[1] = invokeConfig;\n\n const existingMetadata = (invokeConfig.metadata ?? {}) as Record<string, unknown>;\n invokeConfig.metadata = {\n ...existingMetadata,\n __sentry_langgraph__: true,\n ...(typeof graphName === 'string' ? { lc_agent_name: graphName } : {}),\n };\n\n invokeConfig.callbacks = mergeSentryCallback(invokeConfig.callbacks, sentryCallbackHandler);\n }\n\n // Extract available tools from the graph instance\n const tools = extractToolsFromCompiledGraph(graphInstance);\n if (tools) {\n span.setAttribute(GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE, JSON.stringify(tools));\n }\n\n // Parse input messages\n const recordInputs = options.recordInputs;\n const recordOutputs = options.recordOutputs;\n const inputMessages =\n args.length > 0 ? ((args[0] as { messages?: LangChainMessage[] } | null)?.messages ?? []) : [];\n\n if (inputMessages && recordInputs) {\n const normalizedMessages = normalizeLangChainMessages(inputMessages);\n const { systemInstructions, filteredMessages } = extractSystemInstructions(normalizedMessages);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n const enableTruncation = shouldEnableTruncation(options.enableTruncation);\n const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 0;\n span.setAttributes({\n [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: enableTruncation\n ? getTruncatedJsonString(filteredMessages)\n : getJsonString(filteredMessages),\n [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: filteredLength,\n });\n }\n\n // Call original invoke\n const result = await Reflect.apply(target, thisArg, args);\n\n if (recordOutputs) {\n setResponseAttributes(span, inputMessages ?? null, result);\n }\n\n return result;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.langgraph.error',\n },\n });\n throw error;\n }\n },\n );\n },\n }) as (...args: unknown[]) => Promise<unknown>;\n}\n\n/**\n * Instruments createReactAgent to create invoke_agent and execute_tool spans.\n */\nexport function instrumentCreateReactAgent(\n originalCreateReactAgent: (...args: unknown[]) => CompiledGraph,\n options?: LangGraphOptions,\n): (...args: unknown[]) => CompiledGraph {\n if (Object.prototype.hasOwnProperty.call(originalCreateReactAgent, SENTRY_PATCHED)) {\n return originalCreateReactAgent;\n }\n\n const resolvedOptions = resolveAIRecordingOptions(options);\n const sentryHandler = createLangChainCallbackHandler(resolvedOptions);\n\n const wrapped = new Proxy(originalCreateReactAgent, {\n apply(target, thisArg, args: unknown[]): CompiledGraph {\n const llm = extractLLMFromParams(args);\n const agentName = extractAgentNameFromParams(args);\n\n // Wrap tools with execute_tool spans (direct access gives us name, type, description)\n const params = args[0] as Record<string, unknown> | undefined;\n if (params && Array.isArray(params.tools) && params.tools.length > 0) {\n wrapToolsWithSpans(params.tools, resolvedOptions, agentName ?? undefined);\n }\n\n // Suppress StateGraph.compile instrumentation inside createReactAgent\n _insideCreateReactAgent = true;\n let compiledGraph: CompiledGraph;\n try {\n compiledGraph = Reflect.apply(target, thisArg, args);\n } finally {\n _insideCreateReactAgent = false;\n }\n\n // Wrap invoke() on the returned compiled graph\n const originalInvoke = compiledGraph.invoke;\n if (originalInvoke && typeof originalInvoke === 'function') {\n const compileOptions: Record<string, unknown> = {};\n if (agentName) {\n compileOptions.name = agentName;\n }\n\n compiledGraph.invoke = instrumentCompiledGraphInvoke(\n originalInvoke.bind(compiledGraph) as (...args: unknown[]) => Promise<unknown>,\n compiledGraph,\n compileOptions,\n resolvedOptions,\n llm,\n sentryHandler,\n ) as typeof originalInvoke;\n }\n\n return compiledGraph;\n },\n }) as (...args: unknown[]) => CompiledGraph;\n\n Object.defineProperty(wrapped, SENTRY_PATCHED, { value: true, enumerable: false });\n return wrapped;\n}\n\n/**\n * Directly instruments a StateGraph instance to add tracing spans\n *\n * This function can be used to manually instrument LangGraph StateGraph instances\n * in environments where automatic instrumentation is not available or desired.\n *\n * @param stateGraph - The StateGraph instance to instrument\n * @param options - Optional configuration for recording inputs/outputs\n *\n * @example\n * ```typescript\n * import { instrumentLangGraph } from '@sentry/cloudflare';\n * import { StateGraph } from '@langchain/langgraph';\n *\n * const graph = new StateGraph(MessagesAnnotation)\n * .addNode('agent', mockLlm)\n * .addEdge(START, 'agent')\n * .addEdge('agent', END);\n *\n * instrumentLangGraph(graph, { recordInputs: true, recordOutputs: true });\n * const compiled = graph.compile({ name: 'my_agent' });\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function instrumentLangGraph<T extends { compile: (...args: any[]) => any }>(\n stateGraph: T,\n options?: LangGraphOptions,\n): T {\n stateGraph.compile = instrumentStateGraphCompile(stateGraph.compile, resolveAIRecordingOptions(options));\n\n return stateGraph;\n}\n"],"names":["createLangChainCallbackHandler","startSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","LANGGRAPH_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","GEN_AI_OPERATION_NAME_ATTRIBUTE","GEN_AI_AGENT_NAME_ATTRIBUTE","SPAN_STATUS_ERROR","captureException","GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE","GEN_AI_PIPELINE_NAME_ATTRIBUTE","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_CONVERSATION_ID_ATTRIBUTE","mergeSentryCallback","extractToolsFromCompiledGraph","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","normalizeLangChainMessages","extractSystemInstructions","GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE","shouldEnableTruncation","GEN_AI_INPUT_MESSAGES_ATTRIBUTE","getTruncatedJsonString","getJsonString","GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE","setResponseAttributes","resolveAIRecordingOptions","extractLLMFromParams","extractAgentNameFromParams","wrapToolsWithSpans"],"mappings":";;;;;;;;;;;;;AAqCA,IAAI,uBAAA,GAA0B,KAAK;;AAEnC,MAAM,cAAA,GAAiB,oBAAoB;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,2BAA2B;AAC3C,EAAE,eAAe;AACjB,EAAE,OAAO;AACT,EAAyC;AACzC,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,EAAE;AAC7E,IAAI,OAAO,eAAe;AAC1B,EAAE;;AAEF,EAAE,MAAM,aAAA,GAAgBA,oCAA8B,CAAC,OAAO,CAAC;;AAE/D,EAAE,MAAM,OAAA,GAAU,IAAI,KAAK,CAAC,eAAe,EAAE;AAC7C,IAAI,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAA4B;AAC3D;AACA,MAAM,IAAI,uBAAuB,EAAE;AACnC,QAAQ,OAAO,OAAO,CAAC,KAAK,CAAC,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sources":["../../../../src/tracing/langgraph/index.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport {\n GEN_AI_AGENT_NAME_ATTRIBUTE,\n GEN_AI_CONVERSATION_ID_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_PIPELINE_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport {\n extractSystemInstructions,\n getJsonString,\n getTruncatedJsonString,\n resolveAIRecordingOptions,\n shouldEnableTruncation,\n} from '../ai/utils';\nimport { createLangChainCallbackHandler } from '../langchain';\nimport type { BaseChatModel, LangChainMessage } from '../langchain/types';\nimport { normalizeLangChainMessages } from '../langchain/utils';\nimport { startSpan } from '../trace';\nimport { LANGGRAPH_ORIGIN } from './constants';\nimport type { CompiledGraph, LangGraphOptions } from './types';\nimport {\n extractAgentNameFromParams,\n extractLLMFromParams,\n extractToolsFromCompiledGraph,\n mergeSentryCallback,\n setResponseAttributes,\n wrapToolsWithSpans,\n} from './utils';\n\nlet _insideCreateReactAgent = false;\n\nconst SENTRY_PATCHED = '__sentry_patched__';\n\n/**\n * Instruments StateGraph's compile method to create spans for agent creation and invocation\n *\n * Wraps the compile() method to:\n * - Create a `gen_ai.create_agent` span when compile() is called\n * - Automatically wrap the invoke() method on the returned compiled graph with a `gen_ai.invoke_agent` span\n *\n */\nexport function instrumentStateGraphCompile(\n originalCompile: (...args: unknown[]) => CompiledGraph,\n options: LangGraphOptions,\n): (...args: unknown[]) => CompiledGraph {\n if (Object.prototype.hasOwnProperty.call(originalCompile, SENTRY_PATCHED)) {\n return originalCompile;\n }\n\n const sentryHandler = createLangChainCallbackHandler(options);\n\n const wrapped = new Proxy(originalCompile, {\n apply(target, thisArg, args: unknown[]): CompiledGraph {\n // Skip when called from within createReactAgent to avoid duplicate instrumentation\n if (_insideCreateReactAgent) {\n return Reflect.apply(target, thisArg, args);\n }\n\n return startSpan(\n {\n op: 'gen_ai.create_agent',\n name: 'create_agent',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGGRAPH_ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'gen_ai.create_agent',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'create_agent',\n },\n },\n span => {\n try {\n const compiledGraph = Reflect.apply(target, thisArg, args);\n const compileOptions = args.length > 0 ? (args[0] as Record<string, unknown>) : {};\n\n // Extract graph name\n if (compileOptions?.name && typeof compileOptions.name === 'string') {\n span.setAttribute(GEN_AI_AGENT_NAME_ATTRIBUTE, compileOptions.name);\n span.updateName(`create_agent ${compileOptions.name}`);\n }\n\n // Instrument agent invoke method on the compiled graph\n const originalInvoke = compiledGraph.invoke;\n if (originalInvoke && typeof originalInvoke === 'function') {\n compiledGraph.invoke = instrumentCompiledGraphInvoke(\n originalInvoke.bind(compiledGraph) as (...args: unknown[]) => Promise<unknown>,\n compiledGraph,\n compileOptions,\n options,\n undefined,\n sentryHandler,\n ) as typeof originalInvoke;\n }\n\n return compiledGraph;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.langgraph.error',\n },\n });\n throw error;\n }\n },\n );\n },\n }) as (...args: unknown[]) => CompiledGraph;\n\n Object.defineProperty(wrapped, SENTRY_PATCHED, { value: true, enumerable: false });\n return wrapped;\n}\n\n/**\n * Instruments CompiledGraph's invoke method to create spans for agent invocation\n *\n * Creates a `gen_ai.invoke_agent` span when invoke() is called\n */\nfunction instrumentCompiledGraphInvoke(\n originalInvoke: (...args: unknown[]) => Promise<unknown>,\n graphInstance: CompiledGraph,\n compileOptions: Record<string, unknown>,\n options: LangGraphOptions,\n llm?: BaseChatModel | null,\n sentryCallbackHandler?: unknown,\n): (...args: unknown[]) => Promise<unknown> {\n return new Proxy(originalInvoke, {\n apply(target, thisArg, args: unknown[]): Promise<unknown> {\n const modelName = llm?.modelName ?? llm?.model;\n return startSpan(\n {\n op: 'gen_ai.invoke_agent',\n name: 'invoke_agent',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGGRAPH_ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE,\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'invoke_agent',\n },\n },\n async span => {\n try {\n const graphName = compileOptions?.name;\n\n if (graphName && typeof graphName === 'string') {\n span.setAttribute(GEN_AI_PIPELINE_NAME_ATTRIBUTE, graphName);\n span.setAttribute(GEN_AI_AGENT_NAME_ATTRIBUTE, graphName);\n span.updateName(`invoke_agent ${graphName}`);\n }\n\n if (modelName) {\n span.setAttribute(GEN_AI_REQUEST_MODEL_ATTRIBUTE, modelName);\n }\n\n // Extract thread_id from the config (second argument)\n // LangGraph uses config.configurable.thread_id for conversation/session linking\n const config = args.length > 1 ? (args[1] as Record<string, unknown> | undefined) : undefined;\n const configurable = config?.configurable as Record<string, unknown> | undefined;\n const threadId = configurable?.thread_id;\n if (threadId && typeof threadId === 'string') {\n span.setAttribute(GEN_AI_CONVERSATION_ID_ATTRIBUTE, threadId);\n }\n\n // Inject callback handler and agent name into invoke config\n if (sentryCallbackHandler) {\n const invokeConfig = (args[1] ?? {}) as Record<string, unknown>;\n args[1] = invokeConfig;\n\n const existingMetadata = (invokeConfig.metadata ?? {}) as Record<string, unknown>;\n invokeConfig.metadata = {\n ...existingMetadata,\n __sentry_langgraph__: true,\n ...(typeof graphName === 'string' ? { lc_agent_name: graphName } : {}),\n };\n\n invokeConfig.callbacks = mergeSentryCallback(invokeConfig.callbacks, sentryCallbackHandler);\n }\n\n // Extract available tools from the graph instance\n const tools = extractToolsFromCompiledGraph(graphInstance);\n if (tools) {\n span.setAttribute(GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE, JSON.stringify(tools));\n }\n\n // Parse input messages\n const recordInputs = options.recordInputs;\n const recordOutputs = options.recordOutputs;\n const inputMessages =\n args.length > 0 ? ((args[0] as { messages?: LangChainMessage[] } | null)?.messages ?? []) : [];\n\n if (inputMessages && recordInputs) {\n const normalizedMessages = normalizeLangChainMessages(inputMessages);\n const { systemInstructions, filteredMessages } = extractSystemInstructions(normalizedMessages);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n const enableTruncation = shouldEnableTruncation(options.enableTruncation);\n const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 0;\n span.setAttributes({\n [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: enableTruncation\n ? getTruncatedJsonString(filteredMessages)\n : getJsonString(filteredMessages),\n [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: filteredLength,\n });\n }\n\n // Call original invoke\n const result = await Reflect.apply(target, thisArg, args);\n\n if (recordOutputs) {\n setResponseAttributes(span, inputMessages ?? null, result);\n }\n\n return result;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.langgraph.error',\n },\n });\n throw error;\n }\n },\n );\n },\n }) as (...args: unknown[]) => Promise<unknown>;\n}\n\n/**\n * Instruments createReactAgent to create invoke_agent and execute_tool spans.\n */\nexport function instrumentCreateReactAgent(\n originalCreateReactAgent: (...args: unknown[]) => CompiledGraph,\n options?: LangGraphOptions,\n): (...args: unknown[]) => CompiledGraph {\n if (Object.prototype.hasOwnProperty.call(originalCreateReactAgent, SENTRY_PATCHED)) {\n return originalCreateReactAgent;\n }\n\n const resolvedOptions = resolveAIRecordingOptions(options);\n const sentryHandler = createLangChainCallbackHandler(resolvedOptions);\n\n const wrapped = new Proxy(originalCreateReactAgent, {\n apply(target, thisArg, args: unknown[]): CompiledGraph {\n const llm = extractLLMFromParams(args);\n const agentName = extractAgentNameFromParams(args);\n\n // Wrap tools with execute_tool spans (direct access gives us name, type, description)\n const params = args[0] as Record<string, unknown> | undefined;\n if (params && Array.isArray(params.tools) && params.tools.length > 0) {\n wrapToolsWithSpans(params.tools, resolvedOptions, agentName ?? undefined);\n }\n\n // Suppress StateGraph.compile instrumentation inside createReactAgent\n _insideCreateReactAgent = true;\n let compiledGraph: CompiledGraph;\n try {\n compiledGraph = Reflect.apply(target, thisArg, args);\n } finally {\n _insideCreateReactAgent = false;\n }\n\n // Wrap invoke() on the returned compiled graph\n const originalInvoke = compiledGraph.invoke;\n if (originalInvoke && typeof originalInvoke === 'function') {\n const compileOptions: Record<string, unknown> = {};\n if (agentName) {\n compileOptions.name = agentName;\n }\n\n compiledGraph.invoke = instrumentCompiledGraphInvoke(\n originalInvoke.bind(compiledGraph) as (...args: unknown[]) => Promise<unknown>,\n compiledGraph,\n compileOptions,\n resolvedOptions,\n llm,\n sentryHandler,\n ) as typeof originalInvoke;\n }\n\n return compiledGraph;\n },\n }) as (...args: unknown[]) => CompiledGraph;\n\n Object.defineProperty(wrapped, SENTRY_PATCHED, { value: true, enumerable: false });\n return wrapped;\n}\n\n/**\n * Directly instruments a StateGraph instance to add tracing spans\n *\n * This function can be used to manually instrument LangGraph StateGraph instances\n * in environments where automatic instrumentation is not available or desired.\n *\n * @param stateGraph - The StateGraph instance to instrument\n * @param options - Optional configuration for recording inputs/outputs\n *\n * @example\n * ```typescript\n * import { instrumentLangGraph } from '@sentry/cloudflare';\n * import { StateGraph } from '@langchain/langgraph';\n *\n * const graph = new StateGraph(MessagesAnnotation)\n * .addNode('agent', mockLlm)\n * .addEdge(START, 'agent')\n * .addEdge('agent', END);\n *\n * instrumentLangGraph(graph, { recordInputs: true, recordOutputs: true });\n * const compiled = graph.compile({ name: 'my_agent' });\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function instrumentLangGraph<T extends { compile: (...args: any[]) => any }>(\n stateGraph: T,\n options?: LangGraphOptions,\n): T {\n stateGraph.compile = instrumentStateGraphCompile(stateGraph.compile, resolveAIRecordingOptions(options));\n\n return stateGraph;\n}\n"],"names":["createLangChainCallbackHandler","startSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","LANGGRAPH_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","GEN_AI_OPERATION_NAME_ATTRIBUTE","GEN_AI_AGENT_NAME_ATTRIBUTE","SPAN_STATUS_ERROR","captureException","GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE","GEN_AI_PIPELINE_NAME_ATTRIBUTE","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_CONVERSATION_ID_ATTRIBUTE","mergeSentryCallback","extractToolsFromCompiledGraph","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","normalizeLangChainMessages","extractSystemInstructions","GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE","shouldEnableTruncation","GEN_AI_INPUT_MESSAGES_ATTRIBUTE","getTruncatedJsonString","getJsonString","GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE","setResponseAttributes","resolveAIRecordingOptions","extractLLMFromParams","extractAgentNameFromParams","wrapToolsWithSpans"],"mappings":";;;;;;;;;;;;;AAqCA,IAAI,uBAAA,GAA0B,KAAK;;AAEnC,MAAM,cAAA,GAAiB,oBAAoB;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,2BAA2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,EAAA,cAAA,EAAA,EAAA,KAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,CAAA;AACA,EAAA,OAAA,OAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,mBAAA;AACA,EAAA,UAAA;AACA,EAAA,OAAA;AACA,EAAA;AACA,EAAA,UAAA,CAAA,OAAA,GAAA,2BAAA,CAAA,UAAA,CAAA,OAAA,EAAAH,+BAAA,CAAA,OAAA,CAAA,CAAA;;AAEA,EAAA,OAAA,UAAA;AACA;;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const _exports = require('../../exports.js'); | ||
| const exports$1 = require('../../exports.js'); | ||
| const semanticAttributes = require('../../semanticAttributes.js'); | ||
@@ -126,3 +126,3 @@ const spanstatus = require('../spanstatus.js'); | ||
| span.setStatus({ code: spanstatus.SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { | ||
@@ -129,0 +129,0 @@ handled: false, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"utils.js","sources":["../../../../src/tracing/langgraph/utils.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport type { Span, SpanAttributes } from '../../types-hoist/span';\nimport {\n GEN_AI_AGENT_NAME_ATTRIBUTE,\n GEN_AI_EXECUTE_TOOL_OPERATION_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_TEXT_ATTRIBUTE,\n GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n GEN_AI_TOOL_CALL_ID_ATTRIBUTE,\n GEN_AI_TOOL_INPUT_ATTRIBUTE,\n GEN_AI_TOOL_OUTPUT_ATTRIBUTE,\n GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE,\n GEN_AI_TOOL_NAME_ATTRIBUTE,\n GEN_AI_TOOL_TYPE_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { BaseChatModel, LangChainMessage } from '../langchain/types';\nimport { normalizeLangChainMessages } from '../langchain/utils';\nimport { startSpan } from '../trace';\nimport { LANGGRAPH_ORIGIN } from './constants';\nimport type { CompiledGraph, LangGraphOptions, LangGraphTool } from './types';\n\n/**\n * Extract LLM model object from createReactAgent params\n */\nexport function extractLLMFromParams(args: unknown[]): BaseChatModel | null {\n const arg = args[0];\n if (typeof arg !== 'object' || !arg || !('llm' in arg) || !arg.llm || typeof arg.llm !== 'object') {\n return null;\n }\n const llm = arg.llm as BaseChatModel;\n if (typeof llm.modelName !== 'string' && typeof llm.model !== 'string') {\n return null;\n }\n return llm;\n}\n\n/**\n * Extract agent name from createReactAgent params\n */\nexport function extractAgentNameFromParams(args: unknown[]): string | null {\n const arg = args[0];\n if (typeof arg === 'object' && !!arg && 'name' in arg && typeof arg.name === 'string') {\n return arg.name;\n }\n return null;\n}\n\n/**\n * Wraps an array of LangChain tools so each invocation creates a gen_ai.execute_tool span.\n *\n * Wraps each tool's invoke() method in place. A marker prevents double-wrapping.\n */\nexport function wrapToolsWithSpans(tools: unknown[], options: LangGraphOptions, agentName?: string): unknown[] {\n const SENTRY_WRAPPED = '__sentry_tool_wrapped__';\n\n for (const tool of tools) {\n if (!tool || typeof tool !== 'object') {\n continue;\n }\n\n const t = tool as Record<string, unknown>;\n const originalInvoke = t.invoke;\n if (typeof originalInvoke !== 'function' || Object.prototype.hasOwnProperty.call(t, SENTRY_WRAPPED)) {\n continue;\n }\n\n const toolName = typeof t.name === 'string' ? t.name : 'unknown_tool';\n const toolDescription = typeof t.description === 'string' ? t.description : undefined;\n\n const wrappedInvoke = new Proxy(originalInvoke as (...args: unknown[]) => unknown, {\n apply(target, thisArg, args: unknown[]): unknown {\n const spanAttributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGGRAPH_ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: GEN_AI_EXECUTE_TOOL_OPERATION_ATTRIBUTE,\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'execute_tool',\n [GEN_AI_TOOL_NAME_ATTRIBUTE]: toolName,\n [GEN_AI_TOOL_TYPE_ATTRIBUTE]: 'function',\n };\n\n // Read agent name from LangChain's propagated config metadata at call time,\n // so shared tools get the correct agent name for each invocation\n const callConfig = args[1] as Record<string, unknown> | undefined;\n const callAgentName = (callConfig?.metadata as Record<string, unknown>)?.lc_agent_name ?? agentName;\n if (typeof callAgentName === 'string') {\n spanAttributes[GEN_AI_AGENT_NAME_ATTRIBUTE] = callAgentName;\n }\n\n if (toolDescription) {\n spanAttributes[GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE] = toolDescription;\n }\n\n // LangGraph ToolNode passes { name, args, id, type: \"tool_call\" }\n const input = args[0] as Record<string, unknown> | undefined;\n if (typeof input === 'object' && !!input) {\n if ('id' in input && typeof input.id === 'string') {\n spanAttributes[GEN_AI_TOOL_CALL_ID_ATTRIBUTE] = input.id;\n }\n\n if (options.recordInputs) {\n const toolArgs = 'args' in input && typeof input.args === 'object' ? input.args : input;\n try {\n spanAttributes[GEN_AI_TOOL_INPUT_ATTRIBUTE] = JSON.stringify(toolArgs);\n } catch {\n // skip if not serializable\n }\n }\n }\n\n return startSpan(\n {\n op: GEN_AI_EXECUTE_TOOL_OPERATION_ATTRIBUTE,\n name: `execute_tool ${toolName}`,\n attributes: spanAttributes,\n },\n async span => {\n try {\n const result = await Reflect.apply(target, thisArg, args);\n\n if (options.recordOutputs) {\n try {\n // ToolMessage objects wrap the result in .content\n const resultObj = result as Record<string, unknown> | undefined;\n const content =\n resultObj && typeof resultObj === 'object' && 'content' in resultObj ? resultObj.content : result;\n span.setAttribute(\n GEN_AI_TOOL_OUTPUT_ATTRIBUTE,\n typeof content === 'string' ? content : JSON.stringify(content),\n );\n } catch {\n // skip if not serializable\n }\n }\n\n return result;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.langgraph.error',\n },\n });\n throw error;\n }\n },\n );\n },\n });\n\n t.invoke = wrappedInvoke;\n Object.defineProperty(t, SENTRY_WRAPPED, { value: true, enumerable: false });\n }\n\n return tools;\n}\n\n/**\n * Extract tool calls from messages\n */\nexport function extractToolCalls(messages: Array<Record<string, unknown>> | null): unknown[] | null {\n if (!messages || messages.length === 0) {\n return null;\n }\n\n const toolCalls: unknown[] = [];\n\n for (const message of messages) {\n if (message && typeof message === 'object') {\n const msgToolCalls = message.tool_calls;\n if (msgToolCalls && Array.isArray(msgToolCalls)) {\n toolCalls.push(...msgToolCalls);\n }\n }\n }\n\n return toolCalls.length > 0 ? toolCalls : null;\n}\n\n/**\n * Extract token usage from a message's usage_metadata or response_metadata\n * Returns token counts without setting span attributes\n */\nexport function extractTokenUsageFromMessage(message: LangChainMessage): {\n inputTokens: number;\n outputTokens: number;\n totalTokens: number;\n} {\n const msg = message as Record<string, unknown>;\n let inputTokens = 0;\n let outputTokens = 0;\n let totalTokens = 0;\n\n // Extract from usage_metadata (newer format)\n if (msg.usage_metadata && typeof msg.usage_metadata === 'object') {\n const usage = msg.usage_metadata as Record<string, unknown>;\n if (typeof usage.input_tokens === 'number') {\n inputTokens = usage.input_tokens;\n }\n if (typeof usage.output_tokens === 'number') {\n outputTokens = usage.output_tokens;\n }\n if (typeof usage.total_tokens === 'number') {\n totalTokens = usage.total_tokens;\n }\n return { inputTokens, outputTokens, totalTokens };\n }\n\n // Fallback: Extract from response_metadata.tokenUsage\n if (msg.response_metadata && typeof msg.response_metadata === 'object') {\n const metadata = msg.response_metadata as Record<string, unknown>;\n if (metadata.tokenUsage && typeof metadata.tokenUsage === 'object') {\n const tokenUsage = metadata.tokenUsage as Record<string, unknown>;\n if (typeof tokenUsage.promptTokens === 'number') {\n inputTokens = tokenUsage.promptTokens;\n }\n if (typeof tokenUsage.completionTokens === 'number') {\n outputTokens = tokenUsage.completionTokens;\n }\n if (typeof tokenUsage.totalTokens === 'number') {\n totalTokens = tokenUsage.totalTokens;\n }\n }\n }\n\n return { inputTokens, outputTokens, totalTokens };\n}\n\n/**\n * Extract model and finish reason from a message's response_metadata\n */\nexport function extractModelMetadata(span: Span, message: LangChainMessage): void {\n const msg = message as Record<string, unknown>;\n\n if (msg.response_metadata && typeof msg.response_metadata === 'object') {\n const metadata = msg.response_metadata as Record<string, unknown>;\n\n if (metadata.model_name && typeof metadata.model_name === 'string') {\n span.setAttribute(GEN_AI_RESPONSE_MODEL_ATTRIBUTE, metadata.model_name);\n }\n\n if (metadata.finish_reason && typeof metadata.finish_reason === 'string') {\n span.setAttribute(GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE, [metadata.finish_reason]);\n }\n }\n}\n\n/**\n * Extract tools from compiled graph structure\n *\n * Tools are stored in: compiledGraph.builder.nodes.tools.runnable.tools\n */\nexport function extractToolsFromCompiledGraph(compiledGraph: CompiledGraph): unknown[] | null {\n if (!compiledGraph.builder?.nodes?.tools?.runnable?.tools) {\n return null;\n }\n\n const tools = compiledGraph.builder?.nodes?.tools?.runnable?.tools;\n\n if (!tools || !Array.isArray(tools) || tools.length === 0) {\n return null;\n }\n\n // Extract name, description, and schema from each tool's lc_kwargs\n return tools.map((tool: LangGraphTool) => ({\n name: tool.lc_kwargs?.name,\n description: tool.lc_kwargs?.description,\n schema: tool.lc_kwargs?.schema,\n }));\n}\n\n/**\n * Set response attributes on the span\n */\nexport function setResponseAttributes(span: Span, inputMessages: LangChainMessage[] | null, result: unknown): void {\n // Extract messages from result\n const resultObj = result as { messages?: LangChainMessage[] } | undefined;\n const outputMessages = resultObj?.messages;\n\n if (!outputMessages || !Array.isArray(outputMessages)) {\n return;\n }\n\n // Get new messages (delta between input and output)\n const inputCount = inputMessages?.length ?? 0;\n const newMessages = outputMessages.length > inputCount ? outputMessages.slice(inputCount) : [];\n\n if (newMessages.length === 0) {\n return;\n }\n\n // Extract and set tool calls from new messages BEFORE normalization\n // (normalization strips tool_calls, so we need to extract them first)\n const toolCalls = extractToolCalls(newMessages as Array<Record<string, unknown>>);\n if (toolCalls) {\n span.setAttribute(GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE, JSON.stringify(toolCalls));\n }\n\n // Normalize the new messages\n const normalizedNewMessages = normalizeLangChainMessages(newMessages);\n span.setAttribute(GEN_AI_RESPONSE_TEXT_ATTRIBUTE, JSON.stringify(normalizedNewMessages));\n\n // Accumulate token usage across all messages\n let totalInputTokens = 0;\n let totalOutputTokens = 0;\n let totalTokens = 0;\n\n // Extract metadata from messages\n for (const message of newMessages) {\n // Accumulate token usage\n const tokens = extractTokenUsageFromMessage(message);\n totalInputTokens += tokens.inputTokens;\n totalOutputTokens += tokens.outputTokens;\n totalTokens += tokens.totalTokens;\n\n // Extract model metadata (last message's metadata wins for model/finish_reason)\n extractModelMetadata(span, message);\n }\n\n // Set accumulated token usage on span\n if (totalInputTokens > 0) {\n span.setAttribute(GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE, totalInputTokens);\n }\n if (totalOutputTokens > 0) {\n span.setAttribute(GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE, totalOutputTokens);\n }\n if (totalTokens > 0) {\n span.setAttribute(GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE, totalTokens);\n }\n}\n\n/** Merge `sentryHandler` into a langchain `callbacks` value (`BaseCallbackHandler[]` or `BaseCallbackManager`). */\nexport function mergeSentryCallback(existing: unknown, sentryHandler: unknown): unknown {\n if (!existing) {\n return [sentryHandler];\n }\n\n if (Array.isArray(existing)) {\n if (existing.includes(sentryHandler)) {\n return existing;\n }\n return [...existing, sentryHandler];\n }\n\n const manager = existing as { addHandler?: (h: unknown) => void; handlers?: unknown[] };\n if (typeof manager.addHandler === 'function') {\n const alreadyAdded = Array.isArray(manager.handlers) && manager.handlers.includes(sentryHandler);\n if (!alreadyAdded) {\n manager.addHandler(sentryHandler);\n }\n }\n\n return existing;\n}\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","LANGGRAPH_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","GEN_AI_EXECUTE_TOOL_OPERATION_ATTRIBUTE","GEN_AI_OPERATION_NAME_ATTRIBUTE","GEN_AI_TOOL_NAME_ATTRIBUTE","GEN_AI_TOOL_TYPE_ATTRIBUTE","GEN_AI_AGENT_NAME_ATTRIBUTE","GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE","GEN_AI_TOOL_CALL_ID_ATTRIBUTE","GEN_AI_TOOL_INPUT_ATTRIBUTE","startSpan","GEN_AI_TOOL_OUTPUT_ATTRIBUTE","SPAN_STATUS_ERROR","captureException","GEN_AI_RESPONSE_MODEL_ATTRIBUTE","GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE","GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE","normalizeLangChainMessages","GEN_AI_RESPONSE_TEXT_ATTRIBUTE","GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE"],"mappings":";;;;;;;;;;AA4BA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,IAAI,EAAmC;AAC5E,EAAE,MAAM,GAAA,GAAM,I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AA;AACA,EAAA;;AAEA,EAAA,OAAA,QAAA;AACA;;;;;;;;;;;;"} | ||
| {"version":3,"file":"utils.js","sources":["../../../../src/tracing/langgraph/utils.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport type { Span, SpanAttributes } from '../../types-hoist/span';\nimport {\n GEN_AI_AGENT_NAME_ATTRIBUTE,\n GEN_AI_EXECUTE_TOOL_OPERATION_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_TEXT_ATTRIBUTE,\n GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n GEN_AI_TOOL_CALL_ID_ATTRIBUTE,\n GEN_AI_TOOL_INPUT_ATTRIBUTE,\n GEN_AI_TOOL_OUTPUT_ATTRIBUTE,\n GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE,\n GEN_AI_TOOL_NAME_ATTRIBUTE,\n GEN_AI_TOOL_TYPE_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { BaseChatModel, LangChainMessage } from '../langchain/types';\nimport { normalizeLangChainMessages } from '../langchain/utils';\nimport { startSpan } from '../trace';\nimport { LANGGRAPH_ORIGIN } from './constants';\nimport type { CompiledGraph, LangGraphOptions, LangGraphTool } from './types';\n\n/**\n * Extract LLM model object from createReactAgent params\n */\nexport function extractLLMFromParams(args: unknown[]): BaseChatModel | null {\n const arg = args[0];\n if (typeof arg !== 'object' || !arg || !('llm' in arg) || !arg.llm || typeof arg.llm !== 'object') {\n return null;\n }\n const llm = arg.llm as BaseChatModel;\n if (typeof llm.modelName !== 'string' && typeof llm.model !== 'string') {\n return null;\n }\n return llm;\n}\n\n/**\n * Extract agent name from createReactAgent params\n */\nexport function extractAgentNameFromParams(args: unknown[]): string | null {\n const arg = args[0];\n if (typeof arg === 'object' && !!arg && 'name' in arg && typeof arg.name === 'string') {\n return arg.name;\n }\n return null;\n}\n\n/**\n * Wraps an array of LangChain tools so each invocation creates a gen_ai.execute_tool span.\n *\n * Wraps each tool's invoke() method in place. A marker prevents double-wrapping.\n */\nexport function wrapToolsWithSpans(tools: unknown[], options: LangGraphOptions, agentName?: string): unknown[] {\n const SENTRY_WRAPPED = '__sentry_tool_wrapped__';\n\n for (const tool of tools) {\n if (!tool || typeof tool !== 'object') {\n continue;\n }\n\n const t = tool as Record<string, unknown>;\n const originalInvoke = t.invoke;\n if (typeof originalInvoke !== 'function' || Object.prototype.hasOwnProperty.call(t, SENTRY_WRAPPED)) {\n continue;\n }\n\n const toolName = typeof t.name === 'string' ? t.name : 'unknown_tool';\n const toolDescription = typeof t.description === 'string' ? t.description : undefined;\n\n const wrappedInvoke = new Proxy(originalInvoke as (...args: unknown[]) => unknown, {\n apply(target, thisArg, args: unknown[]): unknown {\n const spanAttributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGGRAPH_ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: GEN_AI_EXECUTE_TOOL_OPERATION_ATTRIBUTE,\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'execute_tool',\n [GEN_AI_TOOL_NAME_ATTRIBUTE]: toolName,\n [GEN_AI_TOOL_TYPE_ATTRIBUTE]: 'function',\n };\n\n // Read agent name from LangChain's propagated config metadata at call time,\n // so shared tools get the correct agent name for each invocation\n const callConfig = args[1] as Record<string, unknown> | undefined;\n const callAgentName = (callConfig?.metadata as Record<string, unknown>)?.lc_agent_name ?? agentName;\n if (typeof callAgentName === 'string') {\n spanAttributes[GEN_AI_AGENT_NAME_ATTRIBUTE] = callAgentName;\n }\n\n if (toolDescription) {\n spanAttributes[GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE] = toolDescription;\n }\n\n // LangGraph ToolNode passes { name, args, id, type: \"tool_call\" }\n const input = args[0] as Record<string, unknown> | undefined;\n if (typeof input === 'object' && !!input) {\n if ('id' in input && typeof input.id === 'string') {\n spanAttributes[GEN_AI_TOOL_CALL_ID_ATTRIBUTE] = input.id;\n }\n\n if (options.recordInputs) {\n const toolArgs = 'args' in input && typeof input.args === 'object' ? input.args : input;\n try {\n spanAttributes[GEN_AI_TOOL_INPUT_ATTRIBUTE] = JSON.stringify(toolArgs);\n } catch {\n // skip if not serializable\n }\n }\n }\n\n return startSpan(\n {\n op: GEN_AI_EXECUTE_TOOL_OPERATION_ATTRIBUTE,\n name: `execute_tool ${toolName}`,\n attributes: spanAttributes,\n },\n async span => {\n try {\n const result = await Reflect.apply(target, thisArg, args);\n\n if (options.recordOutputs) {\n try {\n // ToolMessage objects wrap the result in .content\n const resultObj = result as Record<string, unknown> | undefined;\n const content =\n resultObj && typeof resultObj === 'object' && 'content' in resultObj ? resultObj.content : result;\n span.setAttribute(\n GEN_AI_TOOL_OUTPUT_ATTRIBUTE,\n typeof content === 'string' ? content : JSON.stringify(content),\n );\n } catch {\n // skip if not serializable\n }\n }\n\n return result;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.langgraph.error',\n },\n });\n throw error;\n }\n },\n );\n },\n });\n\n t.invoke = wrappedInvoke;\n Object.defineProperty(t, SENTRY_WRAPPED, { value: true, enumerable: false });\n }\n\n return tools;\n}\n\n/**\n * Extract tool calls from messages\n */\nexport function extractToolCalls(messages: Array<Record<string, unknown>> | null): unknown[] | null {\n if (!messages || messages.length === 0) {\n return null;\n }\n\n const toolCalls: unknown[] = [];\n\n for (const message of messages) {\n if (message && typeof message === 'object') {\n const msgToolCalls = message.tool_calls;\n if (msgToolCalls && Array.isArray(msgToolCalls)) {\n toolCalls.push(...msgToolCalls);\n }\n }\n }\n\n return toolCalls.length > 0 ? toolCalls : null;\n}\n\n/**\n * Extract token usage from a message's usage_metadata or response_metadata\n * Returns token counts without setting span attributes\n */\nexport function extractTokenUsageFromMessage(message: LangChainMessage): {\n inputTokens: number;\n outputTokens: number;\n totalTokens: number;\n} {\n const msg = message as Record<string, unknown>;\n let inputTokens = 0;\n let outputTokens = 0;\n let totalTokens = 0;\n\n // Extract from usage_metadata (newer format)\n if (msg.usage_metadata && typeof msg.usage_metadata === 'object') {\n const usage = msg.usage_metadata as Record<string, unknown>;\n if (typeof usage.input_tokens === 'number') {\n inputTokens = usage.input_tokens;\n }\n if (typeof usage.output_tokens === 'number') {\n outputTokens = usage.output_tokens;\n }\n if (typeof usage.total_tokens === 'number') {\n totalTokens = usage.total_tokens;\n }\n return { inputTokens, outputTokens, totalTokens };\n }\n\n // Fallback: Extract from response_metadata.tokenUsage\n if (msg.response_metadata && typeof msg.response_metadata === 'object') {\n const metadata = msg.response_metadata as Record<string, unknown>;\n if (metadata.tokenUsage && typeof metadata.tokenUsage === 'object') {\n const tokenUsage = metadata.tokenUsage as Record<string, unknown>;\n if (typeof tokenUsage.promptTokens === 'number') {\n inputTokens = tokenUsage.promptTokens;\n }\n if (typeof tokenUsage.completionTokens === 'number') {\n outputTokens = tokenUsage.completionTokens;\n }\n if (typeof tokenUsage.totalTokens === 'number') {\n totalTokens = tokenUsage.totalTokens;\n }\n }\n }\n\n return { inputTokens, outputTokens, totalTokens };\n}\n\n/**\n * Extract model and finish reason from a message's response_metadata\n */\nexport function extractModelMetadata(span: Span, message: LangChainMessage): void {\n const msg = message as Record<string, unknown>;\n\n if (msg.response_metadata && typeof msg.response_metadata === 'object') {\n const metadata = msg.response_metadata as Record<string, unknown>;\n\n if (metadata.model_name && typeof metadata.model_name === 'string') {\n span.setAttribute(GEN_AI_RESPONSE_MODEL_ATTRIBUTE, metadata.model_name);\n }\n\n if (metadata.finish_reason && typeof metadata.finish_reason === 'string') {\n span.setAttribute(GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE, [metadata.finish_reason]);\n }\n }\n}\n\n/**\n * Extract tools from compiled graph structure\n *\n * Tools are stored in: compiledGraph.builder.nodes.tools.runnable.tools\n */\nexport function extractToolsFromCompiledGraph(compiledGraph: CompiledGraph): unknown[] | null {\n if (!compiledGraph.builder?.nodes?.tools?.runnable?.tools) {\n return null;\n }\n\n const tools = compiledGraph.builder?.nodes?.tools?.runnable?.tools;\n\n if (!tools || !Array.isArray(tools) || tools.length === 0) {\n return null;\n }\n\n // Extract name, description, and schema from each tool's lc_kwargs\n return tools.map((tool: LangGraphTool) => ({\n name: tool.lc_kwargs?.name,\n description: tool.lc_kwargs?.description,\n schema: tool.lc_kwargs?.schema,\n }));\n}\n\n/**\n * Set response attributes on the span\n */\nexport function setResponseAttributes(span: Span, inputMessages: LangChainMessage[] | null, result: unknown): void {\n // Extract messages from result\n const resultObj = result as { messages?: LangChainMessage[] } | undefined;\n const outputMessages = resultObj?.messages;\n\n if (!outputMessages || !Array.isArray(outputMessages)) {\n return;\n }\n\n // Get new messages (delta between input and output)\n const inputCount = inputMessages?.length ?? 0;\n const newMessages = outputMessages.length > inputCount ? outputMessages.slice(inputCount) : [];\n\n if (newMessages.length === 0) {\n return;\n }\n\n // Extract and set tool calls from new messages BEFORE normalization\n // (normalization strips tool_calls, so we need to extract them first)\n const toolCalls = extractToolCalls(newMessages as Array<Record<string, unknown>>);\n if (toolCalls) {\n span.setAttribute(GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE, JSON.stringify(toolCalls));\n }\n\n // Normalize the new messages\n const normalizedNewMessages = normalizeLangChainMessages(newMessages);\n span.setAttribute(GEN_AI_RESPONSE_TEXT_ATTRIBUTE, JSON.stringify(normalizedNewMessages));\n\n // Accumulate token usage across all messages\n let totalInputTokens = 0;\n let totalOutputTokens = 0;\n let totalTokens = 0;\n\n // Extract metadata from messages\n for (const message of newMessages) {\n // Accumulate token usage\n const tokens = extractTokenUsageFromMessage(message);\n totalInputTokens += tokens.inputTokens;\n totalOutputTokens += tokens.outputTokens;\n totalTokens += tokens.totalTokens;\n\n // Extract model metadata (last message's metadata wins for model/finish_reason)\n extractModelMetadata(span, message);\n }\n\n // Set accumulated token usage on span\n if (totalInputTokens > 0) {\n span.setAttribute(GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE, totalInputTokens);\n }\n if (totalOutputTokens > 0) {\n span.setAttribute(GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE, totalOutputTokens);\n }\n if (totalTokens > 0) {\n span.setAttribute(GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE, totalTokens);\n }\n}\n\n/** Merge `sentryHandler` into a langchain `callbacks` value (`BaseCallbackHandler[]` or `BaseCallbackManager`). */\nexport function mergeSentryCallback(existing: unknown, sentryHandler: unknown): unknown {\n if (!existing) {\n return [sentryHandler];\n }\n\n if (Array.isArray(existing)) {\n if (existing.includes(sentryHandler)) {\n return existing;\n }\n return [...existing, sentryHandler];\n }\n\n const manager = existing as { addHandler?: (h: unknown) => void; handlers?: unknown[] };\n if (typeof manager.addHandler === 'function') {\n const alreadyAdded = Array.isArray(manager.handlers) && manager.handlers.includes(sentryHandler);\n if (!alreadyAdded) {\n manager.addHandler(sentryHandler);\n }\n }\n\n return existing;\n}\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","LANGGRAPH_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","GEN_AI_EXECUTE_TOOL_OPERATION_ATTRIBUTE","GEN_AI_OPERATION_NAME_ATTRIBUTE","GEN_AI_TOOL_NAME_ATTRIBUTE","GEN_AI_TOOL_TYPE_ATTRIBUTE","GEN_AI_AGENT_NAME_ATTRIBUTE","GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE","GEN_AI_TOOL_CALL_ID_ATTRIBUTE","GEN_AI_TOOL_INPUT_ATTRIBUTE","startSpan","GEN_AI_TOOL_OUTPUT_ATTRIBUTE","SPAN_STATUS_ERROR","captureException","GEN_AI_RESPONSE_MODEL_ATTRIBUTE","GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE","GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE","normalizeLangChainMessages","GEN_AI_RESPONSE_TEXT_ATTRIBUTE","GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE"],"mappings":";;;;;;;;;;AA4BA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,IAAI,EAAmC;AAC5E,EAAE,MAAM,GAAA,GAAM,IAAI,CAAC,CAAC,CAAC;AACrB,EAAE,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,CAAC,GAAA,IAAO,EAAE,KAAA,IAAS,GAAG,CAAA,IAAK,CAAC,GAAG,CAAC,GAAA,IAAO,OAAO,GAAG,CAAC,GAAA,KAAQ,QAAQ,EAAE;AACrG,IAAI,OAAO,IAAI;AACf,EAAE;AACF,EAAE,MAAM,GAAA,GAAM,GAAG,CAAC,GAAA;AAClB,EAAE,IAAI,OAAO,GAAG,CAAC,SAAA,KAAc,QAAA,IAAY,OAAO,GAAG,CAAC,KAAA,KAAU,QAAQ,EAAE;AAC1E,IAAI,OAAO,IAAI;AACf,EAAE;AACF,EAAE,OAAO,GAAG;AACZ;;AAEA;AACA;AACA;AACO,SAAS,0BAA0B,CAAC,IAAI,EAA4B;AAC3E,EAAE,MAAM,GAAA,GAAM,IAAI,CAAC,CAAC,CAAC;AACrB,EAAE,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,CAAC,CAAC,GAAA,IAAO,MAAA,IAAU,OAAO,OAAO,GAAG,CAAC,IAAA,KAAS,QAAQ,EAAE;AACzF,IAAI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AA,IAAA,KAAA,CAAA,OAAA,CAAA,QAAA,CAAA,EAAA;AACA,IAAA,IAAA,QAAA,CAAA,QAAA,CAAA,aAAA,CAAA,EAAA;AACA,MAAA,OAAA,QAAA;AACA,IAAA;AACA,IAAA,OAAA,CAAA,GAAA,QAAA,EAAA,aAAA,CAAA;AACA,EAAA;;AAEA,EAAA,MAAA,OAAA,GAAA,QAAA;AACA,EAAA,IAAA,OAAA,OAAA,CAAA,UAAA,KAAA,UAAA,EAAA;AACA,IAAA,MAAA,YAAA,GAAA,KAAA,CAAA,OAAA,CAAA,OAAA,CAAA,QAAA,CAAA,IAAA,OAAA,CAAA,QAAA,CAAA,QAAA,CAAA,aAAA,CAAA;AACA,IAAA,IAAA,CAAA,YAAA,EAAA;AACA,MAAA,OAAA,CAAA,UAAA,CAAA,aAAA,CAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,OAAA,QAAA;AACA;;;;;;;;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const debugBuild = require('../../debug-build.js'); | ||
| const _exports = require('../../exports.js'); | ||
| const exports$1 = require('../../exports.js'); | ||
| const semanticAttributes = require('../../semanticAttributes.js'); | ||
@@ -170,3 +170,3 @@ const debugLogger = require('../../utils/debug-logger.js'); | ||
| span.setStatus({ code: spanstatus.SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { | ||
@@ -204,3 +204,3 @@ handled: false, | ||
| error => { | ||
| _exports.captureException(error, { | ||
| exports$1.captureException(error, { | ||
| mechanism: { | ||
@@ -207,0 +207,0 @@ handled: false, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/openai/index.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../../debug-build';\nimport { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpan, startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types-hoist/span';\nimport { debug } from '../../utils/debug-logger';\nimport {\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { InstrumentedMethodEntry } from '../ai/utils';\nimport {\n buildMethodPath,\n extractSystemInstructions,\n getJsonString,\n getTruncatedJsonString,\n resolveAIRecordingOptions,\n shouldEnableTruncation,\n wrapPromiseWithMethods,\n} from '../ai/utils';\nimport { OPENAI_METHOD_REGISTRY } from './constants';\nimport { instrumentStream } from './streaming';\nimport type { ChatCompletionChunk, OpenAiOptions, OpenAIStream, ResponseStreamingEvent } from './types';\nimport { addResponseAttributes, extractRequestParameters } from './utils';\n\n/**\n * Extract available tools from request parameters\n */\nfunction extractAvailableTools(params: Record<string, unknown>): string | undefined {\n const tools = Array.isArray(params.tools) ? params.tools : [];\n const hasWebSearchOptions = params.web_search_options && typeof params.web_search_options === 'object';\n const webSearchOptions = hasWebSearchOptions\n ? [{ type: 'web_search_options', ...(params.web_search_options as Record<string, unknown>) }]\n : [];\n\n const availableTools = [...tools, ...webSearchOptions];\n if (availableTools.length === 0) {\n return undefined;\n }\n\n try {\n return JSON.stringify(availableTools);\n } catch (error) {\n DEBUG_BUILD && debug.error('Failed to serialize OpenAI tools:', error);\n return undefined;\n }\n}\n\n/**\n * Extract request attributes from method arguments\n */\nfunction extractRequestAttributes(args: unknown[], operationName: string): Record<string, unknown> {\n const attributes: Record<string, unknown> = {\n [GEN_AI_SYSTEM_ATTRIBUTE]: 'openai',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: operationName,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.openai',\n };\n\n if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null) {\n const params = args[0] as Record<string, unknown>;\n\n const availableTools = extractAvailableTools(params);\n if (availableTools) {\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = availableTools;\n }\n\n Object.assign(attributes, extractRequestParameters(params));\n } else {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = 'unknown';\n }\n\n return attributes;\n}\n\n// Extract and record AI request inputs, if present. This is intentionally separate from response attributes.\nfunction addRequestAttributes(\n span: Span,\n params: Record<string, unknown>,\n operationName: string,\n enableTruncation: boolean,\n): void {\n // Store embeddings input on a separate attribute and do not truncate it\n if (operationName === 'embeddings' && 'input' in params) {\n const input = params.input;\n\n // No input provided\n if (input == null) {\n return;\n }\n\n // Empty input string\n if (typeof input === 'string' && input.length === 0) {\n return;\n }\n\n // Empty array input\n if (Array.isArray(input) && input.length === 0) {\n return;\n }\n\n // Store strings as-is, arrays/objects as JSON\n span.setAttribute(GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE, typeof input === 'string' ? input : JSON.stringify(input));\n return;\n }\n\n const src = 'input' in params ? params.input : 'messages' in params ? params.messages : undefined;\n\n if (!src) {\n return;\n }\n\n if (Array.isArray(src) && src.length === 0) {\n return;\n }\n\n const { systemInstructions, filteredMessages } = extractSystemInstructions(src);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n span.setAttribute(\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n enableTruncation ? getTruncatedJsonString(filteredMessages) : getJsonString(filteredMessages),\n );\n\n if (Array.isArray(filteredMessages)) {\n span.setAttribute(GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, filteredMessages.length);\n } else {\n span.setAttribute(GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, 1);\n }\n}\n\n/**\n * Instrument a method with Sentry spans\n * Following Sentry AI Agents Manual Instrumentation conventions\n * @see https://docs.sentry.io/platforms/javascript/guides/node/tracing/instrumentation/ai-agents-module/#manual-instrumentation\n */\nfunction instrumentMethod<T extends unknown[], R>(\n originalMethod: (...args: T) => Promise<R>,\n methodPath: string,\n instrumentedMethod: InstrumentedMethodEntry,\n context: unknown,\n options: OpenAiOptions,\n): (...args: T) => Promise<R> {\n return function instrumentedCall(...args: T): Promise<R> {\n const operationName = instrumentedMethod.operation || 'unknown';\n const requestAttributes = extractRequestAttributes(args, operationName);\n const model = (requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] as string) || 'unknown';\n\n const params = args[0] as Record<string, unknown> | undefined;\n const isStreamRequested = params && typeof params === 'object' && params.stream === true;\n\n const spanConfig = {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n };\n\n if (isStreamRequested) {\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpanManual(spanConfig, (span: Span) => {\n originalResult = originalMethod.apply(context, args);\n\n if (options.recordInputs && params) {\n addRequestAttributes(span, params, operationName, shouldEnableTruncation(options.enableTruncation));\n }\n\n // Return async processing\n return (async () => {\n try {\n const result = await originalResult;\n return instrumentStream(\n result as OpenAIStream<ChatCompletionChunk | ResponseStreamingEvent>,\n span,\n options.recordOutputs ?? false,\n ) as unknown as R;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.openai.stream',\n data: { function: methodPath },\n },\n });\n span.end();\n throw error;\n }\n })();\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.openai');\n }\n\n // Non-streaming\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpan(spanConfig, (span: Span) => {\n // Call synchronously to capture the promise\n originalResult = originalMethod.apply(context, args);\n\n if (options.recordInputs && params) {\n addRequestAttributes(span, params, operationName, shouldEnableTruncation(options.enableTruncation));\n }\n\n return originalResult.then(\n result => {\n addResponseAttributes(span, result, options.recordOutputs);\n return result;\n },\n error => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.openai',\n data: { function: methodPath },\n },\n });\n throw error;\n },\n );\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.openai');\n };\n}\n\n/**\n * Create a deep proxy for OpenAI client instrumentation\n */\nfunction createDeepProxy<T extends object>(target: T, currentPath = '', options: OpenAiOptions): T {\n return new Proxy(target, {\n get(obj: object, prop: string): unknown {\n const value = (obj as Record<string, unknown>)[prop];\n const methodPath = buildMethodPath(currentPath, String(prop));\n\n const instrumentedMethod = OPENAI_METHOD_REGISTRY[methodPath as keyof typeof OPENAI_METHOD_REGISTRY];\n if (typeof value === 'function' && instrumentedMethod) {\n return instrumentMethod(\n value as (...args: unknown[]) => Promise<unknown>,\n methodPath,\n instrumentedMethod,\n obj,\n options,\n );\n }\n\n if (typeof value === 'function') {\n // Bind non-instrumented functions to preserve the original `this` context,\n // which is required for accessing private class fields (e.g. #baseURL) in OpenAI SDK v5.\n return value.bind(obj);\n }\n\n if (value && typeof value === 'object') {\n return createDeepProxy(value, methodPath, options);\n }\n\n return value;\n },\n }) as T;\n}\n\n/**\n * Instrument an OpenAI client with Sentry tracing\n * Can be used across Node.js, Cloudflare Workers, and Vercel Edge\n */\nexport function instrumentOpenAiClient<T extends object>(client: T, options?: OpenAiOptions): T {\n return createDeepProxy(client, '', resolveAIRecordingOptions(options));\n}\n"],"names":["DEBUG_BUILD","debug","GEN_AI_SYSTEM_ATTRIBUTE","GEN_AI_OPERATION_NAME_ATTRIBUTE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","extractRequestParameters","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE","extractSystemInstructions","GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE","GEN_AI_INPUT_MESSAGES_ATTRIBUTE","getTruncatedJsonString","getJsonString","GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE","startSpanManual","shouldEnableTruncation","instrumentStream","SPAN_STATUS_ERROR","captureException","wrapPromiseWithMethods","startSpan","addResponseAttributes","buildMethodPath","OPENAI_METHOD_REGISTRY","resolveAIRecordingOptions"],"mappings":";;;;;;;;;;;;;;AAgCA;AACA;AACA;AACA,SAAS,qBAAqB,CAAC,MAAM,EAA+C;AACpF,EAAE,MAAM,KAAA,GAAQ,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAA,GAAQ,EAAE;AAC/D,EAAE,MAAM,mBAAA,GAAsB,MAAM,CAAC,kBAAA,IAAsB,OAAO,MAAM,CAAC,kBAAA,KAAuB,QAAQ;AACxG,EAAE,MAAM,mBAAmB;AAC3B,MAAM,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,MAAM,CAAC,kBAAA,IAAgD;AAChG,MAAM,EAAE;;AAER,EAAE,MAAM,iBAAiB,CAAC,GAAG,KAAK,EAAE,GAAG,gBAAgB,CAAC;AACxD,EAAE,IAAI,cAAc,CAAC,MAAA,KAAW,CAAC,EAAE;AACnC,IAAI,OAAO,SAAS;AACpB,EAAE;;AAEF,EAAE,IAAI;AACN,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;AACzC,EAAE,CAAA,CAAE,OAAO,KAAK,EAAE;AAClB,IAAIA,sBAAA,IAAeC,iBAAK,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC;AAC1E,IAAI,OAAO,SAAS;AACpB,EAAE;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AAA;AACA,EAAA,OAAA,eAAA,CAAA,MAAA,EAAA,EAAA,EAAAC,+BAAA,CAAA,OAAA,CAAA,CAAA;AACA;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/openai/index.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../../debug-build';\nimport { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpan, startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types-hoist/span';\nimport { debug } from '../../utils/debug-logger';\nimport {\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { InstrumentedMethodEntry } from '../ai/utils';\nimport {\n buildMethodPath,\n extractSystemInstructions,\n getJsonString,\n getTruncatedJsonString,\n resolveAIRecordingOptions,\n shouldEnableTruncation,\n wrapPromiseWithMethods,\n} from '../ai/utils';\nimport { OPENAI_METHOD_REGISTRY } from './constants';\nimport { instrumentStream } from './streaming';\nimport type { ChatCompletionChunk, OpenAiOptions, OpenAIStream, ResponseStreamingEvent } from './types';\nimport { addResponseAttributes, extractRequestParameters } from './utils';\n\n/**\n * Extract available tools from request parameters\n */\nfunction extractAvailableTools(params: Record<string, unknown>): string | undefined {\n const tools = Array.isArray(params.tools) ? params.tools : [];\n const hasWebSearchOptions = params.web_search_options && typeof params.web_search_options === 'object';\n const webSearchOptions = hasWebSearchOptions\n ? [{ type: 'web_search_options', ...(params.web_search_options as Record<string, unknown>) }]\n : [];\n\n const availableTools = [...tools, ...webSearchOptions];\n if (availableTools.length === 0) {\n return undefined;\n }\n\n try {\n return JSON.stringify(availableTools);\n } catch (error) {\n DEBUG_BUILD && debug.error('Failed to serialize OpenAI tools:', error);\n return undefined;\n }\n}\n\n/**\n * Extract request attributes from method arguments\n */\nfunction extractRequestAttributes(args: unknown[], operationName: string): Record<string, unknown> {\n const attributes: Record<string, unknown> = {\n [GEN_AI_SYSTEM_ATTRIBUTE]: 'openai',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: operationName,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.openai',\n };\n\n if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null) {\n const params = args[0] as Record<string, unknown>;\n\n const availableTools = extractAvailableTools(params);\n if (availableTools) {\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = availableTools;\n }\n\n Object.assign(attributes, extractRequestParameters(params));\n } else {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = 'unknown';\n }\n\n return attributes;\n}\n\n// Extract and record AI request inputs, if present. This is intentionally separate from response attributes.\nfunction addRequestAttributes(\n span: Span,\n params: Record<string, unknown>,\n operationName: string,\n enableTruncation: boolean,\n): void {\n // Store embeddings input on a separate attribute and do not truncate it\n if (operationName === 'embeddings' && 'input' in params) {\n const input = params.input;\n\n // No input provided\n if (input == null) {\n return;\n }\n\n // Empty input string\n if (typeof input === 'string' && input.length === 0) {\n return;\n }\n\n // Empty array input\n if (Array.isArray(input) && input.length === 0) {\n return;\n }\n\n // Store strings as-is, arrays/objects as JSON\n span.setAttribute(GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE, typeof input === 'string' ? input : JSON.stringify(input));\n return;\n }\n\n const src = 'input' in params ? params.input : 'messages' in params ? params.messages : undefined;\n\n if (!src) {\n return;\n }\n\n if (Array.isArray(src) && src.length === 0) {\n return;\n }\n\n const { systemInstructions, filteredMessages } = extractSystemInstructions(src);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n span.setAttribute(\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n enableTruncation ? getTruncatedJsonString(filteredMessages) : getJsonString(filteredMessages),\n );\n\n if (Array.isArray(filteredMessages)) {\n span.setAttribute(GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, filteredMessages.length);\n } else {\n span.setAttribute(GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, 1);\n }\n}\n\n/**\n * Instrument a method with Sentry spans\n * Following Sentry AI Agents Manual Instrumentation conventions\n * @see https://docs.sentry.io/platforms/javascript/guides/node/tracing/instrumentation/ai-agents-module/#manual-instrumentation\n */\nfunction instrumentMethod<T extends unknown[], R>(\n originalMethod: (...args: T) => Promise<R>,\n methodPath: string,\n instrumentedMethod: InstrumentedMethodEntry,\n context: unknown,\n options: OpenAiOptions,\n): (...args: T) => Promise<R> {\n return function instrumentedCall(...args: T): Promise<R> {\n const operationName = instrumentedMethod.operation || 'unknown';\n const requestAttributes = extractRequestAttributes(args, operationName);\n const model = (requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] as string) || 'unknown';\n\n const params = args[0] as Record<string, unknown> | undefined;\n const isStreamRequested = params && typeof params === 'object' && params.stream === true;\n\n const spanConfig = {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n };\n\n if (isStreamRequested) {\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpanManual(spanConfig, (span: Span) => {\n originalResult = originalMethod.apply(context, args);\n\n if (options.recordInputs && params) {\n addRequestAttributes(span, params, operationName, shouldEnableTruncation(options.enableTruncation));\n }\n\n // Return async processing\n return (async () => {\n try {\n const result = await originalResult;\n return instrumentStream(\n result as OpenAIStream<ChatCompletionChunk | ResponseStreamingEvent>,\n span,\n options.recordOutputs ?? false,\n ) as unknown as R;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.openai.stream',\n data: { function: methodPath },\n },\n });\n span.end();\n throw error;\n }\n })();\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.openai');\n }\n\n // Non-streaming\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpan(spanConfig, (span: Span) => {\n // Call synchronously to capture the promise\n originalResult = originalMethod.apply(context, args);\n\n if (options.recordInputs && params) {\n addRequestAttributes(span, params, operationName, shouldEnableTruncation(options.enableTruncation));\n }\n\n return originalResult.then(\n result => {\n addResponseAttributes(span, result, options.recordOutputs);\n return result;\n },\n error => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.openai',\n data: { function: methodPath },\n },\n });\n throw error;\n },\n );\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.openai');\n };\n}\n\n/**\n * Create a deep proxy for OpenAI client instrumentation\n */\nfunction createDeepProxy<T extends object>(target: T, currentPath = '', options: OpenAiOptions): T {\n return new Proxy(target, {\n get(obj: object, prop: string): unknown {\n const value = (obj as Record<string, unknown>)[prop];\n const methodPath = buildMethodPath(currentPath, String(prop));\n\n const instrumentedMethod = OPENAI_METHOD_REGISTRY[methodPath as keyof typeof OPENAI_METHOD_REGISTRY];\n if (typeof value === 'function' && instrumentedMethod) {\n return instrumentMethod(\n value as (...args: unknown[]) => Promise<unknown>,\n methodPath,\n instrumentedMethod,\n obj,\n options,\n );\n }\n\n if (typeof value === 'function') {\n // Bind non-instrumented functions to preserve the original `this` context,\n // which is required for accessing private class fields (e.g. #baseURL) in OpenAI SDK v5.\n return value.bind(obj);\n }\n\n if (value && typeof value === 'object') {\n return createDeepProxy(value, methodPath, options);\n }\n\n return value;\n },\n }) as T;\n}\n\n/**\n * Instrument an OpenAI client with Sentry tracing\n * Can be used across Node.js, Cloudflare Workers, and Vercel Edge\n */\nexport function instrumentOpenAiClient<T extends object>(client: T, options?: OpenAiOptions): T {\n return createDeepProxy(client, '', resolveAIRecordingOptions(options));\n}\n"],"names":["DEBUG_BUILD","debug","GEN_AI_SYSTEM_ATTRIBUTE","GEN_AI_OPERATION_NAME_ATTRIBUTE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","extractRequestParameters","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE","extractSystemInstructions","GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE","GEN_AI_INPUT_MESSAGES_ATTRIBUTE","getTruncatedJsonString","getJsonString","GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE","startSpanManual","shouldEnableTruncation","instrumentStream","SPAN_STATUS_ERROR","captureException","wrapPromiseWithMethods","startSpan","addResponseAttributes","buildMethodPath","OPENAI_METHOD_REGISTRY","resolveAIRecordingOptions"],"mappings":";;;;;;;;;;;;;;AAgCA;AACA;AACA;AACA,SAAS,qBAAqB,CAAC,MAAM,EAA+C;AACpF,EAAE,MAAM,KAAA,GAAQ,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAA,GAAQ,EAAE;AAC/D,EAAE,MAAM,mBAAA,GAAsB,MAAM,CAAC,kBAAA,IAAsB,OAAO,MAAM,CAAC,kBAAA,KAAuB,QAAQ;AACxG,EAAE,MAAM,mBAAmB;AAC3B,MAAM,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,MAAM,CAAC,kBAAA,IAAgD;AAChG,MAAM,EAAE;;AAER,EAAE,MAAM,iBAAiB,CAAC,GAAG,KAAK,EAAE,GAAG,gBAAgB,CAAC;AACxD,EAAE,IAAI,cAAc,CAAC,MAAA,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A,CAAA;AACA,MAAA;;AAEA,MAAA,IAAA,KAAA,IAAA,OAAA,KAAA,KAAA,QAAA,EAAA;AACA,QAAA,OAAA,eAAA,CAAA,KAAA,EAAA,UAAA,EAAA,OAAA,CAAA;AACA,MAAA;;AAEA,MAAA,OAAA,KAAA;AACA,IAAA,CAAA;AACA,GAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAA,sBAAA,CAAA,MAAA,EAAA,OAAA,EAAA;AACA,EAAA,OAAA,eAAA,CAAA,MAAA,EAAA,EAAA,EAAAC,+BAAA,CAAA,OAAA,CAAA,CAAA;AACA;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const _exports = require('../../exports.js'); | ||
| const exports$1 = require('../../exports.js'); | ||
| const spanstatus = require('../spanstatus.js'); | ||
@@ -105,3 +105,3 @@ const utils$1 = require('../ai/utils.js'); | ||
| span.setStatus({ code: spanstatus.SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
| _exports.captureException(streamEvent, { | ||
| exports$1.captureException(streamEvent, { | ||
| mechanism: { | ||
@@ -108,0 +108,0 @@ handled: false, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"streaming.js","sources":["../../../../src/tracing/openai/streaming.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport type { Span } from '../../types-hoist/span';\nimport { endStreamSpan } from '../ai/utils';\nimport { RESPONSE_EVENT_TYPES } from './constants';\nimport type {\n ChatCompletionChunk,\n ChatCompletionToolCall,\n OpenAIResponseObject,\n ResponseFunctionCall,\n ResponseStreamingEvent,\n} from './types';\nimport { isChatCompletionChunk, isResponsesApiStreamEvent } from './utils';\n\n/**\n * State object used to accumulate information from a stream of OpenAI events/chunks.\n */\ninterface StreamingState {\n /** Types of events encountered in the stream. */\n eventTypes: string[];\n /** Collected response text fragments (for output recording). */\n responseTexts: string[];\n /** Reasons for finishing the response, as reported by the API. */\n finishReasons: string[];\n /** The response ID. */\n responseId: string;\n /** The model name. */\n responseModel: string;\n /** Number of prompt/input tokens used. */\n promptTokens: number | undefined;\n /** Number of completion/output tokens used. */\n completionTokens: number | undefined;\n /** Total number of tokens used (prompt + completion). */\n totalTokens: number | undefined;\n /**\n * Accumulated tool calls from Chat Completion streaming, indexed by tool call index.\n * @see https://platform.openai.com/docs/guides/function-calling?api-mode=chat#streaming\n */\n chatCompletionToolCalls: Record<number, ChatCompletionToolCall>;\n /**\n * Accumulated function calls from Responses API streaming.\n * @see https://platform.openai.com/docs/guides/function-calling?api-mode=responses#streaming\n */\n responsesApiToolCalls: Array<ResponseFunctionCall | unknown>;\n}\n\n/**\n * Processes tool calls from a chat completion chunk delta.\n * Follows the pattern: accumulate by index, then convert to array at the end.\n *\n * @param toolCalls - Array of tool calls from the delta.\n * @param state - The current streaming state to update.\n *\n * @see https://platform.openai.com/docs/guides/function-calling#streaming\n */\nfunction processChatCompletionToolCalls(toolCalls: ChatCompletionToolCall[], state: StreamingState): void {\n for (const toolCall of toolCalls) {\n const index = toolCall.index;\n if (index === undefined || !toolCall.function) continue;\n\n // Initialize tool call if this is the first chunk for this index\n if (!(index in state.chatCompletionToolCalls)) {\n state.chatCompletionToolCalls[index] = {\n ...toolCall,\n function: {\n name: toolCall.function.name,\n arguments: toolCall.function.arguments || '',\n },\n };\n } else {\n // Accumulate function arguments from subsequent chunks\n const existingToolCall = state.chatCompletionToolCalls[index];\n if (toolCall.function.arguments && existingToolCall?.function) {\n existingToolCall.function.arguments += toolCall.function.arguments;\n }\n }\n }\n}\n\n/**\n * Processes a single OpenAI ChatCompletionChunk event, updating the streaming state.\n *\n * @param chunk - The ChatCompletionChunk event to process.\n * @param state - The current streaming state to update.\n * @param recordOutputs - Whether to record output text fragments.\n */\nfunction processChatCompletionChunk(chunk: ChatCompletionChunk, state: StreamingState, recordOutputs: boolean): void {\n state.responseId = chunk.id ?? state.responseId;\n state.responseModel = chunk.model ?? state.responseModel;\n\n if (chunk.usage) {\n // For stream responses, the input tokens remain constant across all events in the stream.\n // Output tokens, however, are only finalized in the last event.\n // Since we can't guarantee that the last event will include usage data or even be a typed event,\n // we update the output token values on every event that includes them.\n // This ensures that output token usage is always set, even if the final event lacks it.\n state.promptTokens = chunk.usage.prompt_tokens;\n state.completionTokens = chunk.usage.completion_tokens;\n state.totalTokens = chunk.usage.total_tokens;\n }\n\n for (const choice of chunk.choices ?? []) {\n if (recordOutputs) {\n if (choice.delta?.content) {\n state.responseTexts.push(choice.delta.content);\n }\n\n // Handle tool calls from delta\n if (choice.delta?.tool_calls) {\n processChatCompletionToolCalls(choice.delta.tool_calls, state);\n }\n }\n if (choice.finish_reason) {\n state.finishReasons.push(choice.finish_reason);\n }\n }\n}\n\n/**\n * Processes a single OpenAI Responses API streaming event, updating the streaming state and span.\n *\n * @param streamEvent - The event to process (may be an error or unknown object).\n * @param state - The current streaming state to update.\n * @param recordOutputs - Whether to record output text fragments.\n * @param span - The span to update with error status if needed.\n */\nfunction processResponsesApiEvent(\n streamEvent: ResponseStreamingEvent | unknown | Error,\n state: StreamingState,\n recordOutputs: boolean,\n span: Span,\n): void {\n if (!(streamEvent && typeof streamEvent === 'object')) {\n state.eventTypes.push('unknown:non-object');\n return;\n }\n if (streamEvent instanceof Error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(streamEvent, {\n mechanism: {\n handled: false,\n type: 'auto.ai.openai.stream-response',\n },\n });\n return;\n }\n\n if (!('type' in streamEvent)) return;\n const event = streamEvent as ResponseStreamingEvent;\n\n if (!RESPONSE_EVENT_TYPES.includes(event.type)) {\n state.eventTypes.push(event.type);\n return;\n }\n\n // Handle output text delta\n if (recordOutputs) {\n // Handle tool call events for Responses API\n if (event.type === 'response.output_item.done' && 'item' in event) {\n state.responsesApiToolCalls.push(event.item);\n }\n\n if (event.type === 'response.output_text.delta' && 'delta' in event && event.delta) {\n state.responseTexts.push(event.delta);\n return;\n }\n }\n\n if ('response' in event) {\n const { response } = event as { response: OpenAIResponseObject };\n state.responseId = response.id ?? state.responseId;\n state.responseModel = response.model ?? state.responseModel;\n\n if (response.usage) {\n // For stream responses, the input tokens remain constant across all events in the stream.\n // Output tokens, however, are only finalized in the last event.\n // Since we can't guarantee that the last event will include usage data or even be a typed event,\n // we update the output token values on every event that includes them.\n // This ensures that output token usage is always set, even if the final event lacks it.\n state.promptTokens = response.usage.input_tokens;\n state.completionTokens = response.usage.output_tokens;\n state.totalTokens = response.usage.total_tokens;\n }\n\n if (response.status) {\n state.finishReasons.push(response.status);\n }\n\n if (recordOutputs && response.output_text) {\n state.responseTexts.push(response.output_text);\n }\n }\n}\n\n/**\n * Instruments a stream of OpenAI events, updating the provided span with relevant attributes and\n * optionally recording output text. This function yields each event from the input stream as it is processed.\n *\n * @template T - The type of events in the stream.\n * @param stream - The async iterable stream of events to instrument.\n * @param span - The span to add attributes to and to finish at the end of the stream.\n * @param recordOutputs - Whether to record output text fragments in the span.\n * @returns An async generator yielding each event from the input stream.\n */\nexport async function* instrumentStream<T>(\n stream: AsyncIterable<T>,\n span: Span,\n recordOutputs: boolean,\n): AsyncGenerator<T, void, unknown> {\n const state: StreamingState = {\n eventTypes: [],\n responseTexts: [],\n finishReasons: [],\n responseId: '',\n responseModel: '',\n promptTokens: undefined,\n completionTokens: undefined,\n totalTokens: undefined,\n chatCompletionToolCalls: {},\n responsesApiToolCalls: [],\n };\n\n try {\n for await (const event of stream) {\n if (isChatCompletionChunk(event)) {\n processChatCompletionChunk(event as ChatCompletionChunk, state, recordOutputs);\n } else if (isResponsesApiStreamEvent(event)) {\n processResponsesApiEvent(event as ResponseStreamingEvent, state, recordOutputs, span);\n }\n yield event;\n }\n } finally {\n const allToolCalls = [...Object.values(state.chatCompletionToolCalls), ...state.responsesApiToolCalls];\n endStreamSpan(span, { ...state, toolCalls: allToolCalls }, recordOutputs);\n }\n}\n"],"names":["SPAN_STATUS_ERROR","captureException","RESPONSE_EVENT_TYPES","isChatCompletionChunk","isResponsesApiSt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AAC,EAAE;AACnD,QAAQ,wBAAwB,CAAC,KAAA,GAAiC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC;AAC7F,MAAM;AACN,MAAM,MAAM,KAAK;AACjB,IAAI;AACJ,EAAE,UAAU;AACZ,IAAI,MAAM,YAAA,GAAe,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,EAAE,GAAG,KAAK,CAAC,qBAAqB,CAAC;AAC1G,IAAIC,qBAAa,CAAC,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,YAAA,EAAc,EAAE,aAAa,CAAC;AAC7E,EAAE;AACF;;;;"} | ||
| {"version":3,"file":"streaming.js","sources":["../../../../src/tracing/openai/streaming.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport type { Span } from '../../types-hoist/span';\nimport { endStreamSpan } from '../ai/utils';\nimport { RESPONSE_EVENT_TYPES } from './constants';\nimport type {\n ChatCompletionChunk,\n ChatCompletionToolCall,\n OpenAIResponseObject,\n ResponseFunctionCall,\n ResponseStreamingEvent,\n} from './types';\nimport { isChatCompletionChunk, isResponsesApiStreamEvent } from './utils';\n\n/**\n * State object used to accumulate information from a stream of OpenAI events/chunks.\n */\ninterface StreamingState {\n /** Types of events encountered in the stream. */\n eventTypes: string[];\n /** Collected response text fragments (for output recording). */\n responseTexts: string[];\n /** Reasons for finishing the response, as reported by the API. */\n finishReasons: string[];\n /** The response ID. */\n responseId: string;\n /** The model name. */\n responseModel: string;\n /** Number of prompt/input tokens used. */\n promptTokens: number | undefined;\n /** Number of completion/output tokens used. */\n completionTokens: number | undefined;\n /** Total number of tokens used (prompt + completion). */\n totalTokens: number | undefined;\n /**\n * Accumulated tool calls from Chat Completion streaming, indexed by tool call index.\n * @see https://platform.openai.com/docs/guides/function-calling?api-mode=chat#streaming\n */\n chatCompletionToolCalls: Record<number, ChatCompletionToolCall>;\n /**\n * Accumulated function calls from Responses API streaming.\n * @see https://platform.openai.com/docs/guides/function-calling?api-mode=responses#streaming\n */\n responsesApiToolCalls: Array<ResponseFunctionCall | unknown>;\n}\n\n/**\n * Processes tool calls from a chat completion chunk delta.\n * Follows the pattern: accumulate by index, then convert to array at the end.\n *\n * @param toolCalls - Array of tool calls from the delta.\n * @param state - The current streaming state to update.\n *\n * @see https://platform.openai.com/docs/guides/function-calling#streaming\n */\nfunction processChatCompletionToolCalls(toolCalls: ChatCompletionToolCall[], state: StreamingState): void {\n for (const toolCall of toolCalls) {\n const index = toolCall.index;\n if (index === undefined || !toolCall.function) continue;\n\n // Initialize tool call if this is the first chunk for this index\n if (!(index in state.chatCompletionToolCalls)) {\n state.chatCompletionToolCalls[index] = {\n ...toolCall,\n function: {\n name: toolCall.function.name,\n arguments: toolCall.function.arguments || '',\n },\n };\n } else {\n // Accumulate function arguments from subsequent chunks\n const existingToolCall = state.chatCompletionToolCalls[index];\n if (toolCall.function.arguments && existingToolCall?.function) {\n existingToolCall.function.arguments += toolCall.function.arguments;\n }\n }\n }\n}\n\n/**\n * Processes a single OpenAI ChatCompletionChunk event, updating the streaming state.\n *\n * @param chunk - The ChatCompletionChunk event to process.\n * @param state - The current streaming state to update.\n * @param recordOutputs - Whether to record output text fragments.\n */\nfunction processChatCompletionChunk(chunk: ChatCompletionChunk, state: StreamingState, recordOutputs: boolean): void {\n state.responseId = chunk.id ?? state.responseId;\n state.responseModel = chunk.model ?? state.responseModel;\n\n if (chunk.usage) {\n // For stream responses, the input tokens remain constant across all events in the stream.\n // Output tokens, however, are only finalized in the last event.\n // Since we can't guarantee that the last event will include usage data or even be a typed event,\n // we update the output token values on every event that includes them.\n // This ensures that output token usage is always set, even if the final event lacks it.\n state.promptTokens = chunk.usage.prompt_tokens;\n state.completionTokens = chunk.usage.completion_tokens;\n state.totalTokens = chunk.usage.total_tokens;\n }\n\n for (const choice of chunk.choices ?? []) {\n if (recordOutputs) {\n if (choice.delta?.content) {\n state.responseTexts.push(choice.delta.content);\n }\n\n // Handle tool calls from delta\n if (choice.delta?.tool_calls) {\n processChatCompletionToolCalls(choice.delta.tool_calls, state);\n }\n }\n if (choice.finish_reason) {\n state.finishReasons.push(choice.finish_reason);\n }\n }\n}\n\n/**\n * Processes a single OpenAI Responses API streaming event, updating the streaming state and span.\n *\n * @param streamEvent - The event to process (may be an error or unknown object).\n * @param state - The current streaming state to update.\n * @param recordOutputs - Whether to record output text fragments.\n * @param span - The span to update with error status if needed.\n */\nfunction processResponsesApiEvent(\n streamEvent: ResponseStreamingEvent | unknown | Error,\n state: StreamingState,\n recordOutputs: boolean,\n span: Span,\n): void {\n if (!(streamEvent && typeof streamEvent === 'object')) {\n state.eventTypes.push('unknown:non-object');\n return;\n }\n if (streamEvent instanceof Error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(streamEvent, {\n mechanism: {\n handled: false,\n type: 'auto.ai.openai.stream-response',\n },\n });\n return;\n }\n\n if (!('type' in streamEvent)) return;\n const event = streamEvent as ResponseStreamingEvent;\n\n if (!RESPONSE_EVENT_TYPES.includes(event.type)) {\n state.eventTypes.push(event.type);\n return;\n }\n\n // Handle output text delta\n if (recordOutputs) {\n // Handle tool call events for Responses API\n if (event.type === 'response.output_item.done' && 'item' in event) {\n state.responsesApiToolCalls.push(event.item);\n }\n\n if (event.type === 'response.output_text.delta' && 'delta' in event && event.delta) {\n state.responseTexts.push(event.delta);\n return;\n }\n }\n\n if ('response' in event) {\n const { response } = event as { response: OpenAIResponseObject };\n state.responseId = response.id ?? state.responseId;\n state.responseModel = response.model ?? state.responseModel;\n\n if (response.usage) {\n // For stream responses, the input tokens remain constant across all events in the stream.\n // Output tokens, however, are only finalized in the last event.\n // Since we can't guarantee that the last event will include usage data or even be a typed event,\n // we update the output token values on every event that includes them.\n // This ensures that output token usage is always set, even if the final event lacks it.\n state.promptTokens = response.usage.input_tokens;\n state.completionTokens = response.usage.output_tokens;\n state.totalTokens = response.usage.total_tokens;\n }\n\n if (response.status) {\n state.finishReasons.push(response.status);\n }\n\n if (recordOutputs && response.output_text) {\n state.responseTexts.push(response.output_text);\n }\n }\n}\n\n/**\n * Instruments a stream of OpenAI events, updating the provided span with relevant attributes and\n * optionally recording output text. This function yields each event from the input stream as it is processed.\n *\n * @template T - The type of events in the stream.\n * @param stream - The async iterable stream of events to instrument.\n * @param span - The span to add attributes to and to finish at the end of the stream.\n * @param recordOutputs - Whether to record output text fragments in the span.\n * @returns An async generator yielding each event from the input stream.\n */\nexport async function* instrumentStream<T>(\n stream: AsyncIterable<T>,\n span: Span,\n recordOutputs: boolean,\n): AsyncGenerator<T, void, unknown> {\n const state: StreamingState = {\n eventTypes: [],\n responseTexts: [],\n finishReasons: [],\n responseId: '',\n responseModel: '',\n promptTokens: undefined,\n completionTokens: undefined,\n totalTokens: undefined,\n chatCompletionToolCalls: {},\n responsesApiToolCalls: [],\n };\n\n try {\n for await (const event of stream) {\n if (isChatCompletionChunk(event)) {\n processChatCompletionChunk(event as ChatCompletionChunk, state, recordOutputs);\n } else if (isResponsesApiStreamEvent(event)) {\n processResponsesApiEvent(event as ResponseStreamingEvent, state, recordOutputs, span);\n }\n yield event;\n }\n } finally {\n const allToolCalls = [...Object.values(state.chatCompletionToolCalls), ...state.responsesApiToolCalls];\n endStreamSpan(span, { ...state, toolCalls: allToolCalls }, recordOutputs);\n }\n}\n"],"names":["SPAN_STATUS_ERROR","captureException","RESPONSE_EVENT_TYPES","isChatCompletionChunk","isResponsesApiStreamEvent","endStreamSpan"],"mappings":";;;;;;;;AAcA;AACA;AACA;;AA8BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,8BAA8B,CAAC,SAAS,EAA4B,KAAK,EAAwB;AAC1G,EAAE,KAAK,MAAM,QAAA,IAAY,SAAS,EAAE;AACpC,IAAI,MAAM,KAAA,GAAQ,QAAQ,CAAC,KAAK;AAChC,IAAI,IAAI,KAAA,KAAU,SAAA,IAAa,CAAC,QAAQ,CAAC,QA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,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,YAAA,EAAc,EAAE,aAAa,CAAC;AAC7E,EAAE;AACF;;;;"} |
@@ -355,4 +355,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| delete this._attributes[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]; | ||
| let hasGenAiSpans = false; | ||
| spans.forEach(span => { | ||
| delete span.data[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]; | ||
| if (span.op?.startsWith('gen_ai.')) { | ||
| hasGenAiSpans = true; | ||
| } | ||
| }); | ||
@@ -379,2 +383,3 @@ // eslint-enabled-next-line @typescript-eslint/no-dynamic-delete | ||
| dynamicSamplingContext: dynamicSamplingContext.getDynamicSamplingContextFromSpan(this), | ||
| hasGenAiSpans, | ||
| }, | ||
@@ -381,0 +386,0 @@ request: normalizedRequest, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"sentrySpan.js","sources":["../../../src/tracing/sentrySpan.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { getClient, getCurrentScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { createSpanEnvelope } from '../envelope';\nimport {\n SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,\n SEMANTIC_ATTRIBUTE_PROFILE_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { SpanEnvelope } from '../types-hoist/envelope';\nimport type { TransactionEvent } from '../types-hoist/event';\nimport type { SpanLink } from '../types-hoist/link';\nimport type {\n SentrySpanArguments,\n Span,\n SpanAttributes,\n SpanAttributeValue,\n SpanContextData,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types-hoist/span';\nimport type { SpanStatus } from '../types-hoist/spanStatus';\nimport type { TimedEvent } from '../types-hoist/timedEvent';\nimport { debug } from '../utils/debug-logger';\nimport { generateSpanId, generateTraceId } from '../utils/propagationContext';\nimport {\n convertSpanLinksForEnvelope,\n getRootSpan,\n getSimpleStatusMessage,\n getSpanDescendants,\n getStatusMessage,\n getStreamedSpanLinks,\n spanTimeInputToSeconds,\n spanToJSON,\n spanToTransactionTraceContext,\n TRACE_FLAG_NONE,\n TRACE_FLAG_SAMPLED,\n} from '../utils/spanUtils';\nimport { timestampInSeconds } from '../utils/time';\nimport { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanEnd } from './logSpans';\nimport { timedEventsToMeasurements } from './measurement';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport { getCapturedScopesOnSpan } from './utils';\n\nconst MAX_SPAN_COUNT = 1000;\n\n/**\n * Span contains all data about a span\n */\nexport class SentrySpan implements Span {\n protected _traceId: string;\n protected _spanId: string;\n protected _parentSpanId?: string | undefined;\n protected _sampled: boolean | undefined;\n protected _name?: string | undefined;\n protected _attributes: SpanAttributes;\n protected _links?: SpanLink[];\n /** Epoch timestamp in seconds when the span started. */\n protected _startTime: number;\n /** Epoch timestamp in seconds when the span ended. */\n protected _endTime?: number | undefined;\n /** Internal keeper of the status */\n protected _status?: SpanStatus;\n /** The timed events added to this span. */\n protected _events: TimedEvent[];\n\n /** if true, treat span as a standalone span (not part of a transaction) */\n private _isStandaloneSpan?: boolean;\n\n /**\n * You should never call the constructor manually, always use `Sentry.startSpan()`\n * or other span methods.\n * @internal\n * @hideconstructor\n * @hidden\n */\n public constructor(spanContext: SentrySpanArguments = {}) {\n this._traceId = spanContext.traceId || generateTraceId();\n this._spanId = spanContext.spanId || generateSpanId();\n this._startTime = spanContext.startTimestamp || timestampInSeconds();\n this._links = spanContext.links;\n\n this._attributes = {};\n this.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: spanContext.op,\n ...spanContext.attributes,\n });\n\n this._name = spanContext.name;\n\n if (spanContext.parentSpanId) {\n this._parentSpanId = spanContext.parentSpanId;\n }\n // We want to include booleans as well here\n if ('sampled' in spanContext) {\n this._sampled = spanContext.sampled;\n }\n if (spanContext.endTimestamp) {\n this._endTime = spanContext.endTimestamp;\n }\n\n this._events = [];\n\n this._isStandaloneSpan = spanContext.isStandalone;\n\n // If the span is already ended, ensure we finalize the span immediately\n if (this._endTime) {\n this._onSpanEnded();\n }\n }\n\n /** @inheritDoc */\n public addLink(link: SpanLink): this {\n if (this._links) {\n this._links.push(link);\n } else {\n this._links = [link];\n }\n return this;\n }\n\n /** @inheritDoc */\n public addLinks(links: SpanLink[]): this {\n if (this._links) {\n this._links.push(...links);\n } else {\n this._links = links;\n }\n return this;\n }\n\n /**\n * This should generally not be used,\n * but it is needed for being compliant with the OTEL Span interface.\n *\n * @hidden\n * @internal\n */\n public recordException(_exception: unknown, _time?: number | undefined): void {\n // noop\n }\n\n /** @inheritdoc */\n public spanContext(): SpanContextData {\n const { _spanId: spanId, _traceId: traceId, _sampled: sampled } = this;\n return {\n spanId,\n traceId,\n traceFlags: sampled ? TRACE_FLAG_SAMPLED : TRACE_FLAG_NONE,\n };\n }\n\n /** @inheritdoc */\n public setAttribute(key: string, value: SpanAttributeValue | undefined): this {\n if (value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n } else {\n this._attributes[key] = value;\n }\n\n return this;\n }\n\n /** @inheritdoc */\n public setAttributes(attributes: SpanAttributes): this {\n Object.keys(attributes).forEach(key => this.setAttribute(key, attributes[key]));\n return this;\n }\n\n /**\n * This should generally not be used,\n * but we need it for browser tracing where we want to adjust the start time afterwards.\n * USE THIS WITH CAUTION!\n *\n * @hidden\n * @internal\n */\n public updateStartTime(timeInput: SpanTimeInput): void {\n this._startTime = spanTimeInputToSeconds(timeInput);\n }\n\n /**\n * @inheritDoc\n */\n public setStatus(value: SpanStatus): this {\n this._status = value;\n return this;\n }\n\n /**\n * @inheritDoc\n */\n public updateName(name: string): this {\n this._name = name;\n this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'custom');\n return this;\n }\n\n /** @inheritdoc */\n public end(endTimestamp?: SpanTimeInput): void {\n // If already ended, skip\n if (this._endTime) {\n return;\n }\n\n this._endTime = spanTimeInputToSeconds(endTimestamp);\n logSpanEnd(this);\n\n this._onSpanEnded();\n }\n\n /**\n * Get JSON representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToJSON(span)` instead.\n */\n public getSpanJSON(): SpanJSON {\n return {\n data: this._attributes,\n description: this._name,\n op: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n parent_span_id: this._parentSpanId,\n span_id: this._spanId,\n start_timestamp: this._startTime,\n status: getStatusMessage(this._status),\n timestamp: this._endTime,\n trace_id: this._traceId,\n origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n profile_id: this._attributes[SEMANTIC_ATTRIBUTE_PROFILE_ID] as string | undefined,\n exclusive_time: this._attributes[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME] as number | undefined,\n measurements: timedEventsToMeasurements(this._events),\n is_segment: (this._isStandaloneSpan && getRootSpan(this) === this) || undefined,\n segment_id: this._isStandaloneSpan ? getRootSpan(this).spanContext().spanId : undefined,\n links: convertSpanLinksForEnvelope(this._links),\n };\n }\n\n /**\n * Get {@link StreamedSpanJSON} representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToStreamedSpanJSON(span)` instead.\n */\n public getStreamedSpanJSON(): StreamedSpanJSON {\n return {\n name: this._name ?? '',\n span_id: this._spanId,\n trace_id: this._traceId,\n parent_span_id: this._parentSpanId,\n start_timestamp: this._startTime,\n // just in case _endTime is not set, we use the start time (i.e. duration 0)\n end_timestamp: this._endTime ?? this._startTime,\n is_segment: this._isStandaloneSpan || this === getRootSpan(this),\n status: getSimpleStatusMessage(this._status),\n attributes: this._attributes,\n links: getStreamedSpanLinks(this._links),\n };\n }\n\n /** @inheritdoc */\n public isRecording(): boolean {\n return !this._endTime && !!this._sampled;\n }\n\n /**\n * @inheritdoc\n */\n public addEvent(\n name: string,\n attributesOrStartTime?: SpanAttributes | SpanTimeInput,\n startTime?: SpanTimeInput,\n ): this {\n DEBUG_BUILD && debug.log('[Tracing] Adding an event to span:', name);\n\n const time = isSpanTimeInput(attributesOrStartTime) ? attributesOrStartTime : startTime || timestampInSeconds();\n const attributes = isSpanTimeInput(attributesOrStartTime) ? {} : attributesOrStartTime || {};\n\n const event: TimedEvent = {\n name,\n time: spanTimeInputToSeconds(time),\n attributes,\n };\n\n this._events.push(event);\n\n return this;\n }\n\n /**\n * This method should generally not be used,\n * but for now we need a way to publicly check if the `_isStandaloneSpan` flag is set.\n * USE THIS WITH CAUTION!\n * @internal\n * @hidden\n * @experimental\n */\n public isStandaloneSpan(): boolean {\n return !!this._isStandaloneSpan;\n }\n\n /** Emit `spanEnd` when the span is ended. */\n private _onSpanEnded(): void {\n const client = getClient();\n if (client) {\n client.emit('spanEnd', this);\n // Guarding sending standalone v1 spans as v2 streamed spans for now.\n // Otherwise they'd be sent once as v1 spans and again as streamed spans.\n // We'll migrate CLS and LCP spans to streamed spans in a later PR and\n // INP spans in the next major of the SDK. At that point, we can fully remove\n // standalone v1 spans <3\n if (!this._isStandaloneSpan) {\n client.emit('afterSpanEnd', this);\n }\n }\n\n // A segment span is basically the root span of a local span tree.\n // So for now, this is either what we previously refer to as the root span,\n // or a standalone span.\n const isSegmentSpan = this._isStandaloneSpan || this === getRootSpan(this);\n\n if (!isSegmentSpan) {\n return;\n }\n\n // if this is a standalone span, we send it immediately\n if (this._isStandaloneSpan) {\n if (this._sampled) {\n sendSpanEnvelope(createSpanEnvelope([this], client));\n } else {\n DEBUG_BUILD &&\n debug.log('[Tracing] Discarding standalone span because its trace was not chosen to be sampled.');\n if (client) {\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n return;\n } else if (client && hasSpanStreamingEnabled(client)) {\n // TODO (spans): Remove standalone span custom logic in favor of sending simple v2 web vital spans\n client.emit('afterSegmentSpanEnd', this);\n return;\n }\n\n const transactionEvent = this._convertSpanToTransaction();\n if (transactionEvent) {\n const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope();\n scope.captureEvent(transactionEvent);\n }\n }\n\n /**\n * Finish the transaction & prepare the event to send to Sentry.\n */\n private _convertSpanToTransaction(): TransactionEvent | undefined {\n // We can only convert finished spans\n if (!isFullFinishedSpan(spanToJSON(this))) {\n return undefined;\n }\n\n if (!this._name) {\n DEBUG_BUILD && debug.warn('Transaction has no name, falling back to `<unlabeled transaction>`.');\n this._name = '<unlabeled transaction>';\n }\n\n const { scope: capturedSpanScope, isolationScope: capturedSpanIsolationScope } = getCapturedScopesOnSpan(this);\n\n const normalizedRequest = capturedSpanScope?.getScopeData().sdkProcessingMetadata?.normalizedRequest;\n\n if (this._sampled !== true) {\n return undefined;\n }\n\n // The transaction span itself as well as any potential standalone spans should be filtered out\n const finishedSpans = getSpanDescendants(this).filter(span => span !== this && !isStandaloneSpan(span));\n\n const spans = finishedSpans.map(span => spanToJSON(span)).filter(isFullFinishedSpan);\n\n const source = this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n\n // remove internal root span attributes we don't need to send.\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n spans.forEach(span => {\n delete span.data[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n });\n // eslint-enabled-next-line @typescript-eslint/no-dynamic-delete\n\n const transaction: TransactionEvent = {\n contexts: {\n trace: spanToTransactionTraceContext(this),\n },\n spans:\n // spans.sort() mutates the array, but `spans` is already a copy so we can safely do this here\n // we do not use spans anymore after this point\n spans.length > MAX_SPAN_COUNT\n ? spans.sort((a, b) => a.start_timestamp - b.start_timestamp).slice(0, MAX_SPAN_COUNT)\n : spans,\n start_timestamp: this._startTime,\n timestamp: this._endTime,\n transaction: this._name,\n type: 'transaction',\n sdkProcessingMetadata: {\n capturedSpanScope,\n capturedSpanIsolationScope,\n dynamicSamplingContext: getDynamicSamplingContextFromSpan(this),\n },\n request: normalizedRequest,\n ...(source && {\n transaction_info: {\n source,\n },\n }),\n };\n\n const measurements = timedEventsToMeasurements(this._events);\n const hasMeasurements = measurements && Object.keys(measurements).length;\n\n if (hasMeasurements) {\n DEBUG_BUILD &&\n debug.log(\n '[Measurements] Adding measurements to transaction event',\n JSON.stringify(measurements, undefined, 2),\n );\n transaction.measurements = measurements;\n }\n\n return transaction;\n }\n}\n\nfunction isSpanTimeInput(value: undefined | SpanAttributes | SpanTimeInput): value is SpanTimeInput {\n return (value && typeof value === 'number') || value instanceof Date || Array.isArray(value);\n}\n\n// We want to filter out any incomplete SpanJSON objects\nfunction isFullFinishedSpan(input: Partial<SpanJSON>): input is SpanJSON {\n return !!input.start_timestamp && !!input.timestamp && !!input.span_id && !!input.trace_id;\n}\n\n/** `SentrySpan`s can be sent as a standalone span rather than belonging to a transaction */\nfunction isStandaloneSpan(span: Span): boolean {\n return span instanceof SentrySpan && span.isStandaloneSpan();\n}\n\n/**\n * Sends a `SpanEnvelope`.\n *\n * Note: If the envelope's spans are dropped, e.g. via `beforeSendSpan`,\n * the envelope will not be sent either.\n */\nfunction sendSpanEnvelope(envelope: SpanEnvelope): void {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const spanItems = envelope[1];\n if (!spanItems || spanItems.length === 0) {\n client.recordDroppedEvent('before_send', 'span');\n return;\n }\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n"],"names":["generateTraceId","generateSpanId","timestampInSeconds","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","TRACE_FLAG_SAMPLED","TRACE_FLAG_NONE","spanTimeInputToSeconds","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","logSpanEnd","getStatusMessage","SEMANTIC_ATTRIBUTE_PROFILE_ID","SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME","timedEventsToMeasurements","getRootSpan","convertSpanLinksForEnvelope","getSimpleStatusMessage","getStreamedSpanLinks","DEBUG_BUILD","debug","time","getClient","createSpanEnvelope","hasSpanStreamingEnabled","getCapturedScopesOnSpan","getCurrentScope","spanToJSON","getSpanDescendants","SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME","spanToTransactionTraceContext","getDynamicSamplingContextFromSpan"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AAkDA,MAAM,cAAA,GAAiB,IAAI;;AAE3B;AACA;AACA;AACO,MAAM,YAA2B;;AAQxC;;AAEA;;AAEA;;AAEA;;AAGA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAS,WAAW,CAAC,WAAW,GAAwB,EAAE,EAAE;AAC5D,IAAI,IAAI,CAAC,QAAA,GAAW,WAAW,CAAC,OAAA,IAAWA,kCAAe,EAAE;AAC5D,IAAI,IAAI,CAAC,OAAA,GAAU,WAAW,CAAC,MAAA,IAAUC,iCAAc,EAAE;AACzD,IAAI,IAAI,CAAC,UAAA,GAAa,WAAW,CAAC,cAAA,IAAkBC,uBAAkB,EAAE;AACxE,IAAI,IAAI,CAAC,MAAA,GAAS,WAAW,CAAC,KAAK;;AAEnC,IAAI,IAAI,CAAC,WAAA,GAAc,EAAE;AACzB,IAAI,IAAI,CAAC,aAAa,CAAC;AACvB,MAAM,CAACC,mDAAgC,GAAG,QAAQ;AAClD,MAAM,CAACC,+CAA4B,GAAG,WAAW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,EAAE;;AAEF,EAAE,MAAM,SAAA,GAAY,QAAQ,CAAC,CAAC,CAAC;AAC/B,EAAE,IAAI,CAAC,SAAA,IAAa,SAAS,CAAC,MAAA,KAAW,CAAC,EAAE;AAC5C,IAAI,MAAM,CAAC,kBAAkB,CAAC,aAAa,EAAE,MAAM,CAAC;AACpD,IAAI;AACJ,EAAE;;AAEF;AACA;AACA,EAAE,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC;AAC/B;;;;"} | ||
| {"version":3,"file":"sentrySpan.js","sources":["../../../src/tracing/sentrySpan.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { getClient, getCurrentScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { createSpanEnvelope } from '../envelope';\nimport {\n SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,\n SEMANTIC_ATTRIBUTE_PROFILE_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { SpanEnvelope } from '../types-hoist/envelope';\nimport type { TransactionEvent } from '../types-hoist/event';\nimport type { SpanLink } from '../types-hoist/link';\nimport type {\n SentrySpanArguments,\n Span,\n SpanAttributes,\n SpanAttributeValue,\n SpanContextData,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types-hoist/span';\nimport type { SpanStatus } from '../types-hoist/spanStatus';\nimport type { TimedEvent } from '../types-hoist/timedEvent';\nimport { debug } from '../utils/debug-logger';\nimport { generateSpanId, generateTraceId } from '../utils/propagationContext';\nimport {\n convertSpanLinksForEnvelope,\n getRootSpan,\n getSimpleStatusMessage,\n getSpanDescendants,\n getStatusMessage,\n getStreamedSpanLinks,\n spanTimeInputToSeconds,\n spanToJSON,\n spanToTransactionTraceContext,\n TRACE_FLAG_NONE,\n TRACE_FLAG_SAMPLED,\n} from '../utils/spanUtils';\nimport { timestampInSeconds } from '../utils/time';\nimport { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanEnd } from './logSpans';\nimport { timedEventsToMeasurements } from './measurement';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport { getCapturedScopesOnSpan } from './utils';\n\nconst MAX_SPAN_COUNT = 1000;\n\n/**\n * Span contains all data about a span\n */\nexport class SentrySpan implements Span {\n protected _traceId: string;\n protected _spanId: string;\n protected _parentSpanId?: string | undefined;\n protected _sampled: boolean | undefined;\n protected _name?: string | undefined;\n protected _attributes: SpanAttributes;\n protected _links?: SpanLink[];\n /** Epoch timestamp in seconds when the span started. */\n protected _startTime: number;\n /** Epoch timestamp in seconds when the span ended. */\n protected _endTime?: number | undefined;\n /** Internal keeper of the status */\n protected _status?: SpanStatus;\n /** The timed events added to this span. */\n protected _events: TimedEvent[];\n\n /** if true, treat span as a standalone span (not part of a transaction) */\n private _isStandaloneSpan?: boolean;\n\n /**\n * You should never call the constructor manually, always use `Sentry.startSpan()`\n * or other span methods.\n * @internal\n * @hideconstructor\n * @hidden\n */\n public constructor(spanContext: SentrySpanArguments = {}) {\n this._traceId = spanContext.traceId || generateTraceId();\n this._spanId = spanContext.spanId || generateSpanId();\n this._startTime = spanContext.startTimestamp || timestampInSeconds();\n this._links = spanContext.links;\n\n this._attributes = {};\n this.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: spanContext.op,\n ...spanContext.attributes,\n });\n\n this._name = spanContext.name;\n\n if (spanContext.parentSpanId) {\n this._parentSpanId = spanContext.parentSpanId;\n }\n // We want to include booleans as well here\n if ('sampled' in spanContext) {\n this._sampled = spanContext.sampled;\n }\n if (spanContext.endTimestamp) {\n this._endTime = spanContext.endTimestamp;\n }\n\n this._events = [];\n\n this._isStandaloneSpan = spanContext.isStandalone;\n\n // If the span is already ended, ensure we finalize the span immediately\n if (this._endTime) {\n this._onSpanEnded();\n }\n }\n\n /** @inheritDoc */\n public addLink(link: SpanLink): this {\n if (this._links) {\n this._links.push(link);\n } else {\n this._links = [link];\n }\n return this;\n }\n\n /** @inheritDoc */\n public addLinks(links: SpanLink[]): this {\n if (this._links) {\n this._links.push(...links);\n } else {\n this._links = links;\n }\n return this;\n }\n\n /**\n * This should generally not be used,\n * but it is needed for being compliant with the OTEL Span interface.\n *\n * @hidden\n * @internal\n */\n public recordException(_exception: unknown, _time?: number | undefined): void {\n // noop\n }\n\n /** @inheritdoc */\n public spanContext(): SpanContextData {\n const { _spanId: spanId, _traceId: traceId, _sampled: sampled } = this;\n return {\n spanId,\n traceId,\n traceFlags: sampled ? TRACE_FLAG_SAMPLED : TRACE_FLAG_NONE,\n };\n }\n\n /** @inheritdoc */\n public setAttribute(key: string, value: SpanAttributeValue | undefined): this {\n if (value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n } else {\n this._attributes[key] = value;\n }\n\n return this;\n }\n\n /** @inheritdoc */\n public setAttributes(attributes: SpanAttributes): this {\n Object.keys(attributes).forEach(key => this.setAttribute(key, attributes[key]));\n return this;\n }\n\n /**\n * This should generally not be used,\n * but we need it for browser tracing where we want to adjust the start time afterwards.\n * USE THIS WITH CAUTION!\n *\n * @hidden\n * @internal\n */\n public updateStartTime(timeInput: SpanTimeInput): void {\n this._startTime = spanTimeInputToSeconds(timeInput);\n }\n\n /**\n * @inheritDoc\n */\n public setStatus(value: SpanStatus): this {\n this._status = value;\n return this;\n }\n\n /**\n * @inheritDoc\n */\n public updateName(name: string): this {\n this._name = name;\n this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'custom');\n return this;\n }\n\n /** @inheritdoc */\n public end(endTimestamp?: SpanTimeInput): void {\n // If already ended, skip\n if (this._endTime) {\n return;\n }\n\n this._endTime = spanTimeInputToSeconds(endTimestamp);\n logSpanEnd(this);\n\n this._onSpanEnded();\n }\n\n /**\n * Get JSON representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToJSON(span)` instead.\n */\n public getSpanJSON(): SpanJSON {\n return {\n data: this._attributes,\n description: this._name,\n op: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n parent_span_id: this._parentSpanId,\n span_id: this._spanId,\n start_timestamp: this._startTime,\n status: getStatusMessage(this._status),\n timestamp: this._endTime,\n trace_id: this._traceId,\n origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n profile_id: this._attributes[SEMANTIC_ATTRIBUTE_PROFILE_ID] as string | undefined,\n exclusive_time: this._attributes[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME] as number | undefined,\n measurements: timedEventsToMeasurements(this._events),\n is_segment: (this._isStandaloneSpan && getRootSpan(this) === this) || undefined,\n segment_id: this._isStandaloneSpan ? getRootSpan(this).spanContext().spanId : undefined,\n links: convertSpanLinksForEnvelope(this._links),\n };\n }\n\n /**\n * Get {@link StreamedSpanJSON} representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToStreamedSpanJSON(span)` instead.\n */\n public getStreamedSpanJSON(): StreamedSpanJSON {\n return {\n name: this._name ?? '',\n span_id: this._spanId,\n trace_id: this._traceId,\n parent_span_id: this._parentSpanId,\n start_timestamp: this._startTime,\n // just in case _endTime is not set, we use the start time (i.e. duration 0)\n end_timestamp: this._endTime ?? this._startTime,\n is_segment: this._isStandaloneSpan || this === getRootSpan(this),\n status: getSimpleStatusMessage(this._status),\n attributes: this._attributes,\n links: getStreamedSpanLinks(this._links),\n };\n }\n\n /** @inheritdoc */\n public isRecording(): boolean {\n return !this._endTime && !!this._sampled;\n }\n\n /**\n * @inheritdoc\n */\n public addEvent(\n name: string,\n attributesOrStartTime?: SpanAttributes | SpanTimeInput,\n startTime?: SpanTimeInput,\n ): this {\n DEBUG_BUILD && debug.log('[Tracing] Adding an event to span:', name);\n\n const time = isSpanTimeInput(attributesOrStartTime) ? attributesOrStartTime : startTime || timestampInSeconds();\n const attributes = isSpanTimeInput(attributesOrStartTime) ? {} : attributesOrStartTime || {};\n\n const event: TimedEvent = {\n name,\n time: spanTimeInputToSeconds(time),\n attributes,\n };\n\n this._events.push(event);\n\n return this;\n }\n\n /**\n * This method should generally not be used,\n * but for now we need a way to publicly check if the `_isStandaloneSpan` flag is set.\n * USE THIS WITH CAUTION!\n * @internal\n * @hidden\n * @experimental\n */\n public isStandaloneSpan(): boolean {\n return !!this._isStandaloneSpan;\n }\n\n /** Emit `spanEnd` when the span is ended. */\n private _onSpanEnded(): void {\n const client = getClient();\n if (client) {\n client.emit('spanEnd', this);\n // Guarding sending standalone v1 spans as v2 streamed spans for now.\n // Otherwise they'd be sent once as v1 spans and again as streamed spans.\n // We'll migrate CLS and LCP spans to streamed spans in a later PR and\n // INP spans in the next major of the SDK. At that point, we can fully remove\n // standalone v1 spans <3\n if (!this._isStandaloneSpan) {\n client.emit('afterSpanEnd', this);\n }\n }\n\n // A segment span is basically the root span of a local span tree.\n // So for now, this is either what we previously refer to as the root span,\n // or a standalone span.\n const isSegmentSpan = this._isStandaloneSpan || this === getRootSpan(this);\n\n if (!isSegmentSpan) {\n return;\n }\n\n // if this is a standalone span, we send it immediately\n if (this._isStandaloneSpan) {\n if (this._sampled) {\n sendSpanEnvelope(createSpanEnvelope([this], client));\n } else {\n DEBUG_BUILD &&\n debug.log('[Tracing] Discarding standalone span because its trace was not chosen to be sampled.');\n if (client) {\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n return;\n } else if (client && hasSpanStreamingEnabled(client)) {\n // TODO (spans): Remove standalone span custom logic in favor of sending simple v2 web vital spans\n client.emit('afterSegmentSpanEnd', this);\n return;\n }\n\n const transactionEvent = this._convertSpanToTransaction();\n if (transactionEvent) {\n const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope();\n scope.captureEvent(transactionEvent);\n }\n }\n\n /**\n * Finish the transaction & prepare the event to send to Sentry.\n */\n private _convertSpanToTransaction(): TransactionEvent | undefined {\n // We can only convert finished spans\n if (!isFullFinishedSpan(spanToJSON(this))) {\n return undefined;\n }\n\n if (!this._name) {\n DEBUG_BUILD && debug.warn('Transaction has no name, falling back to `<unlabeled transaction>`.');\n this._name = '<unlabeled transaction>';\n }\n\n const { scope: capturedSpanScope, isolationScope: capturedSpanIsolationScope } = getCapturedScopesOnSpan(this);\n\n const normalizedRequest = capturedSpanScope?.getScopeData().sdkProcessingMetadata?.normalizedRequest;\n\n if (this._sampled !== true) {\n return undefined;\n }\n\n // The transaction span itself as well as any potential standalone spans should be filtered out\n const finishedSpans = getSpanDescendants(this).filter(span => span !== this && !isStandaloneSpan(span));\n\n const spans = finishedSpans.map(span => spanToJSON(span)).filter(isFullFinishedSpan);\n\n const source = this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n\n // remove internal root span attributes we don't need to send.\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n let hasGenAiSpans = false;\n spans.forEach(span => {\n delete span.data[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n if (span.op?.startsWith('gen_ai.')) {\n hasGenAiSpans = true;\n }\n });\n // eslint-enabled-next-line @typescript-eslint/no-dynamic-delete\n\n const transaction: TransactionEvent = {\n contexts: {\n trace: spanToTransactionTraceContext(this),\n },\n spans:\n // spans.sort() mutates the array, but `spans` is already a copy so we can safely do this here\n // we do not use spans anymore after this point\n spans.length > MAX_SPAN_COUNT\n ? spans.sort((a, b) => a.start_timestamp - b.start_timestamp).slice(0, MAX_SPAN_COUNT)\n : spans,\n start_timestamp: this._startTime,\n timestamp: this._endTime,\n transaction: this._name,\n type: 'transaction',\n sdkProcessingMetadata: {\n capturedSpanScope,\n capturedSpanIsolationScope,\n dynamicSamplingContext: getDynamicSamplingContextFromSpan(this),\n hasGenAiSpans,\n },\n request: normalizedRequest,\n ...(source && {\n transaction_info: {\n source,\n },\n }),\n };\n\n const measurements = timedEventsToMeasurements(this._events);\n const hasMeasurements = measurements && Object.keys(measurements).length;\n\n if (hasMeasurements) {\n DEBUG_BUILD &&\n debug.log(\n '[Measurements] Adding measurements to transaction event',\n JSON.stringify(measurements, undefined, 2),\n );\n transaction.measurements = measurements;\n }\n\n return transaction;\n }\n}\n\nfunction isSpanTimeInput(value: undefined | SpanAttributes | SpanTimeInput): value is SpanTimeInput {\n return (value && typeof value === 'number') || value instanceof Date || Array.isArray(value);\n}\n\n// We want to filter out any incomplete SpanJSON objects\nfunction isFullFinishedSpan(input: Partial<SpanJSON>): input is SpanJSON {\n return !!input.start_timestamp && !!input.timestamp && !!input.span_id && !!input.trace_id;\n}\n\n/** `SentrySpan`s can be sent as a standalone span rather than belonging to a transaction */\nfunction isStandaloneSpan(span: Span): boolean {\n return span instanceof SentrySpan && span.isStandaloneSpan();\n}\n\n/**\n * Sends a `SpanEnvelope`.\n *\n * Note: If the envelope's spans are dropped, e.g. via `beforeSendSpan`,\n * the envelope will not be sent either.\n */\nfunction sendSpanEnvelope(envelope: SpanEnvelope): void {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const spanItems = envelope[1];\n if (!spanItems || spanItems.length === 0) {\n client.recordDroppedEvent('before_send', 'span');\n return;\n }\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n"],"names":["generateTraceId","generateSpanId","timestampInSeconds","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","TRACE_FLAG_SAMPLED","TRACE_FLAG_NONE","spanTimeInputToSeconds","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","logSpanEnd","getStatusMessage","SEMANTIC_ATTRIBUTE_PROFILE_ID","SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME","timedEventsToMeasurements","getRootSpan","convertSpanLinksForEnvelope","getSimpleStatusMessage","getStreamedSpanLinks","DEBUG_BUILD","debug","time","getClient","createSpanEnvelope","hasSpanStreamingEnabled","getCapturedScopesOnSpan","getCurrentScope","spanToJSON","getSpanDescendants","SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME","spanToTransactionTraceContext","getDynamicSamplingContextFromSpan"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AAkDA,MAAM,cAAA,GAAiB,IAAI;;AAE3B;AACA;AACA;AACO,MAAM,YAA2B;;AAQxC;;AAEA;;AAEA;;AAEA;;AAGA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAS,WAAW,CAAC,WAAW,GAAwB,EAAE,EAAE;AAC5D,IAAI,IAAI,CAAC,QAAA,GAAW,WAAW,CAAC,OAAA,IAAWA,kCAAe,EAAE;AAC5D,IAAI,IAAI,CAAC,OAAA,GAAU,WAAW,CAAC,MAAA,IAAUC,iCAAc,EAAE;AACzD,IAAI,IAAI,CAAC,UAAA,GAAa,WAAW,CAAC,cAAA,IAAkBC,uBAAkB,EAAE;AACxE,IAAI,IAAI,CAAC,MAAA,GAAS,WAAW,CAAC,KAAK;;AAEnC,IAAI,IAAI,CAAC,WAAA,GAAc,EAAE;AACzB,IAAI,IAAI,CAAC,aAAa,CAAC;AACvB,MAAM,CAACC,mDAAgC,GAAG,QAAQ;AAClD,MAAM,CAACC,+CAA4B,GAAG,WAAW,CAAC,EAAE;AACpD,MAAM,GAAG,WAAW,CAAC,UAAU;AAC/B,KAAK,CAAC;;AAEN,IAAI,IAAI,CAAC,KAAA,GAAQ,WAAW,CAAC,IAAI;;AAEjC,IAAI,IAAI,WAAW,CAAC,YAAY,EAAE;AAClC,MAAM,IAAI,CAAC,aAAA,GAAgB,WAAW,CAAC,YAAY;AACnD,IAAI;A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C;AAC/B,EAAE,IAAI,CAAC,SAAA,IAAa,SAAS,CAAC,MAAA,KAAW,CAAC,EAAE;AAC5C,IAAI,MAAM,CAAC,kBAAkB,CAAC,aAAa,EAAE,MAAM,CAAC;AACpD,IAAI;AACJ,EAAE;;AAEF;AACA;AACA,EAAE,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC;AAC/B;;;;"} |
@@ -272,4 +272,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| // Change attributes namespaced with `ai.X` to `vercel.ai.X` | ||
| for (const key of Object.keys(attributes)) { | ||
| // JSON-stringify any array-valued attributes so they survive v2 span serialization. | ||
| // Can be removed once span streaming supports arrays natively. | ||
| if (Array.isArray(attributes[key])) { | ||
| attributes[key] = JSON.stringify(attributes[key]); | ||
| } | ||
| // Change attributes namespaced with `ai.X` to `vercel.ai.X` | ||
| if (key.startsWith('ai.')) { | ||
@@ -276,0 +281,0 @@ renameAttributeKey(attributes, key, `vercel.${key}`); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/vercel-ai/index.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { Client } from '../../client';\nimport { getClient } from '../../currentScopes';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { shouldEnableTruncation } from '../ai/utils';\nimport type { Event } from '../../types-hoist/event';\nimport type { Span, SpanAttributes, SpanAttributeValue, SpanJSON, StreamedSpanJSON } from '../../types-hoist/span';\nimport { spanToJSON } from '../../utils/spanUtils';\nimport {\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_OUTPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_TOOL_CALL_ID_ATTRIBUTE,\n GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE,\n GEN_AI_TOOL_INPUT_ATTRIBUTE,\n GEN_AI_TOOL_NAME_ATTRIBUTE,\n GEN_AI_TOOL_OUTPUT_ATTRIBUTE,\n GEN_AI_TOOL_TYPE_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport { SPAN_TO_OPERATION_NAME, toolCallSpanContextMap, toolDescriptionMap } from './constants';\nimport type { TokenSummary } from './types';\nimport { hasSpanStreamingEnabled } from '../spans/hasSpanStreamingEnabled';\nimport {\n accumulateTokensForParent,\n applyAccumulatedTokens,\n applyToolDescriptionsAndTokens,\n convertAvailableToolsToJsonString,\n requestMessagesFromPrompt,\n} from './utils';\nimport type { OpenAiProviderMetadata, ProviderMetadata } from './vercel-ai-attributes';\nimport {\n AI_MODEL_ID_ATTRIBUTE,\n AI_OPERATION_ID_ATTRIBUTE,\n AI_PROMPT_MESSAGES_ATTRIBUTE,\n AI_PROMPT_TOOLS_ATTRIBUTE,\n AI_RESPONSE_FINISH_REASON_ATTRIBUTE,\n AI_RESPONSE_OBJECT_ATTRIBUTE,\n AI_RESPONSE_PROVIDER_METADATA_ATTRIBUTE,\n AI_RESPONSE_TEXT_ATTRIBUTE,\n AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n AI_SCHEMA_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TOOL_CALL_ARGS_ATTRIBUTE,\n AI_TOOL_CALL_ID_ATTRIBUTE,\n AI_TOOL_CALL_NAME_ATTRIBUTE,\n AI_TOOL_CALL_RESULT_ATTRIBUTE,\n AI_USAGE_CACHED_INPUT_TOKENS_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n AI_USAGE_TOKENS_ATTRIBUTE,\n AI_VALUES_ATTRIBUTE,\n OPERATION_NAME_ATTRIBUTE,\n} from './vercel-ai-attributes';\n\n/**\n * Post-process spans emitted by the Vercel AI SDK.\n * This is supposed to be used in `client.on('spanStart', ...)\n */\nfunction onVercelAiSpanStart(span: Span): void {\n const { data: attributes, description: name } = spanToJSON(span);\n\n if (!name) {\n return;\n }\n\n // Tool call spans\n // https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n if (attributes[AI_TOOL_CALL_NAME_ATTRIBUTE] && attributes[AI_TOOL_CALL_ID_ATTRIBUTE] && name === 'ai.toolCall') {\n processToolCallSpan(span, attributes);\n return;\n }\n\n // V6+ Check if this is a Vercel AI span by checking if the operation ID attribute is present.\n // V5+ Check if this is a Vercel AI span by name pattern.\n if (!attributes[AI_OPERATION_ID_ATTRIBUTE] && !name.startsWith('ai.')) {\n return;\n }\n\n const client = getClient();\n const integration = client?.getIntegrationByName('VercelAI') as\n | { options?: { enableTruncation?: boolean } }\n | undefined;\n const enableTruncation = shouldEnableTruncation(integration?.options?.enableTruncation);\n\n processGenerateSpan(span, name, attributes, enableTruncation);\n}\n\nfunction vercelAiEventProcessor(event: Event): Event {\n if (event.type === 'transaction' && event.spans) {\n // Map to accumulate token data by parent span ID\n const tokenAccumulator: Map<string, TokenSummary> = new Map();\n\n // First pass: process all spans and accumulate token data\n for (const span of event.spans) {\n processEndedVercelAiSpan(span);\n\n // Accumulate token data for parent spans\n accumulateTokensForParent(span, tokenAccumulator);\n }\n\n // Second pass: apply tool descriptions and accumulated tokens\n applyToolDescriptionsAndTokens(event.spans, tokenAccumulator);\n\n // Also apply to root when it is the invoke_agent pipeline\n const trace = event.contexts?.trace;\n if (trace?.op === 'gen_ai.invoke_agent') {\n applyAccumulatedTokens(trace, tokenAccumulator);\n }\n }\n\n return event;\n}\n\n/**\n * Tool call structure from Vercel AI SDK\n * Note: V5/V6 use 'input' for arguments, V4 and earlier use 'args'\n */\ninterface VercelToolCall {\n toolCallId: string;\n toolName: string;\n input?: Record<string, unknown> | string; // V5/V6\n args?: string; // V4 and earlier\n}\n\n/**\n * Normalize finish reason to match OpenTelemetry semantic conventions.\n * Valid values: \"stop\", \"length\", \"content_filter\", \"tool_call\", \"error\"\n *\n * Vercel AI SDK uses \"tool-calls\" (plural, with hyphen) which we map to \"tool_call\".\n */\nfunction normalizeFinishReason(finishReason: unknown): string {\n if (typeof finishReason !== 'string') {\n return 'stop';\n }\n\n // Map Vercel AI SDK finish reasons to OpenTelemetry semantic convention values\n switch (finishReason) {\n case 'tool-calls':\n return 'tool_call';\n case 'stop':\n case 'length':\n case 'content_filter':\n case 'error':\n return finishReason;\n default:\n // For unknown values, return as-is (schema allows arbitrary strings)\n return finishReason;\n }\n}\n\n/**\n * Build gen_ai.output.messages from ai.response.text and/or ai.response.toolCalls\n *\n * Format follows OpenTelemetry semantic conventions:\n * [{\"role\": \"assistant\", \"parts\": [...], \"finish_reason\": \"stop\"}]\n *\n * Parts can be:\n * - {\"type\": \"text\", \"content\": \"...\"}\n * - {\"type\": \"tool_call\", \"id\": \"...\", \"name\": \"...\", \"arguments\": \"...\"}\n */\nfunction buildOutputMessages(attributes: Record<string, unknown>): void {\n const responseText = attributes[AI_RESPONSE_TEXT_ATTRIBUTE];\n const responseToolCalls = attributes[AI_RESPONSE_TOOL_CALLS_ATTRIBUTE];\n const finishReason = attributes[AI_RESPONSE_FINISH_REASON_ATTRIBUTE];\n\n // Skip if neither text nor tool calls are present\n if (responseText == null && responseToolCalls == null) {\n return;\n }\n\n const parts: Array<Record<string, unknown>> = [];\n\n // Add text part if present\n if (typeof responseText === 'string' && responseText.length > 0) {\n parts.push({\n type: 'text',\n content: responseText,\n });\n }\n\n // Add tool call parts if present\n if (responseToolCalls != null) {\n try {\n // Tool calls can be a string (JSON) or already parsed array\n const toolCalls: VercelToolCall[] =\n typeof responseToolCalls === 'string' ? JSON.parse(responseToolCalls) : responseToolCalls;\n\n if (Array.isArray(toolCalls)) {\n for (const toolCall of toolCalls) {\n // V5/V6 use 'input', V4 and earlier use 'args'\n const args = toolCall.input ?? toolCall.args;\n parts.push({\n type: 'tool_call',\n id: toolCall.toolCallId,\n name: toolCall.toolName,\n // Handle undefined args: JSON.stringify(undefined) returns undefined, not a string,\n // which would cause the property to be omitted from the final JSON output\n arguments: typeof args === 'string' ? args : JSON.stringify(args ?? {}),\n });\n }\n // Only delete tool calls attribute if we successfully processed them\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[AI_RESPONSE_TOOL_CALLS_ATTRIBUTE];\n }\n } catch {\n // Ignore parsing errors - tool calls attribute is preserved\n }\n }\n\n // Only set output messages and delete text attribute if we have parts\n if (parts.length > 0) {\n const outputMessage = {\n role: 'assistant',\n parts,\n finish_reason: normalizeFinishReason(finishReason),\n };\n\n attributes[GEN_AI_OUTPUT_MESSAGES_ATTRIBUTE] = JSON.stringify([outputMessage]);\n\n // Remove the text attribute since it's now captured in gen_ai.output.messages\n // Note: tool calls attribute is deleted above only if successfully parsed\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[AI_RESPONSE_TEXT_ATTRIBUTE];\n }\n}\n\n/**\n * Post-process spans emitted by the Vercel AI SDK.\n */\n/**\n * Rename and normalize Vercel AI SDK attributes to OpenTelemetry semantic conventions.\n * This is the shared attribute processing logic used by both the legacy event processor\n * path (SpanJSON) and the streamed span path (StreamedSpanJSON).\n */\nexport function processVercelAiSpanAttributes(attributes: Record<string, unknown>): void {\n renameAttributeKey(attributes, AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE, GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE);\n renameAttributeKey(attributes, AI_USAGE_PROMPT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE);\n renameAttributeKey(attributes, AI_USAGE_CACHED_INPUT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE);\n\n // Parent spans (ai.streamText, ai.streamObject, etc.) use inputTokens/outputTokens instead of promptTokens/completionTokens\n renameAttributeKey(attributes, 'ai.usage.inputTokens', GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE);\n renameAttributeKey(attributes, 'ai.usage.outputTokens', GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE);\n\n // Embedding spans use ai.usage.tokens instead of promptTokens/completionTokens\n renameAttributeKey(attributes, AI_USAGE_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE);\n\n // AI SDK uses avgOutputTokensPerSecond, map to our expected attribute name\n renameAttributeKey(attributes, 'ai.response.avgOutputTokensPerSecond', 'ai.response.avgCompletionTokensPerSecond');\n\n // Input tokens is the sum of prompt tokens and cached input tokens\n if (\n typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] === 'number' &&\n typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE] === 'number'\n ) {\n attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] =\n attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] + attributes[GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE];\n }\n\n // Compute total tokens from input + output (embeddings may only have input tokens)\n if (typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] === 'number') {\n const outputTokens =\n typeof attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] === 'number'\n ? attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]\n : 0;\n attributes[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE] = outputTokens + attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE];\n }\n\n // Convert the available tools array to a JSON string\n if (attributes[AI_PROMPT_TOOLS_ATTRIBUTE] && Array.isArray(attributes[AI_PROMPT_TOOLS_ATTRIBUTE])) {\n attributes[AI_PROMPT_TOOLS_ATTRIBUTE] = convertAvailableToolsToJsonString(\n attributes[AI_PROMPT_TOOLS_ATTRIBUTE] as unknown[],\n );\n }\n\n // Rename AI SDK attributes to standardized gen_ai attributes\n // Map operation.name to OpenTelemetry semantic convention values\n if (attributes[OPERATION_NAME_ATTRIBUTE]) {\n // V6+ sets ai.operationId to the bare operation (e.g. \"ai.streamText\") while\n // operation.name appends functionId (e.g. \"ai.streamText myAgent\").\n // When ai.operationId is present, use it for correct mapping.\n const rawOperationName = attributes[AI_OPERATION_ID_ATTRIBUTE]\n ? (attributes[AI_OPERATION_ID_ATTRIBUTE] as string)\n : (attributes[OPERATION_NAME_ATTRIBUTE] as string);\n const operationName = SPAN_TO_OPERATION_NAME.get(rawOperationName) ?? rawOperationName;\n attributes[GEN_AI_OPERATION_NAME_ATTRIBUTE] = operationName;\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[OPERATION_NAME_ATTRIBUTE];\n }\n renameAttributeKey(attributes, AI_PROMPT_MESSAGES_ATTRIBUTE, GEN_AI_INPUT_MESSAGES_ATTRIBUTE);\n\n // Build gen_ai.output.messages from response text and/or tool calls\n // Note: buildOutputMessages also removes the source attributes when output is successfully generated\n buildOutputMessages(attributes);\n\n renameAttributeKey(attributes, AI_RESPONSE_OBJECT_ATTRIBUTE, 'gen_ai.response.object');\n renameAttributeKey(attributes, AI_PROMPT_TOOLS_ATTRIBUTE, 'gen_ai.request.available_tools');\n\n renameAttributeKey(attributes, AI_TOOL_CALL_ARGS_ATTRIBUTE, GEN_AI_TOOL_INPUT_ATTRIBUTE);\n renameAttributeKey(attributes, AI_TOOL_CALL_RESULT_ATTRIBUTE, GEN_AI_TOOL_OUTPUT_ATTRIBUTE);\n\n renameAttributeKey(attributes, AI_SCHEMA_ATTRIBUTE, 'gen_ai.request.schema');\n renameAttributeKey(attributes, AI_MODEL_ID_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE);\n\n // Map embedding input: ai.values → gen_ai.embeddings.input\n // Vercel AI SDK JSON-stringifies each value individually, so we parse each element back.\n // Single embed gets unwrapped to a plain value; batch embedMany stays as a JSON array.\n if (Array.isArray(attributes[AI_VALUES_ATTRIBUTE])) {\n const parsed = (attributes[AI_VALUES_ATTRIBUTE] as string[]).map(v => {\n try {\n return JSON.parse(v);\n } catch {\n return v;\n }\n });\n attributes[GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE] = parsed.length === 1 ? parsed[0] : JSON.stringify(parsed);\n }\n\n addProviderMetadataToAttributes(attributes);\n\n // Change attributes namespaced with `ai.X` to `vercel.ai.X`\n for (const key of Object.keys(attributes)) {\n if (key.startsWith('ai.')) {\n renameAttributeKey(attributes, key, `vercel.${key}`);\n }\n }\n}\n\nfunction processEndedVercelAiSpan(span: SpanJSON): void {\n const { data: attributes, origin } = span;\n\n if (origin !== 'auto.vercelai.otel') {\n return;\n }\n\n // The Vercel AI SDK sets span status to raw error message strings.\n // Any such value should be normalized to a SpanStatusType value. We pick internal_error as it is the most generic.\n if (span.status && span.status !== 'ok') {\n span.status = 'internal_error';\n }\n\n processVercelAiSpanAttributes(attributes);\n}\n\nfunction processVercelAiStreamedSpan(span: StreamedSpanJSON): void {\n const attributes = span.attributes;\n if (attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] !== 'auto.vercelai.otel') {\n return;\n }\n\n processVercelAiSpanAttributes(attributes);\n\n // Look up tool description from the toolDescriptionMap for execute_tool spans\n if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] === 'gen_ai.execute_tool' && span.parent_span_id) {\n const descriptions = toolDescriptionMap.get(span.parent_span_id);\n\n if (descriptions) {\n const toolName = attributes[GEN_AI_TOOL_NAME_ATTRIBUTE];\n if (typeof toolName === 'string') {\n const desc = descriptions.get(toolName);\n if (desc) {\n attributes[GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE] = desc;\n }\n }\n }\n }\n\n // Clean up tool descriptions when the parent span ends\n toolDescriptionMap.delete(span.span_id);\n}\n\n/**\n * Renames an attribute key in the provided attributes object if the old key exists.\n * This function safely handles null and undefined values.\n */\nfunction renameAttributeKey(attributes: Record<string, unknown>, oldKey: string, newKey: string): void {\n if (attributes[oldKey] != null) {\n attributes[newKey] = attributes[oldKey];\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[oldKey];\n }\n}\n\nfunction processToolCallSpan(span: Span, attributes: SpanAttributes): void {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.vercelai.otel');\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.execute_tool');\n span.setAttribute(GEN_AI_OPERATION_NAME_ATTRIBUTE, 'execute_tool');\n renameAttributeKey(attributes, AI_TOOL_CALL_NAME_ATTRIBUTE, GEN_AI_TOOL_NAME_ATTRIBUTE);\n renameAttributeKey(attributes, AI_TOOL_CALL_ID_ATTRIBUTE, GEN_AI_TOOL_CALL_ID_ATTRIBUTE);\n\n // Store the span context in our global map using the tool call ID.\n // This allows us to capture tool errors and link them to the correct span\n // without retaining the full Span object in memory.\n const toolCallId = attributes[GEN_AI_TOOL_CALL_ID_ATTRIBUTE];\n\n if (typeof toolCallId === 'string') {\n toolCallSpanContextMap.set(toolCallId, span.spanContext());\n }\n\n // https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-tool-type\n if (!attributes[GEN_AI_TOOL_TYPE_ATTRIBUTE]) {\n span.setAttribute(GEN_AI_TOOL_TYPE_ATTRIBUTE, 'function');\n }\n const toolName = attributes[GEN_AI_TOOL_NAME_ATTRIBUTE];\n if (toolName) {\n span.updateName(`execute_tool ${toolName}`);\n }\n}\n\nfunction processGenerateSpan(span: Span, name: string, attributes: SpanAttributes, enableTruncation: boolean): void {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.vercelai.otel');\n\n const nameWthoutAi = name.replace('ai.', '');\n span.setAttribute('ai.pipeline.name', nameWthoutAi);\n span.updateName(nameWthoutAi);\n\n const functionId = attributes[AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE];\n if (functionId && typeof functionId === 'string') {\n span.setAttribute('gen_ai.function_id', functionId);\n }\n\n requestMessagesFromPrompt(span, attributes, enableTruncation);\n\n if (attributes[AI_MODEL_ID_ATTRIBUTE] && !attributes[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]) {\n span.setAttribute(GEN_AI_RESPONSE_MODEL_ATTRIBUTE, attributes[AI_MODEL_ID_ATTRIBUTE]);\n }\n span.setAttribute('ai.streaming', name.includes('stream'));\n\n // Set the op based on the operation name registry\n const operationName = SPAN_TO_OPERATION_NAME.get(name);\n if (operationName) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, `gen_ai.${operationName}`);\n } else if (name.startsWith('ai.stream')) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.run');\n }\n\n // For invoke_agent pipeline spans, use 'invoke_agent' as the description\n // to be consistent with other AI integrations (e.g. LangGraph)\n if (operationName === 'invoke_agent') {\n if (functionId && typeof functionId === 'string') {\n span.updateName(`invoke_agent ${functionId}`);\n } else {\n span.updateName('invoke_agent');\n }\n return;\n }\n\n const modelId = attributes[AI_MODEL_ID_ATTRIBUTE];\n if (modelId && operationName) {\n span.updateName(`${operationName} ${modelId}`);\n }\n\n // Store tool descriptions in the toolDescriptionMap so processSpan can apply them to execute_tool spans.\n // This is only needed for span streaming (transaction path handles this separately)\n const client = getClient();\n if (\n client &&\n hasSpanStreamingEnabled(client) &&\n attributes[AI_PROMPT_TOOLS_ATTRIBUTE] &&\n Array.isArray(attributes[AI_PROMPT_TOOLS_ATTRIBUTE])\n ) {\n const descriptions = new Map<string, string>();\n\n // parse tool names and descriptions from tool string array\n for (const toolStr of attributes[AI_PROMPT_TOOLS_ATTRIBUTE] as unknown[]) {\n try {\n const parsed = (typeof toolStr === 'string' ? JSON.parse(toolStr) : toolStr) as {\n name?: string;\n description?: string;\n };\n if (parsed?.name && parsed?.description) {\n descriptions.set(parsed.name, parsed.description);\n }\n } catch {\n // ignore parse errors\n }\n }\n if (descriptions.size > 0) {\n // Tool call spans are siblings of doGenerate (both children of invoke_agent),\n // so we key by the parent span ID (the invoke_agent span).\n const parentSpanId = spanToJSON(span).parent_span_id;\n if (parentSpanId) {\n toolDescriptionMap.set(parentSpanId, descriptions);\n }\n }\n }\n}\n\n/**\n * Add event processors to the given client to process Vercel AI spans.\n */\nexport function addVercelAiProcessors(client: Client): void {\n client.on('spanStart', onVercelAiSpanStart);\n // Note: We cannot do this on `spanEnd`, because the span cannot be mutated anymore at this point\n client.addEventProcessor(Object.assign(vercelAiEventProcessor, { id: 'VercelAiEventProcessor' }));\n client.on('processSpan', span => {\n processVercelAiStreamedSpan(span);\n });\n}\n\nfunction addProviderMetadataToAttributes(attributes: Record<string, unknown>): void {\n const providerMetadata = attributes[AI_RESPONSE_PROVIDER_METADATA_ATTRIBUTE] as string | undefined;\n if (providerMetadata) {\n try {\n const providerMetadataObject = JSON.parse(providerMetadata) as ProviderMetadata;\n\n // Handle OpenAI metadata (v5 uses 'openai', v6 Azure Responses API uses 'azure')\n const openaiMetadata: OpenAiProviderMetadata | undefined =\n providerMetadataObject.openai ?? providerMetadataObject.azure;\n if (openaiMetadata) {\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n openaiMetadata.cachedPromptTokens,\n );\n setAttributeIfDefined(attributes, 'gen_ai.usage.output_tokens.reasoning', openaiMetadata.reasoningTokens);\n setAttributeIfDefined(\n attributes,\n 'gen_ai.usage.output_tokens.prediction_accepted',\n openaiMetadata.acceptedPredictionTokens,\n );\n setAttributeIfDefined(\n attributes,\n 'gen_ai.usage.output_tokens.prediction_rejected',\n openaiMetadata.rejectedPredictionTokens,\n );\n if (!attributes['gen_ai.conversation.id']) {\n setAttributeIfDefined(attributes, 'gen_ai.conversation.id', openaiMetadata.responseId);\n }\n }\n\n if (providerMetadataObject.anthropic) {\n const cachedInputTokens =\n providerMetadataObject.anthropic.usage?.cache_read_input_tokens ??\n providerMetadataObject.anthropic.cacheReadInputTokens;\n setAttributeIfDefined(attributes, GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE, cachedInputTokens);\n\n const cacheWriteInputTokens =\n providerMetadataObject.anthropic.usage?.cache_creation_input_tokens ??\n providerMetadataObject.anthropic.cacheCreationInputTokens;\n setAttributeIfDefined(attributes, GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE_ATTRIBUTE, cacheWriteInputTokens);\n }\n\n if (providerMetadataObject.bedrock?.usage) {\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n providerMetadataObject.bedrock.usage.cacheReadInputTokens,\n );\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE_ATTRIBUTE,\n providerMetadataObject.bedrock.usage.cacheWriteInputTokens,\n );\n }\n\n if (providerMetadataObject.deepseek) {\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n providerMetadataObject.deepseek.promptCacheHitTokens,\n );\n setAttributeIfDefined(\n attributes,\n 'gen_ai.usage.input_tokens.cache_miss',\n providerMetadataObject.deepseek.promptCacheMissTokens,\n );\n }\n } catch {\n // Ignore\n }\n }\n}\n\n/**\n * Sets an attribute only if the value is not null or undefined.\n */\nfunction setAttributeIfDefined(\n attributes: Record<string, unknown>,\n key: string,\n value: SpanAttributeValue | undefined,\n): void {\n if (value != null) {\n attributes[key] = value;\n }\n}\n"],"names":["spanToJSON","AI_TOOL_CALL_NAME_ATTRIBUTE","AI_TOOL_CALL_ID_ATTRIBUTE","AI_OPERATION_ID_ATTRIBUTE","getClient","shouldEnableTruncation","accumulateTokensForParent","applyToolDescriptionsAndTokens","applyAccumulatedTokens","AI_RESPONSE_TEXT_ATTRIBUTE","AI_RESPONSE_TOOL_CALLS_ATTRIBUTE","AI_RESPONSE_FINISH_REASON_ATTRIBUTE","GEN_AI_OUTPUT_MESSAGES_ATTRIBUTE","AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE","GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE","AI_USAGE_PROMPT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE","AI_USAGE_CACHED_INPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE","AI_USAGE_TOKENS_ATTRIBUTE","GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE","AI_PROMPT_TOOLS_ATTRIBUTE","convertAvailableToolsToJsonString","OPERATION_NAME_ATTRIBUTE","SPAN_TO_OPERATION_NAME","GEN_AI_OPERATION_NAME_ATTRIBUTE","AI_PROMPT_MESSAGES_ATTRIBUTE","GEN_AI_INPUT_MESSAGES_ATTRIBUTE","AI_RESPONSE_OBJECT_ATTRIBUTE","AI_TOOL_CALL_ARGS_ATTRIBUTE","GEN_AI_TOOL_INPUT_ATTRIBUTE","AI_TOOL_CALL_RESULT_ATTRIBUTE","GEN_AI_TOOL_OUTPUT_ATTRIBUTE","AI_SCHEMA_ATTRIBUTE","AI_MODEL_ID_ATTRIBUTE","GEN_AI_REQUEST_MODEL_ATTRIBUTE","AI_VALUES_ATTRIBUTE","GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","toolDescriptionMap","GEN_AI_TOOL_NAME_ATTRIBUTE","GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE","GEN_AI_T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KAAA,EAAA,2BAAA;AACA,UAAA,sBAAA,CAAA,SAAA,CAAA,wBAAA;AACA,QAAA,qBAAA,CAAA,UAAA,EAAAiC,+DAAA,EAAA,qBAAA,CAAA;AACA,MAAA;;AAEA,MAAA,IAAA,sBAAA,CAAA,OAAA,EAAA,KAAA,EAAA;AACA,QAAA,qBAAA;AACA,UAAA,UAAA;AACA,UAAAjC,0DAAA;AACA,UAAA,sBAAA,CAAA,OAAA,CAAA,KAAA,CAAA,oBAAA;AACA,SAAA;AACA,QAAA,qBAAA;AACA,UAAA,UAAA;AACA,UAAAiC,+DAAA;AACA,UAAA,sBAAA,CAAA,OAAA,CAAA,KAAA,CAAA,qBAAA;AACA,SAAA;AACA,MAAA;;AAEA,MAAA,IAAA,sBAAA,CAAA,QAAA,EAAA;AACA,QAAA,qBAAA;AACA,UAAA,UAAA;AACA,UAAAjC,0DAAA;AACA,UAAA,sBAAA,CAAA,QAAA,CAAA,oBAAA;AACA,SAAA;AACA,QAAA,qBAAA;AACA,UAAA,UAAA;AACA,UAAA,sCAAA;AACA,UAAA,sBAAA,CAAA,QAAA,CAAA,qBAAA;AACA,SAAA;AACA,MAAA;AACA,IAAA,CAAA,CAAA,MAAA;AACA;AACA,IAAA;AACA,EAAA;AACA;;AAEA;AACA;AACA;AACA,SAAA,qBAAA;AACA,EAAA,UAAA;AACA,EAAA,GAAA;AACA,EAAA,KAAA;AACA,EAAA;AACA,EAAA,IAAA,KAAA,IAAA,IAAA,EAAA;AACA,IAAA,UAAA,CAAA,GAAA,CAAA,GAAA,KAAA;AACA,EAAA;AACA;;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/vercel-ai/index.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { Client } from '../../client';\nimport { getClient } from '../../currentScopes';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { shouldEnableTruncation } from '../ai/utils';\nimport type { Event } from '../../types-hoist/event';\nimport type { Span, SpanAttributes, SpanAttributeValue, SpanJSON, StreamedSpanJSON } from '../../types-hoist/span';\nimport { spanToJSON } from '../../utils/spanUtils';\nimport {\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_OUTPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_TOOL_CALL_ID_ATTRIBUTE,\n GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE,\n GEN_AI_TOOL_INPUT_ATTRIBUTE,\n GEN_AI_TOOL_NAME_ATTRIBUTE,\n GEN_AI_TOOL_OUTPUT_ATTRIBUTE,\n GEN_AI_TOOL_TYPE_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport { SPAN_TO_OPERATION_NAME, toolCallSpanContextMap, toolDescriptionMap } from './constants';\nimport type { TokenSummary } from './types';\nimport { hasSpanStreamingEnabled } from '../spans/hasSpanStreamingEnabled';\nimport {\n accumulateTokensForParent,\n applyAccumulatedTokens,\n applyToolDescriptionsAndTokens,\n convertAvailableToolsToJsonString,\n requestMessagesFromPrompt,\n} from './utils';\nimport type { OpenAiProviderMetadata, ProviderMetadata } from './vercel-ai-attributes';\nimport {\n AI_MODEL_ID_ATTRIBUTE,\n AI_OPERATION_ID_ATTRIBUTE,\n AI_PROMPT_MESSAGES_ATTRIBUTE,\n AI_PROMPT_TOOLS_ATTRIBUTE,\n AI_RESPONSE_FINISH_REASON_ATTRIBUTE,\n AI_RESPONSE_OBJECT_ATTRIBUTE,\n AI_RESPONSE_PROVIDER_METADATA_ATTRIBUTE,\n AI_RESPONSE_TEXT_ATTRIBUTE,\n AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n AI_SCHEMA_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TOOL_CALL_ARGS_ATTRIBUTE,\n AI_TOOL_CALL_ID_ATTRIBUTE,\n AI_TOOL_CALL_NAME_ATTRIBUTE,\n AI_TOOL_CALL_RESULT_ATTRIBUTE,\n AI_USAGE_CACHED_INPUT_TOKENS_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n AI_USAGE_TOKENS_ATTRIBUTE,\n AI_VALUES_ATTRIBUTE,\n OPERATION_NAME_ATTRIBUTE,\n} from './vercel-ai-attributes';\n\n/**\n * Post-process spans emitted by the Vercel AI SDK.\n * This is supposed to be used in `client.on('spanStart', ...)\n */\nfunction onVercelAiSpanStart(span: Span): void {\n const { data: attributes, description: name } = spanToJSON(span);\n\n if (!name) {\n return;\n }\n\n // Tool call spans\n // https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n if (attributes[AI_TOOL_CALL_NAME_ATTRIBUTE] && attributes[AI_TOOL_CALL_ID_ATTRIBUTE] && name === 'ai.toolCall') {\n processToolCallSpan(span, attributes);\n return;\n }\n\n // V6+ Check if this is a Vercel AI span by checking if the operation ID attribute is present.\n // V5+ Check if this is a Vercel AI span by name pattern.\n if (!attributes[AI_OPERATION_ID_ATTRIBUTE] && !name.startsWith('ai.')) {\n return;\n }\n\n const client = getClient();\n const integration = client?.getIntegrationByName('VercelAI') as\n | { options?: { enableTruncation?: boolean } }\n | undefined;\n const enableTruncation = shouldEnableTruncation(integration?.options?.enableTruncation);\n\n processGenerateSpan(span, name, attributes, enableTruncation);\n}\n\nfunction vercelAiEventProcessor(event: Event): Event {\n if (event.type === 'transaction' && event.spans) {\n // Map to accumulate token data by parent span ID\n const tokenAccumulator: Map<string, TokenSummary> = new Map();\n\n // First pass: process all spans and accumulate token data\n for (const span of event.spans) {\n processEndedVercelAiSpan(span);\n\n // Accumulate token data for parent spans\n accumulateTokensForParent(span, tokenAccumulator);\n }\n\n // Second pass: apply tool descriptions and accumulated tokens\n applyToolDescriptionsAndTokens(event.spans, tokenAccumulator);\n\n // Also apply to root when it is the invoke_agent pipeline\n const trace = event.contexts?.trace;\n if (trace?.op === 'gen_ai.invoke_agent') {\n applyAccumulatedTokens(trace, tokenAccumulator);\n }\n }\n\n return event;\n}\n\n/**\n * Tool call structure from Vercel AI SDK\n * Note: V5/V6 use 'input' for arguments, V4 and earlier use 'args'\n */\ninterface VercelToolCall {\n toolCallId: string;\n toolName: string;\n input?: Record<string, unknown> | string; // V5/V6\n args?: string; // V4 and earlier\n}\n\n/**\n * Normalize finish reason to match OpenTelemetry semantic conventions.\n * Valid values: \"stop\", \"length\", \"content_filter\", \"tool_call\", \"error\"\n *\n * Vercel AI SDK uses \"tool-calls\" (plural, with hyphen) which we map to \"tool_call\".\n */\nfunction normalizeFinishReason(finishReason: unknown): string {\n if (typeof finishReason !== 'string') {\n return 'stop';\n }\n\n // Map Vercel AI SDK finish reasons to OpenTelemetry semantic convention values\n switch (finishReason) {\n case 'tool-calls':\n return 'tool_call';\n case 'stop':\n case 'length':\n case 'content_filter':\n case 'error':\n return finishReason;\n default:\n // For unknown values, return as-is (schema allows arbitrary strings)\n return finishReason;\n }\n}\n\n/**\n * Build gen_ai.output.messages from ai.response.text and/or ai.response.toolCalls\n *\n * Format follows OpenTelemetry semantic conventions:\n * [{\"role\": \"assistant\", \"parts\": [...], \"finish_reason\": \"stop\"}]\n *\n * Parts can be:\n * - {\"type\": \"text\", \"content\": \"...\"}\n * - {\"type\": \"tool_call\", \"id\": \"...\", \"name\": \"...\", \"arguments\": \"...\"}\n */\nfunction buildOutputMessages(attributes: Record<string, unknown>): void {\n const responseText = attributes[AI_RESPONSE_TEXT_ATTRIBUTE];\n const responseToolCalls = attributes[AI_RESPONSE_TOOL_CALLS_ATTRIBUTE];\n const finishReason = attributes[AI_RESPONSE_FINISH_REASON_ATTRIBUTE];\n\n // Skip if neither text nor tool calls are present\n if (responseText == null && responseToolCalls == null) {\n return;\n }\n\n const parts: Array<Record<string, unknown>> = [];\n\n // Add text part if present\n if (typeof responseText === 'string' && responseText.length > 0) {\n parts.push({\n type: 'text',\n content: responseText,\n });\n }\n\n // Add tool call parts if present\n if (responseToolCalls != null) {\n try {\n // Tool calls can be a string (JSON) or already parsed array\n const toolCalls: VercelToolCall[] =\n typeof responseToolCalls === 'string' ? JSON.parse(responseToolCalls) : responseToolCalls;\n\n if (Array.isArray(toolCalls)) {\n for (const toolCall of toolCalls) {\n // V5/V6 use 'input', V4 and earlier use 'args'\n const args = toolCall.input ?? toolCall.args;\n parts.push({\n type: 'tool_call',\n id: toolCall.toolCallId,\n name: toolCall.toolName,\n // Handle undefined args: JSON.stringify(undefined) returns undefined, not a string,\n // which would cause the property to be omitted from the final JSON output\n arguments: typeof args === 'string' ? args : JSON.stringify(args ?? {}),\n });\n }\n // Only delete tool calls attribute if we successfully processed them\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[AI_RESPONSE_TOOL_CALLS_ATTRIBUTE];\n }\n } catch {\n // Ignore parsing errors - tool calls attribute is preserved\n }\n }\n\n // Only set output messages and delete text attribute if we have parts\n if (parts.length > 0) {\n const outputMessage = {\n role: 'assistant',\n parts,\n finish_reason: normalizeFinishReason(finishReason),\n };\n\n attributes[GEN_AI_OUTPUT_MESSAGES_ATTRIBUTE] = JSON.stringify([outputMessage]);\n\n // Remove the text attribute since it's now captured in gen_ai.output.messages\n // Note: tool calls attribute is deleted above only if successfully parsed\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[AI_RESPONSE_TEXT_ATTRIBUTE];\n }\n}\n\n/**\n * Post-process spans emitted by the Vercel AI SDK.\n */\n/**\n * Rename and normalize Vercel AI SDK attributes to OpenTelemetry semantic conventions.\n * This is the shared attribute processing logic used by both the legacy event processor\n * path (SpanJSON) and the streamed span path (StreamedSpanJSON).\n */\nexport function processVercelAiSpanAttributes(attributes: Record<string, unknown>): void {\n renameAttributeKey(attributes, AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE, GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE);\n renameAttributeKey(attributes, AI_USAGE_PROMPT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE);\n renameAttributeKey(attributes, AI_USAGE_CACHED_INPUT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE);\n\n // Parent spans (ai.streamText, ai.streamObject, etc.) use inputTokens/outputTokens instead of promptTokens/completionTokens\n renameAttributeKey(attributes, 'ai.usage.inputTokens', GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE);\n renameAttributeKey(attributes, 'ai.usage.outputTokens', GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE);\n\n // Embedding spans use ai.usage.tokens instead of promptTokens/completionTokens\n renameAttributeKey(attributes, AI_USAGE_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE);\n\n // AI SDK uses avgOutputTokensPerSecond, map to our expected attribute name\n renameAttributeKey(attributes, 'ai.response.avgOutputTokensPerSecond', 'ai.response.avgCompletionTokensPerSecond');\n\n // Input tokens is the sum of prompt tokens and cached input tokens\n if (\n typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] === 'number' &&\n typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE] === 'number'\n ) {\n attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] =\n attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] + attributes[GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE];\n }\n\n // Compute total tokens from input + output (embeddings may only have input tokens)\n if (typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] === 'number') {\n const outputTokens =\n typeof attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] === 'number'\n ? attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]\n : 0;\n attributes[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE] = outputTokens + attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE];\n }\n\n // Convert the available tools array to a JSON string\n if (attributes[AI_PROMPT_TOOLS_ATTRIBUTE] && Array.isArray(attributes[AI_PROMPT_TOOLS_ATTRIBUTE])) {\n attributes[AI_PROMPT_TOOLS_ATTRIBUTE] = convertAvailableToolsToJsonString(\n attributes[AI_PROMPT_TOOLS_ATTRIBUTE] as unknown[],\n );\n }\n\n // Rename AI SDK attributes to standardized gen_ai attributes\n // Map operation.name to OpenTelemetry semantic convention values\n if (attributes[OPERATION_NAME_ATTRIBUTE]) {\n // V6+ sets ai.operationId to the bare operation (e.g. \"ai.streamText\") while\n // operation.name appends functionId (e.g. \"ai.streamText myAgent\").\n // When ai.operationId is present, use it for correct mapping.\n const rawOperationName = attributes[AI_OPERATION_ID_ATTRIBUTE]\n ? (attributes[AI_OPERATION_ID_ATTRIBUTE] as string)\n : (attributes[OPERATION_NAME_ATTRIBUTE] as string);\n const operationName = SPAN_TO_OPERATION_NAME.get(rawOperationName) ?? rawOperationName;\n attributes[GEN_AI_OPERATION_NAME_ATTRIBUTE] = operationName;\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[OPERATION_NAME_ATTRIBUTE];\n }\n renameAttributeKey(attributes, AI_PROMPT_MESSAGES_ATTRIBUTE, GEN_AI_INPUT_MESSAGES_ATTRIBUTE);\n\n // Build gen_ai.output.messages from response text and/or tool calls\n // Note: buildOutputMessages also removes the source attributes when output is successfully generated\n buildOutputMessages(attributes);\n\n renameAttributeKey(attributes, AI_RESPONSE_OBJECT_ATTRIBUTE, 'gen_ai.response.object');\n renameAttributeKey(attributes, AI_PROMPT_TOOLS_ATTRIBUTE, 'gen_ai.request.available_tools');\n\n renameAttributeKey(attributes, AI_TOOL_CALL_ARGS_ATTRIBUTE, GEN_AI_TOOL_INPUT_ATTRIBUTE);\n renameAttributeKey(attributes, AI_TOOL_CALL_RESULT_ATTRIBUTE, GEN_AI_TOOL_OUTPUT_ATTRIBUTE);\n\n renameAttributeKey(attributes, AI_SCHEMA_ATTRIBUTE, 'gen_ai.request.schema');\n renameAttributeKey(attributes, AI_MODEL_ID_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE);\n\n // Map embedding input: ai.values → gen_ai.embeddings.input\n // Vercel AI SDK JSON-stringifies each value individually, so we parse each element back.\n // Single embed gets unwrapped to a plain value; batch embedMany stays as a JSON array.\n if (Array.isArray(attributes[AI_VALUES_ATTRIBUTE])) {\n const parsed = (attributes[AI_VALUES_ATTRIBUTE] as string[]).map(v => {\n try {\n return JSON.parse(v);\n } catch {\n return v;\n }\n });\n attributes[GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE] = parsed.length === 1 ? parsed[0] : JSON.stringify(parsed);\n }\n\n addProviderMetadataToAttributes(attributes);\n\n for (const key of Object.keys(attributes)) {\n // JSON-stringify any array-valued attributes so they survive v2 span serialization.\n // Can be removed once span streaming supports arrays natively.\n if (Array.isArray(attributes[key])) {\n attributes[key] = JSON.stringify(attributes[key]);\n }\n // Change attributes namespaced with `ai.X` to `vercel.ai.X`\n if (key.startsWith('ai.')) {\n renameAttributeKey(attributes, key, `vercel.${key}`);\n }\n }\n}\n\nfunction processEndedVercelAiSpan(span: SpanJSON): void {\n const { data: attributes, origin } = span;\n\n if (origin !== 'auto.vercelai.otel') {\n return;\n }\n\n // The Vercel AI SDK sets span status to raw error message strings.\n // Any such value should be normalized to a SpanStatusType value. We pick internal_error as it is the most generic.\n if (span.status && span.status !== 'ok') {\n span.status = 'internal_error';\n }\n\n processVercelAiSpanAttributes(attributes);\n}\n\nfunction processVercelAiStreamedSpan(span: StreamedSpanJSON): void {\n const attributes = span.attributes;\n if (attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] !== 'auto.vercelai.otel') {\n return;\n }\n\n processVercelAiSpanAttributes(attributes);\n\n // Look up tool description from the toolDescriptionMap for execute_tool spans\n if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] === 'gen_ai.execute_tool' && span.parent_span_id) {\n const descriptions = toolDescriptionMap.get(span.parent_span_id);\n\n if (descriptions) {\n const toolName = attributes[GEN_AI_TOOL_NAME_ATTRIBUTE];\n if (typeof toolName === 'string') {\n const desc = descriptions.get(toolName);\n if (desc) {\n attributes[GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE] = desc;\n }\n }\n }\n }\n\n // Clean up tool descriptions when the parent span ends\n toolDescriptionMap.delete(span.span_id);\n}\n\n/**\n * Renames an attribute key in the provided attributes object if the old key exists.\n * This function safely handles null and undefined values.\n */\nfunction renameAttributeKey(attributes: Record<string, unknown>, oldKey: string, newKey: string): void {\n if (attributes[oldKey] != null) {\n attributes[newKey] = attributes[oldKey];\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[oldKey];\n }\n}\n\nfunction processToolCallSpan(span: Span, attributes: SpanAttributes): void {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.vercelai.otel');\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.execute_tool');\n span.setAttribute(GEN_AI_OPERATION_NAME_ATTRIBUTE, 'execute_tool');\n renameAttributeKey(attributes, AI_TOOL_CALL_NAME_ATTRIBUTE, GEN_AI_TOOL_NAME_ATTRIBUTE);\n renameAttributeKey(attributes, AI_TOOL_CALL_ID_ATTRIBUTE, GEN_AI_TOOL_CALL_ID_ATTRIBUTE);\n\n // Store the span context in our global map using the tool call ID.\n // This allows us to capture tool errors and link them to the correct span\n // without retaining the full Span object in memory.\n const toolCallId = attributes[GEN_AI_TOOL_CALL_ID_ATTRIBUTE];\n\n if (typeof toolCallId === 'string') {\n toolCallSpanContextMap.set(toolCallId, span.spanContext());\n }\n\n // https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-tool-type\n if (!attributes[GEN_AI_TOOL_TYPE_ATTRIBUTE]) {\n span.setAttribute(GEN_AI_TOOL_TYPE_ATTRIBUTE, 'function');\n }\n const toolName = attributes[GEN_AI_TOOL_NAME_ATTRIBUTE];\n if (toolName) {\n span.updateName(`execute_tool ${toolName}`);\n }\n}\n\nfunction processGenerateSpan(span: Span, name: string, attributes: SpanAttributes, enableTruncation: boolean): void {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.vercelai.otel');\n\n const nameWthoutAi = name.replace('ai.', '');\n span.setAttribute('ai.pipeline.name', nameWthoutAi);\n span.updateName(nameWthoutAi);\n\n const functionId = attributes[AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE];\n if (functionId && typeof functionId === 'string') {\n span.setAttribute('gen_ai.function_id', functionId);\n }\n\n requestMessagesFromPrompt(span, attributes, enableTruncation);\n\n if (attributes[AI_MODEL_ID_ATTRIBUTE] && !attributes[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]) {\n span.setAttribute(GEN_AI_RESPONSE_MODEL_ATTRIBUTE, attributes[AI_MODEL_ID_ATTRIBUTE]);\n }\n span.setAttribute('ai.streaming', name.includes('stream'));\n\n // Set the op based on the operation name registry\n const operationName = SPAN_TO_OPERATION_NAME.get(name);\n if (operationName) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, `gen_ai.${operationName}`);\n } else if (name.startsWith('ai.stream')) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.run');\n }\n\n // For invoke_agent pipeline spans, use 'invoke_agent' as the description\n // to be consistent with other AI integrations (e.g. LangGraph)\n if (operationName === 'invoke_agent') {\n if (functionId && typeof functionId === 'string') {\n span.updateName(`invoke_agent ${functionId}`);\n } else {\n span.updateName('invoke_agent');\n }\n return;\n }\n\n const modelId = attributes[AI_MODEL_ID_ATTRIBUTE];\n if (modelId && operationName) {\n span.updateName(`${operationName} ${modelId}`);\n }\n\n // Store tool descriptions in the toolDescriptionMap so processSpan can apply them to execute_tool spans.\n // This is only needed for span streaming (transaction path handles this separately)\n const client = getClient();\n if (\n client &&\n hasSpanStreamingEnabled(client) &&\n attributes[AI_PROMPT_TOOLS_ATTRIBUTE] &&\n Array.isArray(attributes[AI_PROMPT_TOOLS_ATTRIBUTE])\n ) {\n const descriptions = new Map<string, string>();\n\n // parse tool names and descriptions from tool string array\n for (const toolStr of attributes[AI_PROMPT_TOOLS_ATTRIBUTE] as unknown[]) {\n try {\n const parsed = (typeof toolStr === 'string' ? JSON.parse(toolStr) : toolStr) as {\n name?: string;\n description?: string;\n };\n if (parsed?.name && parsed?.description) {\n descriptions.set(parsed.name, parsed.description);\n }\n } catch {\n // ignore parse errors\n }\n }\n if (descriptions.size > 0) {\n // Tool call spans are siblings of doGenerate (both children of invoke_agent),\n // so we key by the parent span ID (the invoke_agent span).\n const parentSpanId = spanToJSON(span).parent_span_id;\n if (parentSpanId) {\n toolDescriptionMap.set(parentSpanId, descriptions);\n }\n }\n }\n}\n\n/**\n * Add event processors to the given client to process Vercel AI spans.\n */\nexport function addVercelAiProcessors(client: Client): void {\n client.on('spanStart', onVercelAiSpanStart);\n // Note: We cannot do this on `spanEnd`, because the span cannot be mutated anymore at this point\n client.addEventProcessor(Object.assign(vercelAiEventProcessor, { id: 'VercelAiEventProcessor' }));\n client.on('processSpan', span => {\n processVercelAiStreamedSpan(span);\n });\n}\n\nfunction addProviderMetadataToAttributes(attributes: Record<string, unknown>): void {\n const providerMetadata = attributes[AI_RESPONSE_PROVIDER_METADATA_ATTRIBUTE] as string | undefined;\n if (providerMetadata) {\n try {\n const providerMetadataObject = JSON.parse(providerMetadata) as ProviderMetadata;\n\n // Handle OpenAI metadata (v5 uses 'openai', v6 Azure Responses API uses 'azure')\n const openaiMetadata: OpenAiProviderMetadata | undefined =\n providerMetadataObject.openai ?? providerMetadataObject.azure;\n if (openaiMetadata) {\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n openaiMetadata.cachedPromptTokens,\n );\n setAttributeIfDefined(attributes, 'gen_ai.usage.output_tokens.reasoning', openaiMetadata.reasoningTokens);\n setAttributeIfDefined(\n attributes,\n 'gen_ai.usage.output_tokens.prediction_accepted',\n openaiMetadata.acceptedPredictionTokens,\n );\n setAttributeIfDefined(\n attributes,\n 'gen_ai.usage.output_tokens.prediction_rejected',\n openaiMetadata.rejectedPredictionTokens,\n );\n if (!attributes['gen_ai.conversation.id']) {\n setAttributeIfDefined(attributes, 'gen_ai.conversation.id', openaiMetadata.responseId);\n }\n }\n\n if (providerMetadataObject.anthropic) {\n const cachedInputTokens =\n providerMetadataObject.anthropic.usage?.cache_read_input_tokens ??\n providerMetadataObject.anthropic.cacheReadInputTokens;\n setAttributeIfDefined(attributes, GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE, cachedInputTokens);\n\n const cacheWriteInputTokens =\n providerMetadataObject.anthropic.usage?.cache_creation_input_tokens ??\n providerMetadataObject.anthropic.cacheCreationInputTokens;\n setAttributeIfDefined(attributes, GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE_ATTRIBUTE, cacheWriteInputTokens);\n }\n\n if (providerMetadataObject.bedrock?.usage) {\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n providerMetadataObject.bedrock.usage.cacheReadInputTokens,\n );\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE_ATTRIBUTE,\n providerMetadataObject.bedrock.usage.cacheWriteInputTokens,\n );\n }\n\n if (providerMetadataObject.deepseek) {\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n providerMetadataObject.deepseek.promptCacheHitTokens,\n );\n setAttributeIfDefined(\n attributes,\n 'gen_ai.usage.input_tokens.cache_miss',\n providerMetadataObject.deepseek.promptCacheMissTokens,\n );\n }\n } catch {\n // Ignore\n }\n }\n}\n\n/**\n * Sets an attribute only if the value is not null or undefined.\n */\nfunction setAttributeIfDefined(\n attributes: Record<string, unknown>,\n key: string,\n value: SpanAttributeValue | undefined,\n): void {\n if (value != null) {\n attributes[key] = value;\n }\n}\n"],"names":["spanToJSON","AI_TOOL_CALL_NAME_ATTRIBUTE","AI_TOOL_CALL_ID_ATTRIBUTE","AI_OPERATION_ID_ATTRIBUTE","getClient","shouldEnableTruncation","accumulateTokensForParent","applyToolDescriptionsAndTokens","applyAccumulatedTokens","AI_RESPONSE_TEXT_ATTRIBUTE","AI_RESPONSE_TOOL_CALLS_ATTRIBUTE","AI_RESPONSE_FINISH_REASON_ATTRIBUTE","GEN_AI_OUTPUT_MESSAGES_ATTRIBUTE","AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE","GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE","AI_USAGE_PROMPT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE","AI_USAGE_CACHED_INPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE","AI_USAGE_TOKENS_ATTRIBUTE","GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE","AI_PROMPT_TOOLS_ATTRIBUTE","convertAvailableToolsToJsonString","OPERATION_NAME_ATTRIBUTE","SPAN_TO_OPERATION_NAME","GEN_AI_OPERATION_NAME_ATTRIBUTE","AI_PROMPT_MESSAGES_ATTRIBUTE","GEN_AI_INPUT_MESSAGES_ATTRIBUTE","AI_RESPONSE_OBJECT_ATTRIBUTE","AI_TOOL_CALL_ARGS_ATTRIBUTE","GEN_AI_TOOL_INPUT_ATTRIBUTE","AI_TOOL_CALL_RESULT_ATTRIBUTE","GEN_AI_TOOL_OUTPUT_ATTRIBUTE","AI_SCHEMA_ATTRIBUTE","AI_MODEL_ID_ATTRIBUTE","GEN_AI_REQUEST_MODEL_ATTRIBUTE","AI_VALUES_ATTRIBUTE","GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","toolDescriptionMap","GEN_AI_TOOL_NAME_ATTRIBUTE","GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE","GEN_AI_TOOL_CALL_ID_ATTRIBUTE","toolCallSpanContextMap","GEN_AI_TOOL_TYPE_ATTRIBUTE","AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE","requestMessagesFromPrompt","GEN_AI_RESPONSE_MODEL_ATTRIBUTE","hasSpanStreamingEnabled","AI_RESPONSE_PROVIDER_METADATA_ATTRIBUTE","GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE_ATTRIBUTE"],"mappings":";;;;;;;;;;;;AA8DA;AACA;AACA;AACA;AACA,SAAS,mBAAmB,CAAC,IAAI,EAAc;AAC/C,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,IAAA,EAAK,GAAIA,oBAAU,CAAC,IAAI,CAAC;;AAElE,EAAE,IAAI,CAAC,IAAI,EAAE;AACb,IAAI;AACJ,EAAE;;AAEF;AACA;AACA,EAAE,IAAI,UAAU,CAACC,8CAA2B,CAAA,IAAK,UAAU,CAACC,4CAAyB,CAAA,IAAK,IAAA,KAAS,aAAa,EAAE;AAClH,IAAI,mBAAmB,CAAC,IAAI,EAAE,UAAU,CAAC;AACzC,IAAI;AACJ,EAAE;;AAEF;AACA;AACA,EAAE,IAAI,CAAC,UAAU,CAACC,4CAAyB,CAAA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A,QAAA,CAAA,oBAAA;AACA,SAAA;AACA,QAAA,qBAAA;AACA,UAAA,UAAA;AACA,UAAA,sCAAA;AACA,UAAA,sBAAA,CAAA,QAAA,CAAA,qBAAA;AACA,SAAA;AACA,MAAA;AACA,IAAA,CAAA,CAAA,MAAA;AACA;AACA,IAAA;AACA,EAAA;AACA;;AAEA;AACA;AACA;AACA,SAAA,qBAAA;AACA,EAAA,UAAA;AACA,EAAA,GAAA;AACA,EAAA,KAAA;AACA,EAAA;AACA,EAAA,IAAA,KAAA,IAAA,IAAA,EAAA;AACA,IAAA,UAAA,CAAA,GAAA,CAAA,GAAA,KAAA;AACA,EAAA;AACA;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const currentScopes = require('./currentScopes.js'); | ||
| const _exports = require('./exports.js'); | ||
| const exports$1 = require('./exports.js'); | ||
| const semanticAttributes = require('./semanticAttributes.js'); | ||
@@ -21,3 +21,3 @@ const normalize = require('./utils/normalize.js'); | ||
| ) { | ||
| _exports.captureException(nextResult.error, trpcCaptureContext); | ||
| exports$1.captureException(nextResult.error, trpcCaptureContext); | ||
| } | ||
@@ -84,3 +84,3 @@ } | ||
| } catch (e) { | ||
| _exports.captureException(e, trpcCaptureContext); | ||
| exports$1.captureException(e, trpcCaptureContext); | ||
| span.end(); | ||
@@ -87,0 +87,0 @@ throw e; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"trpc.js","sources":["../../src/trpc.ts"],"sourcesContent":["import { getClient, withIsolationScope } from './currentScopes';\nimport { captureException } from './exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from './semanticAttributes';\nimport { startSpanManual } from './tracing';\nimport { normalize } from './utils/normalize';\nimport { setNormalizationDepthOverrideHint } from './utils/normalizationHints';\n\ninterface SentryTrpcMiddlewareOptions {\n /** Whether to include procedure inputs in reported events. Defaults to `false`. */\n attachRpcInput?: boolean;\n forceTransaction?: boolean;\n}\n\nexport interface SentryTrpcMiddlewareArguments<T> {\n path?: unknown;\n type?: unknown;\n next: () => T;\n rawInput?: unknown;\n getRawInput?: () => Promise<unknown>;\n}\n\nconst trpcCaptureContext = { mechanism: { handled: false, type: 'auto.rpc.trpc.middleware' } };\n\nfunction captureIfError(nextResult: unknown): void {\n // TODO: Set span status based on what TRPCError was encountered\n if (\n typeof nextResult === 'object' &&\n nextResult !== null &&\n 'ok' in nextResult &&\n !nextResult.ok &&\n 'error' in nextResult\n ) {\n captureException(nextResult.error, trpcCaptureContext);\n }\n}\n\ntype SentryTrpcMiddleware<T> = T extends Promise<unknown> ? T : Promise<T>;\n\n/**\n * Sentry tRPC middleware that captures errors and creates spans for tRPC procedures.\n */\nexport function trpcMiddleware(options: SentryTrpcMiddlewareOptions = {}) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return async function <T>(opts: SentryTrpcMiddlewareArguments<T>): SentryTrpcMiddleware<T> {\n const { path, type, next, rawInput, getRawInput } = opts;\n\n const client = getClient();\n const clientOptions = client?.getOptions();\n\n const trpcContext: Record<string, unknown> = {\n procedure_path: path,\n procedure_type: type,\n };\n\n setNormalizationDepthOverrideHint(\n trpcContext,\n 1 + // 1 for context.input + the normal normalization depth\n (clientOptions?.normalizeDepth ?? 5), // 5 is a sane depth\n );\n\n if (options.attachRpcInput !== undefined ? options.attachRpcInput : clientOptions?.sendDefaultPii) {\n if (rawInput !== undefined) {\n trpcContext.input = normalize(rawInput);\n }\n\n if (getRawInput !== undefined && typeof getRawInput === 'function') {\n try {\n const rawRes = await getRawInput();\n\n trpcContext.input = normalize(rawRes);\n } catch {\n // noop\n }\n }\n }\n\n return withIsolationScope(scope => {\n scope.setContext('trpc', trpcContext);\n return startSpanManual(\n {\n name: `trpc/${path}`,\n op: 'rpc.server',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.rpc.trpc',\n },\n forceTransaction: !!options.forceTransaction,\n },\n async span => {\n try {\n const nextResult = await next();\n captureIfError(nextResult);\n span.end();\n return nextResult;\n } catch (e) {\n captureException(e, trpcCaptureContext);\n span.end();\n throw e;\n }\n },\n ) as SentryTrpcMiddleware<T>;\n });\n };\n}\n"],"names":["captureException","getClient","setNormalizationDepthOverrideHint","normalize","withIsolationScope","startSpanManual","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN"],"mappings":";;;;;;;;;AAqBA,MAAM,kBAAA,GAAqB,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,0BAAA,IAA8B;;AAE9F,SAAS,cAAc,CAAC,UAAU,EAAiB;AACnD;AACA,EAAE;AACF,IAAI,OAAO,UAAA,KAAe,QAAA;AAC1B,IAAI,UAAA,KAAe,IAAA;AACnB,IAAI,IAAA,IAAQ,UAAA;AACZ,IAAI,CAAC,UAAU,CAAC,EAAA;AAChB,IAAI,WAAW;AACf,IAAI;AACJ,IAAIA,yBAAgB,CAAC,UAAU,CAAC,KAAK,EAAE,kBAAkB,CAAC;AAC1D,EAAE;AACF;;AAIA;AACA;AACA;AACO,SAAS,cAAc,CAAC,OAAO,GAAgC,EAAE,EAAE;AAC1E;AACA;AACA,EAAE,OAAO,gBAAmB,IAAI,EAA6D;AAC7F,IAAI,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAA,EAAY,GAAI,IAAI;;AAE5D,IAAI,MAAM,MAAA,GAASC,uBAAS,EAAE;AAC9B,IAAI,MAAM,aAAA,GAAgB,MAAM,EAAE,UAAU,EAAE;;AAE9C,IAAI,MAAM,WAAW,GAA4B;AACjD,MAAM,cAAc,EAAE,IAAI;AAC1B,MAAM,cAAc,EAAE,IAAI;AAC1B,KAAK;;AAEL,IAAIC,oDAAiC;AACrC,MAAM,WAAW;AACjB,MA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CAAA,EAAA,kBAAA,CAAA;AACA,YAAA,IAAA,CAAA,GAAA,EAAA;AACA,YAAA,MAAA,CAAA;AACA,UAAA;AACA,QAAA,CAAA;AACA,OAAA;AACA,IAAA,CAAA,CAAA;AACA,EAAA,CAAA;AACA;;;;"} | ||
| {"version":3,"file":"trpc.js","sources":["../../src/trpc.ts"],"sourcesContent":["import { getClient, withIsolationScope } from './currentScopes';\nimport { captureException } from './exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from './semanticAttributes';\nimport { startSpanManual } from './tracing';\nimport { normalize } from './utils/normalize';\nimport { setNormalizationDepthOverrideHint } from './utils/normalizationHints';\n\ninterface SentryTrpcMiddlewareOptions {\n /** Whether to include procedure inputs in reported events. Defaults to `false`. */\n attachRpcInput?: boolean;\n forceTransaction?: boolean;\n}\n\nexport interface SentryTrpcMiddlewareArguments<T> {\n path?: unknown;\n type?: unknown;\n next: () => T;\n rawInput?: unknown;\n getRawInput?: () => Promise<unknown>;\n}\n\nconst trpcCaptureContext = { mechanism: { handled: false, type: 'auto.rpc.trpc.middleware' } };\n\nfunction captureIfError(nextResult: unknown): void {\n // TODO: Set span status based on what TRPCError was encountered\n if (\n typeof nextResult === 'object' &&\n nextResult !== null &&\n 'ok' in nextResult &&\n !nextResult.ok &&\n 'error' in nextResult\n ) {\n captureException(nextResult.error, trpcCaptureContext);\n }\n}\n\ntype SentryTrpcMiddleware<T> = T extends Promise<unknown> ? T : Promise<T>;\n\n/**\n * Sentry tRPC middleware that captures errors and creates spans for tRPC procedures.\n */\nexport function trpcMiddleware(options: SentryTrpcMiddlewareOptions = {}) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return async function <T>(opts: SentryTrpcMiddlewareArguments<T>): SentryTrpcMiddleware<T> {\n const { path, type, next, rawInput, getRawInput } = opts;\n\n const client = getClient();\n const clientOptions = client?.getOptions();\n\n const trpcContext: Record<string, unknown> = {\n procedure_path: path,\n procedure_type: type,\n };\n\n setNormalizationDepthOverrideHint(\n trpcContext,\n 1 + // 1 for context.input + the normal normalization depth\n (clientOptions?.normalizeDepth ?? 5), // 5 is a sane depth\n );\n\n if (options.attachRpcInput !== undefined ? options.attachRpcInput : clientOptions?.sendDefaultPii) {\n if (rawInput !== undefined) {\n trpcContext.input = normalize(rawInput);\n }\n\n if (getRawInput !== undefined && typeof getRawInput === 'function') {\n try {\n const rawRes = await getRawInput();\n\n trpcContext.input = normalize(rawRes);\n } catch {\n // noop\n }\n }\n }\n\n return withIsolationScope(scope => {\n scope.setContext('trpc', trpcContext);\n return startSpanManual(\n {\n name: `trpc/${path}`,\n op: 'rpc.server',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.rpc.trpc',\n },\n forceTransaction: !!options.forceTransaction,\n },\n async span => {\n try {\n const nextResult = await next();\n captureIfError(nextResult);\n span.end();\n return nextResult;\n } catch (e) {\n captureException(e, trpcCaptureContext);\n span.end();\n throw e;\n }\n },\n ) as SentryTrpcMiddleware<T>;\n });\n };\n}\n"],"names":["captureException","getClient","setNormalizationDepthOverrideHint","normalize","withIsolationScope","startSpanManual","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN"],"mappings":";;;;;;;;;AAqBA,MAAM,kBAAA,GAAqB,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,0BAAA,IAA8B;;AAE9F,SAAS,cAAc,CAAC,UAAU,EAAiB;AACnD;AACA,EAAE;AACF,IAAI,OAAO,UAAA,KAAe,QAAA;AAC1B,IAAI,UAAA,KAAe,IAAA;AACnB,IAAI,IAAA,IAAQ,UAAA;AACZ,IAAI,CAAC,UAAU,CAAC,EAAA;AAChB,IAAI,WAAW;AACf,IAAI;AACJ,IAAIA,0BAAgB,CAA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AAe;AAC5B,QAAQ;AACR,UAAU,IAAI,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AACA,UAAA,EAAA,EAAA,YAAA;AACA,UAAA,UAAA,EAAA;AACA,YAAA,CAAAC,mDAAA,GAAA,OAAA;AACA,YAAA,CAAAC,mDAAA,GAAA,eAAA;AACA,WAAA;AACA,UAAA,gBAAA,EAAA,CAAA,CAAA,OAAA,CAAA,gBAAA;AACA,SAAA;AACA,QAAA,MAAA,IAAA,IAAA;AACA,UAAA,IAAA;AACA,YAAA,MAAA,UAAA,GAAA,MAAA,IAAA,EAAA;AACA,YAAA,cAAA,CAAA,UAAA,CAAA;AACA,YAAA,IAAA,CAAA,GAAA,EAAA;AACA,YAAA,OAAA,UAAA;AACA,UAAA,CAAA,CAAA,OAAA,CAAA,EAAA;AACA,YAAAP,0BAAA,CAAA,CAAA,EAAA,kBAAA,CAAA;AACA,YAAA,IAAA,CAAA,GAAA,EAAA;AACA,YAAA,MAAA,CAAA;AACA,UAAA;AACA,QAAA,CAAA;AACA,OAAA;AACA,IAAA,CAAA,CAAA;AACA,EAAA,CAAA;AACA;;;;"} |
@@ -13,7 +13,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| function replaceExports( | ||
| exports$1, | ||
| exports, | ||
| exportName, | ||
| wrappedConstructor, | ||
| ) { | ||
| const original = exports$1[exportName]; | ||
| const original = exports[exportName]; | ||
@@ -26,6 +26,6 @@ if (typeof original !== 'function') { | ||
| try { | ||
| exports$1[exportName] = wrappedConstructor; | ||
| exports[exportName] = wrappedConstructor; | ||
| } catch { | ||
| // If direct assignment fails, override the property descriptor | ||
| Object.defineProperty(exports$1, exportName, { | ||
| Object.defineProperty(exports, exportName, { | ||
| value: wrappedConstructor, | ||
@@ -39,7 +39,7 @@ writable: true, | ||
| // Replace the default export if it points to the original constructor | ||
| if (exports$1.default === original) { | ||
| if (exports.default === original) { | ||
| try { | ||
| exports$1.default = wrappedConstructor; | ||
| exports.default = wrappedConstructor; | ||
| } catch { | ||
| Object.defineProperty(exports$1, 'default', { | ||
| Object.defineProperty(exports, 'default', { | ||
| value: wrappedConstructor, | ||
@@ -46,0 +46,0 @@ writable: true, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"exports.js","sources":["../../../src/utils/exports.ts"],"sourcesContent":["/**\n * Replaces constructor functions in module exports, handling read-only properties,\n * and both default and named exports by wrapping them with the constructor.\n *\n * @param exports The module exports object to modify\n * @param exportName The name of the export to replace (e.g., 'GoogleGenAI', 'Anthropic', 'OpenAI')\n * @param wrappedConstructor The wrapped constructor function to replace the original with\n * @returns void\n */\nexport function replaceExports(\n exports: { [key: string]: unknown },\n exportName: string,\n wrappedConstructor: unknown,\n): void {\n const original = exports[exportName];\n\n if (typeof original !== 'function') {\n return;\n }\n\n // Replace the named export - handle read-only properties\n try {\n exports[exportName] = wrappedConstructor;\n } catch {\n // If direct assignment fails, override the property descriptor\n Object.defineProperty(exports, exportName, {\n value: wrappedConstructor,\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n\n // Replace the default export if it points to the original constructor\n if (exports.default === original) {\n try {\n exports.default = wrappedConstructor;\n } catch {\n Object.defineProperty(exports, 'default', {\n value: wrappedConstructor,\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n }\n}\n"],"names":["exports"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc;AAC9B,EAAEA,SAAO;AACT,EAAE,UAAU;AACZ,EAAE,kBAAkB;AACpB,EAAQ;AACR,EAAE,MAAM,QAAA,GAAWA,SAAO,CAAC,UAAU,CAAC;;AAEtC,EAAE,IAAI,OAAO,QAAA,KAAa,UAAU,EAAE;AACtC,IAAI;AACJ,EAAE;;AAEF;AACA,EAAE,IAAI;AACN,IAAIA,SAAO,CAAC,UAAU,CAAA,GAAI,kBAAkB;AAC5C,EAAE,EAAE,MAAM;AACV;AACA,IAAI,MAAM,CAAC,cAAc,CAACA,SAAO,EAAE,UAAU,EAAE;AAC/C,MAAM,KAAK,EAAE,kBAAkB;AAC/B,MAAM,QAAQ,EAAE,IAAI;AACpB,MAAM,YAAY,EAAE,IAAI;AACxB,MAAM,UAAU,EAAE,IAAI;AACtB,KAAK,CAAC;AACN,EAAE;;AAEF;AACA,EAAE,IAAIA,SAAO,CAAC,OAAA,KAAY,QAAQ,EAAE;AACpC,IAAI,IAAI;AACR,MAAMA,SAAO,CAAC,OAAA,GAAU,kBAAkB;AAC1C,IAAI,EAAE,MAAM;AACZ,MAAM,MAAM,CAAC,cAAc,CAACA,SAAO,EAAE,SAAS,EAAE;AAChD,QAAQ,KAAK,EAAE,kBAAkB;AACjC,QAAQ,QAAQ,EAAE,IAAI;AACtB,QAAQ,YAAY,EAAE,IAAI;AAC1B,QAAQ,UAAU,EAAE,IAAI;AACxB,OAAO,CAAC;AACR,IAAI;AACJ,EAAE;AACF;;;;"} | ||
| {"version":3,"file":"exports.js","sources":["../../../src/utils/exports.ts"],"sourcesContent":["/**\n * Replaces constructor functions in module exports, handling read-only properties,\n * and both default and named exports by wrapping them with the constructor.\n *\n * @param exports The module exports object to modify\n * @param exportName The name of the export to replace (e.g., 'GoogleGenAI', 'Anthropic', 'OpenAI')\n * @param wrappedConstructor The wrapped constructor function to replace the original with\n * @returns void\n */\nexport function replaceExports(\n exports: { [key: string]: unknown },\n exportName: string,\n wrappedConstructor: unknown,\n): void {\n const original = exports[exportName];\n\n if (typeof original !== 'function') {\n return;\n }\n\n // Replace the named export - handle read-only properties\n try {\n exports[exportName] = wrappedConstructor;\n } catch {\n // If direct assignment fails, override the property descriptor\n Object.defineProperty(exports, exportName, {\n value: wrappedConstructor,\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n\n // Replace the default export if it points to the original constructor\n if (exports.default === original) {\n try {\n exports.default = wrappedConstructor;\n } catch {\n Object.defineProperty(exports, 'default', {\n value: wrappedConstructor,\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n }\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc;AAC9B,EAAE,OAAO;AACT,EAAE,UAAU;AACZ,EAAE,kBAAkB;AACpB,EAAQ;AACR,EAAE,MAAM,QAAA,GAAW,OAAO,CAAC,UAAU,CAAC;;AAEtC,EAAE,IAAI,OAAO,QAAA,KAAa,UAAU,EAAE;AACtC,IAAI;AACJ,EAAE;;AAEF;AACA,EAAE,IAAI;AACN,IAAI,OAAO,CAAC,UAAU,CAAA,GAAI,kBAAkB;AAC5C,EAAE,EAAE,MAAM;AACV;AACA,IAAI,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE;AAC/C,MAAM,KAAK,EAAE,kBAAkB;AAC/B,MAAM,QAAQ,EAAE,IAAI;AACpB,MAAM,YAAY,EAAE,IAAI;AACxB,MAAM,UAAU,EAAE,IAAI;AACtB,KAAK,CAAC;AACN,EAAE;;AAEF;AACA,EAAE,IAAI,OAAO,CAAC,OAAA,KAAY,QAAQ,EAAE;AACpC,IAAI,IAAI;AACR,MAAM,OAAO,CAAC,OAAA,GAAU,kBAAkB;AAC1C,IAAI,EAAE,MAAM;AACZ,MAAM,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE;AAChD,QAAQ,KAAK,EAAE,kBAAkB;AACjC,QAAQ,QAAQ,EAAE,IAAI;AACtB,QAAQ,YAAY,EAAE,IAAI;AAC1B,QAAQ,UAAU,EAAE,IAAI;AACxB,OAAO,CAAC;AACR,IAAI;AACJ,EAAE;AACF;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const _exports = require('../exports.js'); | ||
| const exports$1 = require('../exports.js'); | ||
| const debugLogger = require('./debug-logger.js'); | ||
@@ -11,3 +11,3 @@ const vercelWaitUntil = require('./vercelWaitUntil.js'); | ||
| debugLogger.debug.log('Flushing events...'); | ||
| await _exports.flush(timeout); | ||
| await exports$1.flush(timeout); | ||
| debugLogger.debug.log('Done flushing events'); | ||
@@ -14,0 +14,0 @@ } catch (e) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"flushIfServerless.js","sources":["../../../src/utils/flushIfServerless.ts"],"sourcesContent":["import { flush } from '../exports';\nimport { debug } from './debug-logger';\nimport { vercelWaitUntil } from './vercelWaitUntil';\nimport { GLOBAL_OBJ } from './worldwide';\n\ntype MinimalCloudflareContext = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n waitUntil(promise: Promise<any>): void;\n};\n\nasync function flushWithTimeout(timeout: number): Promise<void> {\n try {\n debug.log('Flushing events...');\n await flush(timeout);\n debug.log('Done flushing events');\n } catch (e) {\n debug.log('Error while flushing events:\\n', e);\n }\n}\n\n/**\n * Flushes the event queue with a timeout in serverless environments to ensure that events are sent to Sentry before the\n * serverless function execution ends.\n *\n * The function is async, but in environments that support a `waitUntil` mechanism, it will run synchronously.\n *\n * This function is aware of the following serverless platforms:\n * - Cloudflare: If a Cloudflare context is provided, it will use `ctx.waitUntil()` to flush events (keeps the `this` context of `ctx`).\n * If a `cloudflareWaitUntil` function is provided, it will use that to flush events (looses the `this` context of `ctx`).\n * - Vercel: It detects the Vercel environment and uses Vercel's `waitUntil` function.\n * - Other Serverless (AWS Lambda, Google Cloud, etc.): It detects the environment via environment variables\n * and uses a regular `await flush()`.\n *\n * @internal This function is supposed for internal Sentry SDK usage only.\n * @hidden\n */\nexport async function flushIfServerless(\n params: // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | { timeout?: number; cloudflareWaitUntil?: (task: Promise<any>) => void }\n | { timeout?: number; cloudflareCtx?: MinimalCloudflareContext } = {},\n): Promise<void> {\n const { timeout = 2000 } = params;\n\n if ('cloudflareWaitUntil' in params && typeof params?.cloudflareWaitUntil === 'function') {\n params.cloudflareWaitUntil(flushWithTimeout(timeout));\n return;\n }\n\n if ('cloudflareCtx' in params && typeof params.cloudflareCtx?.waitUntil === 'function') {\n params.cloudflareCtx.waitUntil(flushWithTimeout(timeout));\n return;\n }\n\n // Note: vercelWaitUntil only does something in Vercel Edge runtime\n // In Node runtime, we use process.on('SIGTERM') instead\n // @ts-expect-error This is not typed\n if (GLOBAL_OBJ[Symbol.for('@vercel/request-context')]) {\n // Vercel has a waitUntil equivalent that works without execution context\n vercelWaitUntil(flushWithTimeout(timeout));\n return;\n }\n\n if (typeof process === 'undefined') {\n return;\n }\n\n const isServerless =\n !!process.env.FUNCTIONS_WORKER_RUNTIME || // Azure Functions\n !!process.env.LAMBDA_TASK_ROOT || // AWS Lambda\n !!process.env.K_SERVICE || // Google Cloud Run\n !!process.env.CF_PAGES || // Cloudflare Pages\n !!process.env.VERCEL ||\n !!process.env.NETLIFY;\n\n if (isServerless) {\n // Use regular flush for environments without a generic waitUntil mechanism\n await flushWithTimeout(timeout);\n }\n}\n"],"names":["debug","flush","GLOBAL_OBJ","vercelWaitUntil"],"mappings":";;;;;;;AAUA,eAAe,gBAAgB,CAAC,OAAO,EAAyB;AAChE,EAAE,IAAI;AACN,IAAIA,iBAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC;AACnC,IAAI,MAAMC,cAAK,CAAC,OAAO,CAAC;AACxB,IAAID,iBAAK,CAAC,GAAG,CAAC,sBAAsB,CAAC;AACrC,EAAE,CAAA,CAAE,OAAO,CAAC,EAAE;AACd,IAAIA,iBAAK,CAAC,GAAG,CAAC,gCAAgC,EAAE,CAAC,CAAC;AAClD,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,iBAAiB;AACvC,EAAE;;AAEE,GAAmE,EAAE;AACzE,EAAiB;AACjB,EAAE,MAAM,EAAE,OAAA,GAAU,IAAA,EAAK,GAAI,MAAM;;AAEnC,EAAE,IAAI,qBAAA,IAAyB,MAAA,IAAU,OAAO,MAAM,EAAE,mBAAA,KAAwB,UAAU,EAAE;AAC5F,IAAI,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACzD,IAAI;AACJ,EAAE;;AAEF,EAAE,IAAI,eAAA,IAAmB,UAAU,OAAO,MAAM,CAAC,aAAa,EAAE,SAAA,KAAc,UAAU,EAAE;AAC1F,IAAI,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC7D,IAAI;AACJ,EAAE;;AAEF;AACA;AACA;AACA,EAAE,IAAIE,oBAAU,CAAC,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,EAAE;AACzD;AACA,IAAIC,+BAAe,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC9C,IAAI;AACJ,EAAE;;AAEF,EAAE,IAAI,OAAO,OAAA,KAAY,WAAW,EAAE;AACtC,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,YAAA;AACR,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO;;AAEzB,EAAE,IAAI,YAAY,EAAE;AACpB;AACA,IAAI,MAAM,gBAAgB,CAAC,OAAO,CAAC;AACnC,EAAE;AACF;;;;"} | ||
| {"version":3,"file":"flushIfServerless.js","sources":["../../../src/utils/flushIfServerless.ts"],"sourcesContent":["import { flush } from '../exports';\nimport { debug } from './debug-logger';\nimport { vercelWaitUntil } from './vercelWaitUntil';\nimport { GLOBAL_OBJ } from './worldwide';\n\ntype MinimalCloudflareContext = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n waitUntil(promise: Promise<any>): void;\n};\n\nasync function flushWithTimeout(timeout: number): Promise<void> {\n try {\n debug.log('Flushing events...');\n await flush(timeout);\n debug.log('Done flushing events');\n } catch (e) {\n debug.log('Error while flushing events:\\n', e);\n }\n}\n\n/**\n * Flushes the event queue with a timeout in serverless environments to ensure that events are sent to Sentry before the\n * serverless function execution ends.\n *\n * The function is async, but in environments that support a `waitUntil` mechanism, it will run synchronously.\n *\n * This function is aware of the following serverless platforms:\n * - Cloudflare: If a Cloudflare context is provided, it will use `ctx.waitUntil()` to flush events (keeps the `this` context of `ctx`).\n * If a `cloudflareWaitUntil` function is provided, it will use that to flush events (looses the `this` context of `ctx`).\n * - Vercel: It detects the Vercel environment and uses Vercel's `waitUntil` function.\n * - Other Serverless (AWS Lambda, Google Cloud, etc.): It detects the environment via environment variables\n * and uses a regular `await flush()`.\n *\n * @internal This function is supposed for internal Sentry SDK usage only.\n * @hidden\n */\nexport async function flushIfServerless(\n params: // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | { timeout?: number; cloudflareWaitUntil?: (task: Promise<any>) => void }\n | { timeout?: number; cloudflareCtx?: MinimalCloudflareContext } = {},\n): Promise<void> {\n const { timeout = 2000 } = params;\n\n if ('cloudflareWaitUntil' in params && typeof params?.cloudflareWaitUntil === 'function') {\n params.cloudflareWaitUntil(flushWithTimeout(timeout));\n return;\n }\n\n if ('cloudflareCtx' in params && typeof params.cloudflareCtx?.waitUntil === 'function') {\n params.cloudflareCtx.waitUntil(flushWithTimeout(timeout));\n return;\n }\n\n // Note: vercelWaitUntil only does something in Vercel Edge runtime\n // In Node runtime, we use process.on('SIGTERM') instead\n // @ts-expect-error This is not typed\n if (GLOBAL_OBJ[Symbol.for('@vercel/request-context')]) {\n // Vercel has a waitUntil equivalent that works without execution context\n vercelWaitUntil(flushWithTimeout(timeout));\n return;\n }\n\n if (typeof process === 'undefined') {\n return;\n }\n\n const isServerless =\n !!process.env.FUNCTIONS_WORKER_RUNTIME || // Azure Functions\n !!process.env.LAMBDA_TASK_ROOT || // AWS Lambda\n !!process.env.K_SERVICE || // Google Cloud Run\n !!process.env.CF_PAGES || // Cloudflare Pages\n !!process.env.VERCEL ||\n !!process.env.NETLIFY;\n\n if (isServerless) {\n // Use regular flush for environments without a generic waitUntil mechanism\n await flushWithTimeout(timeout);\n }\n}\n"],"names":["debug","flush","GLOBAL_OBJ","vercelWaitUntil"],"mappings":";;;;;;;AAUA,eAAe,gBAAgB,CAAC,OAAO,EAAyB;AAChE,EAAE,IAAI;AACN,IAAIA,iBAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC;AACnC,IAAI,MAAMC,eAAK,CAAC,OAAO,CAAC;AACxB,IAAID,iBAAK,CAAC,GAAG,CAAC,sBAAsB,CAAC;AACrC,EAAE,CAAA,CAAE,OAAO,CAAC,EAAE;AACd,IAAIA,iBAAK,CAAC,GAAG,CAAC,gCAAgC,EAAE,CAAC,CAAC;AAClD,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,iBAAiB;AACvC,EAAE;;AAEE,GAAmE,EAAE;AACzE,EAAiB;AACjB,EAAE,MAAM,EAAE,OAAA,GAAU,IAAA,EAAK,GAAI,MAAM;;AAEnC,EAAE,IAAI,qBAAA,IAAyB,MAAA,IAAU,OAAO,MAAM,EAAE,mBAAA,KAAwB,UAAU,EAAE;AAC5F,IAAI,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACzD,IAAI;AACJ,EAAE;;AAEF,EAAE,IAAI,eAAA,IAAmB,UAAU,OAAO,MAAM,CAAC,aAAa,EAAE,SAAA,KAAc,UAAU,EAAE;AAC1F,IAAI,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC7D,IAAI;AACJ,EAAE;;AAEF;AACA;AACA;AACA,EAAE,IAAIE,oBAAU,CAAC,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,EAAE;AACzD;AACA,IAAIC,+BAAe,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC9C,IAAI;AACJ,EAAE;;AAEF,EAAE,IAAI,OAAO,OAAA,KAAY,WAAW,EAAE;AACtC,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,YAAA;AACR,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAA;AAClB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO;;AAEzB,EAAE,IAAI,YAAY,EAAE;AACpB;AACA,IAAI,MAAM,gBAAgB,CAAC,OAAO,CAAC;AACnC,EAAE;AACF;;;;"} |
@@ -139,6 +139,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| testString, | ||
| patterns = [], | ||
| patterns | ||
| = [], | ||
| requireExactStringMatch = false, | ||
| ) { | ||
| return patterns.some(pattern => isMatchingPattern(testString, pattern, requireExactStringMatch)); | ||
| for (const pattern of patterns) { | ||
| if (isMatchingPattern(testString, pattern, requireExactStringMatch)) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
@@ -145,0 +152,0 @@ |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"string.js","sources":["../../../src/utils/string.ts"],"sourcesContent":["import { isRegExp, isString, isVueViewModel } from './is';\nimport { getVueInternalName } from './stacktrace';\n\nexport { escapeStringForRegex } from '../vendor/escapeStringForRegex';\n\n/**\n * Truncates given string to the maximum characters count\n *\n * @param str An object that contains serializable values\n * @param max Maximum number of characters in truncated string (0 = unlimited)\n * @returns string Encoded\n */\nexport function truncate(str: string, max: number = 0): string {\n if (typeof str !== 'string' || max === 0) {\n return str;\n }\n return str.length <= max ? str : `${str.slice(0, max)}...`;\n}\n\n/**\n * This is basically just `trim_line` from\n * https://github.com/getsentry/sentry/blob/master/src/sentry/lang/javascript/processor.py#L67\n *\n * @param str An object that contains serializable values\n * @param max Maximum number of characters in truncated string\n * @returns string Encoded\n */\nexport function snipLine(line: string, colno: number): string {\n let newLine = line;\n const lineLength = newLine.length;\n if (lineLength <= 150) {\n return newLine;\n }\n if (colno > lineLength) {\n // eslint-disable-next-line no-param-reassign\n colno = lineLength;\n }\n\n let start = Math.max(colno - 60, 0);\n if (start < 5) {\n start = 0;\n }\n\n let end = Math.min(start + 140, lineLength);\n if (end > lineLength - 5) {\n end = lineLength;\n }\n if (end === lineLength) {\n start = Math.max(end - 140, 0);\n }\n\n newLine = newLine.slice(start, end);\n if (start > 0) {\n newLine = `'{snip} ${newLine}`;\n }\n if (end < lineLength) {\n newLine += ' {snip}';\n }\n\n return newLine;\n}\n\n/**\n * Join values in array\n * @param input array of values to be joined together\n * @param delimiter string to be placed in-between values\n * @returns Joined values\n */\nexport function safeJoin(input: unknown[], delimiter?: string): string {\n if (!Array.isArray(input)) {\n return '';\n }\n\n const output = [];\n // eslint-disable-next-line typescript/prefer-for-of\n for (let i = 0; i < input.length; i++) {\n const value = input[i];\n try {\n // This is a hack to fix a Vue3-specific bug that causes an infinite loop of\n // console warnings. This happens when a Vue template is rendered with\n // an undeclared variable, which we try to stringify, ultimately causing\n // Vue to issue another warning which repeats indefinitely.\n // see: https://github.com/getsentry/sentry-javascript/pull/8981\n if (isVueViewModel(value)) {\n output.push(getVueInternalName(value));\n } else {\n output.push(String(value));\n }\n } catch {\n output.push('[value cannot be serialized]');\n }\n }\n\n return output.join(delimiter);\n}\n\n/**\n * Checks if the given value matches a regex or string\n *\n * @param value The string to test\n * @param pattern Either a regex or a string against which `value` will be matched\n * @param requireExactStringMatch If true, `value` must match `pattern` exactly. If false, `value` will match\n * `pattern` if it contains `pattern`. Only applies to string-type patterns.\n */\nexport function isMatchingPattern(\n value: string,\n pattern: RegExp | string | ((value: string) => boolean),\n requireExactStringMatch: boolean = false,\n): boolean {\n if (!isString(value)) {\n return false;\n }\n\n if (isRegExp(pattern)) {\n return pattern.test(value);\n }\n if (isString(pattern)) {\n return requireExactStringMatch ? value === pattern : value.includes(pattern);\n }\n if (typeof pattern === 'function') {\n return pattern(value);\n }\n\n return false;\n}\n\n/**\n * Test the given string against an array of strings and regexes. By default, string matching is done on a\n * substring-inclusion basis rather than a strict equality basis\n *\n * @param testString The string to test\n * @param patterns The patterns against which to test the string\n * @param requireExactStringMatch If true, `testString` must match one of the given string patterns exactly in order to\n * count. If false, `testString` will match a string pattern if it contains that pattern.\n * @returns\n */\nexport function stringMatchesSomePattern(\n testString: string,\n patterns: Array<string | RegExp | ((value: string) => boolean)> = [],\n requireExactStringMatch: boolean = false,\n): boolean {\n return patterns.some(pattern => isMatchingPattern(testString, pattern, requireExactStringMatch));\n}\n"],"names":["isVueViewModel","getVueInternalName","isString","isRegExp"],"mappings":";;;;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,QAAQ,CAAC,GAAG,EAAU,GAAG,GAAW,CAAC,EAAU;AAC/D,EAAE,IAAI,OAAO,GAAA,KAAQ,YAAY,GAAA,KAAQ,CAAC,EAAE;AAC5C,IAAI,OAAO,GAAG;AACd,EAAE;AACF,EAAE,OAAO,GAAG,CAAC,MAAA,IAAU,MAAM,GAAA,GAAM,CAAC,EAAA,GAAA,CAAA,KAAA,CAAA,CAAA,EAAA,GAAA,CAAA,CAAA,GAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,QAAA,CAAA,IAAA,EAAA,KAAA,EAAA;AACA,EAAA,IAAA,OAAA,GAAA,IAAA;AACA,EAAA,MAAA,UAAA,GAAA,OAAA,CAAA,MAAA;AACA,EAAA,IAAA,UAAA,IAAA,GAAA,EAAA;AACA,I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A,OAAA,QAAA,CAAA,IAAA,CAAA,OAAA,IAAA,iBAAA,CAAA,UAAA,EAAA,OAAA,EAAA,uBAAA,CAAA,CAAA;AACA;;;;;;;;"} | ||
| {"version":3,"file":"string.js","sources":["../../../src/utils/string.ts"],"sourcesContent":["import { isRegExp, isString, isVueViewModel } from './is';\nimport { getVueInternalName } from './stacktrace';\n\nexport { escapeStringForRegex } from '../vendor/escapeStringForRegex';\n\n/**\n * Truncates given string to the maximum characters count\n *\n * @param str An object that contains serializable values\n * @param max Maximum number of characters in truncated string (0 = unlimited)\n * @returns string Encoded\n */\nexport function truncate(str: string, max: number = 0): string {\n if (typeof str !== 'string' || max === 0) {\n return str;\n }\n return str.length <= max ? str : `${str.slice(0, max)}...`;\n}\n\n/**\n * This is basically just `trim_line` from\n * https://github.com/getsentry/sentry/blob/master/src/sentry/lang/javascript/processor.py#L67\n *\n * @param str An object that contains serializable values\n * @param max Maximum number of characters in truncated string\n * @returns string Encoded\n */\nexport function snipLine(line: string, colno: number): string {\n let newLine = line;\n const lineLength = newLine.length;\n if (lineLength <= 150) {\n return newLine;\n }\n if (colno > lineLength) {\n // eslint-disable-next-line no-param-reassign\n colno = lineLength;\n }\n\n let start = Math.max(colno - 60, 0);\n if (start < 5) {\n start = 0;\n }\n\n let end = Math.min(start + 140, lineLength);\n if (end > lineLength - 5) {\n end = lineLength;\n }\n if (end === lineLength) {\n start = Math.max(end - 140, 0);\n }\n\n newLine = newLine.slice(start, end);\n if (start > 0) {\n newLine = `'{snip} ${newLine}`;\n }\n if (end < lineLength) {\n newLine += ' {snip}';\n }\n\n return newLine;\n}\n\n/**\n * Join values in array\n * @param input array of values to be joined together\n * @param delimiter string to be placed in-between values\n * @returns Joined values\n */\nexport function safeJoin(input: unknown[], delimiter?: string): string {\n if (!Array.isArray(input)) {\n return '';\n }\n\n const output = [];\n // eslint-disable-next-line typescript/prefer-for-of\n for (let i = 0; i < input.length; i++) {\n const value = input[i];\n try {\n // This is a hack to fix a Vue3-specific bug that causes an infinite loop of\n // console warnings. This happens when a Vue template is rendered with\n // an undeclared variable, which we try to stringify, ultimately causing\n // Vue to issue another warning which repeats indefinitely.\n // see: https://github.com/getsentry/sentry-javascript/pull/8981\n if (isVueViewModel(value)) {\n output.push(getVueInternalName(value));\n } else {\n output.push(String(value));\n }\n } catch {\n output.push('[value cannot be serialized]');\n }\n }\n\n return output.join(delimiter);\n}\n\n/**\n * Checks if the given value matches a regex or string\n *\n * @param value The string to test\n * @param pattern Either a regex or a string against which `value` will be matched\n * @param requireExactStringMatch If true, `value` must match `pattern` exactly. If false, `value` will match\n * `pattern` if it contains `pattern`. Only applies to string-type patterns.\n */\nexport function isMatchingPattern(\n value: string,\n pattern: RegExp | string | ((value: string) => boolean),\n requireExactStringMatch: boolean = false,\n): boolean {\n if (!isString(value)) {\n return false;\n }\n\n if (isRegExp(pattern)) {\n return pattern.test(value);\n }\n if (isString(pattern)) {\n return requireExactStringMatch ? value === pattern : value.includes(pattern);\n }\n if (typeof pattern === 'function') {\n return pattern(value);\n }\n\n return false;\n}\n\n/**\n * Test the given string against an array of strings and regexes. By default, string matching is done on a\n * substring-inclusion basis rather than a strict equality basis\n *\n * @param testString The string to test\n * @param patterns The patterns against which to test the string\n * @param requireExactStringMatch If true, `testString` must match one of the given string patterns exactly in order to\n * count. If false, `testString` will match a string pattern if it contains that pattern.\n * @returns\n */\nexport function stringMatchesSomePattern(\n testString: string,\n patterns:\n | Array<string | RegExp | ((value: string) => boolean)>\n | Set<string | RegExp | ((value: string) => boolean)> = [],\n requireExactStringMatch: boolean = false,\n): boolean {\n for (const pattern of patterns) {\n if (isMatchingPattern(testString, pattern, requireExactStringMatch)) {\n return true;\n }\n }\n return false;\n}\n"],"names":["isVueViewModel","getVueInternalName","isString","isRegExp"],"mappings":";;;;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,QAAQ,CAAC,GAAG,EAAU,GAAG,GAAW,CAAC,EAAU;AAC/D,EAAE,IAAI,OAAO,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A,EAAA,IAAAD,WAAA,CAAA,OAAA,CAAA,EAAA;AACA,IAAA,OAAA,uBAAA,GAAA,KAAA,KAAA,OAAA,GAAA,KAAA,CAAA,QAAA,CAAA,OAAA,CAAA;AACA,EAAA;AACA,EAAA,IAAA,OAAA,OAAA,KAAA,UAAA,EAAA;AACA,IAAA,OAAA,OAAA,CAAA,KAAA,CAAA;AACA,EAAA;;AAEA,EAAA,OAAA,KAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,wBAAA;AACA,EAAA,UAAA;AACA,EAAA;;AAEA,GAAA,EAAA;AACA,EAAA,uBAAA,GAAA,KAAA;AACA,EAAA;AACA,EAAA,KAAA,MAAA,OAAA,IAAA,QAAA,EAAA;AACA,IAAA,IAAA,iBAAA,CAAA,UAAA,EAAA,OAAA,EAAA,uBAAA,CAAA,EAAA;AACA,MAAA,OAAA,IAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA,OAAA,KAAA;AACA;;;;;;;;"} |
@@ -6,3 +6,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const currentScopes = require('../currentScopes.js'); | ||
| const _exports = require('../exports.js'); | ||
| const exports$1 = require('../exports.js'); | ||
| const debugLogger = require('./debug-logger.js'); | ||
@@ -36,3 +36,3 @@ const spanUtils = require('./spanUtils.js'); | ||
| const client = options.client || currentScopes.getClient(); | ||
| if (!_exports.isEnabled() || !client) { | ||
| if (!exports$1.isEnabled() || !client) { | ||
| return {}; | ||
@@ -39,0 +39,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"traceData.js","sources":["../../../src/utils/traceData.ts"],"sourcesContent":["import { getAsyncContextStrategy } from '../asyncContext';\nimport { getMainCarrier } from '../carrier';\nimport type { Client } from '../client';\nimport { getClient, getCurrentScope, hasExternalPropagationContext } from '../currentScopes';\nimport { isEnabled } from '../exports';\nimport type { Scope } from '../scope';\nimport { getDynamicSamplingContextFromScope, getDynamicSamplingContextFromSpan } from '../tracing';\nimport type { Span } from '../types-hoist/span';\nimport type { SerializedTraceData } from '../types-hoist/tracing';\nimport { dynamicSamplingContextToSentryBaggageHeader } from './baggage';\nimport { debug } from './debug-logger';\nimport { getActiveSpan, spanToTraceHeader, spanToTraceparentHeader } from './spanUtils';\nimport { generateSentryTraceHeader, generateTraceparentHeader, TRACEPARENT_REGEXP } from './tracing';\n\n/**\n * Extracts trace propagation data from the current span or from the client's scope (via transaction or propagation\n * context) and serializes it to `sentry-trace` and `baggage` values. These values can be used to propagate\n * a trace via our tracing Http headers or Html `<meta>` tags.\n *\n * This function also applies some validation to the generated sentry-trace and baggage values to ensure that\n * only valid strings are returned.\n *\n * When an external propagation context is registered (e.g. via the OTLP integration) and there is no active\n * Sentry span, this function returns an empty object to defer outgoing request propagation to the external\n * propagator (e.g. an OpenTelemetry propagator).\n *\n * If (@param options.propagateTraceparent) is `true`, the function will also generate a `traceparent` value,\n * following the W3C traceparent header format.\n *\n * @returns an object with the tracing data values. The object keys are the name of the tracing key to be used as header\n * or meta tag name.\n */\nexport function getTraceData(\n options: { span?: Span; scope?: Scope; client?: Client; propagateTraceparent?: boolean } = {},\n): SerializedTraceData {\n const client = options.client || getClient();\n if (!isEnabled() || !client) {\n return {};\n }\n\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.getTraceData) {\n return acs.getTraceData(options);\n }\n\n const scope = options.scope || getCurrentScope();\n const span = options.span || getActiveSpan();\n\n // When no active span and external propagation context is registered (e.g. OTLP integration),\n // return empty to let the OTel propagator handle outgoing request propagation.\n if (!span && hasExternalPropagationContext()) {\n return {};\n }\n\n const sentryTrace = span ? spanToTraceHeader(span) : scopeToTraceHeader(scope);\n const dsc = span ? getDynamicSamplingContextFromSpan(span) : getDynamicSamplingContextFromScope(client, scope);\n const baggage = dynamicSamplingContextToSentryBaggageHeader(dsc);\n\n const isValidSentryTraceHeader = TRACEPARENT_REGEXP.test(sentryTrace);\n if (!isValidSentryTraceHeader) {\n debug.warn('Invalid sentry-trace data. Cannot generate trace data');\n return {};\n }\n\n const traceData: SerializedTraceData = {\n 'sentry-trace': sentryTrace,\n baggage,\n };\n\n if (options.propagateTraceparent) {\n traceData.traceparent = span ? spanToTraceparentHeader(span) : scopeToTraceparentHeader(scope);\n }\n\n return traceData;\n}\n\n/**\n * Get a sentry-trace header value for the given scope.\n */\nfunction scopeToTraceHeader(scope: Scope): string {\n const { traceId, sampled, propagationSpanId } = scope.getPropagationContext();\n return generateSentryTraceHeader(traceId, propagationSpanId, sampled);\n}\n\nfunction scopeToTraceparentHeader(scope: Scope): string {\n const { traceId, sampled, propagationSpanId } = scope.getPropagationContext();\n return generateTraceparentHeader(traceId, propagationSpanId, sampled);\n}\n"],"names":["getClient","isEnabled","carrier","getMainCarrier","getAsyncContextStrategy","getCurrentScope","getActiveSpan","hasExternalPropagationContext","spanToTraceHeader","getDynamicSamplingContextFromSpan","getDynamicSamplingContextFromScope","baggage","dynamicSamplingContextToSentryBaggageHeader","TRACEPARENT_REGEXP","debug","spanToTraceparentHeader","generateSentryTraceHeader","generateTraceparentHeader"],"mappings":";;;;;;;;;;;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,YAAY;AAC5B,EAAE,OAAO,GAAoF,EAAE;AAC/F,EAAuB;AACvB,EAAE,MAAM,SAAS,OAAO,CAAC,MAAA,IAAUA,uBAAS,EAAE;AAC9C,EAAE,IAAI,CAACC,kBAAS,EAAC,IAAK,CAAC,MAAM,EAAE;AAC/B,IAAI,OAAO,EAAE;AACb,EAAE;;AAEF,EAAE,MAAMC,SAAA,GAAUC,sBAAc,EAAE;AAClC,EAAE,MAAM,GAAA,GAAMC,6BAAuB,CAACF,SAAO,CAAC;AAC9C,EAAE,IAAI,GAAG,CAAC,YAAY,EAAE;AACxB,IAAI,OAAO,GAAG,CAAC,YAAY,CAAC,OAAO,C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E;;AAEA,SAAS,wBAAwB,CAAC,KAAK,EAAiB;AACxD,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAA,EAAkB,GAAI,KAAK,CAAC,qBAAqB,EAAE;AAC/E,EAAE,OAAOC,iCAAyB,CAAC,OAAO,EAAE,iBAAiB,EAAE,OAAO,CAAC;AACvE;;;;"} | ||
| {"version":3,"file":"traceData.js","sources":["../../../src/utils/traceData.ts"],"sourcesContent":["import { getAsyncContextStrategy } from '../asyncContext';\nimport { getMainCarrier } from '../carrier';\nimport type { Client } from '../client';\nimport { getClient, getCurrentScope, hasExternalPropagationContext } from '../currentScopes';\nimport { isEnabled } from '../exports';\nimport type { Scope } from '../scope';\nimport { getDynamicSamplingContextFromScope, getDynamicSamplingContextFromSpan } from '../tracing';\nimport type { Span } from '../types-hoist/span';\nimport type { SerializedTraceData } from '../types-hoist/tracing';\nimport { dynamicSamplingContextToSentryBaggageHeader } from './baggage';\nimport { debug } from './debug-logger';\nimport { getActiveSpan, spanToTraceHeader, spanToTraceparentHeader } from './spanUtils';\nimport { generateSentryTraceHeader, generateTraceparentHeader, TRACEPARENT_REGEXP } from './tracing';\n\n/**\n * Extracts trace propagation data from the current span or from the client's scope (via transaction or propagation\n * context) and serializes it to `sentry-trace` and `baggage` values. These values can be used to propagate\n * a trace via our tracing Http headers or Html `<meta>` tags.\n *\n * This function also applies some validation to the generated sentry-trace and baggage values to ensure that\n * only valid strings are returned.\n *\n * When an external propagation context is registered (e.g. via the OTLP integration) and there is no active\n * Sentry span, this function returns an empty object to defer outgoing request propagation to the external\n * propagator (e.g. an OpenTelemetry propagator).\n *\n * If (@param options.propagateTraceparent) is `true`, the function will also generate a `traceparent` value,\n * following the W3C traceparent header format.\n *\n * @returns an object with the tracing data values. The object keys are the name of the tracing key to be used as header\n * or meta tag name.\n */\nexport function getTraceData(\n options: { span?: Span; scope?: Scope; client?: Client; propagateTraceparent?: boolean } = {},\n): SerializedTraceData {\n const client = options.client || getClient();\n if (!isEnabled() || !client) {\n return {};\n }\n\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.getTraceData) {\n return acs.getTraceData(options);\n }\n\n const scope = options.scope || getCurrentScope();\n const span = options.span || getActiveSpan();\n\n // When no active span and external propagation context is registered (e.g. OTLP integration),\n // return empty to let the OTel propagator handle outgoing request propagation.\n if (!span && hasExternalPropagationContext()) {\n return {};\n }\n\n const sentryTrace = span ? spanToTraceHeader(span) : scopeToTraceHeader(scope);\n const dsc = span ? getDynamicSamplingContextFromSpan(span) : getDynamicSamplingContextFromScope(client, scope);\n const baggage = dynamicSamplingContextToSentryBaggageHeader(dsc);\n\n const isValidSentryTraceHeader = TRACEPARENT_REGEXP.test(sentryTrace);\n if (!isValidSentryTraceHeader) {\n debug.warn('Invalid sentry-trace data. Cannot generate trace data');\n return {};\n }\n\n const traceData: SerializedTraceData = {\n 'sentry-trace': sentryTrace,\n baggage,\n };\n\n if (options.propagateTraceparent) {\n traceData.traceparent = span ? spanToTraceparentHeader(span) : scopeToTraceparentHeader(scope);\n }\n\n return traceData;\n}\n\n/**\n * Get a sentry-trace header value for the given scope.\n */\nfunction scopeToTraceHeader(scope: Scope): string {\n const { traceId, sampled, propagationSpanId } = scope.getPropagationContext();\n return generateSentryTraceHeader(traceId, propagationSpanId, sampled);\n}\n\nfunction scopeToTraceparentHeader(scope: Scope): string {\n const { traceId, sampled, propagationSpanId } = scope.getPropagationContext();\n return generateTraceparentHeader(traceId, propagationSpanId, sampled);\n}\n"],"names":["getClient","isEnabled","carrier","getMainCarrier","getAsyncContextStrategy","getCurrentScope","getActiveSpan","hasExternalPropagationContext","spanToTraceHeader","getDynamicSamplingContextFromSpan","getDynamicSamplingContextFromScope","baggage","dynamicSamplingContextToSentryBaggageHeader","TRACEPARENT_REGEXP","debug","spanToTraceparentHeader","generateSentryTraceHeader","generateTraceparentHeader"],"mappings":";;;;;;;;;;;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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c,EAAE,WAAW;AAC/B,aAAIH,SAAO;AACX,GAAG;;AAEH,EAAE,IAAI,OAAO,CAAC,oBAAoB,EAAE;AACpC,IAAI,SAAS,CAAC,WAAA,GAAc,OAAOI,iCAAuB,CAAC,IAAI,CAAA,GAAI,wBAAwB,CAAC,KAAK,CAAC;AAClG,EAAE;;AAEF,EAAE,OAAO,SAAS;AAClB;;AAEA;AACA;AACA;AACA,SAAS,kBAAkB,CAAC,KAAK,EAAiB;AAClD,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAA,EAAkB,GAAI,KAAK,CAAC,qBAAqB,EAAE;AAC/E,EAAE,OAAOC,iCAAyB,CAAC,OAAO,EAAE,iBAAiB,EAAE,OAAO,CAAC;AACvE;;AAEA,SAAS,wBAAwB,CAAC,KAAK,EAAiB;AACxD,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAA,EAAkB,GAAI,KAAK,CAAC,qBAAqB,EAAE;AAC/E,EAAE,OAAOC,iCAAyB,CAAC,OAAO,EAAE,iBAAiB,EAAE,OAAO,CAAC;AACvE;;;;"} |
@@ -5,5 +5,5 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const SDK_VERSION = "10.52.0" ; | ||
| const SDK_VERSION = "10.53.0" ; | ||
| exports.SDK_VERSION = SDK_VERSION; | ||
| //# sourceMappingURL=version.js.map |
@@ -12,2 +12,3 @@ import { getEnvelopeEndpointWithUrlEncodedAuth } from './api.js'; | ||
| import { isStreamedBeforeSendSpanCallback } from './tracing/spans/beforeSendSpan.js'; | ||
| import { extractGenAiSpansFromEvent } from './tracing/spans/extractGenAiSpans.js'; | ||
| import { DEFAULT_TRANSPORT_BUFFER_SIZE } from './transports/base.js'; | ||
@@ -482,2 +483,6 @@ import { createClientReportEnvelope } from './utils/clientreport.js'; | ||
| // Extract gen_ai spans from transaction and convert to span v2 format. | ||
| // This mutates event.spans to remove the extracted spans. | ||
| const genAiSpanItem = extractGenAiSpansFromEvent(event, this); | ||
| let env = createEventEnvelope(event, this._dsn, this._options._metadata, this._options.tunnel); | ||
@@ -489,2 +494,6 @@ | ||
| if (genAiSpanItem) { | ||
| env = addItemToEnvelope(env, genAiSpanItem); | ||
| } | ||
| // sendEnvelope should not throw | ||
@@ -491,0 +500,0 @@ // eslint-disable-next-line @typescript-eslint/no-floating-promises |
+17
-17
@@ -25,3 +25,2 @@ export { registerSpanErrorInstrumentation } from './tracing/errors.js'; | ||
| export { Client } from './client.js'; | ||
| export { ServerRuntimeClient } from './server-runtime-client.js'; | ||
| export { initAndBind, setCurrentClient } from './sdk.js'; | ||
@@ -63,3 +62,2 @@ export { createTransport } from './transports/base.js'; | ||
| export { captureConsoleIntegration } from './integrations/captureconsole.js'; | ||
| export { expressErrorHandler, patchExpressModule, setupExpressErrorHandler } from './integrations/express/index.js'; | ||
| export { dedupeIntegration } from './integrations/dedupe.js'; | ||
@@ -69,3 +67,2 @@ export { extraErrorDataIntegration } from './integrations/extraerrordata.js'; | ||
| export { instrumentSupabaseClient, supabaseIntegration } from './integrations/supabase.js'; | ||
| export { instrumentPostgresJsSql } from './integrations/postgresjs.js'; | ||
| export { zodErrorsIntegration } from './integrations/zoderrors.js'; | ||
@@ -77,11 +74,4 @@ export { thirdPartyErrorFilterIntegration } from './integrations/third-party-errors-filter.js'; | ||
| export { conversationIdIntegration } from './integrations/conversationId.js'; | ||
| export { patchHttpModuleClient } from './integrations/http/client-patch.js'; | ||
| export { getHttpClientSubscriptions } from './integrations/http/client-subscriptions.js'; | ||
| export { addOutgoingRequestBreadcrumb } from './integrations/http/add-outgoing-request-breadcrumb.js'; | ||
| export { getRequestOptions, getRequestUrl, getRequestUrlFromClientRequest, getRequestUrlObject } from './integrations/http/get-request-url.js'; | ||
| export { HTTP_ON_CLIENT_REQUEST, HTTP_ON_SERVER_REQUEST } from './integrations/http/constants.js'; | ||
| export { profiler } from './profiling.js'; | ||
| export { _INTERNAL_getTracingHeadersForFetchRequest, instrumentFetchRequest } from './fetch.js'; | ||
| export { trpcMiddleware } from './trpc.js'; | ||
| export { wrapMcpServerWithSentry } from './integrations/mcp-server/index.js'; | ||
| export { captureFeedback } from './feedback.js'; | ||
@@ -115,7 +105,6 @@ export { _INTERNAL_captureLog, _INTERNAL_captureSerializedLog, _INTERNAL_flushLogsBuffer } from './logs/internal.js'; | ||
| export { getBreadcrumbLogLevelFromHttpStatusCode } from './utils/breadcrumb-log-level.js'; | ||
| export { getComponentName, getLocationHref, htmlTreeAsString } from './utils/browser.js'; | ||
| export { dsnFromString, dsnToString, makeDsn } from './utils/dsn.js'; | ||
| export { SentryError } from './utils/error.js'; | ||
| export { GLOBAL_OBJ } from './utils/worldwide.js'; | ||
| export { addConsoleInstrumentationHandler } from './instrument/console.js'; | ||
| export { addConsoleInstrumentationFilter, addConsoleInstrumentationHandler } from './instrument/console.js'; | ||
| export { addFetchEndInstrumentationHandler, addFetchInstrumentationHandler } from './instrument/fetch.js'; | ||
@@ -129,3 +118,2 @@ export { addGlobalErrorInstrumentationHandler } from './instrument/globalError.js'; | ||
| export { addContextToFrame, addExceptionMechanism, addExceptionTypeValue, checkOrSetAlreadyCaught, getEventDescription, isAlreadyCaptured, parseSemver, uuid4 } from './utils/misc.js'; | ||
| export { isNodeEnv, loadModule } from './utils/node.js'; | ||
| export { normalize, normalizeToSize, normalizeUrlToBase } from './utils/normalize.js'; | ||
@@ -139,3 +127,2 @@ export { setNormalizationDepthOverrideHint, setSkipNormalizationHint } from './utils/normalizationHints.js'; | ||
| export { UNKNOWN_FUNCTION, createStackParser, getFramesFromEvent, getFunctionName, stackParserFromStackParserOptions, stripSentryFramesAndReverse } from './utils/stacktrace.js'; | ||
| export { filenameIsInApp, node, nodeStackLineParser } from './utils/node-stack-trace.js'; | ||
| export { isMatchingPattern, safeJoin, snipLine, stringMatchesSomePattern, truncate } from './utils/string.js'; | ||
@@ -153,7 +140,4 @@ export { isNativeFunction, supportsDOMError, supportsDOMException, supportsErrorEvent, supportsFetch, supportsHistory, supportsNativeFetch, supportsReferrerPolicy, supportsReportingObserver } from './utils/supports.js'; | ||
| export { _enhanceErrorWithSentryInfo as _INTERNAL_enhanceErrorWithSentryInfo, eventFromMessage, eventFromUnknownInput, exceptionFromError, parseStackFrames } from './utils/eventbuilder.js'; | ||
| export { callFrameToStackFrame, watchdogTimer } from './utils/anr.js'; | ||
| export { LRUMap } from './utils/lru.js'; | ||
| export { generateSpanId, generateTraceId } from './utils/propagationContext.js'; | ||
| export { vercelWaitUntil } from './utils/vercelWaitUntil.js'; | ||
| export { flushIfServerless } from './utils/flushIfServerless.js'; | ||
| export { SDK_VERSION } from './utils/version.js'; | ||
@@ -164,4 +148,20 @@ export { getDebugImagesForResources, getFilenameToDebugIdMap } from './utils/debug-ids.js'; | ||
| export { safeDateNow as _INTERNAL_safeDateNow, safeMathRandom as _INTERNAL_safeMathRandom, withRandomSafeContext as _INTERNAL_withRandomSafeContext } from './utils/randomSafeContext.js'; | ||
| export { ServerRuntimeClient } from './server-runtime-client.js'; | ||
| export { trpcMiddleware } from './trpc.js'; | ||
| export { wrapMcpServerWithSentry } from './integrations/mcp-server/index.js'; | ||
| export { isNodeEnv, loadModule } from './utils/node.js'; | ||
| export { filenameIsInApp, node, nodeStackLineParser } from './utils/node-stack-trace.js'; | ||
| export { vercelWaitUntil } from './utils/vercelWaitUntil.js'; | ||
| export { flushIfServerless } from './utils/flushIfServerless.js'; | ||
| export { callFrameToStackFrame, watchdogTimer } from './utils/anr.js'; | ||
| export { safeUnref as _INTERNAL_safeUnref } from './utils/timer.js'; | ||
| export { expressErrorHandler, patchExpressModule, setupExpressErrorHandler } from './integrations/express/index.js'; | ||
| export { instrumentPostgresJsSql } from './integrations/postgresjs.js'; | ||
| export { patchHttpModuleClient } from './integrations/http/client-patch.js'; | ||
| export { getHttpClientSubscriptions } from './integrations/http/client-subscriptions.js'; | ||
| export { addOutgoingRequestBreadcrumb } from './integrations/http/add-outgoing-request-breadcrumb.js'; | ||
| export { getRequestOptions, getRequestUrl, getRequestUrlFromClientRequest, getRequestUrlObject } from './integrations/http/get-request-url.js'; | ||
| export { HTTP_ON_CLIENT_REQUEST, HTTP_ON_SERVER_REQUEST } from './integrations/http/constants.js'; | ||
| export { getComponentName, getLocationHref, htmlTreeAsString } from './utils/browser.js'; | ||
| export { instrumentLangChainEmbeddings } from './tracing/langchain/embeddings.js'; | ||
| //# sourceMappingURL=index.js.map |
@@ -1,7 +0,19 @@ | ||
| import { CONSOLE_LEVELS, originalConsoleMethods } from '../utils/debug-logger.js'; | ||
| import { DEBUG_BUILD } from '../debug-build.js'; | ||
| import { CONSOLE_LEVELS, originalConsoleMethods, debug } from '../utils/debug-logger.js'; | ||
| import { fill } from '../utils/object.js'; | ||
| import { stringMatchesSomePattern } from '../utils/string.js'; | ||
| import { GLOBAL_OBJ } from '../utils/worldwide.js'; | ||
| import { addHandler, maybeInstrument, triggerHandlers } from './handlers.js'; | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| /* eslint-disable @typescript-eslint/ban-types */ | ||
| /** | ||
| * Filter out console messages that match the given strings or regular expressions. | ||
| * These will neither be passed to the handler, and they will also not be logged to the user, unless they have debug enabled. | ||
| * This is a set to avoid duplicate integration setups to add the same filter multiple times. | ||
| */ | ||
| const _filter = new Set([]); | ||
| /** | ||
| * Add an instrumentation handler for when a console.xxx method is called. | ||
@@ -20,2 +32,18 @@ * Returns a function to remove the handler. | ||
| /** | ||
| * Add a filter to the console instrumentation to filter out console messages that match the given strings or regular expressions. | ||
| * Returns a function to remove the filter. | ||
| */ | ||
| function addConsoleInstrumentationFilter(filter) { | ||
| for (const f of filter) { | ||
| _filter.add(f); | ||
| } | ||
| return () => { | ||
| for (const f of filter) { | ||
| _filter.delete(f); | ||
| } | ||
| }; | ||
| } | ||
| function instrumentConsole() { | ||
@@ -35,6 +63,17 @@ if (!('console' in GLOBAL_OBJ)) { | ||
| return function (...args) { | ||
| triggerHandlers('console', { args, level } ); | ||
| const firstArg = args[0]; | ||
| const log = originalConsoleMethods[level]; | ||
| const log = originalConsoleMethods[level]; | ||
| log?.apply(GLOBAL_OBJ.console, args); | ||
| const isFiltered = _filter.size && typeof firstArg === 'string' && stringMatchesSomePattern(firstArg, _filter); | ||
| // Only trigger handlers for non-filtered messages | ||
| if (!isFiltered) { | ||
| triggerHandlers('console', { args, level } ); | ||
| } | ||
| // Only log filtered messages in debug mode | ||
| if (!isFiltered || (DEBUG_BUILD && debug.isEnabled())) { | ||
| // Call original console method | ||
| log?.apply(GLOBAL_OBJ.console, args); | ||
| } | ||
| }; | ||
@@ -45,3 +84,3 @@ }); | ||
| export { addConsoleInstrumentationHandler }; | ||
| export { addConsoleInstrumentationFilter, addConsoleInstrumentationHandler }; | ||
| //# sourceMappingURL=console.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"console.js","sources":["../../../src/instrument/console.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/ban-types */\nimport type { ConsoleLevel, HandlerDataConsole } from '../types-hoist/instrument';\nimport { CONSOLE_LEVELS, originalConsoleMethods } from '../utils/debug-logger';\nimport { fill } from '../utils/object';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\nimport { addHandler, maybeInstrument, triggerHandlers } from './handlers';\n\n/**\n * Add an instrumentation handler for when a console.xxx method is called.\n * Returns a function to remove the handler.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nexport function addConsoleInstrumentationHandler(handler: (data: HandlerDataConsole) => void): () => void {\n const type = 'console';\n const removeHandler = addHandler(type, handler);\n maybeInstrument(type, instrumentConsole);\n return removeHandler;\n}\n\nfunction instrumentConsole(): void {\n if (!('console' in GLOBAL_OBJ)) {\n return;\n }\n\n CONSOLE_LEVELS.forEach(function (level: ConsoleLevel): void {\n if (!(level in GLOBAL_OBJ.console)) {\n return;\n }\n\n fill(GLOBAL_OBJ.console, level, function (originalConsoleMethod: () => any): Function {\n originalConsoleMethods[level] = originalConsoleMethod;\n\n return function (...args: any[]): void {\n triggerHandlers('console', { args, level } as HandlerDataConsole);\n\n const log = originalConsoleMethods[level];\n log?.apply(GLOBAL_OBJ.console, args);\n };\n });\n });\n}\n"],"names":[],"mappings":";;;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gCAAgC,CAAC,OAAO,EAAkD;AAC1G,EAAE,MAAM,IAAA,GAAO,SAAS;AACxB,EAAE,MAAM,gBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC;AACjD,EAAE,eAAe,CAAC,IAAI,EAAE,iBAAiB,CAAC;AAC1C,EAAE,OAAO,aAAa;AACtB;;AAEA,SAAS,iBAAiB,GAAS;AACnC,EAAE,IAAI,EAAE,aAAa,UAAU,CAAC,EAAE;AAClC,IAAI;AACJ,EAAE;;AAEF,EAAE,cAAc,CAAC,OAAO,CAAC,UAAU,KAAK,EAAsB;AAC9D,IAAI,IAAI,EAAE,KAAA,IAAS,UAAU,CAAC,OAAO,CAAC,EAAE;AACxC,MAAM;AACN,IAAI;;AAEJ,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,qBAAqB,EAAuB;AAC1F,MAAM,sBAAsB,CAAC,KAAK,CAAA,GAAI,qBAAqB;;AAE3D,MAAM,OAAO,UAAU,GAAG,IAAI,EAAe;AAC7C,QAAQ,eAAe,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,KAAA,EAAM,EAAwB;;AAEzE,QAAQ,MAAM,GAAA,GAAM,sBAAsB,CAAC,KAAK,CAAC;AACjD,QAAQ,GAAG,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC;AAC5C,MAAM,CAAC;AACP,IAAI,CAAC,CAAC;AACN,EAAE,CAAC,CAAC;AACJ;;;;"} | ||
| {"version":3,"file":"console.js","sources":["../../../src/instrument/console.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/ban-types */\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { ConsoleLevel, HandlerDataConsole } from '../types-hoist/instrument';\nimport { CONSOLE_LEVELS, originalConsoleMethods } from '../utils/debug-logger';\nimport { fill } from '../utils/object';\nimport { stringMatchesSomePattern } from '../utils/string';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\nimport { addHandler, maybeInstrument, triggerHandlers } from './handlers';\nimport { debug } from '../utils/debug-logger';\n\n/**\n * Filter out console messages that match the given strings or regular expressions.\n * These will neither be passed to the handler, and they will also not be logged to the user, unless they have debug enabled.\n * This is a set to avoid duplicate integration setups to add the same filter multiple times.\n */\nconst _filter = new Set<string | RegExp>([]);\n\n/**\n * Add an instrumentation handler for when a console.xxx method is called.\n * Returns a function to remove the handler.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nexport function addConsoleInstrumentationHandler(handler: (data: HandlerDataConsole) => void): () => void {\n const type = 'console';\n const removeHandler = addHandler(type, handler);\n maybeInstrument(type, instrumentConsole);\n return removeHandler;\n}\n\n/**\n * Add a filter to the console instrumentation to filter out console messages that match the given strings or regular expressions.\n * Returns a function to remove the filter.\n */\nexport function addConsoleInstrumentationFilter(filter: (string | RegExp)[]): () => void {\n for (const f of filter) {\n _filter.add(f);\n }\n\n return () => {\n for (const f of filter) {\n _filter.delete(f);\n }\n };\n}\n\n/** Only exported for tests. */\nexport function _INTERNAL_resetConsoleInstrumentationOptions(): void {\n _filter.clear();\n}\n\nfunction instrumentConsole(): void {\n if (!('console' in GLOBAL_OBJ)) {\n return;\n }\n\n CONSOLE_LEVELS.forEach(function (level: ConsoleLevel): void {\n if (!(level in GLOBAL_OBJ.console)) {\n return;\n }\n\n fill(GLOBAL_OBJ.console, level, function (originalConsoleMethod: () => any): Function {\n originalConsoleMethods[level] = originalConsoleMethod;\n\n return function (...args: any[]): void {\n const firstArg = args[0];\n const log = originalConsoleMethods[level];\n\n const isFiltered = _filter.size && typeof firstArg === 'string' && stringMatchesSomePattern(firstArg, _filter);\n\n // Only trigger handlers for non-filtered messages\n if (!isFiltered) {\n triggerHandlers('console', { args, level } as HandlerDataConsole);\n }\n\n // Only log filtered messages in debug mode\n if (!isFiltered || (DEBUG_BUILD && debug.isEnabled())) {\n // Call original console method\n log?.apply(GLOBAL_OBJ.console, args);\n }\n };\n });\n });\n}\n"],"names":[],"mappings":";;;;;;;AAAA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA,MAAM,UAAU,IAAI,GAAG,CAAkB,EAAE,CAAC;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gCAAgC,CAAC,OAAO,EAAkD;AAC1G,EAAE,MAAM,IAAA,GAAO,SAAS;AACxB,EAAE,MAAM,gBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC;AACjD,EAAE,eAAe,CAAC,IAAI,EAAE,iBAAiB,CAAC;AAC1C,EAAE,OAAO,aAAa;AACtB;;AAEA;AACA;AACA;AACA;AACO,SAAS,+BAA+B,CAAC,MAAM,EAAmC;AACzF,EAAE,KAAK,MAAM,CAAA,IAAK,MAAM,EAAE;AAC1B,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AAClB,EAAE;;AAEF,EAAE,OAAO,MAAM;AACf,IAAI,KAAK,MAAM,CAAA,IAAK,MAAM,EAAE;AAC5B,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACvB,IAAI;AACJ,EAAE,CAAC;AACH;;AAOA,SAAS,iBAAiB,GAAS;AACnC,EAAE,IAAI,EAAE,aAAa,UAAU,CAAC,EAAE;AAClC,IAAI;AACJ,EAAE;;AAEF,EAAE,cAAc,CAAC,OAAO,CAAC,UAAU,KAAK,EAAsB;AAC9D,IAAI,IAAI,EAAE,KAAA,IAAS,UAAU,CAAC,OAAO,CAAC,EAAE;AACxC,MAAM;AACN,IAAI;;AAEJ,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,qBAAqB,EAAuB;AAC1F,MAAM,sBAAsB,CAAC,KAAK,CAAA,GAAI,qBAAqB;;AAE3D,MAAM,OAAO,UAAU,GAAG,IAAI,EAAe;AAC7C,QAAQ,MAAM,QAAA,GAAW,IAAI,CAAC,CAAC,CAAC;AAChC,QAAQ,MAAM,GAAA,GAAM,sBAAsB,CAAC,KAAK,CAAC;;AAEjD,QAAQ,MAAM,UAAA,GAAa,OAAO,CAAC,QAAQ,OAAO,QAAA,KAAa,YAAY,wBAAwB,CAAC,QAAQ,EAAE,OAAO,CAAC;;AAEtH;AACA,QAAQ,IAAI,CAAC,UAAU,EAAE;AACzB,UAAU,eAAe,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,KAAA,EAAM,EAAwB;AAC3E,QAAQ;;AAER;AACA,QAAQ,IAAI,CAAC,UAAA,KAAe,WAAA,IAAe,KAAK,CAAC,SAAS,EAAE,CAAC,EAAE;AAC/D;AACA,UAAU,GAAG,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC;AAC9C,QAAQ;AACR,MAAM,CAAC;AACP,IAAI,CAAC,CAAC;AACN,EAAE,CAAC,CAAC;AACJ;;;;"} |
| import { addBreadcrumb } from '../breadcrumbs.js'; | ||
| import { getClient } from '../currentScopes.js'; | ||
| import { addConsoleInstrumentationHandler } from '../instrument/console.js'; | ||
| import { addConsoleInstrumentationHandler, addConsoleInstrumentationFilter } from '../instrument/console.js'; | ||
| import { defineIntegration } from '../integration.js'; | ||
@@ -40,4 +40,8 @@ import { CONSOLE_LEVELS } from '../utils/debug-logger.js'; | ||
| }); | ||
| client.registerCleanup(unsubscribe); | ||
| client.registerCleanup(unsubscribe); | ||
| if (options.filter) { | ||
| const unsubscribe = addConsoleInstrumentationFilter(options.filter); | ||
| client.registerCleanup(unsubscribe); | ||
| } | ||
| }, | ||
@@ -44,0 +48,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"console.js","sources":["../../../src/integrations/console.ts"],"sourcesContent":["import { addBreadcrumb } from '../breadcrumbs';\nimport { getClient } from '../currentScopes';\nimport { addConsoleInstrumentationHandler } from '../instrument/console';\nimport { defineIntegration } from '../integration';\nimport type { ConsoleLevel } from '../types-hoist/instrument';\nimport { CONSOLE_LEVELS } from '../utils/debug-logger';\nimport { severityLevelFromString } from '../utils/severity';\nimport { safeJoin } from '../utils/string';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\n\ninterface ConsoleIntegrationOptions {\n levels: ConsoleLevel[];\n}\n\ntype GlobalObjectWithUtil = typeof GLOBAL_OBJ & {\n util: {\n format: (...args: unknown[]) => string;\n };\n};\n\nconst INTEGRATION_NAME = 'Console';\n\n/**\n * Captures calls to the `console` API as breadcrumbs in Sentry.\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 * ```js\n * Sentry.init({\n * integrations: [Sentry.consoleIntegration({ levels: ['error', 'warn'] })],\n * });\n * ```\n */\nexport const consoleIntegration = defineIntegration((options: Partial<ConsoleIntegrationOptions> = {}) => {\n const levels = new Set(options.levels || CONSOLE_LEVELS);\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const unsubscribe = addConsoleInstrumentationHandler(({ args, level }) => {\n if (getClient() !== client || !levels.has(level)) {\n return;\n }\n\n addConsoleBreadcrumb(level, args);\n });\n\n client.registerCleanup(unsubscribe);\n },\n };\n});\n\n/**\n * Capture a console breadcrumb.\n *\n * Exported just for tests.\n */\nexport function addConsoleBreadcrumb(level: ConsoleLevel, args: unknown[]): void {\n const breadcrumb = {\n category: 'console',\n data: {\n arguments: args,\n logger: 'console',\n },\n level: severityLevelFromString(level),\n message: formatConsoleArgs(args),\n };\n\n if (level === 'assert') {\n if (args[0] === false) {\n const assertionArgs = args.slice(1);\n breadcrumb.message =\n assertionArgs.length > 0 ? `Assertion failed: ${formatConsoleArgs(assertionArgs)}` : 'Assertion failed';\n breadcrumb.data.arguments = assertionArgs;\n } else {\n // Don't capture a breadcrumb for passed assertions\n return;\n }\n }\n\n addBreadcrumb(breadcrumb, {\n input: args,\n level,\n });\n}\n\nfunction formatConsoleArgs(values: unknown[]): string {\n return 'util' in GLOBAL_OBJ && typeof (GLOBAL_OBJ as GlobalObjectWithUtil).util.format === 'function'\n ? (GLOBAL_OBJ as GlobalObjectWithUtil).util.format(...values)\n : safeJoin(values, ' ');\n}\n"],"names":[],"mappings":";;;;;;;;;AAoBA,MAAM,gBAAA,GAAmB,SAAS;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,kBAAA,GAAqB,iBAAiB,CAAC,CAAC,OAAO,GAAuC,EAAE,KAAK;AAC1G,EAAE,MAAM,MAAA,GAAS,IAAI,GAAG,CAAC,OAAO,CAAC,MAAA,IAAU,cAAc,CAAC;;AAE1D,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,WAAA,GAAc,gCAAgC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAA,EAAO,KAAK;AAChF,QAAQ,IAAI,SAAS,OAAO,MAAA,IAAU,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;AAC1D,UAAU;AACV,QAAQ;;AAER,QAAQ,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC;AACzC,MAAM,CAAC,CAAC;;AAER,MAAM,MAAM,CAAC,eAAe,CAAC,WAAW,CAAC;AACzC,IAAI,CAAC;AACL,GAAG;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,KAAK,EAAgB,IAAI,EAAmB;AACjF,EAAE,MAAM,aAAa;AACrB,IAAI,QAAQ,EAAE,SAAS;AACvB,IAAI,IAAI,EAAE;AACV,MAAM,SAAS,EAAE,IAAI;AACrB,MAAM,MAAM,EAAE,SAAS;AACvB,KAAK;AACL,IAAI,KAAK,EAAE,uBAAuB,CAAC,KAAK,CAAC;AACzC,IAAI,OAAO,EAAE,iBAAiB,CAAC,IAAI,CAAC;AACpC,GAAG;;AAEH,EAAE,IAAI,KAAA,KAAU,QAAQ,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,CAAC,CAAA,KAAM,KAAK,EAAE;AAC3B,MAAM,MAAM,gBAAgB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACzC,MAAM,UAAU,CAAC,OAAA;AACjB,QAAQ,aAAa,CAAC,MAAA,GAAS,IAAI,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAA,GAAA,kBAAA;AACA,MAAA,UAAA,CAAA,IAAA,CAAA,SAAA,GAAA,aAAA;AACA,IAAA,CAAA,MAAA;AACA;AACA,MAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,aAAA,CAAA,UAAA,EAAA;AACA,IAAA,KAAA,EAAA,IAAA;AACA,IAAA,KAAA;AACA,GAAA,CAAA;AACA;;AAEA,SAAA,iBAAA,CAAA,MAAA,EAAA;AACA,EAAA,OAAA,MAAA,IAAA,UAAA,IAAA,OAAA,CAAA,UAAA,GAAA,IAAA,CAAA,MAAA,KAAA;AACA,MAAA,CAAA,UAAA,GAAA,IAAA,CAAA,MAAA,CAAA,GAAA,MAAA;AACA,MAAA,QAAA,CAAA,MAAA,EAAA,GAAA,CAAA;AACA;;;;"} | ||
| {"version":3,"file":"console.js","sources":["../../../src/integrations/console.ts"],"sourcesContent":["import { addBreadcrumb } from '../breadcrumbs';\nimport { getClient } from '../currentScopes';\nimport { addConsoleInstrumentationFilter, addConsoleInstrumentationHandler } from '../instrument/console';\nimport { defineIntegration } from '../integration';\nimport type { ConsoleLevel } from '../types-hoist/instrument';\nimport { CONSOLE_LEVELS } from '../utils/debug-logger';\nimport { severityLevelFromString } from '../utils/severity';\nimport { safeJoin } from '../utils/string';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\n\ninterface ConsoleIntegrationOptions {\n levels: ConsoleLevel[];\n /**\n * Filter out console messages that match the given strings or regular expressions.\n * These will neither be passed to the handler, and they will also not be logged to the user, unless they have debug enabled.\n */\n filter?: (string | RegExp)[];\n}\n\ntype GlobalObjectWithUtil = typeof GLOBAL_OBJ & {\n util: {\n format: (...args: unknown[]) => string;\n };\n};\n\nconst INTEGRATION_NAME = 'Console';\n\n/**\n * Captures calls to the `console` API as breadcrumbs in Sentry.\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 * ```js\n * Sentry.init({\n * integrations: [Sentry.consoleIntegration({ levels: ['error', 'warn'] })],\n * });\n * ```\n */\nexport const consoleIntegration = defineIntegration((options: Partial<ConsoleIntegrationOptions> = {}) => {\n const levels = new Set(options.levels || CONSOLE_LEVELS);\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const unsubscribe = addConsoleInstrumentationHandler(({ args, level }) => {\n if (getClient() !== client || !levels.has(level)) {\n return;\n }\n\n addConsoleBreadcrumb(level, args);\n });\n client.registerCleanup(unsubscribe);\n\n if (options.filter) {\n const unsubscribe = addConsoleInstrumentationFilter(options.filter);\n client.registerCleanup(unsubscribe);\n }\n },\n };\n});\n\n/**\n * Capture a console breadcrumb.\n *\n * Exported just for tests.\n */\nexport function addConsoleBreadcrumb(level: ConsoleLevel, args: unknown[]): void {\n const breadcrumb = {\n category: 'console',\n data: {\n arguments: args,\n logger: 'console',\n },\n level: severityLevelFromString(level),\n message: formatConsoleArgs(args),\n };\n\n if (level === 'assert') {\n if (args[0] === false) {\n const assertionArgs = args.slice(1);\n breadcrumb.message =\n assertionArgs.length > 0 ? `Assertion failed: ${formatConsoleArgs(assertionArgs)}` : 'Assertion failed';\n breadcrumb.data.arguments = assertionArgs;\n } else {\n // Don't capture a breadcrumb for passed assertions\n return;\n }\n }\n\n addBreadcrumb(breadcrumb, {\n input: args,\n level,\n });\n}\n\nfunction formatConsoleArgs(values: unknown[]): string {\n return 'util' in GLOBAL_OBJ && typeof (GLOBAL_OBJ as GlobalObjectWithUtil).util.format === 'function'\n ? (GLOBAL_OBJ as GlobalObjectWithUtil).util.format(...values)\n : safeJoin(values, ' ');\n}\n"],"names":[],"mappings":";;;;;;;;;AAyBA,MAAM,gBAAA,GAAmB,SAAS;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,kBAAA,GAAqB,iBAAiB,CAAC,CAAC,OAAO,GAAuC,EAAE,KAAK;AAC1G,EAAE,MAAM,MAAA,GAAS,IAAI,GAAG,CAAC,OAAO,CAAC,MAAA,IAAU,cAAc,CAAC;;AAE1D,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,WAAA,GAAc,gCAAgC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAA,EAAO,KAAK;AAChF,QAAQ,IAAI,SAAS,OAAO,MAAA,IAAU,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;AAC1D,UAAU;AACV,QAAQ;;AAER,QAAQ,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC;AACzC,MAAM,CAAC,CAAC;AACR,MAAM,MAAM,CAAC,eAAe,CAAC,WAAW,CAAC;;AAEzC,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE;AAC1B,QAAQ,MAAM,cAAc,+BAA+B,CAAC,OAAO,CAAC,MAAM,CAAC;AAC3E,QAAQ,MAAM,CAAC,eAAe,CAAC,WAAW,CAAC;AAC3C,MAAM;AACN,IAAI,CAAC;AACL,GAAG;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,KAAK,EAAgB,IAAI,EAAmB;AACjF,EAAE,MAAM,aAAa;AACrB,IAAI,QAAQ,EAAE,SAAS;AACvB,IAAI,IAAI,EAAE;AACV,MAAM,SAAS,EAAE,IAAI;AACrB,MAAM,MAAM,EAAE,SAAS;AACvB,KAAK;AACL,IAAI,KAAK,EAAE,uBAAuB,CAAC,KAAK,CAAC;AACzC,IAAI,OAAO,EAAE,iBAAiB,CAAC,IAAI,CAAC;AACpC,GAAG;;AAEH,EAAE,IAAI,KAAA,KAAU,QAAQ,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,CAAC,CAAA,KAAM,KAAK,EAAE;AAC3B,MAAM,MAAM,gBAAgB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACzC,MAAM,UAAU,CAAC,OAAA;AACjB,QAAQ,aAAa,CAAC,MAAA,GAAS,IAAI,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAA,GAAA,kBAAA;AACA,MAAA,UAAA,CAAA,IAAA,CAAA,SAAA,GAAA,aAAA;AACA,IAAA,CAAA,MAAA;AACA;AACA,MAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,aAAA,CAAA,UAAA,EAAA;AACA,IAAA,KAAA,EAAA,IAAA;AACA,IAAA,KAAA;AACA,GAAA,CAAA;AACA;;AAEA,SAAA,iBAAA,CAAA,MAAA,EAAA;AACA,EAAA,OAAA,MAAA,IAAA,UAAA,IAAA,OAAA,CAAA,UAAA,GAAA,IAAA,CAAA,MAAA,KAAA;AACA,MAAA,CAAA,UAAA,GAAA,IAAA,CAAA,MAAA,CAAA,GAAA,MAAA;AACA,MAAA,QAAA,CAAA,MAAA,EAAA,GAAA,CAAA;AACA;;;;"} |
@@ -171,3 +171,74 @@ import { DEBUG_BUILD } from '../../debug-build.js'; | ||
| export { wrapAllMCPHandlers, wrapPromptHandlers, wrapResourceHandlers, wrapToolHandlers }; | ||
| /** | ||
| * Retroactively wraps handlers on tools, resources, and prompts that were registered | ||
| * before `wrapMcpServerWithSentry` was called. | ||
| * | ||
| * The MCP SDK stores registered entries in private maps and invokes them via the entry's | ||
| * own property at call time — `executor` for tools, `readCallback` for resources, and | ||
| * `handler` for prompts. Replacing those properties | ||
| * in-place is therefore equivalent to having wrapped the original registration call. | ||
| * | ||
| * NOTE: This intentionally accesses private MCP SDK internals (`_registeredTools` etc.). | ||
| * The properties and their shapes are verified against @modelcontextprotocol/sdk source: | ||
| * https://github.com/modelcontextprotocol/typescript-sdk/blob/2c0c481cb9dbfd15c8613f765c940a5f5bace94d/packages/server/src/server/mcp.ts#L304 | ||
| * When upgrading the MCP SDK, re-verify that these internal maps and their callable | ||
| * properties still exist and are invoked directly (not captured by closure at registration). | ||
| * All access is defensive — if a property is absent or not a function we skip silently. | ||
| * @internal | ||
| */ | ||
| function wrapExistingHandlers(serverInstance) { | ||
| const server = serverInstance ; | ||
| // Tools: MCP SDK calls registeredTool.executor (generated from handler at registration time) | ||
| const registeredTools = server['_registeredTools']; | ||
| if (registeredTools && typeof registeredTools === 'object') { | ||
| for (const [name, tool] of Object.entries(registeredTools )) { | ||
| if (typeof tool['executor'] === 'function') { | ||
| tool['executor'] = createWrappedHandler(tool['executor'] , 'registerTool', name); | ||
| } | ||
| } | ||
| } | ||
| // Resources: MCP SDK calls registeredResource.readCallback | ||
| const registeredResources = server['_registeredResources']; | ||
| if (registeredResources && typeof registeredResources === 'object') { | ||
| for (const [name, resource] of Object.entries(registeredResources )) { | ||
| if (typeof resource['readCallback'] === 'function') { | ||
| resource['readCallback'] = createWrappedHandler( | ||
| resource['readCallback'] , | ||
| 'registerResource', | ||
| name, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| // Resource templates: MCP SDK calls registeredResourceTemplate.readCallback | ||
| const registeredResourceTemplates = server['_registeredResourceTemplates']; | ||
| if (registeredResourceTemplates && typeof registeredResourceTemplates === 'object') { | ||
| for (const [name, template] of Object.entries( | ||
| registeredResourceTemplates , | ||
| )) { | ||
| if (typeof template['readCallback'] === 'function') { | ||
| template['readCallback'] = createWrappedHandler( | ||
| template['readCallback'] , | ||
| 'registerResource', | ||
| name, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| // Prompts: MCP SDK calls registeredPrompt.handler | ||
| const registeredPrompts = server['_registeredPrompts']; | ||
| if (registeredPrompts && typeof registeredPrompts === 'object') { | ||
| for (const [name, prompt] of Object.entries(registeredPrompts )) { | ||
| if (typeof prompt['handler'] === 'function') { | ||
| prompt['handler'] = createWrappedHandler(prompt['handler'] , 'registerPrompt', name); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| export { wrapAllMCPHandlers, wrapExistingHandlers, wrapPromptHandlers, wrapResourceHandlers, wrapToolHandlers }; | ||
| //# sourceMappingURL=handlers.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"handlers.js","sources":["../../../../src/integrations/mcp-server/handlers.ts"],"sourcesContent":["/**\n * Handler method wrapping for MCP server instrumentation\n *\n * Provides automatic error capture and span correlation for tool, resource,\n * and prompt handlers.\n */\n\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { debug } from '../../utils/debug-logger';\nimport { fill } from '../../utils/object';\nimport { captureError } from './errorCapture';\nimport type { MCPHandler, MCPServerInstance } from './types';\n\n/**\n * Generic function to wrap MCP server method handlers\n * @internal\n * @param serverInstance - MCP server instance\n * @param methodName - Method name to wrap (tool, resource, prompt)\n */\nfunction wrapMethodHandler(serverInstance: MCPServerInstance, methodName: keyof MCPServerInstance): void {\n fill(serverInstance, methodName, originalMethod => {\n return function (this: MCPServerInstance, name: string, ...args: unknown[]) {\n const handler = args[args.length - 1];\n\n if (typeof handler !== 'function') {\n return (originalMethod as (...args: unknown[]) => unknown).call(this, name, ...args);\n }\n\n const wrappedHandler = createWrappedHandler(handler as MCPHandler, methodName, name);\n return (originalMethod as (...args: unknown[]) => unknown).call(this, name, ...args.slice(0, -1), wrappedHandler);\n };\n });\n}\n\n/**\n * Creates a wrapped handler with span correlation and error capture\n * @internal\n * @param originalHandler - Original handler function\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n * @returns Wrapped handler function\n */\nfunction createWrappedHandler(originalHandler: MCPHandler, methodName: keyof MCPServerInstance, handlerName: string) {\n return function (this: unknown, ...handlerArgs: unknown[]): unknown {\n try {\n return createErrorCapturingHandler.call(this, originalHandler, methodName, handlerName, handlerArgs);\n } catch (error) {\n DEBUG_BUILD && debug.warn('MCP handler wrapping failed:', error);\n return originalHandler.apply(this, handlerArgs);\n }\n };\n}\n\n/**\n * Creates an error-capturing wrapper for handler execution\n * @internal\n * @param originalHandler - Original handler function\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n * @param handlerArgs - Handler arguments\n * @param extraHandlerData - Additional handler context\n * @returns Handler execution result\n */\nfunction createErrorCapturingHandler(\n this: MCPServerInstance,\n originalHandler: MCPHandler,\n methodName: keyof MCPServerInstance,\n handlerName: string,\n handlerArgs: unknown[],\n): unknown {\n try {\n const result = originalHandler.apply(this, handlerArgs);\n\n if (result && typeof result === 'object' && typeof (result as { then?: unknown }).then === 'function') {\n return Promise.resolve(result).catch(error => {\n captureHandlerError(error, methodName, handlerName);\n throw error;\n });\n }\n\n return result;\n } catch (error) {\n captureHandlerError(error as Error, methodName, handlerName);\n throw error;\n }\n}\n\n/**\n * Captures handler execution errors based on handler type\n * @internal\n * @param error - Error to capture\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n */\nfunction captureHandlerError(error: Error, methodName: keyof MCPServerInstance, handlerName: string): void {\n try {\n const extraData: Record<string, unknown> = {};\n\n if (methodName === 'tool' || methodName === 'registerTool') {\n extraData.tool_name = handlerName;\n\n if (\n error.name === 'ProtocolValidationError' ||\n error.message.includes('validation') ||\n error.message.includes('protocol')\n ) {\n captureError(error, 'validation', extraData);\n } else if (\n error.name === 'ServerTimeoutError' ||\n error.message.includes('timed out') ||\n error.message.includes('timeout')\n ) {\n captureError(error, 'timeout', extraData);\n } else {\n captureError(error, 'tool_execution', extraData);\n }\n } else if (methodName === 'resource' || methodName === 'registerResource') {\n extraData.resource_uri = handlerName;\n captureError(error, 'resource_execution', extraData);\n } else if (methodName === 'prompt' || methodName === 'registerPrompt') {\n extraData.prompt_name = handlerName;\n captureError(error, 'prompt_execution', extraData);\n }\n } catch (_captureErr) {\n // noop\n }\n}\n\n/**\n * Wraps tool handlers to associate them with request spans.\n * Instruments both `tool` (legacy API) and `registerTool` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapToolHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.tool === 'function') wrapMethodHandler(serverInstance, 'tool');\n if (typeof serverInstance.registerTool === 'function') wrapMethodHandler(serverInstance, 'registerTool');\n}\n\n/**\n * Wraps resource handlers to associate them with request spans.\n * Instruments both `resource` (legacy API) and `registerResource` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapResourceHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.resource === 'function') wrapMethodHandler(serverInstance, 'resource');\n if (typeof serverInstance.registerResource === 'function') wrapMethodHandler(serverInstance, 'registerResource');\n}\n\n/**\n * Wraps prompt handlers to associate them with request spans.\n * Instruments both `prompt` (legacy API) and `registerPrompt` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapPromptHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.prompt === 'function') wrapMethodHandler(serverInstance, 'prompt');\n if (typeof serverInstance.registerPrompt === 'function') wrapMethodHandler(serverInstance, 'registerPrompt');\n}\n\n/**\n * Wraps all MCP handler types for span correlation.\n * Supports both the legacy API (`tool`, `resource`, `prompt`) and the newer API\n * (`registerTool`, `registerResource`, `registerPrompt`), instrumenting whichever methods are present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapAllMCPHandlers(serverInstance: MCPServerInstance): void {\n wrapToolHandlers(serverInstance);\n wrapResourceHandlers(serverInstance);\n wrapPromptHandlers(serverInstance);\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,iBAAiB,CAA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CAAC,cAAc,EAAE,kBAAkB,CAAC;AAClH;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,cAAc,EAA2B;AAC5E,EAAE,IAAI,OAAO,cAAc,CAAC,MAAA,KAAW,UAAU,EAAE,iBAAiB,CAAC,cAAc,EAAE,QAAQ,CAAC;AAC9F,EAAE,IAAI,OAAO,cAAc,CAAC,cAAA,KAAmB,UAAU,EAAE,iBAAiB,CAAC,cAAc,EAAE,gBAAgB,CAAC;AAC9G;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,cAAc,EAA2B;AAC5E,EAAE,gBAAgB,CAAC,cAAc,CAAC;AAClC,EAAE,oBAAoB,CAAC,cAAc,CAAC;AACtC,EAAE,kBAAkB,CAAC,cAAc,CAAC;AACpC;;;;"} | ||
| {"version":3,"file":"handlers.js","sources":["../../../../src/integrations/mcp-server/handlers.ts"],"sourcesContent":["/**\n * Handler method wrapping for MCP server instrumentation\n *\n * Provides automatic error capture and span correlation for tool, resource,\n * and prompt handlers.\n */\n\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { debug } from '../../utils/debug-logger';\nimport { fill } from '../../utils/object';\nimport { captureError } from './errorCapture';\nimport type { MCPHandler, MCPServerInstance } from './types';\n\n/**\n * Generic function to wrap MCP server method handlers\n * @internal\n * @param serverInstance - MCP server instance\n * @param methodName - Method name to wrap (tool, resource, prompt)\n */\nfunction wrapMethodHandler(serverInstance: MCPServerInstance, methodName: keyof MCPServerInstance): void {\n fill(serverInstance, methodName, originalMethod => {\n return function (this: MCPServerInstance, name: string, ...args: unknown[]) {\n const handler = args[args.length - 1];\n\n if (typeof handler !== 'function') {\n return (originalMethod as (...args: unknown[]) => unknown).call(this, name, ...args);\n }\n\n const wrappedHandler = createWrappedHandler(handler as MCPHandler, methodName, name);\n return (originalMethod as (...args: unknown[]) => unknown).call(this, name, ...args.slice(0, -1), wrappedHandler);\n };\n });\n}\n\n/**\n * Creates a wrapped handler with span correlation and error capture\n * @internal\n * @param originalHandler - Original handler function\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n * @returns Wrapped handler function\n */\nfunction createWrappedHandler(originalHandler: MCPHandler, methodName: keyof MCPServerInstance, handlerName: string) {\n return function (this: unknown, ...handlerArgs: unknown[]): unknown {\n try {\n return createErrorCapturingHandler.call(this, originalHandler, methodName, handlerName, handlerArgs);\n } catch (error) {\n DEBUG_BUILD && debug.warn('MCP handler wrapping failed:', error);\n return originalHandler.apply(this, handlerArgs);\n }\n };\n}\n\n/**\n * Creates an error-capturing wrapper for handler execution\n * @internal\n * @param originalHandler - Original handler function\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n * @param handlerArgs - Handler arguments\n * @param extraHandlerData - Additional handler context\n * @returns Handler execution result\n */\nfunction createErrorCapturingHandler(\n this: MCPServerInstance,\n originalHandler: MCPHandler,\n methodName: keyof MCPServerInstance,\n handlerName: string,\n handlerArgs: unknown[],\n): unknown {\n try {\n const result = originalHandler.apply(this, handlerArgs);\n\n if (result && typeof result === 'object' && typeof (result as { then?: unknown }).then === 'function') {\n return Promise.resolve(result).catch(error => {\n captureHandlerError(error, methodName, handlerName);\n throw error;\n });\n }\n\n return result;\n } catch (error) {\n captureHandlerError(error as Error, methodName, handlerName);\n throw error;\n }\n}\n\n/**\n * Captures handler execution errors based on handler type\n * @internal\n * @param error - Error to capture\n * @param methodName - MCP method name\n * @param handlerName - Handler identifier\n */\nfunction captureHandlerError(error: Error, methodName: keyof MCPServerInstance, handlerName: string): void {\n try {\n const extraData: Record<string, unknown> = {};\n\n if (methodName === 'tool' || methodName === 'registerTool') {\n extraData.tool_name = handlerName;\n\n if (\n error.name === 'ProtocolValidationError' ||\n error.message.includes('validation') ||\n error.message.includes('protocol')\n ) {\n captureError(error, 'validation', extraData);\n } else if (\n error.name === 'ServerTimeoutError' ||\n error.message.includes('timed out') ||\n error.message.includes('timeout')\n ) {\n captureError(error, 'timeout', extraData);\n } else {\n captureError(error, 'tool_execution', extraData);\n }\n } else if (methodName === 'resource' || methodName === 'registerResource') {\n extraData.resource_uri = handlerName;\n captureError(error, 'resource_execution', extraData);\n } else if (methodName === 'prompt' || methodName === 'registerPrompt') {\n extraData.prompt_name = handlerName;\n captureError(error, 'prompt_execution', extraData);\n }\n } catch (_captureErr) {\n // noop\n }\n}\n\n/**\n * Wraps tool handlers to associate them with request spans.\n * Instruments both `tool` (legacy API) and `registerTool` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapToolHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.tool === 'function') wrapMethodHandler(serverInstance, 'tool');\n if (typeof serverInstance.registerTool === 'function') wrapMethodHandler(serverInstance, 'registerTool');\n}\n\n/**\n * Wraps resource handlers to associate them with request spans.\n * Instruments both `resource` (legacy API) and `registerResource` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapResourceHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.resource === 'function') wrapMethodHandler(serverInstance, 'resource');\n if (typeof serverInstance.registerResource === 'function') wrapMethodHandler(serverInstance, 'registerResource');\n}\n\n/**\n * Wraps prompt handlers to associate them with request spans.\n * Instruments both `prompt` (legacy API) and `registerPrompt` (new API) if present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapPromptHandlers(serverInstance: MCPServerInstance): void {\n if (typeof serverInstance.prompt === 'function') wrapMethodHandler(serverInstance, 'prompt');\n if (typeof serverInstance.registerPrompt === 'function') wrapMethodHandler(serverInstance, 'registerPrompt');\n}\n\n/**\n * Wraps all MCP handler types for span correlation.\n * Supports both the legacy API (`tool`, `resource`, `prompt`) and the newer API\n * (`registerTool`, `registerResource`, `registerPrompt`), instrumenting whichever methods are present.\n * @param serverInstance - MCP server instance\n */\nexport function wrapAllMCPHandlers(serverInstance: MCPServerInstance): void {\n wrapToolHandlers(serverInstance);\n wrapResourceHandlers(serverInstance);\n wrapPromptHandlers(serverInstance);\n}\n\n/**\n * Retroactively wraps handlers on tools, resources, and prompts that were registered\n * before `wrapMcpServerWithSentry` was called.\n *\n * The MCP SDK stores registered entries in private maps and invokes them via the entry's\n * own property at call time — `executor` for tools, `readCallback` for resources, and\n * `handler` for prompts. Replacing those properties\n * in-place is therefore equivalent to having wrapped the original registration call.\n *\n * NOTE: This intentionally accesses private MCP SDK internals (`_registeredTools` etc.).\n * The properties and their shapes are verified against @modelcontextprotocol/sdk source:\n * https://github.com/modelcontextprotocol/typescript-sdk/blob/2c0c481cb9dbfd15c8613f765c940a5f5bace94d/packages/server/src/server/mcp.ts#L304\n * When upgrading the MCP SDK, re-verify that these internal maps and their callable\n * properties still exist and are invoked directly (not captured by closure at registration).\n * All access is defensive — if a property is absent or not a function we skip silently.\n * @internal\n */\nexport function wrapExistingHandlers(serverInstance: MCPServerInstance): void {\n const server = serverInstance as unknown as Record<string, unknown>;\n\n // Tools: MCP SDK calls registeredTool.executor (generated from handler at registration time)\n const registeredTools = server['_registeredTools'];\n if (registeredTools && typeof registeredTools === 'object') {\n for (const [name, tool] of Object.entries(registeredTools as Record<string, Record<string, unknown>>)) {\n if (typeof tool['executor'] === 'function') {\n tool['executor'] = createWrappedHandler(tool['executor'] as MCPHandler, 'registerTool', name);\n }\n }\n }\n\n // Resources: MCP SDK calls registeredResource.readCallback\n const registeredResources = server['_registeredResources'];\n if (registeredResources && typeof registeredResources === 'object') {\n for (const [name, resource] of Object.entries(registeredResources as Record<string, Record<string, unknown>>)) {\n if (typeof resource['readCallback'] === 'function') {\n resource['readCallback'] = createWrappedHandler(\n resource['readCallback'] as MCPHandler,\n 'registerResource',\n name,\n );\n }\n }\n }\n\n // Resource templates: MCP SDK calls registeredResourceTemplate.readCallback\n const registeredResourceTemplates = server['_registeredResourceTemplates'];\n if (registeredResourceTemplates && typeof registeredResourceTemplates === 'object') {\n for (const [name, template] of Object.entries(\n registeredResourceTemplates as Record<string, Record<string, unknown>>,\n )) {\n if (typeof template['readCallback'] === 'function') {\n template['readCallback'] = createWrappedHandler(\n template['readCallback'] as MCPHandler,\n 'registerResource',\n name,\n );\n }\n }\n }\n\n // Prompts: MCP SDK calls registeredPrompt.handler\n const registeredPrompts = server['_registeredPrompts'];\n if (registeredPrompts && typeof registeredPrompts === 'object') {\n for (const [name, prompt] of Object.entries(registeredPrompts as Record<string, Record<string, unknown>>)) {\n if (typeof prompt['handler'] === 'function') {\n prompt['handler'] = createWrappedHandler(prompt['handler'] as MCPHandler, 'registerPrompt', name);\n }\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,cAAc,EAAqB,UAAU,EAAiC;AACzG,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,EAAE,kBAAkB;AACrD,IAAI,OAAO,WAAmC,IAAI,EAAU,GAAG,IAAI,EAAa;AAChF,MAAM,MAAM,OAAA,GAAU,IAAI,CAAC,IAAI,CAAC,MAAA,GAAS,CAAC,CAAC;;AAE3C,MAAM,IAAI,OAAO,OAAA,KAAY,UAAU,EAAE;AACzC,QAAQ,OAAO,CAAC,cAAA,GAAmD,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;AAC5F,MAAM;;AAEN,MAAM,MAAM,cAAA,GAAiB,oBAAoB,CAAC,UAAuB,UAAU,EAAE,IAAI,CAAC;AAC1F,MAAM,OAAO,CAAC,cAAA,GAAmD,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,cAAc,CAAC;AACvH,IAAI,CAAC;AACL,EAAE,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,oBAAoB,CAAC,eAAe,EAAc,UAAU,EAA2B,WAAW,EAAU;AACrH,EAAE,OAAO,WAAyB,GAAG,WAAW,EAAsB;AACtE,IAAI,IAAI;AACR,MAAM,OAAO,2BAA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N,IAAI;AACJ,EAAE;;AAEF;AACA,EAAE,MAAM,iBAAA,GAAoB,MAAM,CAAC,oBAAoB,CAAC;AACxD,EAAE,IAAI,iBAAA,IAAqB,OAAO,iBAAA,KAAsB,QAAQ,EAAE;AAClE,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAA,IAAK,MAAM,CAAC,OAAO,CAAC,iBAAA,EAA6D,EAAE;AAC/G,MAAM,IAAI,OAAO,MAAM,CAAC,SAAS,CAAA,KAAM,UAAU,EAAE;AACnD,QAAQ,MAAM,CAAC,SAAS,CAAA,GAAI,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAA,GAAiB,gBAAgB,EAAE,IAAI,CAAC;AACzG,MAAM;AACN,IAAI;AACJ,EAAE;AACF;;;;"} |
| import { getClient } from '../../currentScopes.js'; | ||
| import { fill } from '../../utils/object.js'; | ||
| import { wrapAllMCPHandlers } from './handlers.js'; | ||
| import { wrapAllMCPHandlers, wrapExistingHandlers } from './handlers.js'; | ||
| import { wrapTransportOnMessage, wrapTransportSend, wrapTransportOnClose, wrapTransportError } from './transport.js'; | ||
@@ -20,2 +20,7 @@ import { validateMcpServerInstance } from './validation.js'; | ||
| * | ||
| * Both call orderings are supported: wrapping before or after registering tools, resources, | ||
| * and prompts. Sentry patches the registration methods for future handlers and retroactively | ||
| * wraps any already-registered ones. Wrapping at construction time is recommended by | ||
| * convention (consistent with other SDK integrations), but is not required. | ||
| * | ||
| * @example | ||
@@ -27,3 +32,3 @@ * ```typescript | ||
| * | ||
| * // Default: inputs/outputs captured based on sendDefaultPii option | ||
| * // Wrap first, then register tools — this is the correct order | ||
| * const server = Sentry.wrapMcpServerWithSentry( | ||
@@ -33,2 +38,4 @@ * new McpServer({ name: "my-server", version: "1.0.0" }) | ||
| * | ||
| * server.registerTool('my-tool', schema, handler); | ||
| * | ||
| * // Explicitly control input/output capture | ||
@@ -85,2 +92,4 @@ * const server = Sentry.wrapMcpServerWithSentry( | ||
| wrapExistingHandlers(serverInstance); | ||
| wrappedMcpServerInstances.add(mcpServerInstance); | ||
@@ -87,0 +96,0 @@ return mcpServerInstance; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/integrations/mcp-server/index.ts"],"sourcesContent":["import { getClient } from '../../currentScopes';\nimport { fill } from '../../utils/object';\nimport { wrapAllMCPHandlers } from './handlers';\nimport { wrapTransportError, wrapTransportOnClose, wrapTransportOnMessage, wrapTransportSend } from './transport';\nimport type { MCPServerInstance, McpServerWrapperOptions, MCPTransport, ResolvedMcpOptions } from './types';\nimport { validateMcpServerInstance } from './validation';\n\n/**\n * Tracks wrapped MCP server instances to prevent double-wrapping\n * @internal\n */\nconst wrappedMcpServerInstances = new WeakSet();\n\n/**\n * Wraps a MCP Server instance from the `@modelcontextprotocol/sdk` package with Sentry instrumentation.\n *\n * Compatible with versions `^1.9.0` of the `@modelcontextprotocol/sdk` package (legacy `tool`/`resource`/`prompt` API)\n * and versions that expose the newer `registerTool`/`registerResource`/`registerPrompt` API (introduced in 1.x, sole API in 2.x).\n * Automatically instruments transport methods and handler functions for comprehensive monitoring.\n *\n * @example\n * ```typescript\n * import * as Sentry from '@sentry/core';\n * import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n * import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\n *\n * // Default: inputs/outputs captured based on sendDefaultPii option\n * const server = Sentry.wrapMcpServerWithSentry(\n * new McpServer({ name: \"my-server\", version: \"1.0.0\" })\n * );\n *\n * // Explicitly control input/output capture\n * const server = Sentry.wrapMcpServerWithSentry(\n * new McpServer({ name: \"my-server\", version: \"1.0.0\" }),\n * { recordInputs: true, recordOutputs: false }\n * );\n *\n * const transport = new StreamableHTTPServerTransport();\n * await server.connect(transport);\n * ```\n *\n * @param mcpServerInstance - MCP server instance to instrument\n * @param options - Optional configuration for recording inputs and outputs\n * @returns Instrumented server instance (same reference)\n */\nexport function wrapMcpServerWithSentry<S extends object>(mcpServerInstance: S, options?: McpServerWrapperOptions): S {\n if (wrappedMcpServerInstances.has(mcpServerInstance)) {\n return mcpServerInstance;\n }\n\n if (!validateMcpServerInstance(mcpServerInstance)) {\n return mcpServerInstance;\n }\n\n const serverInstance = mcpServerInstance as MCPServerInstance;\n const client = getClient();\n const sendDefaultPii = Boolean(client?.getOptions().sendDefaultPii);\n\n const resolvedOptions: ResolvedMcpOptions = {\n recordInputs: options?.recordInputs ?? sendDefaultPii,\n recordOutputs: options?.recordOutputs ?? sendDefaultPii,\n };\n\n fill(serverInstance, 'connect', originalConnect => {\n return async function (this: MCPServerInstance, transport: MCPTransport, ...restArgs: unknown[]) {\n const result = await (originalConnect as (...args: unknown[]) => Promise<unknown>).call(\n this,\n transport,\n ...restArgs,\n );\n\n wrapTransportOnMessage(transport, resolvedOptions);\n wrapTransportSend(transport, resolvedOptions);\n wrapTransportOnClose(transport);\n wrapTransportError(transport);\n\n return result;\n };\n });\n\n wrapAllMCPHandlers(serverInstance);\n\n wrappedMcpServerInstances.add(mcpServerInstance);\n return mcpServerInstance;\n}\n"],"names":[],"mappings":";;;;;;AAOA;AACA;AACA;AACA;AACA,MAAM,yBAAA,GAA4B,IAAI,OAAO,EAAE;;AAE/C;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;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAmB,iBAAiB,EAAK,OAAO,EAA+B;AACtH,EAAE,IAAI,yBAAyB,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE;AACxD,IAAI,OAAO,iBAAiB;AAC5B,EAAE;;AAEF,EAAE,IAAI,CAAC,yBAAyB,CAAC,iBAAiB,CAAC,EAAE;AACrD,IAAI,OAAO,iBAAiB;AAC5B,EAAE;;AAEF,EAAE,MAAM,cAAA,GAAiB,iBAAA;AACzB,EAAE,MAAM,MAAA,GAAS,SAAS,EAAE;AAC5B,EAAE,MAAM,cAAA,GAAiB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,cAAc,CAAC;;AAErE,EAAE,MAAM,eAAe,GAAuB;AAC9C,IAAI,YAAY,EAAE,OAAO,EAAE,YAAA,IAAgB,cAAc;AACzD,IAAI,aAAa,EAAE,OAAO,EAAE,aAAA,IAAiB,cAAc;AAC3D,GAAG;;AAEH,EAAE,IAAI,CAAC,cAAc,EAAE,SAAS,EAAE,mBAAmB;AACrD,IAAI,OAAO,iBAAyC,SAAS,EAAgB,GAAG,QAAQ,EAAa;AACrG,MAAM,MAAM,SAAS,MAAM,CAAC,eAAA,GAA6D,IAAI;AAC7F,QAAQ,IAAI;AACZ,QAAQ,SAAS;AACjB,QAAQ,GAAG,QAAQ;AACnB,OAAO;;AAEP,MAAM,sBAAsB,CAAC,SAAS,EAAE,eAAe,CAAC;AACxD,MAAM,iBAAiB,CAAC,SAAS,EAAE,eAAe,CAAC;AACnD,MAAM,oBAAoB,CAAC,SAAS,CAAC;AACrC,MAAM,kBAAkB,CAAC,SAAS,CAAC;;AAEnC,MAAM,OAAO,MAAM;AACnB,IAAI,CAAC;AACL,EAAE,CAAC,CAAC;;AAEJ,EAAE,kBAAkB,CAAC,cAAc,CAAC;;AAEpC,EAAE,yBAAyB,CAAC,GAAG,CAAC,iBAAiB,CAAC;AAClD,EAAE,OAAO,iBAAiB;AAC1B;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../src/integrations/mcp-server/index.ts"],"sourcesContent":["import { getClient } from '../../currentScopes';\nimport { fill } from '../../utils/object';\nimport { wrapAllMCPHandlers, wrapExistingHandlers } from './handlers';\nimport { wrapTransportError, wrapTransportOnClose, wrapTransportOnMessage, wrapTransportSend } from './transport';\nimport type { MCPServerInstance, McpServerWrapperOptions, MCPTransport, ResolvedMcpOptions } from './types';\nimport { validateMcpServerInstance } from './validation';\n\n/**\n * Tracks wrapped MCP server instances to prevent double-wrapping\n * @internal\n */\nconst wrappedMcpServerInstances = new WeakSet();\n\n/**\n * Wraps a MCP Server instance from the `@modelcontextprotocol/sdk` package with Sentry instrumentation.\n *\n * Compatible with versions `^1.9.0` of the `@modelcontextprotocol/sdk` package (legacy `tool`/`resource`/`prompt` API)\n * and versions that expose the newer `registerTool`/`registerResource`/`registerPrompt` API (introduced in 1.x, sole API in 2.x).\n * Automatically instruments transport methods and handler functions for comprehensive monitoring.\n *\n * Both call orderings are supported: wrapping before or after registering tools, resources,\n * and prompts. Sentry patches the registration methods for future handlers and retroactively\n * wraps any already-registered ones. Wrapping at construction time is recommended by\n * convention (consistent with other SDK integrations), but is not required.\n *\n * @example\n * ```typescript\n * import * as Sentry from '@sentry/core';\n * import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n * import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\n *\n * // Wrap first, then register tools — this is the correct order\n * const server = Sentry.wrapMcpServerWithSentry(\n * new McpServer({ name: \"my-server\", version: \"1.0.0\" })\n * );\n *\n * server.registerTool('my-tool', schema, handler);\n *\n * // Explicitly control input/output capture\n * const server = Sentry.wrapMcpServerWithSentry(\n * new McpServer({ name: \"my-server\", version: \"1.0.0\" }),\n * { recordInputs: true, recordOutputs: false }\n * );\n *\n * const transport = new StreamableHTTPServerTransport();\n * await server.connect(transport);\n * ```\n *\n * @param mcpServerInstance - MCP server instance to instrument\n * @param options - Optional configuration for recording inputs and outputs\n * @returns Instrumented server instance (same reference)\n */\nexport function wrapMcpServerWithSentry<S extends object>(mcpServerInstance: S, options?: McpServerWrapperOptions): S {\n if (wrappedMcpServerInstances.has(mcpServerInstance)) {\n return mcpServerInstance;\n }\n\n if (!validateMcpServerInstance(mcpServerInstance)) {\n return mcpServerInstance;\n }\n\n const serverInstance = mcpServerInstance as MCPServerInstance;\n const client = getClient();\n const sendDefaultPii = Boolean(client?.getOptions().sendDefaultPii);\n\n const resolvedOptions: ResolvedMcpOptions = {\n recordInputs: options?.recordInputs ?? sendDefaultPii,\n recordOutputs: options?.recordOutputs ?? sendDefaultPii,\n };\n\n fill(serverInstance, 'connect', originalConnect => {\n return async function (this: MCPServerInstance, transport: MCPTransport, ...restArgs: unknown[]) {\n const result = await (originalConnect as (...args: unknown[]) => Promise<unknown>).call(\n this,\n transport,\n ...restArgs,\n );\n\n wrapTransportOnMessage(transport, resolvedOptions);\n wrapTransportSend(transport, resolvedOptions);\n wrapTransportOnClose(transport);\n wrapTransportError(transport);\n\n return result;\n };\n });\n\n wrapAllMCPHandlers(serverInstance);\n\n wrapExistingHandlers(serverInstance);\n\n wrappedMcpServerInstances.add(mcpServerInstance);\n return mcpServerInstance;\n}\n"],"names":[],"mappings":";;;;;;AAOA;AACA;AACA;AACA;AACA,MAAM,yBAAA,GAA4B,IAAI,OAAO,EAAE;;AAE/C;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAmB,iBAAiB,EAAK,OAAO,EAA+B;AACtH,EAAE,IAAI,yBAAyB,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE;AACxD,IAAI,OAAO,iBAAiB;AAC5B,EAAE;;AAEF,EAAE,IAAI,CAAC,yBAAyB,CAAC,iBAAiB,CAAC,EAAE;AACrD,IAAI,OAAO,iBAAiB;AAC5B,EAAE;;AAEF,EAAE,MAAM,cAAA,GAAiB,iBAAA;AACzB,EAAE,MAAM,MAAA,GAAS,SAAS,EAAE;AAC5B,EAAE,MAAM,cAAA,GAAiB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,cAAc,CAAC;;AAErE,EAAE,MAAM,eAAe,GAAuB;AAC9C,IAAI,YAAY,EAAE,OAAO,EAAE,YAAA,IAAgB,cAAc;AACzD,IAAI,aAAa,EAAE,OAAO,EAAE,aAAA,IAAiB,cAAc;AAC3D,GAAG;;AAEH,EAAE,IAAI,CAAC,cAAc,EAAE,SAAS,EAAE,mBAAmB;AACrD,IAAI,OAAO,iBAAyC,SAAS,EAAgB,GAAG,QAAQ,EAAa;AACrG,MAAM,MAAM,SAAS,MAAM,CAAC,eAAA,GAA6D,IAAI;AAC7F,QAAQ,IAAI;AACZ,QAAQ,SAAS;AACjB,QAAQ,GAAG,QAAQ;AACnB,OAAO;;AAEP,MAAM,sBAAsB,CAAC,SAAS,EAAE,eAAe,CAAC;AACxD,MAAM,iBAAiB,CAAC,SAAS,EAAE,eAAe,CAAC;AACnD,MAAM,oBAAoB,CAAC,SAAS,CAAC;AACrC,MAAM,kBAAkB,CAAC,SAAS,CAAC;;AAEnC,MAAM,OAAO,MAAM;AACnB,IAAI,CAAC;AACL,EAAE,CAAC,CAAC;;AAEJ,EAAE,kBAAkB,CAAC,cAAc,CAAC;;AAEpC,EAAE,oBAAoB,CAAC,cAAc,CAAC;;AAEtC,EAAE,yBAAyB,CAAC,GAAG,CAAC,iBAAiB,CAAC;AAClD,EAAE,OAAO,iBAAiB;AAC1B;;;;"} |
@@ -1,1 +0,1 @@ | ||
| {"type":"module","version":"10.52.0","sideEffects":false} | ||
| {"type":"module","version":"10.53.0","sideEffects":false} |
@@ -353,4 +353,8 @@ import { getClient, getCurrentScope } from '../currentScopes.js'; | ||
| delete this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]; | ||
| let hasGenAiSpans = false; | ||
| spans.forEach(span => { | ||
| delete span.data[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]; | ||
| if (span.op?.startsWith('gen_ai.')) { | ||
| hasGenAiSpans = true; | ||
| } | ||
| }); | ||
@@ -377,2 +381,3 @@ // eslint-enabled-next-line @typescript-eslint/no-dynamic-delete | ||
| dynamicSamplingContext: getDynamicSamplingContextFromSpan(this), | ||
| hasGenAiSpans, | ||
| }, | ||
@@ -379,0 +384,0 @@ request: normalizedRequest, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"sentrySpan.js","sources":["../../../src/tracing/sentrySpan.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { getClient, getCurrentScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { createSpanEnvelope } from '../envelope';\nimport {\n SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,\n SEMANTIC_ATTRIBUTE_PROFILE_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { SpanEnvelope } from '../types-hoist/envelope';\nimport type { TransactionEvent } from '../types-hoist/event';\nimport type { SpanLink } from '../types-hoist/link';\nimport type {\n SentrySpanArguments,\n Span,\n SpanAttributes,\n SpanAttributeValue,\n SpanContextData,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types-hoist/span';\nimport type { SpanStatus } from '../types-hoist/spanStatus';\nimport type { TimedEvent } from '../types-hoist/timedEvent';\nimport { debug } from '../utils/debug-logger';\nimport { generateSpanId, generateTraceId } from '../utils/propagationContext';\nimport {\n convertSpanLinksForEnvelope,\n getRootSpan,\n getSimpleStatusMessage,\n getSpanDescendants,\n getStatusMessage,\n getStreamedSpanLinks,\n spanTimeInputToSeconds,\n spanToJSON,\n spanToTransactionTraceContext,\n TRACE_FLAG_NONE,\n TRACE_FLAG_SAMPLED,\n} from '../utils/spanUtils';\nimport { timestampInSeconds } from '../utils/time';\nimport { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanEnd } from './logSpans';\nimport { timedEventsToMeasurements } from './measurement';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport { getCapturedScopesOnSpan } from './utils';\n\nconst MAX_SPAN_COUNT = 1000;\n\n/**\n * Span contains all data about a span\n */\nexport class SentrySpan implements Span {\n protected _traceId: string;\n protected _spanId: string;\n protected _parentSpanId?: string | undefined;\n protected _sampled: boolean | undefined;\n protected _name?: string | undefined;\n protected _attributes: SpanAttributes;\n protected _links?: SpanLink[];\n /** Epoch timestamp in seconds when the span started. */\n protected _startTime: number;\n /** Epoch timestamp in seconds when the span ended. */\n protected _endTime?: number | undefined;\n /** Internal keeper of the status */\n protected _status?: SpanStatus;\n /** The timed events added to this span. */\n protected _events: TimedEvent[];\n\n /** if true, treat span as a standalone span (not part of a transaction) */\n private _isStandaloneSpan?: boolean;\n\n /**\n * You should never call the constructor manually, always use `Sentry.startSpan()`\n * or other span methods.\n * @internal\n * @hideconstructor\n * @hidden\n */\n public constructor(spanContext: SentrySpanArguments = {}) {\n this._traceId = spanContext.traceId || generateTraceId();\n this._spanId = spanContext.spanId || generateSpanId();\n this._startTime = spanContext.startTimestamp || timestampInSeconds();\n this._links = spanContext.links;\n\n this._attributes = {};\n this.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: spanContext.op,\n ...spanContext.attributes,\n });\n\n this._name = spanContext.name;\n\n if (spanContext.parentSpanId) {\n this._parentSpanId = spanContext.parentSpanId;\n }\n // We want to include booleans as well here\n if ('sampled' in spanContext) {\n this._sampled = spanContext.sampled;\n }\n if (spanContext.endTimestamp) {\n this._endTime = spanContext.endTimestamp;\n }\n\n this._events = [];\n\n this._isStandaloneSpan = spanContext.isStandalone;\n\n // If the span is already ended, ensure we finalize the span immediately\n if (this._endTime) {\n this._onSpanEnded();\n }\n }\n\n /** @inheritDoc */\n public addLink(link: SpanLink): this {\n if (this._links) {\n this._links.push(link);\n } else {\n this._links = [link];\n }\n return this;\n }\n\n /** @inheritDoc */\n public addLinks(links: SpanLink[]): this {\n if (this._links) {\n this._links.push(...links);\n } else {\n this._links = links;\n }\n return this;\n }\n\n /**\n * This should generally not be used,\n * but it is needed for being compliant with the OTEL Span interface.\n *\n * @hidden\n * @internal\n */\n public recordException(_exception: unknown, _time?: number | undefined): void {\n // noop\n }\n\n /** @inheritdoc */\n public spanContext(): SpanContextData {\n const { _spanId: spanId, _traceId: traceId, _sampled: sampled } = this;\n return {\n spanId,\n traceId,\n traceFlags: sampled ? TRACE_FLAG_SAMPLED : TRACE_FLAG_NONE,\n };\n }\n\n /** @inheritdoc */\n public setAttribute(key: string, value: SpanAttributeValue | undefined): this {\n if (value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n } else {\n this._attributes[key] = value;\n }\n\n return this;\n }\n\n /** @inheritdoc */\n public setAttributes(attributes: SpanAttributes): this {\n Object.keys(attributes).forEach(key => this.setAttribute(key, attributes[key]));\n return this;\n }\n\n /**\n * This should generally not be used,\n * but we need it for browser tracing where we want to adjust the start time afterwards.\n * USE THIS WITH CAUTION!\n *\n * @hidden\n * @internal\n */\n public updateStartTime(timeInput: SpanTimeInput): void {\n this._startTime = spanTimeInputToSeconds(timeInput);\n }\n\n /**\n * @inheritDoc\n */\n public setStatus(value: SpanStatus): this {\n this._status = value;\n return this;\n }\n\n /**\n * @inheritDoc\n */\n public updateName(name: string): this {\n this._name = name;\n this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'custom');\n return this;\n }\n\n /** @inheritdoc */\n public end(endTimestamp?: SpanTimeInput): void {\n // If already ended, skip\n if (this._endTime) {\n return;\n }\n\n this._endTime = spanTimeInputToSeconds(endTimestamp);\n logSpanEnd(this);\n\n this._onSpanEnded();\n }\n\n /**\n * Get JSON representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToJSON(span)` instead.\n */\n public getSpanJSON(): SpanJSON {\n return {\n data: this._attributes,\n description: this._name,\n op: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n parent_span_id: this._parentSpanId,\n span_id: this._spanId,\n start_timestamp: this._startTime,\n status: getStatusMessage(this._status),\n timestamp: this._endTime,\n trace_id: this._traceId,\n origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n profile_id: this._attributes[SEMANTIC_ATTRIBUTE_PROFILE_ID] as string | undefined,\n exclusive_time: this._attributes[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME] as number | undefined,\n measurements: timedEventsToMeasurements(this._events),\n is_segment: (this._isStandaloneSpan && getRootSpan(this) === this) || undefined,\n segment_id: this._isStandaloneSpan ? getRootSpan(this).spanContext().spanId : undefined,\n links: convertSpanLinksForEnvelope(this._links),\n };\n }\n\n /**\n * Get {@link StreamedSpanJSON} representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToStreamedSpanJSON(span)` instead.\n */\n public getStreamedSpanJSON(): StreamedSpanJSON {\n return {\n name: this._name ?? '',\n span_id: this._spanId,\n trace_id: this._traceId,\n parent_span_id: this._parentSpanId,\n start_timestamp: this._startTime,\n // just in case _endTime is not set, we use the start time (i.e. duration 0)\n end_timestamp: this._endTime ?? this._startTime,\n is_segment: this._isStandaloneSpan || this === getRootSpan(this),\n status: getSimpleStatusMessage(this._status),\n attributes: this._attributes,\n links: getStreamedSpanLinks(this._links),\n };\n }\n\n /** @inheritdoc */\n public isRecording(): boolean {\n return !this._endTime && !!this._sampled;\n }\n\n /**\n * @inheritdoc\n */\n public addEvent(\n name: string,\n attributesOrStartTime?: SpanAttributes | SpanTimeInput,\n startTime?: SpanTimeInput,\n ): this {\n DEBUG_BUILD && debug.log('[Tracing] Adding an event to span:', name);\n\n const time = isSpanTimeInput(attributesOrStartTime) ? attributesOrStartTime : startTime || timestampInSeconds();\n const attributes = isSpanTimeInput(attributesOrStartTime) ? {} : attributesOrStartTime || {};\n\n const event: TimedEvent = {\n name,\n time: spanTimeInputToSeconds(time),\n attributes,\n };\n\n this._events.push(event);\n\n return this;\n }\n\n /**\n * This method should generally not be used,\n * but for now we need a way to publicly check if the `_isStandaloneSpan` flag is set.\n * USE THIS WITH CAUTION!\n * @internal\n * @hidden\n * @experimental\n */\n public isStandaloneSpan(): boolean {\n return !!this._isStandaloneSpan;\n }\n\n /** Emit `spanEnd` when the span is ended. */\n private _onSpanEnded(): void {\n const client = getClient();\n if (client) {\n client.emit('spanEnd', this);\n // Guarding sending standalone v1 spans as v2 streamed spans for now.\n // Otherwise they'd be sent once as v1 spans and again as streamed spans.\n // We'll migrate CLS and LCP spans to streamed spans in a later PR and\n // INP spans in the next major of the SDK. At that point, we can fully remove\n // standalone v1 spans <3\n if (!this._isStandaloneSpan) {\n client.emit('afterSpanEnd', this);\n }\n }\n\n // A segment span is basically the root span of a local span tree.\n // So for now, this is either what we previously refer to as the root span,\n // or a standalone span.\n const isSegmentSpan = this._isStandaloneSpan || this === getRootSpan(this);\n\n if (!isSegmentSpan) {\n return;\n }\n\n // if this is a standalone span, we send it immediately\n if (this._isStandaloneSpan) {\n if (this._sampled) {\n sendSpanEnvelope(createSpanEnvelope([this], client));\n } else {\n DEBUG_BUILD &&\n debug.log('[Tracing] Discarding standalone span because its trace was not chosen to be sampled.');\n if (client) {\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n return;\n } else if (client && hasSpanStreamingEnabled(client)) {\n // TODO (spans): Remove standalone span custom logic in favor of sending simple v2 web vital spans\n client.emit('afterSegmentSpanEnd', this);\n return;\n }\n\n const transactionEvent = this._convertSpanToTransaction();\n if (transactionEvent) {\n const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope();\n scope.captureEvent(transactionEvent);\n }\n }\n\n /**\n * Finish the transaction & prepare the event to send to Sentry.\n */\n private _convertSpanToTransaction(): TransactionEvent | undefined {\n // We can only convert finished spans\n if (!isFullFinishedSpan(spanToJSON(this))) {\n return undefined;\n }\n\n if (!this._name) {\n DEBUG_BUILD && debug.warn('Transaction has no name, falling back to `<unlabeled transaction>`.');\n this._name = '<unlabeled transaction>';\n }\n\n const { scope: capturedSpanScope, isolationScope: capturedSpanIsolationScope } = getCapturedScopesOnSpan(this);\n\n const normalizedRequest = capturedSpanScope?.getScopeData().sdkProcessingMetadata?.normalizedRequest;\n\n if (this._sampled !== true) {\n return undefined;\n }\n\n // The transaction span itself as well as any potential standalone spans should be filtered out\n const finishedSpans = getSpanDescendants(this).filter(span => span !== this && !isStandaloneSpan(span));\n\n const spans = finishedSpans.map(span => spanToJSON(span)).filter(isFullFinishedSpan);\n\n const source = this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n\n // remove internal root span attributes we don't need to send.\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n spans.forEach(span => {\n delete span.data[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n });\n // eslint-enabled-next-line @typescript-eslint/no-dynamic-delete\n\n const transaction: TransactionEvent = {\n contexts: {\n trace: spanToTransactionTraceContext(this),\n },\n spans:\n // spans.sort() mutates the array, but `spans` is already a copy so we can safely do this here\n // we do not use spans anymore after this point\n spans.length > MAX_SPAN_COUNT\n ? spans.sort((a, b) => a.start_timestamp - b.start_timestamp).slice(0, MAX_SPAN_COUNT)\n : spans,\n start_timestamp: this._startTime,\n timestamp: this._endTime,\n transaction: this._name,\n type: 'transaction',\n sdkProcessingMetadata: {\n capturedSpanScope,\n capturedSpanIsolationScope,\n dynamicSamplingContext: getDynamicSamplingContextFromSpan(this),\n },\n request: normalizedRequest,\n ...(source && {\n transaction_info: {\n source,\n },\n }),\n };\n\n const measurements = timedEventsToMeasurements(this._events);\n const hasMeasurements = measurements && Object.keys(measurements).length;\n\n if (hasMeasurements) {\n DEBUG_BUILD &&\n debug.log(\n '[Measurements] Adding measurements to transaction event',\n JSON.stringify(measurements, undefined, 2),\n );\n transaction.measurements = measurements;\n }\n\n return transaction;\n }\n}\n\nfunction isSpanTimeInput(value: undefined | SpanAttributes | SpanTimeInput): value is SpanTimeInput {\n return (value && typeof value === 'number') || value instanceof Date || Array.isArray(value);\n}\n\n// We want to filter out any incomplete SpanJSON objects\nfunction isFullFinishedSpan(input: Partial<SpanJSON>): input is SpanJSON {\n return !!input.start_timestamp && !!input.timestamp && !!input.span_id && !!input.trace_id;\n}\n\n/** `SentrySpan`s can be sent as a standalone span rather than belonging to a transaction */\nfunction isStandaloneSpan(span: Span): boolean {\n return span instanceof SentrySpan && span.isStandaloneSpan();\n}\n\n/**\n * Sends a `SpanEnvelope`.\n *\n * Note: If the envelope's spans are dropped, e.g. via `beforeSendSpan`,\n * the envelope will not be sent either.\n */\nfunction sendSpanEnvelope(envelope: SpanEnvelope): void {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const spanItems = envelope[1];\n if (!spanItems || spanItems.length === 0) {\n client.recordDroppedEvent('before_send', 'span');\n return;\n }\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;AAkDA,MAAM,cAAA,GAAiB,IAAI;;AAE3B;AACA;AACA;AACO,MAAM,YAA2B;;AAQxC;;AAEA;;AAEA;;AAEA;;AAGA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAS,WAAW,CAAC,WAAW,GAAwB,EAAE,EAAE;AAC5D,IAAI,IAAI,CAAC,QAAA,GAAW,WAAW,CAAC,OAAA,IAAW,eAAe,EAAE;AAC5D,IAAI,IAAI,CAAC,OAAA,GAAU,WAAW,CAAC,MAAA,IAAU,cAAc,EAAE;AACzD,IAAI,IAAI,CAAC,UAAA,GAAa,WAAW,CAAC,cAAA,IAAkB,kBAAkB,EAAE;AACxE,IAAI,IAAI,CAAC,MAAA,GAAS,WAAW,CAAC,KAAK;;AAEnC,IAAI,I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AAM,MAAA,GAAS,SAAS,EAAE;AAC5B,EAAE,IAAI,CAAC,MAAM,EAAE;AACf,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,SAAA,GAAY,QAAQ,CAAC,CAAC,CAAC;AAC/B,EAAE,IAAI,CAAC,SAAA,IAAa,SAAS,CAAC,MAAA,KAAW,CAAC,EAAE;AAC5C,IAAI,MAAM,CAAC,kBAAkB,CAAC,aAAa,EAAE,MAAM,CAAC;AACpD,IAAI;AACJ,EAAE;;AAEF;AACA;AACA,EAAE,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC;AAC/B;;;;"} | ||
| {"version":3,"file":"sentrySpan.js","sources":["../../../src/tracing/sentrySpan.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { getClient, getCurrentScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { createSpanEnvelope } from '../envelope';\nimport {\n SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,\n SEMANTIC_ATTRIBUTE_PROFILE_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { SpanEnvelope } from '../types-hoist/envelope';\nimport type { TransactionEvent } from '../types-hoist/event';\nimport type { SpanLink } from '../types-hoist/link';\nimport type {\n SentrySpanArguments,\n Span,\n SpanAttributes,\n SpanAttributeValue,\n SpanContextData,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types-hoist/span';\nimport type { SpanStatus } from '../types-hoist/spanStatus';\nimport type { TimedEvent } from '../types-hoist/timedEvent';\nimport { debug } from '../utils/debug-logger';\nimport { generateSpanId, generateTraceId } from '../utils/propagationContext';\nimport {\n convertSpanLinksForEnvelope,\n getRootSpan,\n getSimpleStatusMessage,\n getSpanDescendants,\n getStatusMessage,\n getStreamedSpanLinks,\n spanTimeInputToSeconds,\n spanToJSON,\n spanToTransactionTraceContext,\n TRACE_FLAG_NONE,\n TRACE_FLAG_SAMPLED,\n} from '../utils/spanUtils';\nimport { timestampInSeconds } from '../utils/time';\nimport { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanEnd } from './logSpans';\nimport { timedEventsToMeasurements } from './measurement';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport { getCapturedScopesOnSpan } from './utils';\n\nconst MAX_SPAN_COUNT = 1000;\n\n/**\n * Span contains all data about a span\n */\nexport class SentrySpan implements Span {\n protected _traceId: string;\n protected _spanId: string;\n protected _parentSpanId?: string | undefined;\n protected _sampled: boolean | undefined;\n protected _name?: string | undefined;\n protected _attributes: SpanAttributes;\n protected _links?: SpanLink[];\n /** Epoch timestamp in seconds when the span started. */\n protected _startTime: number;\n /** Epoch timestamp in seconds when the span ended. */\n protected _endTime?: number | undefined;\n /** Internal keeper of the status */\n protected _status?: SpanStatus;\n /** The timed events added to this span. */\n protected _events: TimedEvent[];\n\n /** if true, treat span as a standalone span (not part of a transaction) */\n private _isStandaloneSpan?: boolean;\n\n /**\n * You should never call the constructor manually, always use `Sentry.startSpan()`\n * or other span methods.\n * @internal\n * @hideconstructor\n * @hidden\n */\n public constructor(spanContext: SentrySpanArguments = {}) {\n this._traceId = spanContext.traceId || generateTraceId();\n this._spanId = spanContext.spanId || generateSpanId();\n this._startTime = spanContext.startTimestamp || timestampInSeconds();\n this._links = spanContext.links;\n\n this._attributes = {};\n this.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: spanContext.op,\n ...spanContext.attributes,\n });\n\n this._name = spanContext.name;\n\n if (spanContext.parentSpanId) {\n this._parentSpanId = spanContext.parentSpanId;\n }\n // We want to include booleans as well here\n if ('sampled' in spanContext) {\n this._sampled = spanContext.sampled;\n }\n if (spanContext.endTimestamp) {\n this._endTime = spanContext.endTimestamp;\n }\n\n this._events = [];\n\n this._isStandaloneSpan = spanContext.isStandalone;\n\n // If the span is already ended, ensure we finalize the span immediately\n if (this._endTime) {\n this._onSpanEnded();\n }\n }\n\n /** @inheritDoc */\n public addLink(link: SpanLink): this {\n if (this._links) {\n this._links.push(link);\n } else {\n this._links = [link];\n }\n return this;\n }\n\n /** @inheritDoc */\n public addLinks(links: SpanLink[]): this {\n if (this._links) {\n this._links.push(...links);\n } else {\n this._links = links;\n }\n return this;\n }\n\n /**\n * This should generally not be used,\n * but it is needed for being compliant with the OTEL Span interface.\n *\n * @hidden\n * @internal\n */\n public recordException(_exception: unknown, _time?: number | undefined): void {\n // noop\n }\n\n /** @inheritdoc */\n public spanContext(): SpanContextData {\n const { _spanId: spanId, _traceId: traceId, _sampled: sampled } = this;\n return {\n spanId,\n traceId,\n traceFlags: sampled ? TRACE_FLAG_SAMPLED : TRACE_FLAG_NONE,\n };\n }\n\n /** @inheritdoc */\n public setAttribute(key: string, value: SpanAttributeValue | undefined): this {\n if (value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n } else {\n this._attributes[key] = value;\n }\n\n return this;\n }\n\n /** @inheritdoc */\n public setAttributes(attributes: SpanAttributes): this {\n Object.keys(attributes).forEach(key => this.setAttribute(key, attributes[key]));\n return this;\n }\n\n /**\n * This should generally not be used,\n * but we need it for browser tracing where we want to adjust the start time afterwards.\n * USE THIS WITH CAUTION!\n *\n * @hidden\n * @internal\n */\n public updateStartTime(timeInput: SpanTimeInput): void {\n this._startTime = spanTimeInputToSeconds(timeInput);\n }\n\n /**\n * @inheritDoc\n */\n public setStatus(value: SpanStatus): this {\n this._status = value;\n return this;\n }\n\n /**\n * @inheritDoc\n */\n public updateName(name: string): this {\n this._name = name;\n this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'custom');\n return this;\n }\n\n /** @inheritdoc */\n public end(endTimestamp?: SpanTimeInput): void {\n // If already ended, skip\n if (this._endTime) {\n return;\n }\n\n this._endTime = spanTimeInputToSeconds(endTimestamp);\n logSpanEnd(this);\n\n this._onSpanEnded();\n }\n\n /**\n * Get JSON representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToJSON(span)` instead.\n */\n public getSpanJSON(): SpanJSON {\n return {\n data: this._attributes,\n description: this._name,\n op: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n parent_span_id: this._parentSpanId,\n span_id: this._spanId,\n start_timestamp: this._startTime,\n status: getStatusMessage(this._status),\n timestamp: this._endTime,\n trace_id: this._traceId,\n origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n profile_id: this._attributes[SEMANTIC_ATTRIBUTE_PROFILE_ID] as string | undefined,\n exclusive_time: this._attributes[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME] as number | undefined,\n measurements: timedEventsToMeasurements(this._events),\n is_segment: (this._isStandaloneSpan && getRootSpan(this) === this) || undefined,\n segment_id: this._isStandaloneSpan ? getRootSpan(this).spanContext().spanId : undefined,\n links: convertSpanLinksForEnvelope(this._links),\n };\n }\n\n /**\n * Get {@link StreamedSpanJSON} representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToStreamedSpanJSON(span)` instead.\n */\n public getStreamedSpanJSON(): StreamedSpanJSON {\n return {\n name: this._name ?? '',\n span_id: this._spanId,\n trace_id: this._traceId,\n parent_span_id: this._parentSpanId,\n start_timestamp: this._startTime,\n // just in case _endTime is not set, we use the start time (i.e. duration 0)\n end_timestamp: this._endTime ?? this._startTime,\n is_segment: this._isStandaloneSpan || this === getRootSpan(this),\n status: getSimpleStatusMessage(this._status),\n attributes: this._attributes,\n links: getStreamedSpanLinks(this._links),\n };\n }\n\n /** @inheritdoc */\n public isRecording(): boolean {\n return !this._endTime && !!this._sampled;\n }\n\n /**\n * @inheritdoc\n */\n public addEvent(\n name: string,\n attributesOrStartTime?: SpanAttributes | SpanTimeInput,\n startTime?: SpanTimeInput,\n ): this {\n DEBUG_BUILD && debug.log('[Tracing] Adding an event to span:', name);\n\n const time = isSpanTimeInput(attributesOrStartTime) ? attributesOrStartTime : startTime || timestampInSeconds();\n const attributes = isSpanTimeInput(attributesOrStartTime) ? {} : attributesOrStartTime || {};\n\n const event: TimedEvent = {\n name,\n time: spanTimeInputToSeconds(time),\n attributes,\n };\n\n this._events.push(event);\n\n return this;\n }\n\n /**\n * This method should generally not be used,\n * but for now we need a way to publicly check if the `_isStandaloneSpan` flag is set.\n * USE THIS WITH CAUTION!\n * @internal\n * @hidden\n * @experimental\n */\n public isStandaloneSpan(): boolean {\n return !!this._isStandaloneSpan;\n }\n\n /** Emit `spanEnd` when the span is ended. */\n private _onSpanEnded(): void {\n const client = getClient();\n if (client) {\n client.emit('spanEnd', this);\n // Guarding sending standalone v1 spans as v2 streamed spans for now.\n // Otherwise they'd be sent once as v1 spans and again as streamed spans.\n // We'll migrate CLS and LCP spans to streamed spans in a later PR and\n // INP spans in the next major of the SDK. At that point, we can fully remove\n // standalone v1 spans <3\n if (!this._isStandaloneSpan) {\n client.emit('afterSpanEnd', this);\n }\n }\n\n // A segment span is basically the root span of a local span tree.\n // So for now, this is either what we previously refer to as the root span,\n // or a standalone span.\n const isSegmentSpan = this._isStandaloneSpan || this === getRootSpan(this);\n\n if (!isSegmentSpan) {\n return;\n }\n\n // if this is a standalone span, we send it immediately\n if (this._isStandaloneSpan) {\n if (this._sampled) {\n sendSpanEnvelope(createSpanEnvelope([this], client));\n } else {\n DEBUG_BUILD &&\n debug.log('[Tracing] Discarding standalone span because its trace was not chosen to be sampled.');\n if (client) {\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n return;\n } else if (client && hasSpanStreamingEnabled(client)) {\n // TODO (spans): Remove standalone span custom logic in favor of sending simple v2 web vital spans\n client.emit('afterSegmentSpanEnd', this);\n return;\n }\n\n const transactionEvent = this._convertSpanToTransaction();\n if (transactionEvent) {\n const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope();\n scope.captureEvent(transactionEvent);\n }\n }\n\n /**\n * Finish the transaction & prepare the event to send to Sentry.\n */\n private _convertSpanToTransaction(): TransactionEvent | undefined {\n // We can only convert finished spans\n if (!isFullFinishedSpan(spanToJSON(this))) {\n return undefined;\n }\n\n if (!this._name) {\n DEBUG_BUILD && debug.warn('Transaction has no name, falling back to `<unlabeled transaction>`.');\n this._name = '<unlabeled transaction>';\n }\n\n const { scope: capturedSpanScope, isolationScope: capturedSpanIsolationScope } = getCapturedScopesOnSpan(this);\n\n const normalizedRequest = capturedSpanScope?.getScopeData().sdkProcessingMetadata?.normalizedRequest;\n\n if (this._sampled !== true) {\n return undefined;\n }\n\n // The transaction span itself as well as any potential standalone spans should be filtered out\n const finishedSpans = getSpanDescendants(this).filter(span => span !== this && !isStandaloneSpan(span));\n\n const spans = finishedSpans.map(span => spanToJSON(span)).filter(isFullFinishedSpan);\n\n const source = this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n\n // remove internal root span attributes we don't need to send.\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n let hasGenAiSpans = false;\n spans.forEach(span => {\n delete span.data[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n if (span.op?.startsWith('gen_ai.')) {\n hasGenAiSpans = true;\n }\n });\n // eslint-enabled-next-line @typescript-eslint/no-dynamic-delete\n\n const transaction: TransactionEvent = {\n contexts: {\n trace: spanToTransactionTraceContext(this),\n },\n spans:\n // spans.sort() mutates the array, but `spans` is already a copy so we can safely do this here\n // we do not use spans anymore after this point\n spans.length > MAX_SPAN_COUNT\n ? spans.sort((a, b) => a.start_timestamp - b.start_timestamp).slice(0, MAX_SPAN_COUNT)\n : spans,\n start_timestamp: this._startTime,\n timestamp: this._endTime,\n transaction: this._name,\n type: 'transaction',\n sdkProcessingMetadata: {\n capturedSpanScope,\n capturedSpanIsolationScope,\n dynamicSamplingContext: getDynamicSamplingContextFromSpan(this),\n hasGenAiSpans,\n },\n request: normalizedRequest,\n ...(source && {\n transaction_info: {\n source,\n },\n }),\n };\n\n const measurements = timedEventsToMeasurements(this._events);\n const hasMeasurements = measurements && Object.keys(measurements).length;\n\n if (hasMeasurements) {\n DEBUG_BUILD &&\n debug.log(\n '[Measurements] Adding measurements to transaction event',\n JSON.stringify(measurements, undefined, 2),\n );\n transaction.measurements = measurements;\n }\n\n return transaction;\n }\n}\n\nfunction isSpanTimeInput(value: undefined | SpanAttributes | SpanTimeInput): value is SpanTimeInput {\n return (value && typeof value === 'number') || value instanceof Date || Array.isArray(value);\n}\n\n// We want to filter out any incomplete SpanJSON objects\nfunction isFullFinishedSpan(input: Partial<SpanJSON>): input is SpanJSON {\n return !!input.start_timestamp && !!input.timestamp && !!input.span_id && !!input.trace_id;\n}\n\n/** `SentrySpan`s can be sent as a standalone span rather than belonging to a transaction */\nfunction isStandaloneSpan(span: Span): boolean {\n return span instanceof SentrySpan && span.isStandaloneSpan();\n}\n\n/**\n * Sends a `SpanEnvelope`.\n *\n * Note: If the envelope's spans are dropped, e.g. via `beforeSendSpan`,\n * the envelope will not be sent either.\n */\nfunction sendSpanEnvelope(envelope: SpanEnvelope): void {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const spanItems = envelope[1];\n if (!spanItems || spanItems.length === 0) {\n client.recordDroppedEvent('before_send', 'span');\n return;\n }\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;AAkDA,MAAM,cAAA,GAAiB,IAAI;;AAE3B;AACA;AACA;AACO,MAAM,YAA2B;;AAQxC;;AAEA;;AA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AAS,eAAe,CAAC,KAAK,EAAsE;AACpG,EAAE,OAAO,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,QAAQ,KAAK,KAAA,YAAiB,QAAQ,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;AAC9F;;AAEA;AACA,SAAS,kBAAkB,CAAC,KAAK,EAAwC;AACzE,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,eAAA,IAAmB,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,OAAA,IAAW,CAAC,CAAC,KAAK,CAAC,QAAQ;AAC5F;;AAEA;AACA,SAAS,gBAAgB,CAAC,IAAI,EAAiB;AAC/C,EAAE,OAAO,gBAAgB,UAAA,IAAc,IAAI,CAAC,gBAAgB,EAAE;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,gBAAgB,CAAC,QAAQ,EAAsB;AACxD,EAAE,MAAM,MAAA,GAAS,SAAS,EAAE;AAC5B,EAAE,IAAI,CAAC,MAAM,EAAE;AACf,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,SAAA,GAAY,QAAQ,CAAC,CAAC,CAAC;AAC/B,EAAE,IAAI,CAAC,SAAA,IAAa,SAAS,CAAC,MAAA,KAAW,CAAC,EAAE;AAC5C,IAAI,MAAM,CAAC,kBAAkB,CAAC,aAAa,EAAE,MAAM,CAAC;AACpD,IAAI;AACJ,EAAE;;AAEF;AACA;AACA,EAAE,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC;AAC/B;;;;"} |
@@ -270,4 +270,9 @@ import { getClient } from '../../currentScopes.js'; | ||
| // Change attributes namespaced with `ai.X` to `vercel.ai.X` | ||
| for (const key of Object.keys(attributes)) { | ||
| // JSON-stringify any array-valued attributes so they survive v2 span serialization. | ||
| // Can be removed once span streaming supports arrays natively. | ||
| if (Array.isArray(attributes[key])) { | ||
| attributes[key] = JSON.stringify(attributes[key]); | ||
| } | ||
| // Change attributes namespaced with `ai.X` to `vercel.ai.X` | ||
| if (key.startsWith('ai.')) { | ||
@@ -274,0 +279,0 @@ renameAttributeKey(attributes, key, `vercel.${key}`); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/vercel-ai/index.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { Client } from '../../client';\nimport { getClient } from '../../currentScopes';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { shouldEnableTruncation } from '../ai/utils';\nimport type { Event } from '../../types-hoist/event';\nimport type { Span, SpanAttributes, SpanAttributeValue, SpanJSON, StreamedSpanJSON } from '../../types-hoist/span';\nimport { spanToJSON } from '../../utils/spanUtils';\nimport {\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_OUTPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_TOOL_CALL_ID_ATTRIBUTE,\n GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE,\n GEN_AI_TOOL_INPUT_ATTRIBUTE,\n GEN_AI_TOOL_NAME_ATTRIBUTE,\n GEN_AI_TOOL_OUTPUT_ATTRIBUTE,\n GEN_AI_TOOL_TYPE_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport { SPAN_TO_OPERATION_NAME, toolCallSpanContextMap, toolDescriptionMap } from './constants';\nimport type { TokenSummary } from './types';\nimport { hasSpanStreamingEnabled } from '../spans/hasSpanStreamingEnabled';\nimport {\n accumulateTokensForParent,\n applyAccumulatedTokens,\n applyToolDescriptionsAndTokens,\n convertAvailableToolsToJsonString,\n requestMessagesFromPrompt,\n} from './utils';\nimport type { OpenAiProviderMetadata, ProviderMetadata } from './vercel-ai-attributes';\nimport {\n AI_MODEL_ID_ATTRIBUTE,\n AI_OPERATION_ID_ATTRIBUTE,\n AI_PROMPT_MESSAGES_ATTRIBUTE,\n AI_PROMPT_TOOLS_ATTRIBUTE,\n AI_RESPONSE_FINISH_REASON_ATTRIBUTE,\n AI_RESPONSE_OBJECT_ATTRIBUTE,\n AI_RESPONSE_PROVIDER_METADATA_ATTRIBUTE,\n AI_RESPONSE_TEXT_ATTRIBUTE,\n AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n AI_SCHEMA_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TOOL_CALL_ARGS_ATTRIBUTE,\n AI_TOOL_CALL_ID_ATTRIBUTE,\n AI_TOOL_CALL_NAME_ATTRIBUTE,\n AI_TOOL_CALL_RESULT_ATTRIBUTE,\n AI_USAGE_CACHED_INPUT_TOKENS_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n AI_USAGE_TOKENS_ATTRIBUTE,\n AI_VALUES_ATTRIBUTE,\n OPERATION_NAME_ATTRIBUTE,\n} from './vercel-ai-attributes';\n\n/**\n * Post-process spans emitted by the Vercel AI SDK.\n * This is supposed to be used in `client.on('spanStart', ...)\n */\nfunction onVercelAiSpanStart(span: Span): void {\n const { data: attributes, description: name } = spanToJSON(span);\n\n if (!name) {\n return;\n }\n\n // Tool call spans\n // https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n if (attributes[AI_TOOL_CALL_NAME_ATTRIBUTE] && attributes[AI_TOOL_CALL_ID_ATTRIBUTE] && name === 'ai.toolCall') {\n processToolCallSpan(span, attributes);\n return;\n }\n\n // V6+ Check if this is a Vercel AI span by checking if the operation ID attribute is present.\n // V5+ Check if this is a Vercel AI span by name pattern.\n if (!attributes[AI_OPERATION_ID_ATTRIBUTE] && !name.startsWith('ai.')) {\n return;\n }\n\n const client = getClient();\n const integration = client?.getIntegrationByName('VercelAI') as\n | { options?: { enableTruncation?: boolean } }\n | undefined;\n const enableTruncation = shouldEnableTruncation(integration?.options?.enableTruncation);\n\n processGenerateSpan(span, name, attributes, enableTruncation);\n}\n\nfunction vercelAiEventProcessor(event: Event): Event {\n if (event.type === 'transaction' && event.spans) {\n // Map to accumulate token data by parent span ID\n const tokenAccumulator: Map<string, TokenSummary> = new Map();\n\n // First pass: process all spans and accumulate token data\n for (const span of event.spans) {\n processEndedVercelAiSpan(span);\n\n // Accumulate token data for parent spans\n accumulateTokensForParent(span, tokenAccumulator);\n }\n\n // Second pass: apply tool descriptions and accumulated tokens\n applyToolDescriptionsAndTokens(event.spans, tokenAccumulator);\n\n // Also apply to root when it is the invoke_agent pipeline\n const trace = event.contexts?.trace;\n if (trace?.op === 'gen_ai.invoke_agent') {\n applyAccumulatedTokens(trace, tokenAccumulator);\n }\n }\n\n return event;\n}\n\n/**\n * Tool call structure from Vercel AI SDK\n * Note: V5/V6 use 'input' for arguments, V4 and earlier use 'args'\n */\ninterface VercelToolCall {\n toolCallId: string;\n toolName: string;\n input?: Record<string, unknown> | string; // V5/V6\n args?: string; // V4 and earlier\n}\n\n/**\n * Normalize finish reason to match OpenTelemetry semantic conventions.\n * Valid values: \"stop\", \"length\", \"content_filter\", \"tool_call\", \"error\"\n *\n * Vercel AI SDK uses \"tool-calls\" (plural, with hyphen) which we map to \"tool_call\".\n */\nfunction normalizeFinishReason(finishReason: unknown): string {\n if (typeof finishReason !== 'string') {\n return 'stop';\n }\n\n // Map Vercel AI SDK finish reasons to OpenTelemetry semantic convention values\n switch (finishReason) {\n case 'tool-calls':\n return 'tool_call';\n case 'stop':\n case 'length':\n case 'content_filter':\n case 'error':\n return finishReason;\n default:\n // For unknown values, return as-is (schema allows arbitrary strings)\n return finishReason;\n }\n}\n\n/**\n * Build gen_ai.output.messages from ai.response.text and/or ai.response.toolCalls\n *\n * Format follows OpenTelemetry semantic conventions:\n * [{\"role\": \"assistant\", \"parts\": [...], \"finish_reason\": \"stop\"}]\n *\n * Parts can be:\n * - {\"type\": \"text\", \"content\": \"...\"}\n * - {\"type\": \"tool_call\", \"id\": \"...\", \"name\": \"...\", \"arguments\": \"...\"}\n */\nfunction buildOutputMessages(attributes: Record<string, unknown>): void {\n const responseText = attributes[AI_RESPONSE_TEXT_ATTRIBUTE];\n const responseToolCalls = attributes[AI_RESPONSE_TOOL_CALLS_ATTRIBUTE];\n const finishReason = attributes[AI_RESPONSE_FINISH_REASON_ATTRIBUTE];\n\n // Skip if neither text nor tool calls are present\n if (responseText == null && responseToolCalls == null) {\n return;\n }\n\n const parts: Array<Record<string, unknown>> = [];\n\n // Add text part if present\n if (typeof responseText === 'string' && responseText.length > 0) {\n parts.push({\n type: 'text',\n content: responseText,\n });\n }\n\n // Add tool call parts if present\n if (responseToolCalls != null) {\n try {\n // Tool calls can be a string (JSON) or already parsed array\n const toolCalls: VercelToolCall[] =\n typeof responseToolCalls === 'string' ? JSON.parse(responseToolCalls) : responseToolCalls;\n\n if (Array.isArray(toolCalls)) {\n for (const toolCall of toolCalls) {\n // V5/V6 use 'input', V4 and earlier use 'args'\n const args = toolCall.input ?? toolCall.args;\n parts.push({\n type: 'tool_call',\n id: toolCall.toolCallId,\n name: toolCall.toolName,\n // Handle undefined args: JSON.stringify(undefined) returns undefined, not a string,\n // which would cause the property to be omitted from the final JSON output\n arguments: typeof args === 'string' ? args : JSON.stringify(args ?? {}),\n });\n }\n // Only delete tool calls attribute if we successfully processed them\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[AI_RESPONSE_TOOL_CALLS_ATTRIBUTE];\n }\n } catch {\n // Ignore parsing errors - tool calls attribute is preserved\n }\n }\n\n // Only set output messages and delete text attribute if we have parts\n if (parts.length > 0) {\n const outputMessage = {\n role: 'assistant',\n parts,\n finish_reason: normalizeFinishReason(finishReason),\n };\n\n attributes[GEN_AI_OUTPUT_MESSAGES_ATTRIBUTE] = JSON.stringify([outputMessage]);\n\n // Remove the text attribute since it's now captured in gen_ai.output.messages\n // Note: tool calls attribute is deleted above only if successfully parsed\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[AI_RESPONSE_TEXT_ATTRIBUTE];\n }\n}\n\n/**\n * Post-process spans emitted by the Vercel AI SDK.\n */\n/**\n * Rename and normalize Vercel AI SDK attributes to OpenTelemetry semantic conventions.\n * This is the shared attribute processing logic used by both the legacy event processor\n * path (SpanJSON) and the streamed span path (StreamedSpanJSON).\n */\nexport function processVercelAiSpanAttributes(attributes: Record<string, unknown>): void {\n renameAttributeKey(attributes, AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE, GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE);\n renameAttributeKey(attributes, AI_USAGE_PROMPT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE);\n renameAttributeKey(attributes, AI_USAGE_CACHED_INPUT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE);\n\n // Parent spans (ai.streamText, ai.streamObject, etc.) use inputTokens/outputTokens instead of promptTokens/completionTokens\n renameAttributeKey(attributes, 'ai.usage.inputTokens', GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE);\n renameAttributeKey(attributes, 'ai.usage.outputTokens', GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE);\n\n // Embedding spans use ai.usage.tokens instead of promptTokens/completionTokens\n renameAttributeKey(attributes, AI_USAGE_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE);\n\n // AI SDK uses avgOutputTokensPerSecond, map to our expected attribute name\n renameAttributeKey(attributes, 'ai.response.avgOutputTokensPerSecond', 'ai.response.avgCompletionTokensPerSecond');\n\n // Input tokens is the sum of prompt tokens and cached input tokens\n if (\n typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] === 'number' &&\n typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE] === 'number'\n ) {\n attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] =\n attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] + attributes[GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE];\n }\n\n // Compute total tokens from input + output (embeddings may only have input tokens)\n if (typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] === 'number') {\n const outputTokens =\n typeof attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] === 'number'\n ? attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]\n : 0;\n attributes[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE] = outputTokens + attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE];\n }\n\n // Convert the available tools array to a JSON string\n if (attributes[AI_PROMPT_TOOLS_ATTRIBUTE] && Array.isArray(attributes[AI_PROMPT_TOOLS_ATTRIBUTE])) {\n attributes[AI_PROMPT_TOOLS_ATTRIBUTE] = convertAvailableToolsToJsonString(\n attributes[AI_PROMPT_TOOLS_ATTRIBUTE] as unknown[],\n );\n }\n\n // Rename AI SDK attributes to standardized gen_ai attributes\n // Map operation.name to OpenTelemetry semantic convention values\n if (attributes[OPERATION_NAME_ATTRIBUTE]) {\n // V6+ sets ai.operationId to the bare operation (e.g. \"ai.streamText\") while\n // operation.name appends functionId (e.g. \"ai.streamText myAgent\").\n // When ai.operationId is present, use it for correct mapping.\n const rawOperationName = attributes[AI_OPERATION_ID_ATTRIBUTE]\n ? (attributes[AI_OPERATION_ID_ATTRIBUTE] as string)\n : (attributes[OPERATION_NAME_ATTRIBUTE] as string);\n const operationName = SPAN_TO_OPERATION_NAME.get(rawOperationName) ?? rawOperationName;\n attributes[GEN_AI_OPERATION_NAME_ATTRIBUTE] = operationName;\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[OPERATION_NAME_ATTRIBUTE];\n }\n renameAttributeKey(attributes, AI_PROMPT_MESSAGES_ATTRIBUTE, GEN_AI_INPUT_MESSAGES_ATTRIBUTE);\n\n // Build gen_ai.output.messages from response text and/or tool calls\n // Note: buildOutputMessages also removes the source attributes when output is successfully generated\n buildOutputMessages(attributes);\n\n renameAttributeKey(attributes, AI_RESPONSE_OBJECT_ATTRIBUTE, 'gen_ai.response.object');\n renameAttributeKey(attributes, AI_PROMPT_TOOLS_ATTRIBUTE, 'gen_ai.request.available_tools');\n\n renameAttributeKey(attributes, AI_TOOL_CALL_ARGS_ATTRIBUTE, GEN_AI_TOOL_INPUT_ATTRIBUTE);\n renameAttributeKey(attributes, AI_TOOL_CALL_RESULT_ATTRIBUTE, GEN_AI_TOOL_OUTPUT_ATTRIBUTE);\n\n renameAttributeKey(attributes, AI_SCHEMA_ATTRIBUTE, 'gen_ai.request.schema');\n renameAttributeKey(attributes, AI_MODEL_ID_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE);\n\n // Map embedding input: ai.values → gen_ai.embeddings.input\n // Vercel AI SDK JSON-stringifies each value individually, so we parse each element back.\n // Single embed gets unwrapped to a plain value; batch embedMany stays as a JSON array.\n if (Array.isArray(attributes[AI_VALUES_ATTRIBUTE])) {\n const parsed = (attributes[AI_VALUES_ATTRIBUTE] as string[]).map(v => {\n try {\n return JSON.parse(v);\n } catch {\n return v;\n }\n });\n attributes[GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE] = parsed.length === 1 ? parsed[0] : JSON.stringify(parsed);\n }\n\n addProviderMetadataToAttributes(attributes);\n\n // Change attributes namespaced with `ai.X` to `vercel.ai.X`\n for (const key of Object.keys(attributes)) {\n if (key.startsWith('ai.')) {\n renameAttributeKey(attributes, key, `vercel.${key}`);\n }\n }\n}\n\nfunction processEndedVercelAiSpan(span: SpanJSON): void {\n const { data: attributes, origin } = span;\n\n if (origin !== 'auto.vercelai.otel') {\n return;\n }\n\n // The Vercel AI SDK sets span status to raw error message strings.\n // Any such value should be normalized to a SpanStatusType value. We pick internal_error as it is the most generic.\n if (span.status && span.status !== 'ok') {\n span.status = 'internal_error';\n }\n\n processVercelAiSpanAttributes(attributes);\n}\n\nfunction processVercelAiStreamedSpan(span: StreamedSpanJSON): void {\n const attributes = span.attributes;\n if (attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] !== 'auto.vercelai.otel') {\n return;\n }\n\n processVercelAiSpanAttributes(attributes);\n\n // Look up tool description from the toolDescriptionMap for execute_tool spans\n if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] === 'gen_ai.execute_tool' && span.parent_span_id) {\n const descriptions = toolDescriptionMap.get(span.parent_span_id);\n\n if (descriptions) {\n const toolName = attributes[GEN_AI_TOOL_NAME_ATTRIBUTE];\n if (typeof toolName === 'string') {\n const desc = descriptions.get(toolName);\n if (desc) {\n attributes[GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE] = desc;\n }\n }\n }\n }\n\n // Clean up tool descriptions when the parent span ends\n toolDescriptionMap.delete(span.span_id);\n}\n\n/**\n * Renames an attribute key in the provided attributes object if the old key exists.\n * This function safely handles null and undefined values.\n */\nfunction renameAttributeKey(attributes: Record<string, unknown>, oldKey: string, newKey: string): void {\n if (attributes[oldKey] != null) {\n attributes[newKey] = attributes[oldKey];\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[oldKey];\n }\n}\n\nfunction processToolCallSpan(span: Span, attributes: SpanAttributes): void {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.vercelai.otel');\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.execute_tool');\n span.setAttribute(GEN_AI_OPERATION_NAME_ATTRIBUTE, 'execute_tool');\n renameAttributeKey(attributes, AI_TOOL_CALL_NAME_ATTRIBUTE, GEN_AI_TOOL_NAME_ATTRIBUTE);\n renameAttributeKey(attributes, AI_TOOL_CALL_ID_ATTRIBUTE, GEN_AI_TOOL_CALL_ID_ATTRIBUTE);\n\n // Store the span context in our global map using the tool call ID.\n // This allows us to capture tool errors and link them to the correct span\n // without retaining the full Span object in memory.\n const toolCallId = attributes[GEN_AI_TOOL_CALL_ID_ATTRIBUTE];\n\n if (typeof toolCallId === 'string') {\n toolCallSpanContextMap.set(toolCallId, span.spanContext());\n }\n\n // https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-tool-type\n if (!attributes[GEN_AI_TOOL_TYPE_ATTRIBUTE]) {\n span.setAttribute(GEN_AI_TOOL_TYPE_ATTRIBUTE, 'function');\n }\n const toolName = attributes[GEN_AI_TOOL_NAME_ATTRIBUTE];\n if (toolName) {\n span.updateName(`execute_tool ${toolName}`);\n }\n}\n\nfunction processGenerateSpan(span: Span, name: string, attributes: SpanAttributes, enableTruncation: boolean): void {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.vercelai.otel');\n\n const nameWthoutAi = name.replace('ai.', '');\n span.setAttribute('ai.pipeline.name', nameWthoutAi);\n span.updateName(nameWthoutAi);\n\n const functionId = attributes[AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE];\n if (functionId && typeof functionId === 'string') {\n span.setAttribute('gen_ai.function_id', functionId);\n }\n\n requestMessagesFromPrompt(span, attributes, enableTruncation);\n\n if (attributes[AI_MODEL_ID_ATTRIBUTE] && !attributes[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]) {\n span.setAttribute(GEN_AI_RESPONSE_MODEL_ATTRIBUTE, attributes[AI_MODEL_ID_ATTRIBUTE]);\n }\n span.setAttribute('ai.streaming', name.includes('stream'));\n\n // Set the op based on the operation name registry\n const operationName = SPAN_TO_OPERATION_NAME.get(name);\n if (operationName) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, `gen_ai.${operationName}`);\n } else if (name.startsWith('ai.stream')) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.run');\n }\n\n // For invoke_agent pipeline spans, use 'invoke_agent' as the description\n // to be consistent with other AI integrations (e.g. LangGraph)\n if (operationName === 'invoke_agent') {\n if (functionId && typeof functionId === 'string') {\n span.updateName(`invoke_agent ${functionId}`);\n } else {\n span.updateName('invoke_agent');\n }\n return;\n }\n\n const modelId = attributes[AI_MODEL_ID_ATTRIBUTE];\n if (modelId && operationName) {\n span.updateName(`${operationName} ${modelId}`);\n }\n\n // Store tool descriptions in the toolDescriptionMap so processSpan can apply them to execute_tool spans.\n // This is only needed for span streaming (transaction path handles this separately)\n const client = getClient();\n if (\n client &&\n hasSpanStreamingEnabled(client) &&\n attributes[AI_PROMPT_TOOLS_ATTRIBUTE] &&\n Array.isArray(attributes[AI_PROMPT_TOOLS_ATTRIBUTE])\n ) {\n const descriptions = new Map<string, string>();\n\n // parse tool names and descriptions from tool string array\n for (const toolStr of attributes[AI_PROMPT_TOOLS_ATTRIBUTE] as unknown[]) {\n try {\n const parsed = (typeof toolStr === 'string' ? JSON.parse(toolStr) : toolStr) as {\n name?: string;\n description?: string;\n };\n if (parsed?.name && parsed?.description) {\n descriptions.set(parsed.name, parsed.description);\n }\n } catch {\n // ignore parse errors\n }\n }\n if (descriptions.size > 0) {\n // Tool call spans are siblings of doGenerate (both children of invoke_agent),\n // so we key by the parent span ID (the invoke_agent span).\n const parentSpanId = spanToJSON(span).parent_span_id;\n if (parentSpanId) {\n toolDescriptionMap.set(parentSpanId, descriptions);\n }\n }\n }\n}\n\n/**\n * Add event processors to the given client to process Vercel AI spans.\n */\nexport function addVercelAiProcessors(client: Client): void {\n client.on('spanStart', onVercelAiSpanStart);\n // Note: We cannot do this on `spanEnd`, because the span cannot be mutated anymore at this point\n client.addEventProcessor(Object.assign(vercelAiEventProcessor, { id: 'VercelAiEventProcessor' }));\n client.on('processSpan', span => {\n processVercelAiStreamedSpan(span);\n });\n}\n\nfunction addProviderMetadataToAttributes(attributes: Record<string, unknown>): void {\n const providerMetadata = attributes[AI_RESPONSE_PROVIDER_METADATA_ATTRIBUTE] as string | undefined;\n if (providerMetadata) {\n try {\n const providerMetadataObject = JSON.parse(providerMetadata) as ProviderMetadata;\n\n // Handle OpenAI metadata (v5 uses 'openai', v6 Azure Responses API uses 'azure')\n const openaiMetadata: OpenAiProviderMetadata | undefined =\n providerMetadataObject.openai ?? providerMetadataObject.azure;\n if (openaiMetadata) {\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n openaiMetadata.cachedPromptTokens,\n );\n setAttributeIfDefined(attributes, 'gen_ai.usage.output_tokens.reasoning', openaiMetadata.reasoningTokens);\n setAttributeIfDefined(\n attributes,\n 'gen_ai.usage.output_tokens.prediction_accepted',\n openaiMetadata.acceptedPredictionTokens,\n );\n setAttributeIfDefined(\n attributes,\n 'gen_ai.usage.output_tokens.prediction_rejected',\n openaiMetadata.rejectedPredictionTokens,\n );\n if (!attributes['gen_ai.conversation.id']) {\n setAttributeIfDefined(attributes, 'gen_ai.conversation.id', openaiMetadata.responseId);\n }\n }\n\n if (providerMetadataObject.anthropic) {\n const cachedInputTokens =\n providerMetadataObject.anthropic.usage?.cache_read_input_tokens ??\n providerMetadataObject.anthropic.cacheReadInputTokens;\n setAttributeIfDefined(attributes, GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE, cachedInputTokens);\n\n const cacheWriteInputTokens =\n providerMetadataObject.anthropic.usage?.cache_creation_input_tokens ??\n providerMetadataObject.anthropic.cacheCreationInputTokens;\n setAttributeIfDefined(attributes, GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE_ATTRIBUTE, cacheWriteInputTokens);\n }\n\n if (providerMetadataObject.bedrock?.usage) {\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n providerMetadataObject.bedrock.usage.cacheReadInputTokens,\n );\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE_ATTRIBUTE,\n providerMetadataObject.bedrock.usage.cacheWriteInputTokens,\n );\n }\n\n if (providerMetadataObject.deepseek) {\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n providerMetadataObject.deepseek.promptCacheHitTokens,\n );\n setAttributeIfDefined(\n attributes,\n 'gen_ai.usage.input_tokens.cache_miss',\n providerMetadataObject.deepseek.promptCacheMissTokens,\n );\n }\n } catch {\n // Ignore\n }\n }\n}\n\n/**\n * Sets an attribute only if the value is not null or undefined.\n */\nfunction setAttributeIfDefined(\n attributes: Record<string, unknown>,\n key: string,\n value: SpanAttributeValue | undefined,\n): void {\n if (value != null) {\n attributes[key] = value;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AA8DA;AACA;AACA;AACA;AACA,SAAS,mBAAmB,CAAC,IAAI,EAAc;AAC/C,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,IAAA,EAAK,GAAI,UAAU,CAAC,IAAI,CAAC;;AAElE,EAAE,IAAI,CAAC,IAAI,EAAE;AACb,IAAI;AACJ,EAAE;;AAEF;AACA;AACA,EAAE,IAAI,UAAU,CAAC,2BAA2B,CAAA,IAAK,UAAU,CAAC,yBAAyB,CAAA,IAAK,IAAA,KAAS,aAAa,EAAE;AAClH,IAAI,mBAAmB,CAAC,IAAI,EAAE,UAAU,CAAC;AACzC,IAAI;AACJ,EAAE;;AAEF;AACA;AACA,EAAE,IAAI,CAAC,UAAU,CAAC,yBAAyB,CAAA,IAAK,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;AACzE,IAAI;AACJ,EAAE;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A,KAAA;AACA,EAAA;AACA;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/vercel-ai/index.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { Client } from '../../client';\nimport { getClient } from '../../currentScopes';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { shouldEnableTruncation } from '../ai/utils';\nimport type { Event } from '../../types-hoist/event';\nimport type { Span, SpanAttributes, SpanAttributeValue, SpanJSON, StreamedSpanJSON } from '../../types-hoist/span';\nimport { spanToJSON } from '../../utils/spanUtils';\nimport {\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_OUTPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_TOOL_CALL_ID_ATTRIBUTE,\n GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE,\n GEN_AI_TOOL_INPUT_ATTRIBUTE,\n GEN_AI_TOOL_NAME_ATTRIBUTE,\n GEN_AI_TOOL_OUTPUT_ATTRIBUTE,\n GEN_AI_TOOL_TYPE_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport { SPAN_TO_OPERATION_NAME, toolCallSpanContextMap, toolDescriptionMap } from './constants';\nimport type { TokenSummary } from './types';\nimport { hasSpanStreamingEnabled } from '../spans/hasSpanStreamingEnabled';\nimport {\n accumulateTokensForParent,\n applyAccumulatedTokens,\n applyToolDescriptionsAndTokens,\n convertAvailableToolsToJsonString,\n requestMessagesFromPrompt,\n} from './utils';\nimport type { OpenAiProviderMetadata, ProviderMetadata } from './vercel-ai-attributes';\nimport {\n AI_MODEL_ID_ATTRIBUTE,\n AI_OPERATION_ID_ATTRIBUTE,\n AI_PROMPT_MESSAGES_ATTRIBUTE,\n AI_PROMPT_TOOLS_ATTRIBUTE,\n AI_RESPONSE_FINISH_REASON_ATTRIBUTE,\n AI_RESPONSE_OBJECT_ATTRIBUTE,\n AI_RESPONSE_PROVIDER_METADATA_ATTRIBUTE,\n AI_RESPONSE_TEXT_ATTRIBUTE,\n AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n AI_SCHEMA_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TOOL_CALL_ARGS_ATTRIBUTE,\n AI_TOOL_CALL_ID_ATTRIBUTE,\n AI_TOOL_CALL_NAME_ATTRIBUTE,\n AI_TOOL_CALL_RESULT_ATTRIBUTE,\n AI_USAGE_CACHED_INPUT_TOKENS_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n AI_USAGE_TOKENS_ATTRIBUTE,\n AI_VALUES_ATTRIBUTE,\n OPERATION_NAME_ATTRIBUTE,\n} from './vercel-ai-attributes';\n\n/**\n * Post-process spans emitted by the Vercel AI SDK.\n * This is supposed to be used in `client.on('spanStart', ...)\n */\nfunction onVercelAiSpanStart(span: Span): void {\n const { data: attributes, description: name } = spanToJSON(span);\n\n if (!name) {\n return;\n }\n\n // Tool call spans\n // https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n if (attributes[AI_TOOL_CALL_NAME_ATTRIBUTE] && attributes[AI_TOOL_CALL_ID_ATTRIBUTE] && name === 'ai.toolCall') {\n processToolCallSpan(span, attributes);\n return;\n }\n\n // V6+ Check if this is a Vercel AI span by checking if the operation ID attribute is present.\n // V5+ Check if this is a Vercel AI span by name pattern.\n if (!attributes[AI_OPERATION_ID_ATTRIBUTE] && !name.startsWith('ai.')) {\n return;\n }\n\n const client = getClient();\n const integration = client?.getIntegrationByName('VercelAI') as\n | { options?: { enableTruncation?: boolean } }\n | undefined;\n const enableTruncation = shouldEnableTruncation(integration?.options?.enableTruncation);\n\n processGenerateSpan(span, name, attributes, enableTruncation);\n}\n\nfunction vercelAiEventProcessor(event: Event): Event {\n if (event.type === 'transaction' && event.spans) {\n // Map to accumulate token data by parent span ID\n const tokenAccumulator: Map<string, TokenSummary> = new Map();\n\n // First pass: process all spans and accumulate token data\n for (const span of event.spans) {\n processEndedVercelAiSpan(span);\n\n // Accumulate token data for parent spans\n accumulateTokensForParent(span, tokenAccumulator);\n }\n\n // Second pass: apply tool descriptions and accumulated tokens\n applyToolDescriptionsAndTokens(event.spans, tokenAccumulator);\n\n // Also apply to root when it is the invoke_agent pipeline\n const trace = event.contexts?.trace;\n if (trace?.op === 'gen_ai.invoke_agent') {\n applyAccumulatedTokens(trace, tokenAccumulator);\n }\n }\n\n return event;\n}\n\n/**\n * Tool call structure from Vercel AI SDK\n * Note: V5/V6 use 'input' for arguments, V4 and earlier use 'args'\n */\ninterface VercelToolCall {\n toolCallId: string;\n toolName: string;\n input?: Record<string, unknown> | string; // V5/V6\n args?: string; // V4 and earlier\n}\n\n/**\n * Normalize finish reason to match OpenTelemetry semantic conventions.\n * Valid values: \"stop\", \"length\", \"content_filter\", \"tool_call\", \"error\"\n *\n * Vercel AI SDK uses \"tool-calls\" (plural, with hyphen) which we map to \"tool_call\".\n */\nfunction normalizeFinishReason(finishReason: unknown): string {\n if (typeof finishReason !== 'string') {\n return 'stop';\n }\n\n // Map Vercel AI SDK finish reasons to OpenTelemetry semantic convention values\n switch (finishReason) {\n case 'tool-calls':\n return 'tool_call';\n case 'stop':\n case 'length':\n case 'content_filter':\n case 'error':\n return finishReason;\n default:\n // For unknown values, return as-is (schema allows arbitrary strings)\n return finishReason;\n }\n}\n\n/**\n * Build gen_ai.output.messages from ai.response.text and/or ai.response.toolCalls\n *\n * Format follows OpenTelemetry semantic conventions:\n * [{\"role\": \"assistant\", \"parts\": [...], \"finish_reason\": \"stop\"}]\n *\n * Parts can be:\n * - {\"type\": \"text\", \"content\": \"...\"}\n * - {\"type\": \"tool_call\", \"id\": \"...\", \"name\": \"...\", \"arguments\": \"...\"}\n */\nfunction buildOutputMessages(attributes: Record<string, unknown>): void {\n const responseText = attributes[AI_RESPONSE_TEXT_ATTRIBUTE];\n const responseToolCalls = attributes[AI_RESPONSE_TOOL_CALLS_ATTRIBUTE];\n const finishReason = attributes[AI_RESPONSE_FINISH_REASON_ATTRIBUTE];\n\n // Skip if neither text nor tool calls are present\n if (responseText == null && responseToolCalls == null) {\n return;\n }\n\n const parts: Array<Record<string, unknown>> = [];\n\n // Add text part if present\n if (typeof responseText === 'string' && responseText.length > 0) {\n parts.push({\n type: 'text',\n content: responseText,\n });\n }\n\n // Add tool call parts if present\n if (responseToolCalls != null) {\n try {\n // Tool calls can be a string (JSON) or already parsed array\n const toolCalls: VercelToolCall[] =\n typeof responseToolCalls === 'string' ? JSON.parse(responseToolCalls) : responseToolCalls;\n\n if (Array.isArray(toolCalls)) {\n for (const toolCall of toolCalls) {\n // V5/V6 use 'input', V4 and earlier use 'args'\n const args = toolCall.input ?? toolCall.args;\n parts.push({\n type: 'tool_call',\n id: toolCall.toolCallId,\n name: toolCall.toolName,\n // Handle undefined args: JSON.stringify(undefined) returns undefined, not a string,\n // which would cause the property to be omitted from the final JSON output\n arguments: typeof args === 'string' ? args : JSON.stringify(args ?? {}),\n });\n }\n // Only delete tool calls attribute if we successfully processed them\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[AI_RESPONSE_TOOL_CALLS_ATTRIBUTE];\n }\n } catch {\n // Ignore parsing errors - tool calls attribute is preserved\n }\n }\n\n // Only set output messages and delete text attribute if we have parts\n if (parts.length > 0) {\n const outputMessage = {\n role: 'assistant',\n parts,\n finish_reason: normalizeFinishReason(finishReason),\n };\n\n attributes[GEN_AI_OUTPUT_MESSAGES_ATTRIBUTE] = JSON.stringify([outputMessage]);\n\n // Remove the text attribute since it's now captured in gen_ai.output.messages\n // Note: tool calls attribute is deleted above only if successfully parsed\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[AI_RESPONSE_TEXT_ATTRIBUTE];\n }\n}\n\n/**\n * Post-process spans emitted by the Vercel AI SDK.\n */\n/**\n * Rename and normalize Vercel AI SDK attributes to OpenTelemetry semantic conventions.\n * This is the shared attribute processing logic used by both the legacy event processor\n * path (SpanJSON) and the streamed span path (StreamedSpanJSON).\n */\nexport function processVercelAiSpanAttributes(attributes: Record<string, unknown>): void {\n renameAttributeKey(attributes, AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE, GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE);\n renameAttributeKey(attributes, AI_USAGE_PROMPT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE);\n renameAttributeKey(attributes, AI_USAGE_CACHED_INPUT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE);\n\n // Parent spans (ai.streamText, ai.streamObject, etc.) use inputTokens/outputTokens instead of promptTokens/completionTokens\n renameAttributeKey(attributes, 'ai.usage.inputTokens', GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE);\n renameAttributeKey(attributes, 'ai.usage.outputTokens', GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE);\n\n // Embedding spans use ai.usage.tokens instead of promptTokens/completionTokens\n renameAttributeKey(attributes, AI_USAGE_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE);\n\n // AI SDK uses avgOutputTokensPerSecond, map to our expected attribute name\n renameAttributeKey(attributes, 'ai.response.avgOutputTokensPerSecond', 'ai.response.avgCompletionTokensPerSecond');\n\n // Input tokens is the sum of prompt tokens and cached input tokens\n if (\n typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] === 'number' &&\n typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE] === 'number'\n ) {\n attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] =\n attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] + attributes[GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE];\n }\n\n // Compute total tokens from input + output (embeddings may only have input tokens)\n if (typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] === 'number') {\n const outputTokens =\n typeof attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] === 'number'\n ? attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]\n : 0;\n attributes[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE] = outputTokens + attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE];\n }\n\n // Convert the available tools array to a JSON string\n if (attributes[AI_PROMPT_TOOLS_ATTRIBUTE] && Array.isArray(attributes[AI_PROMPT_TOOLS_ATTRIBUTE])) {\n attributes[AI_PROMPT_TOOLS_ATTRIBUTE] = convertAvailableToolsToJsonString(\n attributes[AI_PROMPT_TOOLS_ATTRIBUTE] as unknown[],\n );\n }\n\n // Rename AI SDK attributes to standardized gen_ai attributes\n // Map operation.name to OpenTelemetry semantic convention values\n if (attributes[OPERATION_NAME_ATTRIBUTE]) {\n // V6+ sets ai.operationId to the bare operation (e.g. \"ai.streamText\") while\n // operation.name appends functionId (e.g. \"ai.streamText myAgent\").\n // When ai.operationId is present, use it for correct mapping.\n const rawOperationName = attributes[AI_OPERATION_ID_ATTRIBUTE]\n ? (attributes[AI_OPERATION_ID_ATTRIBUTE] as string)\n : (attributes[OPERATION_NAME_ATTRIBUTE] as string);\n const operationName = SPAN_TO_OPERATION_NAME.get(rawOperationName) ?? rawOperationName;\n attributes[GEN_AI_OPERATION_NAME_ATTRIBUTE] = operationName;\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[OPERATION_NAME_ATTRIBUTE];\n }\n renameAttributeKey(attributes, AI_PROMPT_MESSAGES_ATTRIBUTE, GEN_AI_INPUT_MESSAGES_ATTRIBUTE);\n\n // Build gen_ai.output.messages from response text and/or tool calls\n // Note: buildOutputMessages also removes the source attributes when output is successfully generated\n buildOutputMessages(attributes);\n\n renameAttributeKey(attributes, AI_RESPONSE_OBJECT_ATTRIBUTE, 'gen_ai.response.object');\n renameAttributeKey(attributes, AI_PROMPT_TOOLS_ATTRIBUTE, 'gen_ai.request.available_tools');\n\n renameAttributeKey(attributes, AI_TOOL_CALL_ARGS_ATTRIBUTE, GEN_AI_TOOL_INPUT_ATTRIBUTE);\n renameAttributeKey(attributes, AI_TOOL_CALL_RESULT_ATTRIBUTE, GEN_AI_TOOL_OUTPUT_ATTRIBUTE);\n\n renameAttributeKey(attributes, AI_SCHEMA_ATTRIBUTE, 'gen_ai.request.schema');\n renameAttributeKey(attributes, AI_MODEL_ID_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE);\n\n // Map embedding input: ai.values → gen_ai.embeddings.input\n // Vercel AI SDK JSON-stringifies each value individually, so we parse each element back.\n // Single embed gets unwrapped to a plain value; batch embedMany stays as a JSON array.\n if (Array.isArray(attributes[AI_VALUES_ATTRIBUTE])) {\n const parsed = (attributes[AI_VALUES_ATTRIBUTE] as string[]).map(v => {\n try {\n return JSON.parse(v);\n } catch {\n return v;\n }\n });\n attributes[GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE] = parsed.length === 1 ? parsed[0] : JSON.stringify(parsed);\n }\n\n addProviderMetadataToAttributes(attributes);\n\n for (const key of Object.keys(attributes)) {\n // JSON-stringify any array-valued attributes so they survive v2 span serialization.\n // Can be removed once span streaming supports arrays natively.\n if (Array.isArray(attributes[key])) {\n attributes[key] = JSON.stringify(attributes[key]);\n }\n // Change attributes namespaced with `ai.X` to `vercel.ai.X`\n if (key.startsWith('ai.')) {\n renameAttributeKey(attributes, key, `vercel.${key}`);\n }\n }\n}\n\nfunction processEndedVercelAiSpan(span: SpanJSON): void {\n const { data: attributes, origin } = span;\n\n if (origin !== 'auto.vercelai.otel') {\n return;\n }\n\n // The Vercel AI SDK sets span status to raw error message strings.\n // Any such value should be normalized to a SpanStatusType value. We pick internal_error as it is the most generic.\n if (span.status && span.status !== 'ok') {\n span.status = 'internal_error';\n }\n\n processVercelAiSpanAttributes(attributes);\n}\n\nfunction processVercelAiStreamedSpan(span: StreamedSpanJSON): void {\n const attributes = span.attributes;\n if (attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] !== 'auto.vercelai.otel') {\n return;\n }\n\n processVercelAiSpanAttributes(attributes);\n\n // Look up tool description from the toolDescriptionMap for execute_tool spans\n if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] === 'gen_ai.execute_tool' && span.parent_span_id) {\n const descriptions = toolDescriptionMap.get(span.parent_span_id);\n\n if (descriptions) {\n const toolName = attributes[GEN_AI_TOOL_NAME_ATTRIBUTE];\n if (typeof toolName === 'string') {\n const desc = descriptions.get(toolName);\n if (desc) {\n attributes[GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE] = desc;\n }\n }\n }\n }\n\n // Clean up tool descriptions when the parent span ends\n toolDescriptionMap.delete(span.span_id);\n}\n\n/**\n * Renames an attribute key in the provided attributes object if the old key exists.\n * This function safely handles null and undefined values.\n */\nfunction renameAttributeKey(attributes: Record<string, unknown>, oldKey: string, newKey: string): void {\n if (attributes[oldKey] != null) {\n attributes[newKey] = attributes[oldKey];\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete attributes[oldKey];\n }\n}\n\nfunction processToolCallSpan(span: Span, attributes: SpanAttributes): void {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.vercelai.otel');\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.execute_tool');\n span.setAttribute(GEN_AI_OPERATION_NAME_ATTRIBUTE, 'execute_tool');\n renameAttributeKey(attributes, AI_TOOL_CALL_NAME_ATTRIBUTE, GEN_AI_TOOL_NAME_ATTRIBUTE);\n renameAttributeKey(attributes, AI_TOOL_CALL_ID_ATTRIBUTE, GEN_AI_TOOL_CALL_ID_ATTRIBUTE);\n\n // Store the span context in our global map using the tool call ID.\n // This allows us to capture tool errors and link them to the correct span\n // without retaining the full Span object in memory.\n const toolCallId = attributes[GEN_AI_TOOL_CALL_ID_ATTRIBUTE];\n\n if (typeof toolCallId === 'string') {\n toolCallSpanContextMap.set(toolCallId, span.spanContext());\n }\n\n // https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-tool-type\n if (!attributes[GEN_AI_TOOL_TYPE_ATTRIBUTE]) {\n span.setAttribute(GEN_AI_TOOL_TYPE_ATTRIBUTE, 'function');\n }\n const toolName = attributes[GEN_AI_TOOL_NAME_ATTRIBUTE];\n if (toolName) {\n span.updateName(`execute_tool ${toolName}`);\n }\n}\n\nfunction processGenerateSpan(span: Span, name: string, attributes: SpanAttributes, enableTruncation: boolean): void {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.vercelai.otel');\n\n const nameWthoutAi = name.replace('ai.', '');\n span.setAttribute('ai.pipeline.name', nameWthoutAi);\n span.updateName(nameWthoutAi);\n\n const functionId = attributes[AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE];\n if (functionId && typeof functionId === 'string') {\n span.setAttribute('gen_ai.function_id', functionId);\n }\n\n requestMessagesFromPrompt(span, attributes, enableTruncation);\n\n if (attributes[AI_MODEL_ID_ATTRIBUTE] && !attributes[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]) {\n span.setAttribute(GEN_AI_RESPONSE_MODEL_ATTRIBUTE, attributes[AI_MODEL_ID_ATTRIBUTE]);\n }\n span.setAttribute('ai.streaming', name.includes('stream'));\n\n // Set the op based on the operation name registry\n const operationName = SPAN_TO_OPERATION_NAME.get(name);\n if (operationName) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, `gen_ai.${operationName}`);\n } else if (name.startsWith('ai.stream')) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.run');\n }\n\n // For invoke_agent pipeline spans, use 'invoke_agent' as the description\n // to be consistent with other AI integrations (e.g. LangGraph)\n if (operationName === 'invoke_agent') {\n if (functionId && typeof functionId === 'string') {\n span.updateName(`invoke_agent ${functionId}`);\n } else {\n span.updateName('invoke_agent');\n }\n return;\n }\n\n const modelId = attributes[AI_MODEL_ID_ATTRIBUTE];\n if (modelId && operationName) {\n span.updateName(`${operationName} ${modelId}`);\n }\n\n // Store tool descriptions in the toolDescriptionMap so processSpan can apply them to execute_tool spans.\n // This is only needed for span streaming (transaction path handles this separately)\n const client = getClient();\n if (\n client &&\n hasSpanStreamingEnabled(client) &&\n attributes[AI_PROMPT_TOOLS_ATTRIBUTE] &&\n Array.isArray(attributes[AI_PROMPT_TOOLS_ATTRIBUTE])\n ) {\n const descriptions = new Map<string, string>();\n\n // parse tool names and descriptions from tool string array\n for (const toolStr of attributes[AI_PROMPT_TOOLS_ATTRIBUTE] as unknown[]) {\n try {\n const parsed = (typeof toolStr === 'string' ? JSON.parse(toolStr) : toolStr) as {\n name?: string;\n description?: string;\n };\n if (parsed?.name && parsed?.description) {\n descriptions.set(parsed.name, parsed.description);\n }\n } catch {\n // ignore parse errors\n }\n }\n if (descriptions.size > 0) {\n // Tool call spans are siblings of doGenerate (both children of invoke_agent),\n // so we key by the parent span ID (the invoke_agent span).\n const parentSpanId = spanToJSON(span).parent_span_id;\n if (parentSpanId) {\n toolDescriptionMap.set(parentSpanId, descriptions);\n }\n }\n }\n}\n\n/**\n * Add event processors to the given client to process Vercel AI spans.\n */\nexport function addVercelAiProcessors(client: Client): void {\n client.on('spanStart', onVercelAiSpanStart);\n // Note: We cannot do this on `spanEnd`, because the span cannot be mutated anymore at this point\n client.addEventProcessor(Object.assign(vercelAiEventProcessor, { id: 'VercelAiEventProcessor' }));\n client.on('processSpan', span => {\n processVercelAiStreamedSpan(span);\n });\n}\n\nfunction addProviderMetadataToAttributes(attributes: Record<string, unknown>): void {\n const providerMetadata = attributes[AI_RESPONSE_PROVIDER_METADATA_ATTRIBUTE] as string | undefined;\n if (providerMetadata) {\n try {\n const providerMetadataObject = JSON.parse(providerMetadata) as ProviderMetadata;\n\n // Handle OpenAI metadata (v5 uses 'openai', v6 Azure Responses API uses 'azure')\n const openaiMetadata: OpenAiProviderMetadata | undefined =\n providerMetadataObject.openai ?? providerMetadataObject.azure;\n if (openaiMetadata) {\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n openaiMetadata.cachedPromptTokens,\n );\n setAttributeIfDefined(attributes, 'gen_ai.usage.output_tokens.reasoning', openaiMetadata.reasoningTokens);\n setAttributeIfDefined(\n attributes,\n 'gen_ai.usage.output_tokens.prediction_accepted',\n openaiMetadata.acceptedPredictionTokens,\n );\n setAttributeIfDefined(\n attributes,\n 'gen_ai.usage.output_tokens.prediction_rejected',\n openaiMetadata.rejectedPredictionTokens,\n );\n if (!attributes['gen_ai.conversation.id']) {\n setAttributeIfDefined(attributes, 'gen_ai.conversation.id', openaiMetadata.responseId);\n }\n }\n\n if (providerMetadataObject.anthropic) {\n const cachedInputTokens =\n providerMetadataObject.anthropic.usage?.cache_read_input_tokens ??\n providerMetadataObject.anthropic.cacheReadInputTokens;\n setAttributeIfDefined(attributes, GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE, cachedInputTokens);\n\n const cacheWriteInputTokens =\n providerMetadataObject.anthropic.usage?.cache_creation_input_tokens ??\n providerMetadataObject.anthropic.cacheCreationInputTokens;\n setAttributeIfDefined(attributes, GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE_ATTRIBUTE, cacheWriteInputTokens);\n }\n\n if (providerMetadataObject.bedrock?.usage) {\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n providerMetadataObject.bedrock.usage.cacheReadInputTokens,\n );\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE_ATTRIBUTE,\n providerMetadataObject.bedrock.usage.cacheWriteInputTokens,\n );\n }\n\n if (providerMetadataObject.deepseek) {\n setAttributeIfDefined(\n attributes,\n GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE,\n providerMetadataObject.deepseek.promptCacheHitTokens,\n );\n setAttributeIfDefined(\n attributes,\n 'gen_ai.usage.input_tokens.cache_miss',\n providerMetadataObject.deepseek.promptCacheMissTokens,\n );\n }\n } catch {\n // Ignore\n }\n }\n}\n\n/**\n * Sets an attribute only if the value is not null or undefined.\n */\nfunction setAttributeIfDefined(\n attributes: Record<string, unknown>,\n key: string,\n value: SpanAttributeValue | undefined,\n): void {\n if (value != null) {\n attributes[key] = value;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AA8DA;AACA;AACA;AACA;AACA,SAAS,mBAAmB,CAAC,IAAI,EAAc;AAC/C,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,IAAA,EAAK,GAAI,UAAU,CAAC,IAAI,CAAC;;AAElE,EAAE,IAAI,CAAC,IAAI,EAAE;AACb,IAAI;AACJ,EAAE;;AAEF;AACA;AACA,EAAE,IAAI,UAAU,CAAC,2BAA2B,CAAA,IAAK,UAAU,CAAC,yBAAyB,CAAA,IAAK,IAAA,KAAS,aAAa,EAAE;AAClH,IAAI,mBAAmB,CAAC,IAAI,EAAE,UAAU,CAAC;AACzC,IAAI;AACJ,EAAE;;AAEF;AACA;AACA,EAAE,IAAI,CAAC,UAAU,CAAC,yBAAyB,CAAA,IAAK,CAAC,IAAI,CAAC,UAAU,CAAC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AA;AACA,IAAA,CAAA,CAAA,MAAA;AACA;AACA,IAAA;AACA,EAAA;AACA;;AAEA;AACA;AACA;AACA,SAAA,qBAAA;AACA,EAAA,UAAA;AACA,EAAA,GAAA;AACA,EAAA,KAAA;AACA,EAAA;AACA,EAAA,IAAA,KAAA,IAAA,IAAA,EAAA;AACA,IAAA,UAAA,CAAA,GAAA,CAAA,GAAA,KAAA;AACA,EAAA;AACA;;;;"} |
@@ -11,7 +11,7 @@ /** | ||
| function replaceExports( | ||
| exports$1, | ||
| exports, | ||
| exportName, | ||
| wrappedConstructor, | ||
| ) { | ||
| const original = exports$1[exportName]; | ||
| const original = exports[exportName]; | ||
@@ -24,6 +24,6 @@ if (typeof original !== 'function') { | ||
| try { | ||
| exports$1[exportName] = wrappedConstructor; | ||
| exports[exportName] = wrappedConstructor; | ||
| } catch { | ||
| // If direct assignment fails, override the property descriptor | ||
| Object.defineProperty(exports$1, exportName, { | ||
| Object.defineProperty(exports, exportName, { | ||
| value: wrappedConstructor, | ||
@@ -37,7 +37,7 @@ writable: true, | ||
| // Replace the default export if it points to the original constructor | ||
| if (exports$1.default === original) { | ||
| if (exports.default === original) { | ||
| try { | ||
| exports$1.default = wrappedConstructor; | ||
| exports.default = wrappedConstructor; | ||
| } catch { | ||
| Object.defineProperty(exports$1, 'default', { | ||
| Object.defineProperty(exports, 'default', { | ||
| value: wrappedConstructor, | ||
@@ -44,0 +44,0 @@ writable: true, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"exports.js","sources":["../../../src/utils/exports.ts"],"sourcesContent":["/**\n * Replaces constructor functions in module exports, handling read-only properties,\n * and both default and named exports by wrapping them with the constructor.\n *\n * @param exports The module exports object to modify\n * @param exportName The name of the export to replace (e.g., 'GoogleGenAI', 'Anthropic', 'OpenAI')\n * @param wrappedConstructor The wrapped constructor function to replace the original with\n * @returns void\n */\nexport function replaceExports(\n exports: { [key: string]: unknown },\n exportName: string,\n wrappedConstructor: unknown,\n): void {\n const original = exports[exportName];\n\n if (typeof original !== 'function') {\n return;\n }\n\n // Replace the named export - handle read-only properties\n try {\n exports[exportName] = wrappedConstructor;\n } catch {\n // If direct assignment fails, override the property descriptor\n Object.defineProperty(exports, exportName, {\n value: wrappedConstructor,\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n\n // Replace the default export if it points to the original constructor\n if (exports.default === original) {\n try {\n exports.default = wrappedConstructor;\n } catch {\n Object.defineProperty(exports, 'default', {\n value: wrappedConstructor,\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n }\n}\n"],"names":["exports"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc;AAC9B,EAAEA,SAAO;AACT,EAAE,UAAU;AACZ,EAAE,kBAAkB;AACpB,EAAQ;AACR,EAAE,MAAM,QAAA,GAAWA,SAAO,CAAC,UAAU,CAAC;;AAEtC,EAAE,IAAI,OAAO,QAAA,KAAa,UAAU,EAAE;AACtC,IAAI;AACJ,EAAE;;AAEF;AACA,EAAE,IAAI;AACN,IAAIA,SAAO,CAAC,UAAU,CAAA,GAAI,kBAAkB;AAC5C,EAAE,EAAE,MAAM;AACV;AACA,IAAI,MAAM,CAAC,cAAc,CAACA,SAAO,EAAE,UAAU,EAAE;AAC/C,MAAM,KAAK,EAAE,kBAAkB;AAC/B,MAAM,QAAQ,EAAE,IAAI;AACpB,MAAM,YAAY,EAAE,IAAI;AACxB,MAAM,UAAU,EAAE,IAAI;AACtB,KAAK,CAAC;AACN,EAAE;;AAEF;AACA,EAAE,IAAIA,SAAO,CAAC,OAAA,KAAY,QAAQ,EAAE;AACpC,IAAI,IAAI;AACR,MAAMA,SAAO,CAAC,OAAA,GAAU,kBAAkB;AAC1C,IAAI,EAAE,MAAM;AACZ,MAAM,MAAM,CAAC,cAAc,CAACA,SAAO,EAAE,SAAS,EAAE;AAChD,QAAQ,KAAK,EAAE,kBAAkB;AACjC,QAAQ,QAAQ,EAAE,IAAI;AACtB,QAAQ,YAAY,EAAE,IAAI;AAC1B,QAAQ,UAAU,EAAE,IAAI;AACxB,OAAO,CAAC;AACR,IAAI;AACJ,EAAE;AACF;;;;"} | ||
| {"version":3,"file":"exports.js","sources":["../../../src/utils/exports.ts"],"sourcesContent":["/**\n * Replaces constructor functions in module exports, handling read-only properties,\n * and both default and named exports by wrapping them with the constructor.\n *\n * @param exports The module exports object to modify\n * @param exportName The name of the export to replace (e.g., 'GoogleGenAI', 'Anthropic', 'OpenAI')\n * @param wrappedConstructor The wrapped constructor function to replace the original with\n * @returns void\n */\nexport function replaceExports(\n exports: { [key: string]: unknown },\n exportName: string,\n wrappedConstructor: unknown,\n): void {\n const original = exports[exportName];\n\n if (typeof original !== 'function') {\n return;\n }\n\n // Replace the named export - handle read-only properties\n try {\n exports[exportName] = wrappedConstructor;\n } catch {\n // If direct assignment fails, override the property descriptor\n Object.defineProperty(exports, exportName, {\n value: wrappedConstructor,\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n\n // Replace the default export if it points to the original constructor\n if (exports.default === original) {\n try {\n exports.default = wrappedConstructor;\n } catch {\n Object.defineProperty(exports, 'default', {\n value: wrappedConstructor,\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n }\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc;AAC9B,EAAE,OAAO;AACT,EAAE,UAAU;AACZ,EAAE,kBAAkB;AACpB,EAAQ;AACR,EAAE,MAAM,QAAA,GAAW,OAAO,CAAC,UAAU,CAAC;;AAEtC,EAAE,IAAI,OAAO,QAAA,KAAa,UAAU,EAAE;AACtC,IAAI;AACJ,EAAE;;AAEF;AACA,EAAE,IAAI;AACN,IAAI,OAAO,CAAC,UAAU,CAAA,GAAI,kBAAkB;AAC5C,EAAE,EAAE,MAAM;AACV;AACA,IAAI,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE;AAC/C,MAAM,KAAK,EAAE,kBAAkB;AAC/B,MAAM,QAAQ,EAAE,IAAI;AACpB,MAAM,YAAY,EAAE,IAAI;AACxB,MAAM,UAAU,EAAE,IAAI;AACtB,KAAK,CAAC;AACN,EAAE;;AAEF;AACA,EAAE,IAAI,OAAO,CAAC,OAAA,KAAY,QAAQ,EAAE;AACpC,IAAI,IAAI;AACR,MAAM,OAAO,CAAC,OAAA,GAAU,kBAAkB;AAC1C,IAAI,EAAE,MAAM;AACZ,MAAM,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE;AAChD,QAAQ,KAAK,EAAE,kBAAkB;AACjC,QAAQ,QAAQ,EAAE,IAAI;AACtB,QAAQ,YAAY,EAAE,IAAI;AAC1B,QAAQ,UAAU,EAAE,IAAI;AACxB,OAAO,CAAC;AACR,IAAI;AACJ,EAAE;AACF;;;;"} |
@@ -137,6 +137,13 @@ import { isString, isRegExp, isVueViewModel } from './is.js'; | ||
| testString, | ||
| patterns = [], | ||
| patterns | ||
| = [], | ||
| requireExactStringMatch = false, | ||
| ) { | ||
| return patterns.some(pattern => isMatchingPattern(testString, pattern, requireExactStringMatch)); | ||
| for (const pattern of patterns) { | ||
| if (isMatchingPattern(testString, pattern, requireExactStringMatch)) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
@@ -143,0 +150,0 @@ |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"string.js","sources":["../../../src/utils/string.ts"],"sourcesContent":["import { isRegExp, isString, isVueViewModel } from './is';\nimport { getVueInternalName } from './stacktrace';\n\nexport { escapeStringForRegex } from '../vendor/escapeStringForRegex';\n\n/**\n * Truncates given string to the maximum characters count\n *\n * @param str An object that contains serializable values\n * @param max Maximum number of characters in truncated string (0 = unlimited)\n * @returns string Encoded\n */\nexport function truncate(str: string, max: number = 0): string {\n if (typeof str !== 'string' || max === 0) {\n return str;\n }\n return str.length <= max ? str : `${str.slice(0, max)}...`;\n}\n\n/**\n * This is basically just `trim_line` from\n * https://github.com/getsentry/sentry/blob/master/src/sentry/lang/javascript/processor.py#L67\n *\n * @param str An object that contains serializable values\n * @param max Maximum number of characters in truncated string\n * @returns string Encoded\n */\nexport function snipLine(line: string, colno: number): string {\n let newLine = line;\n const lineLength = newLine.length;\n if (lineLength <= 150) {\n return newLine;\n }\n if (colno > lineLength) {\n // eslint-disable-next-line no-param-reassign\n colno = lineLength;\n }\n\n let start = Math.max(colno - 60, 0);\n if (start < 5) {\n start = 0;\n }\n\n let end = Math.min(start + 140, lineLength);\n if (end > lineLength - 5) {\n end = lineLength;\n }\n if (end === lineLength) {\n start = Math.max(end - 140, 0);\n }\n\n newLine = newLine.slice(start, end);\n if (start > 0) {\n newLine = `'{snip} ${newLine}`;\n }\n if (end < lineLength) {\n newLine += ' {snip}';\n }\n\n return newLine;\n}\n\n/**\n * Join values in array\n * @param input array of values to be joined together\n * @param delimiter string to be placed in-between values\n * @returns Joined values\n */\nexport function safeJoin(input: unknown[], delimiter?: string): string {\n if (!Array.isArray(input)) {\n return '';\n }\n\n const output = [];\n // eslint-disable-next-line typescript/prefer-for-of\n for (let i = 0; i < input.length; i++) {\n const value = input[i];\n try {\n // This is a hack to fix a Vue3-specific bug that causes an infinite loop of\n // console warnings. This happens when a Vue template is rendered with\n // an undeclared variable, which we try to stringify, ultimately causing\n // Vue to issue another warning which repeats indefinitely.\n // see: https://github.com/getsentry/sentry-javascript/pull/8981\n if (isVueViewModel(value)) {\n output.push(getVueInternalName(value));\n } else {\n output.push(String(value));\n }\n } catch {\n output.push('[value cannot be serialized]');\n }\n }\n\n return output.join(delimiter);\n}\n\n/**\n * Checks if the given value matches a regex or string\n *\n * @param value The string to test\n * @param pattern Either a regex or a string against which `value` will be matched\n * @param requireExactStringMatch If true, `value` must match `pattern` exactly. If false, `value` will match\n * `pattern` if it contains `pattern`. Only applies to string-type patterns.\n */\nexport function isMatchingPattern(\n value: string,\n pattern: RegExp | string | ((value: string) => boolean),\n requireExactStringMatch: boolean = false,\n): boolean {\n if (!isString(value)) {\n return false;\n }\n\n if (isRegExp(pattern)) {\n return pattern.test(value);\n }\n if (isString(pattern)) {\n return requireExactStringMatch ? value === pattern : value.includes(pattern);\n }\n if (typeof pattern === 'function') {\n return pattern(value);\n }\n\n return false;\n}\n\n/**\n * Test the given string against an array of strings and regexes. By default, string matching is done on a\n * substring-inclusion basis rather than a strict equality basis\n *\n * @param testString The string to test\n * @param patterns The patterns against which to test the string\n * @param requireExactStringMatch If true, `testString` must match one of the given string patterns exactly in order to\n * count. If false, `testString` will match a string pattern if it contains that pattern.\n * @returns\n */\nexport function stringMatchesSomePattern(\n testString: string,\n patterns: Array<string | RegExp | ((value: string) => boolean)> = [],\n requireExactStringMatch: boolean = false,\n): boolean {\n return patterns.some(pattern => isMatchingPattern(testString, pattern, requireExactStringMatch));\n}\n"],"names":[],"mappings":";;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,QAAQ,CAAC,GAAG,EAAU,GAAG,GAAW,CAAC,EAAU;AAC/D,EAAE,IAAI,OAAO,GAAA,KAAQ,YAAY,GAAA,KAAQ,CAAC,EAAE;AAC5C,IAAI,OAAO,GAAG;AACd,EAAE;AACF,EAAE,OAAO,GAAG,CAAC,MAAA,IAAU,MAAM,GAAA,GAAM,CAAC,EAAA,GAAA,CAAA,KAAA,CAAA,CAAA,EAAA,GAAA,CAAA,CAAA,GAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,QAAA,CAAA,IAAA,EAAA,KAAA,EAAA;AACA,EAAA,IAAA,OAAA,GAAA,IAAA;AACA,EAAA,MAAA,UAAA,GAAA,OAAA,CAAA,MAAA;AACA,EAAA,IAAA,UAAA,IAAA,GAAA,EAAA;AACA,IAAA,OAAA,OAAA;AACA,EAAA;AACA,EAAA,IAAA,KAAA,GAAA,UAAA,EAAA;AACA;AACA,IAAA,KAAA,GAAA,UAAA;AACA,EAAA;;AAEA,EAAA,IAAA,KAAA,GAAA,IAAA,CAAA,GAAA,CAAA,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,CAAA,KAAA,CAAA,CAAA;AACA,MAAA,CAAA,MAAA;AACA,QAAA,MAAA,CAAA,IAAA,CAAA,MAAA,CAAA,KAAA,CAAA,CAAA;AACA,MAAA;AACA,IAAA,CAAA,CAAA,MAAA;AACA,MAAA,MAAA,CAAA,IAAA,CAAA,8BAAA,CAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,OAAA,MAAA,CAAA,IAAA,CAAA,SAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,iBAAA;AACA,EAAA,KAAA;AACA,EAAA,OAAA;AACA,EAAA,uBAAA,GAAA,KAAA;AACA,EAAA;AACA,EAAA,IAAA,CAAA,QAAA,CAAA,KAAA,CAAA,EAAA;AACA,IAAA,OAAA,KAAA;AACA,EAAA;;AAEA,EAAA,IAAA,QAAA,CAAA,OAAA,CAAA,EAAA;AACA,IAAA,OAAA,OAAA,CAAA,IAAA,CAAA,KAAA,CAAA;AACA,EAAA;AACA,EAAA,IAAA,QAAA,CAAA,OAAA,CAAA,EAAA;AACA,IAAA,OAAA,uBAAA,GAAA,KAAA,KAAA,OAAA,GAAA,KAAA,CAAA,QAAA,CAAA,OAAA,CAAA;AACA,EAAA;AACA,EAAA,IAAA,OAAA,OAAA,KAAA,UAAA,EAAA;AACA,IAAA,OAAA,OAAA,CAAA,KAAA,CAAA;AACA,EAAA;;AAEA,EAAA,OAAA,KAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,wBAAA;AACA,EAAA,UAAA;AACA,EAAA,QAAA,GAAA,EAAA;AACA,EAAA,uBAAA,GAAA,KAAA;AACA,EAAA;AACA,EAAA,OAAA,QAAA,CAAA,IAAA,CAAA,OAAA,IAAA,iBAAA,CAAA,UAAA,EAAA,OAAA,EAAA,uBAAA,CAAA,CAAA;AACA;;;;"} | ||
| {"version":3,"file":"string.js","sources":["../../../src/utils/string.ts"],"sourcesContent":["import { isRegExp, isString, isVueViewModel } from './is';\nimport { getVueInternalName } from './stacktrace';\n\nexport { escapeStringForRegex } from '../vendor/escapeStringForRegex';\n\n/**\n * Truncates given string to the maximum characters count\n *\n * @param str An object that contains serializable values\n * @param max Maximum number of characters in truncated string (0 = unlimited)\n * @returns string Encoded\n */\nexport function truncate(str: string, max: number = 0): string {\n if (typeof str !== 'string' || max === 0) {\n return str;\n }\n return str.length <= max ? str : `${str.slice(0, max)}...`;\n}\n\n/**\n * This is basically just `trim_line` from\n * https://github.com/getsentry/sentry/blob/master/src/sentry/lang/javascript/processor.py#L67\n *\n * @param str An object that contains serializable values\n * @param max Maximum number of characters in truncated string\n * @returns string Encoded\n */\nexport function snipLine(line: string, colno: number): string {\n let newLine = line;\n const lineLength = newLine.length;\n if (lineLength <= 150) {\n return newLine;\n }\n if (colno > lineLength) {\n // eslint-disable-next-line no-param-reassign\n colno = lineLength;\n }\n\n let start = Math.max(colno - 60, 0);\n if (start < 5) {\n start = 0;\n }\n\n let end = Math.min(start + 140, lineLength);\n if (end > lineLength - 5) {\n end = lineLength;\n }\n if (end === lineLength) {\n start = Math.max(end - 140, 0);\n }\n\n newLine = newLine.slice(start, end);\n if (start > 0) {\n newLine = `'{snip} ${newLine}`;\n }\n if (end < lineLength) {\n newLine += ' {snip}';\n }\n\n return newLine;\n}\n\n/**\n * Join values in array\n * @param input array of values to be joined together\n * @param delimiter string to be placed in-between values\n * @returns Joined values\n */\nexport function safeJoin(input: unknown[], delimiter?: string): string {\n if (!Array.isArray(input)) {\n return '';\n }\n\n const output = [];\n // eslint-disable-next-line typescript/prefer-for-of\n for (let i = 0; i < input.length; i++) {\n const value = input[i];\n try {\n // This is a hack to fix a Vue3-specific bug that causes an infinite loop of\n // console warnings. This happens when a Vue template is rendered with\n // an undeclared variable, which we try to stringify, ultimately causing\n // Vue to issue another warning which repeats indefinitely.\n // see: https://github.com/getsentry/sentry-javascript/pull/8981\n if (isVueViewModel(value)) {\n output.push(getVueInternalName(value));\n } else {\n output.push(String(value));\n }\n } catch {\n output.push('[value cannot be serialized]');\n }\n }\n\n return output.join(delimiter);\n}\n\n/**\n * Checks if the given value matches a regex or string\n *\n * @param value The string to test\n * @param pattern Either a regex or a string against which `value` will be matched\n * @param requireExactStringMatch If true, `value` must match `pattern` exactly. If false, `value` will match\n * `pattern` if it contains `pattern`. Only applies to string-type patterns.\n */\nexport function isMatchingPattern(\n value: string,\n pattern: RegExp | string | ((value: string) => boolean),\n requireExactStringMatch: boolean = false,\n): boolean {\n if (!isString(value)) {\n return false;\n }\n\n if (isRegExp(pattern)) {\n return pattern.test(value);\n }\n if (isString(pattern)) {\n return requireExactStringMatch ? value === pattern : value.includes(pattern);\n }\n if (typeof pattern === 'function') {\n return pattern(value);\n }\n\n return false;\n}\n\n/**\n * Test the given string against an array of strings and regexes. By default, string matching is done on a\n * substring-inclusion basis rather than a strict equality basis\n *\n * @param testString The string to test\n * @param patterns The patterns against which to test the string\n * @param requireExactStringMatch If true, `testString` must match one of the given string patterns exactly in order to\n * count. If false, `testString` will match a string pattern if it contains that pattern.\n * @returns\n */\nexport function stringMatchesSomePattern(\n testString: string,\n patterns:\n | Array<string | RegExp | ((value: string) => boolean)>\n | Set<string | RegExp | ((value: string) => boolean)> = [],\n requireExactStringMatch: boolean = false,\n): boolean {\n for (const pattern of patterns) {\n if (isMatchingPattern(testString, pattern, requireExactStringMatch)) {\n return true;\n }\n }\n return false;\n}\n"],"names":[],"mappings":";;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,QAAQ,CAAC,GAAG,EAAU,GAAG,GAAW,CAAC,EAAU;AAC/D,EAAE,IAAI,OAAO,GAAA,KAAQ,YAAY,GAAA,KAAQ,CAAC,EAAE;AAC5C,IAAI,OAAO,GAAG;AACd,EAAE;AACF,EAAE,OAAO,GAAG,CAAC,MAAA,IAAU,MAAM,GAAA,GAAM,CAAC,EAAA,GAAA,CAAA,KAAA,CAAA,CAAA,EAAA,GAAA,CAAA,CAAA,GAAA,C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A,KAAA,CAAA;AACA,EAAA;;AAEA,EAAA,OAAA,KAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,wBAAA;AACA,EAAA,UAAA;AACA,EAAA;;AAEA,GAAA,EAAA;AACA,EAAA,uBAAA,GAAA,KAAA;AACA,EAAA;AACA,EAAA,KAAA,MAAA,OAAA,IAAA,QAAA,EAAA;AACA,IAAA,IAAA,iBAAA,CAAA,UAAA,EAAA,OAAA,EAAA,uBAAA,CAAA,EAAA;AACA,MAAA,OAAA,IAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA,OAAA,KAAA;AACA;;;;"} |
| // This is a magic string replaced by rollup | ||
| const SDK_VERSION = "10.52.0" ; | ||
| const SDK_VERSION = "10.53.0" ; | ||
| export { SDK_VERSION }; | ||
| //# sourceMappingURL=version.js.map |
@@ -117,2 +117,10 @@ /** | ||
| bundleSizeOptimizations?: BundleSizeOptimizationsOptions; | ||
| /** | ||
| * A key that is used to identify the application in the Sentry bundler plugins. | ||
| * This key is used by the `thirdPartyErrorFilterIntegration` to filter out errors | ||
| * originating from third-party scripts. | ||
| * | ||
| * @see https://docs.sentry.io/platforms/javascript/configuration/filtering/#using-thirdpartyerrorfilterintegration | ||
| */ | ||
| applicationKey?: string; | ||
| } | ||
@@ -119,0 +127,0 @@ /** |
@@ -62,4 +62,4 @@ import { AsyncContextStack } from './asyncContext/stackStrategy'; | ||
| */ | ||
| export declare function getGlobalSingleton<Prop extends keyof SentryCarrier>(name: Prop, creator: () => NonNullable<SentryCarrier[Prop]>, obj?: import("./utils/worldwide").InternalGlobal): NonNullable<SentryCarrier[Prop]>; | ||
| export declare function getGlobalSingleton<Prop extends keyof SentryCarrier>(name: Prop, creator: () => NonNullable<SentryCarrier[Prop]>, obj?: import("./shared-exports").InternalGlobal): NonNullable<SentryCarrier[Prop]>; | ||
| export {}; | ||
| //# sourceMappingURL=carrier.d.ts.map |
@@ -1,235 +0,4 @@ | ||
| export { ClientClass as SentryCoreCurrentScopes } from './sdk'; | ||
| export { AsyncContextStrategy } from './asyncContext/types'; | ||
| export { Carrier } from './carrier'; | ||
| export { OfflineStore, OfflineTransportOptions } from './transports/offline'; | ||
| export { ServerRuntimeClientOptions } from './server-runtime-client'; | ||
| export { IntegrationIndex } from './integration'; | ||
| export * from './tracing'; | ||
| export * from './semanticAttributes'; | ||
| export { createEventEnvelope, createSessionEnvelope, createSpanEnvelope } from './envelope'; | ||
| export { captureCheckIn, withMonitor, captureException, captureEvent, captureMessage, lastEventId, close, flush, setContext, setExtra, setExtras, setTag, setTags, setUser, setConversationId, isInitialized, isEnabled, startSession, endSession, captureSession, addEventProcessor, } from './exports'; | ||
| export { getCurrentScope, getIsolationScope, getGlobalScope, withScope, withIsolationScope, getClient, getTraceContextFromScope, registerExternalPropagationContext, getExternalPropagationContext, hasExternalPropagationContext, } from './currentScopes'; | ||
| export { getDefaultCurrentScope, getDefaultIsolationScope } from './defaultScopes'; | ||
| export { setAsyncContextStrategy } from './asyncContext'; | ||
| export { getGlobalSingleton, getMainCarrier } from './carrier'; | ||
| export { makeSession, closeSession, updateSession } from './session'; | ||
| export { Scope } from './scope'; | ||
| export { CaptureContext, ScopeContext, ScopeData } from './scope'; | ||
| export { notifyEventProcessors } from './eventProcessors'; | ||
| export { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint, SENTRY_API_VERSION } from './api'; | ||
| export { Client } from './client'; | ||
| export { ServerRuntimeClient } from './server-runtime-client'; | ||
| export { initAndBind, setCurrentClient } from './sdk'; | ||
| export { createTransport } from './transports/base'; | ||
| export { makeOfflineTransport } from './transports/offline'; | ||
| export { makeMultiplexedTransport, MULTIPLEXED_TRANSPORT_EXTRA_KEY } from './transports/multiplexed'; | ||
| export { getIntegrationsToSetup, addIntegration, defineIntegration, installedIntegrations } from './integration'; | ||
| export { _INTERNAL_skipAiProviderWrapping, _INTERNAL_shouldSkipAiProviderWrapping, _INTERNAL_clearAiProviderSkips, } from './utils/ai/providerSkip'; | ||
| export { envToBool } from './utils/envToBool'; | ||
| export { applyScopeDataToEvent, mergeScopeData, getCombinedScopeData } from './utils/scopeData'; | ||
| export { prepareEvent } from './utils/prepareEvent'; | ||
| export { ExclusiveEventHintOrCaptureContext } from './utils/prepareEvent'; | ||
| export { createCheckInEnvelope } from './checkin'; | ||
| export { hasSpansEnabled } from './utils/hasSpansEnabled'; | ||
| export { withStreamedSpan } from './tracing/spans/beforeSendSpan'; | ||
| export { isStreamedBeforeSendSpanCallback } from './tracing/spans/beforeSendSpan'; | ||
| export { safeSetSpanJSONAttributes } from './tracing/spans/captureSpan'; | ||
| export { isSentryRequestUrl } from './utils/isSentryRequestUrl'; | ||
| export { handleCallbackErrors } from './utils/handleCallbackErrors'; | ||
| export { parameterize, fmt } from './utils/parameterize'; | ||
| export { HandleTunnelRequestOptions } from './utils/tunnel'; | ||
| export { handleTunnelRequest } from './utils/tunnel'; | ||
| export { addAutoIpAddressToSession } from './utils/ipAddress'; | ||
| export { addAutoIpAddressToUser } from './utils/ipAddress'; | ||
| export { convertSpanLinksForEnvelope, spanToTraceHeader, spanToJSON, spanToStreamedSpanJSON, spanIsSampled, spanToTraceContext, getSpanDescendants, getStatusMessage, getRootSpan, INTERNAL_getSegmentSpan, getActiveSpan, addChildSpanToSpan, spanTimeInputToSeconds, updateSpanName, } from './utils/spanUtils'; | ||
| export { _setSpanForScope as _INTERNAL_setSpanForScope } from './utils/spanOnScope'; | ||
| export { parseSampleRate } from './utils/parseSampleRate'; | ||
| export { applySdkMetadata } from './utils/sdkMetadata'; | ||
| export { getTraceData } from './utils/traceData'; | ||
| export { shouldPropagateTraceForUrl } from './utils/tracePropagationTargets'; | ||
| export { getTraceMetaTags } from './utils/meta'; | ||
| export { debounce } from './utils/debounce'; | ||
| export { makeWeakRef, derefWeakRef } from './utils/weakRef'; | ||
| export { MaybeWeakRef } from './utils/weakRef'; | ||
| export { shouldIgnoreSpan } from './utils/should-ignore-span'; | ||
| export { winterCGHeadersToDict, winterCGRequestToRequestData, captureBodyFromWinterCGRequest, httpRequestToRequestData, extractQueryParamsFromUrl, headersToDict, httpHeadersToSpanAttributes, getMaxBodyByteLength, MAX_BODY_BYTE_LENGTH, } from './utils/request'; | ||
| export { MaxRequestBodySize } from './utils/request'; | ||
| export { DEFAULT_ENVIRONMENT, DEV_ENVIRONMENT } from './constants'; | ||
| export { addBreadcrumb } from './breadcrumbs'; | ||
| export { functionToStringIntegration } from './integrations/functiontostring'; | ||
| export { inboundFiltersIntegration } from './integrations/eventFilters'; | ||
| export { eventFiltersIntegration } from './integrations/eventFilters'; | ||
| export { linkedErrorsIntegration } from './integrations/linkederrors'; | ||
| export { moduleMetadataIntegration } from './integrations/moduleMetadata'; | ||
| export { requestDataIntegration } from './integrations/requestdata'; | ||
| export { captureConsoleIntegration } from './integrations/captureconsole'; | ||
| export { patchExpressModule, setupExpressErrorHandler, expressErrorHandler } from './integrations/express/index'; | ||
| export { ExpressIntegrationOptions, ExpressHandlerOptions, ExpressMiddleware, ExpressErrorMiddleware, } from './integrations/express/types'; | ||
| export { dedupeIntegration } from './integrations/dedupe'; | ||
| export { extraErrorDataIntegration } from './integrations/extraerrordata'; | ||
| export { rewriteFramesIntegration } from './integrations/rewriteframes'; | ||
| export { supabaseIntegration, instrumentSupabaseClient } from './integrations/supabase'; | ||
| export { instrumentPostgresJsSql } from './integrations/postgresjs'; | ||
| export { zodErrorsIntegration } from './integrations/zoderrors'; | ||
| export { thirdPartyErrorFilterIntegration } from './integrations/third-party-errors-filter'; | ||
| export { consoleIntegration } from './integrations/console'; | ||
| export { FeatureFlagsIntegration } from './integrations/featureFlags'; | ||
| export { featureFlagsIntegration } from './integrations/featureFlags'; | ||
| export { growthbookIntegration } from './integrations/featureFlags'; | ||
| export { conversationIdIntegration } from './integrations/conversationId'; | ||
| export { patchHttpModuleClient } from './integrations/http/client-patch'; | ||
| export { getHttpClientSubscriptions } from './integrations/http/client-subscriptions'; | ||
| export { addOutgoingRequestBreadcrumb } from './integrations/http/add-outgoing-request-breadcrumb'; | ||
| export { getRequestUrl, getRequestUrlObject, getRequestUrlFromClientRequest, getRequestOptions, } from './integrations/http/get-request-url'; | ||
| export { HTTP_ON_CLIENT_REQUEST, HTTP_ON_SERVER_REQUEST } from './integrations/http/constants'; | ||
| export { HttpInstrumentationOptions, HttpClientRequest, HttpIncomingMessage, HttpServerResponse, HttpModuleExport, } from './integrations/http/types'; | ||
| export { profiler } from './profiling'; | ||
| export { instrumentFetchRequest, _INTERNAL_getTracingHeadersForFetchRequest } from './fetch'; | ||
| export { trpcMiddleware } from './trpc'; | ||
| export { wrapMcpServerWithSentry } from './integrations/mcp-server'; | ||
| export { captureFeedback } from './feedback'; | ||
| export { ReportDialogOptions } from './report-dialog'; | ||
| export { _INTERNAL_captureLog, _INTERNAL_flushLogsBuffer, _INTERNAL_captureSerializedLog } from './logs/internal'; | ||
| import * as logger_1 from './logs/public-api'; | ||
| export { logger_1 as logger }; | ||
| export { consoleLoggingIntegration } from './logs/console-integration'; | ||
| export { _INTERNAL_captureMetric, _INTERNAL_flushMetricsBuffer, _INTERNAL_captureSerializedMetric, } from './metrics/internal'; | ||
| import * as metrics_1 from './metrics/public-api'; | ||
| export { metrics_1 as metrics }; | ||
| export { MetricOptions } from './metrics/public-api'; | ||
| export { createConsolaReporter } from './integrations/consola'; | ||
| export { addVercelAiProcessors } from './tracing/vercel-ai'; | ||
| export { _INTERNAL_getSpanContextForToolCallId, _INTERNAL_cleanupToolCallSpanContext } from './tracing/vercel-ai/utils'; | ||
| export { toolCallSpanContextMap as _INTERNAL_toolCallSpanContextMap } from './tracing/vercel-ai/constants'; | ||
| export { instrumentOpenAiClient } from './tracing/openai'; | ||
| export { OPENAI_INTEGRATION_NAME } from './tracing/openai/constants'; | ||
| export { instrumentAnthropicAiClient } from './tracing/anthropic-ai'; | ||
| export { ANTHROPIC_AI_INTEGRATION_NAME } from './tracing/anthropic-ai/constants'; | ||
| export { instrumentGoogleGenAIClient } from './tracing/google-genai'; | ||
| export { GOOGLE_GENAI_INTEGRATION_NAME } from './tracing/google-genai/constants'; | ||
| export { GoogleGenAIResponse } from './tracing/google-genai/types'; | ||
| export { createLangChainCallbackHandler, instrumentLangChainEmbeddings } from './tracing/langchain'; | ||
| export { LANGCHAIN_INTEGRATION_NAME } from './tracing/langchain/constants'; | ||
| export { LangChainOptions, LangChainIntegration } from './tracing/langchain/types'; | ||
| export { instrumentStateGraphCompile, instrumentCreateReactAgent, instrumentLangGraph } from './tracing/langgraph'; | ||
| export { LANGGRAPH_INTEGRATION_NAME } from './tracing/langgraph/constants'; | ||
| export { LangGraphOptions, LangGraphIntegration, CompiledGraph } from './tracing/langgraph/types'; | ||
| export { OpenAiClient, OpenAiOptions, InstrumentedMethod } from './tracing/openai/types'; | ||
| export { AnthropicAiClient, AnthropicAiOptions, AnthropicAiInstrumentedMethod, AnthropicAiResponse, } from './tracing/anthropic-ai/types'; | ||
| export { GoogleGenAIClient, GoogleGenAIChat, GoogleGenAIOptions, GoogleGenAIInstrumentedMethod, } from './tracing/google-genai/types'; | ||
| export { GoogleGenAIIstrumentedMethod } from './tracing/google-genai/types'; | ||
| export { SpanBuffer } from './tracing/spans/spanBuffer'; | ||
| export { hasSpanStreamingEnabled } from './tracing/spans/hasSpanStreamingEnabled'; | ||
| export { spanStreamingIntegration } from './integrations/spanStreaming'; | ||
| export { FeatureFlag } from './utils/featureFlags'; | ||
| export { _INTERNAL_copyFlagsFromScopeToEvent, _INTERNAL_insertFlagToScope, _INTERNAL_addFeatureFlagToActiveSpan, _INTERNAL_FLAG_BUFFER_SIZE, _INTERNAL_MAX_FLAGS_PER_SPAN, } from './utils/featureFlags'; | ||
| export { applyAggregateErrorsToEvent } from './utils/aggregate-errors'; | ||
| export { getBreadcrumbLogLevelFromHttpStatusCode } from './utils/breadcrumb-log-level'; | ||
| export { getComponentName, getLocationHref, htmlTreeAsString } from './utils/browser'; | ||
| export { dsnFromString, dsnToString, makeDsn } from './utils/dsn'; | ||
| export { SentryError } from './utils/error'; | ||
| export { GLOBAL_OBJ } from './utils/worldwide'; | ||
| export { InternalGlobal } from './utils/worldwide'; | ||
| export { addConsoleInstrumentationHandler } from './instrument/console'; | ||
| export { addFetchEndInstrumentationHandler, addFetchInstrumentationHandler } from './instrument/fetch'; | ||
| export { addGlobalErrorInstrumentationHandler } from './instrument/globalError'; | ||
| export { addGlobalUnhandledRejectionInstrumentationHandler } from './instrument/globalUnhandledRejection'; | ||
| export { addHandler, maybeInstrument, resetInstrumentationHandlers, triggerHandlers } from './instrument/handlers'; | ||
| export { isDOMError, isDOMException, isElement, isError, isErrorEvent, isEvent, isInstanceOf, isParameterizedString, isPlainObject, isPrimitive, isRegExp, isString, isSyntheticEvent, isThenable, isVueViewModel, } from './utils/is'; | ||
| export { isBrowser } from './utils/isBrowser'; | ||
| export { CONSOLE_LEVELS, consoleSandbox, debug, originalConsoleMethods } from './utils/debug-logger'; | ||
| export { SentryDebugLogger } from './utils/debug-logger'; | ||
| export { addContextToFrame, addExceptionMechanism, addExceptionTypeValue, checkOrSetAlreadyCaught, isAlreadyCaptured, getEventDescription, parseSemver, uuid4, } from './utils/misc'; | ||
| export { isNodeEnv, loadModule } from './utils/node'; | ||
| export { normalize, normalizeToSize, normalizeUrlToBase } from './utils/normalize'; | ||
| export { setNormalizationDepthOverrideHint, setSkipNormalizationHint } from './utils/normalizationHints'; | ||
| export { addNonEnumerableProperty, convertToPlainObject, dropUndefinedKeys, extractExceptionKeysForMessage, fill, getOriginalFunction, markFunctionWrapped, objectify, } from './utils/object'; | ||
| export { basename, dirname, isAbsolute, join, normalizePath, relative, resolve } from './utils/path'; | ||
| export { makePromiseBuffer, SENTRY_BUFFER_FULL_ERROR } from './utils/promisebuffer'; | ||
| export { PromiseBuffer } from './utils/promisebuffer'; | ||
| export { severityLevelFromString } from './utils/severity'; | ||
| export { replaceExports } from './utils/exports'; | ||
| export { UNKNOWN_FUNCTION, createStackParser, getFramesFromEvent, getFunctionName, stackParserFromStackParserOptions, stripSentryFramesAndReverse, } from './utils/stacktrace'; | ||
| export { filenameIsInApp, node, nodeStackLineParser } from './utils/node-stack-trace'; | ||
| export { isMatchingPattern, safeJoin, snipLine, stringMatchesSomePattern, truncate } from './utils/string'; | ||
| export { isNativeFunction, supportsDOMError, supportsDOMException, supportsErrorEvent, supportsFetch, supportsHistory, supportsNativeFetch, supportsReferrerPolicy, supportsReportingObserver, } from './utils/supports'; | ||
| export { SyncPromise, rejectedSyncPromise, resolvedSyncPromise } from './utils/syncpromise'; | ||
| export { browserPerformanceTimeOrigin, dateTimestampInSeconds, timestampInSeconds } from './utils/time'; | ||
| export { TRACEPARENT_REGEXP, extractTraceparentData, generateSentryTraceHeader, propagationContextFromHeaders, shouldContinueTrace, generateTraceparentHeader, } from './utils/tracing'; | ||
| export { getSDKSource, isBrowserBundle } from './utils/env'; | ||
| export { SdkSource } from './utils/env'; | ||
| export { addItemToEnvelope, createAttachmentEnvelopeItem, createEnvelope, createEventEnvelopeHeaders, createSpanEnvelopeItem, envelopeContainsItemType, envelopeItemTypeToDataCategory, forEachEnvelopeItem, getSdkMetadataForEnvelopeHeader, parseEnvelope, serializeEnvelope, } from './utils/envelope'; | ||
| export { createClientReportEnvelope } from './utils/clientreport'; | ||
| export { DEFAULT_RETRY_AFTER, disabledUntil, isRateLimited, parseRetryAfterHeader, updateRateLimits, } from './utils/ratelimit'; | ||
| export { RateLimits } from './utils/ratelimit'; | ||
| export { MAX_BAGGAGE_STRING_LENGTH, SENTRY_BAGGAGE_KEY_PREFIX, SENTRY_BAGGAGE_KEY_PREFIX_REGEX, baggageHeaderToDynamicSamplingContext, dynamicSamplingContextToSentryBaggageHeader, parseBaggageHeader, objectToBaggageHeader, mergeBaggageHeaders, } from './utils/baggage'; | ||
| export { getSanitizedUrlString, parseUrl, stripUrlQueryAndFragment, parseStringToURLObject, getHttpSpanDetailsFromUrlObject, isURLObjectRelative, getSanitizedUrlStringFromUrlObject, stripDataUrlContent, } from './utils/url'; | ||
| export { eventFromMessage, eventFromUnknownInput, exceptionFromError, parseStackFrames, _enhanceErrorWithSentryInfo as _INTERNAL_enhanceErrorWithSentryInfo, } from './utils/eventbuilder'; | ||
| export { callFrameToStackFrame, watchdogTimer } from './utils/anr'; | ||
| export { LRUMap } from './utils/lru'; | ||
| export { generateTraceId, generateSpanId } from './utils/propagationContext'; | ||
| export { vercelWaitUntil } from './utils/vercelWaitUntil'; | ||
| export { flushIfServerless } from './utils/flushIfServerless'; | ||
| export { SDK_VERSION } from './utils/version'; | ||
| export { getDebugImagesForResources, getFilenameToDebugIdMap } from './utils/debug-ids'; | ||
| export { getFilenameToMetadataMap } from './metadata'; | ||
| export { escapeStringForRegex } from './vendor/escapeStringForRegex'; | ||
| export { Attachment } from './types-hoist/attachment'; | ||
| export { Breadcrumb, BreadcrumbHint, FetchBreadcrumbData, XhrBreadcrumbData, FetchBreadcrumbHint, XhrBreadcrumbHint, } from './types-hoist/breadcrumb'; | ||
| export { ClientReport, Outcome, EventDropReason } from './types-hoist/clientreport'; | ||
| export { Context, Contexts, DeviceContext, OsContext, AppContext, CultureContext, TraceContext, CloudResourceContext, MissingInstrumentationContext, } from './types-hoist/context'; | ||
| export { DataCategory } from './types-hoist/datacategory'; | ||
| export { DsnComponents, DsnLike, DsnProtocol } from './types-hoist/dsn'; | ||
| export { DebugImage, DebugMeta } from './types-hoist/debugMeta'; | ||
| export { AttachmentItem, BaseEnvelopeHeaders, BaseEnvelopeItemHeaders, ClientReportEnvelope, ClientReportItem, DynamicSamplingContext, Envelope, EnvelopeItemType, EnvelopeItem, EventEnvelope, EventEnvelopeHeaders, EventItem, ReplayEnvelope, FeedbackItem, SessionEnvelope, SessionItem, UserFeedbackItem, CheckInItem, CheckInEnvelope, RawSecurityEnvelope, RawSecurityItem, ProfileItem, ProfileChunkEnvelope, ProfileChunkItem, SpanEnvelope, StreamedSpanEnvelope, SpanItem, LogEnvelope, MetricEnvelope, } from './types-hoist/envelope'; | ||
| export { ExtendedError } from './types-hoist/error'; | ||
| export { Event, EventHint, EventType, ErrorEvent, TransactionEvent } from './types-hoist/event'; | ||
| export { EventProcessor } from './types-hoist/eventprocessor'; | ||
| export { Exception } from './types-hoist/exception'; | ||
| export { Extra, Extras } from './types-hoist/extra'; | ||
| export { Integration, IntegrationFn } from './types-hoist/integration'; | ||
| export { Mechanism } from './types-hoist/mechanism'; | ||
| export { ExtractedNodeRequestData, HttpHeaderValue, Primitive, WorkerLocation } from './types-hoist/misc'; | ||
| export { ClientOptions, CoreOptions as Options, ServerRuntimeOptions } from './types-hoist/options'; | ||
| export { Package } from './types-hoist/package'; | ||
| export { PolymorphicEvent, PolymorphicRequest } from './types-hoist/polymorphics'; | ||
| export { ThreadId, FrameId, StackId, ThreadCpuSample, ThreadCpuStack, ThreadCpuFrame, ThreadCpuProfile, ContinuousThreadCpuProfile, Profile, ProfileChunk, } from './types-hoist/profiling'; | ||
| export { ReplayEndEvent, ReplayEvent, ReplayRecordingData, ReplayRecordingMode, ReplayStartEvent, ReplayStopReason, } from './types-hoist/replay'; | ||
| export { FeedbackErrorCode, FeedbackErrorMessages, FeedbackEvent, FeedbackFormData, FeedbackInternalOptions, FeedbackModalIntegration, FeedbackScreenshotIntegration, SendFeedback, SendFeedbackParams, UserFeedback, } from './types-hoist/feedback'; | ||
| export { QueryParams, RequestEventData, RequestHookInfo, ResponseHookInfo, SanitizedRequestData, } from './types-hoist/request'; | ||
| export { Runtime } from './types-hoist/runtime'; | ||
| export { SdkInfo } from './types-hoist/sdkinfo'; | ||
| export { SdkMetadata } from './types-hoist/sdkmetadata'; | ||
| export { SessionAggregates, AggregationCounts, Session, SessionContext, SessionStatus, SerializedSession, } from './types-hoist/session'; | ||
| export { SeverityLevel } from './types-hoist/severity'; | ||
| export { Span, SentrySpanArguments, SpanOrigin, SpanAttributeValue, SpanAttributes, SpanTimeInput, SpanJSON, SpanContextData, TraceFlag, SerializedStreamedSpan, SerializedStreamedSpanContainer, StreamedSpanJSON, } from './types-hoist/span'; | ||
| export { SpanStatus } from './types-hoist/spanStatus'; | ||
| export { Log, LogSeverityLevel } from './types-hoist/log'; | ||
| export { SpanLink } from './types-hoist/link'; | ||
| export { Metric, MetricType, SerializedMetric, SerializedMetricContainer, SerializedMetricAttributeValue, } from './types-hoist/metric'; | ||
| export { TimedEvent } from './types-hoist/timedEvent'; | ||
| export { StackFrame } from './types-hoist/stackframe'; | ||
| export { Stacktrace, StackParser, StackLineParser, StackLineParserFn } from './types-hoist/stacktrace'; | ||
| export { PropagationContext, TracePropagationTargets, SerializedTraceData } from './types-hoist/tracing'; | ||
| export { StartSpanOptions } from './types-hoist/startSpanOptions'; | ||
| export { TraceparentData, TransactionSource } from './types-hoist/transaction'; | ||
| export { TracesSamplerSamplingContext, CustomSamplingContext, SamplingContext, } from './types-hoist/samplingcontext'; | ||
| export { DurationUnit, InformationUnit, FractionUnit, MeasurementUnit, NoneUnit, Measurements, } from './types-hoist/measurement'; | ||
| export { Thread } from './types-hoist/thread'; | ||
| export { Transport, TransportRequest, TransportMakeRequestResponse, InternalBaseTransportOptions, BaseTransportOptions, TransportRequestExecutor, } from './types-hoist/transport'; | ||
| export { User } from './types-hoist/user'; | ||
| export { WebFetchHeaders, WebFetchRequest } from './types-hoist/webfetchapi'; | ||
| export { WrappedFunction } from './types-hoist/wrappedfunction'; | ||
| export { HandlerDataFetch, HandlerDataXhr, HandlerDataDom, HandlerDataConsole, HandlerDataHistory, HandlerDataError, HandlerDataUnhandledRejection, ConsoleLevel, SentryXhrData, SentryWrappedXMLHttpRequest, } from './types-hoist/instrument'; | ||
| export { BrowserClientReplayOptions, BrowserClientProfilingOptions } from './types-hoist/browseroptions'; | ||
| export { CheckIn, MonitorConfig, FinishedCheckIn, InProgressCheckIn, SerializedCheckIn, } from './types-hoist/checkin'; | ||
| export { ParameterizedString } from './types-hoist/parameterize'; | ||
| export { ContinuousProfiler, ProfilingIntegration, Profiler } from './types-hoist/profiling'; | ||
| export { ViewHierarchyData, ViewHierarchyWindow } from './types-hoist/view-hierarchy'; | ||
| export { LegacyCSPReport } from './types-hoist/csp'; | ||
| export { SerializedLog, SerializedLogContainer } from './types-hoist/log'; | ||
| export { BuildTimeOptionsBase, UnstableVitePluginOptions, UnstableRollupPluginOptions, UnstableWebpackPluginOptions, } from './build-time-plugins/buildTimeOptionsBase'; | ||
| export { RandomSafeContextRunner as _INTERNAL_RandomSafeContextRunner } from './utils/randomSafeContext'; | ||
| export { withRandomSafeContext as _INTERNAL_withRandomSafeContext, safeMathRandom as _INTERNAL_safeMathRandom, safeDateNow as _INTERNAL_safeDateNow, } from './utils/randomSafeContext'; | ||
| export { safeUnref as _INTERNAL_safeUnref } from './utils/timer'; | ||
| export * from './shared-exports'; | ||
| export * from './server-exports'; | ||
| export * from './browser-exports'; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -10,2 +10,9 @@ import { HandlerDataConsole } from '../types-hoist/instrument'; | ||
| export declare function addConsoleInstrumentationHandler(handler: (data: HandlerDataConsole) => void): () => void; | ||
| /** | ||
| * Add a filter to the console instrumentation to filter out console messages that match the given strings or regular expressions. | ||
| * Returns a function to remove the filter. | ||
| */ | ||
| export declare function addConsoleInstrumentationFilter(filter: (string | RegExp)[]): () => void; | ||
| /** Only exported for tests. */ | ||
| export declare function _INTERNAL_resetConsoleInstrumentationOptions(): void; | ||
| //# sourceMappingURL=console.d.ts.map |
@@ -14,4 +14,4 @@ interface CaptureConsoleOptions { | ||
| */ | ||
| export declare const captureConsoleIntegration: (options?: CaptureConsoleOptions | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const captureConsoleIntegration: (options?: CaptureConsoleOptions | undefined) => import("..").Integration; | ||
| export {}; | ||
| //# sourceMappingURL=captureconsole.d.ts.map |
| import { ConsoleLevel } from '../types-hoist/instrument'; | ||
| interface ConsoleIntegrationOptions { | ||
| levels: ConsoleLevel[]; | ||
| /** | ||
| * Filter out console messages that match the given strings or regular expressions. | ||
| * These will neither be passed to the handler, and they will also not be logged to the user, unless they have debug enabled. | ||
| */ | ||
| filter?: (string | RegExp)[]; | ||
| } | ||
@@ -5,0 +10,0 @@ /** |
@@ -8,3 +8,3 @@ /** | ||
| */ | ||
| export declare const conversationIdIntegration: () => import("../types-hoist/integration").Integration; | ||
| export declare const conversationIdIntegration: () => import("..").Integration; | ||
| //# sourceMappingURL=conversationId.d.ts.map |
@@ -5,5 +5,5 @@ import { Event } from '../types-hoist/event'; | ||
| */ | ||
| export declare const dedupeIntegration: () => import("../types-hoist/integration").Integration; | ||
| export declare const dedupeIntegration: () => import("..").Integration; | ||
| /** only exported for tests. */ | ||
| export declare function _shouldDropEvent(currentEvent: Event, previousEvent?: Event): boolean; | ||
| //# sourceMappingURL=dedupe.d.ts.map |
@@ -23,3 +23,3 @@ /** Options for the EventFilters integration */ | ||
| */ | ||
| export declare const eventFiltersIntegration: (options?: Partial<EventFiltersOptions> | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const eventFiltersIntegration: (options?: Partial<EventFiltersOptions> | undefined) => import("..").Integration; | ||
| /** | ||
@@ -41,3 +41,3 @@ * An integration that filters out events (errors and transactions) based on: | ||
| */ | ||
| export declare const inboundFiltersIntegration: (options?: Partial<EventFiltersOptions> | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const inboundFiltersIntegration: (options?: Partial<EventFiltersOptions> | undefined) => import("..").Integration; | ||
| //# sourceMappingURL=eventFilters.d.ts.map |
@@ -13,4 +13,4 @@ interface ExtraErrorDataOptions { | ||
| } | ||
| export declare const extraErrorDataIntegration: (options?: Partial<ExtraErrorDataOptions> | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const extraErrorDataIntegration: (options?: Partial<ExtraErrorDataOptions> | undefined) => import("..").Integration; | ||
| export {}; | ||
| //# sourceMappingURL=extraerrordata.d.ts.map |
@@ -12,3 +12,3 @@ /** | ||
| */ | ||
| export declare const functionToStringIntegration: () => import("../types-hoist/integration").Integration; | ||
| export declare const functionToStringIntegration: () => import("..").Integration; | ||
| //# sourceMappingURL=functiontostring.d.ts.map |
@@ -5,4 +5,4 @@ interface LinkedErrorsOptions { | ||
| } | ||
| export declare const linkedErrorsIntegration: (options?: LinkedErrorsOptions | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const linkedErrorsIntegration: (options?: LinkedErrorsOptions | undefined) => import("..").Integration; | ||
| export {}; | ||
| //# sourceMappingURL=linkederrors.d.ts.map |
@@ -33,2 +33,20 @@ /** | ||
| export declare function wrapAllMCPHandlers(serverInstance: MCPServerInstance): void; | ||
| /** | ||
| * Retroactively wraps handlers on tools, resources, and prompts that were registered | ||
| * before `wrapMcpServerWithSentry` was called. | ||
| * | ||
| * The MCP SDK stores registered entries in private maps and invokes them via the entry's | ||
| * own property at call time — `executor` for tools, `readCallback` for resources, and | ||
| * `handler` for prompts. Replacing those properties | ||
| * in-place is therefore equivalent to having wrapped the original registration call. | ||
| * | ||
| * NOTE: This intentionally accesses private MCP SDK internals (`_registeredTools` etc.). | ||
| * The properties and their shapes are verified against @modelcontextprotocol/sdk source: | ||
| * https://github.com/modelcontextprotocol/typescript-sdk/blob/2c0c481cb9dbfd15c8613f765c940a5f5bace94d/packages/server/src/server/mcp.ts#L304 | ||
| * When upgrading the MCP SDK, re-verify that these internal maps and their callable | ||
| * properties still exist and are invoked directly (not captured by closure at registration). | ||
| * All access is defensive — if a property is absent or not a function we skip silently. | ||
| * @internal | ||
| */ | ||
| export declare function wrapExistingHandlers(serverInstance: MCPServerInstance): void; | ||
| //# sourceMappingURL=handlers.d.ts.map |
@@ -9,2 +9,7 @@ import { McpServerWrapperOptions } from './types'; | ||
| * | ||
| * Both call orderings are supported: wrapping before or after registering tools, resources, | ||
| * and prompts. Sentry patches the registration methods for future handlers and retroactively | ||
| * wraps any already-registered ones. Wrapping at construction time is recommended by | ||
| * convention (consistent with other SDK integrations), but is not required. | ||
| * | ||
| * @example | ||
@@ -16,3 +21,3 @@ * ```typescript | ||
| * | ||
| * // Default: inputs/outputs captured based on sendDefaultPii option | ||
| * // Wrap first, then register tools — this is the correct order | ||
| * const server = Sentry.wrapMcpServerWithSentry( | ||
@@ -22,2 +27,4 @@ * new McpServer({ name: "my-server", version: "1.0.0" }) | ||
| * | ||
| * server.registerTool('my-tool', schema, handler); | ||
| * | ||
| * // Explicitly control input/output capture | ||
@@ -24,0 +31,0 @@ * const server = Sentry.wrapMcpServerWithSentry( |
@@ -19,4 +19,4 @@ interface RequestDataIncludeOptions { | ||
| */ | ||
| export declare const requestDataIntegration: (options?: RequestDataIntegrationOptions | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const requestDataIntegration: (options?: RequestDataIntegrationOptions | undefined) => import("..").Integration; | ||
| export {}; | ||
| //# sourceMappingURL=requestdata.d.ts.map |
@@ -1,2 +0,2 @@ | ||
| export declare const spanStreamingIntegration: () => import("../types-hoist/integration").Integration; | ||
| export declare const spanStreamingIntegration: () => import("..").Integration; | ||
| //# sourceMappingURL=spanStreaming.d.ts.map |
@@ -98,4 +98,4 @@ declare const AUTH_OPERATIONS_TO_INSTRUMENT: string[]; | ||
| supabaseClient: any; | ||
| }) => import("../types-hoist/integration").Integration; | ||
| }) => import("..").Integration; | ||
| export {}; | ||
| //# sourceMappingURL=supabase.d.ts.map |
@@ -74,4 +74,4 @@ import { Event, EventHint } from '../types-hoist/event'; | ||
| */ | ||
| export declare const zodErrorsIntegration: (options?: ZodErrorsOptions | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const zodErrorsIntegration: (options?: ZodErrorsOptions | undefined) => import("..").Integration; | ||
| export {}; | ||
| //# sourceMappingURL=zoderrors.d.ts.map |
@@ -25,4 +25,4 @@ import { ConsoleLevel } from '../types-hoist/instrument'; | ||
| */ | ||
| export declare const consoleLoggingIntegration: (options?: Partial<CaptureConsoleOptions> | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const consoleLoggingIntegration: (options?: Partial<CaptureConsoleOptions> | undefined) => import("..").Integration; | ||
| export {}; | ||
| //# sourceMappingURL=console-integration.d.ts.map |
@@ -163,3 +163,3 @@ import { AttachmentType } from './attachment'; | ||
| type MetricEnvelopeHeaders = BaseEnvelopeHeaders; | ||
| export type EventEnvelope = BaseEnvelope<EventEnvelopeHeaders, EventItem | AttachmentItem | UserFeedbackItem | FeedbackItem | ProfileItem>; | ||
| export type EventEnvelope = BaseEnvelope<EventEnvelopeHeaders, EventItem | AttachmentItem | UserFeedbackItem | FeedbackItem | ProfileItem | SpanContainerItem>; | ||
| export type SessionEnvelope = BaseEnvelope<SessionEnvelopeHeaders, SessionItem>; | ||
@@ -166,0 +166,0 @@ export type ClientReportEnvelope = BaseEnvelope<ClientReportEnvelopeHeaders, ClientReportItem>; |
@@ -503,2 +503,10 @@ import { CaptureContext } from '../scope'; | ||
| /** | ||
| * If set to `true`, gen_ai spans will be extracted from transactions and sent as v2 span envelope items. | ||
| * | ||
| * This enables streaming gen_ai spans, avoiding payload size limits of usual transactions. | ||
| * | ||
| * @default false | ||
| */ | ||
| streamGenAiSpans?: boolean; | ||
| /** | ||
| * If logs support should be enabled. | ||
@@ -505,0 +513,0 @@ * |
@@ -45,3 +45,3 @@ export { escapeStringForRegex } from '../vendor/escapeStringForRegex'; | ||
| */ | ||
| export declare function stringMatchesSomePattern(testString: string, patterns?: Array<string | RegExp | ((value: string) => boolean)>, requireExactStringMatch?: boolean): boolean; | ||
| export declare function stringMatchesSomePattern(testString: string, patterns?: Array<string | RegExp | ((value: string) => boolean)> | Set<string | RegExp | ((value: string) => boolean)>, requireExactStringMatch?: boolean): boolean; | ||
| //# sourceMappingURL=string.d.ts.map |
@@ -117,2 +117,10 @@ /** | ||
| bundleSizeOptimizations?: BundleSizeOptimizationsOptions; | ||
| /** | ||
| * A key that is used to identify the application in the Sentry bundler plugins. | ||
| * This key is used by the `thirdPartyErrorFilterIntegration` to filter out errors | ||
| * originating from third-party scripts. | ||
| * | ||
| * @see https://docs.sentry.io/platforms/javascript/configuration/filtering/#using-thirdpartyerrorfilterintegration | ||
| */ | ||
| applicationKey?: string; | ||
| } | ||
@@ -119,0 +127,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"buildTimeOptionsBase.d.ts","sourceRoot":"","sources":["../../../src/build-time-plugins/buildTimeOptionsBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;;;;;;;;OAUG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;;;;;;;;;;;OAcG;IACH,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;IAEpC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAE/B;;;;OAIG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB;;OAEG;IACH,uBAAuB,CAAC,EAAE,8BAA8B,CAAC;CAC1D;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,yBAAyB,CAAC,iBAAiB,IAAI;IACzD;;;;;OAKG;IACH,gCAAgC,CAAC,EAAE,iBAAiB,CAAC;CACtD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,4BAA4B,CAAC,iBAAiB,IAAI;IAC5D;;;;;OAKG;IACH,mCAAmC,CAAC,EAAE,iBAAiB,CAAC;CACzD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,M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;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,UAAU,CAAC,EACP,KAAK,GACL,CAAC,CAAC,qBAAqB,GAAG,uBAAuB,CAAC,GAAG;QACnD;;;;;;;WAOG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QAExB;;;;;;WAMG;QACH,aAAa,CAAC,EAAE,OAAO,CAAC;QAExB;;;;;WAKG;QACH,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC,CAAC;IAEP;;;;OAIG;IACH,MAAM,CAAC,EACH,KAAK,GACL;QACE;;;WAGG;QACH,GAAG,EAAE,MAAM,CAAC;QAEZ;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAE1B;;WAEG;QACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAE3B;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACP;AAED,UAAU,8BAA8B;IACtC;;;;;;;OAOG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;;;;;;OASG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;;;;;;OASG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;;;;;;OASG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;;;;;;OASG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B"} | ||
| {"version":3,"file":"buildTimeOptionsBase.d.ts","sourceRoot":"","sources":["../../../src/build-time-plugins/buildTimeOptionsBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAA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AAC;QAExB;;;;;;WAMG;QACH,aAAa,CAAC,EAAE,OAAO,CAAC;QAExB;;;;;WAKG;QACH,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC,CAAC;IAEP;;;;OAIG;IACH,MAAM,CAAC,EACH,KAAK,GACL;QACE;;;WAGG;QACH,GAAG,EAAE,MAAM,CAAC;QAEZ;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAE1B;;WAEG;QACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAE3B;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACP;AAED,UAAU,8BAA8B;IACtC;;;;;;;OAOG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;;;;;;OASG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;;;;;;OASG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;;;;;;OASG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;;;;;;OASG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B"} |
@@ -62,4 +62,4 @@ import type { AsyncContextStack } from './asyncContext/stackStrategy'; | ||
| */ | ||
| export declare function getGlobalSingleton<Prop extends keyof SentryCarrier>(name: Prop, creator: () => NonNullable<SentryCarrier[Prop]>, obj?: import("./utils/worldwide").InternalGlobal): NonNullable<SentryCarrier[Prop]>; | ||
| export declare function getGlobalSingleton<Prop extends keyof SentryCarrier>(name: Prop, creator: () => NonNullable<SentryCarrier[Prop]>, obj?: import("./shared-exports").InternalGlobal): NonNullable<SentryCarrier[Prop]>; | ||
| export {}; | ||
| //# sourceMappingURL=carrier.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"carrier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CAAC,UAAU,IAAI,OAAO;IAI/B;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,aAAa,CACrB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,SAAS,EACf,YAAY,EAAE,KAAK,EACnB,cAAc,EAAE,KAAK,GACpB,WAAW,CAAC,KAAK,GAAG,IAAI,CAAC;IAoC5B;;;;;OAKG;IACH,SAAS,CAAC,aAAa,CACrB,KAAK,EAAE,KAAK,EACZ,IAAI,GAAE,SAAc,EACpB,YAAY,QAAoB,EAChC,cAAc,QAAsB,GACnC,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC;IAwBlC;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,aAAa,CACrB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,SAAS,EACf,YAAY,EAAE,KAAK,EACnB,cAAc,EAAE,KAAK,GACpB,WAAW,CAAC,KAAK,CAAC;IAsGrB;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,YAAY,GAAG,IAAI;IAoB3F;;OAEG;IACH,SAAS,CAAC,cAAc,IAAI,OAAO,EAAE;IAarC;;OAEG;IACH,SAAS,CAAC,cAAc,IAAI,IAAI;IAyBhC;;OAEG;aACa,kBAAkB,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC;IAE9F;;OAEG;aACa,gBAAgB,CAC9B,QAAQ,EAAE,mBAAmB,EAC7B,MAAM,CAAC,EAAE,aAAa,EACtB,KAAK,CAAC,EAAE,SAAS,GAChB,WAAW,CAAC,KAAK,CAAC;CACtB"} |
+3
-232
@@ -1,233 +0,4 @@ | ||
| export type { ClientClass as SentryCoreCurrentScopes } from './sdk'; | ||
| export type { AsyncContextStrategy } from './asyncContext/types'; | ||
| export type { Carrier } from './carrier'; | ||
| export type { OfflineStore, OfflineTransportOptions } from './transports/offline'; | ||
| export type { ServerRuntimeClientOptions } from './server-runtime-client'; | ||
| export type { IntegrationIndex } from './integration'; | ||
| export * from './tracing'; | ||
| export * from './semanticAttributes'; | ||
| export { createEventEnvelope, createSessionEnvelope, createSpanEnvelope } from './envelope'; | ||
| export { captureCheckIn, withMonitor, captureException, captureEvent, captureMessage, lastEventId, close, flush, setContext, setExtra, setExtras, setTag, setTags, setUser, setConversationId, isInitialized, isEnabled, startSession, endSession, captureSession, addEventProcessor, } from './exports'; | ||
| export { getCurrentScope, getIsolationScope, getGlobalScope, withScope, withIsolationScope, getClient, getTraceContextFromScope, registerExternalPropagationContext, getExternalPropagationContext, hasExternalPropagationContext, } from './currentScopes'; | ||
| export { getDefaultCurrentScope, getDefaultIsolationScope } from './defaultScopes'; | ||
| export { setAsyncContextStrategy } from './asyncContext'; | ||
| export { getGlobalSingleton, getMainCarrier } from './carrier'; | ||
| export { makeSession, closeSession, updateSession } from './session'; | ||
| export { Scope } from './scope'; | ||
| export type { CaptureContext, ScopeContext, ScopeData } from './scope'; | ||
| export { notifyEventProcessors } from './eventProcessors'; | ||
| export { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint, SENTRY_API_VERSION } from './api'; | ||
| export { Client } from './client'; | ||
| export { ServerRuntimeClient } from './server-runtime-client'; | ||
| export { initAndBind, setCurrentClient } from './sdk'; | ||
| export { createTransport } from './transports/base'; | ||
| export { makeOfflineTransport } from './transports/offline'; | ||
| export { makeMultiplexedTransport, MULTIPLEXED_TRANSPORT_EXTRA_KEY } from './transports/multiplexed'; | ||
| export { getIntegrationsToSetup, addIntegration, defineIntegration, installedIntegrations } from './integration'; | ||
| export { _INTERNAL_skipAiProviderWrapping, _INTERNAL_shouldSkipAiProviderWrapping, _INTERNAL_clearAiProviderSkips, } from './utils/ai/providerSkip'; | ||
| export { envToBool } from './utils/envToBool'; | ||
| export { applyScopeDataToEvent, mergeScopeData, getCombinedScopeData } from './utils/scopeData'; | ||
| export { prepareEvent } from './utils/prepareEvent'; | ||
| export type { ExclusiveEventHintOrCaptureContext } from './utils/prepareEvent'; | ||
| export { createCheckInEnvelope } from './checkin'; | ||
| export { hasSpansEnabled } from './utils/hasSpansEnabled'; | ||
| export { withStreamedSpan } from './tracing/spans/beforeSendSpan'; | ||
| export { isStreamedBeforeSendSpanCallback } from './tracing/spans/beforeSendSpan'; | ||
| export { safeSetSpanJSONAttributes } from './tracing/spans/captureSpan'; | ||
| export { isSentryRequestUrl } from './utils/isSentryRequestUrl'; | ||
| export { handleCallbackErrors } from './utils/handleCallbackErrors'; | ||
| export { parameterize, fmt } from './utils/parameterize'; | ||
| export type { HandleTunnelRequestOptions } from './utils/tunnel'; | ||
| export { handleTunnelRequest } from './utils/tunnel'; | ||
| export { addAutoIpAddressToSession } from './utils/ipAddress'; | ||
| export { addAutoIpAddressToUser } from './utils/ipAddress'; | ||
| export { convertSpanLinksForEnvelope, spanToTraceHeader, spanToJSON, spanToStreamedSpanJSON, spanIsSampled, spanToTraceContext, getSpanDescendants, getStatusMessage, getRootSpan, INTERNAL_getSegmentSpan, getActiveSpan, addChildSpanToSpan, spanTimeInputToSeconds, updateSpanName, } from './utils/spanUtils'; | ||
| export { _setSpanForScope as _INTERNAL_setSpanForScope } from './utils/spanOnScope'; | ||
| export { parseSampleRate } from './utils/parseSampleRate'; | ||
| export { applySdkMetadata } from './utils/sdkMetadata'; | ||
| export { getTraceData } from './utils/traceData'; | ||
| export { shouldPropagateTraceForUrl } from './utils/tracePropagationTargets'; | ||
| export { getTraceMetaTags } from './utils/meta'; | ||
| export { debounce } from './utils/debounce'; | ||
| export { makeWeakRef, derefWeakRef } from './utils/weakRef'; | ||
| export type { MaybeWeakRef } from './utils/weakRef'; | ||
| export { shouldIgnoreSpan } from './utils/should-ignore-span'; | ||
| export { winterCGHeadersToDict, winterCGRequestToRequestData, captureBodyFromWinterCGRequest, httpRequestToRequestData, extractQueryParamsFromUrl, headersToDict, httpHeadersToSpanAttributes, getMaxBodyByteLength, MAX_BODY_BYTE_LENGTH, } from './utils/request'; | ||
| export type { MaxRequestBodySize } from './utils/request'; | ||
| export { DEFAULT_ENVIRONMENT, DEV_ENVIRONMENT } from './constants'; | ||
| export { addBreadcrumb } from './breadcrumbs'; | ||
| export { functionToStringIntegration } from './integrations/functiontostring'; | ||
| export { inboundFiltersIntegration } from './integrations/eventFilters'; | ||
| export { eventFiltersIntegration } from './integrations/eventFilters'; | ||
| export { linkedErrorsIntegration } from './integrations/linkederrors'; | ||
| export { moduleMetadataIntegration } from './integrations/moduleMetadata'; | ||
| export { requestDataIntegration } from './integrations/requestdata'; | ||
| export { captureConsoleIntegration } from './integrations/captureconsole'; | ||
| export { patchExpressModule, setupExpressErrorHandler, expressErrorHandler } from './integrations/express/index'; | ||
| export type { ExpressIntegrationOptions, ExpressHandlerOptions, ExpressMiddleware, ExpressErrorMiddleware, } from './integrations/express/types'; | ||
| export { dedupeIntegration } from './integrations/dedupe'; | ||
| export { extraErrorDataIntegration } from './integrations/extraerrordata'; | ||
| export { rewriteFramesIntegration } from './integrations/rewriteframes'; | ||
| export { supabaseIntegration, instrumentSupabaseClient } from './integrations/supabase'; | ||
| export { instrumentPostgresJsSql } from './integrations/postgresjs'; | ||
| export { zodErrorsIntegration } from './integrations/zoderrors'; | ||
| export { thirdPartyErrorFilterIntegration } from './integrations/third-party-errors-filter'; | ||
| export { consoleIntegration } from './integrations/console'; | ||
| export type { FeatureFlagsIntegration } from './integrations/featureFlags'; | ||
| export { featureFlagsIntegration } from './integrations/featureFlags'; | ||
| export { growthbookIntegration } from './integrations/featureFlags'; | ||
| export { conversationIdIntegration } from './integrations/conversationId'; | ||
| export { patchHttpModuleClient } from './integrations/http/client-patch'; | ||
| export { getHttpClientSubscriptions } from './integrations/http/client-subscriptions'; | ||
| export { addOutgoingRequestBreadcrumb } from './integrations/http/add-outgoing-request-breadcrumb'; | ||
| export { getRequestUrl, getRequestUrlObject, getRequestUrlFromClientRequest, getRequestOptions, } from './integrations/http/get-request-url'; | ||
| export { HTTP_ON_CLIENT_REQUEST, HTTP_ON_SERVER_REQUEST } from './integrations/http/constants'; | ||
| export type { HttpInstrumentationOptions, HttpClientRequest, HttpIncomingMessage, HttpServerResponse, HttpModuleExport, } from './integrations/http/types'; | ||
| export { profiler } from './profiling'; | ||
| export { instrumentFetchRequest, _INTERNAL_getTracingHeadersForFetchRequest } from './fetch'; | ||
| export { trpcMiddleware } from './trpc'; | ||
| export { wrapMcpServerWithSentry } from './integrations/mcp-server'; | ||
| export { captureFeedback } from './feedback'; | ||
| export type { ReportDialogOptions } from './report-dialog'; | ||
| export { _INTERNAL_captureLog, _INTERNAL_flushLogsBuffer, _INTERNAL_captureSerializedLog } from './logs/internal'; | ||
| export * as logger from './logs/public-api'; | ||
| export { consoleLoggingIntegration } from './logs/console-integration'; | ||
| export { _INTERNAL_captureMetric, _INTERNAL_flushMetricsBuffer, _INTERNAL_captureSerializedMetric, } from './metrics/internal'; | ||
| export * as metrics from './metrics/public-api'; | ||
| export type { MetricOptions } from './metrics/public-api'; | ||
| export { createConsolaReporter } from './integrations/consola'; | ||
| export { addVercelAiProcessors } from './tracing/vercel-ai'; | ||
| export { _INTERNAL_getSpanContextForToolCallId, _INTERNAL_cleanupToolCallSpanContext } from './tracing/vercel-ai/utils'; | ||
| export { toolCallSpanContextMap as _INTERNAL_toolCallSpanContextMap } from './tracing/vercel-ai/constants'; | ||
| export { instrumentOpenAiClient } from './tracing/openai'; | ||
| export { OPENAI_INTEGRATION_NAME } from './tracing/openai/constants'; | ||
| export { instrumentAnthropicAiClient } from './tracing/anthropic-ai'; | ||
| export { ANTHROPIC_AI_INTEGRATION_NAME } from './tracing/anthropic-ai/constants'; | ||
| export { instrumentGoogleGenAIClient } from './tracing/google-genai'; | ||
| export { GOOGLE_GENAI_INTEGRATION_NAME } from './tracing/google-genai/constants'; | ||
| export type { GoogleGenAIResponse } from './tracing/google-genai/types'; | ||
| export { createLangChainCallbackHandler, instrumentLangChainEmbeddings } from './tracing/langchain'; | ||
| export { LANGCHAIN_INTEGRATION_NAME } from './tracing/langchain/constants'; | ||
| export type { LangChainOptions, LangChainIntegration } from './tracing/langchain/types'; | ||
| export { instrumentStateGraphCompile, instrumentCreateReactAgent, instrumentLangGraph } from './tracing/langgraph'; | ||
| export { LANGGRAPH_INTEGRATION_NAME } from './tracing/langgraph/constants'; | ||
| export type { LangGraphOptions, LangGraphIntegration, CompiledGraph } from './tracing/langgraph/types'; | ||
| export type { OpenAiClient, OpenAiOptions, InstrumentedMethod } from './tracing/openai/types'; | ||
| export type { AnthropicAiClient, AnthropicAiOptions, AnthropicAiInstrumentedMethod, AnthropicAiResponse, } from './tracing/anthropic-ai/types'; | ||
| export type { GoogleGenAIClient, GoogleGenAIChat, GoogleGenAIOptions, GoogleGenAIInstrumentedMethod, } from './tracing/google-genai/types'; | ||
| export type { GoogleGenAIIstrumentedMethod } from './tracing/google-genai/types'; | ||
| export { SpanBuffer } from './tracing/spans/spanBuffer'; | ||
| export { hasSpanStreamingEnabled } from './tracing/spans/hasSpanStreamingEnabled'; | ||
| export { spanStreamingIntegration } from './integrations/spanStreaming'; | ||
| export type { FeatureFlag } from './utils/featureFlags'; | ||
| export { _INTERNAL_copyFlagsFromScopeToEvent, _INTERNAL_insertFlagToScope, _INTERNAL_addFeatureFlagToActiveSpan, _INTERNAL_FLAG_BUFFER_SIZE, _INTERNAL_MAX_FLAGS_PER_SPAN, } from './utils/featureFlags'; | ||
| export { applyAggregateErrorsToEvent } from './utils/aggregate-errors'; | ||
| export { getBreadcrumbLogLevelFromHttpStatusCode } from './utils/breadcrumb-log-level'; | ||
| export { getComponentName, getLocationHref, htmlTreeAsString } from './utils/browser'; | ||
| export { dsnFromString, dsnToString, makeDsn } from './utils/dsn'; | ||
| export { SentryError } from './utils/error'; | ||
| export { GLOBAL_OBJ } from './utils/worldwide'; | ||
| export type { InternalGlobal } from './utils/worldwide'; | ||
| export { addConsoleInstrumentationHandler } from './instrument/console'; | ||
| export { addFetchEndInstrumentationHandler, addFetchInstrumentationHandler } from './instrument/fetch'; | ||
| export { addGlobalErrorInstrumentationHandler } from './instrument/globalError'; | ||
| export { addGlobalUnhandledRejectionInstrumentationHandler } from './instrument/globalUnhandledRejection'; | ||
| export { addHandler, maybeInstrument, resetInstrumentationHandlers, triggerHandlers } from './instrument/handlers'; | ||
| export { isDOMError, isDOMException, isElement, isError, isErrorEvent, isEvent, isInstanceOf, isParameterizedString, isPlainObject, isPrimitive, isRegExp, isString, isSyntheticEvent, isThenable, isVueViewModel, } from './utils/is'; | ||
| export { isBrowser } from './utils/isBrowser'; | ||
| export { CONSOLE_LEVELS, consoleSandbox, debug, originalConsoleMethods } from './utils/debug-logger'; | ||
| export type { SentryDebugLogger } from './utils/debug-logger'; | ||
| export { addContextToFrame, addExceptionMechanism, addExceptionTypeValue, checkOrSetAlreadyCaught, isAlreadyCaptured, getEventDescription, parseSemver, uuid4, } from './utils/misc'; | ||
| export { isNodeEnv, loadModule } from './utils/node'; | ||
| export { normalize, normalizeToSize, normalizeUrlToBase } from './utils/normalize'; | ||
| export { setNormalizationDepthOverrideHint, setSkipNormalizationHint } from './utils/normalizationHints'; | ||
| export { addNonEnumerableProperty, convertToPlainObject, dropUndefinedKeys, extractExceptionKeysForMessage, fill, getOriginalFunction, markFunctionWrapped, objectify, } from './utils/object'; | ||
| export { basename, dirname, isAbsolute, join, normalizePath, relative, resolve } from './utils/path'; | ||
| export { makePromiseBuffer, SENTRY_BUFFER_FULL_ERROR } from './utils/promisebuffer'; | ||
| export type { PromiseBuffer } from './utils/promisebuffer'; | ||
| export { severityLevelFromString } from './utils/severity'; | ||
| export { replaceExports } from './utils/exports'; | ||
| export { UNKNOWN_FUNCTION, createStackParser, getFramesFromEvent, getFunctionName, stackParserFromStackParserOptions, stripSentryFramesAndReverse, } from './utils/stacktrace'; | ||
| export { filenameIsInApp, node, nodeStackLineParser } from './utils/node-stack-trace'; | ||
| export { isMatchingPattern, safeJoin, snipLine, stringMatchesSomePattern, truncate } from './utils/string'; | ||
| export { isNativeFunction, supportsDOMError, supportsDOMException, supportsErrorEvent, supportsFetch, supportsHistory, supportsNativeFetch, supportsReferrerPolicy, supportsReportingObserver, } from './utils/supports'; | ||
| export { SyncPromise, rejectedSyncPromise, resolvedSyncPromise } from './utils/syncpromise'; | ||
| export { browserPerformanceTimeOrigin, dateTimestampInSeconds, timestampInSeconds } from './utils/time'; | ||
| export { TRACEPARENT_REGEXP, extractTraceparentData, generateSentryTraceHeader, propagationContextFromHeaders, shouldContinueTrace, generateTraceparentHeader, } from './utils/tracing'; | ||
| export { getSDKSource, isBrowserBundle } from './utils/env'; | ||
| export type { SdkSource } from './utils/env'; | ||
| export { addItemToEnvelope, createAttachmentEnvelopeItem, createEnvelope, createEventEnvelopeHeaders, createSpanEnvelopeItem, envelopeContainsItemType, envelopeItemTypeToDataCategory, forEachEnvelopeItem, getSdkMetadataForEnvelopeHeader, parseEnvelope, serializeEnvelope, } from './utils/envelope'; | ||
| export { createClientReportEnvelope } from './utils/clientreport'; | ||
| export { DEFAULT_RETRY_AFTER, disabledUntil, isRateLimited, parseRetryAfterHeader, updateRateLimits, } from './utils/ratelimit'; | ||
| export type { RateLimits } from './utils/ratelimit'; | ||
| export { MAX_BAGGAGE_STRING_LENGTH, SENTRY_BAGGAGE_KEY_PREFIX, SENTRY_BAGGAGE_KEY_PREFIX_REGEX, baggageHeaderToDynamicSamplingContext, dynamicSamplingContextToSentryBaggageHeader, parseBaggageHeader, objectToBaggageHeader, mergeBaggageHeaders, } from './utils/baggage'; | ||
| export { getSanitizedUrlString, parseUrl, stripUrlQueryAndFragment, parseStringToURLObject, getHttpSpanDetailsFromUrlObject, isURLObjectRelative, getSanitizedUrlStringFromUrlObject, stripDataUrlContent, } from './utils/url'; | ||
| export { eventFromMessage, eventFromUnknownInput, exceptionFromError, parseStackFrames, _enhanceErrorWithSentryInfo as _INTERNAL_enhanceErrorWithSentryInfo, } from './utils/eventbuilder'; | ||
| export { callFrameToStackFrame, watchdogTimer } from './utils/anr'; | ||
| export { LRUMap } from './utils/lru'; | ||
| export { generateTraceId, generateSpanId } from './utils/propagationContext'; | ||
| export { vercelWaitUntil } from './utils/vercelWaitUntil'; | ||
| export { flushIfServerless } from './utils/flushIfServerless'; | ||
| export { SDK_VERSION } from './utils/version'; | ||
| export { getDebugImagesForResources, getFilenameToDebugIdMap } from './utils/debug-ids'; | ||
| export { getFilenameToMetadataMap } from './metadata'; | ||
| export { escapeStringForRegex } from './vendor/escapeStringForRegex'; | ||
| export type { Attachment } from './types-hoist/attachment'; | ||
| export type { Breadcrumb, BreadcrumbHint, FetchBreadcrumbData, XhrBreadcrumbData, FetchBreadcrumbHint, XhrBreadcrumbHint, } from './types-hoist/breadcrumb'; | ||
| export type { ClientReport, Outcome, EventDropReason } from './types-hoist/clientreport'; | ||
| export type { Context, Contexts, DeviceContext, OsContext, AppContext, CultureContext, TraceContext, CloudResourceContext, MissingInstrumentationContext, } from './types-hoist/context'; | ||
| export type { DataCategory } from './types-hoist/datacategory'; | ||
| export type { DsnComponents, DsnLike, DsnProtocol } from './types-hoist/dsn'; | ||
| export type { DebugImage, DebugMeta } from './types-hoist/debugMeta'; | ||
| export type { AttachmentItem, BaseEnvelopeHeaders, BaseEnvelopeItemHeaders, ClientReportEnvelope, ClientReportItem, DynamicSamplingContext, Envelope, EnvelopeItemType, EnvelopeItem, EventEnvelope, EventEnvelopeHeaders, EventItem, ReplayEnvelope, FeedbackItem, SessionEnvelope, SessionItem, UserFeedbackItem, CheckInItem, CheckInEnvelope, RawSecurityEnvelope, RawSecurityItem, ProfileItem, ProfileChunkEnvelope, ProfileChunkItem, SpanEnvelope, StreamedSpanEnvelope, SpanItem, LogEnvelope, MetricEnvelope, } from './types-hoist/envelope'; | ||
| export type { ExtendedError } from './types-hoist/error'; | ||
| export type { Event, EventHint, EventType, ErrorEvent, TransactionEvent } from './types-hoist/event'; | ||
| export type { EventProcessor } from './types-hoist/eventprocessor'; | ||
| export type { Exception } from './types-hoist/exception'; | ||
| export type { Extra, Extras } from './types-hoist/extra'; | ||
| export type { Integration, IntegrationFn } from './types-hoist/integration'; | ||
| export type { Mechanism } from './types-hoist/mechanism'; | ||
| export type { ExtractedNodeRequestData, HttpHeaderValue, Primitive, WorkerLocation } from './types-hoist/misc'; | ||
| export type { ClientOptions, CoreOptions as Options, ServerRuntimeOptions } from './types-hoist/options'; | ||
| export type { Package } from './types-hoist/package'; | ||
| export type { PolymorphicEvent, PolymorphicRequest } from './types-hoist/polymorphics'; | ||
| export type { ThreadId, FrameId, StackId, ThreadCpuSample, ThreadCpuStack, ThreadCpuFrame, ThreadCpuProfile, ContinuousThreadCpuProfile, Profile, ProfileChunk, } from './types-hoist/profiling'; | ||
| export type { ReplayEndEvent, ReplayEvent, ReplayRecordingData, ReplayRecordingMode, ReplayStartEvent, ReplayStopReason, } from './types-hoist/replay'; | ||
| export type { FeedbackErrorCode, FeedbackErrorMessages, FeedbackEvent, FeedbackFormData, FeedbackInternalOptions, FeedbackModalIntegration, FeedbackScreenshotIntegration, SendFeedback, SendFeedbackParams, UserFeedback, } from './types-hoist/feedback'; | ||
| export type { QueryParams, RequestEventData, RequestHookInfo, ResponseHookInfo, SanitizedRequestData, } from './types-hoist/request'; | ||
| export type { Runtime } from './types-hoist/runtime'; | ||
| export type { SdkInfo } from './types-hoist/sdkinfo'; | ||
| export type { SdkMetadata } from './types-hoist/sdkmetadata'; | ||
| export type { SessionAggregates, AggregationCounts, Session, SessionContext, SessionStatus, SerializedSession, } from './types-hoist/session'; | ||
| export type { SeverityLevel } from './types-hoist/severity'; | ||
| export type { Span, SentrySpanArguments, SpanOrigin, SpanAttributeValue, SpanAttributes, SpanTimeInput, SpanJSON, SpanContextData, TraceFlag, SerializedStreamedSpan, SerializedStreamedSpanContainer, StreamedSpanJSON, } from './types-hoist/span'; | ||
| export type { SpanStatus } from './types-hoist/spanStatus'; | ||
| export type { Log, LogSeverityLevel } from './types-hoist/log'; | ||
| export type { SpanLink } from './types-hoist/link'; | ||
| export type { Metric, MetricType, SerializedMetric, SerializedMetricContainer, SerializedMetricAttributeValue, } from './types-hoist/metric'; | ||
| export type { TimedEvent } from './types-hoist/timedEvent'; | ||
| export type { StackFrame } from './types-hoist/stackframe'; | ||
| export type { Stacktrace, StackParser, StackLineParser, StackLineParserFn } from './types-hoist/stacktrace'; | ||
| export type { PropagationContext, TracePropagationTargets, SerializedTraceData } from './types-hoist/tracing'; | ||
| export type { StartSpanOptions } from './types-hoist/startSpanOptions'; | ||
| export type { TraceparentData, TransactionSource } from './types-hoist/transaction'; | ||
| export type { TracesSamplerSamplingContext, CustomSamplingContext, SamplingContext, } from './types-hoist/samplingcontext'; | ||
| export type { DurationUnit, InformationUnit, FractionUnit, MeasurementUnit, NoneUnit, Measurements, } from './types-hoist/measurement'; | ||
| export type { Thread } from './types-hoist/thread'; | ||
| export type { Transport, TransportRequest, TransportMakeRequestResponse, InternalBaseTransportOptions, BaseTransportOptions, TransportRequestExecutor, } from './types-hoist/transport'; | ||
| export type { User } from './types-hoist/user'; | ||
| export type { WebFetchHeaders, WebFetchRequest } from './types-hoist/webfetchapi'; | ||
| export type { WrappedFunction } from './types-hoist/wrappedfunction'; | ||
| export type { HandlerDataFetch, HandlerDataXhr, HandlerDataDom, HandlerDataConsole, HandlerDataHistory, HandlerDataError, HandlerDataUnhandledRejection, ConsoleLevel, SentryXhrData, SentryWrappedXMLHttpRequest, } from './types-hoist/instrument'; | ||
| export type { BrowserClientReplayOptions, BrowserClientProfilingOptions } from './types-hoist/browseroptions'; | ||
| export type { CheckIn, MonitorConfig, FinishedCheckIn, InProgressCheckIn, SerializedCheckIn, } from './types-hoist/checkin'; | ||
| export type { ParameterizedString } from './types-hoist/parameterize'; | ||
| export type { ContinuousProfiler, ProfilingIntegration, Profiler } from './types-hoist/profiling'; | ||
| export type { ViewHierarchyData, ViewHierarchyWindow } from './types-hoist/view-hierarchy'; | ||
| export type { LegacyCSPReport } from './types-hoist/csp'; | ||
| export type { SerializedLog, SerializedLogContainer } from './types-hoist/log'; | ||
| export type { BuildTimeOptionsBase, UnstableVitePluginOptions, UnstableRollupPluginOptions, UnstableWebpackPluginOptions, } from './build-time-plugins/buildTimeOptionsBase'; | ||
| export type { RandomSafeContextRunner as _INTERNAL_RandomSafeContextRunner } from './utils/randomSafeContext'; | ||
| export { withRandomSafeContext as _INTERNAL_withRandomSafeContext, safeMathRandom as _INTERNAL_safeMathRandom, safeDateNow as _INTERNAL_safeDateNow, } from './utils/randomSafeContext'; | ||
| export { safeUnref as _INTERNAL_safeUnref } from './utils/timer'; | ||
| export * from './shared-exports'; | ||
| export * from './server-exports'; | ||
| export * from './browser-exports'; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,WAAW,IAAI,uBAAuB,EAAE,MAAM,OAAO,CAAC;AACpE,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAClF,YAAY,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC5F,OAAO,EACL,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,WAAW,EACX,KAAK,EACL,KAAK,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,YAAY,EACZ,UAAU,EACV,cAAc,EACd,iBAA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yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,2CAA2C,CAAC;AACnD,YAAY,EAAE,uBAAuB,IAAI,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAC9G,OAAO,EACL,qBAAqB,IAAI,+BAA+B,EACxD,cAAc,IAAI,wBAAwB,EAC1C,WAAW,IAAI,qBAAqB,GACrC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,SAAS,IAAI,mBAAmB,EAAE,MAAM,eAAe,CAAC"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"} |
@@ -10,2 +10,9 @@ import type { HandlerDataConsole } from '../types-hoist/instrument'; | ||
| export declare function addConsoleInstrumentationHandler(handler: (data: HandlerDataConsole) => void): () => void; | ||
| /** | ||
| * Add a filter to the console instrumentation to filter out console messages that match the given strings or regular expressions. | ||
| * Returns a function to remove the filter. | ||
| */ | ||
| export declare function addConsoleInstrumentationFilter(filter: (string | RegExp)[]): () => void; | ||
| /** Only exported for tests. */ | ||
| export declare function _INTERNAL_resetConsoleInstrumentationOptions(): void; | ||
| //# sourceMappingURL=console.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../../src/instrument/console.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAMlF;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,GAAG,MAAM,IAAI,CAKxG"} | ||
| {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../../src/instrument/console.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAelF;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,GAAG,MAAM,IAAI,CAKxG;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM,IAAI,CAUvF;AAED,+BAA+B;AAC/B,wBAAgB,4CAA4C,IAAI,IAAI,CAEnE"} |
@@ -14,4 +14,4 @@ interface CaptureConsoleOptions { | ||
| */ | ||
| export declare const captureConsoleIntegration: (options?: CaptureConsoleOptions | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const captureConsoleIntegration: (options?: CaptureConsoleOptions | undefined) => import("..").Integration; | ||
| export {}; | ||
| //# sourceMappingURL=captureconsole.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"captureconsole.d.ts","sourceRoot":"","sources":["../../../src/integrations/captureconsole.ts"],"names":[],"mappings":"AAYA,UAAU,qBAAqB;IAC7B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA0BD;;GAEG;AACH,eAAO,MAAM,yBAAyB,mGAAgD,CAAC"} | ||
| {"version":3,"file":"captureconsole.d.ts","sourceRoot":"","sources":["../../../src/integrations/captureconsole.ts"],"names":[],"mappings":"AAYA,UAAU,qBAAqB;IAC7B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA0BD;;GAEG;AACH,eAAO,MAAM,yBAAyB,2EAAgD,CAAC"} |
| import type { ConsoleLevel } from '../types-hoist/instrument'; | ||
| interface ConsoleIntegrationOptions { | ||
| levels: ConsoleLevel[]; | ||
| /** | ||
| * Filter out console messages that match the given strings or regular expressions. | ||
| * These will neither be passed to the handler, and they will also not be logged to the user, unless they have debug enabled. | ||
| */ | ||
| filter?: (string | RegExp)[]; | ||
| } | ||
@@ -5,0 +10,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../../src/integrations/console.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAM9D,UAAU,yBAAyB;IACjC,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB;AAUD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,wFAiB7B,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CA2B/E"} | ||
| {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../../src/integrations/console.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAM9D,UAAU,yBAAyB;IACjC,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CAC9B;AAUD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,wFAqB7B,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CA2B/E"} |
@@ -8,3 +8,3 @@ /** | ||
| */ | ||
| export declare const conversationIdIntegration: () => import("../types-hoist/integration").Integration; | ||
| export declare const conversationIdIntegration: () => import("..").Integration; | ||
| //# sourceMappingURL=conversationId.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"conversationId.d.ts","sourceRoot":"","sources":["../../../src/integrations/conversationId.ts"],"names":[],"mappings":"AAsCA;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,wDAAgD,CAAC"} | ||
| {"version":3,"file":"conversationId.d.ts","sourceRoot":"","sources":["../../../src/integrations/conversationId.ts"],"names":[],"mappings":"AAsCA;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,gCAAgD,CAAC"} |
@@ -5,5 +5,5 @@ import type { Event } from '../types-hoist/event'; | ||
| */ | ||
| export declare const dedupeIntegration: () => import("../types-hoist/integration").Integration; | ||
| export declare const dedupeIntegration: () => import("..").Integration; | ||
| /** only exported for tests. */ | ||
| export declare function _shouldDropEvent(currentEvent: Event, previousEvent?: Event): boolean; | ||
| //# sourceMappingURL=dedupe.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"dedupe.d.ts","sourceRoot":"","sources":["../../../src/integrations/dedupe.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAkClD;;GAEG;AACH,eAAO,MAAM,iBAAiB,wDAAwC,CAAC;AAEvE,+BAA+B;AAC/B,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,KAAK,EAAE,aAAa,CAAC,EAAE,KAAK,GAAG,OAAO,CAcpF"} | ||
| {"version":3,"file":"dedupe.d.ts","sourceRoot":"","sources":["../../../src/integrations/dedupe.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAkClD;;GAEG;AACH,eAAO,MAAM,iBAAiB,gCAAwC,CAAC;AAEvE,+BAA+B;AAC/B,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,KAAK,EAAE,aAAa,CAAC,EAAE,KAAK,GAAG,OAAO,CAcpF"} |
@@ -23,3 +23,3 @@ /** Options for the EventFilters integration */ | ||
| */ | ||
| export declare const eventFiltersIntegration: (options?: Partial<EventFiltersOptions> | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const eventFiltersIntegration: (options?: Partial<EventFiltersOptions> | undefined) => import("..").Integration; | ||
| /** | ||
@@ -41,3 +41,3 @@ * An integration that filters out events (errors and transactions) based on: | ||
| */ | ||
| export declare const inboundFiltersIntegration: (options?: Partial<EventFiltersOptions> | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const inboundFiltersIntegration: (options?: Partial<EventFiltersOptions> | undefined) => import("..").Integration; | ||
| //# sourceMappingURL=eventFilters.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"eventFilters.d.ts","sourceRoot":"","sources":["../../../src/integrations/eventFilters.ts"],"names":[],"mappings":"AA0BA,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACjC,YAAY,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACrC,kBAAkB,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAC3C,cAAc,EAAE,OAAO,CAAC;IACxB,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAID;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,0GAgBlC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,yBAAyB,0GAKX,CAAC"} | ||
| {"version":3,"file":"eventFilters.d.ts","sourceRoot":"","sources":["../../../src/integrations/eventFilters.ts"],"names":[],"mappings":"AA0BA,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACjC,YAAY,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACrC,kBAAkB,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAC3C,cAAc,EAAE,OAAO,CAAC;IACxB,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAID;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,kFAgBlC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,yBAAyB,kFAKX,CAAC"} |
@@ -13,4 +13,4 @@ interface ExtraErrorDataOptions { | ||
| } | ||
| export declare const extraErrorDataIntegration: (options?: Partial<ExtraErrorDataOptions> | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const extraErrorDataIntegration: (options?: Partial<ExtraErrorDataOptions> | undefined) => import("..").Integration; | ||
| export {}; | ||
| //# sourceMappingURL=extraerrordata.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"extraerrordata.d.ts","sourceRoot":"","sources":["../../../src/integrations/extraerrordata.ts"],"names":[],"mappings":"AAcA,UAAU,qBAAqB;IAC7B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAgBD,eAAO,MAAM,yBAAyB,4GAAgD,CAAC"} | ||
| {"version":3,"file":"extraerrordata.d.ts","sourceRoot":"","sources":["../../../src/integrations/extraerrordata.ts"],"names":[],"mappings":"AAcA,UAAU,qBAAqB;IAC7B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAgBD,eAAO,MAAM,yBAAyB,oFAAgD,CAAC"} |
@@ -12,3 +12,3 @@ /** | ||
| */ | ||
| export declare const functionToStringIntegration: () => import("../types-hoist/integration").Integration; | ||
| export declare const functionToStringIntegration: () => import("..").Integration; | ||
| //# sourceMappingURL=functiontostring.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"functiontostring.d.ts","sourceRoot":"","sources":["../../../src/integrations/functiontostring.ts"],"names":[],"mappings":"AAuCA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,wDAAkD,CAAC"} | ||
| {"version":3,"file":"functiontostring.d.ts","sourceRoot":"","sources":["../../../src/integrations/functiontostring.ts"],"names":[],"mappings":"AAuCA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,gCAAkD,CAAC"} |
@@ -5,4 +5,4 @@ interface LinkedErrorsOptions { | ||
| } | ||
| export declare const linkedErrorsIntegration: (options?: LinkedErrorsOptions | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const linkedErrorsIntegration: (options?: LinkedErrorsOptions | undefined) => import("..").Integration; | ||
| export {}; | ||
| //# sourceMappingURL=linkederrors.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"linkederrors.d.ts","sourceRoot":"","sources":["../../../src/integrations/linkederrors.ts"],"names":[],"mappings":"AAKA,UAAU,mBAAmB;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAqBD,eAAO,MAAM,uBAAuB,iGAA8C,CAAC"} | ||
| {"version":3,"file":"linkederrors.d.ts","sourceRoot":"","sources":["../../../src/integrations/linkederrors.ts"],"names":[],"mappings":"AAKA,UAAU,mBAAmB;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAqBD,eAAO,MAAM,uBAAuB,yEAA8C,CAAC"} |
@@ -33,2 +33,20 @@ /** | ||
| export declare function wrapAllMCPHandlers(serverInstance: MCPServerInstance): void; | ||
| /** | ||
| * Retroactively wraps handlers on tools, resources, and prompts that were registered | ||
| * before `wrapMcpServerWithSentry` was called. | ||
| * | ||
| * The MCP SDK stores registered entries in private maps and invokes them via the entry's | ||
| * own property at call time — `executor` for tools, `readCallback` for resources, and | ||
| * `handler` for prompts. Replacing those properties | ||
| * in-place is therefore equivalent to having wrapped the original registration call. | ||
| * | ||
| * NOTE: This intentionally accesses private MCP SDK internals (`_registeredTools` etc.). | ||
| * The properties and their shapes are verified against @modelcontextprotocol/sdk source: | ||
| * https://github.com/modelcontextprotocol/typescript-sdk/blob/2c0c481cb9dbfd15c8613f765c940a5f5bace94d/packages/server/src/server/mcp.ts#L304 | ||
| * When upgrading the MCP SDK, re-verify that these internal maps and their callable | ||
| * properties still exist and are invoked directly (not captured by closure at registration). | ||
| * All access is defensive — if a property is absent or not a function we skip silently. | ||
| * @internal | ||
| */ | ||
| export declare function wrapExistingHandlers(serverInstance: MCPServerInstance): void; | ||
| //# sourceMappingURL=handlers.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../../src/integrations/mcp-server/handlers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAqH7D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAGxE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAG5E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAG1E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAI1E"} | ||
| {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../../src/integrations/mcp-server/handlers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAqH7D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAGxE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAG5E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAG1E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAI1E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAoD5E"} |
@@ -9,2 +9,7 @@ import type { McpServerWrapperOptions } from './types'; | ||
| * | ||
| * Both call orderings are supported: wrapping before or after registering tools, resources, | ||
| * and prompts. Sentry patches the registration methods for future handlers and retroactively | ||
| * wraps any already-registered ones. Wrapping at construction time is recommended by | ||
| * convention (consistent with other SDK integrations), but is not required. | ||
| * | ||
| * @example | ||
@@ -16,3 +21,3 @@ * ```typescript | ||
| * | ||
| * // Default: inputs/outputs captured based on sendDefaultPii option | ||
| * // Wrap first, then register tools — this is the correct order | ||
| * const server = Sentry.wrapMcpServerWithSentry( | ||
@@ -22,2 +27,4 @@ * new McpServer({ name: "my-server", version: "1.0.0" }) | ||
| * | ||
| * server.registerTool('my-tool', schema, handler); | ||
| * | ||
| * // Explicitly control input/output capture | ||
@@ -24,0 +31,0 @@ * const server = Sentry.wrapMcpServerWithSentry( |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/mcp-server/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAqB,uBAAuB,EAAoC,MAAM,SAAS,CAAC;AAS5G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,EAAE,iBAAiB,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,CAAC,CAuCpH"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/mcp-server/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAqB,uBAAuB,EAAoC,MAAM,SAAS,CAAC;AAS5G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,EAAE,iBAAiB,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,CAAC,CAyCpH"} |
@@ -19,4 +19,4 @@ interface RequestDataIncludeOptions { | ||
| */ | ||
| export declare const requestDataIntegration: (options?: RequestDataIntegrationOptions | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const requestDataIntegration: (options?: RequestDataIntegrationOptions | undefined) => import("..").Integration; | ||
| export {}; | ||
| //# sourceMappingURL=requestdata.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"requestdata.d.ts","sourceRoot":"","sources":["../../../src/integrations/requestdata.ts"],"names":[],"mappings":"AAYA,UAAU,yBAAyB;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,KAAK,6BAA6B,GAAG;IACnC;;OAEG;IACH,OAAO,CAAC,EAAE,yBAAyB,CAAC;CACrC,CAAC;AAuDF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,2GAA6C,CAAC"} | ||
| {"version":3,"file":"requestdata.d.ts","sourceRoot":"","sources":["../../../src/integrations/requestdata.ts"],"names":[],"mappings":"AAYA,UAAU,yBAAyB;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,KAAK,6BAA6B,GAAG;IACnC;;OAEG;IACH,OAAO,CAAC,EAAE,yBAAyB,CAAC;CACrC,CAAC;AAuDF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,mFAA6C,CAAC"} |
@@ -1,2 +0,2 @@ | ||
| export declare const spanStreamingIntegration: () => import("../types-hoist/integration").Integration; | ||
| export declare const spanStreamingIntegration: () => import("..").Integration; | ||
| //# sourceMappingURL=spanStreaming.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"spanStreaming.d.ts","sourceRoot":"","sources":["../../../src/integrations/spanStreaming.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,wBAAwB,wDAiCX,CAAC"} | ||
| {"version":3,"file":"spanStreaming.d.ts","sourceRoot":"","sources":["../../../src/integrations/spanStreaming.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,wBAAwB,gCAiCX,CAAC"} |
@@ -98,4 +98,4 @@ declare const AUTH_OPERATIONS_TO_INSTRUMENT: string[]; | ||
| supabaseClient: any; | ||
| }) => import("../types-hoist/integration").Integration; | ||
| }) => import("..").Integration; | ||
| export {}; | ||
| //# sourceMappingURL=supabase.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../../../src/integrations/supabase.ts"],"names":[],"mappings":"AAiBA,QAAA,MAAM,6BAA6B,UAWlC,CAAC;AAEF,QAAA,MAAM,mCAAmC,UAOxC,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4B3B,CAAC;AAEF,eAAO,MAAM,2BAA2B,UAAqD,CAAC;AAE9F,KAAK,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAChE,KAAK,iBAAiB,GAAG,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,CAAC,CAAC;AACxE,KAAK,sBAAsB,GAAG,CAAC,OAAO,mCAAmC,CAAC,CAAC,MAAM,CAAC,CAAC;AACnF,KAAK,yBAAyB,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,sBAAsB,CAAC;AAEhF,MAAM,W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AC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EACvD,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,KACtD,OAAO,CAAC,CAAC,CAAC,CAAC;CACjB;AAyCD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,MAAM,CAsB7F;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CA8B9E;AA6SD,eAAO,MAAM,wBAAwB,GAAI,gBAAgB,OAAO,KAAG,IAUlE,CAAC;AAaF,eAAO,MAAM,mBAAmB;oBAAiD,GAAG;8BAE1D,CAAC"} |
@@ -74,4 +74,4 @@ import type { Event, EventHint } from '../types-hoist/event'; | ||
| */ | ||
| export declare const zodErrorsIntegration: (options?: ZodErrorsOptions | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const zodErrorsIntegration: (options?: ZodErrorsOptions | undefined) => import("..").Integration; | ||
| export {}; | ||
| //# sourceMappingURL=zoderrors.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"zoderrors.d.ts","sourceRoot":"","sources":["../../../src/integrations/zoderrors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAK7D,UAAU,gBAAgB;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAKD;;GAEG;AACH,UAAU,QAAQ;IAChB,IAAI,EAAE,CAAC,MAAM,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BAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,yBAAyB,EAAE,OAAO,YAAQ,EAC1C,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,SAAS,GACd,KAAK,CA6DP;AAcD;;GAEG;AACH,eAAO,MAAM,oBAAoB,sEAA2C,CAAC"} |
@@ -25,4 +25,4 @@ import type { ConsoleLevel } from '../types-hoist/instrument'; | ||
| */ | ||
| export declare const consoleLoggingIntegration: (options?: Partial<CaptureConsoleOptions> | undefined) => import("../types-hoist/integration").Integration; | ||
| export declare const consoleLoggingIntegration: (options?: Partial<CaptureConsoleOptions> | undefined) => import("..").Integration; | ||
| export {}; | ||
| //# sourceMappingURL=console-integration.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"console-integration.d.ts","sourceRoot":"","sources":["../../../src/logs/console-integration.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAM9D,UAAU,qBAAqB;IAC7B,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB;AA6DD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,yBAAyB,4GAAgD,CAAC"} | ||
| {"version":3,"file":"console-integration.d.ts","sourceRoot":"","sources":["../../../src/logs/console-integration.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAM9D,UAAU,qBAAqB;IAC7B,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB;AA6DD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,yBAAyB,oFAAgD,CAAC"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"sentrySpan.d.ts","sourceRoot":"","sources":["../../../src/tracing/sentrySpan.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EACV,mBAAmB,EACnB,IAAI,EACJ,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AG,IAAI;IAKtD;;;;;;;OAOG;IACI,eAAe,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI;IAItD;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAKzC;;OAEG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAMrC,kBAAkB;IACX,GAAG,CAAC,YAAY,CAAC,EAAE,aAAa,GAAG,IAAI;IAY9C;;;;;;;OAOG;IACI,WAAW,IAAI,QAAQ;IAqB9B;;;;;;;OAOG;IACI,mBAAmB,IAAI,gBAAgB;IAgB9C,kBAAkB;IACX,WAAW,IAAI,OAAO;IAI7B;;OAEG;IACI,QAAQ,CACb,IAAI,EAAE,MAAM,EACZ,qBAAqB,CAAC,EAAE,cAAc,GAAG,aAAa,EACtD,SAAS,CAAC,EAAE,aAAa,GACxB,IAAI;IAiBP;;;;;;;OAOG;IACI,gBAAgB,IAAI,OAAO;IAIlC,6CAA6C;IAC7C,OAAO,CAAC,YAAY;IAgDpB;;OAEG;IACH,OAAO,CAAC,yBAAyB;CAgFlC"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tracing/vercel-ai/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAyO3C;;GAEG;AACH;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CA2FvF;AAkKD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAO1D"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tracing/vercel-ai/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAyO3C;;GAEG;AACH;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAgGvF;AAkKD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAO1D"} |
@@ -160,3 +160,3 @@ import type { AttachmentType } from './attachment'; | ||
| type MetricEnvelopeHeaders = BaseEnvelopeHeaders; | ||
| export type EventEnvelope = BaseEnvelope<EventEnvelopeHeaders, EventItem | AttachmentItem | UserFeedbackItem | FeedbackItem | ProfileItem>; | ||
| export type EventEnvelope = BaseEnvelope<EventEnvelopeHeaders, EventItem | AttachmentItem | UserFeedbackItem | FeedbackItem | ProfileItem | SpanContainerItem>; | ||
| export type SessionEnvelope = BaseEnvelope<SessionEnvelopeHeaders, SessionItem>; | ||
@@ -163,0 +163,0 @@ export type ClientReportEnvelope = BaseEnvelope<ClientReportEnvelopeHeaders, ClientReportItem>; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../../src/types-hoist/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,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AY,GAAG,WAAW,GAAG,iBAAiB,CAC/F,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,sBAAsB,EAAE,WAAW,CAAC,CAAC;AAChF,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,2BAA2B,EAAE,gBAAgB,CAAC,CAAC;AAC/F,MAAM,MAAM,cAAc,GAAG,CAAC,qBAAqB,EAAE,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAC7F,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,sBAAsB,EAAE,WAAW,CAAC,CAAC;AAChF,MAAM,MAAM,YAAY,GAAG,YAAY,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;AACvE,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,2BAA2B,EAAE,iBAAiB,CAAC,CAAC;AAChG,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;AACvF,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;AACrF,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;AAC7E,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;AAEtF,MAAM,MAAM,QAAQ,GAChB,aAAa,GACb,eAAe,GACf,oBAAoB,GACpB,oBAAoB,GACpB,cAAc,GACd,eAAe,GACf,YAAY,GACZ,oBAAoB,GACpB,mBAAmB,GACnB,WAAW,GACX,cAAc,CAAC;AACnB,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC"} |
@@ -503,2 +503,10 @@ import type { CaptureContext } from '../scope'; | ||
| /** | ||
| * If set to `true`, gen_ai spans will be extracted from transactions and sent as v2 span envelope items. | ||
| * | ||
| * This enables streaming gen_ai spans, avoiding payload size limits of usual transactions. | ||
| * | ||
| * @default false | ||
| */ | ||
| streamGenAiSpans?: boolean; | ||
| /** | ||
| * If logs support should be enabled. | ||
@@ -505,0 +513,0 @@ * |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/types-hoist/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnE;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;;;;;;;;OAeG;IACH,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAElD;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAE7B;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC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,CAAC;IAEvE;;;;;;;;;;OAUG;IACH,qBAAqB,CAAC,EAAE,CACtB,KAAK,EAAE,gBAAgB,EACvB,IAAI,EAAE,SAAS,KACZ,WAAW,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAEpE;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,cAAc,KAAK,UAAU,GAAG,IAAI,CAAC;CACzF;AAED;;;;GAIG;AACH,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,IAAI,EAAE,gBAAgB,KAAK,gBAAgB,CAAC,GAAG;IAC5F;;;OAGG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB,CAAC;AAEF,gDAAgD;AAChD,MAAM,WAAW,WAAW,CAAC,EAAE,SAAS,oBAAoB,GAAG,oBAAoB,CAAE,SAAQ,IAAI,CAC/F,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,EAC1B,cAAc,GAAG,WAAW,GAAG,aAAa,CAC7C;IACC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,KAAK,GAAG,WAAW,EAAE,CAAC;IAE5C;;;;OAIG;IACH,YAAY,CAAC,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC,YAAY,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,CAAC,CAAC;IAEhF;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,gBAAgB,EAAE,EAAE,KAAK,SAAS,CAAC;IAEhD;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,GAAG,eAAe,EAAE,CAAC;CAC/C"} |
@@ -45,3 +45,3 @@ export { escapeStringForRegex } from '../vendor/escapeStringForRegex'; | ||
| */ | ||
| export declare function stringMatchesSomePattern(testString: string, patterns?: Array<string | RegExp | ((value: string) => boolean)>, requireExactStringMatch?: boolean): boolean; | ||
| export declare function stringMatchesSomePattern(testString: string, patterns?: Array<string | RegExp | ((value: string) => boolean)> | Set<string | RegExp | ((value: string) => boolean)>, requireExactStringMatch?: boolean): boolean; | ||
| //# sourceMappingURL=string.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/utils/string.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAEtE;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAU,GAAG,MAAM,CAK7D;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAiC5D;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA0BrE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,EACvD,uBAAuB,GAAE,OAAe,GACvC,OAAO,CAgBT;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAM,EACpE,uBAAuB,GAAE,OAAe,GACvC,OAAO,CAET"} | ||
| {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/utils/string.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAEtE;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAU,GAAG,MAAM,CAK7D;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAiC5D;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA0BrE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,EACvD,uBAAuB,GAAE,OAAe,GACvC,OAAO,CAgBT;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,QAAQ,GACJ,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,GACrD,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAM,EAC5D,uBAAuB,GAAE,OAAe,GACvC,OAAO,CAOT"} |
+24
-2
| { | ||
| "name": "@sentry/core", | ||
| "version": "10.52.0", | ||
| "version": "10.53.0", | ||
| "description": "Base implementation for all Sentry JavaScript SDKs", | ||
@@ -13,3 +13,5 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
| "files": [ | ||
| "/build" | ||
| "/build", | ||
| "browser.js", | ||
| "server.js" | ||
| ], | ||
@@ -21,2 +23,22 @@ "main": "build/cjs/index.js", | ||
| "./package.json": "./package.json", | ||
| "./server": { | ||
| "import": { | ||
| "types": "./build/types/server.d.ts", | ||
| "default": "./build/esm/server.js" | ||
| }, | ||
| "require": { | ||
| "types": "./build/types/server.d.ts", | ||
| "default": "./build/cjs/server.js" | ||
| } | ||
| }, | ||
| "./browser": { | ||
| "import": { | ||
| "types": "./build/types/browser.d.ts", | ||
| "default": "./build/esm/browser.js" | ||
| }, | ||
| "require": { | ||
| "types": "./build/types/browser.d.ts", | ||
| "default": "./build/cjs/browser.js" | ||
| } | ||
| }, | ||
| ".": { | ||
@@ -23,0 +45,0 @@ "import": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 7 instances in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 7 instances in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
7052227
2.31%1722
2.32%81373
2.55%142
2.9%154
14.93%