UNPKG

@sentry/core

Version:
709 lines (708 loc) • 27.9 kB
import { getEnvelopeEndpointWithUrlEncodedAuth } from "./api.js"; import { DEFAULT_ENVIRONMENT } from "./constants.js"; import { getCurrentScope, getIsolationScope, getTraceContextFromScope } from "./currentScopes.js"; import { DEBUG_BUILD } from "./debug-build.js"; import { createEventEnvelope, createSessionEnvelope } from "./envelope.js"; import { afterSetupIntegrations, setupIntegration, setupIntegrations } from "./integration.js"; import { updateSession } from "./session.js"; import { getDynamicSamplingContextFromScope } from "./tracing/dynamicSamplingContext.js"; import { applyBeforeSendSpanCallback, isStaticBeforeSendSpanCallback } from "./tracing/spans/beforeSendSpan.js"; import { extractGenAiSpansFromEvent } from "./tracing/spans/extractGenAiSpans.js"; import "./transports/base.js"; import { createClientReportEnvelope } from "./utils/clientreport.js"; import { consoleSandbox, debug } from "./utils/debug-logger.js"; import { dsnToString, makeDsn } from "./utils/dsn.js"; import { addItemToEnvelope, createAttachmentEnvelopeItem, getDataCategoryByType } from "./utils/envelope.js"; import { getPossibleEventMessages, isInternalException } from "./utils/eventUtils.js"; import { isObjectLike, isParameterizedString, isPlainObject, isPrimitive } from "./utils/is.js"; import { merge } from "./utils/merge.js"; import { checkOrSetAlreadyCaught, uuid4 } from "./utils/misc.js"; import { parseSampleRate } from "./utils/parseSampleRate.js"; import { prepareEvent } from "./utils/prepareEvent.js"; import { SENTRY_BUFFER_FULL_ERROR, makePromiseBuffer } from "./utils/promisebuffer.js"; import { safeMathRandom } from "./utils/randomSafeContext.js"; import { safeCallback } from "./utils/safeCallback.js"; import { reparentChildSpans, shouldIgnoreSpan } from "./utils/should-ignore-span.js"; import { rejectedSyncPromise } from "./utils/syncpromise.js"; import { convertSpanJsonToTransactionEvent, convertTransactionEventToSpanJson } from "./utils/transactionEvent.js"; import { maybeWarnAboutIgnoredTransactionOptions } from "./utils/warnAboutIgnoredTransactionOptions.js"; import { resolveDataCollectionOptions } from "./utils/data-collection/resolveDataCollectionOptions.js"; // src/client.ts const ALREADY_SEEN_ERROR = "Not capturing exception because it's already been captured."; const MISSING_RELEASE_FOR_SESSION_ERROR = "Discarded session because of missing or non-string release"; const INTERNAL_ERROR_SYMBOL = Symbol.for("SentryInternalError"); const DO_NOT_SEND_EVENT_SYMBOL = Symbol.for("SentryDoNotSendEventError"); const CLOSED_CLIENT_SYMBOL = Symbol.for("SentryClosedClient"); /** * Whether `close()` was called on the given client. * * @hidden */ function isClientClosed(client) { return CLOSED_CLIENT_SYMBOL in client; } function _makeInternalError(message) { return { message, [INTERNAL_ERROR_SYMBOL]: true }; } function _makeDoNotSendEventError(message) { return { message, [DO_NOT_SEND_EVENT_SYMBOL]: true }; } function _makeSampledOutError(sampleRate) { return _makeDoNotSendEventError(`Discarding event because it's not included in the random sample (sampling rate = ${sampleRate})`); } function _isInternalError(error) { return isObjectLike(error) && INTERNAL_ERROR_SYMBOL in error; } function _isDoNotSendEventError(error) { return isObjectLike(error) && DO_NOT_SEND_EVENT_SYMBOL in error; } /** * Base implementation for all JavaScript SDK clients. * * Call the constructor with the corresponding options * specific to the client subclass. To access these options later, use * {@link Client.getOptions}. * * If a Dsn is specified in the options, it will be parsed and stored. Use * {@link Client.getDsn} to retrieve the Dsn at any moment. In case the Dsn is * invalid, the constructor will throw a {@link SentryException}. Note that * without a valid Dsn, the SDK will not send any events to Sentry. * * Before sending an event, it is passed through * {@link Client._prepareEvent} to add SDK information and scope data * (breadcrumbs and context). To add more custom information, override this * method and extend the resulting prepared event. * * To issue automatically created events (e.g. via instrumentation), use * {@link Client.captureEvent}. It will prepare the event and pass it through * the callback lifecycle. To issue auto-breadcrumbs, use * {@link Client.addBreadcrumb}. * * @example * class NodeClient extends Client<NodeOptions> { * public constructor(options: NodeOptions) { * super(options); * } * * // ... * } */ var Client = class { /** * Initializes this client instance. * * @param options Options for the client. */ constructor(options) { this._options = { attachStacktrace: true, ...options, traceLifecycle: options.traceLifecycle === "static" ? "static" : "stream" }; this._integrations = {}; this._numProcessing = 0; this._outcomes = {}; this._hooks = {}; this._eventProcessors = []; this._promiseBuffer = makePromiseBuffer(options.transportOptions?.bufferSize ?? 64); this._dataCollection = resolveDataCollectionOptions(options); this._unhandledSessionStatus = "crashed"; this._attachStacktraceIsDefault = options.attachStacktrace === void 0; if (options.dsn) this._dsn = makeDsn(options.dsn); else DEBUG_BUILD && debug.warn("No DSN provided, client will not send events."); const { beforeSendSpan, traceLifecycle } = this._options; if (DEBUG_BUILD && beforeSendSpan && isStaticBeforeSendSpanCallback(beforeSendSpan) !== (traceLifecycle === "static")) consoleSandbox(() => { console.warn(`Ignoring \`beforeSendSpan\`: ${traceLifecycle === "static" ? "wrap it with" : "remove"} \`Sentry.withStaticSpan\` to use it with \`traceLifecycle: "${traceLifecycle}"\`.`); }); if (this._dsn) { const url = getEnvelopeEndpointWithUrlEncodedAuth(this._dsn, options.tunnel, options._metadata ? options._metadata.sdk : void 0); this._transport = options.transport({ tunnel: this._options.tunnel, recordDroppedEvent: this.recordDroppedEvent.bind(this), ...options.transportOptions, url }); } } /** * Captures an exception event and sends it to Sentry. * * Unlike `captureException` exported from every SDK, this method requires that you pass it the current scope. */ captureException(exception, hint, scope) { const eventId = uuid4(); if (checkOrSetAlreadyCaught(exception)) { DEBUG_BUILD && debug.log(ALREADY_SEEN_ERROR); return eventId; } const hintWithEventId = { event_id: eventId, ...hint }; this._process(() => this.eventFromException(exception, hintWithEventId).then((event) => this._captureEvent(event, hintWithEventId, scope)).then((res) => res), "error"); return hintWithEventId.event_id; } /** * Captures a message event and sends it to Sentry. * * Unlike `captureMessage` exported from every SDK, this method requires that you pass it the current scope. */ captureMessage(message, level, hint, currentScope) { const hintWithEventId = { event_id: uuid4(), ...hint }; const eventMessage = isParameterizedString(message) ? message : String(message); const isMessage = isPrimitive(message); const promisedEvent = isMessage ? this.eventFromMessage(eventMessage, level, hintWithEventId).then((event) => { if (event.exception && this._attachStacktraceIsDefault) event.sdkProcessingMetadata = { ...event.sdkProcessingMetadata, hasDefaultSyntheticStacktrace: true }; return event; }) : this.eventFromException(message, hintWithEventId); this._process(() => promisedEvent.then((event) => this._captureEvent(event, hintWithEventId, currentScope)), isMessage ? "unknown" : "error"); return hintWithEventId.event_id; } /** * Captures a manually created event and sends it to Sentry. * * Unlike `captureEvent` exported from every SDK, this method requires that you pass it the current scope. */ captureEvent(event, hint, currentScope) { const eventId = uuid4(); if (hint?.originalException && checkOrSetAlreadyCaught(hint.originalException)) { DEBUG_BUILD && debug.log(ALREADY_SEEN_ERROR); return eventId; } const hintWithEventId = { event_id: eventId, ...hint }; const sdkProcessingMetadata = event.sdkProcessingMetadata || {}; const capturedSpanScope = sdkProcessingMetadata.capturedSpanScope; const capturedSpanIsolationScope = sdkProcessingMetadata.capturedSpanIsolationScope; const dataCategory = getDataCategoryByType(event.type); this._process(() => this._captureEvent(event, hintWithEventId, capturedSpanScope || currentScope, capturedSpanIsolationScope), dataCategory); return hintWithEventId.event_id; } /** * Captures a session. */ captureSession(session) { this.sendSession(session); updateSession(session, { init: false }); } /** * Get the current Dsn. */ getDsn() { return this._dsn; } /** * Get the current options. */ getOptions() { return this._options; } /** * Get the resolved data collection configuration. */ getDataCollectionOptions() { return this._dataCollection; } /** * Get the SDK metadata. * @see SdkMetadata */ getSdkMetadata() { return this._options._metadata; } /** * Returns the transport that is used by the client. * Please note that the transport gets lazy initialized so it will only be there once the first event has been sent. */ getTransport() { return this._transport; } /** * Wait for all events to be sent or the timeout to expire, whichever comes first. * * @param timeout Maximum time in ms the client should wait for events to be flushed. Omitting this parameter will * cause the client to wait until all events are sent before resolving the promise. * @returns A promise that will resolve with `true` if all events are sent before the timeout, or `false` if there are * still events in the queue when the timeout is reached. */ async flush(timeout) { const transport = this._transport; this.emit("flush"); if (!transport) return true; const clientFinished = await this._isClientDoneProcessing(timeout); const transportFlushed = await transport.flush(timeout); return clientFinished && transportFlushed; } /** * Flush the event queue and set the client to `enabled = false`. See {@link Client.flush}. * * @param {number} timeout Maximum time in ms the client should wait before shutting down. Omitting this parameter will cause * the client to wait until all events are sent before disabling itself. * @returns {Promise<boolean>} A promise which resolves to `true` if the flush completes successfully before the timeout, or `false` if * it doesn't. */ async close(timeout) { Object.defineProperty(this, CLOSED_CLIENT_SYMBOL, { value: true }); const result = await this.flush(timeout); this.getOptions().enabled = false; this.emit("close"); return result; } /** * Get all installed event processors. */ getEventProcessors() { return this._eventProcessors; } /** * Adds an event processor that applies to any event processed by this client. */ addEventProcessor(eventProcessor) { this._eventProcessors.push(eventProcessor); } /** * Initialize this client. * Call this after the client was set on a scope. */ init() { if (this._isEnabled() || this._options.integrations.some(({ name }) => name.startsWith("Spotlight"))) { this._setupIntegrations(); maybeWarnAboutIgnoredTransactionOptions(this._options); } } /** * Gets an installed integration by its name. * * @returns {Integration|undefined} The installed integration or `undefined` if no integration with that `name` was installed. */ getIntegrationByName(integrationName) { return this._integrations[integrationName]; } /** * Returns the names of all installed integrations. */ getIntegrationNames() { return Object.keys(this._integrations); } /** * Add an integration to the client. * This can be used to e.g. lazy load integrations. * In most cases, this should not be necessary, * and you're better off just passing the integrations via `integrations: []` at initialization time. * However, if you find the need to conditionally load & add an integration, you can use `addIntegration` to do so. */ addIntegration(integration) { const isAlreadyInstalled = this._integrations[integration.name]; if (!isAlreadyInstalled && integration.beforeSetup) integration.beforeSetup(this); setupIntegration(this, integration, this._integrations); if (!isAlreadyInstalled) afterSetupIntegrations(this, [integration]); } /** * Send a fully prepared event to Sentry. */ sendEvent(event, hint = {}) { this.emit("beforeSendEvent", event, hint); const genAiSpanItem = extractGenAiSpansFromEvent(event, this); let env = createEventEnvelope(event, this._dsn, this._options._metadata, this._options.tunnel); if (!isInternalException(hint)) for (const attachment of hint.attachments || []) env = addItemToEnvelope(env, createAttachmentEnvelopeItem(attachment)); if (genAiSpanItem) env = addItemToEnvelope(env, genAiSpanItem); this.sendEnvelope(env).then((sendResponse) => this.emit("afterSendEvent", event, sendResponse)); } /** * Send a session or session aggregrates to Sentry. */ sendSession(session) { const { release: clientReleaseOption, environment: clientEnvironmentOption = DEFAULT_ENVIRONMENT } = this._options; if ("aggregates" in session) { const sessionAttrs = session.attrs || {}; if (!sessionAttrs.release && !clientReleaseOption) { DEBUG_BUILD && debug.warn(MISSING_RELEASE_FOR_SESSION_ERROR); return; } sessionAttrs.release = sessionAttrs.release || clientReleaseOption; sessionAttrs.environment = sessionAttrs.environment || clientEnvironmentOption; session.attrs = sessionAttrs; } else { if (!session.release && !clientReleaseOption) { DEBUG_BUILD && debug.warn(MISSING_RELEASE_FOR_SESSION_ERROR); return; } session.release = session.release || clientReleaseOption; session.environment = session.environment || clientEnvironmentOption; } this.emit("beforeSendSession", session); const env = createSessionEnvelope(session, this._dsn, this._options._metadata, this._options.tunnel); this.sendEnvelope(env); } /** * Record on the client that an event got dropped (ie, an event that will not be sent to Sentry). */ recordDroppedEvent(reason, category, count = 1) { if (this._options.sendClientReports) { const key = `${reason}:${category}`; DEBUG_BUILD && debug.log(`Recording outcome: "${key}"${count > 1 ? ` (${count} times)` : ""}`); this._outcomes[key] = (this._outcomes[key] || 0) + count; } } /** * Register a hook on this client. */ on(hook, callback) { const hookCallbacks = this._hooks[hook] = this._hooks[hook] || /* @__PURE__ */ new Set(); const uniqueCallback = (...args) => callback(...args); hookCallbacks.add(uniqueCallback); return () => { hookCallbacks.delete(uniqueCallback); }; } /** * Emit a hook that was previously registered via `on()`. */ emit(hook, ...rest) { const callbacks = this._hooks[hook]; if (callbacks) callbacks.forEach((callback) => callback(...rest)); } /** * Send an envelope to Sentry. */ async sendEnvelope(envelope) { this.emit("beforeEnvelope", envelope); if (this._isEnabled() && this._transport) try { const result = await this._transport.send(envelope); this.emit("afterEnvelope", envelope); return result; } catch (reason) { DEBUG_BUILD && debug.error("Error while sending envelope:", reason); return {}; } DEBUG_BUILD && debug.error("Transport disabled"); return {}; } /** * Register a cleanup function to be called when the client is disposed. * This is useful for integrations that need to clean up global state. * * NOTE: This is a no-op in the base `Client` class. Subclasses like `ServerRuntimeClient` * override this method to actually register and execute cleanup callbacks. */ registerCleanup(callback) {} /** * Disposes of the client and releases all resources. * * Subclasses should override this method to clean up their own resources, including invoking * any callbacks registered via {@link Client.registerCleanup}. The base implementation is a * no-op and does NOT execute registered cleanup callbacks. * * After calling dispose(), the client should not be used anymore. */ dispose() {} /** Setup integrations for this client. */ _setupIntegrations() { const { integrations } = this._options; this._integrations = setupIntegrations(this, integrations); afterSetupIntegrations(this, integrations); } /** Updates existing session based on the provided event */ _updateSessionFromEvent(session, event) { let unhandled = event.level === "fatal"; let errored = false; const exceptions = event.exception?.values; if (exceptions) { errored = true; unhandled = false; for (const ex of exceptions) if (ex.mechanism?.handled === false) { unhandled = true; break; } } const sessionNonTerminal = session.status === "ok"; if (sessionNonTerminal && session.errors === 0 || sessionNonTerminal && unhandled) { updateSession(session, { ...unhandled && { status: this._unhandledSessionStatus }, errors: session.errors || Number(errored || unhandled) }); this.captureSession(session); } } /** * Determine if the client is finished processing. Returns a promise because it will wait `timeout` ms before saying * "no" (resolving to `false`) in order to give the client a chance to potentially finish first. * * @param timeout The time, in ms, after which to resolve to `false` if the client is still busy. Passing `0` (or not * passing anything) will make the promise wait as long as it takes for processing to finish before resolving to * `true`. * @returns A promise which will resolve to `true` if processing is already done or finishes before the timeout, and * `false` otherwise */ async _isClientDoneProcessing(timeout) { let ticked = 0; while (!timeout || ticked < timeout) { await new Promise((resolve) => setTimeout(resolve, 1)); if (!this._numProcessing) return true; ticked++; } return false; } /** Determines whether this SDK is enabled and a transport is present. */ _isEnabled() { return this.getOptions().enabled !== false && this._transport !== void 0; } /** * Adds common information to events. * * The information includes release and environment from `options`, * breadcrumbs and context (extra, tags and user) from the scope. * * Information that is already present in the event is never overwritten. For * nested objects, such as the context, keys are merged. * * @param event The original event. * @param hint May contain additional information about the original exception. * @param currentScope A scope containing event metadata. * @returns A new event with more information. */ _prepareEvent(event, hint, currentScope, isolationScope) { const options = this.getOptions(); const integrations = this.getIntegrationNames(); if (!hint.integrations && integrations.length) hint.integrations = integrations; this.emit("preprocessEvent", event, hint); if (!event.type) isolationScope.setLastEventId(event.event_id || hint.event_id); return prepareEvent(options, event, hint, currentScope, this, isolationScope).then((evt) => { if (evt === null) return evt; this.emit("postprocessEvent", evt, hint); evt.contexts = { trace: { ...evt.contexts?.trace, ...getTraceContextFromScope(currentScope) }, ...evt.contexts }; evt.sdkProcessingMetadata = { dynamicSamplingContext: getDynamicSamplingContextFromScope(this, currentScope), ...evt.sdkProcessingMetadata }; return evt; }); } /** * Processes the event and logs an error in case of rejection * @param event * @param hint * @param scope */ _captureEvent(event, hint = {}, currentScope = getCurrentScope(), isolationScope = getIsolationScope()) { if (DEBUG_BUILD && isErrorEvent(event)) debug.log(`Captured error event \`${getPossibleEventMessages(event)[0] || "<unknown>"}\``); return this._processEvent(event, hint, currentScope, isolationScope).then((finalEvent) => { return finalEvent.event_id; }, (reason) => { if (DEBUG_BUILD) { if (_isDoNotSendEventError(reason)) debug.log(reason.message); else if (_isInternalError(reason)) debug.warn(reason.message); else debug.warn(reason); } }); } /** * Processes an event (either error or message) and sends it to Sentry. * * This also adds breadcrumbs and context information to the event. However, * platform specific meta data (such as the User's IP address) must be added * by the SDK implementor. * * * @param event The event to send to Sentry. * @param hint May contain additional information about the original exception. * @param currentScope A scope containing event metadata. * @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send. */ _processEvent(event, hint, currentScope, isolationScope) { const options = this.getOptions(); const { sampleRate } = options; const isTransaction = isTransactionEvent(event); const isError = isErrorEvent(event); const beforeSendLabel = `before send for type \`${event.type || "error"}\``; let beforeSendDropReason = "before_send"; let ignoredSpanCount = 0; const parsedSampleRate = typeof sampleRate === "undefined" ? void 0 : parseSampleRate(sampleRate); const isSampledOut = isError && typeof parsedSampleRate === "number" && safeMathRandom() > parsedSampleRate; const dataCategory = getDataCategoryByType(event.type); let preparedSpanCount = 0; const session = currentScope.getSession() || isolationScope.getSession(); if (isSampledOut && session?.status !== "ok") { this.recordDroppedEvent("sample_rate", "error"); return rejectedSyncPromise(_makeSampledOutError(sampleRate)); } return this._prepareEvent(event, hint, currentScope, isolationScope).then((prepared) => { if (prepared === null) throw _makeDoNotSendEventError("An event processor returned `null`, will not send event."); preparedSpanCount = prepared.spans?.length || 0; if (isInternalException(hint)) return prepared; return processBeforeSend(options, prepared, hint, (reason) => { beforeSendDropReason = reason; }, (count) => { ignoredSpanCount = count; }); }).then((processedEvent) => { if (ignoredSpanCount) this.recordDroppedEvent("ignored", "span", ignoredSpanCount); if (!isPlainObject(processedEvent) || processedEvent === null) { this.recordDroppedEvent(beforeSendDropReason, dataCategory); if (isTransaction) this.recordDroppedEvent(beforeSendDropReason, "span", 1 + preparedSpanCount - ignoredSpanCount); if (processedEvent !== null) throw _makeInternalError(`${beforeSendLabel} must return \`null\` or a valid event.`); throw _makeDoNotSendEventError(`${beforeSendDropReason === "ignored" ? "Transaction matched `ignoreSpans`" : `${beforeSendLabel} ${beforeSendDropReason === "callback_error" ? "threw an error" : "returned `null`"}`}, will not send event.`); } if (isError && session) this._updateSessionFromEvent(session, processedEvent); if (isSampledOut) { this.recordDroppedEvent("sample_rate", "error"); throw _makeSampledOutError(sampleRate); } if (isTransaction) { const droppedSpanCount = preparedSpanCount - ignoredSpanCount - (processedEvent.spans?.length || 0); if (droppedSpanCount > 0) this.recordDroppedEvent("before_send", "span", droppedSpanCount); } const transactionInfo = processedEvent.transaction_info; if (isTransaction && transactionInfo && processedEvent.transaction !== event.transaction) { const source = "custom"; processedEvent.transaction_info = { ...transactionInfo, source }; } this.sendEvent(processedEvent, hint); return processedEvent; }).then(null, (reason) => { if (_isDoNotSendEventError(reason) || _isInternalError(reason)) throw reason; this.captureException(reason, { mechanism: { handled: false, type: "internal" }, data: { __sentry__: true }, originalException: reason }); throw _makeInternalError(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${reason}`); }); } /** * Occupies the client with processing and event */ _process(taskProducer, dataCategory) { this._numProcessing++; this._promiseBuffer.add(taskProducer).then((value) => { this._numProcessing--; return value; }, (reason) => { this._numProcessing--; if (reason === SENTRY_BUFFER_FULL_ERROR) this.recordDroppedEvent("queue_overflow", dataCategory); return reason; }); } /** * Clears outcomes on this client and returns them. */ _clearOutcomes() { const outcomes = this._outcomes; this._outcomes = {}; return Object.entries(outcomes).map(([key, quantity]) => { const [reason, category] = key.split(":"); return { reason, category, quantity }; }); } /** * Sends client reports as an envelope. */ _flushOutcomes() { DEBUG_BUILD && debug.log("Flushing outcomes..."); const outcomes = this._clearOutcomes(); if (outcomes.length === 0) { DEBUG_BUILD && debug.log("No outcomes to send"); return; } if (!this._dsn) { DEBUG_BUILD && debug.log("No dsn provided, will not send outcomes"); return; } DEBUG_BUILD && debug.log("Sending outcomes:", outcomes); const envelope = createClientReportEnvelope(outcomes, this._options.tunnel && dsnToString(this._dsn)); this.sendEnvelope(envelope); } }; /** * Process the matching `beforeSendXXX` callback. */ function processBeforeSend(options, event, hint, onDrop, onIgnoredSpans) { const { beforeSend, ignoreSpans, beforeSendTransaction } = options; const beforeSendSpan = isStaticBeforeSendSpanCallback(options.beforeSendSpan) && options.beforeSendSpan; let processedEvent = event; if (isErrorEvent(processedEvent) && beforeSend) { const errorEvent = processedEvent; return safeCallback(DEBUG_BUILD ? "The `beforeSend` callback threw an error, dropping the event:" : "", () => beforeSend(errorEvent, hint), () => { onDrop("callback_error"); return null; }); } if (isTransactionEvent(processedEvent)) { if (beforeSendSpan || ignoreSpans) { const rootSpanJson = convertTransactionEventToSpanJson(processedEvent); if (ignoreSpans?.length && shouldIgnoreSpan({ description: rootSpanJson.description, op: rootSpanJson.op, attributes: rootSpanJson.data }, ignoreSpans)) { onDrop("ignored"); return null; } if (beforeSendSpan) { const processedRootSpanJson = applyBeforeSendSpanCallback(rootSpanJson, beforeSendSpan); processedEvent = merge(event, convertSpanJsonToTransactionEvent(processedRootSpanJson)); } if (processedEvent.spans) { const processedSpans = []; const initialSpans = processedEvent.spans; for (const span of initialSpans) { if (ignoreSpans?.length && shouldIgnoreSpan({ description: span.description, op: span.op, attributes: span.data }, ignoreSpans)) { reparentChildSpans(initialSpans, span); continue; } if (beforeSendSpan) processedSpans.push(applyBeforeSendSpanCallback(span, beforeSendSpan)); else processedSpans.push(span); } onIgnoredSpans(initialSpans.length - processedSpans.length); processedEvent.spans = processedSpans; } } if (beforeSendTransaction) return safeCallback(DEBUG_BUILD ? "The `beforeSendTransaction` callback threw an error, dropping the event:" : "", () => beforeSendTransaction(processedEvent, hint), () => { onDrop("callback_error"); return null; }); } return processedEvent; } function isErrorEvent(event) { return event.type === void 0; } function isTransactionEvent(event) { return event.type === "transaction"; } export { Client, isClientClosed }; //# sourceMappingURL=client.js.map