Socket
Socket
Sign inDemoInstall

@sentry/core

Package Overview
Dependencies
2
Maintainers
11
Versions
476
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.105.0 to 8.0.0-alpha.1

cjs/asyncContext.js

103

cjs/baseclient.js

@@ -5,8 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });

const api = require('./api.js');
const currentScopes = require('./currentScopes.js');
const debugBuild = require('./debug-build.js');
const envelope = require('./envelope.js');
const exports$1 = require('./exports.js');
const hub = require('./hub.js');
const integration = require('./integration.js');
const envelope$1 = require('./metrics/envelope.js');
const session = require('./session.js');

@@ -50,8 +48,2 @@ const dynamicSamplingContext = require('./tracing/dynamicSamplingContext.js');

class BaseClient {
/**
* A reference to a metrics aggregator
*
* @experimental Note this is alpha API. It may experience breaking changes in the future.
*/
/** Options passed to the SDK. */

@@ -104,3 +96,3 @@

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
// eslint-disable-next-line @typescript-eslint/no-explicit-any
captureException(exception, hint, scope) {

@@ -131,3 +123,2 @@ // ensure we haven't captured this very object before

message,
// eslint-disable-next-line deprecation/deprecation
level,

@@ -229,5 +220,3 @@ hint,

if (transport) {
if (this.metricsAggregator) {
this.metricsAggregator.flush();
}
this.emit('flush');
return this._isClientDoneProcessing(timeout).then(clientFinished => {

@@ -247,5 +236,3 @@ return transport.flush(timeout).then(transportFlushed => clientFinished && transportFlushed);

this.getOptions().enabled = false;
if (this.metricsAggregator) {
this.metricsAggregator.close();
}
this.emit('close');
return result;

@@ -337,12 +324,6 @@ });

for (const attachment of hint.attachments || []) {
env = utils.addItemToEnvelope(
env,
utils.createAttachmentEnvelopeItem(
attachment,
this._options.transportOptions && this._options.transportOptions.textEncoder,
),
);
env = utils.addItemToEnvelope(env, utils.createAttachmentEnvelopeItem(attachment));
}
const promise = this._sendEnvelope(env);
const promise = this.sendEnvelope(env);
if (promise) {

@@ -359,5 +340,5 @@ promise.then(sendResponse => this.emit('afterSendEvent', event, sendResponse), null);

// _sendEnvelope should not throw
// sendEnvelope should not throw
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this._sendEnvelope(env);
this.sendEnvelope(env);
}

@@ -386,19 +367,2 @@

/**
* @inheritDoc
*/
captureAggregateMetrics(metricBucketItems) {
debugBuild.DEBUG_BUILD && utils.logger.log(`Flushing aggregated metrics, number of metrics: ${metricBucketItems.length}`);
const metricsEnvelope = envelope$1.createMetricEnvelope(
metricBucketItems,
this._dsn,
this._options._metadata,
this._options.tunnel,
);
// _sendEnvelope should not throw
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this._sendEnvelope(metricsEnvelope);
}
// Keep on() & emit() signatures in sync with types' client.ts interface

@@ -428,2 +392,17 @@ /* eslint-disable @typescript-eslint/unified-signatures */

/**
* @inheritdoc
*/
sendEnvelope(envelope) {
this.emit('beforeEnvelope', envelope);
if (this._isEnabled() && this._transport) {
return this._transport.send(envelope).then(null, reason => {
debugBuild.DEBUG_BUILD && utils.logger.error('Error while sending event:', reason);
});
} else {
debugBuild.DEBUG_BUILD && utils.logger.error('Transport disabled');
}
}
/* eslint-enable @typescript-eslint/unified-signatures */

@@ -527,3 +506,3 @@

scope,
isolationScope = hub.getIsolationScope(),
isolationScope = currentScopes.getIsolationScope(),
) {

@@ -560,3 +539,3 @@ const options = this.getOptions();

const dynamicSamplingContext$1 = dsc ? dsc : dynamicSamplingContext.getDynamicSamplingContextFromClient(trace_id, this, scope);
const dynamicSamplingContext$1 = dsc ? dsc : dynamicSamplingContext.getDynamicSamplingContextFromClient(trace_id, this);

@@ -715,17 +694,2 @@ evt.sdkProcessingMetadata = {

/**
* @inheritdoc
*/
_sendEnvelope(envelope) {
this.emit('beforeEnvelope', envelope);
if (this._isEnabled() && this._transport) {
return this._transport.send(envelope).then(null, reason => {
debugBuild.DEBUG_BUILD && utils.logger.error('Error while sending event:', reason);
});
} else {
debugBuild.DEBUG_BUILD && utils.logger.error('Transport disabled');
}
}
/**
* Clears outcomes on this client and returns them.

@@ -749,3 +713,3 @@ */

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -809,18 +773,3 @@ }

/**
* Add an event processor to the current client.
* This event processor will run for all events processed by this client.
*/
function addEventProcessor(callback) {
const client = exports$1.getClient();
if (!client || !client.addEventProcessor) {
return;
}
client.addEventProcessor(callback);
}
exports.BaseClient = BaseClient;
exports.addEventProcessor = addEventProcessor;
//# sourceMappingURL=baseclient.js.map

@@ -5,2 +5,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

const constants = require('./constants.js');
const currentScopes = require('./currentScopes.js');
const debugBuild = require('./debug-build.js');

@@ -23,4 +24,3 @@ const hub = require('./hub.js');

) {
// eslint-disable-next-line deprecation/deprecation
return hub.getCurrentHub().captureException(exception, prepareEvent.parseEventHintOrCaptureContext(hint));
return currentScopes.getCurrentScope().captureException(exception, prepareEvent.parseEventHintOrCaptureContext(hint));
}

@@ -35,7 +35,3 @@

*/
function captureMessage(
message,
// eslint-disable-next-line deprecation/deprecation
captureContext,
) {
function captureMessage(message, captureContext) {
// This is necessary to provide explicit scopes upgrade, without changing the original

@@ -45,4 +41,3 @@ // arity of the `captureMessage(message, level)` method.

const context = typeof captureContext !== 'string' ? { captureContext } : undefined;
// eslint-disable-next-line deprecation/deprecation
return hub.getCurrentHub().captureMessage(message, level, context);
return currentScopes.getCurrentScope().captureMessage(message, level, context);
}

@@ -58,31 +53,6 @@

function captureEvent(event, hint) {
// eslint-disable-next-line deprecation/deprecation
return hub.getCurrentHub().captureEvent(event, hint);
return currentScopes.getCurrentScope().captureEvent(event, hint);
}
/**
* Callback to set context information onto the scope.
* @param callback Callback function that receives Scope.
*
* @deprecated Use getCurrentScope() directly.
*/
function configureScope(callback) {
// eslint-disable-next-line deprecation/deprecation
hub.getCurrentHub().configureScope(callback);
}
/**
* Records a new breadcrumb which will be attached to future events.
*
* Breadcrumbs will be added to subsequent events to provide more context on
* user's actions prior to an error or crash.
*
* @param breadcrumb The breadcrumb to record.
*/
function addBreadcrumb(breadcrumb, hint) {
// eslint-disable-next-line deprecation/deprecation
hub.getCurrentHub().addBreadcrumb(breadcrumb, hint);
}
/**
* Sets context data with the given name.

@@ -94,4 +64,3 @@ * @param name of the context

function setContext(name, context) {
// eslint-disable-next-line deprecation/deprecation
hub.getCurrentHub().setContext(name, context);
currentScopes.getIsolationScope().setContext(name, context);
}

@@ -104,4 +73,3 @@

function setExtras(extras) {
// eslint-disable-next-line deprecation/deprecation
hub.getCurrentHub().setExtras(extras);
currentScopes.getIsolationScope().setExtras(extras);
}

@@ -115,4 +83,3 @@

function setExtra(key, extra) {
// eslint-disable-next-line deprecation/deprecation
hub.getCurrentHub().setExtra(key, extra);
currentScopes.getIsolationScope().setExtra(key, extra);
}

@@ -125,4 +92,3 @@

function setTags(tags) {
// eslint-disable-next-line deprecation/deprecation
hub.getCurrentHub().setTags(tags);
currentScopes.getIsolationScope().setTags(tags);
}

@@ -139,4 +105,3 @@

function setTag(key, value) {
// eslint-disable-next-line deprecation/deprecation
hub.getCurrentHub().setTag(key, value);
currentScopes.getIsolationScope().setTag(key, value);
}

@@ -150,71 +115,11 @@

function setUser(user) {
// eslint-disable-next-line deprecation/deprecation
hub.getCurrentHub().setUser(user);
currentScopes.getIsolationScope().setUser(user);
}
/**
* Creates a new scope with and executes the given operation within.
* The scope is automatically removed once the operation
* finishes or throws.
* Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be
* passed `null` to start an entirely new span tree.
*
* This is essentially a convenience function for:
*
* pushScope();
* callback();
* popScope();
*/
/**
* Either creates a new active scope, or sets the given scope as active scope in the given callback.
*/
function withScope(
...rest
) {
// eslint-disable-next-line deprecation/deprecation
const hub$1 = hub.getCurrentHub();
// If a scope is defined, we want to make this the active scope instead of the default one
if (rest.length === 2) {
const [scope, callback] = rest;
if (!scope) {
// eslint-disable-next-line deprecation/deprecation
return hub$1.withScope(callback);
}
// eslint-disable-next-line deprecation/deprecation
return hub$1.withScope(() => {
// eslint-disable-next-line deprecation/deprecation
hub$1.getStackTop().scope = scope ;
return callback(scope );
});
}
// eslint-disable-next-line deprecation/deprecation
return hub$1.withScope(rest[0]);
}
/**
* Attempts to fork the current isolation scope and the current scope based on the current async context strategy. If no
* async context strategy is set, the isolation scope and the current scope will not be forked (this is currently the
* case, for example, in the browser).
*
* Usage of this function in environments without async context strategy is discouraged and may lead to unexpected behaviour.
*
* This function is intended for Sentry SDK and SDK integration development. It is not recommended to be used in "normal"
* applications directly because it comes with pitfalls. Use at your own risk!
*
* @param callback The callback in which the passed isolation scope is active. (Note: In environments without async
* context strategy, the currently active isolation scope may change within execution of the callback.)
* @returns The same value that `callback` returns.
*/
function withIsolationScope(callback) {
return hub.runWithAsyncContext(() => {
return callback(hub.getIsolationScope());
});
}
/**
* Forks the current scope and sets the provided span as active span in the context of the provided callback.
*
* @param span Spans started in the context of the provided callback will be children of this span.
* @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,
* spans started within the callback will not be attached to a parent span.
* @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.

@@ -224,5 +129,5 @@ * @returns the value returned from the provided callback function.

function withActiveSpan(span, callback) {
return withScope(scope => {
return currentScopes.withScope(scope => {
// eslint-disable-next-line deprecation/deprecation
scope.setSpan(span);
scope.setSpan(span || undefined);
return callback(scope);

@@ -270,4 +175,4 @@ });

function captureCheckIn(checkIn, upsertMonitorConfig) {
const scope = getCurrentScope();
const client = getClient();
const scope = currentScopes.getCurrentScope();
const client = currentScopes.getClient();
if (!client) {

@@ -336,3 +241,3 @@ debugBuild.DEBUG_BUILD && utils.logger.warn('Cannot capture check-in. No client defined.');

async function flush(timeout) {
const client = getClient();
const client = currentScopes.getClient();
if (client) {

@@ -354,3 +259,3 @@ return client.flush(timeout);

async function close(timeout) {
const client = getClient();
const client = currentScopes.getClient();
if (client) {

@@ -364,33 +269,15 @@ return client.close(timeout);

/**
* This is the getter for lastEventId.
*
* @returns The last event id of a captured event.
* @deprecated This function will be removed in the next major version of the Sentry SDK.
*/
function lastEventId() {
// eslint-disable-next-line deprecation/deprecation
return hub.getCurrentHub().lastEventId();
}
/**
* Get the currently active client.
*/
function getClient() {
// eslint-disable-next-line deprecation/deprecation
return hub.getCurrentHub().getClient();
}
/**
* Returns true if Sentry has been properly initialized.
*/
function isInitialized() {
return !!getClient();
return !!currentScopes.getClient();
}
/**
* Get the currently active scope.
* Add an event processor.
* This will be added to the current isolation scope, ensuring any event that is processed in the current execution
* context will have the processor applied.
*/
function getCurrentScope() {
// eslint-disable-next-line deprecation/deprecation
return hub.getCurrentHub().getScope();
function addEventProcessor(callback) {
currentScopes.getIsolationScope().addEventProcessor(callback);
}

@@ -406,5 +293,5 @@

function startSession(context) {
const client = getClient();
const isolationScope = hub.getIsolationScope();
const currentScope = getCurrentScope();
const client = currentScopes.getClient();
const isolationScope = currentScopes.getIsolationScope();
const currentScope = currentScopes.getCurrentScope();

@@ -446,4 +333,4 @@ const { release, environment = constants.DEFAULT_ENVIRONMENT } = (client && client.getOptions()) || {};

function endSession() {
const isolationScope = hub.getIsolationScope();
const currentScope = getCurrentScope();
const isolationScope = currentScopes.getIsolationScope();
const currentScope = currentScopes.getCurrentScope();

@@ -468,9 +355,9 @@ const session$1 = currentScope.getSession() || isolationScope.getSession();

function _sendSessionUpdate() {
const isolationScope = hub.getIsolationScope();
const currentScope = getCurrentScope();
const client = getClient();
const isolationScope = currentScopes.getIsolationScope();
const currentScope = currentScopes.getCurrentScope();
const client = currentScopes.getClient();
// TODO (v8): Remove currentScope and only use the isolation scope(?).
// For v7 though, we can't "soft-break" people using getCurrentHub().getScope().setSession()
const session = currentScope.getSession() || isolationScope.getSession();
if (session && client && client.captureSession) {
if (session && client) {
client.captureSession(session);

@@ -497,3 +384,3 @@ }

exports.addBreadcrumb = addBreadcrumb;
exports.addEventProcessor = addEventProcessor;
exports.captureCheckIn = captureCheckIn;

@@ -505,9 +392,5 @@ exports.captureEvent = captureEvent;

exports.close = close;
exports.configureScope = configureScope;
exports.endSession = endSession;
exports.flush = flush;
exports.getClient = getClient;
exports.getCurrentScope = getCurrentScope;
exports.isInitialized = isInitialized;
exports.lastEventId = lastEventId;
exports.setContext = setContext;

@@ -522,5 +405,3 @@ exports.setExtra = setExtra;

exports.withActiveSpan = withActiveSpan;
exports.withIsolationScope = withIsolationScope;
exports.withMonitor = withMonitor;
exports.withScope = withScope;
//# sourceMappingURL=exports.js.map
Object.defineProperty(exports, '__esModule', { value: true });
const utils = require('@sentry/utils');
const asyncContext = require('./asyncContext.js');
const constants = require('./constants.js');

@@ -27,2 +28,7 @@ const debugBuild = require('./debug-build.js');

/**
* A layer in the process stack.
* @hidden
*/
/**
* @inheritDoc

@@ -33,4 +39,2 @@ */

/** Contains the last event id of a captured event. */
/**

@@ -264,3 +268,3 @@ * Creates a new instance of the hub, will push one {@link Layer} into the

captureException(exception, hint) {
const eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : utils.uuid4());
const eventId = hint && hint.event_id ? hint.event_id : utils.uuid4();
const syntheticException = new Error('Sentry syntheticException');

@@ -283,9 +287,4 @@ // eslint-disable-next-line deprecation/deprecation

*/
captureMessage(
message,
// eslint-disable-next-line deprecation/deprecation
level,
hint,
) {
const eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : utils.uuid4());
captureMessage(message, level, hint) {
const eventId = hint && hint.event_id ? hint.event_id : utils.uuid4();
const syntheticException = new Error(message);

@@ -310,5 +309,2 @@ // eslint-disable-next-line deprecation/deprecation

const eventId = hint && hint.event_id ? hint.event_id : utils.uuid4();
if (!event.type) {
this._lastEventId = eventId;
}
// eslint-disable-next-line deprecation/deprecation

@@ -322,11 +318,2 @@ this.getScope().captureEvent(event, { ...hint, event_id: eventId });

*
* @deprecated This will be removed in v8.
*/
lastEventId() {
return this._lastEventId;
}
/**
* @inheritDoc
*
* @deprecated Use `Sentry.addBreadcrumb()` instead.

@@ -336,3 +323,3 @@ */

// eslint-disable-next-line deprecation/deprecation
const { scope, client } = this.getStackTop();
const { client } = this.getStackTop();

@@ -354,15 +341,6 @@ if (!client) return;

if (client.emit) {
client.emit('beforeAddBreadcrumb', finalBreadcrumb, hint);
}
client.emit('beforeAddBreadcrumb', finalBreadcrumb, hint);
// TODO(v8): I know this comment doesn't make much sense because the hub will be deprecated but I still wanted to
// write it down. In theory, we would have to add the breadcrumbs to the isolation scope here, however, that would
// duplicate all of the breadcrumbs. There was the possibility of adding breadcrumbs to both, the isolation scope
// and the normal scope, and deduplicating it down the line in the event processing pipeline. However, that would
// have been very fragile, because the breadcrumb objects would have needed to keep their identity all throughout
// the event processing pipeline.
// In the new implementation, the top level `Sentry.addBreadcrumb()` should ONLY write to the isolation scope.
scope.addBreadcrumb(finalBreadcrumb, maxBreadcrumbs);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().addBreadcrumb(finalBreadcrumb, maxBreadcrumbs);
}

@@ -375,6 +353,3 @@

setUser(user) {
// TODO(v8): The top level `Sentry.setUser()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setUser(user);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setUser(user);

@@ -388,6 +363,3 @@ }

setTags(tags) {
// TODO(v8): The top level `Sentry.setTags()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setTags(tags);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setTags(tags);

@@ -401,6 +373,3 @@ }

setExtras(extras) {
// TODO(v8): The top level `Sentry.setExtras()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setExtras(extras);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setExtras(extras);

@@ -414,6 +383,3 @@ }

setTag(key, value) {
// TODO(v8): The top level `Sentry.setTag()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setTag(key, value);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setTag(key, value);

@@ -427,6 +393,3 @@ }

setExtra(key, extra) {
// TODO(v8): The top level `Sentry.setExtra()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setExtra(key, extra);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setExtra(key, extra);

@@ -441,6 +404,3 @@ }

setContext(name, context) {
// TODO(v8): The top level `Sentry.setContext()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setContext(name, context);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setContext(name, context);

@@ -451,29 +411,2 @@ }

* @inheritDoc
*
* @deprecated Use `getScope()` directly.
*/
configureScope(callback) {
// eslint-disable-next-line deprecation/deprecation
const { scope, client } = this.getStackTop();
if (client) {
callback(scope);
}
}
/**
* @inheritDoc
*/
run(callback) {
// eslint-disable-next-line deprecation/deprecation
const oldHub = makeMain(this);
try {
callback(this);
} finally {
// eslint-disable-next-line deprecation/deprecation
makeMain(oldHub);
}
}
/**
* @inheritDoc
* @deprecated Use `Sentry.getClient().getIntegrationByName()` instead.

@@ -536,10 +469,2 @@ */

* @inheritDoc
* @deprecated Use `spanToTraceHeader()` instead.
*/
traceHeaders() {
return this._callExtensionMethod('traceHeaders');
}
/**
* @inheritDoc
*

@@ -644,5 +569,5 @@ * @deprecated Use top level `captureSession` instead.

_callExtensionMethod(method, ...args) {
const carrier = getMainCarrier();
const sentry = carrier.__SENTRY__;
if (sentry && sentry.extensions && typeof sentry.extensions[method] === 'function') {
const carrier = asyncContext.getMainCarrier();
const sentry = asyncContext.getSentryCarrier(carrier);
if (sentry.extensions && typeof sentry.extensions[method] === 'function') {
return sentry.extensions[method].apply(this, args);

@@ -655,17 +580,2 @@ }

/**
* Returns the global shim registry.
*
* FIXME: This function is problematic, because despite always returning a valid Carrier,
* it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check
* at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there.
**/
function getMainCarrier() {
utils.GLOBAL_OBJ.__SENTRY__ = utils.GLOBAL_OBJ.__SENTRY__ || {
extensions: {},
hub: undefined,
};
return utils.GLOBAL_OBJ;
}
/**
* Replaces the current main hub with the passed one on the global object

@@ -678,6 +588,4 @@ *

function makeMain(hub) {
const registry = getMainCarrier();
const oldHub = getHubFromCarrier(registry);
setHubOnCarrier(registry, hub);
return oldHub;
// noop!
return hub;
}

@@ -696,138 +604,109 @@

// Get main carrier (global for every environment)
const registry = getMainCarrier();
const carrier = asyncContext.getMainCarrier();
if (registry.__SENTRY__ && registry.__SENTRY__.acs) {
const hub = registry.__SENTRY__.acs.getCurrentHub();
const acs = getAsyncContextStrategy(carrier);
return acs.getCurrentHub() || getGlobalHub();
}
if (hub) {
return hub;
}
let defaultCurrentScope;
let defaultIsolationScope;
/** Get the default current scope. */
function getDefaultCurrentScope() {
if (!defaultCurrentScope) {
defaultCurrentScope = new scope.Scope();
}
// Return hub that lives on a global object
return getGlobalHub(registry);
return defaultCurrentScope;
}
/**
* Get the currently active isolation scope.
* The isolation scope is active for the current exection context,
* meaning that it will remain stable for the same Hub.
*/
function getIsolationScope() {
// eslint-disable-next-line deprecation/deprecation
return getCurrentHub().getIsolationScope();
}
function getGlobalHub(registry = getMainCarrier()) {
// If there's no hub, or its an old API, assign a new one
if (
!hasHubOnCarrier(registry) ||
// eslint-disable-next-line deprecation/deprecation
getHubFromCarrier(registry).isOlderThan(API_VERSION)
) {
// eslint-disable-next-line deprecation/deprecation
setHubOnCarrier(registry, new Hub());
/** Get the default isolation scope. */
function getDefaultIsolationScope() {
if (!defaultIsolationScope) {
defaultIsolationScope = new scope.Scope();
}
// Return hub that lives on a global object
return getHubFromCarrier(registry);
return defaultIsolationScope;
}
/**
* @private Private API with no semver guarantees!
*
* If the carrier does not contain a hub, a new hub is created with the global hub client and scope.
* Get the global hub.
* This will be removed during the v8 cycle and is only here to make migration easier.
*/
function ensureHubOnCarrier(carrier, parent = getGlobalHub()) {
// If there's no hub on current domain, or it's an old API, assign a new one
if (
!hasHubOnCarrier(carrier) ||
// eslint-disable-next-line deprecation/deprecation
getHubFromCarrier(carrier).isOlderThan(API_VERSION)
) {
// eslint-disable-next-line deprecation/deprecation
const client = parent.getClient();
// eslint-disable-next-line deprecation/deprecation
const scope = parent.getScope();
// eslint-disable-next-line deprecation/deprecation
const isolationScope = parent.getIsolationScope();
// eslint-disable-next-line deprecation/deprecation
setHubOnCarrier(carrier, new Hub(client, scope.clone(), isolationScope.clone()));
function getGlobalHub() {
const registry = asyncContext.getMainCarrier();
const sentry = asyncContext.getSentryCarrier(registry) ;
// If there's no hub, or its an old API, assign a new one
if (sentry.hub) {
return sentry.hub;
}
}
/**
* @private Private API with no semver guarantees!
*
* Sets the global async context strategy
*/
function setAsyncContextStrategy(strategy) {
// Get main carrier (global for every environment)
const registry = getMainCarrier();
registry.__SENTRY__ = registry.__SENTRY__ || {};
registry.__SENTRY__.acs = strategy;
// eslint-disable-next-line deprecation/deprecation
sentry.hub = new Hub(undefined, getDefaultCurrentScope(), getDefaultIsolationScope());
return sentry.hub;
}
/**
* Runs the supplied callback in its own async context. Async Context strategies are defined per SDK.
*
* @param callback The callback to run in its own async context
* @param options Options to pass to the async context strategy
* @returns The result of the callback
* Get the current async context strategy.
* If none has been setup, the default will be used.
*/
function runWithAsyncContext(callback, options = {}) {
const registry = getMainCarrier();
function getAsyncContextStrategy(carrier) {
const sentry = asyncContext.getSentryCarrier(carrier);
if (registry.__SENTRY__ && registry.__SENTRY__.acs) {
return registry.__SENTRY__.acs.runWithAsyncContext(callback, options);
if (sentry.acs) {
return sentry.acs;
}
// if there was no strategy, fallback to just calling the callback
return callback();
// Otherwise, use the default one
return getHubStackAsyncContextStrategy();
}
/**
* This will tell whether a carrier has a hub on it or not
* @param carrier object
*/
function hasHubOnCarrier(carrier) {
return !!(carrier && carrier.__SENTRY__ && carrier.__SENTRY__.hub);
function withScope(callback) {
// eslint-disable-next-line deprecation/deprecation
return getGlobalHub().withScope(callback);
}
/**
* This will create a new {@link Hub} and add to the passed object on
* __SENTRY__.hub.
* @param carrier object
* @hidden
*/
function getHubFromCarrier(carrier) {
function withSetScope(scope, callback) {
const hub = getGlobalHub() ;
// eslint-disable-next-line deprecation/deprecation
return utils.getGlobalSingleton('hub', () => new Hub(), carrier);
return hub.withScope(() => {
// eslint-disable-next-line deprecation/deprecation
hub.getStackTop().scope = scope ;
return callback(scope);
});
}
/**
* This will set passed {@link Hub} on the passed object's __SENTRY__.hub attribute
* @param carrier object
* @param hub Hub
* @returns A boolean indicating success or failure
*/
function setHubOnCarrier(carrier, hub) {
if (!carrier) return false;
const __SENTRY__ = (carrier.__SENTRY__ = carrier.__SENTRY__ || {});
__SENTRY__.hub = hub;
return true;
function withIsolationScope(callback) {
// eslint-disable-next-line deprecation/deprecation
return getGlobalHub().withScope(() => {
// eslint-disable-next-line deprecation/deprecation
return callback(getGlobalHub().getIsolationScope());
});
}
/* eslint-disable deprecation/deprecation */
function getHubStackAsyncContextStrategy() {
return {
getCurrentHub: getGlobalHub,
withIsolationScope,
withScope,
withSetScope,
withSetIsolationScope: (_isolationScope, callback) => {
return withIsolationScope(callback);
},
getCurrentScope: () => getGlobalHub().getScope(),
getIsolationScope: () => getGlobalHub().getIsolationScope(),
};
}
/* eslint-enable deprecation/deprecation */
exports.API_VERSION = API_VERSION;
exports.Hub = Hub;
exports.ensureHubOnCarrier = ensureHubOnCarrier;
exports.getAsyncContextStrategy = getAsyncContextStrategy;
exports.getCurrentHub = getCurrentHub;
exports.getHubFromCarrier = getHubFromCarrier;
exports.getIsolationScope = getIsolationScope;
exports.getMainCarrier = getMainCarrier;
exports.getDefaultCurrentScope = getDefaultCurrentScope;
exports.getDefaultIsolationScope = getDefaultIsolationScope;
exports.getGlobalHub = getGlobalHub;
exports.makeMain = makeMain;
exports.runWithAsyncContext = runWithAsyncContext;
exports.setAsyncContextStrategy = setAsyncContextStrategy;
exports.setHubOnCarrier = setHubOnCarrier;
//# sourceMappingURL=hub.js.map

@@ -5,3 +5,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

const idletransaction = require('./tracing/idletransaction.js');
const span$1 = require('./tracing/span.js');
const sentrySpan = require('./tracing/sentrySpan.js');
const transaction = require('./tracing/transaction.js');

@@ -13,3 +13,2 @@ const utils = require('./tracing/utils.js');

const measurement = require('./tracing/measurement.js');
const sampling = require('./tracing/sampling.js');
const semanticAttributes = require('./semanticAttributes.js');

@@ -19,2 +18,4 @@ const envelope = require('./envelope.js');

const hub = require('./hub.js');
const currentScopes = require('./currentScopes.js');
const asyncContext = require('./asyncContext.js');
const session = require('./session.js');

@@ -36,3 +37,2 @@ const sessionflusher = require('./sessionflusher.js');

const checkin = require('./checkin.js');
const span = require('./span.js');
const hasTracingEnabled = require('./utils/hasTracingEnabled.js');

@@ -51,4 +51,13 @@ const isSentryRequestUrl = require('./utils/isSentryRequestUrl.js');

const linkederrors = require('./integrations/linkederrors.js');
const breadcrumbs = require('./breadcrumbs.js');
const index = require('./integrations/index.js');
const captureconsole = require('./integrations/captureconsole.js');
const debug = require('./integrations/debug.js');
const dedupe = require('./integrations/dedupe.js');
const extraerrordata = require('./integrations/extraerrordata.js');
const rewriteframes = require('./integrations/rewriteframes.js');
const sessiontiming = require('./integrations/sessiontiming.js');
const exports$2 = require('./metrics/exports.js');
const exportsDefault = require('./metrics/exports-default.js');
const browserAggregator = require('./metrics/browser-aggregator.js');

@@ -62,5 +71,5 @@ /** @deprecated Import the integration function directly, e.g. `inboundFiltersIntegration()` instead of `new Integrations.InboundFilter(). */

exports.TRACING_DEFAULTS = idletransaction.TRACING_DEFAULTS;
exports.Span = span$1.Span;
exports.SentrySpan = sentrySpan.SentrySpan;
exports.Transaction = transaction.Transaction;
exports.extractTraceparentData = utils.extractTraceparentData;
exports.getActiveSpan = utils.getActiveSpan;
exports.getActiveTransaction = utils.getActiveTransaction;

@@ -73,15 +82,9 @@ Object.defineProperty(exports, 'SpanStatus', {

exports.setHttpStatus = spanstatus.setHttpStatus;
exports.spanStatusfromHttpCode = spanstatus.spanStatusfromHttpCode;
exports.continueTrace = trace.continueTrace;
exports.getActiveSpan = trace.getActiveSpan;
exports.startActiveSpan = trace.startActiveSpan;
exports.startInactiveSpan = trace.startInactiveSpan;
exports.startSpan = trace.startSpan;
exports.startSpanManual = trace.startSpanManual;
exports.trace = trace.trace;
exports.getDynamicSamplingContextFromClient = dynamicSamplingContext.getDynamicSamplingContextFromClient;
exports.getDynamicSamplingContextFromSpan = dynamicSamplingContext.getDynamicSamplingContextFromSpan;
exports.setMeasurement = measurement.setMeasurement;
exports.isValidSampleRate = sampling.isValidSampleRate;
exports.SEMANTIC_ATTRIBUTE_PROFILE_ID = semanticAttributes.SEMANTIC_ATTRIBUTE_PROFILE_ID;
exports.SEMANTIC_ATTRIBUTE_SENTRY_OP = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_OP;

@@ -93,3 +96,3 @@ exports.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN;

exports.createSessionEnvelope = envelope.createSessionEnvelope;
exports.addBreadcrumb = exports$1.addBreadcrumb;
exports.addEventProcessor = exports$1.addEventProcessor;
exports.captureCheckIn = exports$1.captureCheckIn;

@@ -101,9 +104,5 @@ exports.captureEvent = exports$1.captureEvent;

exports.close = exports$1.close;
exports.configureScope = exports$1.configureScope;
exports.endSession = exports$1.endSession;
exports.flush = exports$1.flush;
exports.getClient = exports$1.getClient;
exports.getCurrentScope = exports$1.getCurrentScope;
exports.isInitialized = exports$1.isInitialized;
exports.lastEventId = exports$1.lastEventId;
exports.setContext = exports$1.setContext;

@@ -118,15 +117,18 @@ exports.setExtra = exports$1.setExtra;

exports.withActiveSpan = exports$1.withActiveSpan;
exports.withIsolationScope = exports$1.withIsolationScope;
exports.withMonitor = exports$1.withMonitor;
exports.withScope = exports$1.withScope;
exports.Hub = hub.Hub;
exports.ensureHubOnCarrier = hub.ensureHubOnCarrier;
exports.getCurrentHub = hub.getCurrentHub;
exports.getHubFromCarrier = hub.getHubFromCarrier;
exports.getIsolationScope = hub.getIsolationScope;
exports.getMainCarrier = hub.getMainCarrier;
exports.getDefaultCurrentScope = hub.getDefaultCurrentScope;
exports.getDefaultIsolationScope = hub.getDefaultIsolationScope;
exports.getGlobalHub = hub.getGlobalHub;
exports.makeMain = hub.makeMain;
exports.runWithAsyncContext = hub.runWithAsyncContext;
exports.setAsyncContextStrategy = hub.setAsyncContextStrategy;
exports.setHubOnCarrier = hub.setHubOnCarrier;
exports.getClient = currentScopes.getClient;
exports.getCurrentScope = currentScopes.getCurrentScope;
exports.getGlobalScope = currentScopes.getGlobalScope;
exports.getIsolationScope = currentScopes.getIsolationScope;
exports.setGlobalScope = currentScopes.setGlobalScope;
exports.withIsolationScope = currentScopes.withIsolationScope;
exports.withScope = currentScopes.withScope;
exports.getMainCarrier = asyncContext.getMainCarrier;
exports.setAsyncContextStrategy = asyncContext.setAsyncContextStrategy;
exports.closeSession = session.closeSession;

@@ -137,4 +139,2 @@ exports.makeSession = session.makeSession;

exports.Scope = scope.Scope;
exports.getGlobalScope = scope.getGlobalScope;
exports.setGlobalScope = scope.setGlobalScope;
exports.addGlobalEventProcessor = eventProcessors.addGlobalEventProcessor;

@@ -145,3 +145,2 @@ exports.notifyEventProcessors = eventProcessors.notifyEventProcessors;

exports.BaseClient = baseclient.BaseClient;
exports.addEventProcessor = baseclient.addEventProcessor;
exports.ServerRuntimeClient = serverRuntimeClient.ServerRuntimeClient;

@@ -162,3 +161,2 @@ exports.initAndBind = sdk.initAndBind;

exports.createCheckInEnvelope = checkin.createCheckInEnvelope;
exports.createSpanEnvelope = span.createSpanEnvelope;
exports.hasTracingEnabled = hasTracingEnabled.hasTracingEnabled;

@@ -185,4 +183,13 @@ exports.isSentryRequestUrl = isSentryRequestUrl.isSentryRequestUrl;

exports.linkedErrorsIntegration = linkederrors.linkedErrorsIntegration;
exports.addBreadcrumb = breadcrumbs.addBreadcrumb;
exports.captureConsoleIntegration = captureconsole.captureConsoleIntegration;
exports.debugIntegration = debug.debugIntegration;
exports.dedupeIntegration = dedupe.dedupeIntegration;
exports.extraErrorDataIntegration = extraerrordata.extraErrorDataIntegration;
exports.rewriteFramesIntegration = rewriteframes.rewriteFramesIntegration;
exports.sessionTimingIntegration = sessiontiming.sessionTimingIntegration;
exports.metrics = exports$2.metrics;
exports.metricsDefault = exportsDefault.metricsDefault;
exports.BrowserMetricsAggregator = browserAggregator.BrowserMetricsAggregator;
exports.Integrations = Integrations;
//# sourceMappingURL=index.js.map
Object.defineProperty(exports, '__esModule', { value: true });
const utils = require('@sentry/utils');
const currentScopes = require('./currentScopes.js');
const debugBuild = require('./debug-build.js');
const eventProcessors = require('./eventProcessors.js');
const exports$1 = require('./exports.js');
const hub = require('./hub.js');

@@ -114,3 +114,3 @@

// `setupOnce` is only called the first time
if (installedIntegrations.indexOf(integration.name) === -1) {
if (installedIntegrations.indexOf(integration.name) === -1 && typeof integration.setupOnce === 'function') {
// eslint-disable-next-line deprecation/deprecation

@@ -126,3 +126,3 @@ integration.setupOnce(eventProcessors.addGlobalEventProcessor, hub.getCurrentHub);

if (client.on && typeof integration.preprocessEvent === 'function') {
if (typeof integration.preprocessEvent === 'function') {
const callback = integration.preprocessEvent.bind(integration) ;

@@ -132,3 +132,3 @@ client.on('preprocessEvent', (event, hint) => callback(event, hint, client));

if (client.addEventProcessor && typeof integration.processEvent === 'function') {
if (typeof integration.processEvent === 'function') {
const callback = integration.processEvent.bind(integration) ;

@@ -148,5 +148,5 @@

function addIntegration(integration) {
const client = exports$1.getClient();
const client = currentScopes.getClient();
if (!client || !client.addIntegration) {
if (!client) {
debugBuild.DEBUG_BUILD && utils.logger.warn(`Cannot add integration "${integration.name}" because no SDK Client is available.`);

@@ -153,0 +153,0 @@ return;

Object.defineProperty(exports, '__esModule', { value: true });
const utils = require('@sentry/utils');
const exports$1 = require('../exports.js');
const currentScopes = require('../currentScopes.js');
const integration = require('../integration.js');

@@ -27,3 +27,3 @@

const context =
SETUP_CLIENTS.has(exports$1.getClient() ) && originalFunction !== undefined ? originalFunction : this;
SETUP_CLIENTS.has(currentScopes.getClient() ) && originalFunction !== undefined ? originalFunction : this;
return originalFunctionToString.apply(context, args);

@@ -30,0 +30,0 @@ };

@@ -9,12 +9,6 @@ Object.defineProperty(exports, '__esModule', { value: true });

// this is the result of a script being pulled in from an external domain and CORS.
const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script error\.? on line 0$/];
const DEFAULT_IGNORE_TRANSACTIONS = [
/^.*\/healthcheck$/,
/^.*\/healthy$/,
/^.*\/live$/,
/^.*\/ready$/,
/^.*\/heartbeat$/,
/^.*\/health$/,
/^.*\/healthz$/,
const DEFAULT_IGNORE_ERRORS = [
/^Script error\.?$/,
/^Javascript error: Script error\.? on line 0$/,
/^ResizeObserver loop completed with undelivered notifications.$/,
];

@@ -28,4 +22,2 @@

name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event, _hint, client) {

@@ -65,7 +57,3 @@ const clientOptions = client.getOptions();

],
ignoreTransactions: [
...(internalOptions.ignoreTransactions || []),
...(clientOptions.ignoreTransactions || []),
...(internalOptions.disableTransactionDefaults ? [] : DEFAULT_IGNORE_TRANSACTIONS),
],
ignoreTransactions: [...(internalOptions.ignoreTransactions || []), ...(clientOptions.ignoreTransactions || [])],
ignoreInternal: internalOptions.ignoreInternal !== undefined ? internalOptions.ignoreInternal : true,

@@ -162,3 +150,2 @@ };

// @ts-expect-error Try catching to save bundle size
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
lastException = event.exception.values[event.exception.values.length - 1];

@@ -188,3 +175,2 @@ } catch (e) {

// @ts-expect-error can't be a sentry error if undefined
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return event.exception.values[0].type === 'SentryError';

@@ -191,0 +177,0 @@ } catch (e) {

@@ -17,4 +17,2 @@ Object.defineProperty(exports, '__esModule', { value: true });

name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
preprocessEvent(event, hint, client) {

@@ -21,0 +19,0 @@ const options = client.getOptions();

@@ -12,9 +12,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client) {
if (typeof client.on !== 'function') {
return;
}
// We need to strip metadata from stack frames before sending them to Sentry since these are client side only.

@@ -21,0 +15,0 @@ client.on('beforeEnvelope', envelope => {

@@ -21,3 +21,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

},
transactionNamingScheme: 'methodPath',
transactionNamingScheme: 'methodPath' ,
};

@@ -28,3 +28,2 @@

const _requestDataIntegration = ((options = {}) => {
const _addRequestData = utils.addRequestDataToEvent;
const _options = {

@@ -34,5 +33,2 @@ ...DEFAULT_OPTIONS,

include: {
// @ts-expect-error It's mad because `method` isn't a known `include` key. (It's only here and not set by default in
// `addRequestDataToEvent` for legacy reasons. TODO (v8): Change that.)
method: true,
...DEFAULT_OPTIONS.include,

@@ -53,4 +49,2 @@ ...options.include,

name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event, _hint, client) {

@@ -70,11 +64,5 @@ // Note: In the long run, most of the logic here should probably move into the request data utility functions. For

// The Express request handler takes a similar `include` option to that which can be passed to this integration.
// If passed there, we store it in `sdkProcessingMetadata`. TODO(v8): Force express and GCP people to use this
// integration, so that all of this passing and conversion isn't necessary
const addRequestDataOptions =
sdkProcessingMetadata.requestDataOptionsFromExpressHandler ||
sdkProcessingMetadata.requestDataOptionsFromGCPWrapper ||
convertReqDataIntegrationOptsToAddReqDataOpts(_options);
const addRequestDataOptions = convertReqDataIntegrationOptsToAddReqDataOpts(_options);
const processedEvent = _addRequestData(event, req, addRequestDataOptions);
const processedEvent = utils.addRequestDataToEvent(event, req, addRequestDataOptions);

@@ -118,3 +106,3 @@ // Transaction events already have the right `transaction` value

/**
* Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/integrations`
* Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/core`
* so it can be used in cross-platform SDKs like `@sentry/nextjs`.

@@ -138,3 +126,3 @@ * @deprecated Use `requestDataIntegration()` instead.

const requestIncludeKeys = [];
const requestIncludeKeys = ['method'];
for (const [key, value] of Object.entries(requestOptions)) {

@@ -141,0 +129,0 @@ if (value) {

@@ -5,2 +5,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

const constants = require('./constants.js');
const envelope = require('./envelope.js');
const instance = require('./instance.js');

@@ -154,7 +155,7 @@ const metricSummary = require('./metric-summary.js');

_captureMetrics(flushedBuckets) {
if (flushedBuckets.size > 0 && this._client.captureAggregateMetrics) {
if (flushedBuckets.size > 0) {
// TODO(@anonrig): Optimization opportunity.
// This copy operation can be avoided if we store the key in the bucketItem.
const buckets = Array.from(flushedBuckets).map(([, bucketItem]) => bucketItem);
this._client.captureAggregateMetrics(buckets);
envelope.captureAggregateMetrics(this._client, buckets);
}

@@ -161,0 +162,0 @@ }

@@ -5,2 +5,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

const constants = require('./constants.js');
const envelope = require('./envelope.js');
const instance = require('./instance.js');

@@ -79,7 +80,7 @@ const metricSummary = require('./metric-summary.js');

}
if (this._client.captureAggregateMetrics) {
// TODO(@anonrig): Use Object.values() when we support ES6+
const metricBuckets = Array.from(this._buckets).map(([, bucketItem]) => bucketItem);
this._client.captureAggregateMetrics(metricBuckets);
}
// TODO(@anonrig): Use Object.values() when we support ES6+
const metricBuckets = Array.from(this._buckets).map(([, bucketItem]) => bucketItem);
envelope.captureAggregateMetrics(this._client, metricBuckets);
this._buckets.clear();

@@ -86,0 +87,0 @@ }

@@ -7,2 +7,21 @@ Object.defineProperty(exports, '__esModule', { value: true });

/**
* Captures aggregated metrics to the supplied client.
*/
function captureAggregateMetrics(
client,
metricBucketItems,
) {
utils.logger.log(`Flushing aggregated metrics, number of metrics: ${metricBucketItems.length}`);
const dsn = client.getDsn();
const metadata = client.getSdkMetadata();
const tunnel = client.getOptions().tunnel;
const metricsEnvelope = createMetricEnvelope(metricBucketItems, dsn, metadata, tunnel);
// sendEnvelope should not throw
// eslint-disable-next-line @typescript-eslint/no-floating-promises
client.sendEnvelope(metricsEnvelope);
}
/**
* Create envelope from a metric aggregate.

@@ -44,3 +63,4 @@ */

exports.captureAggregateMetrics = captureAggregateMetrics;
exports.createMetricEnvelope = createMetricEnvelope;
//# sourceMappingURL=envelope.js.map
Object.defineProperty(exports, '__esModule', { value: true });
const utils = require('@sentry/utils');
const currentScopes = require('../currentScopes.js');
const debugBuild = require('../debug-build.js');
const exports$1 = require('../exports.js');
const spanUtils = require('../utils/spanUtils.js');
const constants = require('./constants.js');
const integration = require('./integration.js');
/**
* Global metrics aggregator instance.
*
* This is initialized on the first call to any `Sentry.metric.*` method.
*/
let globalMetricsAggregator;
function addToMetricsAggregator(
Aggregator,
metricType,

@@ -16,10 +23,16 @@ name,

) {
const client = exports$1.getClient();
const scope = exports$1.getCurrentScope();
const client = currentScopes.getClient();
if (!client) {
return;
}
if (!globalMetricsAggregator) {
const aggregator = (globalMetricsAggregator = new Aggregator(client));
client.on('flush', () => aggregator.flush());
client.on('close', () => aggregator.close());
}
if (client) {
if (!client.metricsAggregator) {
debugBuild.DEBUG_BUILD &&
utils.logger.warn('No metrics aggregator enabled. Please add the MetricsAggregator integration to use metrics APIs');
return;
}
const scope = currentScopes.getCurrentScope();
const { unit, tags, timestamp } = data;

@@ -41,3 +54,3 @@ const { release, environment } = client.getOptions();

debugBuild.DEBUG_BUILD && utils.logger.log(`Adding value of ${value} to ${metricType} metric ${name}`);
client.metricsAggregator.add(metricType, name, value, unit, { ...metricTags, ...tags }, timestamp);
globalMetricsAggregator.add(metricType, name, value, unit, { ...metricTags, ...tags }, timestamp);
}

@@ -51,4 +64,4 @@ }

*/
function increment(name, value = 1, data) {
addToMetricsAggregator(constants.COUNTER_METRIC_TYPE, name, value, data);
function increment(aggregator, name, value = 1, data) {
addToMetricsAggregator(aggregator, constants.COUNTER_METRIC_TYPE, name, value, data);
}

@@ -61,4 +74,4 @@

*/
function distribution(name, value, data) {
addToMetricsAggregator(constants.DISTRIBUTION_METRIC_TYPE, name, value, data);
function distribution(aggregator, name, value, data) {
addToMetricsAggregator(aggregator, constants.DISTRIBUTION_METRIC_TYPE, name, value, data);
}

@@ -71,4 +84,4 @@

*/
function set(name, value, data) {
addToMetricsAggregator(constants.SET_METRIC_TYPE, name, value, data);
function set(aggregator, name, value, data) {
addToMetricsAggregator(aggregator, constants.SET_METRIC_TYPE, name, value, data);
}

@@ -81,4 +94,4 @@

*/
function gauge(name, value, data) {
addToMetricsAggregator(constants.GAUGE_METRIC_TYPE, name, value, data);
function gauge(aggregator, name, value, data) {
addToMetricsAggregator(aggregator, constants.GAUGE_METRIC_TYPE, name, value, data);
}

@@ -91,13 +104,5 @@

gauge,
/** @deprecated Use `metrics.metricsAggregratorIntegration()` instead. */
// eslint-disable-next-line deprecation/deprecation
MetricsAggregator: integration.MetricsAggregator,
metricsAggregatorIntegration: integration.metricsAggregatorIntegration,
};
exports.distribution = distribution;
exports.gauge = gauge;
exports.increment = increment;
exports.metrics = metrics;
exports.set = set;
//# sourceMappingURL=exports.js.map
Object.defineProperty(exports, '__esModule', { value: true });
const utils = require('@sentry/utils');
require('../debug-build.js');
require('../tracing/errors.js');
require('../tracing/spanstatus.js');
const trace = require('../tracing/trace.js');
const utils$1 = require('@sentry/utils');
const utils = require('../tracing/utils.js');

@@ -36,3 +33,3 @@ /**

output[exportKey].push(utils.dropUndefinedKeys(summary));
output[exportKey].push(utils$1.dropUndefinedKeys(summary));
}

@@ -54,3 +51,3 @@

) {
const span = trace.getActiveSpan();
const span = utils.getActiveSpan();
if (span) {

@@ -57,0 +54,0 @@ const storage = getMetricStorageForSpan(span) || new Map();

Object.defineProperty(exports, '__esModule', { value: true });
const utils = require('@sentry/utils');
const eventProcessors = require('./eventProcessors.js');
const session = require('./session.js');
const applyScopeDataToEvent = require('./utils/applyScopeDataToEvent.js');

@@ -14,11 +12,4 @@ /**

/**
* The global scope is kept in this module.
* When accessing this via `getGlobalScope()` we'll make sure to set one if none is currently present.
* Holds additional event information.
*/
let globalScope;
/**
* Holds additional event information. {@link Scope.applyToEvent} will be
* called by the client before an event will be sent.
*/
class Scope {

@@ -29,3 +20,3 @@ /** Flag if notifying is happening. */

/** Callback list that will be called after {@link applyToEvent}. */
/** Callback list that will be called during event processing. */

@@ -54,3 +45,2 @@ /** Array of breadcrumbs. */

/** Severity */
// eslint-disable-next-line deprecation/deprecation

@@ -129,3 +119,3 @@ /**

getClient() {
return this._client;
return this._client ;
}

@@ -159,3 +149,2 @@

ip_address: undefined,
segment: undefined,
username: undefined,

@@ -248,6 +237,3 @@ };

*/
setLevel(
// eslint-disable-next-line deprecation/deprecation
level,
) {
setLevel(level) {
this._level = level;

@@ -310,6 +296,11 @@ this._notifyScopeListeners();

const span = this._span;
// Cannot replace with getRootSpan because getRootSpan returns a span, not a transaction
// Also, this method will be removed anyway.
// eslint-disable-next-line deprecation/deprecation
return span && span.transaction;
if (span && (span ).transaction) {
// eslint-disable-next-line deprecation/deprecation
return (span ).transaction;
}
return undefined;
}

@@ -397,2 +388,3 @@

clear() {
// client is not cleared here on purpose!
this._breadcrumbs = [];

@@ -518,28 +510,2 @@ this._tags = {};

/**
* Applies data from the scope to the event and runs all event processors on it.
*
* @param event Event
* @param hint Object containing additional information about the original exception, for use by the event processors.
* @hidden
* @deprecated Use `applyScopeDataToEvent()` directly
*/
applyToEvent(
event,
hint = {},
additionalEventProcessors = [],
) {
applyScopeDataToEvent.applyScopeDataToEvent(event, this.getScopeData());
// TODO (v8): Update this order to be: Global > Client > Scope
const eventProcessors$1 = [
...additionalEventProcessors,
// eslint-disable-next-line deprecation/deprecation
...eventProcessors.getGlobalEventProcessors(),
...this._eventProcessors,
];
return eventProcessors.notifyEventProcessors(eventProcessors$1, event, hint);
}
/**
* Add data which will be accessible during event processing but won't get sent to Sentry

@@ -669,23 +635,2 @@ */

/**
* Get the global scope.
* This scope is applied to _all_ events.
*/
function getGlobalScope() {
if (!globalScope) {
globalScope = new Scope();
}
return globalScope;
}
/**
* This is mainly needed for tests.
* DO NOT USE this, as this is an internal API and subject to change.
* @hidden
*/
function setGlobalScope(scope) {
globalScope = scope;
}
function generatePropagationContext() {

@@ -699,4 +644,2 @@ return {

exports.Scope = Scope;
exports.getGlobalScope = getGlobalScope;
exports.setGlobalScope = setGlobalScope;
//# sourceMappingURL=scope.js.map
Object.defineProperty(exports, '__esModule', { value: true });
const utils = require('@sentry/utils');
const currentScopes = require('./currentScopes.js');
const debugBuild = require('./debug-build.js');
const exports$1 = require('./exports.js');
const hub = require('./hub.js');

@@ -32,3 +32,3 @@

}
const scope = exports$1.getCurrentScope();
const scope = currentScopes.getCurrentScope();
scope.update(options.initialScope);

@@ -38,3 +38,3 @@

setCurrentClient(client);
initializeClient(client);
client.init();
}

@@ -46,27 +46,21 @@

function setCurrentClient(client) {
currentScopes.getCurrentScope().setClient(client);
// is there a hub too?
// eslint-disable-next-line deprecation/deprecation
const hub$1 = hub.getCurrentHub();
// eslint-disable-next-line deprecation/deprecation
const top = hub$1.getStackTop();
top.client = client;
top.scope.setClient(client);
}
/**
* Initialize the client for the current scope.
* Make sure to call this after `setCurrentClient()`.
*/
function initializeClient(client) {
if (client.init) {
client.init();
// TODO v8: Remove this fallback
if (isHubClass(hub$1)) {
// eslint-disable-next-line deprecation/deprecation
} else if (client.setupIntegrations) {
// eslint-disable-next-line deprecation/deprecation
client.setupIntegrations();
const top = hub$1.getStackTop();
top.client = client;
}
}
function isHubClass(hub) {
// eslint-disable-next-line deprecation/deprecation
return !!(hub ).getStackTop;
}
exports.initAndBind = initAndBind;
exports.setCurrentClient = setCurrentClient;
//# sourceMappingURL=sdk.js.map

@@ -25,8 +25,2 @@ Object.defineProperty(exports, '__esModule', { value: true });

/**
* The id of the profile that this span occured in.
*/
const SEMANTIC_ATTRIBUTE_PROFILE_ID = 'profile_id';
exports.SEMANTIC_ATTRIBUTE_PROFILE_ID = SEMANTIC_ATTRIBUTE_PROFILE_ID;
exports.SEMANTIC_ATTRIBUTE_SENTRY_OP = SEMANTIC_ATTRIBUTE_SENTRY_OP;

@@ -33,0 +27,0 @@ exports.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN;

@@ -6,5 +6,4 @@ Object.defineProperty(exports, '__esModule', { value: true });

const checkin = require('./checkin.js');
const currentScopes = require('./currentScopes.js');
const debugBuild = require('./debug-build.js');
const exports$1 = require('./exports.js');
const aggregator = require('./metrics/aggregator.js');
const sessionflusher = require('./sessionflusher.js');

@@ -14,4 +13,4 @@ const hubextensions = require('./tracing/hubextensions.js');

const getRootSpan = require('./utils/getRootSpan.js');
const dynamicSamplingContext = require('./tracing/dynamicSamplingContext.js');
require('./tracing/spanstatus.js');
const dynamicSamplingContext = require('./tracing/dynamicSamplingContext.js');

@@ -34,6 +33,2 @@ /**

super(options);
if (options._experiments && options._experiments['metricsAggregator']) {
this.metricsAggregator = new aggregator.MetricsAggregator(this);
}
}

@@ -45,3 +40,3 @@

eventFromException(exception, hint) {
return utils.resolvedSyncPromise(utils.eventFromUnknownInput(exports$1.getClient(), this._options.stackParser, exception, hint));
return utils.resolvedSyncPromise(utils.eventFromUnknownInput(this, this._options.stackParser, exception, hint));
}

@@ -54,3 +49,2 @@

message,
// eslint-disable-next-line deprecation/deprecation
level = 'info',

@@ -67,3 +61,3 @@ hint,

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
// eslint-disable-next-line @typescript-eslint/no-explicit-any
captureException(exception, hint, scope) {

@@ -73,4 +67,4 @@ // Check if the flag `autoSessionTracking` is enabled, and if `_sessionFlusher` exists because it is initialised only

// sent to the Server only when the `requestHandler` middleware is used
if (this._options.autoSessionTracking && this._sessionFlusher && scope) {
const requestSession = scope.getRequestSession();
if (this._options.autoSessionTracking && this._sessionFlusher) {
const requestSession = currentScopes.getIsolationScope().getRequestSession();

@@ -94,3 +88,3 @@ // Necessary checks to ensure this is code block is executed only within a request

// sent to the Server only when the `requestHandler` middleware is used
if (this._options.autoSessionTracking && this._sessionFlusher && scope) {
if (this._options.autoSessionTracking && this._sessionFlusher) {
const eventType = event.type || 'exception';

@@ -102,3 +96,3 @@ const isException =

if (isException) {
const requestSession = scope.getRequestSession();
const requestSession = currentScopes.getIsolationScope().getRequestSession();

@@ -195,5 +189,5 @@ // Ensure that this is happening within the bounds of a request, and make sure not to override

// _sendEnvelope should not throw
// sendEnvelope should not throw
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this._sendEnvelope(envelope);
this.sendEnvelope(envelope);

@@ -267,3 +261,3 @@ return id;

return [dynamicSamplingContext.getDynamicSamplingContextFromClient(traceId, this, scope), traceContext];
return [dynamicSamplingContext.getDynamicSamplingContextFromClient(traceId, this), traceContext];
}

@@ -270,0 +264,0 @@ }

Object.defineProperty(exports, '__esModule', { value: true });
const utils = require('@sentry/utils');
const exports$1 = require('./exports.js');
const currentScopes = require('./currentScopes.js');

@@ -61,4 +61,4 @@ /**

}
const scope = exports$1.getCurrentScope();
const requestSession = scope.getRequestSession();
const isolationScope = currentScopes.getIsolationScope();
const requestSession = isolationScope.getRequestSession();

@@ -69,3 +69,3 @@ if (requestSession && requestSession.status) {

// case captureRequestSession is called more than once to prevent double count
scope.setRequestSession(undefined);
isolationScope.setRequestSession(undefined);
/* eslint-enable @typescript-eslint/no-unsafe-member-access */

@@ -72,0 +72,0 @@ }

@@ -5,3 +5,4 @@ Object.defineProperty(exports, '__esModule', { value: true });

const constants = require('../constants.js');
const exports$1 = require('../exports.js');
const currentScopes = require('../currentScopes.js');
const semanticAttributes = require('../semanticAttributes.js');
const getRootSpan = require('../utils/getRootSpan.js');

@@ -15,13 +16,6 @@ const spanUtils = require('../utils/spanUtils.js');

*/
function getDynamicSamplingContextFromClient(
trace_id,
client,
scope,
) {
function getDynamicSamplingContextFromClient(trace_id, client) {
const options = client.getOptions();
const { publicKey: public_key } = client.getDsn() || {};
// TODO(v8): Remove segment from User
// eslint-disable-next-line deprecation/deprecation
const { segment: user_segment } = (scope && scope.getUser()) || {};

@@ -31,3 +25,2 @@ const dsc = utils.dropUndefinedKeys({

release: options.release,
user_segment,
public_key,

@@ -37,3 +30,3 @@ trace_id,

client.emit && client.emit('createDsc', dsc);
client.emit('createDsc', dsc);

@@ -55,3 +48,3 @@ return dsc;

function getDynamicSamplingContextFromSpan(span) {
const client = exports$1.getClient();
const client = currentScopes.getClient();
if (!client) {

@@ -61,4 +54,3 @@ return {};

// passing emit=false here to only emit later once the DSC is actually populated
const dsc = getDynamicSamplingContextFromClient(spanUtils.spanToJSON(span).trace_id || '', client, exports$1.getCurrentScope());
const dsc = getDynamicSamplingContextFromClient(spanUtils.spanToJSON(span).trace_id || '', client);

@@ -82,3 +74,3 @@ // TODO (v8): Remove v7FrozenDsc as a Transaction will no longer have _frozenDynamicSamplingContext

// eslint-disable-next-line deprecation/deprecation
const { sampleRate: maybeSampleRate, source } = txn.metadata;
const { sampleRate: maybeSampleRate } = txn.metadata;
if (maybeSampleRate != null) {

@@ -91,2 +83,4 @@ dsc.sample_rate = `${maybeSampleRate}`;

const source = (jsonSpan.data || {})[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
// after JSON conversion, txn.name becomes jsonSpan.description

@@ -99,3 +93,3 @@ if (source && source !== 'url') {

client.emit && client.emit('createDsc', dsc);
client.emit('createDsc', dsc);

@@ -102,0 +96,0 @@ return dsc;

Object.defineProperty(exports, '__esModule', { value: true });
const utils = require('@sentry/utils');
const debugBuild = require('../debug-build.js');
const hub = require('../hub.js');
const spanUtils = require('../utils/spanUtils.js');
const asyncContext = require('../asyncContext.js');
const errors = require('./errors.js');

@@ -12,16 +9,2 @@ const idletransaction = require('./idletransaction.js');

/** Returns all trace headers that are currently on the top scope. */
function traceHeaders() {
// eslint-disable-next-line deprecation/deprecation
const scope = this.getScope();
// eslint-disable-next-line deprecation/deprecation
const span = scope.getSpan();
return span
? {
'sentry-trace': spanUtils.spanToTraceHeader(span),
}
: {};
}
/**

@@ -51,16 +34,2 @@ * Creates a new transaction and adds a sampling decision if it doesn't yet have one.

const configInstrumenter = options.instrumenter || 'sentry';
const transactionInstrumenter = transactionContext.instrumenter || 'sentry';
if (configInstrumenter !== transactionInstrumenter) {
debugBuild.DEBUG_BUILD &&
utils.logger.error(
`A transaction was started with instrumenter=\`${transactionInstrumenter}\`, but the SDK is configured with the \`${configInstrumenter}\` instrumenter.
The transaction will not be sampled. Please use the ${configInstrumenter} instrumentation to start transactions.`,
);
// eslint-disable-next-line deprecation/deprecation
transactionContext.sampled = false;
}
// eslint-disable-next-line deprecation/deprecation

@@ -80,5 +49,5 @@ let transaction$1 = new transaction.Transaction(transactionContext, this);

if (transaction$1.isRecording()) {
transaction$1.initSpanRecorder(options._experiments && (options._experiments.maxSpans ));
transaction$1.initSpanRecorder();
}
if (client && client.emit) {
if (client) {
client.emit('startTransaction', transaction$1);

@@ -128,5 +97,5 @@ }

if (transaction.isRecording()) {
transaction.initSpanRecorder(options._experiments && (options._experiments.maxSpans ));
transaction.initSpanRecorder();
}
if (client && client.emit) {
if (client) {
client.emit('startTransaction', transaction);

@@ -141,3 +110,3 @@ }

function addTracingExtensions() {
const carrier = hub.getMainCarrier();
const carrier = asyncContext.getMainCarrier();
if (!carrier.__SENTRY__) {

@@ -150,5 +119,2 @@ return;

}
if (!carrier.__SENTRY__.extensions.traceHeaders) {
carrier.__SENTRY__.extensions.traceHeaders = traceHeaders;
}

@@ -155,0 +121,0 @@ errors.registerErrorInstrumentation();

@@ -6,3 +6,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

const spanUtils = require('../utils/spanUtils.js');
const span = require('./span.js');
const sentrySpan = require('./sentrySpan.js');
const transaction = require('./transaction.js');

@@ -30,3 +30,3 @@

*/
class IdleTransactionSpanRecorder extends span.SpanRecorder {
class IdleTransactionSpanRecorder extends sentrySpan.SpanRecorder {
constructor(

@@ -150,4 +150,5 @@ _pushActivity,

// eslint-disable-next-line deprecation/deprecation
if (this.op === 'ui.action.click') {
const op = spanUtils.spanToJSON(this).op;
if (op === 'ui.action.click') {
this.setAttribute(FINISH_REASON_TAG, this._finishReason);

@@ -159,4 +160,3 @@ }

debugBuild.DEBUG_BUILD &&
// eslint-disable-next-line deprecation/deprecation
utils.logger.log('[Tracing] finishing IdleTransaction', new Date(endTimestampInS * 1000).toISOString(), this.op);
utils.logger.log('[Tracing] finishing IdleTransaction', new Date(endTimestampInS * 1000).toISOString(), op);

@@ -163,0 +163,0 @@ for (const callback of this._beforeFinishCallbacks) {

@@ -96,5 +96,7 @@ Object.defineProperty(exports, '__esModule', { value: true });

debugBuild.DEBUG_BUILD &&
// eslint-disable-next-line deprecation/deprecation
utils.logger.log(`[Tracing] starting ${transaction.op} transaction - ${spanUtils.spanToJSON(transaction).description}`);
if (debugBuild.DEBUG_BUILD) {
const { op, description } = spanUtils.spanToJSON(transaction);
utils.logger.log(`[Tracing] starting ${op} transaction - ${description}`);
}
return transaction;

@@ -108,3 +110,2 @@ }

// we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (utils.isNaN(rate) || !(typeof rate === 'number' || typeof rate === 'boolean')) {

@@ -129,4 +130,3 @@ debugBuild.DEBUG_BUILD &&

exports.isValidSampleRate = isValidSampleRate;
exports.sampleTransaction = sampleTransaction;
//# sourceMappingURL=sampling.js.map

@@ -91,13 +91,2 @@ Object.defineProperty(exports, '__esModule', { value: true });

/**
* Converts a HTTP status code into a {@link SpanStatusType}.
*
* @deprecated Use {@link spanStatusFromHttpCode} instead.
* This export will be removed in v8 as the signature contains a typo.
*
* @param httpStatus The HTTP response status code.
* @returns The span status or unknown_error.
*/
const spanStatusfromHttpCode = getSpanStatusFromHttpCode;
/**
* Sets the Http status attributes on the current span based on the http code.

@@ -107,14 +96,4 @@ * Additionally, the span's status is updated, depending on the http code.

function setHttpStatus(span, httpStatus) {
// TODO (v8): Remove these calls
// Relay does not require us to send the status code as a tag
// For now, just because users might expect it to land as a tag we keep sending it.
// Same with data.
// In v8, we replace both, simply with
// span.setAttribute('http.response.status_code', httpStatus);
span.setAttribute('http.response.status_code', httpStatus);
// eslint-disable-next-line deprecation/deprecation
span.setTag('http.status_code', String(httpStatus));
// eslint-disable-next-line deprecation/deprecation
span.setData('http.response.status_code', httpStatus);
const spanStatus = getSpanStatusFromHttpCode(httpStatus);

@@ -128,3 +107,2 @@ if (spanStatus !== 'unknown_error') {

exports.setHttpStatus = setHttpStatus;
exports.spanStatusfromHttpCode = spanStatusfromHttpCode;
//# sourceMappingURL=spanstatus.js.map
Object.defineProperty(exports, '__esModule', { value: true });
const utils = require('@sentry/utils');
const utils$1 = require('@sentry/utils');
const currentScopes = require('../currentScopes.js');
const debugBuild = require('../debug-build.js');
const hub = require('../hub.js');
const handleCallbackErrors = require('../utils/handleCallbackErrors.js');
const hasTracingEnabled = require('../utils/hasTracingEnabled.js');
const spanUtils = require('../utils/spanUtils.js');
require('./errors.js');
require('./spanstatus.js');
const dynamicSamplingContext = require('./dynamicSamplingContext.js');
const exports$1 = require('../exports.js');
const handleCallbackErrors = require('../utils/handleCallbackErrors.js');
const hasTracingEnabled = require('../utils/hasTracingEnabled.js');
const utils = require('./utils.js');
/**
* Wraps a function with a transaction/span and finishes the span after the function is done.
*
* Note that if you have not enabled tracing extensions via `addTracingExtensions`
* or you didn't set `tracesSampleRate`, this function will not generate spans
* and the `span` returned from the callback will be undefined.
*
* This function is meant to be used internally and may break at any time. Use at your own risk.
*
* @internal
* @private
*
* @deprecated Use `startSpan` instead.
*/
function trace(
context,
callback,
// eslint-disable-next-line @typescript-eslint/no-empty-function
onError = () => {},
// eslint-disable-next-line @typescript-eslint/no-empty-function
afterFinish = () => {},
) {
// eslint-disable-next-line deprecation/deprecation
const hub$1 = hub.getCurrentHub();
const scope = exports$1.getCurrentScope();
// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
const spanContext = normalizeContext(context);
const activeSpan = createChildSpanOrTransaction(hub$1, {
parentSpan,
spanContext,
forceTransaction: false,
scope,
});
// eslint-disable-next-line deprecation/deprecation
scope.setSpan(activeSpan);
return handleCallbackErrors.handleCallbackErrors(
() => callback(activeSpan),
error => {
activeSpan && activeSpan.setStatus('internal_error');
onError(error, activeSpan);
},
() => {
activeSpan && activeSpan.end();
// eslint-disable-next-line deprecation/deprecation
scope.setSpan(parentSpan);
afterFinish();
},
);
}
/**
* Wraps a function with a transaction/span and finishes the span after the function is done.
* The created span is the active span and will be used as parent by other spans created inside the function

@@ -82,33 +27,31 @@ * and can be accessed via `Sentry.getSpan()`, as long as the function is executed while the scope is active.

return hub.runWithAsyncContext(() => {
return exports$1.withScope(context.scope, scope => {
// eslint-disable-next-line deprecation/deprecation
const hub$1 = hub.getCurrentHub();
// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
return currentScopes.withScope(context.scope, scope => {
// eslint-disable-next-line deprecation/deprecation
const hub$1 = hub.getCurrentHub();
// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan() ;
const shouldSkipSpan = context.onlyIfParent && !parentSpan;
const activeSpan = shouldSkipSpan
? undefined
: createChildSpanOrTransaction(hub$1, {
parentSpan,
spanContext,
forceTransaction: context.forceTransaction,
scope,
});
const shouldSkipSpan = context.onlyIfParent && !parentSpan;
const activeSpan = shouldSkipSpan
? undefined
: createChildSpanOrTransaction(hub$1, {
parentSpan,
spanContext,
forceTransaction: context.forceTransaction,
scope,
});
return handleCallbackErrors.handleCallbackErrors(
() => callback(activeSpan),
() => {
// Only update the span status if it hasn't been changed yet
if (activeSpan) {
const { status } = spanUtils.spanToJSON(activeSpan);
if (!status || status === 'ok') {
activeSpan.setStatus('internal_error');
}
return handleCallbackErrors.handleCallbackErrors(
() => callback(activeSpan),
() => {
// Only update the span status if it hasn't been changed yet
if (activeSpan) {
const { status } = spanUtils.spanToJSON(activeSpan);
if (!status || status === 'ok') {
activeSpan.setStatus('internal_error');
}
},
() => activeSpan && activeSpan.end(),
);
});
}
},
() => activeSpan && activeSpan.end(),
);
});

@@ -118,7 +61,2 @@ }

/**
* @deprecated Use {@link startSpan} instead.
*/
const startActiveSpan = startSpan;
/**
* Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span

@@ -140,36 +78,34 @@ * after the function is done automatically. You'll have to call `span.end()` manually.

return hub.runWithAsyncContext(() => {
return exports$1.withScope(context.scope, scope => {
// eslint-disable-next-line deprecation/deprecation
const hub$1 = hub.getCurrentHub();
// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
return currentScopes.withScope(context.scope, scope => {
// eslint-disable-next-line deprecation/deprecation
const hub$1 = hub.getCurrentHub();
// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan() ;
const shouldSkipSpan = context.onlyIfParent && !parentSpan;
const activeSpan = shouldSkipSpan
? undefined
: createChildSpanOrTransaction(hub$1, {
parentSpan,
spanContext,
forceTransaction: context.forceTransaction,
scope,
});
const shouldSkipSpan = context.onlyIfParent && !parentSpan;
const activeSpan = shouldSkipSpan
? undefined
: createChildSpanOrTransaction(hub$1, {
parentSpan,
spanContext,
forceTransaction: context.forceTransaction,
scope,
});
function finishAndSetSpan() {
activeSpan && activeSpan.end();
}
function finishAndSetSpan() {
activeSpan && activeSpan.end();
}
return handleCallbackErrors.handleCallbackErrors(
() => callback(activeSpan, finishAndSetSpan),
() => {
// Only update the span status if it hasn't been changed yet, and the span is not yet finished
if (activeSpan && activeSpan.isRecording()) {
const { status } = spanUtils.spanToJSON(activeSpan);
if (!status || status === 'ok') {
activeSpan.setStatus('internal_error');
}
return handleCallbackErrors.handleCallbackErrors(
() => callback(activeSpan, finishAndSetSpan),
() => {
// Only update the span status if it hasn't been changed yet, and the span is not yet finished
if (activeSpan && activeSpan.isRecording()) {
const { status } = spanUtils.spanToJSON(activeSpan);
if (!status || status === 'ok') {
activeSpan.setStatus('internal_error');
}
},
);
});
}
},
);
});

@@ -198,4 +134,4 @@ }

? // eslint-disable-next-line deprecation/deprecation
context.scope.getSpan()
: getActiveSpan();
(context.scope.getSpan() )
: (utils.getActiveSpan() );

@@ -208,3 +144,3 @@ const shouldSkipSpan = context.onlyIfParent && !parentSpan;

const scope = context.scope || exports$1.getCurrentScope();
const scope = context.scope || currentScopes.getCurrentScope();

@@ -214,3 +150,3 @@ // Even though we don't actually want to make this span active on the current scope,

// as otherwise, it won't pick the correct span for the event when processing it
const temporaryScope = (scope ).clone();
const temporaryScope = scope.clone();

@@ -225,10 +161,2 @@ return createChildSpanOrTransaction(hub$1, {

/**
* Returns the currently active span.
*/
function getActiveSpan() {
// eslint-disable-next-line deprecation/deprecation
return exports$1.getCurrentScope().getSpan();
}
const continueTrace = (

@@ -252,6 +180,6 @@ {

const currentScope = exports$1.getCurrentScope();
const currentScope = currentScopes.getCurrentScope();
// eslint-disable-next-line deprecation/deprecation
const { traceparentData, dynamicSamplingContext, propagationContext } = utils.tracingContextFromHeaders(
const { traceparentData, dynamicSamplingContext, propagationContext } = utils$1.tracingContextFromHeaders(
sentryTrace,

@@ -264,3 +192,3 @@ baggage,

if (debugBuild.DEBUG_BUILD && traceparentData) {
utils.logger.log(`[Tracing] Continuing trace ${traceparentData.traceId}.`);
utils$1.logger.log(`[Tracing] Continuing trace ${traceparentData.traceId}.`);
}

@@ -270,3 +198,3 @@

...traceparentData,
metadata: utils.dropUndefinedKeys({
metadata: utils$1.dropUndefinedKeys({
dynamicSamplingContext,

@@ -280,3 +208,3 @@ }),

return hub.runWithAsyncContext(() => {
return currentScopes.withScope(() => {
return callback(transactionContext);

@@ -287,3 +215,3 @@ });

function createChildSpanOrTransaction(
hub$1,
hub,
{

@@ -302,3 +230,3 @@ parentSpan,

const isolationScope = hub.getIsolationScope();
const isolationScope = currentScopes.getIsolationScope();

@@ -309,2 +237,3 @@ let span;

span = parentSpan.startChild(spanContext);
utils.addChildSpanToSpan(parentSpan, span);
} else if (parentSpan) {

@@ -317,3 +246,3 @@ // If we forced a transaction but have a parent span, make sure to continue from the parent span, not the scope

// eslint-disable-next-line deprecation/deprecation
span = hub$1.startTransaction({
span = hub.startTransaction({
traceId,

@@ -336,3 +265,3 @@ parentSpanId,

// eslint-disable-next-line deprecation/deprecation
span = hub$1.startTransaction({
span = hub.startTransaction({
traceId,

@@ -356,3 +285,3 @@ parentSpanId,

setCapturedScopesOnSpan(span, scope, isolationScope);
utils.setCapturedScopesOnSpan(span, scope, isolationScope);

@@ -380,30 +309,6 @@ return span;

const SCOPE_ON_START_SPAN_FIELD = '_sentryScope';
const ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';
function setCapturedScopesOnSpan(span, scope, isolationScope) {
if (span) {
utils.addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, isolationScope);
utils.addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);
}
}
/**
* Grabs the scope and isolation scope off a span that were active when the span was started.
*/
function getCapturedScopesOnSpan(span) {
return {
scope: (span )[SCOPE_ON_START_SPAN_FIELD],
isolationScope: (span )[ISOLATION_SCOPE_ON_START_SPAN_FIELD],
};
}
exports.continueTrace = continueTrace;
exports.getActiveSpan = getActiveSpan;
exports.getCapturedScopesOnSpan = getCapturedScopesOnSpan;
exports.startActiveSpan = startActiveSpan;
exports.startInactiveSpan = startInactiveSpan;
exports.startSpan = startSpan;
exports.startSpanManual = startSpanManual;
exports.trace = trace;
//# sourceMappingURL=trace.js.map

@@ -10,7 +10,7 @@ Object.defineProperty(exports, '__esModule', { value: true });

const dynamicSamplingContext = require('./dynamicSamplingContext.js');
const span = require('./span.js');
const trace = require('./trace.js');
const sentrySpan = require('./sentrySpan.js');
const utils$1 = require('./utils.js');
/** JSDoc */
class Transaction extends span.Span {
class Transaction extends sentrySpan.SentrySpan {
/**

@@ -33,2 +33,3 @@ * The reference to the current hub.

super(transactionContext);
this._measurements = {};
this._contexts = {};

@@ -48,2 +49,7 @@

this._attributes = {
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',
...this._attributes,
};
// this is because transactions are also spans, and spans have a transaction pointer

@@ -64,22 +70,4 @@ // TODO (v8): Replace this with another way to set the root span

// This sadly conflicts with the getter/setter ordering :(
/* eslint-disable @typescript-eslint/member-ordering */
/**
* Getter for `name` property.
* @deprecated Use `spanToJSON(span).description` instead.
*/
get name() {
return this._name;
}
/**
* Setter for `name` property, which also sets `source` as custom.
* @deprecated Use `updateName()` and `setMetadata()` instead.
*/
set name(newName) {
// eslint-disable-next-line deprecation/deprecation
this.setName(newName);
}
/**
* Get the metadata for this transaction.

@@ -92,4 +80,2 @@ * @deprecated Use `spanGetMetadata(transaction)` instead.

// Defaults
// eslint-disable-next-line deprecation/deprecation
source: 'custom',
spanMetadata: {},

@@ -101,5 +87,2 @@

// From attributes
...(this._attributes[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] && {
source: this._attributes[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] ,
}),
...(this._attributes[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE] && {

@@ -121,15 +104,6 @@ sampleRate: this._attributes[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE] ,

/**
* Setter for `name` property, which also sets `source` on the metadata.
*
* @deprecated Use `.updateName()` and `.setAttribute()` instead.
*/
setName(name, source = 'custom') {
this._name = name;
this.setAttribute(semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);
}
/** @inheritdoc */
updateName(name) {
this._name = name;
this.setAttribute(semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'custom');
return this;

@@ -146,3 +120,3 @@ }

// eslint-disable-next-line deprecation/deprecation
this.spanRecorder = new span.SpanRecorder(maxlen);
this.spanRecorder = new sentrySpan.SpanRecorder(maxlen);
}

@@ -211,15 +185,2 @@ // eslint-disable-next-line deprecation/deprecation

/**
* @inheritDoc
*/
updateWithContext(transactionContext) {
// eslint-disable-next-line deprecation/deprecation
super.updateWithContext(transactionContext);
this._name = transactionContext.name || '';
this._trimEnd = transactionContext.trimEnd;
return this;
}
/**
* @inheritdoc

@@ -246,12 +207,2 @@ *

/**
* Get the profile id of the transaction.
*/
getProfileId() {
if (this._contexts !== undefined && this._contexts['profile'] !== undefined) {
return this._contexts['profile'].profile_id ;
}
return undefined;
}
/**
* Finish the transaction & prepare the event to send to Sentry.

@@ -275,3 +226,3 @@ */

const client = this._hub.getClient();
if (client && client.emit) {
if (client) {
client.emit('finishTransaction', this);

@@ -291,7 +242,4 @@ }

// eslint-disable-next-line deprecation/deprecation
const finishedSpans = this.spanRecorder
? // eslint-disable-next-line deprecation/deprecation
this.spanRecorder.spans.filter(span => span !== this && spanUtils.spanToJSON(span).timestamp)
: [];
// We only want to include finished spans in the event
const finishedSpans = utils$1.getSpanTree(this).filter(span => span !== this && spanUtils.spanToJSON(span).timestamp);

@@ -305,9 +253,9 @@ if (this._trimEnd && finishedSpans.length > 0) {

const { scope: capturedSpanScope, isolationScope: capturedSpanIsolationScope } = trace.getCapturedScopesOnSpan(this);
const { scope: capturedSpanScope, isolationScope: capturedSpanIsolationScope } = utils$1.getCapturedScopesOnSpan(this);
// eslint-disable-next-line deprecation/deprecation
const { metadata } = this;
// eslint-disable-next-line deprecation/deprecation
const { source } = metadata;
const source = this._attributes['sentry.source'] ;
const transaction = {

@@ -354,5 +302,3 @@ contexts: {

// eslint-disable-next-line deprecation/deprecation
debugBuild.DEBUG_BUILD && utils.logger.log(`[Tracing] Finishing ${this.op} transaction: ${this._name}.`);
debugBuild.DEBUG_BUILD && utils.logger.log(`[Tracing] Finishing ${spanUtils.spanToJSON(this).op} transaction: ${this._name}.`);
return transaction;

@@ -359,0 +305,0 @@ }

Object.defineProperty(exports, '__esModule', { value: true });
const utils = require('@sentry/utils');
const currentScopes = require('../currentScopes.js');
const hub = require('../hub.js');

@@ -21,18 +22,74 @@

/**
* The `extractTraceparentData` function and `TRACEPARENT_REGEXP` constant used
* to be declared in this file. It was later moved into `@sentry/utils` as part of a
* move to remove `@sentry/tracing` dependencies from `@sentry/node` (`extractTraceparentData`
* is the only tracing function used by `@sentry/node`).
*
* These exports are kept here for backwards compatability's sake.
*
* See https://github.com/getsentry/sentry-javascript/issues/4642 for more details.
*
* @deprecated Import this function from `@sentry/utils` instead
* Returns the currently active span.
*/
const extractTraceparentData = utils.extractTraceparentData;
function getActiveSpan() {
// eslint-disable-next-line deprecation/deprecation
return currentScopes.getCurrentScope().getSpan();
}
const CHILD_SPANS_FIELD = '_sentryChildSpans';
/**
* Adds an opaque child span reference to a span.
*/
function addChildSpanToSpan(span, childSpan) {
if (span[CHILD_SPANS_FIELD] && span[CHILD_SPANS_FIELD].size < 1000) {
span[CHILD_SPANS_FIELD].add(childSpan);
} else {
span[CHILD_SPANS_FIELD] = new Set([childSpan]);
}
}
/**
* Obtains the entire span tree, meaning a span + all of its descendants for a particular span.
*/
function getSpanTree(span) {
const resultSet = new Set();
function addSpanChildren(span) {
// This exit condition is required to not infinitely loop in case of a circular dependency.
if (resultSet.has(span)) {
return;
} else {
resultSet.add(span);
const childSpans = span[CHILD_SPANS_FIELD] ? Array.from(span[CHILD_SPANS_FIELD]) : [];
for (const childSpan of childSpans) {
addSpanChildren(childSpan);
}
}
}
addSpanChildren(span);
return Array.from(resultSet);
}
const SCOPE_ON_START_SPAN_FIELD = '_sentryScope';
const ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';
/** Store the scope & isolation scope for a span, which can the be used when it is finished. */
function setCapturedScopesOnSpan(span, scope, isolationScope) {
if (span) {
utils.addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, isolationScope);
utils.addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);
}
}
/**
* Grabs the scope and isolation scope off a span that were active when the span was started.
*/
function getCapturedScopesOnSpan(span) {
return {
scope: (span )[SCOPE_ON_START_SPAN_FIELD],
isolationScope: (span )[ISOLATION_SCOPE_ON_START_SPAN_FIELD],
};
}
exports.stripUrlQueryAndFragment = utils.stripUrlQueryAndFragment;
exports.extractTraceparentData = extractTraceparentData;
exports.addChildSpanToSpan = addChildSpanToSpan;
exports.getActiveSpan = getActiveSpan;
exports.getActiveTransaction = getActiveTransaction;
exports.getCapturedScopesOnSpan = getCapturedScopesOnSpan;
exports.getSpanTree = getSpanTree;
exports.setCapturedScopesOnSpan = setCapturedScopesOnSpan;
//# sourceMappingURL=utils.js.map

@@ -55,3 +55,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

const requestTask = () =>
makeRequest({ body: utils.serializeEnvelope(filteredEnvelope, options.textEncoder) }).then(
makeRequest({ body: utils.serializeEnvelope(filteredEnvelope) }).then(
response => {

@@ -58,0 +58,0 @@ // We don't want to throw on NOK responses, but we want to at least log them

@@ -14,3 +14,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

// eslint-disable-next-line deprecation/deprecation
return span.transaction;
return (span ).transaction ? (span ).transaction : undefined;
}

@@ -17,0 +17,0 @@

Object.defineProperty(exports, '__esModule', { value: true });
const exports$1 = require('../exports.js');
const currentScopes = require('../currentScopes.js');

@@ -19,3 +19,3 @@ // Treeshakable guard to remove all code related to tracing

const client = exports$1.getClient();
const client = currentScopes.getClient();
const options = maybeOptions || (client && client.getOptions());

@@ -22,0 +22,0 @@ return !!options && (options.enableTracing || 'tracesSampleRate' in options || 'tracesSampler' in options);

@@ -5,2 +5,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

const constants = require('../constants.js');
const currentScopes = require('../currentScopes.js');
const eventProcessors = require('../eventProcessors.js');

@@ -38,3 +39,3 @@ const scope = require('../scope.js');

hint,
scope$1,
scope,
client,

@@ -61,3 +62,3 @@ isolationScope,

// This allows us to prevent unnecessary copying of data if `captureContext` is not provided.
const finalScope = getFinalScope(scope$1, hint.captureContext);
const finalScope = getFinalScope(scope, hint.captureContext);

@@ -68,3 +69,3 @@ if (hint.mechanism) {

const clientEventProcessors = client && client.getEventProcessors ? client.getEventProcessors() : [];
const clientEventProcessors = client ? client.getEventProcessors() : [];

@@ -74,3 +75,3 @@ // This should be the last thing called, since we want that

// Merge scope data together
const data = scope.getGlobalScope().getScopeData();
const data = currentScopes.getGlobalScope().getScopeData();

@@ -326,4 +327,3 @@ if (isolationScope) {

// This is a bit weird, as we generally have `Span` instances here, but to be safe we do not assume so
// eslint-disable-next-line deprecation/deprecation
span.data = utils.normalize(data, depth, maxBreadth);
span.setAttributes(utils.normalize(data, depth, maxBreadth));
}

@@ -338,3 +338,6 @@

function getFinalScope(scope$1, captureContext) {
function getFinalScope(
scope$1,
captureContext,
) {
if (!captureContext) {

@@ -341,0 +344,0 @@ return scope$1;

@@ -72,6 +72,5 @@ Object.defineProperty(exports, '__esModule', { value: true });

* And `spanToJSON` needs the Span class from `span.ts` to check here.
* TODO v8: When we remove the deprecated stuff from `span.ts`, we can remove the circular dependency again.
*/
function spanToJSON(span) {
if (spanIsSpanClass(span)) {
if (spanIsSentrySpan(span)) {
return span.getSpanJSON();

@@ -81,8 +80,8 @@ }

// Fallback: We also check for `.toJSON()` here...
// eslint-disable-next-line deprecation/deprecation
if (typeof span.toJSON === 'function') {
// eslint-disable-next-line deprecation/deprecation
return span.toJSON();
if (typeof (span ).toJSON === 'function') {
return (span ).toJSON();
}
// TODO: Also handle OTEL spans here!
return {};

@@ -95,3 +94,3 @@ }

*/
function spanIsSpanClass(span) {
function spanIsSentrySpan(span) {
return typeof (span ).getSpanJSON === 'function';

@@ -98,0 +97,0 @@ }

Object.defineProperty(exports, '__esModule', { value: true });
const SDK_VERSION = '7.105.0';
const SDK_VERSION = '8.0.0-alpha.1';
exports.SDK_VERSION = SDK_VERSION;
//# sourceMappingURL=version.js.map
import { makeDsn, logger, checkOrSetAlreadyCaught, isParameterizedString, isPrimitive, resolvedSyncPromise, addItemToEnvelope, createAttachmentEnvelopeItem, SyncPromise, rejectedSyncPromise, SentryError, isThenable, isPlainObject } from '@sentry/utils';
import { getEnvelopeEndpointWithUrlEncodedAuth } from './api.js';
import { getIsolationScope } from './currentScopes.js';
import { DEBUG_BUILD } from './debug-build.js';
import { createEventEnvelope, createSessionEnvelope } from './envelope.js';
import { getClient } from './exports.js';
import { getIsolationScope } from './hub.js';
import { setupIntegration, afterSetupIntegrations, setupIntegrations } from './integration.js';
import { createMetricEnvelope } from './metrics/envelope.js';
import { updateSession } from './session.js';

@@ -47,8 +45,2 @@ import { getDynamicSamplingContextFromClient } from './tracing/dynamicSamplingContext.js';

class BaseClient {
/**
* A reference to a metrics aggregator
*
* @experimental Note this is alpha API. It may experience breaking changes in the future.
*/
/** Options passed to the SDK. */

@@ -101,3 +93,3 @@

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
// eslint-disable-next-line @typescript-eslint/no-explicit-any
captureException(exception, hint, scope) {

@@ -128,3 +120,2 @@ // ensure we haven't captured this very object before

message,
// eslint-disable-next-line deprecation/deprecation
level,

@@ -226,5 +217,3 @@ hint,

if (transport) {
if (this.metricsAggregator) {
this.metricsAggregator.flush();
}
this.emit('flush');
return this._isClientDoneProcessing(timeout).then(clientFinished => {

@@ -244,5 +233,3 @@ return transport.flush(timeout).then(transportFlushed => clientFinished && transportFlushed);

this.getOptions().enabled = false;
if (this.metricsAggregator) {
this.metricsAggregator.close();
}
this.emit('close');
return result;

@@ -334,12 +321,6 @@ });

for (const attachment of hint.attachments || []) {
env = addItemToEnvelope(
env,
createAttachmentEnvelopeItem(
attachment,
this._options.transportOptions && this._options.transportOptions.textEncoder,
),
);
env = addItemToEnvelope(env, createAttachmentEnvelopeItem(attachment));
}
const promise = this._sendEnvelope(env);
const promise = this.sendEnvelope(env);
if (promise) {

@@ -356,5 +337,5 @@ promise.then(sendResponse => this.emit('afterSendEvent', event, sendResponse), null);

// _sendEnvelope should not throw
// sendEnvelope should not throw
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this._sendEnvelope(env);
this.sendEnvelope(env);
}

@@ -383,19 +364,2 @@

/**
* @inheritDoc
*/
captureAggregateMetrics(metricBucketItems) {
DEBUG_BUILD && logger.log(`Flushing aggregated metrics, number of metrics: ${metricBucketItems.length}`);
const metricsEnvelope = createMetricEnvelope(
metricBucketItems,
this._dsn,
this._options._metadata,
this._options.tunnel,
);
// _sendEnvelope should not throw
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this._sendEnvelope(metricsEnvelope);
}
// Keep on() & emit() signatures in sync with types' client.ts interface

@@ -425,2 +389,17 @@ /* eslint-disable @typescript-eslint/unified-signatures */

/**
* @inheritdoc
*/
sendEnvelope(envelope) {
this.emit('beforeEnvelope', envelope);
if (this._isEnabled() && this._transport) {
return this._transport.send(envelope).then(null, reason => {
DEBUG_BUILD && logger.error('Error while sending event:', reason);
});
} else {
DEBUG_BUILD && logger.error('Transport disabled');
}
}
/* eslint-enable @typescript-eslint/unified-signatures */

@@ -556,3 +535,3 @@

const dynamicSamplingContext = dsc ? dsc : getDynamicSamplingContextFromClient(trace_id, this, scope);
const dynamicSamplingContext = dsc ? dsc : getDynamicSamplingContextFromClient(trace_id, this);

@@ -711,17 +690,2 @@ evt.sdkProcessingMetadata = {

/**
* @inheritdoc
*/
_sendEnvelope(envelope) {
this.emit('beforeEnvelope', envelope);
if (this._isEnabled() && this._transport) {
return this._transport.send(envelope).then(null, reason => {
DEBUG_BUILD && logger.error('Error while sending event:', reason);
});
} else {
DEBUG_BUILD && logger.error('Transport disabled');
}
}
/**
* Clears outcomes on this client and returns them.

@@ -745,3 +709,3 @@ */

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -805,17 +769,3 @@ }

/**
* Add an event processor to the current client.
* This event processor will run for all events processed by this client.
*/
function addEventProcessor(callback) {
const client = getClient();
if (!client || !client.addEventProcessor) {
return;
}
client.addEventProcessor(callback);
}
export { BaseClient, addEventProcessor };
export { BaseClient };
//# sourceMappingURL=baseclient.js.map
import { logger, uuid4, timestampInSeconds, isThenable, GLOBAL_OBJ } from '@sentry/utils';
import { DEFAULT_ENVIRONMENT } from './constants.js';
import { getCurrentScope, getIsolationScope, withScope, getClient } from './currentScopes.js';
import { DEBUG_BUILD } from './debug-build.js';
import { getCurrentHub, runWithAsyncContext, getIsolationScope } from './hub.js';
import { getCurrentHub } from './hub.js';
import { makeSession, updateSession, closeSession } from './session.js';

@@ -20,4 +21,3 @@ import { parseEventHintOrCaptureContext } from './utils/prepareEvent.js';

) {
// eslint-disable-next-line deprecation/deprecation
return getCurrentHub().captureException(exception, parseEventHintOrCaptureContext(hint));
return getCurrentScope().captureException(exception, parseEventHintOrCaptureContext(hint));
}

@@ -32,7 +32,3 @@

*/
function captureMessage(
message,
// eslint-disable-next-line deprecation/deprecation
captureContext,
) {
function captureMessage(message, captureContext) {
// This is necessary to provide explicit scopes upgrade, without changing the original

@@ -42,4 +38,3 @@ // arity of the `captureMessage(message, level)` method.

const context = typeof captureContext !== 'string' ? { captureContext } : undefined;
// eslint-disable-next-line deprecation/deprecation
return getCurrentHub().captureMessage(message, level, context);
return getCurrentScope().captureMessage(message, level, context);
}

@@ -55,31 +50,6 @@

function captureEvent(event, hint) {
// eslint-disable-next-line deprecation/deprecation
return getCurrentHub().captureEvent(event, hint);
return getCurrentScope().captureEvent(event, hint);
}
/**
* Callback to set context information onto the scope.
* @param callback Callback function that receives Scope.
*
* @deprecated Use getCurrentScope() directly.
*/
function configureScope(callback) {
// eslint-disable-next-line deprecation/deprecation
getCurrentHub().configureScope(callback);
}
/**
* Records a new breadcrumb which will be attached to future events.
*
* Breadcrumbs will be added to subsequent events to provide more context on
* user's actions prior to an error or crash.
*
* @param breadcrumb The breadcrumb to record.
*/
function addBreadcrumb(breadcrumb, hint) {
// eslint-disable-next-line deprecation/deprecation
getCurrentHub().addBreadcrumb(breadcrumb, hint);
}
/**
* Sets context data with the given name.

@@ -91,4 +61,3 @@ * @param name of the context

function setContext(name, context) {
// eslint-disable-next-line deprecation/deprecation
getCurrentHub().setContext(name, context);
getIsolationScope().setContext(name, context);
}

@@ -101,4 +70,3 @@

function setExtras(extras) {
// eslint-disable-next-line deprecation/deprecation
getCurrentHub().setExtras(extras);
getIsolationScope().setExtras(extras);
}

@@ -112,4 +80,3 @@

function setExtra(key, extra) {
// eslint-disable-next-line deprecation/deprecation
getCurrentHub().setExtra(key, extra);
getIsolationScope().setExtra(key, extra);
}

@@ -122,4 +89,3 @@

function setTags(tags) {
// eslint-disable-next-line deprecation/deprecation
getCurrentHub().setTags(tags);
getIsolationScope().setTags(tags);
}

@@ -136,4 +102,3 @@

function setTag(key, value) {
// eslint-disable-next-line deprecation/deprecation
getCurrentHub().setTag(key, value);
getIsolationScope().setTag(key, value);
}

@@ -147,71 +112,11 @@

function setUser(user) {
// eslint-disable-next-line deprecation/deprecation
getCurrentHub().setUser(user);
getIsolationScope().setUser(user);
}
/**
* Creates a new scope with and executes the given operation within.
* The scope is automatically removed once the operation
* finishes or throws.
* Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be
* passed `null` to start an entirely new span tree.
*
* This is essentially a convenience function for:
*
* pushScope();
* callback();
* popScope();
*/
/**
* Either creates a new active scope, or sets the given scope as active scope in the given callback.
*/
function withScope(
...rest
) {
// eslint-disable-next-line deprecation/deprecation
const hub = getCurrentHub();
// If a scope is defined, we want to make this the active scope instead of the default one
if (rest.length === 2) {
const [scope, callback] = rest;
if (!scope) {
// eslint-disable-next-line deprecation/deprecation
return hub.withScope(callback);
}
// eslint-disable-next-line deprecation/deprecation
return hub.withScope(() => {
// eslint-disable-next-line deprecation/deprecation
hub.getStackTop().scope = scope ;
return callback(scope );
});
}
// eslint-disable-next-line deprecation/deprecation
return hub.withScope(rest[0]);
}
/**
* Attempts to fork the current isolation scope and the current scope based on the current async context strategy. If no
* async context strategy is set, the isolation scope and the current scope will not be forked (this is currently the
* case, for example, in the browser).
*
* Usage of this function in environments without async context strategy is discouraged and may lead to unexpected behaviour.
*
* This function is intended for Sentry SDK and SDK integration development. It is not recommended to be used in "normal"
* applications directly because it comes with pitfalls. Use at your own risk!
*
* @param callback The callback in which the passed isolation scope is active. (Note: In environments without async
* context strategy, the currently active isolation scope may change within execution of the callback.)
* @returns The same value that `callback` returns.
*/
function withIsolationScope(callback) {
return runWithAsyncContext(() => {
return callback(getIsolationScope());
});
}
/**
* Forks the current scope and sets the provided span as active span in the context of the provided callback.
*
* @param span Spans started in the context of the provided callback will be children of this span.
* @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,
* spans started within the callback will not be attached to a parent span.
* @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.

@@ -223,3 +128,3 @@ * @returns the value returned from the provided callback function.

// eslint-disable-next-line deprecation/deprecation
scope.setSpan(span);
scope.setSpan(span || undefined);
return callback(scope);

@@ -358,21 +263,2 @@ });

/**
* This is the getter for lastEventId.
*
* @returns The last event id of a captured event.
* @deprecated This function will be removed in the next major version of the Sentry SDK.
*/
function lastEventId() {
// eslint-disable-next-line deprecation/deprecation
return getCurrentHub().lastEventId();
}
/**
* Get the currently active client.
*/
function getClient() {
// eslint-disable-next-line deprecation/deprecation
return getCurrentHub().getClient();
}
/**
* Returns true if Sentry has been properly initialized.

@@ -385,7 +271,8 @@ */

/**
* Get the currently active scope.
* Add an event processor.
* This will be added to the current isolation scope, ensuring any event that is processed in the current execution
* context will have the processor applied.
*/
function getCurrentScope() {
// eslint-disable-next-line deprecation/deprecation
return getCurrentHub().getScope();
function addEventProcessor(callback) {
getIsolationScope().addEventProcessor(callback);
}

@@ -467,3 +354,3 @@

const session = currentScope.getSession() || isolationScope.getSession();
if (session && client && client.captureSession) {
if (session && client) {
client.captureSession(session);

@@ -490,3 +377,3 @@ }

export { addBreadcrumb, captureCheckIn, captureEvent, captureException, captureMessage, captureSession, close, configureScope, endSession, flush, getClient, getCurrentScope, isInitialized, lastEventId, setContext, setExtra, setExtras, setTag, setTags, setUser, startSession, startTransaction, withActiveSpan, withIsolationScope, withMonitor, withScope };
export { addEventProcessor, captureCheckIn, captureEvent, captureException, captureMessage, captureSession, close, endSession, flush, isInitialized, setContext, setExtra, setExtras, setTag, setTags, setUser, startSession, startTransaction, withActiveSpan, withMonitor };
//# sourceMappingURL=exports.js.map

@@ -1,2 +0,3 @@

import { isThenable, uuid4, dateTimestampInSeconds, consoleSandbox, logger, GLOBAL_OBJ, getGlobalSingleton } from '@sentry/utils';
import { isThenable, uuid4, dateTimestampInSeconds, consoleSandbox, logger, GLOBAL_OBJ } from '@sentry/utils';
import { getMainCarrier, getSentryCarrier } from './asyncContext.js';
import { DEFAULT_ENVIRONMENT } from './constants.js';

@@ -25,2 +26,7 @@ import { DEBUG_BUILD } from './debug-build.js';

/**
* A layer in the process stack.
* @hidden
*/
/**
* @inheritDoc

@@ -31,4 +37,2 @@ */

/** Contains the last event id of a captured event. */
/**

@@ -262,3 +266,3 @@ * Creates a new instance of the hub, will push one {@link Layer} into the

captureException(exception, hint) {
const eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4());
const eventId = hint && hint.event_id ? hint.event_id : uuid4();
const syntheticException = new Error('Sentry syntheticException');

@@ -281,9 +285,4 @@ // eslint-disable-next-line deprecation/deprecation

*/
captureMessage(
message,
// eslint-disable-next-line deprecation/deprecation
level,
hint,
) {
const eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4());
captureMessage(message, level, hint) {
const eventId = hint && hint.event_id ? hint.event_id : uuid4();
const syntheticException = new Error(message);

@@ -308,5 +307,2 @@ // eslint-disable-next-line deprecation/deprecation

const eventId = hint && hint.event_id ? hint.event_id : uuid4();
if (!event.type) {
this._lastEventId = eventId;
}
// eslint-disable-next-line deprecation/deprecation

@@ -320,11 +316,2 @@ this.getScope().captureEvent(event, { ...hint, event_id: eventId });

*
* @deprecated This will be removed in v8.
*/
lastEventId() {
return this._lastEventId;
}
/**
* @inheritDoc
*
* @deprecated Use `Sentry.addBreadcrumb()` instead.

@@ -334,3 +321,3 @@ */

// eslint-disable-next-line deprecation/deprecation
const { scope, client } = this.getStackTop();
const { client } = this.getStackTop();

@@ -352,15 +339,6 @@ if (!client) return;

if (client.emit) {
client.emit('beforeAddBreadcrumb', finalBreadcrumb, hint);
}
client.emit('beforeAddBreadcrumb', finalBreadcrumb, hint);
// TODO(v8): I know this comment doesn't make much sense because the hub will be deprecated but I still wanted to
// write it down. In theory, we would have to add the breadcrumbs to the isolation scope here, however, that would
// duplicate all of the breadcrumbs. There was the possibility of adding breadcrumbs to both, the isolation scope
// and the normal scope, and deduplicating it down the line in the event processing pipeline. However, that would
// have been very fragile, because the breadcrumb objects would have needed to keep their identity all throughout
// the event processing pipeline.
// In the new implementation, the top level `Sentry.addBreadcrumb()` should ONLY write to the isolation scope.
scope.addBreadcrumb(finalBreadcrumb, maxBreadcrumbs);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().addBreadcrumb(finalBreadcrumb, maxBreadcrumbs);
}

@@ -373,6 +351,3 @@

setUser(user) {
// TODO(v8): The top level `Sentry.setUser()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setUser(user);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setUser(user);

@@ -386,6 +361,3 @@ }

setTags(tags) {
// TODO(v8): The top level `Sentry.setTags()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setTags(tags);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setTags(tags);

@@ -399,6 +371,3 @@ }

setExtras(extras) {
// TODO(v8): The top level `Sentry.setExtras()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setExtras(extras);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setExtras(extras);

@@ -412,6 +381,3 @@ }

setTag(key, value) {
// TODO(v8): The top level `Sentry.setTag()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setTag(key, value);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setTag(key, value);

@@ -425,6 +391,3 @@ }

setExtra(key, extra) {
// TODO(v8): The top level `Sentry.setExtra()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setExtra(key, extra);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setExtra(key, extra);

@@ -439,6 +402,3 @@ }

setContext(name, context) {
// TODO(v8): The top level `Sentry.setContext()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setContext(name, context);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setContext(name, context);

@@ -449,29 +409,2 @@ }

* @inheritDoc
*
* @deprecated Use `getScope()` directly.
*/
configureScope(callback) {
// eslint-disable-next-line deprecation/deprecation
const { scope, client } = this.getStackTop();
if (client) {
callback(scope);
}
}
/**
* @inheritDoc
*/
run(callback) {
// eslint-disable-next-line deprecation/deprecation
const oldHub = makeMain(this);
try {
callback(this);
} finally {
// eslint-disable-next-line deprecation/deprecation
makeMain(oldHub);
}
}
/**
* @inheritDoc
* @deprecated Use `Sentry.getClient().getIntegrationByName()` instead.

@@ -534,10 +467,2 @@ */

* @inheritDoc
* @deprecated Use `spanToTraceHeader()` instead.
*/
traceHeaders() {
return this._callExtensionMethod('traceHeaders');
}
/**
* @inheritDoc
*

@@ -643,4 +568,4 @@ * @deprecated Use top level `captureSession` instead.

const carrier = getMainCarrier();
const sentry = carrier.__SENTRY__;
if (sentry && sentry.extensions && typeof sentry.extensions[method] === 'function') {
const sentry = getSentryCarrier(carrier);
if (sentry.extensions && typeof sentry.extensions[method] === 'function') {
return sentry.extensions[method].apply(this, args);

@@ -653,17 +578,2 @@ }

/**
* Returns the global shim registry.
*
* FIXME: This function is problematic, because despite always returning a valid Carrier,
* it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check
* at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there.
**/
function getMainCarrier() {
GLOBAL_OBJ.__SENTRY__ = GLOBAL_OBJ.__SENTRY__ || {
extensions: {},
hub: undefined,
};
return GLOBAL_OBJ;
}
/**
* Replaces the current main hub with the passed one on the global object

@@ -676,6 +586,4 @@ *

function makeMain(hub) {
const registry = getMainCarrier();
const oldHub = getHubFromCarrier(registry);
setHubOnCarrier(registry, hub);
return oldHub;
// noop!
return hub;
}

@@ -694,128 +602,102 @@

// Get main carrier (global for every environment)
const registry = getMainCarrier();
const carrier = getMainCarrier();
if (registry.__SENTRY__ && registry.__SENTRY__.acs) {
const hub = registry.__SENTRY__.acs.getCurrentHub();
const acs = getAsyncContextStrategy(carrier);
return acs.getCurrentHub() || getGlobalHub();
}
if (hub) {
return hub;
}
let defaultCurrentScope;
let defaultIsolationScope;
/** Get the default current scope. */
function getDefaultCurrentScope() {
if (!defaultCurrentScope) {
defaultCurrentScope = new Scope();
}
// Return hub that lives on a global object
return getGlobalHub(registry);
return defaultCurrentScope;
}
/**
* Get the currently active isolation scope.
* The isolation scope is active for the current exection context,
* meaning that it will remain stable for the same Hub.
*/
function getIsolationScope() {
// eslint-disable-next-line deprecation/deprecation
return getCurrentHub().getIsolationScope();
}
function getGlobalHub(registry = getMainCarrier()) {
// If there's no hub, or its an old API, assign a new one
if (
!hasHubOnCarrier(registry) ||
// eslint-disable-next-line deprecation/deprecation
getHubFromCarrier(registry).isOlderThan(API_VERSION)
) {
// eslint-disable-next-line deprecation/deprecation
setHubOnCarrier(registry, new Hub());
/** Get the default isolation scope. */
function getDefaultIsolationScope() {
if (!defaultIsolationScope) {
defaultIsolationScope = new Scope();
}
// Return hub that lives on a global object
return getHubFromCarrier(registry);
return defaultIsolationScope;
}
/**
* @private Private API with no semver guarantees!
*
* If the carrier does not contain a hub, a new hub is created with the global hub client and scope.
* Get the global hub.
* This will be removed during the v8 cycle and is only here to make migration easier.
*/
function ensureHubOnCarrier(carrier, parent = getGlobalHub()) {
// If there's no hub on current domain, or it's an old API, assign a new one
if (
!hasHubOnCarrier(carrier) ||
// eslint-disable-next-line deprecation/deprecation
getHubFromCarrier(carrier).isOlderThan(API_VERSION)
) {
// eslint-disable-next-line deprecation/deprecation
const client = parent.getClient();
// eslint-disable-next-line deprecation/deprecation
const scope = parent.getScope();
// eslint-disable-next-line deprecation/deprecation
const isolationScope = parent.getIsolationScope();
// eslint-disable-next-line deprecation/deprecation
setHubOnCarrier(carrier, new Hub(client, scope.clone(), isolationScope.clone()));
function getGlobalHub() {
const registry = getMainCarrier();
const sentry = getSentryCarrier(registry) ;
// If there's no hub, or its an old API, assign a new one
if (sentry.hub) {
return sentry.hub;
}
}
/**
* @private Private API with no semver guarantees!
*
* Sets the global async context strategy
*/
function setAsyncContextStrategy(strategy) {
// Get main carrier (global for every environment)
const registry = getMainCarrier();
registry.__SENTRY__ = registry.__SENTRY__ || {};
registry.__SENTRY__.acs = strategy;
// eslint-disable-next-line deprecation/deprecation
sentry.hub = new Hub(undefined, getDefaultCurrentScope(), getDefaultIsolationScope());
return sentry.hub;
}
/**
* Runs the supplied callback in its own async context. Async Context strategies are defined per SDK.
*
* @param callback The callback to run in its own async context
* @param options Options to pass to the async context strategy
* @returns The result of the callback
* Get the current async context strategy.
* If none has been setup, the default will be used.
*/
function runWithAsyncContext(callback, options = {}) {
const registry = getMainCarrier();
function getAsyncContextStrategy(carrier) {
const sentry = getSentryCarrier(carrier);
if (registry.__SENTRY__ && registry.__SENTRY__.acs) {
return registry.__SENTRY__.acs.runWithAsyncContext(callback, options);
if (sentry.acs) {
return sentry.acs;
}
// if there was no strategy, fallback to just calling the callback
return callback();
// Otherwise, use the default one
return getHubStackAsyncContextStrategy();
}
/**
* This will tell whether a carrier has a hub on it or not
* @param carrier object
*/
function hasHubOnCarrier(carrier) {
return !!(carrier && carrier.__SENTRY__ && carrier.__SENTRY__.hub);
function withScope(callback) {
// eslint-disable-next-line deprecation/deprecation
return getGlobalHub().withScope(callback);
}
/**
* This will create a new {@link Hub} and add to the passed object on
* __SENTRY__.hub.
* @param carrier object
* @hidden
*/
function getHubFromCarrier(carrier) {
function withSetScope(scope, callback) {
const hub = getGlobalHub() ;
// eslint-disable-next-line deprecation/deprecation
return getGlobalSingleton('hub', () => new Hub(), carrier);
return hub.withScope(() => {
// eslint-disable-next-line deprecation/deprecation
hub.getStackTop().scope = scope ;
return callback(scope);
});
}
/**
* This will set passed {@link Hub} on the passed object's __SENTRY__.hub attribute
* @param carrier object
* @param hub Hub
* @returns A boolean indicating success or failure
*/
function setHubOnCarrier(carrier, hub) {
if (!carrier) return false;
const __SENTRY__ = (carrier.__SENTRY__ = carrier.__SENTRY__ || {});
__SENTRY__.hub = hub;
return true;
function withIsolationScope(callback) {
// eslint-disable-next-line deprecation/deprecation
return getGlobalHub().withScope(() => {
// eslint-disable-next-line deprecation/deprecation
return callback(getGlobalHub().getIsolationScope());
});
}
export { API_VERSION, Hub, ensureHubOnCarrier, getCurrentHub, getHubFromCarrier, getIsolationScope, getMainCarrier, makeMain, runWithAsyncContext, setAsyncContextStrategy, setHubOnCarrier };
/* eslint-disable deprecation/deprecation */
function getHubStackAsyncContextStrategy() {
return {
getCurrentHub: getGlobalHub,
withIsolationScope,
withScope,
withSetScope,
withSetIsolationScope: (_isolationScope, callback) => {
return withIsolationScope(callback);
},
getCurrentScope: () => getGlobalHub().getScope(),
getIsolationScope: () => getGlobalHub().getIsolationScope(),
};
}
/* eslint-enable deprecation/deprecation */
export { API_VERSION, Hub, getAsyncContextStrategy, getCurrentHub, getDefaultCurrentScope, getDefaultIsolationScope, getGlobalHub, makeMain };
//# sourceMappingURL=hub.js.map
export { addTracingExtensions, startIdleTransaction } from './tracing/hubextensions.js';
export { IdleTransaction, TRACING_DEFAULTS } from './tracing/idletransaction.js';
export { Span } from './tracing/span.js';
export { SentrySpan } from './tracing/sentrySpan.js';
export { Transaction } from './tracing/transaction.js';
export { extractTraceparentData, getActiveTransaction } from './tracing/utils.js';
export { SpanStatus, getSpanStatusFromHttpCode, setHttpStatus, spanStatusfromHttpCode } from './tracing/spanstatus.js';
export { continueTrace, getActiveSpan, startActiveSpan, startInactiveSpan, startSpan, startSpanManual, trace } from './tracing/trace.js';
export { getActiveSpan, getActiveTransaction } from './tracing/utils.js';
export { SpanStatus, getSpanStatusFromHttpCode, setHttpStatus } from './tracing/spanstatus.js';
export { continueTrace, startInactiveSpan, startSpan, startSpanManual } from './tracing/trace.js';
export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromSpan } from './tracing/dynamicSamplingContext.js';
export { setMeasurement } from './tracing/measurement.js';
export { isValidSampleRate } from './tracing/sampling.js';
export { SEMANTIC_ATTRIBUTE_PROFILE_ID, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from './semanticAttributes.js';
export { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from './semanticAttributes.js';
export { createEventEnvelope, createSessionEnvelope } from './envelope.js';
export { addBreadcrumb, captureCheckIn, captureEvent, captureException, captureMessage, captureSession, close, configureScope, endSession, flush, getClient, getCurrentScope, isInitialized, lastEventId, setContext, setExtra, setExtras, setTag, setTags, setUser, startSession, startTransaction, withActiveSpan, withIsolationScope, withMonitor, withScope } from './exports.js';
export { Hub, ensureHubOnCarrier, getCurrentHub, getHubFromCarrier, getIsolationScope, getMainCarrier, makeMain, runWithAsyncContext, setAsyncContextStrategy, setHubOnCarrier } from './hub.js';
export { addEventProcessor, captureCheckIn, captureEvent, captureException, captureMessage, captureSession, close, endSession, flush, isInitialized, setContext, setExtra, setExtras, setTag, setTags, setUser, startSession, startTransaction, withActiveSpan, withMonitor } from './exports.js';
export { Hub, getCurrentHub, getDefaultCurrentScope, getDefaultIsolationScope, getGlobalHub, makeMain } from './hub.js';
export { getClient, getCurrentScope, getGlobalScope, getIsolationScope, setGlobalScope, withIsolationScope, withScope } from './currentScopes.js';
export { getMainCarrier, setAsyncContextStrategy } from './asyncContext.js';
export { closeSession, makeSession, updateSession } from './session.js';
export { SessionFlusher } from './sessionflusher.js';
export { Scope, getGlobalScope, setGlobalScope } from './scope.js';
export { Scope } from './scope.js';
export { addGlobalEventProcessor, notifyEventProcessors } from './eventProcessors.js';
export { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint } from './api.js';
export { BaseClient, addEventProcessor } from './baseclient.js';
export { BaseClient } from './baseclient.js';
export { ServerRuntimeClient } from './server-runtime-client.js';

@@ -31,3 +32,2 @@ export { initAndBind, setCurrentClient } from './sdk.js';

export { createCheckInEnvelope } from './checkin.js';
export { createSpanEnvelope } from './span.js';
export { hasTracingEnabled } from './utils/hasTracingEnabled.js';

@@ -46,4 +46,13 @@ export { isSentryRequestUrl } from './utils/isSentryRequestUrl.js';

export { LinkedErrors, linkedErrorsIntegration } from './integrations/linkederrors.js';
export { addBreadcrumb } from './breadcrumbs.js';
import * as index from './integrations/index.js';
export { captureConsoleIntegration } from './integrations/captureconsole.js';
export { debugIntegration } from './integrations/debug.js';
export { dedupeIntegration } from './integrations/dedupe.js';
export { extraErrorDataIntegration } from './integrations/extraerrordata.js';
export { rewriteFramesIntegration } from './integrations/rewriteframes.js';
export { sessionTimingIntegration } from './integrations/sessiontiming.js';
export { metrics } from './metrics/exports.js';
export { metricsDefault } from './metrics/exports-default.js';
export { BrowserMetricsAggregator } from './metrics/browser-aggregator.js';

@@ -50,0 +59,0 @@ /** @deprecated Import the integration function directly, e.g. `inboundFiltersIntegration()` instead of `new Integrations.InboundFilter(). */

import { arrayify, logger } from '@sentry/utils';
import { getClient } from './currentScopes.js';
import { DEBUG_BUILD } from './debug-build.js';
import { addGlobalEventProcessor } from './eventProcessors.js';
import { getClient } from './exports.js';
import { getCurrentHub } from './hub.js';

@@ -112,3 +112,3 @@

// `setupOnce` is only called the first time
if (installedIntegrations.indexOf(integration.name) === -1) {
if (installedIntegrations.indexOf(integration.name) === -1 && typeof integration.setupOnce === 'function') {
// eslint-disable-next-line deprecation/deprecation

@@ -124,3 +124,3 @@ integration.setupOnce(addGlobalEventProcessor, getCurrentHub);

if (client.on && typeof integration.preprocessEvent === 'function') {
if (typeof integration.preprocessEvent === 'function') {
const callback = integration.preprocessEvent.bind(integration) ;

@@ -130,3 +130,3 @@ client.on('preprocessEvent', (event, hint) => callback(event, hint, client));

if (client.addEventProcessor && typeof integration.processEvent === 'function') {
if (typeof integration.processEvent === 'function') {
const callback = integration.processEvent.bind(integration) ;

@@ -148,3 +148,3 @@

if (!client || !client.addIntegration) {
if (!client) {
DEBUG_BUILD && logger.warn(`Cannot add integration "${integration.name}" because no SDK Client is available.`);

@@ -151,0 +151,0 @@ return;

import { getOriginalFunction } from '@sentry/utils';
import { getClient } from '../exports.js';
import { getClient } from '../currentScopes.js';
import { convertIntegrationFnToClass, defineIntegration } from '../integration.js';

@@ -4,0 +4,0 @@

@@ -7,12 +7,6 @@ import { logger, getEventDescription, stringMatchesSomePattern } from '@sentry/utils';

// this is the result of a script being pulled in from an external domain and CORS.
const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script error\.? on line 0$/];
const DEFAULT_IGNORE_TRANSACTIONS = [
/^.*\/healthcheck$/,
/^.*\/healthy$/,
/^.*\/live$/,
/^.*\/ready$/,
/^.*\/heartbeat$/,
/^.*\/health$/,
/^.*\/healthz$/,
const DEFAULT_IGNORE_ERRORS = [
/^Script error\.?$/,
/^Javascript error: Script error\.? on line 0$/,
/^ResizeObserver loop completed with undelivered notifications.$/,
];

@@ -26,4 +20,2 @@

name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event, _hint, client) {

@@ -63,7 +55,3 @@ const clientOptions = client.getOptions();

],
ignoreTransactions: [
...(internalOptions.ignoreTransactions || []),
...(clientOptions.ignoreTransactions || []),
...(internalOptions.disableTransactionDefaults ? [] : DEFAULT_IGNORE_TRANSACTIONS),
],
ignoreTransactions: [...(internalOptions.ignoreTransactions || []), ...(clientOptions.ignoreTransactions || [])],
ignoreInternal: internalOptions.ignoreInternal !== undefined ? internalOptions.ignoreInternal : true,

@@ -160,3 +148,2 @@ };

// @ts-expect-error Try catching to save bundle size
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
lastException = event.exception.values[event.exception.values.length - 1];

@@ -186,3 +173,2 @@ } catch (e) {

// @ts-expect-error can't be a sentry error if undefined
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return event.exception.values[0].type === 'SentryError';

@@ -189,0 +175,0 @@ } catch (e) {

@@ -15,4 +15,2 @@ import { applyAggregateErrorsToEvent, exceptionFromError } from '@sentry/utils';

name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
preprocessEvent(event, hint, client) {

@@ -19,0 +17,0 @@ const options = client.getOptions();

@@ -10,9 +10,3 @@ import { forEachEnvelopeItem } from '@sentry/utils';

name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client) {
if (typeof client.on !== 'function') {
return;
}
// We need to strip metadata from stack frames before sending them to Sentry since these are client side only.

@@ -19,0 +13,0 @@ client.on('beforeEnvelope', envelope => {

@@ -1,2 +0,2 @@

import { extractPathForTransaction, addRequestDataToEvent } from '@sentry/utils';
import { addRequestDataToEvent, extractPathForTransaction } from '@sentry/utils';
import { convertIntegrationFnToClass, defineIntegration } from '../integration.js';

@@ -19,3 +19,3 @@ import { spanToJSON } from '../utils/spanUtils.js';

},
transactionNamingScheme: 'methodPath',
transactionNamingScheme: 'methodPath' ,
};

@@ -26,3 +26,2 @@

const _requestDataIntegration = ((options = {}) => {
const _addRequestData = addRequestDataToEvent;
const _options = {

@@ -32,5 +31,2 @@ ...DEFAULT_OPTIONS,

include: {
// @ts-expect-error It's mad because `method` isn't a known `include` key. (It's only here and not set by default in
// `addRequestDataToEvent` for legacy reasons. TODO (v8): Change that.)
method: true,
...DEFAULT_OPTIONS.include,

@@ -51,4 +47,2 @@ ...options.include,

name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event, _hint, client) {

@@ -68,11 +62,5 @@ // Note: In the long run, most of the logic here should probably move into the request data utility functions. For

// The Express request handler takes a similar `include` option to that which can be passed to this integration.
// If passed there, we store it in `sdkProcessingMetadata`. TODO(v8): Force express and GCP people to use this
// integration, so that all of this passing and conversion isn't necessary
const addRequestDataOptions =
sdkProcessingMetadata.requestDataOptionsFromExpressHandler ||
sdkProcessingMetadata.requestDataOptionsFromGCPWrapper ||
convertReqDataIntegrationOptsToAddReqDataOpts(_options);
const addRequestDataOptions = convertReqDataIntegrationOptsToAddReqDataOpts(_options);
const processedEvent = _addRequestData(event, req, addRequestDataOptions);
const processedEvent = addRequestDataToEvent(event, req, addRequestDataOptions);

@@ -116,3 +104,3 @@ // Transaction events already have the right `transaction` value

/**
* Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/integrations`
* Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/core`
* so it can be used in cross-platform SDKs like `@sentry/nextjs`.

@@ -136,3 +124,3 @@ * @deprecated Use `requestDataIntegration()` instead.

const requestIncludeKeys = [];
const requestIncludeKeys = ['method'];
for (const [key, value] of Object.entries(requestOptions)) {

@@ -139,0 +127,0 @@ if (value) {

import { timestampInSeconds } from '@sentry/utils';
import { DEFAULT_FLUSH_INTERVAL, NAME_AND_TAG_KEY_NORMALIZATION_REGEX, SET_METRIC_TYPE, MAX_WEIGHT } from './constants.js';
import { captureAggregateMetrics } from './envelope.js';
import { METRIC_MAP } from './instance.js';

@@ -151,7 +152,7 @@ import { updateMetricSummaryOnActiveSpan } from './metric-summary.js';

_captureMetrics(flushedBuckets) {
if (flushedBuckets.size > 0 && this._client.captureAggregateMetrics) {
if (flushedBuckets.size > 0) {
// TODO(@anonrig): Optimization opportunity.
// This copy operation can be avoided if we store the key in the bucketItem.
const buckets = Array.from(flushedBuckets).map(([, bucketItem]) => bucketItem);
this._client.captureAggregateMetrics(buckets);
captureAggregateMetrics(this._client, buckets);
}

@@ -158,0 +159,0 @@ }

import { timestampInSeconds } from '@sentry/utils';
import { DEFAULT_BROWSER_FLUSH_INTERVAL, NAME_AND_TAG_KEY_NORMALIZATION_REGEX, SET_METRIC_TYPE } from './constants.js';
import { captureAggregateMetrics } from './envelope.js';
import { METRIC_MAP } from './instance.js';

@@ -76,7 +77,7 @@ import { updateMetricSummaryOnActiveSpan } from './metric-summary.js';

}
if (this._client.captureAggregateMetrics) {
// TODO(@anonrig): Use Object.values() when we support ES6+
const metricBuckets = Array.from(this._buckets).map(([, bucketItem]) => bucketItem);
this._client.captureAggregateMetrics(metricBuckets);
}
// TODO(@anonrig): Use Object.values() when we support ES6+
const metricBuckets = Array.from(this._buckets).map(([, bucketItem]) => bucketItem);
captureAggregateMetrics(this._client, metricBuckets);
this._buckets.clear();

@@ -83,0 +84,0 @@ }

@@ -1,5 +0,24 @@

import { dsnToString, createEnvelope } from '@sentry/utils';
import { logger, dsnToString, createEnvelope } from '@sentry/utils';
import { serializeMetricBuckets } from './utils.js';
/**
* Captures aggregated metrics to the supplied client.
*/
function captureAggregateMetrics(
client,
metricBucketItems,
) {
logger.log(`Flushing aggregated metrics, number of metrics: ${metricBucketItems.length}`);
const dsn = client.getDsn();
const metadata = client.getSdkMetadata();
const tunnel = client.getOptions().tunnel;
const metricsEnvelope = createMetricEnvelope(metricBucketItems, dsn, metadata, tunnel);
// sendEnvelope should not throw
// eslint-disable-next-line @typescript-eslint/no-floating-promises
client.sendEnvelope(metricsEnvelope);
}
/**
* Create envelope from a metric aggregate.

@@ -41,3 +60,3 @@ */

export { createMetricEnvelope };
export { captureAggregateMetrics, createMetricEnvelope };
//# sourceMappingURL=envelope.js.map
import { logger } from '@sentry/utils';
import { getClient, getCurrentScope } from '../currentScopes.js';
import { DEBUG_BUILD } from '../debug-build.js';
import { getClient, getCurrentScope } from '../exports.js';
import { spanToJSON } from '../utils/spanUtils.js';
import { COUNTER_METRIC_TYPE, DISTRIBUTION_METRIC_TYPE, SET_METRIC_TYPE, GAUGE_METRIC_TYPE } from './constants.js';
import { MetricsAggregator, metricsAggregatorIntegration } from './integration.js';
/**
* Global metrics aggregator instance.
*
* This is initialized on the first call to any `Sentry.metric.*` method.
*/
let globalMetricsAggregator;
function addToMetricsAggregator(
Aggregator,
metricType,

@@ -15,9 +22,15 @@ name,

const client = getClient();
const scope = getCurrentScope();
if (!client) {
return;
}
if (!globalMetricsAggregator) {
const aggregator = (globalMetricsAggregator = new Aggregator(client));
client.on('flush', () => aggregator.flush());
client.on('close', () => aggregator.close());
}
if (client) {
if (!client.metricsAggregator) {
DEBUG_BUILD &&
logger.warn('No metrics aggregator enabled. Please add the MetricsAggregator integration to use metrics APIs');
return;
}
const scope = getCurrentScope();
const { unit, tags, timestamp } = data;

@@ -39,3 +52,3 @@ const { release, environment } = client.getOptions();

DEBUG_BUILD && logger.log(`Adding value of ${value} to ${metricType} metric ${name}`);
client.metricsAggregator.add(metricType, name, value, unit, { ...metricTags, ...tags }, timestamp);
globalMetricsAggregator.add(metricType, name, value, unit, { ...metricTags, ...tags }, timestamp);
}

@@ -49,4 +62,4 @@ }

*/
function increment(name, value = 1, data) {
addToMetricsAggregator(COUNTER_METRIC_TYPE, name, value, data);
function increment(aggregator, name, value = 1, data) {
addToMetricsAggregator(aggregator, COUNTER_METRIC_TYPE, name, value, data);
}

@@ -59,4 +72,4 @@

*/
function distribution(name, value, data) {
addToMetricsAggregator(DISTRIBUTION_METRIC_TYPE, name, value, data);
function distribution(aggregator, name, value, data) {
addToMetricsAggregator(aggregator, DISTRIBUTION_METRIC_TYPE, name, value, data);
}

@@ -69,4 +82,4 @@

*/
function set(name, value, data) {
addToMetricsAggregator(SET_METRIC_TYPE, name, value, data);
function set(aggregator, name, value, data) {
addToMetricsAggregator(aggregator, SET_METRIC_TYPE, name, value, data);
}

@@ -79,4 +92,4 @@

*/
function gauge(name, value, data) {
addToMetricsAggregator(GAUGE_METRIC_TYPE, name, value, data);
function gauge(aggregator, name, value, data) {
addToMetricsAggregator(aggregator, GAUGE_METRIC_TYPE, name, value, data);
}

@@ -89,9 +102,5 @@

gauge,
/** @deprecated Use `metrics.metricsAggregratorIntegration()` instead. */
// eslint-disable-next-line deprecation/deprecation
MetricsAggregator,
metricsAggregatorIntegration,
};
export { distribution, gauge, increment, metrics, set };
export { metrics };
//# sourceMappingURL=exports.js.map
import { dropUndefinedKeys } from '@sentry/utils';
import '../debug-build.js';
import '../tracing/errors.js';
import '../tracing/spanstatus.js';
import { getActiveSpan } from '../tracing/trace.js';
import { getActiveSpan } from '../tracing/utils.js';

@@ -7,0 +4,0 @@ /**

import { isPlainObject, dateTimestampInSeconds, uuid4, logger } from '@sentry/utils';
import { getGlobalEventProcessors, notifyEventProcessors } from './eventProcessors.js';
import { updateSession } from './session.js';
import { applyScopeDataToEvent } from './utils/applyScopeDataToEvent.js';

@@ -12,11 +10,4 @@ /**

/**
* The global scope is kept in this module.
* When accessing this via `getGlobalScope()` we'll make sure to set one if none is currently present.
* Holds additional event information.
*/
let globalScope;
/**
* Holds additional event information. {@link Scope.applyToEvent} will be
* called by the client before an event will be sent.
*/
class Scope {

@@ -27,3 +18,3 @@ /** Flag if notifying is happening. */

/** Callback list that will be called after {@link applyToEvent}. */
/** Callback list that will be called during event processing. */

@@ -52,3 +43,2 @@ /** Array of breadcrumbs. */

/** Severity */
// eslint-disable-next-line deprecation/deprecation

@@ -127,3 +117,3 @@ /**

getClient() {
return this._client;
return this._client ;
}

@@ -157,3 +147,2 @@

ip_address: undefined,
segment: undefined,
username: undefined,

@@ -246,6 +235,3 @@ };

*/
setLevel(
// eslint-disable-next-line deprecation/deprecation
level,
) {
setLevel(level) {
this._level = level;

@@ -308,6 +294,11 @@ this._notifyScopeListeners();

const span = this._span;
// Cannot replace with getRootSpan because getRootSpan returns a span, not a transaction
// Also, this method will be removed anyway.
// eslint-disable-next-line deprecation/deprecation
return span && span.transaction;
if (span && (span ).transaction) {
// eslint-disable-next-line deprecation/deprecation
return (span ).transaction;
}
return undefined;
}

@@ -395,2 +386,3 @@

clear() {
// client is not cleared here on purpose!
this._breadcrumbs = [];

@@ -516,28 +508,2 @@ this._tags = {};

/**
* Applies data from the scope to the event and runs all event processors on it.
*
* @param event Event
* @param hint Object containing additional information about the original exception, for use by the event processors.
* @hidden
* @deprecated Use `applyScopeDataToEvent()` directly
*/
applyToEvent(
event,
hint = {},
additionalEventProcessors = [],
) {
applyScopeDataToEvent(event, this.getScopeData());
// TODO (v8): Update this order to be: Global > Client > Scope
const eventProcessors = [
...additionalEventProcessors,
// eslint-disable-next-line deprecation/deprecation
...getGlobalEventProcessors(),
...this._eventProcessors,
];
return notifyEventProcessors(eventProcessors, event, hint);
}
/**
* Add data which will be accessible during event processing but won't get sent to Sentry

@@ -667,23 +633,2 @@ */

/**
* Get the global scope.
* This scope is applied to _all_ events.
*/
function getGlobalScope() {
if (!globalScope) {
globalScope = new Scope();
}
return globalScope;
}
/**
* This is mainly needed for tests.
* DO NOT USE this, as this is an internal API and subject to change.
* @hidden
*/
function setGlobalScope(scope) {
globalScope = scope;
}
function generatePropagationContext() {

@@ -696,3 +641,3 @@ return {

export { Scope, getGlobalScope, setGlobalScope };
export { Scope };
//# sourceMappingURL=scope.js.map
import { logger, consoleSandbox } from '@sentry/utils';
import { getCurrentScope } from './currentScopes.js';
import { DEBUG_BUILD } from './debug-build.js';
import { getCurrentScope } from './exports.js';
import { getCurrentHub } from './hub.js';

@@ -35,3 +35,3 @@

setCurrentClient(client);
initializeClient(client);
client.init();
}

@@ -43,26 +43,20 @@

function setCurrentClient(client) {
getCurrentScope().setClient(client);
// is there a hub too?
// eslint-disable-next-line deprecation/deprecation
const hub = getCurrentHub();
// eslint-disable-next-line deprecation/deprecation
const top = hub.getStackTop();
top.client = client;
top.scope.setClient(client);
}
/**
* Initialize the client for the current scope.
* Make sure to call this after `setCurrentClient()`.
*/
function initializeClient(client) {
if (client.init) {
client.init();
// TODO v8: Remove this fallback
if (isHubClass(hub)) {
// eslint-disable-next-line deprecation/deprecation
} else if (client.setupIntegrations) {
// eslint-disable-next-line deprecation/deprecation
client.setupIntegrations();
const top = hub.getStackTop();
top.client = client;
}
}
function isHubClass(hub) {
// eslint-disable-next-line deprecation/deprecation
return !!(hub ).getStackTop;
}
export { initAndBind, setCurrentClient };
//# sourceMappingURL=sdk.js.map

@@ -23,8 +23,3 @@ /**

/**
* The id of the profile that this span occured in.
*/
const SEMANTIC_ATTRIBUTE_PROFILE_ID = 'profile_id';
export { SEMANTIC_ATTRIBUTE_PROFILE_ID, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE };
export { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE };
//# sourceMappingURL=semanticAttributes.js.map
import { resolvedSyncPromise, eventFromUnknownInput, eventFromMessage, logger, uuid4 } from '@sentry/utils';
import { BaseClient } from './baseclient.js';
import { createCheckInEnvelope } from './checkin.js';
import { getIsolationScope } from './currentScopes.js';
import { DEBUG_BUILD } from './debug-build.js';
import { getClient } from './exports.js';
import { MetricsAggregator } from './metrics/aggregator.js';
import { SessionFlusher } from './sessionflusher.js';

@@ -11,4 +10,4 @@ import { addTracingExtensions } from './tracing/hubextensions.js';

import { getRootSpan } from './utils/getRootSpan.js';
import { getDynamicSamplingContextFromSpan, getDynamicSamplingContextFromClient } from './tracing/dynamicSamplingContext.js';
import './tracing/spanstatus.js';
import { getDynamicSamplingContextFromSpan, getDynamicSamplingContextFromClient } from './tracing/dynamicSamplingContext.js';

@@ -31,6 +30,2 @@ /**

super(options);
if (options._experiments && options._experiments['metricsAggregator']) {
this.metricsAggregator = new MetricsAggregator(this);
}
}

@@ -42,3 +37,3 @@

eventFromException(exception, hint) {
return resolvedSyncPromise(eventFromUnknownInput(getClient(), this._options.stackParser, exception, hint));
return resolvedSyncPromise(eventFromUnknownInput(this, this._options.stackParser, exception, hint));
}

@@ -51,3 +46,2 @@

message,
// eslint-disable-next-line deprecation/deprecation
level = 'info',

@@ -64,3 +58,3 @@ hint,

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
// eslint-disable-next-line @typescript-eslint/no-explicit-any
captureException(exception, hint, scope) {

@@ -70,4 +64,4 @@ // Check if the flag `autoSessionTracking` is enabled, and if `_sessionFlusher` exists because it is initialised only

// sent to the Server only when the `requestHandler` middleware is used
if (this._options.autoSessionTracking && this._sessionFlusher && scope) {
const requestSession = scope.getRequestSession();
if (this._options.autoSessionTracking && this._sessionFlusher) {
const requestSession = getIsolationScope().getRequestSession();

@@ -91,3 +85,3 @@ // Necessary checks to ensure this is code block is executed only within a request

// sent to the Server only when the `requestHandler` middleware is used
if (this._options.autoSessionTracking && this._sessionFlusher && scope) {
if (this._options.autoSessionTracking && this._sessionFlusher) {
const eventType = event.type || 'exception';

@@ -99,3 +93,3 @@ const isException =

if (isException) {
const requestSession = scope.getRequestSession();
const requestSession = getIsolationScope().getRequestSession();

@@ -192,5 +186,5 @@ // Ensure that this is happening within the bounds of a request, and make sure not to override

// _sendEnvelope should not throw
// sendEnvelope should not throw
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this._sendEnvelope(envelope);
this.sendEnvelope(envelope);

@@ -264,3 +258,3 @@ return id;

return [getDynamicSamplingContextFromClient(traceId, this, scope), traceContext];
return [getDynamicSamplingContextFromClient(traceId, this), traceContext];
}

@@ -267,0 +261,0 @@ }

import { dropUndefinedKeys } from '@sentry/utils';
import { getCurrentScope } from './exports.js';
import { getIsolationScope } from './currentScopes.js';

@@ -59,4 +59,4 @@ /**

}
const scope = getCurrentScope();
const requestSession = scope.getRequestSession();
const isolationScope = getIsolationScope();
const requestSession = isolationScope.getRequestSession();

@@ -67,3 +67,3 @@ if (requestSession && requestSession.status) {

// case captureRequestSession is called more than once to prevent double count
scope.setRequestSession(undefined);
isolationScope.setRequestSession(undefined);
/* eslint-enable @typescript-eslint/no-unsafe-member-access */

@@ -70,0 +70,0 @@ }

import { dropUndefinedKeys } from '@sentry/utils';
import { DEFAULT_ENVIRONMENT } from '../constants.js';
import { getClient, getCurrentScope } from '../exports.js';
import { getClient } from '../currentScopes.js';
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '../semanticAttributes.js';
import { getRootSpan } from '../utils/getRootSpan.js';

@@ -12,13 +13,6 @@ import { spanToJSON, spanIsSampled } from '../utils/spanUtils.js';

*/
function getDynamicSamplingContextFromClient(
trace_id,
client,
scope,
) {
function getDynamicSamplingContextFromClient(trace_id, client) {
const options = client.getOptions();
const { publicKey: public_key } = client.getDsn() || {};
// TODO(v8): Remove segment from User
// eslint-disable-next-line deprecation/deprecation
const { segment: user_segment } = (scope && scope.getUser()) || {};

@@ -28,3 +22,2 @@ const dsc = dropUndefinedKeys({

release: options.release,
user_segment,
public_key,

@@ -34,3 +27,3 @@ trace_id,

client.emit && client.emit('createDsc', dsc);
client.emit('createDsc', dsc);

@@ -57,4 +50,3 @@ return dsc;

// passing emit=false here to only emit later once the DSC is actually populated
const dsc = getDynamicSamplingContextFromClient(spanToJSON(span).trace_id || '', client, getCurrentScope());
const dsc = getDynamicSamplingContextFromClient(spanToJSON(span).trace_id || '', client);

@@ -78,3 +70,3 @@ // TODO (v8): Remove v7FrozenDsc as a Transaction will no longer have _frozenDynamicSamplingContext

// eslint-disable-next-line deprecation/deprecation
const { sampleRate: maybeSampleRate, source } = txn.metadata;
const { sampleRate: maybeSampleRate } = txn.metadata;
if (maybeSampleRate != null) {

@@ -87,2 +79,4 @@ dsc.sample_rate = `${maybeSampleRate}`;

const source = (jsonSpan.data || {})[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
// after JSON conversion, txn.name becomes jsonSpan.description

@@ -95,3 +89,3 @@ if (source && source !== 'url') {

client.emit && client.emit('createDsc', dsc);
client.emit('createDsc', dsc);

@@ -98,0 +92,0 @@ return dsc;

@@ -1,5 +0,2 @@

import { logger } from '@sentry/utils';
import { DEBUG_BUILD } from '../debug-build.js';
import { getMainCarrier } from '../hub.js';
import { spanToTraceHeader } from '../utils/spanUtils.js';
import { getMainCarrier } from '../asyncContext.js';
import { registerErrorInstrumentation } from './errors.js';

@@ -10,16 +7,2 @@ import { IdleTransaction } from './idletransaction.js';

/** Returns all trace headers that are currently on the top scope. */
function traceHeaders() {
// eslint-disable-next-line deprecation/deprecation
const scope = this.getScope();
// eslint-disable-next-line deprecation/deprecation
const span = scope.getSpan();
return span
? {
'sentry-trace': spanToTraceHeader(span),
}
: {};
}
/**

@@ -49,16 +32,2 @@ * Creates a new transaction and adds a sampling decision if it doesn't yet have one.

const configInstrumenter = options.instrumenter || 'sentry';
const transactionInstrumenter = transactionContext.instrumenter || 'sentry';
if (configInstrumenter !== transactionInstrumenter) {
DEBUG_BUILD &&
logger.error(
`A transaction was started with instrumenter=\`${transactionInstrumenter}\`, but the SDK is configured with the \`${configInstrumenter}\` instrumenter.
The transaction will not be sampled. Please use the ${configInstrumenter} instrumentation to start transactions.`,
);
// eslint-disable-next-line deprecation/deprecation
transactionContext.sampled = false;
}
// eslint-disable-next-line deprecation/deprecation

@@ -78,5 +47,5 @@ let transaction = new Transaction(transactionContext, this);

if (transaction.isRecording()) {
transaction.initSpanRecorder(options._experiments && (options._experiments.maxSpans ));
transaction.initSpanRecorder();
}
if (client && client.emit) {
if (client) {
client.emit('startTransaction', transaction);

@@ -126,5 +95,5 @@ }

if (transaction.isRecording()) {
transaction.initSpanRecorder(options._experiments && (options._experiments.maxSpans ));
transaction.initSpanRecorder();
}
if (client && client.emit) {
if (client) {
client.emit('startTransaction', transaction);

@@ -147,5 +116,2 @@ }

}
if (!carrier.__SENTRY__.extensions.traceHeaders) {
carrier.__SENTRY__.extensions.traceHeaders = traceHeaders;
}

@@ -152,0 +118,0 @@ registerErrorInstrumentation();

import { logger, timestampInSeconds } from '@sentry/utils';
import { DEBUG_BUILD } from '../debug-build.js';
import { spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils.js';
import { SpanRecorder } from './span.js';
import { SpanRecorder } from './sentrySpan.js';
import { Transaction } from './transaction.js';

@@ -146,4 +146,5 @@

// eslint-disable-next-line deprecation/deprecation
if (this.op === 'ui.action.click') {
const op = spanToJSON(this).op;
if (op === 'ui.action.click') {
this.setAttribute(FINISH_REASON_TAG, this._finishReason);

@@ -155,4 +156,3 @@ }

DEBUG_BUILD &&
// eslint-disable-next-line deprecation/deprecation
logger.log('[Tracing] finishing IdleTransaction', new Date(endTimestampInS * 1000).toISOString(), this.op);
logger.log('[Tracing] finishing IdleTransaction', new Date(endTimestampInS * 1000).toISOString(), op);

@@ -159,0 +159,0 @@ for (const callback of this._beforeFinishCallbacks) {

@@ -1,2 +0,2 @@

import { isNaN, logger } from '@sentry/utils';
import { logger, isNaN } from '@sentry/utils';
import { DEBUG_BUILD } from '../debug-build.js';

@@ -94,5 +94,7 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE } from '../semanticAttributes.js';

DEBUG_BUILD &&
// eslint-disable-next-line deprecation/deprecation
logger.log(`[Tracing] starting ${transaction.op} transaction - ${spanToJSON(transaction).description}`);
if (DEBUG_BUILD) {
const { op, description } = spanToJSON(transaction);
logger.log(`[Tracing] starting ${op} transaction - ${description}`);
}
return transaction;

@@ -106,3 +108,2 @@ }

// we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (isNaN(rate) || !(typeof rate === 'number' || typeof rate === 'boolean')) {

@@ -127,3 +128,3 @@ DEBUG_BUILD &&

export { isValidSampleRate, sampleTransaction };
export { sampleTransaction };
//# sourceMappingURL=sampling.js.map

@@ -89,13 +89,2 @@ /** The status of an Span.

/**
* Converts a HTTP status code into a {@link SpanStatusType}.
*
* @deprecated Use {@link spanStatusFromHttpCode} instead.
* This export will be removed in v8 as the signature contains a typo.
*
* @param httpStatus The HTTP response status code.
* @returns The span status or unknown_error.
*/
const spanStatusfromHttpCode = getSpanStatusFromHttpCode;
/**
* Sets the Http status attributes on the current span based on the http code.

@@ -105,14 +94,4 @@ * Additionally, the span's status is updated, depending on the http code.

function setHttpStatus(span, httpStatus) {
// TODO (v8): Remove these calls
// Relay does not require us to send the status code as a tag
// For now, just because users might expect it to land as a tag we keep sending it.
// Same with data.
// In v8, we replace both, simply with
// span.setAttribute('http.response.status_code', httpStatus);
span.setAttribute('http.response.status_code', httpStatus);
// eslint-disable-next-line deprecation/deprecation
span.setTag('http.status_code', String(httpStatus));
// eslint-disable-next-line deprecation/deprecation
span.setData('http.response.status_code', httpStatus);
const spanStatus = getSpanStatusFromHttpCode(httpStatus);

@@ -124,3 +103,3 @@ if (spanStatus !== 'unknown_error') {

export { SpanStatus, getSpanStatusFromHttpCode, setHttpStatus, spanStatusfromHttpCode };
export { SpanStatus, getSpanStatusFromHttpCode, setHttpStatus };
//# sourceMappingURL=spanstatus.js.map

@@ -1,68 +0,13 @@

import { tracingContextFromHeaders, logger, dropUndefinedKeys, addNonEnumerableProperty } from '@sentry/utils';
import { tracingContextFromHeaders, logger, dropUndefinedKeys } from '@sentry/utils';
import { withScope, getCurrentScope, getIsolationScope } from '../currentScopes.js';
import { DEBUG_BUILD } from '../debug-build.js';
import { getCurrentHub, runWithAsyncContext, getIsolationScope } from '../hub.js';
import { getCurrentHub } from '../hub.js';
import { handleCallbackErrors } from '../utils/handleCallbackErrors.js';
import { hasTracingEnabled } from '../utils/hasTracingEnabled.js';
import { spanToJSON, spanIsSampled, spanTimeInputToSeconds } from '../utils/spanUtils.js';
import './errors.js';
import './spanstatus.js';
import { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext.js';
import { getCurrentScope, withScope } from '../exports.js';
import { handleCallbackErrors } from '../utils/handleCallbackErrors.js';
import { hasTracingEnabled } from '../utils/hasTracingEnabled.js';
import { getActiveSpan, addChildSpanToSpan, setCapturedScopesOnSpan } from './utils.js';
/**
* Wraps a function with a transaction/span and finishes the span after the function is done.
*
* Note that if you have not enabled tracing extensions via `addTracingExtensions`
* or you didn't set `tracesSampleRate`, this function will not generate spans
* and the `span` returned from the callback will be undefined.
*
* This function is meant to be used internally and may break at any time. Use at your own risk.
*
* @internal
* @private
*
* @deprecated Use `startSpan` instead.
*/
function trace(
context,
callback,
// eslint-disable-next-line @typescript-eslint/no-empty-function
onError = () => {},
// eslint-disable-next-line @typescript-eslint/no-empty-function
afterFinish = () => {},
) {
// eslint-disable-next-line deprecation/deprecation
const hub = getCurrentHub();
const scope = getCurrentScope();
// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
const spanContext = normalizeContext(context);
const activeSpan = createChildSpanOrTransaction(hub, {
parentSpan,
spanContext,
forceTransaction: false,
scope,
});
// eslint-disable-next-line deprecation/deprecation
scope.setSpan(activeSpan);
return handleCallbackErrors(
() => callback(activeSpan),
error => {
activeSpan && activeSpan.setStatus('internal_error');
onError(error, activeSpan);
},
() => {
activeSpan && activeSpan.end();
// eslint-disable-next-line deprecation/deprecation
scope.setSpan(parentSpan);
afterFinish();
},
);
}
/**
* Wraps a function with a transaction/span and finishes the span after the function is done.
* The created span is the active span and will be used as parent by other spans created inside the function

@@ -80,33 +25,31 @@ * and can be accessed via `Sentry.getSpan()`, as long as the function is executed while the scope is active.

return runWithAsyncContext(() => {
return withScope(context.scope, scope => {
// eslint-disable-next-line deprecation/deprecation
const hub = getCurrentHub();
// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
return withScope(context.scope, scope => {
// eslint-disable-next-line deprecation/deprecation
const hub = getCurrentHub();
// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan() ;
const shouldSkipSpan = context.onlyIfParent && !parentSpan;
const activeSpan = shouldSkipSpan
? undefined
: createChildSpanOrTransaction(hub, {
parentSpan,
spanContext,
forceTransaction: context.forceTransaction,
scope,
});
const shouldSkipSpan = context.onlyIfParent && !parentSpan;
const activeSpan = shouldSkipSpan
? undefined
: createChildSpanOrTransaction(hub, {
parentSpan,
spanContext,
forceTransaction: context.forceTransaction,
scope,
});
return handleCallbackErrors(
() => callback(activeSpan),
() => {
// Only update the span status if it hasn't been changed yet
if (activeSpan) {
const { status } = spanToJSON(activeSpan);
if (!status || status === 'ok') {
activeSpan.setStatus('internal_error');
}
return handleCallbackErrors(
() => callback(activeSpan),
() => {
// Only update the span status if it hasn't been changed yet
if (activeSpan) {
const { status } = spanToJSON(activeSpan);
if (!status || status === 'ok') {
activeSpan.setStatus('internal_error');
}
},
() => activeSpan && activeSpan.end(),
);
});
}
},
() => activeSpan && activeSpan.end(),
);
});

@@ -116,7 +59,2 @@ }

/**
* @deprecated Use {@link startSpan} instead.
*/
const startActiveSpan = startSpan;
/**
* Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span

@@ -138,36 +76,34 @@ * after the function is done automatically. You'll have to call `span.end()` manually.

return runWithAsyncContext(() => {
return withScope(context.scope, scope => {
// eslint-disable-next-line deprecation/deprecation
const hub = getCurrentHub();
// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
return withScope(context.scope, scope => {
// eslint-disable-next-line deprecation/deprecation
const hub = getCurrentHub();
// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan() ;
const shouldSkipSpan = context.onlyIfParent && !parentSpan;
const activeSpan = shouldSkipSpan
? undefined
: createChildSpanOrTransaction(hub, {
parentSpan,
spanContext,
forceTransaction: context.forceTransaction,
scope,
});
const shouldSkipSpan = context.onlyIfParent && !parentSpan;
const activeSpan = shouldSkipSpan
? undefined
: createChildSpanOrTransaction(hub, {
parentSpan,
spanContext,
forceTransaction: context.forceTransaction,
scope,
});
function finishAndSetSpan() {
activeSpan && activeSpan.end();
}
function finishAndSetSpan() {
activeSpan && activeSpan.end();
}
return handleCallbackErrors(
() => callback(activeSpan, finishAndSetSpan),
() => {
// Only update the span status if it hasn't been changed yet, and the span is not yet finished
if (activeSpan && activeSpan.isRecording()) {
const { status } = spanToJSON(activeSpan);
if (!status || status === 'ok') {
activeSpan.setStatus('internal_error');
}
return handleCallbackErrors(
() => callback(activeSpan, finishAndSetSpan),
() => {
// Only update the span status if it hasn't been changed yet, and the span is not yet finished
if (activeSpan && activeSpan.isRecording()) {
const { status } = spanToJSON(activeSpan);
if (!status || status === 'ok') {
activeSpan.setStatus('internal_error');
}
},
);
});
}
},
);
});

@@ -196,4 +132,4 @@ }

? // eslint-disable-next-line deprecation/deprecation
context.scope.getSpan()
: getActiveSpan();
(context.scope.getSpan() )
: (getActiveSpan() );

@@ -211,3 +147,3 @@ const shouldSkipSpan = context.onlyIfParent && !parentSpan;

// as otherwise, it won't pick the correct span for the event when processing it
const temporaryScope = (scope ).clone();
const temporaryScope = scope.clone();

@@ -222,10 +158,2 @@ return createChildSpanOrTransaction(hub, {

/**
* Returns the currently active span.
*/
function getActiveSpan() {
// eslint-disable-next-line deprecation/deprecation
return getCurrentScope().getSpan();
}
const continueTrace = (

@@ -274,3 +202,3 @@ {

return runWithAsyncContext(() => {
return withScope(() => {
return callback(transactionContext);

@@ -301,2 +229,3 @@ });

span = parentSpan.startChild(spanContext);
addChildSpanToSpan(parentSpan, span);
} else if (parentSpan) {

@@ -369,23 +298,3 @@ // If we forced a transaction but have a parent span, make sure to continue from the parent span, not the scope

const SCOPE_ON_START_SPAN_FIELD = '_sentryScope';
const ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';
function setCapturedScopesOnSpan(span, scope, isolationScope) {
if (span) {
addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, isolationScope);
addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);
}
}
/**
* Grabs the scope and isolation scope off a span that were active when the span was started.
*/
function getCapturedScopesOnSpan(span) {
return {
scope: (span )[SCOPE_ON_START_SPAN_FIELD],
isolationScope: (span )[ISOLATION_SCOPE_ON_START_SPAN_FIELD],
};
}
export { continueTrace, getActiveSpan, getCapturedScopesOnSpan, startActiveSpan, startInactiveSpan, startSpan, startSpanManual, trace };
export { continueTrace, startInactiveSpan, startSpan, startSpanManual };
//# sourceMappingURL=trace.js.map

@@ -8,7 +8,7 @@ import { dropUndefinedKeys, logger } from '@sentry/utils';

import { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext.js';
import { Span, SpanRecorder } from './span.js';
import { getCapturedScopesOnSpan } from './trace.js';
import { SentrySpan, SpanRecorder } from './sentrySpan.js';
import { getSpanTree, getCapturedScopesOnSpan } from './utils.js';
/** JSDoc */
class Transaction extends Span {
class Transaction extends SentrySpan {
/**

@@ -31,2 +31,3 @@ * The reference to the current hub.

super(transactionContext);
this._measurements = {};
this._contexts = {};

@@ -46,2 +47,7 @@

this._attributes = {
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',
...this._attributes,
};
// this is because transactions are also spans, and spans have a transaction pointer

@@ -62,22 +68,4 @@ // TODO (v8): Replace this with another way to set the root span

// This sadly conflicts with the getter/setter ordering :(
/* eslint-disable @typescript-eslint/member-ordering */
/**
* Getter for `name` property.
* @deprecated Use `spanToJSON(span).description` instead.
*/
get name() {
return this._name;
}
/**
* Setter for `name` property, which also sets `source` as custom.
* @deprecated Use `updateName()` and `setMetadata()` instead.
*/
set name(newName) {
// eslint-disable-next-line deprecation/deprecation
this.setName(newName);
}
/**
* Get the metadata for this transaction.

@@ -90,4 +78,2 @@ * @deprecated Use `spanGetMetadata(transaction)` instead.

// Defaults
// eslint-disable-next-line deprecation/deprecation
source: 'custom',
spanMetadata: {},

@@ -99,5 +85,2 @@

// From attributes
...(this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] && {
source: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] ,
}),
...(this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE] && {

@@ -119,15 +102,6 @@ sampleRate: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE] ,

/**
* Setter for `name` property, which also sets `source` on the metadata.
*
* @deprecated Use `.updateName()` and `.setAttribute()` instead.
*/
setName(name, source = 'custom') {
this._name = name;
this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);
}
/** @inheritdoc */
updateName(name) {
this._name = name;
this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'custom');
return this;

@@ -208,15 +182,2 @@ }

/**
* @inheritDoc
*/
updateWithContext(transactionContext) {
// eslint-disable-next-line deprecation/deprecation
super.updateWithContext(transactionContext);
this._name = transactionContext.name || '';
this._trimEnd = transactionContext.trimEnd;
return this;
}
/**
* @inheritdoc

@@ -243,12 +204,2 @@ *

/**
* Get the profile id of the transaction.
*/
getProfileId() {
if (this._contexts !== undefined && this._contexts['profile'] !== undefined) {
return this._contexts['profile'].profile_id ;
}
return undefined;
}
/**
* Finish the transaction & prepare the event to send to Sentry.

@@ -272,3 +223,3 @@ */

const client = this._hub.getClient();
if (client && client.emit) {
if (client) {
client.emit('finishTransaction', this);

@@ -288,7 +239,4 @@ }

// eslint-disable-next-line deprecation/deprecation
const finishedSpans = this.spanRecorder
? // eslint-disable-next-line deprecation/deprecation
this.spanRecorder.spans.filter(span => span !== this && spanToJSON(span).timestamp)
: [];
// We only want to include finished spans in the event
const finishedSpans = getSpanTree(this).filter(span => span !== this && spanToJSON(span).timestamp);

@@ -306,5 +254,5 @@ if (this._trimEnd && finishedSpans.length > 0) {

const { metadata } = this;
// eslint-disable-next-line deprecation/deprecation
const { source } = metadata;
const source = this._attributes['sentry.source'] ;
const transaction = {

@@ -351,5 +299,3 @@ contexts: {

// eslint-disable-next-line deprecation/deprecation
DEBUG_BUILD && logger.log(`[Tracing] Finishing ${this.op} transaction: ${this._name}.`);
DEBUG_BUILD && logger.log(`[Tracing] Finishing ${spanToJSON(this).op} transaction: ${this._name}.`);
return transaction;

@@ -356,0 +302,0 @@ }

@@ -1,3 +0,4 @@

import { extractTraceparentData as extractTraceparentData$1 } from '@sentry/utils';
import { addNonEnumerableProperty } from '@sentry/utils';
export { stripUrlQueryAndFragment } from '@sentry/utils';
import { getCurrentScope } from '../currentScopes.js';
import { getCurrentHub } from '../hub.js';

@@ -20,16 +21,68 @@

/**
* The `extractTraceparentData` function and `TRACEPARENT_REGEXP` constant used
* to be declared in this file. It was later moved into `@sentry/utils` as part of a
* move to remove `@sentry/tracing` dependencies from `@sentry/node` (`extractTraceparentData`
* is the only tracing function used by `@sentry/node`).
*
* These exports are kept here for backwards compatability's sake.
*
* See https://github.com/getsentry/sentry-javascript/issues/4642 for more details.
*
* @deprecated Import this function from `@sentry/utils` instead
* Returns the currently active span.
*/
const extractTraceparentData = extractTraceparentData$1;
function getActiveSpan() {
// eslint-disable-next-line deprecation/deprecation
return getCurrentScope().getSpan();
}
export { extractTraceparentData, getActiveTransaction };
const CHILD_SPANS_FIELD = '_sentryChildSpans';
/**
* Adds an opaque child span reference to a span.
*/
function addChildSpanToSpan(span, childSpan) {
if (span[CHILD_SPANS_FIELD] && span[CHILD_SPANS_FIELD].size < 1000) {
span[CHILD_SPANS_FIELD].add(childSpan);
} else {
span[CHILD_SPANS_FIELD] = new Set([childSpan]);
}
}
/**
* Obtains the entire span tree, meaning a span + all of its descendants for a particular span.
*/
function getSpanTree(span) {
const resultSet = new Set();
function addSpanChildren(span) {
// This exit condition is required to not infinitely loop in case of a circular dependency.
if (resultSet.has(span)) {
return;
} else {
resultSet.add(span);
const childSpans = span[CHILD_SPANS_FIELD] ? Array.from(span[CHILD_SPANS_FIELD]) : [];
for (const childSpan of childSpans) {
addSpanChildren(childSpan);
}
}
}
addSpanChildren(span);
return Array.from(resultSet);
}
const SCOPE_ON_START_SPAN_FIELD = '_sentryScope';
const ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';
/** Store the scope & isolation scope for a span, which can the be used when it is finished. */
function setCapturedScopesOnSpan(span, scope, isolationScope) {
if (span) {
addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, isolationScope);
addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);
}
}
/**
* Grabs the scope and isolation scope off a span that were active when the span was started.
*/
function getCapturedScopesOnSpan(span) {
return {
scope: (span )[SCOPE_ON_START_SPAN_FIELD],
isolationScope: (span )[ISOLATION_SCOPE_ON_START_SPAN_FIELD],
};
}
export { addChildSpanToSpan, getActiveSpan, getActiveTransaction, getCapturedScopesOnSpan, getSpanTree, setCapturedScopesOnSpan };
//# sourceMappingURL=utils.js.map

@@ -53,3 +53,3 @@ import { makePromiseBuffer, forEachEnvelopeItem, envelopeItemTypeToDataCategory, isRateLimited, resolvedSyncPromise, createEnvelope, SentryError, logger, serializeEnvelope, updateRateLimits } from '@sentry/utils';

const requestTask = () =>
makeRequest({ body: serializeEnvelope(filteredEnvelope, options.textEncoder) }).then(
makeRequest({ body: serializeEnvelope(filteredEnvelope) }).then(
response => {

@@ -56,0 +56,0 @@ // We don't want to throw on NOK responses, but we want to at least log them

@@ -12,3 +12,3 @@ /**

// eslint-disable-next-line deprecation/deprecation
return span.transaction;
return (span ).transaction ? (span ).transaction : undefined;
}

@@ -15,0 +15,0 @@

@@ -1,2 +0,2 @@

import { getClient } from '../exports.js';
import { getClient } from '../currentScopes.js';

@@ -3,0 +3,0 @@ // Treeshakable guard to remove all code related to tracing

import { uuid4, dateTimestampInSeconds, addExceptionMechanism, truncate, GLOBAL_OBJ, normalize } from '@sentry/utils';
import { DEFAULT_ENVIRONMENT } from '../constants.js';
import { getGlobalScope } from '../currentScopes.js';
import { getGlobalEventProcessors, notifyEventProcessors } from '../eventProcessors.js';
import { getGlobalScope, Scope } from '../scope.js';
import { Scope } from '../scope.js';
import { mergeScopeData, applyScopeDataToEvent } from './applyScopeDataToEvent.js';

@@ -63,3 +64,3 @@ import { spanToJSON } from './spanUtils.js';

const clientEventProcessors = client && client.getEventProcessors ? client.getEventProcessors() : [];
const clientEventProcessors = client ? client.getEventProcessors() : [];

@@ -320,4 +321,3 @@ // This should be the last thing called, since we want that

// This is a bit weird, as we generally have `Span` instances here, but to be safe we do not assume so
// eslint-disable-next-line deprecation/deprecation
span.data = normalize(data, depth, maxBreadth);
span.setAttributes(normalize(data, depth, maxBreadth));
}

@@ -332,3 +332,6 @@

function getFinalScope(scope, captureContext) {
function getFinalScope(
scope,
captureContext,
) {
if (!captureContext) {

@@ -335,0 +338,0 @@ return scope;

@@ -70,6 +70,5 @@ import { dropUndefinedKeys, generateSentryTraceHeader, timestampInSeconds } from '@sentry/utils';

* And `spanToJSON` needs the Span class from `span.ts` to check here.
* TODO v8: When we remove the deprecated stuff from `span.ts`, we can remove the circular dependency again.
*/
function spanToJSON(span) {
if (spanIsSpanClass(span)) {
if (spanIsSentrySpan(span)) {
return span.getSpanJSON();

@@ -79,8 +78,8 @@ }

// Fallback: We also check for `.toJSON()` here...
// eslint-disable-next-line deprecation/deprecation
if (typeof span.toJSON === 'function') {
// eslint-disable-next-line deprecation/deprecation
return span.toJSON();
if (typeof (span ).toJSON === 'function') {
return (span ).toJSON();
}
// TODO: Also handle OTEL spans here!
return {};

@@ -93,3 +92,3 @@ }

*/
function spanIsSpanClass(span) {
function spanIsSentrySpan(span) {
return typeof (span ).getSpanJSON === 'function';

@@ -96,0 +95,0 @@ }

@@ -1,4 +0,4 @@

const SDK_VERSION = '7.105.0';
const SDK_VERSION = '8.0.0-alpha.1';
export { SDK_VERSION };
//# sourceMappingURL=version.js.map
{
"name": "@sentry/core",
"version": "7.105.0",
"version": "8.0.0-alpha.1",
"description": "Base implementation for all Sentry JavaScript SDKs",

@@ -10,3 +10,3 @@ "repository": "git://github.com/getsentry/sentry-javascript.git",

"engines": {
"node": ">=8"
"node": ">=14.8"
},

@@ -33,4 +33,4 @@ "files": [

"dependencies": {
"@sentry/types": "7.105.0",
"@sentry/utils": "7.105.0"
"@sentry/types": "8.0.0-alpha.1",
"@sentry/utils": "8.0.0-alpha.1"
},

@@ -37,0 +37,0 @@ "madge": {

@@ -1,2 +0,2 @@

import { Breadcrumb, BreadcrumbHint, Client, ClientOptions, DataCategory, DsnComponents, DynamicSamplingContext, Envelope, Event, EventDropReason, EventHint, EventProcessor, FeedbackEvent, Integration, IntegrationClass, MetricBucketItem, MetricsAggregator, Outcome, ParameterizedString, SdkMetadata, Session, SessionAggregates, Severity, SeverityLevel, StartSpanOptions, Transaction, Transport, TransportMakeRequestResponse } from '@sentry/types';
import { Breadcrumb, BreadcrumbHint, Client, ClientOptions, DataCategory, DsnComponents, DynamicSamplingContext, Envelope, Event, EventDropReason, EventHint, EventProcessor, FeedbackEvent, Integration, IntegrationClass, Outcome, ParameterizedString, SdkMetadata, Session, SessionAggregates, SeverityLevel, StartSpanOptions, Transaction, Transport, TransportMakeRequestResponse } from '@sentry/types';
import { IntegrationIndex } from './integration';

@@ -36,8 +36,2 @@ import { Scope } from './scope';

export declare abstract class BaseClient<O extends ClientOptions> implements Client<O> {
/**
* A reference to a metrics aggregator
*
* @experimental Note this is alpha API. It may experience breaking changes in the future.
*/
metricsAggregator?: MetricsAggregator;
/** Options passed to the SDK. */

@@ -71,3 +65,3 @@ protected readonly _options: O;

*/
captureMessage(message: ParameterizedString, level?: Severity | SeverityLevel, hint?: EventHint, scope?: Scope): string | undefined;
captureMessage(message: ParameterizedString, level?: SeverityLevel, hint?: EventHint, scope?: Scope): string | undefined;
/**

@@ -152,6 +146,2 @@ * @inheritDoc

recordDroppedEvent(reason: EventDropReason, category: DataCategory, _event?: Event): void;
/**
* @inheritDoc
*/
captureAggregateMetrics(metricBucketItems: Array<MetricBucketItem>): void;
/** @inheritdoc */

@@ -185,2 +175,4 @@ on(hook: 'startTransaction', callback: (transaction: Transaction) => void): void;

on(hook: 'startNavigationSpan', callback: (options: StartSpanOptions) => void): void;
on(hook: 'flush', callback: () => void): void;
on(hook: 'close', callback: () => void): void;
/** @inheritdoc */

@@ -214,2 +206,10 @@ emit(hook: 'startTransaction', transaction: Transaction): void;

emit(hook: 'startNavigationSpan', options: StartSpanOptions): void;
/** @inheritdoc */
emit(hook: 'flush'): void;
/** @inheritdoc */
emit(hook: 'close'): void;
/**
* @inheritdoc
*/
sendEnvelope(envelope: Envelope): PromiseLike<void | TransportMakeRequestResponse> | void;
/** Setup integrations for this client. */

@@ -246,3 +246,3 @@ protected _setupIntegrations(): void;

*/
protected _prepareEvent(event: Event, hint: EventHint, scope?: Scope, isolationScope?: Scope): PromiseLike<Event | null>;
protected _prepareEvent(event: Event, hint: EventHint, scope?: Scope, isolationScope?: import("@sentry/types").Scope): PromiseLike<Event | null>;
/**

@@ -274,6 +274,2 @@ * Processes the event and logs an error in case of rejection

/**
* @inheritdoc
*/
protected _sendEnvelope(envelope: Envelope): PromiseLike<void | TransportMakeRequestResponse> | void;
/**
* Clears outcomes on this client and returns them.

@@ -289,9 +285,4 @@ */

*/
abstract eventFromMessage(_message: ParameterizedString, _level?: Severity | SeverityLevel, _hint?: EventHint): PromiseLike<Event>;
abstract eventFromMessage(_message: ParameterizedString, _level?: SeverityLevel, _hint?: EventHint): PromiseLike<Event>;
}
/**
* Add an event processor to the current client.
* This event processor will run for all events processed by this client.
*/
export declare function addEventProcessor(callback: EventProcessor): void;
//# sourceMappingURL=baseclient.d.ts.map

@@ -1,4 +0,3 @@

import { Breadcrumb, BreadcrumbHint, CaptureContext, CheckIn, Client, CustomSamplingContext, Event, EventHint, Extra, Extras, MonitorConfig, Primitive, Scope as ScopeInterface, Session, SessionContext, Severity, SeverityLevel, Span, TransactionContext, User } from '@sentry/types';
import { CaptureContext, CheckIn, CustomSamplingContext, Event, EventHint, EventProcessor, Extra, Extras, MonitorConfig, Primitive, Scope as ScopeInterface, Session, SessionContext, SeverityLevel, Span, TransactionContext, User } from '@sentry/types';
import { Hub } from './hub';
import { Scope } from './scope';
import { ExclusiveEventHintOrCaptureContext } from './utils/prepareEvent';

@@ -20,3 +19,3 @@ /**

*/
export declare function captureMessage(message: string, captureContext?: CaptureContext | Severity | SeverityLevel): string;
export declare function captureMessage(message: string, captureContext?: CaptureContext | SeverityLevel): string;
/**

@@ -31,18 +30,2 @@ * Captures a manually created event and sends it to Sentry.

/**
* Callback to set context information onto the scope.
* @param callback Callback function that receives Scope.
*
* @deprecated Use getCurrentScope() directly.
*/
export declare function configureScope(callback: (scope: Scope) => void): ReturnType<Hub['configureScope']>;
/**
* Records a new breadcrumb which will be attached to future events.
*
* Breadcrumbs will be added to subsequent events to provide more context on
* user's actions prior to an error or crash.
*
* @param breadcrumb The breadcrumb to record.
*/
export declare function addBreadcrumb(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): ReturnType<Hub['addBreadcrumb']>;
/**
* Sets context data with the given name.

@@ -89,40 +72,11 @@ * @param name of the context

/**
* Creates a new scope with and executes the given operation within.
* The scope is automatically removed once the operation
* finishes or throws.
* Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be
* passed `null` to start an entirely new span tree.
*
* This is essentially a convenience function for:
*
* pushScope();
* callback();
* popScope();
*/
export declare function withScope<T>(callback: (scope: Scope) => T): T;
/**
* Set the given scope as the active scope in the callback.
*/
export declare function withScope<T>(scope: ScopeInterface | undefined, callback: (scope: Scope) => T): T;
/**
* Attempts to fork the current isolation scope and the current scope based on the current async context strategy. If no
* async context strategy is set, the isolation scope and the current scope will not be forked (this is currently the
* case, for example, in the browser).
*
* Usage of this function in environments without async context strategy is discouraged and may lead to unexpected behaviour.
*
* This function is intended for Sentry SDK and SDK integration development. It is not recommended to be used in "normal"
* applications directly because it comes with pitfalls. Use at your own risk!
*
* @param callback The callback in which the passed isolation scope is active. (Note: In environments without async
* context strategy, the currently active isolation scope may change within execution of the callback.)
* @returns The same value that `callback` returns.
*/
export declare function withIsolationScope<T>(callback: (isolationScope: Scope) => T): T;
/**
* Forks the current scope and sets the provided span as active span in the context of the provided callback.
*
* @param span Spans started in the context of the provided callback will be children of this span.
* @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,
* spans started within the callback will not be attached to a parent span.
* @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.
* @returns the value returned from the provided callback function.
*/
export declare function withActiveSpan<T>(span: Span, callback: (scope: Scope) => T): T;
export declare function withActiveSpan<T>(span: Span | null, callback: (scope: ScopeInterface) => T): T;
/**

@@ -186,13 +140,2 @@ * Starts a new `Transaction` and returns it. This is the entry point to manual tracing instrumentation.

/**
* This is the getter for lastEventId.
*
* @returns The last event id of a captured event.
* @deprecated This function will be removed in the next major version of the Sentry SDK.
*/
export declare function lastEventId(): string | undefined;
/**
* Get the currently active client.
*/
export declare function getClient<C extends Client>(): C | undefined;
/**
* Returns true if Sentry has been properly initialized.

@@ -202,5 +145,7 @@ */

/**
* Get the currently active scope.
* Add an event processor.
* This will be added to the current isolation scope, ensuring any event that is processed in the current execution
* context will have the processor applied.
*/
export declare function getCurrentScope(): Scope;
export declare function addEventProcessor(callback: EventProcessor): void;
/**

@@ -207,0 +152,0 @@ * Start a session on the current isolation scope.

@@ -1,2 +0,3 @@

import { Breadcrumb, BreadcrumbHint, Client, CustomSamplingContext, Event, EventHint, Extra, Extras, Hub as HubInterface, Integration, IntegrationClass, Primitive, Session, SessionContext, Severity, SeverityLevel, Transaction, TransactionContext, User } from '@sentry/types';
import { Breadcrumb, BreadcrumbHint, Client, CustomSamplingContext, Event, EventHint, Extra, Extras, Hub as HubInterface, Integration, IntegrationClass, Primitive, Scope as ScopeInterface, Session, SessionContext, SeverityLevel, Transaction, TransactionContext, User } from '@sentry/types';
import { AsyncContextStrategy, Carrier } from './asyncContext';
import { Scope } from './scope';

@@ -12,22 +13,3 @@ /**

export declare const API_VERSION: number;
export interface RunWithAsyncContextOptions {
/** Whether to reuse an existing async context if one exists. Defaults to false. */
reuseExisting?: boolean;
}
/**
* @private Private API with no semver guarantees!
*
* Strategy used to track async context.
*/
export interface AsyncContextStrategy {
/**
* Gets the current async context. Returns undefined if there is no current async context.
*/
getCurrentHub: () => Hub | undefined;
/**
* Runs the supplied callback in its own async context.
*/
runWithAsyncContext<T>(callback: () => T, options: RunWithAsyncContextOptions): T;
}
/**
* A layer in the process stack.

@@ -38,23 +20,5 @@ * @hidden

client?: Client;
scope: Scope;
scope: ScopeInterface;
}
/**
* An object that contains a hub and maintains a scope stack.
* @hidden
*/
export interface Carrier {
__SENTRY__?: {
hub?: Hub;
acs?: AsyncContextStrategy;
/**
* Extra Hub properties injected by various SDKs
*/
integrations?: Integration[];
extensions?: {
/** Extension methods for the hub, which are bound to the current Hub instance */
[key: string]: Function;
};
};
}
/**
* @inheritDoc

@@ -66,4 +30,2 @@ */

private readonly _stack;
/** Contains the last event id of a captured event. */
private _lastEventId?;
private _isolationScope;

@@ -118,3 +80,3 @@ /**

*/
constructor(client?: Client, scope?: Scope, isolationScope?: Scope, _version?: number);
constructor(client?: Client, scope?: ScopeInterface, isolationScope?: ScopeInterface, _version?: number);
/**

@@ -141,3 +103,3 @@ * Checks if this hub's version is older than the given version.

*/
pushScope(): Scope;
pushScope(): ScopeInterface;
/**

@@ -154,3 +116,3 @@ * @inheritDoc

*/
withScope<T>(callback: (scope: Scope) => T): T;
withScope<T>(callback: (scope: ScopeInterface) => T): T;
/**

@@ -167,7 +129,7 @@ * @inheritDoc

*/
getScope(): Scope;
getScope(): ScopeInterface;
/**
* @deprecated Use `Sentry.getIsolationScope()` instead.
*/
getIsolationScope(): Scope;
getIsolationScope(): ScopeInterface;
/**

@@ -194,3 +156,3 @@ * Returns the scope stack for domains or the process.

*/
captureMessage(message: string, level?: Severity | SeverityLevel, hint?: EventHint): string;
captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string;
/**

@@ -205,8 +167,2 @@ * @inheritDoc

*
* @deprecated This will be removed in v8.
*/
lastEventId(): string | undefined;
/**
* @inheritDoc
*
* @deprecated Use `Sentry.addBreadcrumb()` instead.

@@ -251,12 +207,2 @@ */

* @inheritDoc
*
* @deprecated Use `getScope()` directly.
*/
configureScope(callback: (scope: Scope) => void): void;
/**
* @inheritDoc
*/
run(callback: (hub: Hub) => void): void;
/**
* @inheritDoc
* @deprecated Use `Sentry.getClient().getIntegrationByName()` instead.

@@ -287,9 +233,2 @@ */

* @inheritDoc
* @deprecated Use `spanToTraceHeader()` instead.
*/
traceHeaders(): {
[key: string]: string;
};
/**
* @inheritDoc
*

@@ -327,10 +266,2 @@ * @deprecated Use top level `captureSession` instead.

/**
* Returns the global shim registry.
*
* FIXME: This function is problematic, because despite always returning a valid Carrier,
* it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check
* at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there.
**/
export declare function getMainCarrier(): Carrier;
/**
* Replaces the current main hub with the passed one on the global object

@@ -342,3 +273,3 @@ *

*/
export declare function makeMain(hub: Hub): Hub;
export declare function makeMain(hub: HubInterface): HubInterface;
/**

@@ -353,43 +284,17 @@ * Returns the default hub instance.

*/
export declare function getCurrentHub(): Hub;
export declare function getCurrentHub(): HubInterface;
/** Get the default current scope. */
export declare function getDefaultCurrentScope(): Scope;
/** Get the default isolation scope. */
export declare function getDefaultIsolationScope(): Scope;
/**
* Get the currently active isolation scope.
* The isolation scope is active for the current exection context,
* meaning that it will remain stable for the same Hub.
* Get the global hub.
* This will be removed during the v8 cycle and is only here to make migration easier.
*/
export declare function getIsolationScope(): Scope;
export declare function getGlobalHub(): HubInterface;
/**
* @private Private API with no semver guarantees!
*
* If the carrier does not contain a hub, a new hub is created with the global hub client and scope.
* Get the current async context strategy.
* If none has been setup, the default will be used.
*/
export declare function ensureHubOnCarrier(carrier: Carrier, parent?: Hub): void;
/**
* @private Private API with no semver guarantees!
*
* Sets the global async context strategy
*/
export declare function setAsyncContextStrategy(strategy: AsyncContextStrategy | undefined): void;
/**
* Runs the supplied callback in its own async context. Async Context strategies are defined per SDK.
*
* @param callback The callback to run in its own async context
* @param options Options to pass to the async context strategy
* @returns The result of the callback
*/
export declare function runWithAsyncContext<T>(callback: () => T, options?: RunWithAsyncContextOptions): T;
/**
* This will create a new {@link Hub} and add to the passed object on
* __SENTRY__.hub.
* @param carrier object
* @hidden
*/
export declare function getHubFromCarrier(carrier: Carrier): Hub;
/**
* This will set passed {@link Hub} on the passed object's __SENTRY__.hub attribute
* @param carrier object
* @param hub Hub
* @returns A boolean indicating success or failure
*/
export declare function setHubOnCarrier(carrier: Carrier, hub: Hub): boolean;
export declare function getAsyncContextStrategy(carrier: Carrier): AsyncContextStrategy;
//# sourceMappingURL=hub.d.ts.map
export { ClientClass } from './sdk';
export { AsyncContextStrategy, Carrier, Layer, RunWithAsyncContextOptions } from './hub';
export { Layer } from './hub';
export { AsyncContextStrategy, Carrier } from './asyncContext';
export { OfflineStore, OfflineTransportOptions } from './transports/offline';

@@ -10,10 +11,12 @@ export { ServerRuntimeClientOptions } from './server-runtime-client';

export { createEventEnvelope, createSessionEnvelope } from './envelope';
export { addBreadcrumb, captureCheckIn, withMonitor, captureException, captureEvent, captureMessage, close, configureScope, flush, lastEventId, startTransaction, setContext, setExtra, setExtras, setTag, setTags, setUser, withScope, withIsolationScope, getClient, isInitialized, getCurrentScope, startSession, endSession, captureSession, withActiveSpan, } from './exports';
export { getCurrentHub, getIsolationScope, getHubFromCarrier, Hub, makeMain, getMainCarrier, runWithAsyncContext, setHubOnCarrier, ensureHubOnCarrier, setAsyncContextStrategy, } from './hub';
export { captureCheckIn, withMonitor, captureException, captureEvent, captureMessage, close, flush, startTransaction, setContext, setExtra, setExtras, setTag, setTags, setUser, isInitialized, startSession, endSession, captureSession, withActiveSpan, addEventProcessor, } from './exports';
export { getCurrentHub, Hub, makeMain, getGlobalHub, getDefaultCurrentScope, getDefaultIsolationScope, } from './hub';
export { getCurrentScope, getIsolationScope, getGlobalScope, setGlobalScope, withScope, withIsolationScope, getClient, } from './currentScopes';
export { getMainCarrier, setAsyncContextStrategy, } from './asyncContext';
export { makeSession, closeSession, updateSession } from './session';
export { SessionFlusher } from './sessionflusher';
export { Scope, getGlobalScope, setGlobalScope } from './scope';
export { Scope } from './scope';
export { notifyEventProcessors, addGlobalEventProcessor, } from './eventProcessors';
export { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint } from './api';
export { BaseClient, addEventProcessor } from './baseclient';
export { BaseClient } from './baseclient';
export { ServerRuntimeClient } from './server-runtime-client';

@@ -29,3 +32,2 @@ export { initAndBind, setCurrentClient } from './sdk';

export { createCheckInEnvelope } from './checkin';
export { createSpanEnvelope } from './span';
export { hasTracingEnabled } from './utils/hasTracingEnabled';

@@ -44,2 +46,3 @@ export { isSentryRequestUrl } from './utils/isSentryRequestUrl';

export { LinkedErrors } from './integrations/linkederrors';
export { addBreadcrumb } from './breadcrumbs';
import * as INTEGRATIONS from './integrations';

@@ -51,3 +54,12 @@ export { functionToStringIntegration } from './integrations/functiontostring';

export { requestDataIntegration } from './integrations/requestdata';
export { captureConsoleIntegration } from './integrations/captureconsole';
export { debugIntegration } from './integrations/debug';
export { dedupeIntegration } from './integrations/dedupe';
export { extraErrorDataIntegration } from './integrations/extraerrordata';
export { rewriteFramesIntegration } from './integrations/rewriteframes';
export { sessionTimingIntegration } from './integrations/sessiontiming';
export { metrics } from './metrics/exports';
export { MetricData } from './metrics/exports';
export { metricsDefault } from './metrics/exports-default';
export { BrowserMetricsAggregator } from './metrics/browser-aggregator';
/** @deprecated Import the integration function directly, e.g. `inboundFiltersIntegration()` instead of `new Integrations.InboundFilter(). */

@@ -54,0 +66,0 @@ declare const Integrations: typeof INTEGRATIONS;

@@ -10,3 +10,2 @@ import { Client, Event, EventHint, Integration, IntegrationClass } from '@sentry/types';

disableErrorDefaults: boolean;
disableTransactionDefaults: boolean;
}

@@ -13,0 +12,0 @@ export declare const inboundFiltersIntegration: (options?: Partial<InboundFiltersOptions> | undefined) => import("@sentry/types").IntegrationFnResult;

@@ -25,3 +25,3 @@ import { Client, Event, EventHint, Integration, IntegrationClass } from '@sentry/types';

/**
* Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/integrations`
* Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/core`
* so it can be used in cross-platform SDKs like `@sentry/nextjs`.

@@ -28,0 +28,0 @@ * @deprecated Use `requestDataIntegration()` instead.

@@ -1,2 +0,3 @@

import { Client, ClientOptions, MeasurementUnit, MetricsAggregator as MetricsAggregatorBase, Primitive } from '@sentry/types';
import { ClientOptions, MeasurementUnit, MetricsAggregator as MetricsAggregatorBase, Primitive } from '@sentry/types';
import { BaseClient } from '../baseclient';
import { MetricType } from './types';

@@ -13,3 +14,3 @@ /**

private _forceFlush;
constructor(_client: Client<ClientOptions>);
constructor(_client: BaseClient<ClientOptions>);
/**

@@ -16,0 +17,0 @@ * @inheritDoc

@@ -1,2 +0,3 @@

import { Client, ClientOptions, MeasurementUnit, MetricsAggregator, Primitive } from '@sentry/types';
import { ClientOptions, MeasurementUnit, MetricsAggregator, Primitive } from '@sentry/types';
import { BaseClient } from '../baseclient';
import { MetricType } from './types';

@@ -13,3 +14,3 @@ /**

private readonly _interval;
constructor(_client: Client<ClientOptions>);
constructor(_client: BaseClient<ClientOptions>);
/**

@@ -16,0 +17,0 @@ * @inheritDoc

@@ -1,3 +0,8 @@

import { DsnComponents, MetricBucketItem, SdkMetadata, StatsdEnvelope } from '@sentry/types';
import { ClientOptions, DsnComponents, MetricBucketItem, SdkMetadata, StatsdEnvelope } from '@sentry/types';
import { BaseClient } from '../baseclient';
/**
* Captures aggregated metrics to the supplied client.
*/
export declare function captureAggregateMetrics(client: BaseClient<ClientOptions>, metricBucketItems: Array<MetricBucketItem>): void;
/**
* Create envelope from a metric aggregate.

@@ -4,0 +9,0 @@ */

@@ -1,3 +0,4 @@

import { ClientOptions, MeasurementUnit, Primitive } from '@sentry/types';
interface MetricData {
import { ClientOptions, MeasurementUnit, MetricsAggregator as MetricsAggregatorInterface, Primitive } from '@sentry/types';
import { BaseClient } from '../baseclient';
export interface MetricData {
unit?: MeasurementUnit;

@@ -7,2 +8,5 @@ tags?: Record<string, Primitive>;

}
type MetricsAggregatorConstructor = {
new (client: BaseClient<ClientOptions>): MetricsAggregatorInterface;
};
/**

@@ -13,3 +17,3 @@ * Adds a value to a counter metric

*/
export declare function increment(name: string, value?: number, data?: MetricData): void;
declare function increment(aggregator: MetricsAggregatorConstructor, name: string, value?: number, data?: MetricData): void;
/**

@@ -20,3 +24,3 @@ * Adds a value to a distribution metric

*/
export declare function distribution(name: string, value: number, data?: MetricData): void;
declare function distribution(aggregator: MetricsAggregatorConstructor, name: string, value: number, data?: MetricData): void;
/**

@@ -27,3 +31,3 @@ * Adds a value to a set metric. Value must be a string or integer.

*/
export declare function set(name: string, value: number | string, data?: MetricData): void;
declare function set(aggregator: MetricsAggregatorConstructor, name: string, value: number | string, data?: MetricData): void;
/**

@@ -34,3 +38,3 @@ * Adds a value to a gauge metric

*/
export declare function gauge(name: string, value: number, data?: MetricData): void;
declare function gauge(aggregator: MetricsAggregatorConstructor, name: string, value: number, data?: MetricData): void;
export declare const metrics: {

@@ -41,9 +45,4 @@ increment: typeof increment;

gauge: typeof gauge;
/** @deprecated Use `metrics.metricsAggregratorIntegration()` instead. */
MetricsAggregator: import("@sentry/types").IntegrationClass<import("@sentry/types").Integration & {
setup: (client: import("@sentry/types").Client<ClientOptions<import("@sentry/types").BaseTransportOptions>>) => void;
}>;
metricsAggregatorIntegration: () => import("@sentry/types").IntegrationFnResult;
};
export {};
//# sourceMappingURL=exports.d.ts.map

@@ -1,5 +0,4 @@

import { Attachment, Breadcrumb, CaptureContext, Client, Context, Contexts, Event, EventHint, EventProcessor, Extra, Extras, Primitive, PropagationContext, RequestSession, Scope as ScopeInterface, ScopeData, Session, Severity, SeverityLevel, Span, Transaction, User } from '@sentry/types';
import { Attachment, Breadcrumb, CaptureContext, Client, Context, Contexts, Event, EventHint, EventProcessor, Extra, Extras, Primitive, PropagationContext, RequestSession, Scope as ScopeInterface, ScopeData, Session, SeverityLevel, Span, Transaction, User } from '@sentry/types';
/**
* Holds additional event information. {@link Scope.applyToEvent} will be
* called by the client before an event will be sent.
* Holds additional event information.
*/

@@ -11,3 +10,3 @@ export declare class Scope implements ScopeInterface {

protected _scopeListeners: Array<(scope: Scope) => void>;
/** Callback list that will be called after {@link applyToEvent}. */
/** Callback list that will be called during event processing. */
protected _eventProcessors: EventProcessor[];

@@ -40,3 +39,3 @@ /** Array of breadcrumbs. */

/** Severity */
protected _level?: Severity | SeverityLevel;
protected _level?: SeverityLevel;
/**

@@ -71,3 +70,3 @@ * Transaction Name

*/
getClient(): Client | undefined;
getClient<C extends Client>(): C | undefined;
/**

@@ -123,3 +122,3 @@ * Add internal on change listener. Used for sub SDKs that need to store the scope.

*/
setLevel(level: Severity | SeverityLevel): this;
setLevel(level: SeverityLevel): this;
/**

@@ -194,11 +193,2 @@ * Sets the transaction name on the scope for future events.

/**
* Applies data from the scope to the event and runs all event processors on it.
*
* @param event Event
* @param hint Object containing additional information about the original exception, for use by the event processors.
* @hidden
* @deprecated Use `applyScopeDataToEvent()` directly
*/
applyToEvent(event: Event, hint?: EventHint, additionalEventProcessors?: EventProcessor[]): PromiseLike<Event | null>;
/**
* Add data which will be accessible during event processing but won't get sent to Sentry

@@ -247,13 +237,2 @@ */

}
/**
* Get the global scope.
* This scope is applied to _all_ events.
*/
export declare function getGlobalScope(): ScopeInterface;
/**
* This is mainly needed for tests.
* DO NOT USE this, as this is an internal API and subject to change.
* @hidden
*/
export declare function setGlobalScope(scope: ScopeInterface | undefined): void;
//# sourceMappingURL=scope.d.ts.map

@@ -19,6 +19,2 @@ /**

export declare const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = "sentry.origin";
/**
* The id of the profile that this span occured in.
*/
export declare const SEMANTIC_ATTRIBUTE_PROFILE_ID = "profile_id";
//# sourceMappingURL=semanticAttributes.d.ts.map

@@ -1,2 +0,2 @@

import { BaseTransportOptions, CheckIn, ClientOptions, Event, EventHint, MonitorConfig, ParameterizedString, Severity, SeverityLevel } from '@sentry/types';
import { BaseTransportOptions, CheckIn, ClientOptions, Event, EventHint, MonitorConfig, ParameterizedString, SeverityLevel } from '@sentry/types';
import { BaseClient } from './baseclient';

@@ -30,3 +30,3 @@ import { Scope } from './scope';

*/
eventFromMessage(message: ParameterizedString, level?: Severity | SeverityLevel, hint?: EventHint): PromiseLike<Event>;
eventFromMessage(message: ParameterizedString, level?: SeverityLevel, hint?: EventHint): PromiseLike<Event>;
/**

@@ -33,0 +33,0 @@ * @inheritDoc

@@ -1,2 +0,2 @@

import { Client, DynamicSamplingContext, Scope, Span } from '@sentry/types';
import { Client, DynamicSamplingContext, Span } from '@sentry/types';
/**

@@ -7,3 +7,3 @@ * Creates a dynamic sampling context from a client.

*/
export declare function getDynamicSamplingContextFromClient(trace_id: string, client: Client, scope?: Scope): DynamicSamplingContext;
export declare function getDynamicSamplingContextFromClient(trace_id: string, client: Client): DynamicSamplingContext;
/**

@@ -10,0 +10,0 @@ * Creates a dynamic sampling context from a span (and client and scope)

@@ -0,1 +1,3 @@

/** Only exposed for testing */
export declare function _resetErrorsInstrumented(): void;
/**

@@ -2,0 +4,0 @@ * Configures global error listeners

@@ -1,3 +0,2 @@

import { CustomSamplingContext, TransactionContext } from '@sentry/types';
import { Hub } from '../hub';
import { CustomSamplingContext, Hub, TransactionContext } from '@sentry/types';
import { IdleTransaction } from './idletransaction';

@@ -4,0 +3,0 @@ /**

@@ -1,5 +0,4 @@

import { SpanTimeInput, TransactionContext } from '@sentry/types';
import { Hub } from '../hub';
import { Span } from './span';
import { SpanRecorder } from './span';
import { Hub, SpanTimeInput, TransactionContext } from '@sentry/types';
import { SentrySpan } from './sentrySpan';
import { SpanRecorder } from './sentrySpan';
import { Transaction } from './transaction';

@@ -22,3 +21,3 @@ export declare const TRACING_DEFAULTS: {

*/
add(span: Span): void;
add(span: SentrySpan): void;
}

@@ -25,0 +24,0 @@ export type BeforeFinishCallback = (transactionSpan: IdleTransaction, endTimestamp: number) => void;

export { startIdleTransaction, addTracingExtensions } from './hubextensions';
export { IdleTransaction, TRACING_DEFAULTS } from './idletransaction';
export { BeforeFinishCallback } from './idletransaction';
export { Span } from './span';
export { SentrySpan } from './sentrySpan';
export { Transaction } from './transaction';
export { extractTraceparentData, getActiveTransaction } from './utils';
export { getActiveTransaction, getActiveSpan } from './utils';
export { SpanStatus } from './spanstatus';
export { setHttpStatus, spanStatusfromHttpCode, getSpanStatusFromHttpCode, } from './spanstatus';
export { setHttpStatus, getSpanStatusFromHttpCode, } from './spanstatus';
export { SpanStatusType } from './spanstatus';
export { trace, getActiveSpan, startSpan, startInactiveSpan, startActiveSpan, startSpanManual, continueTrace, } from './trace';
export { startSpan, startInactiveSpan, startSpanManual, continueTrace, } from './trace';
export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';
export { setMeasurement } from './measurement';
export { isValidSampleRate } from './sampling';
//# sourceMappingURL=index.d.ts.map

@@ -13,6 +13,2 @@ import { Options, SamplingContext } from '@sentry/types';

export declare function sampleTransaction<T extends Transaction>(transaction: T, options: Pick<Options, 'tracesSampleRate' | 'tracesSampler' | 'enableTracing'>, samplingContext: SamplingContext): T;
/**
* Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).
*/
export declare function isValidSampleRate(rate: unknown): boolean;
//# sourceMappingURL=sampling.d.ts.map

@@ -85,12 +85,2 @@ import { Span } from '@sentry/types';

/**
* Converts a HTTP status code into a {@link SpanStatusType}.
*
* @deprecated Use {@link spanStatusFromHttpCode} instead.
* This export will be removed in v8 as the signature contains a typo.
*
* @param httpStatus The HTTP response status code.
* @returns The span status or unknown_error.
*/
export declare const spanStatusfromHttpCode: typeof getSpanStatusFromHttpCode;
/**
* Sets the Http status attributes on the current span based on the http code.

@@ -97,0 +87,0 @@ * Additionally, the span's status is updated, depending on the http code.

@@ -1,20 +0,5 @@

import { Scope, Span, StartSpanOptions, TransactionContext } from '@sentry/types';
import { Span, StartSpanOptions, TransactionContext } from '@sentry/types';
import { tracingContextFromHeaders } from '@sentry/utils';
/**
* Wraps a function with a transaction/span and finishes the span after the function is done.
*
* Note that if you have not enabled tracing extensions via `addTracingExtensions`
* or you didn't set `tracesSampleRate`, this function will not generate spans
* and the `span` returned from the callback will be undefined.
*
* This function is meant to be used internally and may break at any time. Use at your own risk.
*
* @internal
* @private
*
* @deprecated Use `startSpan` instead.
*/
export declare function trace<T>(context: TransactionContext, callback: (span?: Span) => T, onError?: (error: unknown, span?: Span) => void, afterFinish?: () => void): T;
/**
* Wraps a function with a transaction/span and finishes the span after the function is done.
* The created span is the active span and will be used as parent by other spans created inside the function

@@ -31,6 +16,2 @@ * and can be accessed via `Sentry.getSpan()`, as long as the function is executed while the scope is active.

/**
* @deprecated Use {@link startSpan} instead.
*/
export declare const startActiveSpan: typeof startSpan;
/**
* Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span

@@ -58,6 +39,2 @@ * after the function is done automatically. You'll have to call `span.end()` manually.

export declare function startInactiveSpan(context: StartSpanOptions): Span | undefined;
/**
* Returns the currently active span.
*/
export declare function getActiveSpan(): Span | undefined;
interface ContinueTrace {

@@ -99,10 +76,3 @@ /**

export declare const continueTrace: ContinueTrace;
/**
* Grabs the scope and isolation scope off a span that were active when the span was started.
*/
export declare function getCapturedScopesOnSpan(span: Span): {
scope?: Scope;
isolationScope?: Scope;
};
export {};
//# sourceMappingURL=trace.d.ts.map

@@ -1,6 +0,5 @@

import { Context, DynamicSamplingContext, MeasurementUnit, SpanTimeInput, Transaction as TransactionInterface, TransactionContext, TransactionEvent, TransactionMetadata } from '@sentry/types';
import { Hub } from '../hub';
import { Span as SpanClass } from './span';
import { Context, DynamicSamplingContext, Hub, MeasurementUnit, SpanTimeInput, Transaction as TransactionInterface, TransactionContext, TransactionEvent, TransactionMetadata } from '@sentry/types';
import { SentrySpan } from './sentrySpan';
/** JSDoc */
export declare class Transaction extends SpanClass implements TransactionInterface {
export declare class Transaction extends SentrySpan implements TransactionInterface {
/**

@@ -11,2 +10,3 @@ * The reference to the current hub.

protected _name: string;
private _measurements;
private _contexts;

@@ -27,11 +27,2 @@ private _trimEnd?;

/*
* Getter for `name` property.
* @deprecated Use `spanToJSON(span).description` instead.
* Setter for `name` property, which also sets `source` as custom.
* @deprecated Use `updateName()` and `setMetadata()` instead.
*/
name: string;
/*
* Get the metadata for this transaction.

@@ -45,8 +36,2 @@ * @deprecated Use `spanGetMetadata(transaction)` instead.

metadata: TransactionMetadata;
/**
* Setter for `name` property, which also sets `source` on the metadata.
*
* @deprecated Use `.updateName()` and `.setAttribute()` instead.
*/
setName(name: string, source?: TransactionMetadata['source']): void;
/** @inheritdoc */

@@ -84,6 +69,2 @@ updateName(name: string): this;

/**
* @inheritDoc
*/
updateWithContext(transactionContext: TransactionContext): this;
/**
* @inheritdoc

@@ -104,6 +85,2 @@ *

/**
* Get the profile id of the transaction.
*/
getProfileId(): string | undefined;
/**
* Finish the transaction & prepare the event to send to Sentry.

@@ -110,0 +87,0 @@ */

@@ -1,3 +0,3 @@

import { Transaction } from '@sentry/types';
import { extractTraceparentData as _extractTraceparentData } from '@sentry/utils';
import { Span, Transaction } from '@sentry/types';
import { Scope } from '@sentry/types';
import { Hub } from '../hub';

@@ -12,14 +12,26 @@ /**

/**
* The `extractTraceparentData` function and `TRACEPARENT_REGEXP` constant used
* to be declared in this file. It was later moved into `@sentry/utils` as part of a
* move to remove `@sentry/tracing` dependencies from `@sentry/node` (`extractTraceparentData`
* is the only tracing function used by `@sentry/node`).
*
* These exports are kept here for backwards compatability's sake.
*
* See https://github.com/getsentry/sentry-javascript/issues/4642 for more details.
*
* @deprecated Import this function from `@sentry/utils` instead
* Returns the currently active span.
*/
export declare const extractTraceparentData: typeof _extractTraceparentData;
export declare function getActiveSpan(): Span | undefined;
declare const CHILD_SPANS_FIELD = "_sentryChildSpans";
type SpanWithPotentialChildren = Span & {
[CHILD_SPANS_FIELD]?: Set<Span>;
};
/**
* Adds an opaque child span reference to a span.
*/
export declare function addChildSpanToSpan(span: SpanWithPotentialChildren, childSpan: Span): void;
/**
* Obtains the entire span tree, meaning a span + all of its descendants for a particular span.
*/
export declare function getSpanTree(span: SpanWithPotentialChildren): Span[];
/** Store the scope & isolation scope for a span, which can the be used when it is finished. */
export declare function setCapturedScopesOnSpan(span: Span | undefined, scope: Scope, isolationScope: Scope): void;
/**
* Grabs the scope and isolation scope off a span that were active when the span was started.
*/
export declare function getCapturedScopesOnSpan(span: Span): {
scope?: Scope;
isolationScope?: Scope;
};
//# sourceMappingURL=utils.d.ts.map

@@ -1,3 +0,2 @@

import { CaptureContext, Client, ClientOptions, Event, EventHint, ScopeContext, StackParser } from '@sentry/types';
import { Scope } from '../scope';
import { CaptureContext, Client, ClientOptions, Event, EventHint, Scope as ScopeInterface, ScopeContext, StackParser } from '@sentry/types';
/**

@@ -30,3 +29,3 @@ * This type makes sure that we get either a CaptureContext, OR an EventHint.

*/
export declare function prepareEvent(options: ClientOptions, event: Event, hint: EventHint, scope?: Scope, client?: Client, isolationScope?: Scope): PromiseLike<Event | null>;
export declare function prepareEvent(options: ClientOptions, event: Event, hint: EventHint, scope?: ScopeInterface, client?: Client, isolationScope?: ScopeInterface): PromiseLike<Event | null>;
/**

@@ -33,0 +32,0 @@ * Puts debug IDs into the stack frames of an error event.

@@ -23,3 +23,2 @@ import { Span, SpanJSON, SpanTimeInput, TraceContext } from '@sentry/types';

* And `spanToJSON` needs the Span class from `span.ts` to check here.
* TODO v8: When we remove the deprecated stuff from `span.ts`, we can remove the circular dependency again.
*/

@@ -26,0 +25,0 @@ export declare function spanToJSON(span: Span): Partial<SpanJSON>;

@@ -1,2 +0,2 @@

export declare const SDK_VERSION = "7.105.0";
export declare const SDK_VERSION = "8.0.0-alpha.1";
//# sourceMappingURL=version.d.ts.map

@@ -1,2 +0,2 @@

import type { Breadcrumb, BreadcrumbHint, Client, ClientOptions, DataCategory, DsnComponents, DynamicSamplingContext, Envelope, Event, EventDropReason, EventHint, EventProcessor, FeedbackEvent, Integration, IntegrationClass, MetricBucketItem, MetricsAggregator, Outcome, ParameterizedString, SdkMetadata, Session, SessionAggregates, Severity, SeverityLevel, StartSpanOptions, Transaction, Transport, TransportMakeRequestResponse } from '@sentry/types';
import type { Breadcrumb, BreadcrumbHint, Client, ClientOptions, DataCategory, DsnComponents, DynamicSamplingContext, Envelope, Event, EventDropReason, EventHint, EventProcessor, FeedbackEvent, Integration, IntegrationClass, Outcome, ParameterizedString, SdkMetadata, Session, SessionAggregates, SeverityLevel, StartSpanOptions, Transaction, Transport, TransportMakeRequestResponse } from '@sentry/types';
import type { IntegrationIndex } from './integration';

@@ -36,8 +36,2 @@ import type { Scope } from './scope';

export declare abstract class BaseClient<O extends ClientOptions> implements Client<O> {
/**
* A reference to a metrics aggregator
*
* @experimental Note this is alpha API. It may experience breaking changes in the future.
*/
metricsAggregator?: MetricsAggregator;
/** Options passed to the SDK. */

@@ -71,3 +65,3 @@ protected readonly _options: O;

*/
captureMessage(message: ParameterizedString, level?: Severity | SeverityLevel, hint?: EventHint, scope?: Scope): string | undefined;
captureMessage(message: ParameterizedString, level?: SeverityLevel, hint?: EventHint, scope?: Scope): string | undefined;
/**

@@ -152,6 +146,2 @@ * @inheritDoc

recordDroppedEvent(reason: EventDropReason, category: DataCategory, _event?: Event): void;
/**
* @inheritDoc
*/
captureAggregateMetrics(metricBucketItems: Array<MetricBucketItem>): void;
/** @inheritdoc */

@@ -185,2 +175,4 @@ on(hook: 'startTransaction', callback: (transaction: Transaction) => void): void;

on(hook: 'startNavigationSpan', callback: (options: StartSpanOptions) => void): void;
on(hook: 'flush', callback: () => void): void;
on(hook: 'close', callback: () => void): void;
/** @inheritdoc */

@@ -214,2 +206,10 @@ emit(hook: 'startTransaction', transaction: Transaction): void;

emit(hook: 'startNavigationSpan', options: StartSpanOptions): void;
/** @inheritdoc */
emit(hook: 'flush'): void;
/** @inheritdoc */
emit(hook: 'close'): void;
/**
* @inheritdoc
*/
sendEnvelope(envelope: Envelope): PromiseLike<void | TransportMakeRequestResponse> | void;
/** Setup integrations for this client. */

@@ -246,3 +246,3 @@ protected _setupIntegrations(): void;

*/
protected _prepareEvent(event: Event, hint: EventHint, scope?: Scope, isolationScope?: Scope): PromiseLike<Event | null>;
protected _prepareEvent(event: Event, hint: EventHint, scope?: Scope, isolationScope?: import("@sentry/types").Scope): PromiseLike<Event | null>;
/**

@@ -274,6 +274,2 @@ * Processes the event and logs an error in case of rejection

/**
* @inheritdoc
*/
protected _sendEnvelope(envelope: Envelope): PromiseLike<void | TransportMakeRequestResponse> | void;
/**
* Clears outcomes on this client and returns them.

@@ -289,9 +285,4 @@ */

*/
abstract eventFromMessage(_message: ParameterizedString, _level?: Severity | SeverityLevel, _hint?: EventHint): PromiseLike<Event>;
abstract eventFromMessage(_message: ParameterizedString, _level?: SeverityLevel, _hint?: EventHint): PromiseLike<Event>;
}
/**
* Add an event processor to the current client.
* This event processor will run for all events processed by this client.
*/
export declare function addEventProcessor(callback: EventProcessor): void;
//# sourceMappingURL=baseclient.d.ts.map

@@ -1,4 +0,3 @@

import type { Breadcrumb, BreadcrumbHint, CaptureContext, CheckIn, Client, CustomSamplingContext, Event, EventHint, Extra, Extras, MonitorConfig, Primitive, Scope as ScopeInterface, Session, SessionContext, Severity, SeverityLevel, Span, TransactionContext, User } from '@sentry/types';
import type { CaptureContext, CheckIn, CustomSamplingContext, Event, EventHint, EventProcessor, Extra, Extras, MonitorConfig, Primitive, Scope as ScopeInterface, Session, SessionContext, SeverityLevel, Span, TransactionContext, User } from '@sentry/types';
import type { Hub } from './hub';
import type { Scope } from './scope';
import type { ExclusiveEventHintOrCaptureContext } from './utils/prepareEvent';

@@ -20,3 +19,3 @@ /**

*/
export declare function captureMessage(message: string, captureContext?: CaptureContext | Severity | SeverityLevel): string;
export declare function captureMessage(message: string, captureContext?: CaptureContext | SeverityLevel): string;
/**

@@ -31,18 +30,2 @@ * Captures a manually created event and sends it to Sentry.

/**
* Callback to set context information onto the scope.
* @param callback Callback function that receives Scope.
*
* @deprecated Use getCurrentScope() directly.
*/
export declare function configureScope(callback: (scope: Scope) => void): ReturnType<Hub['configureScope']>;
/**
* Records a new breadcrumb which will be attached to future events.
*
* Breadcrumbs will be added to subsequent events to provide more context on
* user's actions prior to an error or crash.
*
* @param breadcrumb The breadcrumb to record.
*/
export declare function addBreadcrumb(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): ReturnType<Hub['addBreadcrumb']>;
/**
* Sets context data with the given name.

@@ -89,40 +72,11 @@ * @param name of the context

/**
* Creates a new scope with and executes the given operation within.
* The scope is automatically removed once the operation
* finishes or throws.
* Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be
* passed `null` to start an entirely new span tree.
*
* This is essentially a convenience function for:
*
* pushScope();
* callback();
* popScope();
*/
export declare function withScope<T>(callback: (scope: Scope) => T): T;
/**
* Set the given scope as the active scope in the callback.
*/
export declare function withScope<T>(scope: ScopeInterface | undefined, callback: (scope: Scope) => T): T;
/**
* Attempts to fork the current isolation scope and the current scope based on the current async context strategy. If no
* async context strategy is set, the isolation scope and the current scope will not be forked (this is currently the
* case, for example, in the browser).
*
* Usage of this function in environments without async context strategy is discouraged and may lead to unexpected behaviour.
*
* This function is intended for Sentry SDK and SDK integration development. It is not recommended to be used in "normal"
* applications directly because it comes with pitfalls. Use at your own risk!
*
* @param callback The callback in which the passed isolation scope is active. (Note: In environments without async
* context strategy, the currently active isolation scope may change within execution of the callback.)
* @returns The same value that `callback` returns.
*/
export declare function withIsolationScope<T>(callback: (isolationScope: Scope) => T): T;
/**
* Forks the current scope and sets the provided span as active span in the context of the provided callback.
*
* @param span Spans started in the context of the provided callback will be children of this span.
* @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,
* spans started within the callback will not be attached to a parent span.
* @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.
* @returns the value returned from the provided callback function.
*/
export declare function withActiveSpan<T>(span: Span, callback: (scope: Scope) => T): T;
export declare function withActiveSpan<T>(span: Span | null, callback: (scope: ScopeInterface) => T): T;
/**

@@ -186,13 +140,2 @@ * Starts a new `Transaction` and returns it. This is the entry point to manual tracing instrumentation.

/**
* This is the getter for lastEventId.
*
* @returns The last event id of a captured event.
* @deprecated This function will be removed in the next major version of the Sentry SDK.
*/
export declare function lastEventId(): string | undefined;
/**
* Get the currently active client.
*/
export declare function getClient<C extends Client>(): C | undefined;
/**
* Returns true if Sentry has been properly initialized.

@@ -202,5 +145,7 @@ */

/**
* Get the currently active scope.
* Add an event processor.
* This will be added to the current isolation scope, ensuring any event that is processed in the current execution
* context will have the processor applied.
*/
export declare function getCurrentScope(): Scope;
export declare function addEventProcessor(callback: EventProcessor): void;
/**

@@ -207,0 +152,0 @@ * Start a session on the current isolation scope.

@@ -1,2 +0,3 @@

import type { Breadcrumb, BreadcrumbHint, Client, CustomSamplingContext, Event, EventHint, Extra, Extras, Hub as HubInterface, Integration, IntegrationClass, Primitive, Session, SessionContext, Severity, SeverityLevel, Transaction, TransactionContext, User } from '@sentry/types';
import type { Breadcrumb, BreadcrumbHint, Client, CustomSamplingContext, Event, EventHint, Extra, Extras, Hub as HubInterface, Integration, IntegrationClass, Primitive, Scope as ScopeInterface, Session, SessionContext, SeverityLevel, Transaction, TransactionContext, User } from '@sentry/types';
import type { AsyncContextStrategy, Carrier } from './asyncContext';
import { Scope } from './scope';

@@ -12,22 +13,3 @@ /**

export declare const API_VERSION: number;
export interface RunWithAsyncContextOptions {
/** Whether to reuse an existing async context if one exists. Defaults to false. */
reuseExisting?: boolean;
}
/**
* @private Private API with no semver guarantees!
*
* Strategy used to track async context.
*/
export interface AsyncContextStrategy {
/**
* Gets the current async context. Returns undefined if there is no current async context.
*/
getCurrentHub: () => Hub | undefined;
/**
* Runs the supplied callback in its own async context.
*/
runWithAsyncContext<T>(callback: () => T, options: RunWithAsyncContextOptions): T;
}
/**
* A layer in the process stack.

@@ -38,23 +20,5 @@ * @hidden

client?: Client;
scope: Scope;
scope: ScopeInterface;
}
/**
* An object that contains a hub and maintains a scope stack.
* @hidden
*/
export interface Carrier {
__SENTRY__?: {
hub?: Hub;
acs?: AsyncContextStrategy;
/**
* Extra Hub properties injected by various SDKs
*/
integrations?: Integration[];
extensions?: {
/** Extension methods for the hub, which are bound to the current Hub instance */
[key: string]: Function;
};
};
}
/**
* @inheritDoc

@@ -66,4 +30,2 @@ */

private readonly _stack;
/** Contains the last event id of a captured event. */
private _lastEventId?;
private _isolationScope;

@@ -118,3 +80,3 @@ /**

*/
constructor(client?: Client, scope?: Scope, isolationScope?: Scope, _version?: number);
constructor(client?: Client, scope?: ScopeInterface, isolationScope?: ScopeInterface, _version?: number);
/**

@@ -141,3 +103,3 @@ * Checks if this hub's version is older than the given version.

*/
pushScope(): Scope;
pushScope(): ScopeInterface;
/**

@@ -154,3 +116,3 @@ * @inheritDoc

*/
withScope<T>(callback: (scope: Scope) => T): T;
withScope<T>(callback: (scope: ScopeInterface) => T): T;
/**

@@ -167,7 +129,7 @@ * @inheritDoc

*/
getScope(): Scope;
getScope(): ScopeInterface;
/**
* @deprecated Use `Sentry.getIsolationScope()` instead.
*/
getIsolationScope(): Scope;
getIsolationScope(): ScopeInterface;
/**

@@ -194,3 +156,3 @@ * Returns the scope stack for domains or the process.

*/
captureMessage(message: string, level?: Severity | SeverityLevel, hint?: EventHint): string;
captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string;
/**

@@ -205,8 +167,2 @@ * @inheritDoc

*
* @deprecated This will be removed in v8.
*/
lastEventId(): string | undefined;
/**
* @inheritDoc
*
* @deprecated Use `Sentry.addBreadcrumb()` instead.

@@ -251,12 +207,2 @@ */

* @inheritDoc
*
* @deprecated Use `getScope()` directly.
*/
configureScope(callback: (scope: Scope) => void): void;
/**
* @inheritDoc
*/
run(callback: (hub: Hub) => void): void;
/**
* @inheritDoc
* @deprecated Use `Sentry.getClient().getIntegrationByName()` instead.

@@ -287,9 +233,2 @@ */

* @inheritDoc
* @deprecated Use `spanToTraceHeader()` instead.
*/
traceHeaders(): {
[key: string]: string;
};
/**
* @inheritDoc
*

@@ -327,10 +266,2 @@ * @deprecated Use top level `captureSession` instead.

/**
* Returns the global shim registry.
*
* FIXME: This function is problematic, because despite always returning a valid Carrier,
* it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check
* at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there.
**/
export declare function getMainCarrier(): Carrier;
/**
* Replaces the current main hub with the passed one on the global object

@@ -342,3 +273,3 @@ *

*/
export declare function makeMain(hub: Hub): Hub;
export declare function makeMain(hub: HubInterface): HubInterface;
/**

@@ -353,43 +284,17 @@ * Returns the default hub instance.

*/
export declare function getCurrentHub(): Hub;
export declare function getCurrentHub(): HubInterface;
/** Get the default current scope. */
export declare function getDefaultCurrentScope(): Scope;
/** Get the default isolation scope. */
export declare function getDefaultIsolationScope(): Scope;
/**
* Get the currently active isolation scope.
* The isolation scope is active for the current exection context,
* meaning that it will remain stable for the same Hub.
* Get the global hub.
* This will be removed during the v8 cycle and is only here to make migration easier.
*/
export declare function getIsolationScope(): Scope;
export declare function getGlobalHub(): HubInterface;
/**
* @private Private API with no semver guarantees!
*
* If the carrier does not contain a hub, a new hub is created with the global hub client and scope.
* Get the current async context strategy.
* If none has been setup, the default will be used.
*/
export declare function ensureHubOnCarrier(carrier: Carrier, parent?: Hub): void;
/**
* @private Private API with no semver guarantees!
*
* Sets the global async context strategy
*/
export declare function setAsyncContextStrategy(strategy: AsyncContextStrategy | undefined): void;
/**
* Runs the supplied callback in its own async context. Async Context strategies are defined per SDK.
*
* @param callback The callback to run in its own async context
* @param options Options to pass to the async context strategy
* @returns The result of the callback
*/
export declare function runWithAsyncContext<T>(callback: () => T, options?: RunWithAsyncContextOptions): T;
/**
* This will create a new {@link Hub} and add to the passed object on
* __SENTRY__.hub.
* @param carrier object
* @hidden
*/
export declare function getHubFromCarrier(carrier: Carrier): Hub;
/**
* This will set passed {@link Hub} on the passed object's __SENTRY__.hub attribute
* @param carrier object
* @param hub Hub
* @returns A boolean indicating success or failure
*/
export declare function setHubOnCarrier(carrier: Carrier, hub: Hub): boolean;
export declare function getAsyncContextStrategy(carrier: Carrier): AsyncContextStrategy;
//# sourceMappingURL=hub.d.ts.map
export type { ClientClass } from './sdk';
export type { AsyncContextStrategy, Carrier, Layer, RunWithAsyncContextOptions } from './hub';
export type { Layer } from './hub';
export type { AsyncContextStrategy, Carrier } from './asyncContext';
export type { OfflineStore, OfflineTransportOptions } from './transports/offline';

@@ -10,10 +11,12 @@ export type { ServerRuntimeClientOptions } from './server-runtime-client';

export { createEventEnvelope, createSessionEnvelope } from './envelope';
export { addBreadcrumb, captureCheckIn, withMonitor, captureException, captureEvent, captureMessage, close, configureScope, flush, lastEventId, startTransaction, setContext, setExtra, setExtras, setTag, setTags, setUser, withScope, withIsolationScope, getClient, isInitialized, getCurrentScope, startSession, endSession, captureSession, withActiveSpan, } from './exports';
export { getCurrentHub, getIsolationScope, getHubFromCarrier, Hub, makeMain, getMainCarrier, runWithAsyncContext, setHubOnCarrier, ensureHubOnCarrier, setAsyncContextStrategy, } from './hub';
export { captureCheckIn, withMonitor, captureException, captureEvent, captureMessage, close, flush, startTransaction, setContext, setExtra, setExtras, setTag, setTags, setUser, isInitialized, startSession, endSession, captureSession, withActiveSpan, addEventProcessor, } from './exports';
export { getCurrentHub, Hub, makeMain, getGlobalHub, getDefaultCurrentScope, getDefaultIsolationScope, } from './hub';
export { getCurrentScope, getIsolationScope, getGlobalScope, setGlobalScope, withScope, withIsolationScope, getClient, } from './currentScopes';
export { getMainCarrier, setAsyncContextStrategy, } from './asyncContext';
export { makeSession, closeSession, updateSession } from './session';
export { SessionFlusher } from './sessionflusher';
export { Scope, getGlobalScope, setGlobalScope } from './scope';
export { Scope } from './scope';
export { notifyEventProcessors, addGlobalEventProcessor, } from './eventProcessors';
export { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint } from './api';
export { BaseClient, addEventProcessor } from './baseclient';
export { BaseClient } from './baseclient';
export { ServerRuntimeClient } from './server-runtime-client';

@@ -29,3 +32,2 @@ export { initAndBind, setCurrentClient } from './sdk';

export { createCheckInEnvelope } from './checkin';
export { createSpanEnvelope } from './span';
export { hasTracingEnabled } from './utils/hasTracingEnabled';

@@ -44,2 +46,3 @@ export { isSentryRequestUrl } from './utils/isSentryRequestUrl';

export { LinkedErrors } from './integrations/linkederrors';
export { addBreadcrumb } from './breadcrumbs';
import * as INTEGRATIONS from './integrations';

@@ -51,3 +54,12 @@ export { functionToStringIntegration } from './integrations/functiontostring';

export { requestDataIntegration } from './integrations/requestdata';
export { captureConsoleIntegration } from './integrations/captureconsole';
export { debugIntegration } from './integrations/debug';
export { dedupeIntegration } from './integrations/dedupe';
export { extraErrorDataIntegration } from './integrations/extraerrordata';
export { rewriteFramesIntegration } from './integrations/rewriteframes';
export { sessionTimingIntegration } from './integrations/sessiontiming';
export { metrics } from './metrics/exports';
export type { MetricData } from './metrics/exports';
export { metricsDefault } from './metrics/exports-default';
export { BrowserMetricsAggregator } from './metrics/browser-aggregator';
/** @deprecated Import the integration function directly, e.g. `inboundFiltersIntegration()` instead of `new Integrations.InboundFilter(). */

@@ -54,0 +66,0 @@ declare const Integrations: typeof INTEGRATIONS;

@@ -10,3 +10,2 @@ import type { Client, Event, EventHint, Integration, IntegrationClass } from '@sentry/types';

disableErrorDefaults: boolean;
disableTransactionDefaults: boolean;
}

@@ -13,0 +12,0 @@ export declare const inboundFiltersIntegration: (options?: Partial<InboundFiltersOptions> | undefined) => import("@sentry/types").IntegrationFnResult;

@@ -25,3 +25,3 @@ import type { Client, Event, EventHint, Integration, IntegrationClass } from '@sentry/types';

/**
* Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/integrations`
* Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/core`
* so it can be used in cross-platform SDKs like `@sentry/nextjs`.

@@ -28,0 +28,0 @@ * @deprecated Use `requestDataIntegration()` instead.

@@ -1,2 +0,3 @@

import type { Client, ClientOptions, MeasurementUnit, MetricsAggregator as MetricsAggregatorBase, Primitive } from '@sentry/types';
import type { ClientOptions, MeasurementUnit, MetricsAggregator as MetricsAggregatorBase, Primitive } from '@sentry/types';
import type { BaseClient } from '../baseclient';
import type { MetricType } from './types';

@@ -13,3 +14,3 @@ /**

private _forceFlush;
constructor(_client: Client<ClientOptions>);
constructor(_client: BaseClient<ClientOptions>);
/**

@@ -16,0 +17,0 @@ * @inheritDoc

@@ -1,2 +0,3 @@

import type { Client, ClientOptions, MeasurementUnit, MetricsAggregator, Primitive } from '@sentry/types';
import type { ClientOptions, MeasurementUnit, MetricsAggregator, Primitive } from '@sentry/types';
import type { BaseClient } from '../baseclient';
import type { MetricType } from './types';

@@ -13,3 +14,3 @@ /**

private readonly _interval;
constructor(_client: Client<ClientOptions>);
constructor(_client: BaseClient<ClientOptions>);
/**

@@ -16,0 +17,0 @@ * @inheritDoc

@@ -1,3 +0,8 @@

import type { DsnComponents, MetricBucketItem, SdkMetadata, StatsdEnvelope } from '@sentry/types';
import type { ClientOptions, DsnComponents, MetricBucketItem, SdkMetadata, StatsdEnvelope } from '@sentry/types';
import type { BaseClient } from '../baseclient';
/**
* Captures aggregated metrics to the supplied client.
*/
export declare function captureAggregateMetrics(client: BaseClient<ClientOptions>, metricBucketItems: Array<MetricBucketItem>): void;
/**
* Create envelope from a metric aggregate.

@@ -4,0 +9,0 @@ */

@@ -1,3 +0,4 @@

import type { ClientOptions, MeasurementUnit, Primitive } from '@sentry/types';
interface MetricData {
import type { ClientOptions, MeasurementUnit, MetricsAggregator as MetricsAggregatorInterface, Primitive } from '@sentry/types';
import type { BaseClient } from '../baseclient';
export interface MetricData {
unit?: MeasurementUnit;

@@ -7,2 +8,5 @@ tags?: Record<string, Primitive>;

}
type MetricsAggregatorConstructor = {
new (client: BaseClient<ClientOptions>): MetricsAggregatorInterface;
};
/**

@@ -13,3 +17,3 @@ * Adds a value to a counter metric

*/
export declare function increment(name: string, value?: number, data?: MetricData): void;
declare function increment(aggregator: MetricsAggregatorConstructor, name: string, value?: number, data?: MetricData): void;
/**

@@ -20,3 +24,3 @@ * Adds a value to a distribution metric

*/
export declare function distribution(name: string, value: number, data?: MetricData): void;
declare function distribution(aggregator: MetricsAggregatorConstructor, name: string, value: number, data?: MetricData): void;
/**

@@ -27,3 +31,3 @@ * Adds a value to a set metric. Value must be a string or integer.

*/
export declare function set(name: string, value: number | string, data?: MetricData): void;
declare function set(aggregator: MetricsAggregatorConstructor, name: string, value: number | string, data?: MetricData): void;
/**

@@ -34,3 +38,3 @@ * Adds a value to a gauge metric

*/
export declare function gauge(name: string, value: number, data?: MetricData): void;
declare function gauge(aggregator: MetricsAggregatorConstructor, name: string, value: number, data?: MetricData): void;
export declare const metrics: {

@@ -41,9 +45,4 @@ increment: typeof increment;

gauge: typeof gauge;
/** @deprecated Use `metrics.metricsAggregratorIntegration()` instead. */
MetricsAggregator: import("@sentry/types").IntegrationClass<import("@sentry/types").Integration & {
setup: (client: import("@sentry/types").Client<ClientOptions<import("@sentry/types").BaseTransportOptions>>) => void;
}>;
metricsAggregatorIntegration: () => import("@sentry/types").IntegrationFnResult;
};
export {};
//# sourceMappingURL=exports.d.ts.map

@@ -1,5 +0,4 @@

import type { Attachment, Breadcrumb, CaptureContext, Client, Context, Contexts, Event, EventHint, EventProcessor, Extra, Extras, Primitive, PropagationContext, RequestSession, Scope as ScopeInterface, ScopeData, Session, Severity, SeverityLevel, Span, Transaction, User } from '@sentry/types';
import type { Attachment, Breadcrumb, CaptureContext, Client, Context, Contexts, Event, EventHint, EventProcessor, Extra, Extras, Primitive, PropagationContext, RequestSession, Scope as ScopeInterface, ScopeData, Session, SeverityLevel, Span, Transaction, User } from '@sentry/types';
/**
* Holds additional event information. {@link Scope.applyToEvent} will be
* called by the client before an event will be sent.
* Holds additional event information.
*/

@@ -11,3 +10,3 @@ export declare class Scope implements ScopeInterface {

protected _scopeListeners: Array<(scope: Scope) => void>;
/** Callback list that will be called after {@link applyToEvent}. */
/** Callback list that will be called during event processing. */
protected _eventProcessors: EventProcessor[];

@@ -40,3 +39,3 @@ /** Array of breadcrumbs. */

/** Severity */
protected _level?: Severity | SeverityLevel;
protected _level?: SeverityLevel;
/**

@@ -71,3 +70,3 @@ * Transaction Name

*/
getClient(): Client | undefined;
getClient<C extends Client>(): C | undefined;
/**

@@ -123,3 +122,3 @@ * Add internal on change listener. Used for sub SDKs that need to store the scope.

*/
setLevel(level: Severity | SeverityLevel): this;
setLevel(level: SeverityLevel): this;
/**

@@ -194,11 +193,2 @@ * Sets the transaction name on the scope for future events.

/**
* Applies data from the scope to the event and runs all event processors on it.
*
* @param event Event
* @param hint Object containing additional information about the original exception, for use by the event processors.
* @hidden
* @deprecated Use `applyScopeDataToEvent()` directly
*/
applyToEvent(event: Event, hint?: EventHint, additionalEventProcessors?: EventProcessor[]): PromiseLike<Event | null>;
/**
* Add data which will be accessible during event processing but won't get sent to Sentry

@@ -247,13 +237,2 @@ */

}
/**
* Get the global scope.
* This scope is applied to _all_ events.
*/
export declare function getGlobalScope(): ScopeInterface;
/**
* This is mainly needed for tests.
* DO NOT USE this, as this is an internal API and subject to change.
* @hidden
*/
export declare function setGlobalScope(scope: ScopeInterface | undefined): void;
//# sourceMappingURL=scope.d.ts.map

@@ -19,6 +19,2 @@ /**

export declare const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = "sentry.origin";
/**
* The id of the profile that this span occured in.
*/
export declare const SEMANTIC_ATTRIBUTE_PROFILE_ID = "profile_id";
//# sourceMappingURL=semanticAttributes.d.ts.map

@@ -1,2 +0,2 @@

import type { BaseTransportOptions, CheckIn, ClientOptions, Event, EventHint, MonitorConfig, ParameterizedString, Severity, SeverityLevel } from '@sentry/types';
import type { BaseTransportOptions, CheckIn, ClientOptions, Event, EventHint, MonitorConfig, ParameterizedString, SeverityLevel } from '@sentry/types';
import { BaseClient } from './baseclient';

@@ -30,3 +30,3 @@ import type { Scope } from './scope';

*/
eventFromMessage(message: ParameterizedString, level?: Severity | SeverityLevel, hint?: EventHint): PromiseLike<Event>;
eventFromMessage(message: ParameterizedString, level?: SeverityLevel, hint?: EventHint): PromiseLike<Event>;
/**

@@ -33,0 +33,0 @@ * @inheritDoc

@@ -1,2 +0,2 @@

import type { Client, DynamicSamplingContext, Scope, Span } from '@sentry/types';
import type { Client, DynamicSamplingContext, Span } from '@sentry/types';
/**

@@ -7,3 +7,3 @@ * Creates a dynamic sampling context from a client.

*/
export declare function getDynamicSamplingContextFromClient(trace_id: string, client: Client, scope?: Scope): DynamicSamplingContext;
export declare function getDynamicSamplingContextFromClient(trace_id: string, client: Client): DynamicSamplingContext;
/**

@@ -10,0 +10,0 @@ * Creates a dynamic sampling context from a span (and client and scope)

@@ -0,1 +1,3 @@

/** Only exposed for testing */
export declare function _resetErrorsInstrumented(): void;
/**

@@ -2,0 +4,0 @@ * Configures global error listeners

@@ -1,3 +0,2 @@

import type { CustomSamplingContext, TransactionContext } from '@sentry/types';
import type { Hub } from '../hub';
import type { CustomSamplingContext, Hub, TransactionContext } from '@sentry/types';
import { IdleTransaction } from './idletransaction';

@@ -4,0 +3,0 @@ /**

@@ -1,5 +0,4 @@

import type { SpanTimeInput, TransactionContext } from '@sentry/types';
import type { Hub } from '../hub';
import type { Span } from './span';
import { SpanRecorder } from './span';
import type { Hub, SpanTimeInput, TransactionContext } from '@sentry/types';
import type { SentrySpan } from './sentrySpan';
import { SpanRecorder } from './sentrySpan';
import { Transaction } from './transaction';

@@ -22,3 +21,3 @@ export declare const TRACING_DEFAULTS: {

*/
add(span: Span): void;
add(span: SentrySpan): void;
}

@@ -25,0 +24,0 @@ export type BeforeFinishCallback = (transactionSpan: IdleTransaction, endTimestamp: number) => void;

export { startIdleTransaction, addTracingExtensions } from './hubextensions';
export { IdleTransaction, TRACING_DEFAULTS } from './idletransaction';
export type { BeforeFinishCallback } from './idletransaction';
export { Span } from './span';
export { SentrySpan } from './sentrySpan';
export { Transaction } from './transaction';
export { extractTraceparentData, getActiveTransaction } from './utils';
export { getActiveTransaction, getActiveSpan } from './utils';
export { SpanStatus } from './spanstatus';
export { setHttpStatus, spanStatusfromHttpCode, getSpanStatusFromHttpCode, } from './spanstatus';
export { setHttpStatus, getSpanStatusFromHttpCode, } from './spanstatus';
export type { SpanStatusType } from './spanstatus';
export { trace, getActiveSpan, startSpan, startInactiveSpan, startActiveSpan, startSpanManual, continueTrace, } from './trace';
export { startSpan, startInactiveSpan, startSpanManual, continueTrace, } from './trace';
export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';
export { setMeasurement } from './measurement';
export { isValidSampleRate } from './sampling';
//# sourceMappingURL=index.d.ts.map

@@ -13,6 +13,2 @@ import type { Options, SamplingContext } from '@sentry/types';

export declare function sampleTransaction<T extends Transaction>(transaction: T, options: Pick<Options, 'tracesSampleRate' | 'tracesSampler' | 'enableTracing'>, samplingContext: SamplingContext): T;
/**
* Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).
*/
export declare function isValidSampleRate(rate: unknown): boolean;
//# sourceMappingURL=sampling.d.ts.map

@@ -85,12 +85,2 @@ import type { Span } from '@sentry/types';

/**
* Converts a HTTP status code into a {@link SpanStatusType}.
*
* @deprecated Use {@link spanStatusFromHttpCode} instead.
* This export will be removed in v8 as the signature contains a typo.
*
* @param httpStatus The HTTP response status code.
* @returns The span status or unknown_error.
*/
export declare const spanStatusfromHttpCode: typeof getSpanStatusFromHttpCode;
/**
* Sets the Http status attributes on the current span based on the http code.

@@ -97,0 +87,0 @@ * Additionally, the span's status is updated, depending on the http code.

@@ -1,20 +0,5 @@

import type { Scope, Span, StartSpanOptions, TransactionContext } from '@sentry/types';
import type { Span, StartSpanOptions, TransactionContext } from '@sentry/types';
import { tracingContextFromHeaders } from '@sentry/utils';
/**
* Wraps a function with a transaction/span and finishes the span after the function is done.
*
* Note that if you have not enabled tracing extensions via `addTracingExtensions`
* or you didn't set `tracesSampleRate`, this function will not generate spans
* and the `span` returned from the callback will be undefined.
*
* This function is meant to be used internally and may break at any time. Use at your own risk.
*
* @internal
* @private
*
* @deprecated Use `startSpan` instead.
*/
export declare function trace<T>(context: TransactionContext, callback: (span?: Span) => T, onError?: (error: unknown, span?: Span) => void, afterFinish?: () => void): T;
/**
* Wraps a function with a transaction/span and finishes the span after the function is done.
* The created span is the active span and will be used as parent by other spans created inside the function

@@ -31,6 +16,2 @@ * and can be accessed via `Sentry.getSpan()`, as long as the function is executed while the scope is active.

/**
* @deprecated Use {@link startSpan} instead.
*/
export declare const startActiveSpan: typeof startSpan;
/**
* Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span

@@ -58,6 +39,2 @@ * after the function is done automatically. You'll have to call `span.end()` manually.

export declare function startInactiveSpan(context: StartSpanOptions): Span | undefined;
/**
* Returns the currently active span.
*/
export declare function getActiveSpan(): Span | undefined;
interface ContinueTrace {

@@ -99,10 +76,3 @@ /**

export declare const continueTrace: ContinueTrace;
/**
* Grabs the scope and isolation scope off a span that were active when the span was started.
*/
export declare function getCapturedScopesOnSpan(span: Span): {
scope?: Scope;
isolationScope?: Scope;
};
export {};
//# sourceMappingURL=trace.d.ts.map

@@ -1,6 +0,5 @@

import type { Context, DynamicSamplingContext, MeasurementUnit, SpanTimeInput, Transaction as TransactionInterface, TransactionContext, TransactionEvent, TransactionMetadata } from '@sentry/types';
import type { Hub } from '../hub';
import { Span as SpanClass } from './span';
import type { Context, DynamicSamplingContext, Hub, MeasurementUnit, SpanTimeInput, Transaction as TransactionInterface, TransactionContext, TransactionEvent, TransactionMetadata } from '@sentry/types';
import { SentrySpan } from './sentrySpan';
/** JSDoc */
export declare class Transaction extends SpanClass implements TransactionInterface {
export declare class Transaction extends SentrySpan implements TransactionInterface {
/**

@@ -11,2 +10,3 @@ * The reference to the current hub.

protected _name: string;
private _measurements;
private _contexts;

@@ -27,12 +27,2 @@ private _trimEnd?;

/**
* Getter for `name` property.
* @deprecated Use `spanToJSON(span).description` instead.
*/
get name(): string;
/**
* Setter for `name` property, which also sets `source` as custom.
* @deprecated Use `updateName()` and `setMetadata()` instead.
*/
set name(newName: string);
/**
* Get the metadata for this transaction.

@@ -47,8 +37,2 @@ * @deprecated Use `spanGetMetadata(transaction)` instead.

set metadata(metadata: TransactionMetadata);
/**
* Setter for `name` property, which also sets `source` on the metadata.
*
* @deprecated Use `.updateName()` and `.setAttribute()` instead.
*/
setName(name: string, source?: TransactionMetadata['source']): void;
/** @inheritdoc */

@@ -86,6 +70,2 @@ updateName(name: string): this;

/**
* @inheritDoc
*/
updateWithContext(transactionContext: TransactionContext): this;
/**
* @inheritdoc

@@ -106,6 +86,2 @@ *

/**
* Get the profile id of the transaction.
*/
getProfileId(): string | undefined;
/**
* Finish the transaction & prepare the event to send to Sentry.

@@ -112,0 +88,0 @@ */

@@ -1,3 +0,3 @@

import type { Transaction } from '@sentry/types';
import { extractTraceparentData as _extractTraceparentData } from '@sentry/utils';
import type { Span, Transaction } from '@sentry/types';
import type { Scope } from '@sentry/types';
import type { Hub } from '../hub';

@@ -12,14 +12,26 @@ /**

/**
* The `extractTraceparentData` function and `TRACEPARENT_REGEXP` constant used
* to be declared in this file. It was later moved into `@sentry/utils` as part of a
* move to remove `@sentry/tracing` dependencies from `@sentry/node` (`extractTraceparentData`
* is the only tracing function used by `@sentry/node`).
*
* These exports are kept here for backwards compatability's sake.
*
* See https://github.com/getsentry/sentry-javascript/issues/4642 for more details.
*
* @deprecated Import this function from `@sentry/utils` instead
* Returns the currently active span.
*/
export declare const extractTraceparentData: typeof _extractTraceparentData;
export declare function getActiveSpan(): Span | undefined;
declare const CHILD_SPANS_FIELD = "_sentryChildSpans";
type SpanWithPotentialChildren = Span & {
[CHILD_SPANS_FIELD]?: Set<Span>;
};
/**
* Adds an opaque child span reference to a span.
*/
export declare function addChildSpanToSpan(span: SpanWithPotentialChildren, childSpan: Span): void;
/**
* Obtains the entire span tree, meaning a span + all of its descendants for a particular span.
*/
export declare function getSpanTree(span: SpanWithPotentialChildren): Span[];
/** Store the scope & isolation scope for a span, which can the be used when it is finished. */
export declare function setCapturedScopesOnSpan(span: Span | undefined, scope: Scope, isolationScope: Scope): void;
/**
* Grabs the scope and isolation scope off a span that were active when the span was started.
*/
export declare function getCapturedScopesOnSpan(span: Span): {
scope?: Scope;
isolationScope?: Scope;
};
//# sourceMappingURL=utils.d.ts.map

@@ -1,3 +0,2 @@

import type { CaptureContext, Client, ClientOptions, Event, EventHint, ScopeContext, StackParser } from '@sentry/types';
import { Scope } from '../scope';
import type { CaptureContext, Client, ClientOptions, Event, EventHint, Scope as ScopeInterface, ScopeContext, StackParser } from '@sentry/types';
/**

@@ -30,3 +29,3 @@ * This type makes sure that we get either a CaptureContext, OR an EventHint.

*/
export declare function prepareEvent(options: ClientOptions, event: Event, hint: EventHint, scope?: Scope, client?: Client, isolationScope?: Scope): PromiseLike<Event | null>;
export declare function prepareEvent(options: ClientOptions, event: Event, hint: EventHint, scope?: ScopeInterface, client?: Client, isolationScope?: ScopeInterface): PromiseLike<Event | null>;
/**

@@ -33,0 +32,0 @@ * Puts debug IDs into the stack frames of an error event.

@@ -23,3 +23,2 @@ import type { Span, SpanJSON, SpanTimeInput, TraceContext } from '@sentry/types';

* And `spanToJSON` needs the Span class from `span.ts` to check here.
* TODO v8: When we remove the deprecated stuff from `span.ts`, we can remove the circular dependency again.
*/

@@ -26,0 +25,0 @@ export declare function spanToJSON(span: Span): Partial<SpanJSON>;

@@ -1,2 +0,2 @@

export declare const SDK_VERSION = "7.105.0";
export declare const SDK_VERSION = "8.0.0-alpha.1";
//# sourceMappingURL=version.d.ts.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc