@sentry/core
Advanced tools
Comparing version 7.68.0 to 7.69.0
@@ -237,3 +237,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
if (this._isEnabled() && !this._integrationsInitialized) { | ||
this._integrations = integration.setupIntegrations(this._options.integrations); | ||
this._integrations = integration.setupIntegrations(this, this._options.integrations); | ||
this._integrationsInitialized = true; | ||
@@ -268,3 +268,3 @@ } | ||
addIntegration(integration$1) { | ||
integration.setupIntegration(integration$1, this._integrations); | ||
integration.setupIntegration(this, integration$1, this._integrations); | ||
} | ||
@@ -330,2 +330,3 @@ | ||
// Keep on() & emit() signatures in sync with types' client.ts interface | ||
/* eslint-disable @typescript-eslint/unified-signatures */ | ||
@@ -340,3 +341,3 @@ /** @inheritdoc */ | ||
// @ts-ignore We assue the types are correct | ||
// @ts-expect-error We assue the types are correct | ||
this._hooks[hook].push(callback); | ||
@@ -350,3 +351,2 @@ } | ||
if (this._hooks[hook]) { | ||
// @ts-ignore we cannot enforce the callback to match the hook | ||
this._hooks[hook].forEach(callback => callback(...rest)); | ||
@@ -356,2 +356,4 @@ } | ||
/* eslint-enable @typescript-eslint/unified-signatures */ | ||
/** Updates existing session based on the provided event */ | ||
@@ -445,2 +447,5 @@ _updateSessionFromEvent(session$1, event) { | ||
} | ||
this.emit('preprocessEvent', event, hint); | ||
return prepareEvent.prepareEvent(options, event, hint, scope).then(evt => { | ||
@@ -447,0 +452,0 @@ if (evt === null) { |
@@ -427,3 +427,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
*/ | ||
// @ts-ignore Function lacks ending return statement and return type does not include 'undefined'. ts(2366) | ||
// @ts-expect-error Function lacks ending return statement and return type does not include 'undefined'. ts(2366) | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -430,0 +430,0 @@ _callExtensionMethod(method, ...args) { |
@@ -52,3 +52,5 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.startActiveSpan = trace.startActiveSpan; | ||
exports.startInactiveSpan = trace.startInactiveSpan; | ||
exports.startSpan = trace.startSpan; | ||
exports.startSpanManual = trace.startSpanManual; | ||
exports.trace = trace.trace; | ||
@@ -55,0 +57,0 @@ exports.getDynamicSamplingContextFromClient = dynamicSamplingContext.getDynamicSamplingContextFromClient; |
@@ -78,3 +78,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
*/ | ||
function setupIntegrations(integrations) { | ||
function setupIntegrations(client, integrations) { | ||
const integrationIndex = {}; | ||
@@ -85,3 +85,3 @@ | ||
if (integration) { | ||
setupIntegration(integration, integrationIndex); | ||
setupIntegration(client, integration, integrationIndex); | ||
} | ||
@@ -94,3 +94,3 @@ }); | ||
/** Setup a single integration. */ | ||
function setupIntegration(integration, integrationIndex) { | ||
function setupIntegration(client, integration, integrationIndex) { | ||
integrationIndex[integration.name] = integration; | ||
@@ -101,4 +101,10 @@ | ||
installedIntegrations.push(integration.name); | ||
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log(`Integration installed: ${integration.name}`); | ||
} | ||
if (client.on && typeof integration.preprocessEvent === 'function') { | ||
const callback = integration.preprocessEvent.bind(integration); | ||
client.on('preprocessEvent', (event, hint) => callback(event, hint, client)); | ||
} | ||
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log(`Integration installed: ${integration.name}`); | ||
} | ||
@@ -105,0 +111,0 @@ |
@@ -161,16 +161,31 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
function _getPossibleEventMessages(event) { | ||
const possibleMessages = []; | ||
if (event.message) { | ||
return [event.message]; | ||
possibleMessages.push(event.message); | ||
} | ||
if (event.exception) { | ||
const { values } = event.exception; | ||
try { | ||
const { type = '', value = '' } = (values && values[values.length - 1]) || {}; | ||
return [`${value}`, `${type}: ${value}`]; | ||
} catch (oO) { | ||
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.error(`Cannot extract message for event ${utils.getEventDescription(event)}`); | ||
return []; | ||
let lastException; | ||
try { | ||
// @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]; | ||
} catch (e) { | ||
// try catching to save bundle size checking existence of variables | ||
} | ||
if (lastException) { | ||
if (lastException.value) { | ||
possibleMessages.push(lastException.value); | ||
if (lastException.type) { | ||
possibleMessages.push(`${lastException.type}: ${lastException.value}`); | ||
} | ||
} | ||
} | ||
return []; | ||
if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && possibleMessages.length === 0) { | ||
utils.logger.error(`Could not extract message for event ${utils.getEventDescription(event)}`); | ||
} | ||
return possibleMessages; | ||
} | ||
@@ -180,3 +195,3 @@ | ||
try { | ||
// @ts-ignore can't be a sentry error if undefined | ||
// @ts-expect-error can't be a sentry error if undefined | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
@@ -206,3 +221,3 @@ return event.exception.values[0].type === 'SentryError'; | ||
try { | ||
// @ts-ignore we only care about frames if the whole thing here is defined | ||
// @ts-expect-error we only care about frames if the whole thing here is defined | ||
frames = event.exception.values[0].stacktrace.frames; | ||
@@ -209,0 +224,0 @@ } catch (e) { |
@@ -373,3 +373,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
}; | ||
this._breadcrumbs = [...this._breadcrumbs, mergedBreadcrumb].slice(-maxCrumbs); | ||
const breadcrumbs = this._breadcrumbs; | ||
breadcrumbs.push(mergedBreadcrumb); | ||
this._breadcrumbs = breadcrumbs.length > maxCrumbs ? breadcrumbs.slice(-maxCrumbs) : breadcrumbs; | ||
this._notifyScopeListeners(); | ||
@@ -466,4 +470,5 @@ | ||
event.breadcrumbs = [...(event.breadcrumbs || []), ...this._breadcrumbs]; | ||
event.breadcrumbs = event.breadcrumbs.length > 0 ? event.breadcrumbs : undefined; | ||
const scopeBreadcrumbs = this._getBreadcrumbs(); | ||
const breadcrumbs = [...(event.breadcrumbs || []), ...scopeBreadcrumbs]; | ||
event.breadcrumbs = breadcrumbs.length > 0 ? breadcrumbs : undefined; | ||
@@ -504,2 +509,9 @@ event.sdkProcessingMetadata = { | ||
/** | ||
* Get the breadcrumbs for this scope. | ||
*/ | ||
_getBreadcrumbs() { | ||
return this._breadcrumbs; | ||
} | ||
/** | ||
* This will be called after {@link applyToEvent} is finished. | ||
@@ -506,0 +518,0 @@ */ |
@@ -25,21 +25,10 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
) { | ||
const ctx = { ...context }; | ||
// If a name is set and a description is not, set the description to the name. | ||
if (ctx.name !== undefined && ctx.description === undefined) { | ||
ctx.description = ctx.name; | ||
} | ||
const ctx = normalizeContext(context); | ||
const hub$1 = hub.getCurrentHub(); | ||
const scope = hub$1.getScope(); | ||
const parentSpan = scope.getSpan(); | ||
function startActiveSpan() { | ||
if (!hasTracingEnabled.hasTracingEnabled()) { | ||
return undefined; | ||
} | ||
return parentSpan ? parentSpan.startChild(ctx) : hub$1.startTransaction(ctx); | ||
} | ||
const activeSpan = createChildSpanOrTransaction(hub$1, parentSpan, ctx); | ||
const activeSpan = startActiveSpan(); | ||
scope.setSpan(activeSpan); | ||
@@ -85,3 +74,3 @@ | ||
* | ||
* If you want to create a span that is not set as active, use {@link startSpan}. | ||
* If you want to create a span that is not set as active, use {@link startInactiveSpan}. | ||
* | ||
@@ -92,22 +81,10 @@ * Note that if you have not enabled tracing extensions via `addTracingExtensions` | ||
*/ | ||
function startActiveSpan(context, callback) { | ||
const ctx = { ...context }; | ||
// If a name is set and a description is not, set the description to the name. | ||
if (ctx.name !== undefined && ctx.description === undefined) { | ||
ctx.description = ctx.name; | ||
} | ||
function startSpan(context, callback) { | ||
const ctx = normalizeContext(context); | ||
const hub$1 = hub.getCurrentHub(); | ||
const scope = hub$1.getScope(); | ||
const parentSpan = scope.getSpan(); | ||
function startActiveSpan() { | ||
if (!hasTracingEnabled.hasTracingEnabled()) { | ||
return undefined; | ||
} | ||
return parentSpan ? parentSpan.startChild(ctx) : hub$1.startTransaction(ctx); | ||
} | ||
const activeSpan = startActiveSpan(); | ||
const activeSpan = createChildSpanOrTransaction(hub$1, parentSpan, ctx); | ||
scope.setSpan(activeSpan); | ||
@@ -147,6 +124,57 @@ | ||
/** | ||
* @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 | ||
* after the function is done automatically. | ||
* | ||
* The created span is the active span and will be used as parent by other spans created inside the function | ||
* and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active. | ||
* | ||
* 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. | ||
*/ | ||
function startSpanManual( | ||
context, | ||
callback, | ||
) { | ||
const ctx = normalizeContext(context); | ||
const hub$1 = hub.getCurrentHub(); | ||
const scope = hub$1.getScope(); | ||
const parentSpan = scope.getSpan(); | ||
const activeSpan = createChildSpanOrTransaction(hub$1, parentSpan, ctx); | ||
scope.setSpan(activeSpan); | ||
function finishAndSetSpan() { | ||
activeSpan && activeSpan.finish(); | ||
hub$1.getScope().setSpan(parentSpan); | ||
} | ||
let maybePromiseResult; | ||
try { | ||
maybePromiseResult = callback(activeSpan, finishAndSetSpan); | ||
} catch (e) { | ||
activeSpan && activeSpan.setStatus('internal_error'); | ||
throw e; | ||
} | ||
if (utils.isThenable(maybePromiseResult)) { | ||
Promise.resolve(maybePromiseResult).then(undefined, () => { | ||
activeSpan && activeSpan.setStatus('internal_error'); | ||
}); | ||
} | ||
return maybePromiseResult; | ||
} | ||
/** | ||
* Creates a span. This span is not set as active, so will not get automatic instrumentation spans | ||
* as children or be able to be accessed via `Sentry.getSpan()`. | ||
* | ||
* If you want to create a span that is set as active, use {@link startActiveSpan}. | ||
* If you want to create a span that is set as active, use {@link startSpan}. | ||
* | ||
@@ -157,3 +185,3 @@ * Note that if you have not enabled tracing extensions via `addTracingExtensions` | ||
*/ | ||
function startSpan(context) { | ||
function startInactiveSpan(context) { | ||
if (!hasTracingEnabled.hasTracingEnabled()) { | ||
@@ -181,6 +209,29 @@ return undefined; | ||
function createChildSpanOrTransaction( | ||
hub, | ||
parentSpan, | ||
ctx, | ||
) { | ||
if (!hasTracingEnabled.hasTracingEnabled()) { | ||
return undefined; | ||
} | ||
return parentSpan ? parentSpan.startChild(ctx) : hub.startTransaction(ctx); | ||
} | ||
function normalizeContext(context) { | ||
const ctx = { ...context }; | ||
// If a name is set and a description is not, set the description to the name. | ||
if (ctx.name !== undefined && ctx.description === undefined) { | ||
ctx.description = ctx.name; | ||
} | ||
return ctx; | ||
} | ||
exports.getActiveSpan = getActiveSpan; | ||
exports.startActiveSpan = startActiveSpan; | ||
exports.startInactiveSpan = startInactiveSpan; | ||
exports.startSpan = startSpan; | ||
exports.startSpanManual = startSpanManual; | ||
exports.trace = trace; | ||
//# sourceMappingURL=trace.js.map |
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const SDK_VERSION = '7.68.0'; | ||
const SDK_VERSION = '7.69.0'; | ||
exports.SDK_VERSION = SDK_VERSION; | ||
//# sourceMappingURL=version.js.map |
@@ -235,3 +235,3 @@ import { makeDsn, logger, checkOrSetAlreadyCaught, isPrimitive, resolvedSyncPromise, addItemToEnvelope, createAttachmentEnvelopeItem, SyncPromise, rejectedSyncPromise, SentryError, isThenable, isPlainObject } from '@sentry/utils'; | ||
if (this._isEnabled() && !this._integrationsInitialized) { | ||
this._integrations = setupIntegrations(this._options.integrations); | ||
this._integrations = setupIntegrations(this, this._options.integrations); | ||
this._integrationsInitialized = true; | ||
@@ -266,3 +266,3 @@ } | ||
addIntegration(integration) { | ||
setupIntegration(integration, this._integrations); | ||
setupIntegration(this, integration, this._integrations); | ||
} | ||
@@ -328,2 +328,3 @@ | ||
// Keep on() & emit() signatures in sync with types' client.ts interface | ||
/* eslint-disable @typescript-eslint/unified-signatures */ | ||
@@ -338,3 +339,3 @@ /** @inheritdoc */ | ||
// @ts-ignore We assue the types are correct | ||
// @ts-expect-error We assue the types are correct | ||
this._hooks[hook].push(callback); | ||
@@ -348,3 +349,2 @@ } | ||
if (this._hooks[hook]) { | ||
// @ts-ignore we cannot enforce the callback to match the hook | ||
this._hooks[hook].forEach(callback => callback(...rest)); | ||
@@ -354,2 +354,4 @@ } | ||
/* eslint-enable @typescript-eslint/unified-signatures */ | ||
/** Updates existing session based on the provided event */ | ||
@@ -443,2 +445,5 @@ _updateSessionFromEvent(session, event) { | ||
} | ||
this.emit('preprocessEvent', event, hint); | ||
return prepareEvent(options, event, hint, scope).then(evt => { | ||
@@ -445,0 +450,0 @@ if (evt === null) { |
@@ -425,3 +425,3 @@ import { uuid4, dateTimestampInSeconds, consoleSandbox, logger, GLOBAL_OBJ, getGlobalSingleton } from '@sentry/utils'; | ||
*/ | ||
// @ts-ignore Function lacks ending return statement and return type does not include 'undefined'. ts(2366) | ||
// @ts-expect-error Function lacks ending return statement and return type does not include 'undefined'. ts(2366) | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -428,0 +428,0 @@ _callExtensionMethod(method, ...args) { |
@@ -7,3 +7,3 @@ export { addTracingExtensions, startIdleTransaction } from './tracing/hubextensions.js'; | ||
export { SpanStatus } from './tracing/spanstatus.js'; | ||
export { getActiveSpan, startActiveSpan, startSpan, trace } from './tracing/trace.js'; | ||
export { getActiveSpan, startActiveSpan, startInactiveSpan, startSpan, startSpanManual, trace } from './tracing/trace.js'; | ||
export { getDynamicSamplingContextFromClient } from './tracing/dynamicSamplingContext.js'; | ||
@@ -10,0 +10,0 @@ export { setMeasurement } from './tracing/measurement.js'; |
@@ -76,3 +76,3 @@ import { arrayify, logger } from '@sentry/utils'; | ||
*/ | ||
function setupIntegrations(integrations) { | ||
function setupIntegrations(client, integrations) { | ||
const integrationIndex = {}; | ||
@@ -83,3 +83,3 @@ | ||
if (integration) { | ||
setupIntegration(integration, integrationIndex); | ||
setupIntegration(client, integration, integrationIndex); | ||
} | ||
@@ -92,3 +92,3 @@ }); | ||
/** Setup a single integration. */ | ||
function setupIntegration(integration, integrationIndex) { | ||
function setupIntegration(client, integration, integrationIndex) { | ||
integrationIndex[integration.name] = integration; | ||
@@ -99,4 +99,10 @@ | ||
installedIntegrations.push(integration.name); | ||
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log(`Integration installed: ${integration.name}`); | ||
} | ||
if (client.on && typeof integration.preprocessEvent === 'function') { | ||
const callback = integration.preprocessEvent.bind(integration); | ||
client.on('preprocessEvent', (event, hint) => callback(event, hint, client)); | ||
} | ||
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log(`Integration installed: ${integration.name}`); | ||
} | ||
@@ -103,0 +109,0 @@ |
@@ -159,16 +159,31 @@ import { logger, getEventDescription, stringMatchesSomePattern } from '@sentry/utils'; | ||
function _getPossibleEventMessages(event) { | ||
const possibleMessages = []; | ||
if (event.message) { | ||
return [event.message]; | ||
possibleMessages.push(event.message); | ||
} | ||
if (event.exception) { | ||
const { values } = event.exception; | ||
try { | ||
const { type = '', value = '' } = (values && values[values.length - 1]) || {}; | ||
return [`${value}`, `${type}: ${value}`]; | ||
} catch (oO) { | ||
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error(`Cannot extract message for event ${getEventDescription(event)}`); | ||
return []; | ||
let lastException; | ||
try { | ||
// @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]; | ||
} catch (e) { | ||
// try catching to save bundle size checking existence of variables | ||
} | ||
if (lastException) { | ||
if (lastException.value) { | ||
possibleMessages.push(lastException.value); | ||
if (lastException.type) { | ||
possibleMessages.push(`${lastException.type}: ${lastException.value}`); | ||
} | ||
} | ||
} | ||
return []; | ||
if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && possibleMessages.length === 0) { | ||
logger.error(`Could not extract message for event ${getEventDescription(event)}`); | ||
} | ||
return possibleMessages; | ||
} | ||
@@ -178,3 +193,3 @@ | ||
try { | ||
// @ts-ignore can't be a sentry error if undefined | ||
// @ts-expect-error can't be a sentry error if undefined | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
@@ -204,3 +219,3 @@ return event.exception.values[0].type === 'SentryError'; | ||
try { | ||
// @ts-ignore we only care about frames if the whole thing here is defined | ||
// @ts-expect-error we only care about frames if the whole thing here is defined | ||
frames = event.exception.values[0].stacktrace.frames; | ||
@@ -207,0 +222,0 @@ } catch (e) { |
@@ -371,3 +371,7 @@ import { isPlainObject, dateTimestampInSeconds, SyncPromise, logger, isThenable, arrayify, getGlobalSingleton, uuid4 } from '@sentry/utils'; | ||
}; | ||
this._breadcrumbs = [...this._breadcrumbs, mergedBreadcrumb].slice(-maxCrumbs); | ||
const breadcrumbs = this._breadcrumbs; | ||
breadcrumbs.push(mergedBreadcrumb); | ||
this._breadcrumbs = breadcrumbs.length > maxCrumbs ? breadcrumbs.slice(-maxCrumbs) : breadcrumbs; | ||
this._notifyScopeListeners(); | ||
@@ -464,4 +468,5 @@ | ||
event.breadcrumbs = [...(event.breadcrumbs || []), ...this._breadcrumbs]; | ||
event.breadcrumbs = event.breadcrumbs.length > 0 ? event.breadcrumbs : undefined; | ||
const scopeBreadcrumbs = this._getBreadcrumbs(); | ||
const breadcrumbs = [...(event.breadcrumbs || []), ...scopeBreadcrumbs]; | ||
event.breadcrumbs = breadcrumbs.length > 0 ? breadcrumbs : undefined; | ||
@@ -502,2 +507,9 @@ event.sdkProcessingMetadata = { | ||
/** | ||
* Get the breadcrumbs for this scope. | ||
*/ | ||
_getBreadcrumbs() { | ||
return this._breadcrumbs; | ||
} | ||
/** | ||
* This will be called after {@link applyToEvent} is finished. | ||
@@ -504,0 +516,0 @@ */ |
@@ -23,21 +23,10 @@ import { isThenable } from '@sentry/utils'; | ||
) { | ||
const ctx = { ...context }; | ||
// If a name is set and a description is not, set the description to the name. | ||
if (ctx.name !== undefined && ctx.description === undefined) { | ||
ctx.description = ctx.name; | ||
} | ||
const ctx = normalizeContext(context); | ||
const hub = getCurrentHub(); | ||
const scope = hub.getScope(); | ||
const parentSpan = scope.getSpan(); | ||
function startActiveSpan() { | ||
if (!hasTracingEnabled()) { | ||
return undefined; | ||
} | ||
return parentSpan ? parentSpan.startChild(ctx) : hub.startTransaction(ctx); | ||
} | ||
const activeSpan = createChildSpanOrTransaction(hub, parentSpan, ctx); | ||
const activeSpan = startActiveSpan(); | ||
scope.setSpan(activeSpan); | ||
@@ -83,3 +72,3 @@ | ||
* | ||
* If you want to create a span that is not set as active, use {@link startSpan}. | ||
* If you want to create a span that is not set as active, use {@link startInactiveSpan}. | ||
* | ||
@@ -90,22 +79,10 @@ * Note that if you have not enabled tracing extensions via `addTracingExtensions` | ||
*/ | ||
function startActiveSpan(context, callback) { | ||
const ctx = { ...context }; | ||
// If a name is set and a description is not, set the description to the name. | ||
if (ctx.name !== undefined && ctx.description === undefined) { | ||
ctx.description = ctx.name; | ||
} | ||
function startSpan(context, callback) { | ||
const ctx = normalizeContext(context); | ||
const hub = getCurrentHub(); | ||
const scope = hub.getScope(); | ||
const parentSpan = scope.getSpan(); | ||
function startActiveSpan() { | ||
if (!hasTracingEnabled()) { | ||
return undefined; | ||
} | ||
return parentSpan ? parentSpan.startChild(ctx) : hub.startTransaction(ctx); | ||
} | ||
const activeSpan = startActiveSpan(); | ||
const activeSpan = createChildSpanOrTransaction(hub, parentSpan, ctx); | ||
scope.setSpan(activeSpan); | ||
@@ -145,6 +122,57 @@ | ||
/** | ||
* @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 | ||
* after the function is done automatically. | ||
* | ||
* The created span is the active span and will be used as parent by other spans created inside the function | ||
* and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active. | ||
* | ||
* 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. | ||
*/ | ||
function startSpanManual( | ||
context, | ||
callback, | ||
) { | ||
const ctx = normalizeContext(context); | ||
const hub = getCurrentHub(); | ||
const scope = hub.getScope(); | ||
const parentSpan = scope.getSpan(); | ||
const activeSpan = createChildSpanOrTransaction(hub, parentSpan, ctx); | ||
scope.setSpan(activeSpan); | ||
function finishAndSetSpan() { | ||
activeSpan && activeSpan.finish(); | ||
hub.getScope().setSpan(parentSpan); | ||
} | ||
let maybePromiseResult; | ||
try { | ||
maybePromiseResult = callback(activeSpan, finishAndSetSpan); | ||
} catch (e) { | ||
activeSpan && activeSpan.setStatus('internal_error'); | ||
throw e; | ||
} | ||
if (isThenable(maybePromiseResult)) { | ||
Promise.resolve(maybePromiseResult).then(undefined, () => { | ||
activeSpan && activeSpan.setStatus('internal_error'); | ||
}); | ||
} | ||
return maybePromiseResult; | ||
} | ||
/** | ||
* Creates a span. This span is not set as active, so will not get automatic instrumentation spans | ||
* as children or be able to be accessed via `Sentry.getSpan()`. | ||
* | ||
* If you want to create a span that is set as active, use {@link startActiveSpan}. | ||
* If you want to create a span that is set as active, use {@link startSpan}. | ||
* | ||
@@ -155,3 +183,3 @@ * Note that if you have not enabled tracing extensions via `addTracingExtensions` | ||
*/ | ||
function startSpan(context) { | ||
function startInactiveSpan(context) { | ||
if (!hasTracingEnabled()) { | ||
@@ -179,3 +207,24 @@ return undefined; | ||
export { getActiveSpan, startActiveSpan, startSpan, trace }; | ||
function createChildSpanOrTransaction( | ||
hub, | ||
parentSpan, | ||
ctx, | ||
) { | ||
if (!hasTracingEnabled()) { | ||
return undefined; | ||
} | ||
return parentSpan ? parentSpan.startChild(ctx) : hub.startTransaction(ctx); | ||
} | ||
function normalizeContext(context) { | ||
const ctx = { ...context }; | ||
// If a name is set and a description is not, set the description to the name. | ||
if (ctx.name !== undefined && ctx.description === undefined) { | ||
ctx.description = ctx.name; | ||
} | ||
return ctx; | ||
} | ||
export { getActiveSpan, startActiveSpan, startInactiveSpan, startSpan, startSpanManual, trace }; | ||
//# sourceMappingURL=trace.js.map |
@@ -1,4 +0,4 @@ | ||
const SDK_VERSION = '7.68.0'; | ||
const SDK_VERSION = '7.69.0'; | ||
export { SDK_VERSION }; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@sentry/core", | ||
"version": "7.68.0", | ||
"version": "7.69.0", | ||
"description": "Base implementation for all Sentry JavaScript SDKs", | ||
@@ -26,4 +26,4 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@sentry/types": "7.68.0", | ||
"@sentry/utils": "7.68.0", | ||
"@sentry/types": "7.69.0", | ||
"@sentry/utils": "7.69.0", | ||
"tslib": "^2.4.1 || ^1.9.3" | ||
@@ -30,0 +30,0 @@ }, |
@@ -129,4 +129,6 @@ import { Breadcrumb, BreadcrumbHint, Client, ClientOptions, DataCategory, DsnComponents, DynamicSamplingContext, Envelope, Event, EventDropReason, EventHint, Integration, IntegrationClass, Outcome, SdkMetadata, Session, SessionAggregates, Severity, SeverityLevel, Transaction, Transport, TransportMakeRequestResponse } from '@sentry/types'; | ||
/** @inheritdoc */ | ||
on(hook: 'startTransaction' | 'finishTransaction', callback: (transaction: Transaction) => void): void; | ||
on(hook: 'startTransaction', callback: (transaction: Transaction) => void): void; | ||
/** @inheritdoc */ | ||
on(hook: 'finishTransaction', callback: (transaction: Transaction) => void): void; | ||
/** @inheritdoc */ | ||
on(hook: 'beforeEnvelope', callback: (envelope: Envelope) => void): void; | ||
@@ -136,2 +138,4 @@ /** @inheritdoc */ | ||
/** @inheritdoc */ | ||
on(hook: 'preprocessEvent', callback: (event: Event, hint?: EventHint) => void): void; | ||
/** @inheritdoc */ | ||
on(hook: 'afterSendEvent', callback: (event: Event, sendResponse: TransportMakeRequestResponse | void) => void): void; | ||
@@ -147,4 +151,6 @@ /** @inheritdoc */ | ||
/** @inheritdoc */ | ||
emit(hook: 'startTransaction' | 'finishTransaction', transaction: Transaction): void; | ||
emit(hook: 'startTransaction', transaction: Transaction): void; | ||
/** @inheritdoc */ | ||
emit(hook: 'finishTransaction', transaction: Transaction): void; | ||
/** @inheritdoc */ | ||
emit(hook: 'beforeEnvelope', envelope: Envelope): void; | ||
@@ -154,2 +160,4 @@ /** @inheritdoc */ | ||
/** @inheritdoc */ | ||
emit(hook: 'preprocessEvent', event: Event, hint?: EventHint): void; | ||
/** @inheritdoc */ | ||
emit(hook: 'afterSendEvent', event: Event, sendResponse: TransportMakeRequestResponse | void): void; | ||
@@ -156,0 +164,0 @@ /** @inheritdoc */ |
@@ -1,2 +0,2 @@ | ||
import { Integration, Options } from '@sentry/types'; | ||
import { Client, Integration, Options } from '@sentry/types'; | ||
declare module '@sentry/types' { | ||
@@ -20,5 +20,5 @@ interface Integration { | ||
*/ | ||
export declare function setupIntegrations(integrations: Integration[]): IntegrationIndex; | ||
export declare function setupIntegrations(client: Client, integrations: Integration[]): IntegrationIndex; | ||
/** Setup a single integration. */ | ||
export declare function setupIntegration(integration: Integration, integrationIndex: IntegrationIndex): void; | ||
export declare function setupIntegration(client: Client, integration: Integration, integrationIndex: IntegrationIndex): void; | ||
//# sourceMappingURL=integration.d.ts.map |
@@ -188,2 +188,6 @@ import { Attachment, Breadcrumb, CaptureContext, Context, Contexts, Event, EventHint, EventProcessor, Extra, Extras, Primitive, PropagationContext, RequestSession, Scope as ScopeInterface, Session, Severity, SeverityLevel, Span, Transaction, User } from '@sentry/types'; | ||
/** | ||
* Get the breadcrumbs for this scope. | ||
*/ | ||
protected _getBreadcrumbs(): Breadcrumb[]; | ||
/** | ||
* This will be called after {@link applyToEvent} is finished. | ||
@@ -190,0 +194,0 @@ */ |
export { startIdleTransaction, addTracingExtensions } from './hubextensions'; | ||
export { IdleTransaction, TRACING_DEFAULTS } from './idletransaction'; | ||
export { BeforeFinishCallback } from './idletransaction'; | ||
export { Span, spanStatusfromHttpCode } from './span'; | ||
@@ -8,5 +9,5 @@ export { Transaction } from './transaction'; | ||
export { SpanStatusType } from './span'; | ||
export { trace, getActiveSpan, startActiveSpan, startSpan } from './trace'; | ||
export { trace, getActiveSpan, startSpan, startInactiveSpan, startActiveSpan, startSpanManual } from './trace'; | ||
export { getDynamicSamplingContextFromClient } from './dynamicSamplingContext'; | ||
export { setMeasurement } from './measurement'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -21,3 +21,3 @@ import { TransactionContext } from '@sentry/types'; | ||
* | ||
* If you want to create a span that is not set as active, use {@link startSpan}. | ||
* If you want to create a span that is not set as active, use {@link startInactiveSpan}. | ||
* | ||
@@ -28,8 +28,24 @@ * Note that if you have not enabled tracing extensions via `addTracingExtensions` | ||
*/ | ||
export declare function startActiveSpan<T>(context: TransactionContext, callback: (span: Span | undefined) => T): T; | ||
export declare function startSpan<T>(context: TransactionContext, callback: (span: Span | undefined) => T): T; | ||
/** | ||
* @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 | ||
* after the function is done automatically. | ||
* | ||
* The created span is the active span and will be used as parent by other spans created inside the function | ||
* and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active. | ||
* | ||
* 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. | ||
*/ | ||
export declare function startSpanManual<T>(context: TransactionContext, callback: (span: Span | undefined, finish: () => void) => T): T; | ||
/** | ||
* Creates a span. This span is not set as active, so will not get automatic instrumentation spans | ||
* as children or be able to be accessed via `Sentry.getSpan()`. | ||
* | ||
* If you want to create a span that is set as active, use {@link startActiveSpan}. | ||
* If you want to create a span that is set as active, use {@link startSpan}. | ||
* | ||
@@ -40,3 +56,3 @@ * Note that if you have not enabled tracing extensions via `addTracingExtensions` | ||
*/ | ||
export declare function startSpan(context: TransactionContext): Span | undefined; | ||
export declare function startInactiveSpan(context: TransactionContext): Span | undefined; | ||
/** | ||
@@ -43,0 +59,0 @@ * Returns the currently active span. |
@@ -1,2 +0,2 @@ | ||
export declare const SDK_VERSION = "7.68.0"; | ||
export declare const SDK_VERSION = "7.69.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -129,4 +129,6 @@ import type { Breadcrumb, BreadcrumbHint, Client, ClientOptions, DataCategory, DsnComponents, DynamicSamplingContext, Envelope, Event, EventDropReason, EventHint, Integration, IntegrationClass, Outcome, SdkMetadata, Session, SessionAggregates, Severity, SeverityLevel, Transaction, Transport, TransportMakeRequestResponse } from '@sentry/types'; | ||
/** @inheritdoc */ | ||
on(hook: 'startTransaction' | 'finishTransaction', callback: (transaction: Transaction) => void): void; | ||
on(hook: 'startTransaction', callback: (transaction: Transaction) => void): void; | ||
/** @inheritdoc */ | ||
on(hook: 'finishTransaction', callback: (transaction: Transaction) => void): void; | ||
/** @inheritdoc */ | ||
on(hook: 'beforeEnvelope', callback: (envelope: Envelope) => void): void; | ||
@@ -136,2 +138,4 @@ /** @inheritdoc */ | ||
/** @inheritdoc */ | ||
on(hook: 'preprocessEvent', callback: (event: Event, hint?: EventHint) => void): void; | ||
/** @inheritdoc */ | ||
on(hook: 'afterSendEvent', callback: (event: Event, sendResponse: TransportMakeRequestResponse | void) => void): void; | ||
@@ -147,4 +151,6 @@ /** @inheritdoc */ | ||
/** @inheritdoc */ | ||
emit(hook: 'startTransaction' | 'finishTransaction', transaction: Transaction): void; | ||
emit(hook: 'startTransaction', transaction: Transaction): void; | ||
/** @inheritdoc */ | ||
emit(hook: 'finishTransaction', transaction: Transaction): void; | ||
/** @inheritdoc */ | ||
emit(hook: 'beforeEnvelope', envelope: Envelope): void; | ||
@@ -154,2 +160,4 @@ /** @inheritdoc */ | ||
/** @inheritdoc */ | ||
emit(hook: 'preprocessEvent', event: Event, hint?: EventHint): void; | ||
/** @inheritdoc */ | ||
emit(hook: 'afterSendEvent', event: Event, sendResponse: TransportMakeRequestResponse | void): void; | ||
@@ -156,0 +164,0 @@ /** @inheritdoc */ |
@@ -1,2 +0,2 @@ | ||
import type { Integration, Options } from '@sentry/types'; | ||
import type { Client, Integration, Options } from '@sentry/types'; | ||
declare module '@sentry/types' { | ||
@@ -20,5 +20,5 @@ interface Integration { | ||
*/ | ||
export declare function setupIntegrations(integrations: Integration[]): IntegrationIndex; | ||
export declare function setupIntegrations(client: Client, integrations: Integration[]): IntegrationIndex; | ||
/** Setup a single integration. */ | ||
export declare function setupIntegration(integration: Integration, integrationIndex: IntegrationIndex): void; | ||
export declare function setupIntegration(client: Client, integration: Integration, integrationIndex: IntegrationIndex): void; | ||
//# sourceMappingURL=integration.d.ts.map |
@@ -188,2 +188,6 @@ import type { Attachment, Breadcrumb, CaptureContext, Context, Contexts, Event, EventHint, EventProcessor, Extra, Extras, Primitive, PropagationContext, RequestSession, Scope as ScopeInterface, Session, Severity, SeverityLevel, Span, Transaction, User } from '@sentry/types'; | ||
/** | ||
* Get the breadcrumbs for this scope. | ||
*/ | ||
protected _getBreadcrumbs(): Breadcrumb[]; | ||
/** | ||
* This will be called after {@link applyToEvent} is finished. | ||
@@ -190,0 +194,0 @@ */ |
export { startIdleTransaction, addTracingExtensions } from './hubextensions'; | ||
export { IdleTransaction, TRACING_DEFAULTS } from './idletransaction'; | ||
export type { BeforeFinishCallback } from './idletransaction'; | ||
export { Span, spanStatusfromHttpCode } from './span'; | ||
@@ -8,5 +9,5 @@ export { Transaction } from './transaction'; | ||
export type { SpanStatusType } from './span'; | ||
export { trace, getActiveSpan, startActiveSpan, startSpan } from './trace'; | ||
export { trace, getActiveSpan, startSpan, startInactiveSpan, startActiveSpan, startSpanManual } from './trace'; | ||
export { getDynamicSamplingContextFromClient } from './dynamicSamplingContext'; | ||
export { setMeasurement } from './measurement'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -21,3 +21,3 @@ import type { TransactionContext } from '@sentry/types'; | ||
* | ||
* If you want to create a span that is not set as active, use {@link startSpan}. | ||
* If you want to create a span that is not set as active, use {@link startInactiveSpan}. | ||
* | ||
@@ -28,8 +28,24 @@ * Note that if you have not enabled tracing extensions via `addTracingExtensions` | ||
*/ | ||
export declare function startActiveSpan<T>(context: TransactionContext, callback: (span: Span | undefined) => T): T; | ||
export declare function startSpan<T>(context: TransactionContext, callback: (span: Span | undefined) => T): T; | ||
/** | ||
* @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 | ||
* after the function is done automatically. | ||
* | ||
* The created span is the active span and will be used as parent by other spans created inside the function | ||
* and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active. | ||
* | ||
* 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. | ||
*/ | ||
export declare function startSpanManual<T>(context: TransactionContext, callback: (span: Span | undefined, finish: () => void) => T): T; | ||
/** | ||
* Creates a span. This span is not set as active, so will not get automatic instrumentation spans | ||
* as children or be able to be accessed via `Sentry.getSpan()`. | ||
* | ||
* If you want to create a span that is set as active, use {@link startActiveSpan}. | ||
* If you want to create a span that is set as active, use {@link startSpan}. | ||
* | ||
@@ -40,3 +56,3 @@ * Note that if you have not enabled tracing extensions via `addTracingExtensions` | ||
*/ | ||
export declare function startSpan(context: TransactionContext): Span | undefined; | ||
export declare function startInactiveSpan(context: TransactionContext): Span | undefined; | ||
/** | ||
@@ -43,0 +59,0 @@ * Returns the currently active span. |
@@ -1,2 +0,2 @@ | ||
export declare const SDK_VERSION = "7.68.0"; | ||
export declare const SDK_VERSION = "7.69.0"; | ||
//# 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
1179742
13650
+ Added@sentry/types@7.69.0(transitive)
+ Added@sentry/utils@7.69.0(transitive)
- Removed@sentry/types@7.68.0(transitive)
- Removed@sentry/utils@7.68.0(transitive)
Updated@sentry/types@7.69.0
Updated@sentry/utils@7.69.0