Socket
Socket
Sign inDemoInstall

@sentry/core

Package Overview
Dependencies
2
Maintainers
11
Versions
467
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.0.0-alpha.9 to 8.0.0-beta.1

cjs/getCurrentHubShim.js

27

cjs/currentScopes.js

@@ -73,11 +73,26 @@ Object.defineProperty(exports, '__esModule', { value: true });

* 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) {
/**
* Either creates a new active isolation scope, or sets the given isolation scope as active scope in the given callback.
*/
function withIsolationScope(
...rest
) {
const carrier = asyncContext.getMainCarrier();
const acs = hub.getAsyncContextStrategy(carrier);
return acs.withIsolationScope(callback);
// If a scope is defined, we want to make this the active scope instead of the default one
if (rest.length === 2) {
const [isolationScope, callback] = rest;
if (!isolationScope) {
return acs.withIsolationScope(callback);
}
return acs.withSetIsolationScope(isolationScope, callback);
}
return acs.withIsolationScope(rest[0]);
}

@@ -84,0 +99,0 @@

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

) {
if (!hasTracingEnabled.hasTracingEnabled() || !handlerData.fetchData) {
if (!handlerData.fetchData) {
return undefined;
}
const shouldCreateSpanResult = shouldCreateSpan(handlerData.fetchData.url);
const shouldCreateSpanResult = hasTracingEnabled.hasTracingEnabled() && shouldCreateSpan(handlerData.fetchData.url);

@@ -68,16 +68,18 @@ if (handlerData.endTimestamp && shouldCreateSpanResult) {

const span = shouldCreateSpanResult
? trace.startInactiveSpan({
name: `${method} ${url}`,
onlyIfParent: true,
attributes: {
url,
type: 'fetch',
'http.method': method,
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanOrigin,
},
op: 'http.client',
})
: new sentryNonRecordingSpan.SentryNonRecordingSpan();
const hasParent = !!spanUtils.getActiveSpan();
const span =
shouldCreateSpanResult && hasParent
? trace.startInactiveSpan({
name: `${method} ${url}`,
attributes: {
url,
type: 'fetch',
'http.method': method,
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanOrigin,
},
op: 'http.client',
})
: new sentryNonRecordingSpan.SentryNonRecordingSpan();
handlerData.fetchData.__span = span.spanContext().spanId;

@@ -95,3 +97,13 @@ spans[span.spanContext().spanId] = span;

options.headers = addTracingHeadersToFetchRequest(request, client, scope, options, span);
options.headers = addTracingHeadersToFetchRequest(
request,
client,
scope,
options,
// In the following cases, we do not want to use the span as base for the trace headers,
// which means that the headers will be generated from the scope:
// - If tracing is disabled (TWP)
// - If the span has no parent span - which means we ran into `onlyIfParent` check
hasTracingEnabled.hasTracingEnabled() && hasParent ? span : undefined,
);
}

@@ -98,0 +110,0 @@

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

* @inheritDoc
* @deprecated This class will be removed in v8 (tmp-deprecating so we're aware of where this is a problem)
*/
// eslint-disable-next-line deprecation/deprecation
class Hub {

@@ -471,19 +473,2 @@ /** Is a {@link Layer}[] containing the client and scope */

/**
* Returns the default hub instance.
*
* If a hub is already registered in the global carrier but this module
* contains a more recent version, it replaces the registered version.
* Otherwise, the currently registered hub will be returned.
*
* @deprecated Use the respective replacement method directly instead.
*/
function getCurrentHub() {
// Get main carrier (global for every environment)
const carrier = asyncContext.getMainCarrier();
const acs = getAsyncContextStrategy(carrier);
return acs.getCurrentHub() || getGlobalHub();
}
/** Get the default current scope. */

@@ -503,4 +488,6 @@ function getDefaultCurrentScope() {

*/
// eslint-disable-next-line deprecation/deprecation
function getGlobalHub() {
const registry = asyncContext.getMainCarrier();
// eslint-disable-next-line deprecation/deprecation
const sentry = asyncContext.getSentryCarrier(registry) ;

@@ -539,2 +526,3 @@

function withSetScope(scope, callback) {
// eslint-disable-next-line deprecation/deprecation
const hub = getGlobalHub() ;

@@ -560,3 +548,2 @@ // eslint-disable-next-line deprecation/deprecation

return {
getCurrentHub: getGlobalHub,
withIsolationScope,

@@ -577,3 +564,2 @@ withScope,

exports.getAsyncContextStrategy = getAsyncContextStrategy;
exports.getCurrentHub = getCurrentHub;
exports.getDefaultCurrentScope = getDefaultCurrentScope;

@@ -580,0 +566,0 @@ exports.getDefaultIsolationScope = getDefaultIsolationScope;

Object.defineProperty(exports, '__esModule', { value: true });
const errors = require('./tracing/errors.js');
const utils = require('./tracing/utils.js');
const hubextensions = require('./tracing/hubextensions.js');

@@ -35,2 +37,3 @@ const idleSpan = require('./tracing/idleSpan.js');

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

@@ -62,5 +65,9 @@ const isSentryRequestUrl = require('./utils/isSentryRequestUrl.js');

const trpc = require('./trpc.js');
const getCurrentHubShim = require('./getCurrentHubShim.js');
exports.registerSpanErrorInstrumentation = errors.registerSpanErrorInstrumentation;
exports.getCapturedScopesOnSpan = utils.getCapturedScopesOnSpan;
exports.setCapturedScopesOnSpan = utils.setCapturedScopesOnSpan;
exports.addTracingExtensions = hubextensions.addTracingExtensions;

@@ -80,2 +87,3 @@ exports.TRACING_DEFAULTS = idleSpan.TRACING_DEFAULTS;

exports.startSpanManual = trace.startSpanManual;
exports.suppressTracing = trace.suppressTracing;
exports.withActiveSpan = trace.withActiveSpan;

@@ -117,7 +125,4 @@ exports.getDynamicSamplingContextFromClient = dynamicSamplingContext.getDynamicSamplingContextFromClient;

exports.withMonitor = exports$1.withMonitor;
exports.Hub = hub.Hub;
exports.getCurrentHub = hub.getCurrentHub;
exports.getDefaultCurrentScope = hub.getDefaultCurrentScope;
exports.getDefaultIsolationScope = hub.getDefaultIsolationScope;
exports.getGlobalHub = hub.getGlobalHub;
exports.getClient = currentScopes.getClient;

@@ -154,2 +159,3 @@ exports.getCurrentScope = currentScopes.getCurrentScope;

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

@@ -190,2 +196,4 @@ exports.isSentryRequestUrl = isSentryRequestUrl.isSentryRequestUrl;

exports.trpcMiddleware = trpc.trpcMiddleware;
exports.getCurrentHub = getCurrentHubShim.getCurrentHub;
exports.getCurrentHubShim = getCurrentHubShim.getCurrentHubShim;
//# sourceMappingURL=index.js.map

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

if (debugBuild.DEBUG_BUILD && possibleMessages.length === 0) {
utils.logger.error(`Could not extract message for event ${utils.getEventDescription(event)}`);
}
return possibleMessages;

@@ -156,0 +152,0 @@ }

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

const _rewriteFramesIntegration = ((options = {}) => {
/**
* Rewrite event frames paths.
*/
const rewriteFramesIntegration = integration.defineIntegration((options = {}) => {
const root = options.root;
const prefix = options.prefix || 'app:///';
const iteratee =
options.iteratee ||
((frame) => {
if (!frame.filename) {
return frame;
}
// Determine if this is a Windows frame by checking for a Windows-style prefix such as `C:\`
const isWindowsFrame =
/^[a-zA-Z]:\\/.test(frame.filename) ||
// or the presence of a backslash without a forward slash (which are not allowed on Windows)
(frame.filename.includes('\\') && !frame.filename.includes('/'));
// Check if the frame filename begins with `/`
const startsWithSlash = /^\//.test(frame.filename);
if (isWindowsFrame || startsWithSlash) {
const filename = isWindowsFrame
? frame.filename
.replace(/^[a-zA-Z]:/, '') // remove Windows-style prefix
.replace(/\\/g, '/') // replace all `\\` instances with `/`
: frame.filename;
const base = root ? utils.relative(root, filename) : utils.basename(filename);
frame.filename = `${prefix}${base}`;
}
return frame;
});
const isBrowser = 'window' in utils.GLOBAL_OBJ && utils.GLOBAL_OBJ.window !== undefined;
const iteratee = options.iteratee || generateIteratee({ isBrowser, root, prefix });
/** Process an exception event. */

@@ -78,10 +60,53 @@ function _processExceptionsEvent(event) {

};
}) ;
});
/**
* Rewrite event frames paths.
* Exported only for tests.
*/
const rewriteFramesIntegration = integration.defineIntegration(_rewriteFramesIntegration);
function generateIteratee({
isBrowser,
root,
prefix,
}
) {
return (frame) => {
if (!frame.filename) {
return frame;
}
// Determine if this is a Windows frame by checking for a Windows-style prefix such as `C:\`
const isWindowsFrame =
/^[a-zA-Z]:\\/.test(frame.filename) ||
// or the presence of a backslash without a forward slash (which are not allowed on Windows)
(frame.filename.includes('\\') && !frame.filename.includes('/'));
// Check if the frame filename begins with `/`
const startsWithSlash = /^\//.test(frame.filename);
if (isBrowser) {
if (root) {
const oldFilename = frame.filename;
if (oldFilename.indexOf(root) === 0) {
frame.filename = oldFilename.replace(root, prefix);
}
}
} else {
if (isWindowsFrame || startsWithSlash) {
const filename = isWindowsFrame
? frame.filename
.replace(/^[a-zA-Z]:/, '') // remove Windows-style prefix
.replace(/\\/g, '/') // replace all `\\` instances with `/`
: frame.filename;
const base = root ? utils.relative(root, filename) : utils.basename(filename);
frame.filename = `${prefix}${base}`;
}
}
return frame;
};
}
exports.generateIteratee = generateIteratee;
exports.rewriteFramesIntegration = rewriteFramesIntegration;
//# sourceMappingURL=rewriteframes.js.map

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

}
this._flushShift = Math.floor((Math.random() * constants.DEFAULT_FLUSH_INTERVAL) / 1000);

@@ -56,3 +57,3 @@ this._forceFlush = false;

value,
unit = 'none',
unsanitizedUnit = 'none',
unsanitizedTags = {},

@@ -62,4 +63,5 @@ maybeFloatTimestamp = utils$1.timestampInSeconds(),

const timestamp = Math.floor(maybeFloatTimestamp);
const name = unsanitizedName.replace(constants.NAME_AND_TAG_KEY_NORMALIZATION_REGEX, '_');
const name = utils.sanitizeMetricKey(unsanitizedName);
const tags = utils.sanitizeTags(unsanitizedTags);
const unit = utils.sanitizeUnit(unsanitizedUnit );

@@ -66,0 +68,0 @@ const bucketKey = utils.getBucketKey(metricType, name, unit, tags);

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

value,
unit = 'none',
unsanitizedUnit = 'none',
unsanitizedTags = {},

@@ -39,4 +39,5 @@ maybeFloatTimestamp = utils$1.timestampInSeconds(),

const timestamp = Math.floor(maybeFloatTimestamp);
const name = unsanitizedName.replace(constants.NAME_AND_TAG_KEY_NORMALIZATION_REGEX, '_');
const name = utils.sanitizeMetricKey(unsanitizedName);
const tags = utils.sanitizeTags(unsanitizedTags);
const unit = utils.sanitizeUnit(unsanitizedUnit );

@@ -82,4 +83,3 @@ const bucketKey = utils.getBucketKey(metricType, name, unit, tags);

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

@@ -86,0 +86,0 @@

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

/**
* Normalization regex for metric names and metric tag names.
*
* This enforces that names and tag keys only contain alphanumeric characters,
* underscores, forward slashes, periods, and dashes.
*
* See: https://develop.sentry.dev/sdk/metrics/#normalization
*/
const NAME_AND_TAG_KEY_NORMALIZATION_REGEX = /[^a-zA-Z0-9_/.-]+/g;
/**
* Normalization regex for metric tag values.
*
* This enforces that values only contain words, digits, or the following
* special characters: _:/@.{}[\]$-
*
* See: https://develop.sentry.dev/sdk/metrics/#normalization
*/
const TAG_VALUE_NORMALIZATION_REGEX = /[^\w\d\s_:/@.{}[\]$-]+/g;
/**
* This does not match spec in https://develop.sentry.dev/sdk/metrics

@@ -52,5 +32,3 @@ * but was chosen to optimize for the most common case in browser environments.

exports.MAX_WEIGHT = MAX_WEIGHT;
exports.NAME_AND_TAG_KEY_NORMALIZATION_REGEX = NAME_AND_TAG_KEY_NORMALIZATION_REGEX;
exports.SET_METRIC_TYPE = SET_METRIC_TYPE;
exports.TAG_VALUE_NORMALIZATION_REGEX = TAG_VALUE_NORMALIZATION_REGEX;
//# sourceMappingURL=constants.js.map
Object.defineProperty(exports, '__esModule', { value: true });
const utils = require('@sentry/utils');
const constants = require('./constants.js');

@@ -58,2 +57,59 @@ /**

/**
* Sanitizes units
*
* These Regex's are straight from the normalisation docs:
* https://develop.sentry.dev/sdk/metrics/#normalization
*/
function sanitizeUnit(unit) {
return unit.replace(/[^\w]+/gi, '_');
}
/**
* Sanitizes metric keys
*
* These Regex's are straight from the normalisation docs:
* https://develop.sentry.dev/sdk/metrics/#normalization
*/
function sanitizeMetricKey(key) {
return key.replace(/[^\w\-.]+/gi, '_');
}
/**
* Sanitizes metric keys
*
* These Regex's are straight from the normalisation docs:
* https://develop.sentry.dev/sdk/metrics/#normalization
*/
function sanitizeTagKey(key) {
return key.replace(/[^\w\-./]+/gi, '');
}
/**
* These Regex's are straight from the normalisation docs:
* https://develop.sentry.dev/sdk/metrics/#normalization
*/
const tagValueReplacements = [
['\n', '\\n'],
['\r', '\\r'],
['\t', '\\t'],
['\\', '\\\\'],
['|', '\\u{7c}'],
[',', '\\u{2c}'],
];
function getCharOrReplacement(input) {
for (const [search, replacement] of tagValueReplacements) {
if (input === search) {
return replacement;
}
}
return input;
}
function sanitizeTagValue(value) {
return [...value].reduce((acc, char) => acc + getCharOrReplacement(char), '');
}
/**
* Sanitizes tags.

@@ -65,4 +121,4 @@ */

if (Object.prototype.hasOwnProperty.call(unsanitizedTags, key)) {
const sanitizedKey = key.replace(constants.NAME_AND_TAG_KEY_NORMALIZATION_REGEX, '_');
tags[sanitizedKey] = String(unsanitizedTags[key]).replace(constants.TAG_VALUE_NORMALIZATION_REGEX, '');
const sanitizedKey = sanitizeTagKey(key);
tags[sanitizedKey] = sanitizeTagValue(String(unsanitizedTags[key]));
}

@@ -74,5 +130,7 @@ }

exports.getBucketKey = getBucketKey;
exports.sanitizeMetricKey = sanitizeMetricKey;
exports.sanitizeTags = sanitizeTags;
exports.sanitizeUnit = sanitizeUnit;
exports.serializeMetricBuckets = serializeMetricBuckets;
exports.simpleHash = simpleHash;
//# sourceMappingURL=utils.js.map

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

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

@@ -46,20 +46,24 @@ /** A class object that can instantiate Client objects. */

currentScopes.getCurrentScope().setClient(client);
registerClientOnGlobalHub(client);
}
// is there a hub too?
/**
* Unfortunately, we still have to manually bind the client to the "hub" set on the global
* Sentry carrier object. This is because certain scripts (e.g. our loader script) obtain
* the client via `window.__SENTRY__.hub.getClient()`.
*
* @see {@link hub.ts getGlobalHub}
*/
function registerClientOnGlobalHub(client) {
// eslint-disable-next-line deprecation/deprecation
const hub$1 = hub.getCurrentHub();
if (isHubClass(hub$1)) {
const sentryGlobal = asyncContext.getSentryCarrier(asyncContext.getMainCarrier()) ;
// eslint-disable-next-line deprecation/deprecation
if (sentryGlobal.hub && typeof sentryGlobal.hub.getStackTop === 'function') {
// eslint-disable-next-line deprecation/deprecation
const top = hub$1.getStackTop();
top.client = client;
sentryGlobal.hub.getStackTop().client = client;
}
}
function isHubClass(hub) {
// eslint-disable-next-line deprecation/deprecation
return !!(hub ).getStackTop;
}
exports.initAndBind = initAndBind;
exports.setCurrentClient = setCurrentClient;
//# sourceMappingURL=sdk.js.map

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

const sessionflusher = require('./sessionflusher.js');
const hubextensions = require('./tracing/hubextensions.js');
const errors = require('./tracing/errors.js');
const spanOnScope = require('./utils/spanOnScope.js');

@@ -28,3 +28,3 @@ const spanUtils = require('./utils/spanUtils.js');

// Server clients always support tracing
hubextensions.addTracingExtensions();
errors.registerSpanErrorInstrumentation();

@@ -31,0 +31,0 @@ super(options);

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

/**
* Configures global error listeners
* Ensure that global errors automatically set the active span status.
*/
function registerErrorInstrumentation() {
function registerSpanErrorInstrumentation() {
if (errorsInstrumented) {

@@ -41,3 +41,3 @@ return;

exports.registerErrorInstrumentation = registerErrorInstrumentation;
exports.registerSpanErrorInstrumentation = registerSpanErrorInstrumentation;
//# sourceMappingURL=errors.js.map

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

/**
* Adds tracing extensions.
* TODO (v8): Do we still need this?? Can we solve this differently?
* @deprecated Use `registerSpanErrorInstrumentation()` instead. In v9, this function will be removed. Note that you don't need to call this in Node-based SDKs or when using `browserTracingIntegration`.
*/
function addTracingExtensions() {
errors.registerErrorInstrumentation();
errors.registerSpanErrorInstrumentation();
}

@@ -13,0 +12,0 @@

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

const SUPPRESS_TRACING_KEY = '__SENTRY_SUPPRESS_TRACING__';
/**

@@ -40,3 +42,3 @@ * Wraps a function with a transaction/span and finishes the span after the function is done.

return currentScopes.withScope(context.scope, scope => {
const parentSpan = spanOnScope._getSpanForScope(scope) ;
const parentSpan = getParentSpan(scope);

@@ -88,3 +90,3 @@ const shouldSkipSpan = context.onlyIfParent && !parentSpan;

return currentScopes.withScope(context.scope, scope => {
const parentSpan = spanOnScope._getSpanForScope(scope) ;
const parentSpan = getParentSpan(scope);

@@ -136,6 +138,6 @@ const shouldSkipSpan = context.onlyIfParent && !parentSpan;

const spanContext = normalizeContext(context);
const parentSpan = context.scope
? (spanOnScope._getSpanForScope(context.scope) )
: (spanUtils.getActiveSpan() );
const scope = context.scope || currentScopes.getCurrentScope();
const parentSpan = getParentSpan(scope);
const shouldSkipSpan = context.onlyIfParent && !parentSpan;

@@ -147,4 +149,2 @@

const scope = context.scope || currentScopes.getCurrentScope();
return createChildSpanOrTransaction({

@@ -203,2 +203,16 @@ parentSpan,

/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */
function suppressTracing(callback) {
const acs = getAcs();
if (acs.suppressTracing) {
return acs.suppressTracing(callback);
}
return currentScopes.withScope(scope => {
scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });
return callback();
});
}
function createChildSpanOrTransaction({

@@ -220,3 +234,3 @@ parentSpan,

if (parentSpan && !forceTransaction) {
span = _startChildSpan(parentSpan, spanContext);
span = _startChildSpan(parentSpan, scope, spanContext);
spanUtils.addChildSpanToSpan(parentSpan, span);

@@ -235,2 +249,3 @@ } else if (parentSpan) {

},
scope,
parentSampled,

@@ -257,2 +272,3 @@ );

},
scope,
parentSampled,

@@ -296,3 +312,3 @@ );

function _startRootSpan(spanArguments, parentSampled) {
function _startRootSpan(spanArguments, scope, parentSampled) {
const client = currentScopes.getClient();

@@ -302,13 +318,15 @@ const options = (client && client.getOptions()) || {};

const { name = '', attributes } = spanArguments;
const [sampled, sampleRate] = sampling.sampleSpan(options, {
name,
parentSampled,
attributes,
transactionContext: {
name,
parentSampled,
},
});
const [sampled, sampleRate] = scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY]
? [false]
: sampling.sampleSpan(options, {
name,
parentSampled,
attributes,
transactionContext: {
name,
parentSampled,
},
});
const transaction = new sentrySpan.SentrySpan({
const rootSpan = new sentrySpan.SentrySpan({
...spanArguments,

@@ -322,10 +340,10 @@ attributes: {

if (sampleRate !== undefined) {
transaction.setAttribute(semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, sampleRate);
rootSpan.setAttribute(semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, sampleRate);
}
if (client) {
client.emit('spanStart', transaction);
client.emit('spanStart', rootSpan);
}
return transaction;
return rootSpan;
}

@@ -337,12 +355,14 @@

*/
function _startChildSpan(parentSpan, spanArguments) {
function _startChildSpan(parentSpan, scope, spanArguments) {
const { spanId, traceId } = parentSpan.spanContext();
const sampled = spanUtils.spanIsSampled(parentSpan);
const sampled = scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY] ? false : spanUtils.spanIsSampled(parentSpan);
const childSpan = new sentrySpan.SentrySpan({
...spanArguments,
parentSpanId: spanId,
traceId,
sampled,
});
const childSpan = sampled
? new sentrySpan.SentrySpan({
...spanArguments,
parentSpanId: spanId,
traceId,
sampled,
})
: new sentryNonRecordingSpan.SentryNonRecordingSpan({ traceId });

@@ -363,2 +383,18 @@ spanUtils.addChildSpanToSpan(parentSpan, childSpan);

function getParentSpan(scope) {
const span = spanOnScope._getSpanForScope(scope) ;
if (!span) {
return undefined;
}
const client = currentScopes.getClient();
const options = client ? client.getOptions() : {};
if (options.parentSpanIsAlwaysRootSpan) {
return spanUtils.getRootSpan(span) ;
}
return span;
}
exports.continueTrace = continueTrace;

@@ -368,3 +404,4 @@ exports.startInactiveSpan = startInactiveSpan;

exports.startSpanManual = startSpanManual;
exports.suppressTracing = suppressTracing;
exports.withActiveSpan = withActiveSpan;
//# sourceMappingURL=trace.js.map

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

utils.forEachEnvelopeItem(envelope, (item, type) => {
const envelopeItemDataCategory = utils.envelopeItemTypeToDataCategory(type);
if (utils.isRateLimited(rateLimits, envelopeItemDataCategory)) {
const dataCategory = utils.envelopeItemTypeToDataCategory(type);
if (utils.isRateLimited(rateLimits, dataCategory)) {
const event = getEventForEnvelopeItem(item, type);
options.recordDroppedEvent('ratelimit_backoff', envelopeItemDataCategory, event);
options.recordDroppedEvent('ratelimit_backoff', dataCategory, event);
} else {

@@ -35,0 +35,0 @@ filteredEnvelopeItems.push(item);

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

function log(msg, error) {
debugBuild.DEBUG_BUILD && utils.logger.info(`[Offline]: ${msg}`, error);
}
/**

@@ -23,6 +19,15 @@ * Wraps a transport and stores and retries events when they fail to send.

) {
function log(...args) {
debugBuild.DEBUG_BUILD && utils.logger.info('[Offline]:', ...args);
}
return options => {
const transport = createTransport(options);
const store = options.createStore ? options.createStore(options) : undefined;
if (!options.createStore) {
throw new Error('No `createStore` function was provided');
}
const store = options.createStore(options);
let retryDelay = START_DELAY;

@@ -32,7 +37,4 @@ let flushTimer;

function shouldQueue(env, error, retryDelay) {
// We don't queue Session Replay envelopes because they are:
// - Ordered and Replay relies on the response status to know when they're successfully sent.
// - Likely to fill the queue quickly and block other events from being sent.
// We also want to drop client reports because they can be generated when we retry sending events while offline.
if (utils.envelopeContainsItemType(env, ['replay_event', 'replay_recording', 'client_report'])) {
// We want to drop client reports because they can be generated when we retry sending events while offline.
if (utils.envelopeContainsItemType(env, ['client_report'])) {
return false;

@@ -49,6 +51,2 @@ }

function flushIn(delay) {
if (!store) {
return;
}
if (flushTimer) {

@@ -61,6 +59,10 @@ clearTimeout(flushTimer );

const found = await store.pop();
const found = await store.shift();
if (found) {
log('Attempting to send previously queued event');
void send(found).catch(e => {
// We should to update the sent_at timestamp to the current time.
found[0].sent_at = new Date().toISOString();
void send(found, true).catch(e => {
log('Failed to retry sending', e);

@@ -87,3 +89,11 @@ });

async function send(envelope) {
async function send(envelope, isRetry = false) {
// We queue all replay envelopes to avoid multiple replay envelopes being sent at the same time. If one fails, we
// need to retry them in order.
if (!isRetry && utils.envelopeContainsItemType(envelope, ['replay_event', 'replay_recording'])) {
await store.push(envelope);
flushIn(MIN_DELAY);
return {};
}
try {

@@ -98,2 +108,4 @@ const result = await transport.send(envelope);

delay = utils.parseRetryAfterHeader(result.headers['retry-after']);
} else if (result.headers && result.headers['x-sentry-rate-limits']) {
delay = 60000; // 60 seconds
} // If we have a server error, return now so we don't flush the queue.

@@ -109,6 +121,11 @@ else if ((result.statusCode || 0) >= 400) {

} catch (e) {
if (store && (await shouldQueue(envelope, e , retryDelay))) {
await store.insert(envelope);
if (await shouldQueue(envelope, e , retryDelay)) {
// If this envelope was a retry, we want to add it to the front of the queue so it's retried again first.
if (isRetry) {
await store.unshift(envelope);
} else {
await store.push(envelope);
}
flushWithBackOff();
log('Error sending. Event queued', e );
log('Error sending. Event queued.', e );
return {};

@@ -115,0 +132,0 @@ } else {

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

const exports$1 = require('./exports.js');
const trace = require('./tracing/trace.js');
const semanticAttributes = require('./semanticAttributes.js');
require('./tracing/errors.js');
require('./debug-build.js');
const semanticAttributes = require('./semanticAttributes.js');
const trace = require('./tracing/trace.js');

@@ -12,0 +12,0 @@ const trpcCaptureContext = { mechanism: { handled: false, data: { function: 'trpcMiddleware' } } };

Object.defineProperty(exports, '__esModule', { value: true });
const SDK_VERSION = '8.0.0-alpha.9';
const SDK_VERSION = '8.0.0-beta.1';
exports.SDK_VERSION = SDK_VERSION;
//# sourceMappingURL=version.js.map

@@ -71,11 +71,26 @@ import { getGlobalSingleton } from '@sentry/utils';

* 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) {
/**
* Either creates a new active isolation scope, or sets the given isolation scope as active scope in the given callback.
*/
function withIsolationScope(
...rest
) {
const carrier = getMainCarrier();
const acs = getAsyncContextStrategy(carrier);
return acs.withIsolationScope(callback);
// If a scope is defined, we want to make this the active scope instead of the default one
if (rest.length === 2) {
const [isolationScope, callback] = rest;
if (!isolationScope) {
return acs.withIsolationScope(callback);
}
return acs.withSetIsolationScope(isolationScope, callback);
}
return acs.withIsolationScope(rest[0]);
}

@@ -82,0 +97,0 @@

@@ -7,3 +7,3 @@ import { generateSentryTraceHeader, dynamicSamplingContextToSentryBaggageHeader, isInstanceOf, BAGGAGE_HEADER_NAME } from '@sentry/utils';

import { hasTracingEnabled } from './utils/hasTracingEnabled.js';
import { spanToTraceHeader } from './utils/spanUtils.js';
import { getActiveSpan, spanToTraceHeader } from './utils/spanUtils.js';
import { SentryNonRecordingSpan } from './tracing/sentryNonRecordingSpan.js';

@@ -26,7 +26,7 @@ import { setHttpStatus, SPAN_STATUS_ERROR } from './tracing/spanstatus.js';

) {
if (!hasTracingEnabled() || !handlerData.fetchData) {
if (!handlerData.fetchData) {
return undefined;
}
const shouldCreateSpanResult = shouldCreateSpan(handlerData.fetchData.url);
const shouldCreateSpanResult = hasTracingEnabled() && shouldCreateSpan(handlerData.fetchData.url);

@@ -67,16 +67,18 @@ if (handlerData.endTimestamp && shouldCreateSpanResult) {

const span = shouldCreateSpanResult
? startInactiveSpan({
name: `${method} ${url}`,
onlyIfParent: true,
attributes: {
url,
type: 'fetch',
'http.method': method,
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanOrigin,
},
op: 'http.client',
})
: new SentryNonRecordingSpan();
const hasParent = !!getActiveSpan();
const span =
shouldCreateSpanResult && hasParent
? startInactiveSpan({
name: `${method} ${url}`,
attributes: {
url,
type: 'fetch',
'http.method': method,
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanOrigin,
},
op: 'http.client',
})
: new SentryNonRecordingSpan();
handlerData.fetchData.__span = span.spanContext().spanId;

@@ -94,3 +96,13 @@ spans[span.spanContext().spanId] = span;

options.headers = addTracingHeadersToFetchRequest(request, client, scope, options, span);
options.headers = addTracingHeadersToFetchRequest(
request,
client,
scope,
options,
// In the following cases, we do not want to use the span as base for the trace headers,
// which means that the headers will be generated from the scope:
// - If tracing is disabled (TWP)
// - If the span has no parent span - which means we ran into `onlyIfParent` check
hasTracingEnabled() && hasParent ? span : undefined,
);
}

@@ -97,0 +109,0 @@

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

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

@@ -32,3 +32,5 @@ import { DEBUG_BUILD } from './debug-build.js';

* @inheritDoc
* @deprecated This class will be removed in v8 (tmp-deprecating so we're aware of where this is a problem)
*/
// eslint-disable-next-line deprecation/deprecation
class Hub {

@@ -469,19 +471,2 @@ /** Is a {@link Layer}[] containing the client and scope */

/**
* Returns the default hub instance.
*
* If a hub is already registered in the global carrier but this module
* contains a more recent version, it replaces the registered version.
* Otherwise, the currently registered hub will be returned.
*
* @deprecated Use the respective replacement method directly instead.
*/
function getCurrentHub() {
// Get main carrier (global for every environment)
const carrier = getMainCarrier();
const acs = getAsyncContextStrategy(carrier);
return acs.getCurrentHub() || getGlobalHub();
}
/** Get the default current scope. */

@@ -501,4 +486,6 @@ function getDefaultCurrentScope() {

*/
// eslint-disable-next-line deprecation/deprecation
function getGlobalHub() {
const registry = getMainCarrier();
// eslint-disable-next-line deprecation/deprecation
const sentry = getSentryCarrier(registry) ;

@@ -537,2 +524,3 @@

function withSetScope(scope, callback) {
// eslint-disable-next-line deprecation/deprecation
const hub = getGlobalHub() ;

@@ -558,3 +546,2 @@ // eslint-disable-next-line deprecation/deprecation

return {
getCurrentHub: getGlobalHub,
withIsolationScope,

@@ -572,3 +559,3 @@ withScope,

export { API_VERSION, Hub, getAsyncContextStrategy, getCurrentHub, getDefaultCurrentScope, getDefaultIsolationScope, getGlobalHub };
export { API_VERSION, Hub, getAsyncContextStrategy, getDefaultCurrentScope, getDefaultIsolationScope, getGlobalHub };
//# sourceMappingURL=hub.js.map

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

export { registerSpanErrorInstrumentation } from './tracing/errors.js';
export { getCapturedScopesOnSpan, setCapturedScopesOnSpan } from './tracing/utils.js';
export { addTracingExtensions } from './tracing/hubextensions.js';

@@ -6,3 +8,3 @@ export { TRACING_DEFAULTS, startIdleSpan } from './tracing/idleSpan.js';

export { SPAN_STATUS_ERROR, SPAN_STATUS_OK, SPAN_STATUS_UNSET, getSpanStatusFromHttpCode, setHttpStatus } from './tracing/spanstatus.js';
export { continueTrace, startInactiveSpan, startSpan, startSpanManual, withActiveSpan } from './tracing/trace.js';
export { continueTrace, startInactiveSpan, startSpan, startSpanManual, suppressTracing, withActiveSpan } from './tracing/trace.js';
export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromSpan } from './tracing/dynamicSamplingContext.js';

@@ -15,3 +17,3 @@ export { setMeasurement, timedEventsToMeasurements } from './tracing/measurement.js';

export { addEventProcessor, captureCheckIn, captureEvent, captureException, captureMessage, captureSession, close, endSession, flush, isInitialized, setContext, setExtra, setExtras, setTag, setTags, setUser, startSession, withMonitor } from './exports.js';
export { Hub, getCurrentHub, getDefaultCurrentScope, getDefaultIsolationScope, getGlobalHub } from './hub.js';
export { getDefaultCurrentScope, getDefaultIsolationScope } from './hub.js';
export { getClient, getCurrentScope, getGlobalScope, getIsolationScope, withIsolationScope, withScope } from './currentScopes.js';

@@ -35,2 +37,3 @@ export { getMainCarrier, setAsyncContextStrategy } from './asyncContext.js';

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

@@ -62,2 +65,3 @@ export { isSentryRequestUrl } from './utils/isSentryRequestUrl.js';

export { trpcMiddleware } from './trpc.js';
export { getCurrentHub, getCurrentHubShim } from './getCurrentHubShim.js';
//# sourceMappingURL=index.js.map

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

if (DEBUG_BUILD && possibleMessages.length === 0) {
logger.error(`Could not extract message for event ${getEventDescription(event)}`);
}
return possibleMessages;

@@ -154,0 +150,0 @@ }

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

import { relative, basename } from '@sentry/utils';
import { GLOBAL_OBJ, relative, basename } from '@sentry/utils';
import { defineIntegration } from '../integration.js';

@@ -6,31 +6,13 @@

const _rewriteFramesIntegration = ((options = {}) => {
/**
* Rewrite event frames paths.
*/
const rewriteFramesIntegration = defineIntegration((options = {}) => {
const root = options.root;
const prefix = options.prefix || 'app:///';
const iteratee =
options.iteratee ||
((frame) => {
if (!frame.filename) {
return frame;
}
// Determine if this is a Windows frame by checking for a Windows-style prefix such as `C:\`
const isWindowsFrame =
/^[a-zA-Z]:\\/.test(frame.filename) ||
// or the presence of a backslash without a forward slash (which are not allowed on Windows)
(frame.filename.includes('\\') && !frame.filename.includes('/'));
// Check if the frame filename begins with `/`
const startsWithSlash = /^\//.test(frame.filename);
if (isWindowsFrame || startsWithSlash) {
const filename = isWindowsFrame
? frame.filename
.replace(/^[a-zA-Z]:/, '') // remove Windows-style prefix
.replace(/\\/g, '/') // replace all `\\` instances with `/`
: frame.filename;
const base = root ? relative(root, filename) : basename(filename);
frame.filename = `${prefix}${base}`;
}
return frame;
});
const isBrowser = 'window' in GLOBAL_OBJ && GLOBAL_OBJ.window !== undefined;
const iteratee = options.iteratee || generateIteratee({ isBrowser, root, prefix });
/** Process an exception event. */

@@ -76,10 +58,52 @@ function _processExceptionsEvent(event) {

};
}) ;
});
/**
* Rewrite event frames paths.
* Exported only for tests.
*/
const rewriteFramesIntegration = defineIntegration(_rewriteFramesIntegration);
function generateIteratee({
isBrowser,
root,
prefix,
}
export { rewriteFramesIntegration };
) {
return (frame) => {
if (!frame.filename) {
return frame;
}
// Determine if this is a Windows frame by checking for a Windows-style prefix such as `C:\`
const isWindowsFrame =
/^[a-zA-Z]:\\/.test(frame.filename) ||
// or the presence of a backslash without a forward slash (which are not allowed on Windows)
(frame.filename.includes('\\') && !frame.filename.includes('/'));
// Check if the frame filename begins with `/`
const startsWithSlash = /^\//.test(frame.filename);
if (isBrowser) {
if (root) {
const oldFilename = frame.filename;
if (oldFilename.indexOf(root) === 0) {
frame.filename = oldFilename.replace(root, prefix);
}
}
} else {
if (isWindowsFrame || startsWithSlash) {
const filename = isWindowsFrame
? frame.filename
.replace(/^[a-zA-Z]:/, '') // remove Windows-style prefix
.replace(/\\/g, '/') // replace all `\\` instances with `/`
: frame.filename;
const base = root ? relative(root, filename) : basename(filename);
frame.filename = `${prefix}${base}`;
}
}
return frame;
};
}
export { generateIteratee, rewriteFramesIntegration };
//# sourceMappingURL=rewriteframes.js.map
import { timestampInSeconds } from '@sentry/utils';
import { updateMetricSummaryOnActiveSpan } from '../utils/spanUtils.js';
import { DEFAULT_FLUSH_INTERVAL, NAME_AND_TAG_KEY_NORMALIZATION_REGEX, SET_METRIC_TYPE, MAX_WEIGHT } from './constants.js';
import { DEFAULT_FLUSH_INTERVAL, SET_METRIC_TYPE, MAX_WEIGHT } from './constants.js';
import { captureAggregateMetrics } from './envelope.js';
import { METRIC_MAP } from './instance.js';
import { sanitizeTags, getBucketKey } from './utils.js';
import { sanitizeMetricKey, sanitizeTags, sanitizeUnit, getBucketKey } from './utils.js';

@@ -42,2 +42,3 @@ /**

}
this._flushShift = Math.floor((Math.random() * DEFAULT_FLUSH_INTERVAL) / 1000);

@@ -54,3 +55,3 @@ this._forceFlush = false;

value,
unit = 'none',
unsanitizedUnit = 'none',
unsanitizedTags = {},

@@ -60,4 +61,5 @@ maybeFloatTimestamp = timestampInSeconds(),

const timestamp = Math.floor(maybeFloatTimestamp);
const name = unsanitizedName.replace(NAME_AND_TAG_KEY_NORMALIZATION_REGEX, '_');
const name = sanitizeMetricKey(unsanitizedName);
const tags = sanitizeTags(unsanitizedTags);
const unit = sanitizeUnit(unsanitizedUnit );

@@ -64,0 +66,0 @@ const bucketKey = getBucketKey(metricType, name, unit, tags);

import { timestampInSeconds } from '@sentry/utils';
import { updateMetricSummaryOnActiveSpan } from '../utils/spanUtils.js';
import { DEFAULT_BROWSER_FLUSH_INTERVAL, NAME_AND_TAG_KEY_NORMALIZATION_REGEX, SET_METRIC_TYPE } from './constants.js';
import { DEFAULT_BROWSER_FLUSH_INTERVAL, SET_METRIC_TYPE } from './constants.js';
import { captureAggregateMetrics } from './envelope.js';
import { METRIC_MAP } from './instance.js';
import { sanitizeTags, getBucketKey } from './utils.js';
import { sanitizeMetricKey, sanitizeTags, sanitizeUnit, getBucketKey } from './utils.js';

@@ -31,3 +31,3 @@ /**

value,
unit = 'none',
unsanitizedUnit = 'none',
unsanitizedTags = {},

@@ -37,4 +37,5 @@ maybeFloatTimestamp = timestampInSeconds(),

const timestamp = Math.floor(maybeFloatTimestamp);
const name = unsanitizedName.replace(NAME_AND_TAG_KEY_NORMALIZATION_REGEX, '_');
const name = sanitizeMetricKey(unsanitizedName);
const tags = sanitizeTags(unsanitizedTags);
const unit = sanitizeUnit(unsanitizedUnit );

@@ -80,4 +81,3 @@ const bucketKey = getBucketKey(metricType, name, unit, tags);

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

@@ -84,0 +84,0 @@

@@ -7,22 +7,2 @@ const COUNTER_METRIC_TYPE = 'c' ;

/**
* Normalization regex for metric names and metric tag names.
*
* This enforces that names and tag keys only contain alphanumeric characters,
* underscores, forward slashes, periods, and dashes.
*
* See: https://develop.sentry.dev/sdk/metrics/#normalization
*/
const NAME_AND_TAG_KEY_NORMALIZATION_REGEX = /[^a-zA-Z0-9_/.-]+/g;
/**
* Normalization regex for metric tag values.
*
* This enforces that values only contain words, digits, or the following
* special characters: _:/@.{}[\]$-
*
* See: https://develop.sentry.dev/sdk/metrics/#normalization
*/
const TAG_VALUE_NORMALIZATION_REGEX = /[^\w\d\s_:/@.{}[\]$-]+/g;
/**
* This does not match spec in https://develop.sentry.dev/sdk/metrics

@@ -44,3 +24,3 @@ * but was chosen to optimize for the most common case in browser environments.

export { COUNTER_METRIC_TYPE, DEFAULT_BROWSER_FLUSH_INTERVAL, DEFAULT_FLUSH_INTERVAL, DISTRIBUTION_METRIC_TYPE, GAUGE_METRIC_TYPE, MAX_WEIGHT, NAME_AND_TAG_KEY_NORMALIZATION_REGEX, SET_METRIC_TYPE, TAG_VALUE_NORMALIZATION_REGEX };
export { COUNTER_METRIC_TYPE, DEFAULT_BROWSER_FLUSH_INTERVAL, DEFAULT_FLUSH_INTERVAL, DISTRIBUTION_METRIC_TYPE, GAUGE_METRIC_TYPE, MAX_WEIGHT, SET_METRIC_TYPE };
//# sourceMappingURL=constants.js.map
import { dropUndefinedKeys } from '@sentry/utils';
import { NAME_AND_TAG_KEY_NORMALIZATION_REGEX, TAG_VALUE_NORMALIZATION_REGEX } from './constants.js';

@@ -56,2 +55,59 @@ /**

/**
* Sanitizes units
*
* These Regex's are straight from the normalisation docs:
* https://develop.sentry.dev/sdk/metrics/#normalization
*/
function sanitizeUnit(unit) {
return unit.replace(/[^\w]+/gi, '_');
}
/**
* Sanitizes metric keys
*
* These Regex's are straight from the normalisation docs:
* https://develop.sentry.dev/sdk/metrics/#normalization
*/
function sanitizeMetricKey(key) {
return key.replace(/[^\w\-.]+/gi, '_');
}
/**
* Sanitizes metric keys
*
* These Regex's are straight from the normalisation docs:
* https://develop.sentry.dev/sdk/metrics/#normalization
*/
function sanitizeTagKey(key) {
return key.replace(/[^\w\-./]+/gi, '');
}
/**
* These Regex's are straight from the normalisation docs:
* https://develop.sentry.dev/sdk/metrics/#normalization
*/
const tagValueReplacements = [
['\n', '\\n'],
['\r', '\\r'],
['\t', '\\t'],
['\\', '\\\\'],
['|', '\\u{7c}'],
[',', '\\u{2c}'],
];
function getCharOrReplacement(input) {
for (const [search, replacement] of tagValueReplacements) {
if (input === search) {
return replacement;
}
}
return input;
}
function sanitizeTagValue(value) {
return [...value].reduce((acc, char) => acc + getCharOrReplacement(char), '');
}
/**
* Sanitizes tags.

@@ -63,4 +119,4 @@ */

if (Object.prototype.hasOwnProperty.call(unsanitizedTags, key)) {
const sanitizedKey = key.replace(NAME_AND_TAG_KEY_NORMALIZATION_REGEX, '_');
tags[sanitizedKey] = String(unsanitizedTags[key]).replace(TAG_VALUE_NORMALIZATION_REGEX, '');
const sanitizedKey = sanitizeTagKey(key);
tags[sanitizedKey] = sanitizeTagValue(String(unsanitizedTags[key]));
}

@@ -71,3 +127,3 @@ }

export { getBucketKey, sanitizeTags, serializeMetricBuckets, simpleHash };
export { getBucketKey, sanitizeMetricKey, sanitizeTags, sanitizeUnit, serializeMetricBuckets, simpleHash };
//# sourceMappingURL=utils.js.map
import { logger, consoleSandbox } from '@sentry/utils';
import { getCurrentScope } from './currentScopes.js';
import { getSentryCarrier, getMainCarrier } from './asyncContext.js';
import { DEBUG_BUILD } from './debug-build.js';
import { getCurrentHub } from './hub.js';

@@ -43,19 +43,23 @@ /** A class object that can instantiate Client objects. */

getCurrentScope().setClient(client);
registerClientOnGlobalHub(client);
}
// is there a hub too?
/**
* Unfortunately, we still have to manually bind the client to the "hub" set on the global
* Sentry carrier object. This is because certain scripts (e.g. our loader script) obtain
* the client via `window.__SENTRY__.hub.getClient()`.
*
* @see {@link hub.ts getGlobalHub}
*/
function registerClientOnGlobalHub(client) {
// eslint-disable-next-line deprecation/deprecation
const hub = getCurrentHub();
if (isHubClass(hub)) {
const sentryGlobal = getSentryCarrier(getMainCarrier()) ;
// eslint-disable-next-line deprecation/deprecation
if (sentryGlobal.hub && typeof sentryGlobal.hub.getStackTop === 'function') {
// eslint-disable-next-line deprecation/deprecation
const top = hub.getStackTop();
top.client = client;
sentryGlobal.hub.getStackTop().client = client;
}
}
function isHubClass(hub) {
// eslint-disable-next-line deprecation/deprecation
return !!(hub ).getStackTop;
}
export { initAndBind, setCurrentClient };
//# sourceMappingURL=sdk.js.map

@@ -7,3 +7,3 @@ import { resolvedSyncPromise, eventFromUnknownInput, eventFromMessage, logger, uuid4 } from '@sentry/utils';

import { SessionFlusher } from './sessionflusher.js';
import { addTracingExtensions } from './tracing/hubextensions.js';
import { registerSpanErrorInstrumentation } from './tracing/errors.js';
import { _getSpanForScope } from './utils/spanOnScope.js';

@@ -26,3 +26,3 @@ import { getRootSpan, spanToTraceContext } from './utils/spanUtils.js';

// Server clients always support tracing
addTracingExtensions();
registerSpanErrorInstrumentation();

@@ -29,0 +29,0 @@ super(options);

@@ -9,5 +9,5 @@ import { addGlobalErrorInstrumentationHandler, addGlobalUnhandledRejectionInstrumentationHandler, logger } from '@sentry/utils';

/**
* Configures global error listeners
* Ensure that global errors automatically set the active span status.
*/
function registerErrorInstrumentation() {
function registerSpanErrorInstrumentation() {
if (errorsInstrumented) {

@@ -39,3 +39,3 @@ return;

export { registerErrorInstrumentation };
export { registerSpanErrorInstrumentation };
//# sourceMappingURL=errors.js.map

@@ -1,9 +0,8 @@

import { registerErrorInstrumentation } from './errors.js';
import { registerSpanErrorInstrumentation } from './errors.js';
/**
* Adds tracing extensions.
* TODO (v8): Do we still need this?? Can we solve this differently?
* @deprecated Use `registerSpanErrorInstrumentation()` instead. In v9, this function will be removed. Note that you don't need to call this in Node-based SDKs or when using `browserTracingIntegration`.
*/
function addTracingExtensions() {
registerErrorInstrumentation();
registerSpanErrorInstrumentation();
}

@@ -10,0 +9,0 @@

@@ -8,4 +8,4 @@ import { propagationContextFromHeaders } from '@sentry/utils';

import { hasTracingEnabled } from '../utils/hasTracingEnabled.js';
import { _getSpanForScope, _setSpanForScope } from '../utils/spanOnScope.js';
import { spanToJSON, getActiveSpan, addChildSpanToSpan, spanIsSampled, spanTimeInputToSeconds } from '../utils/spanUtils.js';
import { _setSpanForScope, _getSpanForScope } from '../utils/spanOnScope.js';
import { spanToJSON, addChildSpanToSpan, spanIsSampled, spanTimeInputToSeconds, getRootSpan } from '../utils/spanUtils.js';
import { getDynamicSamplingContextFromSpan, freezeDscOnSpan } from './dynamicSamplingContext.js';

@@ -19,2 +19,4 @@ import { logSpanStart } from './logSpans.js';

const SUPPRESS_TRACING_KEY = '__SENTRY_SUPPRESS_TRACING__';
/**

@@ -39,3 +41,3 @@ * Wraps a function with a transaction/span and finishes the span after the function is done.

return withScope(context.scope, scope => {
const parentSpan = _getSpanForScope(scope) ;
const parentSpan = getParentSpan(scope);

@@ -87,3 +89,3 @@ const shouldSkipSpan = context.onlyIfParent && !parentSpan;

return withScope(context.scope, scope => {
const parentSpan = _getSpanForScope(scope) ;
const parentSpan = getParentSpan(scope);

@@ -135,6 +137,6 @@ const shouldSkipSpan = context.onlyIfParent && !parentSpan;

const spanContext = normalizeContext(context);
const parentSpan = context.scope
? (_getSpanForScope(context.scope) )
: (getActiveSpan() );
const scope = context.scope || getCurrentScope();
const parentSpan = getParentSpan(scope);
const shouldSkipSpan = context.onlyIfParent && !parentSpan;

@@ -146,4 +148,2 @@

const scope = context.scope || getCurrentScope();
return createChildSpanOrTransaction({

@@ -202,2 +202,16 @@ parentSpan,

/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */
function suppressTracing(callback) {
const acs = getAcs();
if (acs.suppressTracing) {
return acs.suppressTracing(callback);
}
return withScope(scope => {
scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });
return callback();
});
}
function createChildSpanOrTransaction({

@@ -219,3 +233,3 @@ parentSpan,

if (parentSpan && !forceTransaction) {
span = _startChildSpan(parentSpan, spanContext);
span = _startChildSpan(parentSpan, scope, spanContext);
addChildSpanToSpan(parentSpan, span);

@@ -234,2 +248,3 @@ } else if (parentSpan) {

},
scope,
parentSampled,

@@ -256,2 +271,3 @@ );

},
scope,
parentSampled,

@@ -295,3 +311,3 @@ );

function _startRootSpan(spanArguments, parentSampled) {
function _startRootSpan(spanArguments, scope, parentSampled) {
const client = getClient();

@@ -301,13 +317,15 @@ const options = (client && client.getOptions()) || {};

const { name = '', attributes } = spanArguments;
const [sampled, sampleRate] = sampleSpan(options, {
name,
parentSampled,
attributes,
transactionContext: {
name,
parentSampled,
},
});
const [sampled, sampleRate] = scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY]
? [false]
: sampleSpan(options, {
name,
parentSampled,
attributes,
transactionContext: {
name,
parentSampled,
},
});
const transaction = new SentrySpan({
const rootSpan = new SentrySpan({
...spanArguments,

@@ -321,10 +339,10 @@ attributes: {

if (sampleRate !== undefined) {
transaction.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, sampleRate);
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, sampleRate);
}
if (client) {
client.emit('spanStart', transaction);
client.emit('spanStart', rootSpan);
}
return transaction;
return rootSpan;
}

@@ -336,12 +354,14 @@

*/
function _startChildSpan(parentSpan, spanArguments) {
function _startChildSpan(parentSpan, scope, spanArguments) {
const { spanId, traceId } = parentSpan.spanContext();
const sampled = spanIsSampled(parentSpan);
const sampled = scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY] ? false : spanIsSampled(parentSpan);
const childSpan = new SentrySpan({
...spanArguments,
parentSpanId: spanId,
traceId,
sampled,
});
const childSpan = sampled
? new SentrySpan({
...spanArguments,
parentSpanId: spanId,
traceId,
sampled,
})
: new SentryNonRecordingSpan({ traceId });

@@ -362,3 +382,19 @@ addChildSpanToSpan(parentSpan, childSpan);

export { continueTrace, startInactiveSpan, startSpan, startSpanManual, withActiveSpan };
function getParentSpan(scope) {
const span = _getSpanForScope(scope) ;
if (!span) {
return undefined;
}
const client = getClient();
const options = client ? client.getOptions() : {};
if (options.parentSpanIsAlwaysRootSpan) {
return getRootSpan(span) ;
}
return span;
}
export { continueTrace, startInactiveSpan, startSpan, startSpanManual, suppressTracing, withActiveSpan };
//# sourceMappingURL=trace.js.map

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

forEachEnvelopeItem(envelope, (item, type) => {
const envelopeItemDataCategory = envelopeItemTypeToDataCategory(type);
if (isRateLimited(rateLimits, envelopeItemDataCategory)) {
const dataCategory = envelopeItemTypeToDataCategory(type);
if (isRateLimited(rateLimits, dataCategory)) {
const event = getEventForEnvelopeItem(item, type);
options.recordDroppedEvent('ratelimit_backoff', envelopeItemDataCategory, event);
options.recordDroppedEvent('ratelimit_backoff', dataCategory, event);
} else {

@@ -33,0 +33,0 @@ filteredEnvelopeItems.push(item);

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

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

@@ -8,6 +8,2 @@

function log(msg, error) {
DEBUG_BUILD && logger.info(`[Offline]: ${msg}`, error);
}
/**

@@ -21,6 +17,15 @@ * Wraps a transport and stores and retries events when they fail to send.

) {
function log(...args) {
DEBUG_BUILD && logger.info('[Offline]:', ...args);
}
return options => {
const transport = createTransport(options);
const store = options.createStore ? options.createStore(options) : undefined;
if (!options.createStore) {
throw new Error('No `createStore` function was provided');
}
const store = options.createStore(options);
let retryDelay = START_DELAY;

@@ -30,7 +35,4 @@ let flushTimer;

function shouldQueue(env, error, retryDelay) {
// We don't queue Session Replay envelopes because they are:
// - Ordered and Replay relies on the response status to know when they're successfully sent.
// - Likely to fill the queue quickly and block other events from being sent.
// We also want to drop client reports because they can be generated when we retry sending events while offline.
if (envelopeContainsItemType(env, ['replay_event', 'replay_recording', 'client_report'])) {
// We want to drop client reports because they can be generated when we retry sending events while offline.
if (envelopeContainsItemType(env, ['client_report'])) {
return false;

@@ -47,6 +49,2 @@ }

function flushIn(delay) {
if (!store) {
return;
}
if (flushTimer) {

@@ -59,6 +57,10 @@ clearTimeout(flushTimer );

const found = await store.pop();
const found = await store.shift();
if (found) {
log('Attempting to send previously queued event');
void send(found).catch(e => {
// We should to update the sent_at timestamp to the current time.
found[0].sent_at = new Date().toISOString();
void send(found, true).catch(e => {
log('Failed to retry sending', e);

@@ -85,3 +87,11 @@ });

async function send(envelope) {
async function send(envelope, isRetry = false) {
// We queue all replay envelopes to avoid multiple replay envelopes being sent at the same time. If one fails, we
// need to retry them in order.
if (!isRetry && envelopeContainsItemType(envelope, ['replay_event', 'replay_recording'])) {
await store.push(envelope);
flushIn(MIN_DELAY);
return {};
}
try {

@@ -96,2 +106,4 @@ const result = await transport.send(envelope);

delay = parseRetryAfterHeader(result.headers['retry-after']);
} else if (result.headers && result.headers['x-sentry-rate-limits']) {
delay = 60000; // 60 seconds
} // If we have a server error, return now so we don't flush the queue.

@@ -107,6 +119,11 @@ else if ((result.statusCode || 0) >= 400) {

} catch (e) {
if (store && (await shouldQueue(envelope, e , retryDelay))) {
await store.insert(envelope);
if (await shouldQueue(envelope, e , retryDelay)) {
// If this envelope was a retry, we want to add it to the front of the queue so it's retried again first.
if (isRetry) {
await store.unshift(envelope);
} else {
await store.push(envelope);
}
flushWithBackOff();
log('Error sending. Event queued', e );
log('Error sending. Event queued.', e );
return {};

@@ -113,0 +130,0 @@ } else {

import { normalize, isThenable } from '@sentry/utils';
import { getClient } from './currentScopes.js';
import { setContext, captureException } from './exports.js';
import { startSpanManual } from './tracing/trace.js';
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from './semanticAttributes.js';
import './tracing/errors.js';
import './debug-build.js';
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from './semanticAttributes.js';
import { startSpanManual } from './tracing/trace.js';

@@ -9,0 +9,0 @@ const trpcCaptureContext = { mechanism: { handled: false, data: { function: 'trpcMiddleware' } } };

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

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

@@ -45,4 +45,4 @@ "repository": "git://github.com/getsentry/sentry-javascript.git",

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

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

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

import { Hub, Integration } from '@sentry/types';
import { Integration } from '@sentry/types';
import { Scope } from '@sentry/types';
import { startInactiveSpan, startSpan, startSpanManual, withActiveSpan } from './tracing/trace';
import { startInactiveSpan, startSpan, startSpanManual, suppressTracing, withActiveSpan } from './tracing/trace';
import { getActiveSpan } from './utils/spanUtils';

@@ -12,6 +12,2 @@ /**

/**
* Gets the currently active hub.
*/
getCurrentHub: () => Hub;
/**
* Fork the isolation scope inside of the provided callback.

@@ -50,2 +46,4 @@ */

withActiveSpan?: typeof withActiveSpan;
/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */
suppressTracing?: typeof suppressTracing;
}

@@ -52,0 +50,0 @@ /**

@@ -36,9 +36,18 @@ import { Scope } from '@sentry/types';

* 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;
/**
* Set the provided isolation scope as active in the given callback. 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!
*
* If you pass in `undefined` as a scope, it will fork a new isolation scope, the same as if no scope is passed.
*/
export declare function withIsolationScope<T>(isolationScope: Scope | undefined, callback: (isolationScope: Scope) => T): T;
/**
* Get the currently active client.

@@ -45,0 +54,0 @@ */

import { CaptureContext, CheckIn, Event, EventHint, EventProcessor, Extra, Extras, MonitorConfig, Primitive, Session, SessionContext, SeverityLevel, User } from '@sentry/types';
import { Hub } from './hub';
import { ExclusiveEventHintOrCaptureContext } from './utils/prepareEvent';

@@ -35,3 +34,3 @@ /**

[key: string]: any;
} | null): ReturnType<Hub['setContext']>;
} | null): void;
/**

@@ -41,3 +40,3 @@ * Set an object that will be merged sent as extra data with the event.

*/
export declare function setExtras(extras: Extras): ReturnType<Hub['setExtras']>;
export declare function setExtras(extras: Extras): void;
/**

@@ -48,3 +47,3 @@ * Set key:value that will be sent as extra data with the event.

*/
export declare function setExtra(key: string, extra: Extra): ReturnType<Hub['setExtra']>;
export declare function setExtra(key: string, extra: Extra): void;
/**

@@ -56,3 +55,3 @@ * Set an object that will be merged sent as tags data with the event.

[key: string]: Primitive;
}): ReturnType<Hub['setTags']>;
}): void;
/**

@@ -66,3 +65,3 @@ * Set key:value that will be sent as tags data with the event.

*/
export declare function setTag(key: string, value: Primitive): ReturnType<Hub['setTag']>;
export declare function setTag(key: string, value: Primitive): void;
/**

@@ -73,3 +72,3 @@ * Updates user context information for future events.

*/
export declare function setUser(user: User | null): ReturnType<Hub['setUser']>;
export declare function setUser(user: User | null): void;
/**

@@ -76,0 +75,0 @@ * Create a cron monitor check in and send it to Sentry.

@@ -23,2 +23,3 @@ import { Breadcrumb, BreadcrumbHint, Client, Event, EventHint, Extra, Extras, Hub as HubInterface, Integration, IntegrationClass, Primitive, Scope as ScopeInterface, Session, SessionContext, SeverityLevel, User } from '@sentry/types';

* @inheritDoc
* @deprecated This class will be removed in v8 (tmp-deprecating so we're aware of where this is a problem)
*/

@@ -210,12 +211,2 @@ export declare class Hub implements HubInterface {

}
/**
* Returns the default hub instance.
*
* If a hub is already registered in the global carrier but this module
* contains a more recent version, it replaces the registered version.
* Otherwise, the currently registered hub will be returned.
*
* @deprecated Use the respective replacement method directly instead.
*/
export declare function getCurrentHub(): HubInterface;
/** Get the default current scope. */

@@ -222,0 +213,0 @@ export declare function getDefaultCurrentScope(): Scope;

@@ -12,3 +12,3 @@ export { ClientClass } from './sdk';

export { captureCheckIn, withMonitor, captureException, captureEvent, captureMessage, close, flush, setContext, setExtra, setExtras, setTag, setTags, setUser, isInitialized, startSession, endSession, captureSession, addEventProcessor, } from './exports';
export { getCurrentHub, Hub, getGlobalHub, getDefaultCurrentScope, getDefaultIsolationScope, } from './hub';
export { getDefaultCurrentScope, getDefaultIsolationScope, } from './hub';
export { getCurrentScope, getIsolationScope, getGlobalScope, withScope, withIsolationScope, getClient, } from './currentScopes';

@@ -32,2 +32,3 @@ export { getMainCarrier, setAsyncContextStrategy, } from './asyncContext';

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

@@ -60,2 +61,3 @@ export { isSentryRequestUrl } from './utils/isSentryRequestUrl';

export { trpcMiddleware } from './trpc';
export { getCurrentHubShim, getCurrentHub } from './getCurrentHubShim';
//# sourceMappingURL=index.d.ts.map
import { StackFrame } from '@sentry/types';
type StackFrameIteratee = (frame: StackFrame) => StackFrame;
interface RewriteFramesOptions {
/**
* Root path (the beginning of the path) that will be stripped from the frames' filename.
*
* This option has slightly different behaviour in the browser and on servers:
* - In the browser, the value you provide in `root` will be stripped from the beginning stack frames' paths (if the path started with the value).
* - On the server, the root value will only replace the beginning of stack frame filepaths, when the path is absolute. If no `root` value is provided and the path is absolute, the frame will be reduced to only the filename and the provided `prefix` option.
*
* Browser example:
* - Original frame: `'http://example.com/my/path/static/asset.js'`
* - `root: 'http://example.com/my/path'`
* - `assetPrefix: 'app://'`
* - Resulting frame: `'app:///static/asset.js'`
*
* Server example:
* - Original frame: `'/User/local/my/path/static/asset.js'`
* - `root: '/User/local/my/path'`
* - `assetPrefix: 'app://'`
* - Resulting frame: `'app:///static/asset.js'`
*/
root?: string;
/**
* A custom prefix that stack frames will be prepended with.
*
* Default: `'app://'`
*
* This option has slightly different behaviour in the browser and on servers:
* - In the browser, the value you provide in `prefix` will prefix the resulting filename when the value you provided in `root` was applied. Effectively replacing whatever `root` matched in the beginning of the frame with `prefix`.
* - On the server, the prefix is applied to all stackframes with absolute paths. On Windows, the drive identifier (e.g. "C://") is replaced with the prefix.
*/
prefix?: string;
/**
* Defines an iterator that is used to iterate through all of the stack frames for modification before being sent to Sentry.
* Setting this option will effectively disable both the `root` and the `prefix` options.
*/
iteratee?: StackFrameIteratee;

@@ -12,3 +44,11 @@ }

export declare const rewriteFramesIntegration: (options?: RewriteFramesOptions | undefined) => import("@sentry/types").Integration;
/**
* Exported only for tests.
*/
export declare function generateIteratee({ isBrowser, root, prefix, }: {
isBrowser: boolean;
root?: string;
prefix: string;
}): StackFrameIteratee;
export {};
//# sourceMappingURL=rewriteframes.d.ts.map

@@ -17,3 +17,3 @@ import { Client, MeasurementUnit, MetricsAggregator as MetricsAggregatorBase, Primitive } from '@sentry/types';

*/
add(metricType: MetricType, unsanitizedName: string, value: number | string, unit?: MeasurementUnit, unsanitizedTags?: Record<string, Primitive>, maybeFloatTimestamp?: number): void;
add(metricType: MetricType, unsanitizedName: string, value: number | string, unsanitizedUnit?: MeasurementUnit, unsanitizedTags?: Record<string, Primitive>, maybeFloatTimestamp?: number): void;
/**

@@ -20,0 +20,0 @@ * Flushes the current metrics to the transport via the transport.

@@ -17,3 +17,3 @@ import { Client, MeasurementUnit, MetricsAggregator, Primitive } from '@sentry/types';

*/
add(metricType: MetricType, unsanitizedName: string, value: number | string, unit?: MeasurementUnit | undefined, unsanitizedTags?: Record<string, Primitive> | undefined, maybeFloatTimestamp?: number | undefined): void;
add(metricType: MetricType, unsanitizedName: string, value: number | string, unsanitizedUnit?: MeasurementUnit | undefined, unsanitizedTags?: Record<string, Primitive> | undefined, maybeFloatTimestamp?: number | undefined): void;
/**

@@ -20,0 +20,0 @@ * @inheritDoc

@@ -6,20 +6,2 @@ export declare const COUNTER_METRIC_TYPE: "c";

/**
* Normalization regex for metric names and metric tag names.
*
* This enforces that names and tag keys only contain alphanumeric characters,
* underscores, forward slashes, periods, and dashes.
*
* See: https://develop.sentry.dev/sdk/metrics/#normalization
*/
export declare const NAME_AND_TAG_KEY_NORMALIZATION_REGEX: RegExp;
/**
* Normalization regex for metric tag values.
*
* This enforces that values only contain words, digits, or the following
* special characters: _:/@.{}[\]$-
*
* See: https://develop.sentry.dev/sdk/metrics/#normalization
*/
export declare const TAG_VALUE_NORMALIZATION_REGEX: RegExp;
/**
* This does not match spec in https://develop.sentry.dev/sdk/metrics

@@ -26,0 +8,0 @@ * but was chosen to optimize for the most common case in browser environments.

@@ -26,2 +26,16 @@ import { MeasurementUnit, MetricBucketItem, Primitive } from '@sentry/types';

/**
* Sanitizes units
*
* These Regex's are straight from the normalisation docs:
* https://develop.sentry.dev/sdk/metrics/#normalization
*/
export declare function sanitizeUnit(unit: string): string;
/**
* Sanitizes metric keys
*
* These Regex's are straight from the normalisation docs:
* https://develop.sentry.dev/sdk/metrics/#normalization
*/
export declare function sanitizeMetricKey(key: string): string;
/**
* Sanitizes tags.

@@ -28,0 +42,0 @@ */

/** Only exposed for testing */
export declare function _resetErrorsInstrumented(): void;
/**
* Configures global error listeners
* Ensure that global errors automatically set the active span status.
*/
export declare function registerErrorInstrumentation(): void;
export declare function registerSpanErrorInstrumentation(): void;
//# sourceMappingURL=errors.d.ts.map
/**
* Adds tracing extensions.
* TODO (v8): Do we still need this?? Can we solve this differently?
* @deprecated Use `registerSpanErrorInstrumentation()` instead. In v9, this function will be removed. Note that you don't need to call this in Node-based SDKs or when using `browserTracingIntegration`.
*/
export declare function addTracingExtensions(): void;
//# sourceMappingURL=hubextensions.d.ts.map

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

export { registerSpanErrorInstrumentation } from './errors';
export { setCapturedScopesOnSpan, getCapturedScopesOnSpan } from './utils';
export { addTracingExtensions } from './hubextensions';

@@ -7,3 +9,3 @@ export { startIdleSpan, TRACING_DEFAULTS } from './idleSpan';

export { SPAN_STATUS_ERROR, SPAN_STATUS_OK, SPAN_STATUS_UNSET } from './spanstatus';
export { startSpan, startInactiveSpan, startSpanManual, continueTrace, withActiveSpan, } from './trace';
export { startSpan, startInactiveSpan, startSpanManual, continueTrace, withActiveSpan, suppressTracing, } from './trace';
export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';

@@ -10,0 +12,0 @@ export { setMeasurement, timedEventsToMeasurements } from './measurement';

@@ -57,2 +57,4 @@ import { Scope, Span, StartSpanOptions } from '@sentry/types';

export declare function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T;
/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */
export declare function suppressTracing<T>(callback: () => T): T;
//# sourceMappingURL=trace.d.ts.map

@@ -5,4 +5,5 @@ import { Envelope, InternalBaseTransportOptions, Transport } from '@sentry/types';

export interface OfflineStore {
insert(env: Envelope): Promise<void>;
pop(): Promise<Envelope | undefined>;
push(env: Envelope): Promise<void>;
unshift(env: Envelope): Promise<void>;
shift(): Promise<Envelope | undefined>;
}

@@ -9,0 +10,0 @@ export type CreateOfflineStore = (options: OfflineTransportOptions) => OfflineStore;

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

export declare const SDK_VERSION = "8.0.0-alpha.9";
export declare const SDK_VERSION = "8.0.0-beta.1";
//# sourceMappingURL=version.d.ts.map

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

import type { Hub, Integration } from '@sentry/types';
import type { Integration } from '@sentry/types';
import type { Scope } from '@sentry/types';
import type { startInactiveSpan, startSpan, startSpanManual, withActiveSpan } from './tracing/trace';
import type { startInactiveSpan, startSpan, startSpanManual, suppressTracing, withActiveSpan } from './tracing/trace';
import type { getActiveSpan } from './utils/spanUtils';

@@ -12,6 +12,2 @@ /**

/**
* Gets the currently active hub.
*/
getCurrentHub: () => Hub;
/**
* Fork the isolation scope inside of the provided callback.

@@ -50,2 +46,4 @@ */

withActiveSpan?: typeof withActiveSpan;
/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */
suppressTracing?: typeof suppressTracing;
}

@@ -52,0 +50,0 @@ /**

@@ -36,9 +36,18 @@ import type { Scope } from '@sentry/types';

* 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;
/**
* Set the provided isolation scope as active in the given callback. 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!
*
* If you pass in `undefined` as a scope, it will fork a new isolation scope, the same as if no scope is passed.
*/
export declare function withIsolationScope<T>(isolationScope: Scope | undefined, callback: (isolationScope: Scope) => T): T;
/**
* Get the currently active client.

@@ -45,0 +54,0 @@ */

import type { CaptureContext, CheckIn, Event, EventHint, EventProcessor, Extra, Extras, MonitorConfig, Primitive, Session, SessionContext, SeverityLevel, User } from '@sentry/types';
import type { Hub } from './hub';
import type { ExclusiveEventHintOrCaptureContext } from './utils/prepareEvent';

@@ -35,3 +34,3 @@ /**

[key: string]: any;
} | null): ReturnType<Hub['setContext']>;
} | null): void;
/**

@@ -41,3 +40,3 @@ * Set an object that will be merged sent as extra data with the event.

*/
export declare function setExtras(extras: Extras): ReturnType<Hub['setExtras']>;
export declare function setExtras(extras: Extras): void;
/**

@@ -48,3 +47,3 @@ * Set key:value that will be sent as extra data with the event.

*/
export declare function setExtra(key: string, extra: Extra): ReturnType<Hub['setExtra']>;
export declare function setExtra(key: string, extra: Extra): void;
/**

@@ -56,3 +55,3 @@ * Set an object that will be merged sent as tags data with the event.

[key: string]: Primitive;
}): ReturnType<Hub['setTags']>;
}): void;
/**

@@ -66,3 +65,3 @@ * Set key:value that will be sent as tags data with the event.

*/
export declare function setTag(key: string, value: Primitive): ReturnType<Hub['setTag']>;
export declare function setTag(key: string, value: Primitive): void;
/**

@@ -73,3 +72,3 @@ * Updates user context information for future events.

*/
export declare function setUser(user: User | null): ReturnType<Hub['setUser']>;
export declare function setUser(user: User | null): void;
/**

@@ -76,0 +75,0 @@ * Create a cron monitor check in and send it to Sentry.

@@ -23,2 +23,3 @@ import type { Breadcrumb, BreadcrumbHint, Client, Event, EventHint, Extra, Extras, Hub as HubInterface, Integration, IntegrationClass, Primitive, Scope as ScopeInterface, Session, SessionContext, SeverityLevel, User } from '@sentry/types';

* @inheritDoc
* @deprecated This class will be removed in v8 (tmp-deprecating so we're aware of where this is a problem)
*/

@@ -210,12 +211,2 @@ export declare class Hub implements HubInterface {

}
/**
* Returns the default hub instance.
*
* If a hub is already registered in the global carrier but this module
* contains a more recent version, it replaces the registered version.
* Otherwise, the currently registered hub will be returned.
*
* @deprecated Use the respective replacement method directly instead.
*/
export declare function getCurrentHub(): HubInterface;
/** Get the default current scope. */

@@ -222,0 +213,0 @@ export declare function getDefaultCurrentScope(): Scope;

@@ -12,3 +12,3 @@ export type { ClientClass } from './sdk';

export { captureCheckIn, withMonitor, captureException, captureEvent, captureMessage, close, flush, setContext, setExtra, setExtras, setTag, setTags, setUser, isInitialized, startSession, endSession, captureSession, addEventProcessor, } from './exports';
export { getCurrentHub, Hub, getGlobalHub, getDefaultCurrentScope, getDefaultIsolationScope, } from './hub';
export { getDefaultCurrentScope, getDefaultIsolationScope, } from './hub';
export { getCurrentScope, getIsolationScope, getGlobalScope, withScope, withIsolationScope, getClient, } from './currentScopes';

@@ -32,2 +32,3 @@ export { getMainCarrier, setAsyncContextStrategy, } from './asyncContext';

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

@@ -60,2 +61,3 @@ export { isSentryRequestUrl } from './utils/isSentryRequestUrl';

export { trpcMiddleware } from './trpc';
export { getCurrentHubShim, getCurrentHub } from './getCurrentHubShim';
//# sourceMappingURL=index.d.ts.map
import type { StackFrame } from '@sentry/types';
type StackFrameIteratee = (frame: StackFrame) => StackFrame;
interface RewriteFramesOptions {
/**
* Root path (the beginning of the path) that will be stripped from the frames' filename.
*
* This option has slightly different behaviour in the browser and on servers:
* - In the browser, the value you provide in `root` will be stripped from the beginning stack frames' paths (if the path started with the value).
* - On the server, the root value will only replace the beginning of stack frame filepaths, when the path is absolute. If no `root` value is provided and the path is absolute, the frame will be reduced to only the filename and the provided `prefix` option.
*
* Browser example:
* - Original frame: `'http://example.com/my/path/static/asset.js'`
* - `root: 'http://example.com/my/path'`
* - `assetPrefix: 'app://'`
* - Resulting frame: `'app:///static/asset.js'`
*
* Server example:
* - Original frame: `'/User/local/my/path/static/asset.js'`
* - `root: '/User/local/my/path'`
* - `assetPrefix: 'app://'`
* - Resulting frame: `'app:///static/asset.js'`
*/
root?: string;
/**
* A custom prefix that stack frames will be prepended with.
*
* Default: `'app://'`
*
* This option has slightly different behaviour in the browser and on servers:
* - In the browser, the value you provide in `prefix` will prefix the resulting filename when the value you provided in `root` was applied. Effectively replacing whatever `root` matched in the beginning of the frame with `prefix`.
* - On the server, the prefix is applied to all stackframes with absolute paths. On Windows, the drive identifier (e.g. "C://") is replaced with the prefix.
*/
prefix?: string;
/**
* Defines an iterator that is used to iterate through all of the stack frames for modification before being sent to Sentry.
* Setting this option will effectively disable both the `root` and the `prefix` options.
*/
iteratee?: StackFrameIteratee;

@@ -12,3 +44,11 @@ }

export declare const rewriteFramesIntegration: (options?: RewriteFramesOptions | undefined) => import("@sentry/types").Integration;
/**
* Exported only for tests.
*/
export declare function generateIteratee({ isBrowser, root, prefix, }: {
isBrowser: boolean;
root?: string;
prefix: string;
}): StackFrameIteratee;
export {};
//# sourceMappingURL=rewriteframes.d.ts.map

@@ -17,3 +17,3 @@ import type { Client, MeasurementUnit, MetricsAggregator as MetricsAggregatorBase, Primitive } from '@sentry/types';

*/
add(metricType: MetricType, unsanitizedName: string, value: number | string, unit?: MeasurementUnit, unsanitizedTags?: Record<string, Primitive>, maybeFloatTimestamp?: number): void;
add(metricType: MetricType, unsanitizedName: string, value: number | string, unsanitizedUnit?: MeasurementUnit, unsanitizedTags?: Record<string, Primitive>, maybeFloatTimestamp?: number): void;
/**

@@ -20,0 +20,0 @@ * Flushes the current metrics to the transport via the transport.

@@ -17,3 +17,3 @@ import type { Client, MeasurementUnit, MetricsAggregator, Primitive } from '@sentry/types';

*/
add(metricType: MetricType, unsanitizedName: string, value: number | string, unit?: MeasurementUnit | undefined, unsanitizedTags?: Record<string, Primitive> | undefined, maybeFloatTimestamp?: number | undefined): void;
add(metricType: MetricType, unsanitizedName: string, value: number | string, unsanitizedUnit?: MeasurementUnit | undefined, unsanitizedTags?: Record<string, Primitive> | undefined, maybeFloatTimestamp?: number | undefined): void;
/**

@@ -20,0 +20,0 @@ * @inheritDoc

@@ -6,20 +6,2 @@ export declare const COUNTER_METRIC_TYPE: "c";

/**
* Normalization regex for metric names and metric tag names.
*
* This enforces that names and tag keys only contain alphanumeric characters,
* underscores, forward slashes, periods, and dashes.
*
* See: https://develop.sentry.dev/sdk/metrics/#normalization
*/
export declare const NAME_AND_TAG_KEY_NORMALIZATION_REGEX: RegExp;
/**
* Normalization regex for metric tag values.
*
* This enforces that values only contain words, digits, or the following
* special characters: _:/@.{}[\]$-
*
* See: https://develop.sentry.dev/sdk/metrics/#normalization
*/
export declare const TAG_VALUE_NORMALIZATION_REGEX: RegExp;
/**
* This does not match spec in https://develop.sentry.dev/sdk/metrics

@@ -26,0 +8,0 @@ * but was chosen to optimize for the most common case in browser environments.

@@ -26,2 +26,16 @@ import type { MeasurementUnit, MetricBucketItem, Primitive } from '@sentry/types';

/**
* Sanitizes units
*
* These Regex's are straight from the normalisation docs:
* https://develop.sentry.dev/sdk/metrics/#normalization
*/
export declare function sanitizeUnit(unit: string): string;
/**
* Sanitizes metric keys
*
* These Regex's are straight from the normalisation docs:
* https://develop.sentry.dev/sdk/metrics/#normalization
*/
export declare function sanitizeMetricKey(key: string): string;
/**
* Sanitizes tags.

@@ -28,0 +42,0 @@ */

/** Only exposed for testing */
export declare function _resetErrorsInstrumented(): void;
/**
* Configures global error listeners
* Ensure that global errors automatically set the active span status.
*/
export declare function registerErrorInstrumentation(): void;
export declare function registerSpanErrorInstrumentation(): void;
//# sourceMappingURL=errors.d.ts.map
/**
* Adds tracing extensions.
* TODO (v8): Do we still need this?? Can we solve this differently?
* @deprecated Use `registerSpanErrorInstrumentation()` instead. In v9, this function will be removed. Note that you don't need to call this in Node-based SDKs or when using `browserTracingIntegration`.
*/
export declare function addTracingExtensions(): void;
//# sourceMappingURL=hubextensions.d.ts.map

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

export { registerSpanErrorInstrumentation } from './errors';
export { setCapturedScopesOnSpan, getCapturedScopesOnSpan } from './utils';
export { addTracingExtensions } from './hubextensions';

@@ -7,3 +9,3 @@ export { startIdleSpan, TRACING_DEFAULTS } from './idleSpan';

export { SPAN_STATUS_ERROR, SPAN_STATUS_OK, SPAN_STATUS_UNSET } from './spanstatus';
export { startSpan, startInactiveSpan, startSpanManual, continueTrace, withActiveSpan, } from './trace';
export { startSpan, startInactiveSpan, startSpanManual, continueTrace, withActiveSpan, suppressTracing, } from './trace';
export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';

@@ -10,0 +12,0 @@ export { setMeasurement, timedEventsToMeasurements } from './measurement';

@@ -57,2 +57,4 @@ import type { Scope, Span, StartSpanOptions } from '@sentry/types';

export declare function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T;
/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */
export declare function suppressTracing<T>(callback: () => T): T;
//# sourceMappingURL=trace.d.ts.map

@@ -5,4 +5,5 @@ import type { Envelope, InternalBaseTransportOptions, Transport } from '@sentry/types';

export interface OfflineStore {
insert(env: Envelope): Promise<void>;
pop(): Promise<Envelope | undefined>;
push(env: Envelope): Promise<void>;
unshift(env: Envelope): Promise<void>;
shift(): Promise<Envelope | undefined>;
}

@@ -9,0 +10,0 @@ export type CreateOfflineStore = (options: OfflineTransportOptions) => OfflineStore;

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

export declare const SDK_VERSION = "8.0.0-alpha.9";
export declare const SDK_VERSION = "8.0.0-beta.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

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