@sentry/core
Advanced tools
Comparing version
@@ -14,3 +14,2 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
const envelope$1 = require('./utils-hoist/envelope.js'); | ||
const error = require('./utils-hoist/error.js'); | ||
const is = require('./utils-hoist/is.js'); | ||
@@ -31,2 +30,27 @@ const logger = require('./utils-hoist/logger.js'); | ||
const INTERNAL_ERROR_SYMBOL = Symbol.for('SentryInternalError'); | ||
const DO_NOT_SEND_EVENT_SYMBOL = Symbol.for('SentryDoNotSendEventError'); | ||
function _makeInternalError(message) { | ||
return { | ||
message, | ||
[INTERNAL_ERROR_SYMBOL]: true, | ||
}; | ||
} | ||
function _makeDoNotSendEventError(message) { | ||
return { | ||
message, | ||
[DO_NOT_SEND_EVENT_SYMBOL]: true, | ||
}; | ||
} | ||
function _isInternalError(error) { | ||
return !!error && typeof error === 'object' && INTERNAL_ERROR_SYMBOL in error; | ||
} | ||
function _isDoNotSendEventError(error) { | ||
return !!error && typeof error === 'object' && DO_NOT_SEND_EVENT_SYMBOL in error; | ||
} | ||
/** | ||
@@ -620,6 +644,6 @@ * Base implementation for all JavaScript SDK clients. | ||
if (debugBuild.DEBUG_BUILD) { | ||
// If something's gone wrong, log the error as a warning. If it's just us having used a `SentryError` for | ||
// control flow, log just the message (no stack) as a log-level log. | ||
if (reason instanceof error.SentryError && reason.logLevel === 'log') { | ||
if (_isDoNotSendEventError(reason)) { | ||
logger.logger.log(reason.message); | ||
} else if (_isInternalError(reason)) { | ||
logger.logger.warn(reason.message); | ||
} else { | ||
@@ -668,5 +692,4 @@ logger.logger.warn(reason); | ||
return syncpromise.rejectedSyncPromise( | ||
new error.SentryError( | ||
_makeDoNotSendEventError( | ||
`Discarding event because it's not included in the random sample (sampling rate = ${sampleRate})`, | ||
'log', | ||
), | ||
@@ -682,3 +705,3 @@ ); | ||
this.recordDroppedEvent('event_processor', dataCategory); | ||
throw new error.SentryError('An event processor returned `null`, will not send event.', 'log'); | ||
throw _makeDoNotSendEventError('An event processor returned `null`, will not send event.'); | ||
} | ||
@@ -703,3 +726,3 @@ | ||
} | ||
throw new error.SentryError(`${beforeSendLabel} returned \`null\`, will not send event.`, 'log'); | ||
throw _makeDoNotSendEventError(`${beforeSendLabel} returned \`null\`, will not send event.`); | ||
} | ||
@@ -738,3 +761,3 @@ | ||
.then(null, reason => { | ||
if (reason instanceof error.SentryError) { | ||
if (_isDoNotSendEventError(reason) || _isInternalError(reason)) { | ||
throw reason; | ||
@@ -749,3 +772,3 @@ } | ||
}); | ||
throw new error.SentryError( | ||
throw _makeInternalError( | ||
`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${reason}`, | ||
@@ -846,3 +869,3 @@ ); | ||
if (!is.isPlainObject(event) && event !== null) { | ||
throw new error.SentryError(invalidValueError); | ||
throw _makeInternalError(invalidValueError); | ||
} | ||
@@ -852,7 +875,7 @@ return event; | ||
e => { | ||
throw new error.SentryError(`${beforeSendLabel} rejected with ${e}`); | ||
throw _makeInternalError(`${beforeSendLabel} rejected with ${e}`); | ||
}, | ||
); | ||
} else if (!is.isPlainObject(beforeSendResult) && beforeSendResult !== null) { | ||
throw new error.SentryError(invalidValueError); | ||
throw _makeInternalError(invalidValueError); | ||
} | ||
@@ -859,0 +882,0 @@ return beforeSendResult; |
@@ -214,2 +214,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
exports.handleCallbackErrors = handleCallbackErrors.handleCallbackErrors; | ||
exports.fmt = parameterize.fmt; | ||
exports.parameterize = parameterize.parameterize; | ||
@@ -325,2 +326,3 @@ exports.addAutoIpAddressToSession = ipAddress.addAutoIpAddressToSession; | ||
exports.resolve = path.resolve; | ||
exports.SENTRY_BUFFER_FULL_ERROR = promisebuffer.SENTRY_BUFFER_FULL_ERROR; | ||
exports.makePromiseBuffer = promisebuffer.makePromiseBuffer; | ||
@@ -327,0 +329,0 @@ exports.severityLevelFromString = severity.severityLevelFromString; |
@@ -97,3 +97,2 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
ignoreTransactions: [...(internalOptions.ignoreTransactions || []), ...(clientOptions.ignoreTransactions || [])], | ||
ignoreInternal: internalOptions.ignoreInternal !== undefined ? internalOptions.ignoreInternal : true, | ||
}; | ||
@@ -105,8 +104,2 @@ } | ||
// Filter errors | ||
if (options.ignoreInternal && _isSentryError(event)) { | ||
debugBuild.DEBUG_BUILD && | ||
logger.logger.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${misc.getEventDescription(event)}`); | ||
return true; | ||
} | ||
if (_isIgnoredError(event, options.ignoreErrors)) { | ||
@@ -193,12 +186,2 @@ debugBuild.DEBUG_BUILD && | ||
function _isSentryError(event) { | ||
try { | ||
// @ts-expect-error can't be a sentry error if undefined | ||
return event.exception.values[0].type === 'SentryError'; | ||
} catch (e) { | ||
// ignore | ||
} | ||
return false; | ||
} | ||
function _getLastValidUrl(frames = []) { | ||
@@ -205,0 +188,0 @@ for (let i = frames.length - 1; i >= 0; i--) { |
@@ -7,2 +7,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
const constants = require('./constants.js'); | ||
const is = require('../utils-hoist/is.js'); | ||
require('../utils-hoist/debug-build.js'); | ||
@@ -68,3 +69,3 @@ const logger = require('../utils-hoist/logger.js'); | ||
*/ | ||
function _INTERNAL_captureLog(log, client$1 = currentScopes.getClient(), scope = currentScopes.getCurrentScope()) { | ||
function _INTERNAL_captureLog(beforeLog, client$1 = currentScopes.getClient(), scope = currentScopes.getCurrentScope()) { | ||
if (!client$1) { | ||
@@ -76,3 +77,4 @@ debugBuild.DEBUG_BUILD && logger.logger.warn('No client available to capture log.'); | ||
const { _experiments, release, environment } = client$1.getOptions(); | ||
if (!_experiments?.enableLogs) { | ||
const { enableLogs = false, beforeSendLog } = _experiments ?? {}; | ||
if (!enableLogs) { | ||
debugBuild.DEBUG_BUILD && logger.logger.warn('logging option not enabled, log will not be captured.'); | ||
@@ -82,2 +84,11 @@ return; | ||
client$1.emit('beforeCaptureLog', beforeLog); | ||
const log = beforeSendLog ? beforeSendLog(beforeLog) : beforeLog; | ||
if (!log) { | ||
client$1.recordDroppedEvent('before_send', 'log_item', 1); | ||
debugBuild.DEBUG_BUILD && logger.logger.warn('beforeSendLog returned null, log will not be captured.'); | ||
return; | ||
} | ||
const [, traceContext] = client._getTraceInfoFromScope(client$1, scope); | ||
@@ -99,2 +110,10 @@ | ||
if (is.isParameterizedString(message)) { | ||
const { __sentry_template_string__, __sentry_template_values__ = [] } = message; | ||
logAttributes['sentry.message.template'] = __sentry_template_string__; | ||
__sentry_template_values__.forEach((param, index) => { | ||
logAttributes[`sentry.message.param.${index}`] = param; | ||
}); | ||
} | ||
const span = spanOnScope._getSpanForScope(scope); | ||
@@ -120,10 +139,10 @@ if (span) { | ||
CLIENT_TO_LOG_BUFFER_MAP.set(client$1, [serializedLog]); | ||
// Every time we initialize a new log buffer, we start a new interval to flush the buffer | ||
return; | ||
} else { | ||
logBuffer.push(serializedLog); | ||
if (logBuffer.length > MAX_LOG_BUFFER_SIZE) { | ||
_INTERNAL_flushLogsBuffer(client$1, logBuffer); | ||
} | ||
} | ||
logBuffer.push(serializedLog); | ||
if (logBuffer.length > MAX_LOG_BUFFER_SIZE) { | ||
_INTERNAL_flushLogsBuffer(client$1, logBuffer); | ||
} | ||
client$1.emit('afterCaptureLog', log); | ||
} | ||
@@ -130,0 +149,0 @@ |
@@ -8,2 +8,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
const propagationContext = require('./utils-hoist/propagationContext.js'); | ||
const string = require('./utils-hoist/string.js'); | ||
const time = require('./utils-hoist/time.js'); | ||
@@ -399,2 +400,4 @@ const merge = require('./utils/merge.js'); | ||
...breadcrumb, | ||
// Breadcrumb messages can theoretically be infinitely large and they're held in memory so we truncate them not to leak (too much) memory | ||
message: breadcrumb.message ? string.truncate(breadcrumb.message, 2048) : breadcrumb.message, | ||
}; | ||
@@ -401,0 +404,0 @@ |
@@ -8,2 +8,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
const errors = require('./tracing/errors.js'); | ||
const is = require('./utils-hoist/is.js'); | ||
require('./utils-hoist/debug-build.js'); | ||
@@ -15,2 +16,3 @@ const logger = require('./utils-hoist/logger.js'); | ||
const eventbuilder = require('./utils-hoist/eventbuilder.js'); | ||
const index = require('./logs/index.js'); | ||
@@ -23,2 +25,3 @@ /** | ||
extends client.Client { | ||
/** | ||
@@ -33,2 +36,22 @@ * Creates a new Edge SDK instance. | ||
super(options); | ||
this._logWeight = 0; | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
const client = this; | ||
this.on('flush', () => { | ||
index._INTERNAL_flushLogsBuffer(client); | ||
}); | ||
this.on('afterCaptureLog', log => { | ||
client._logWeight += estimateLogSizeInBytes(log); | ||
// We flush the logs buffer if it exceeds 0.8 MB | ||
// The log weight is a rough estimate, so we flush way before | ||
// the payload gets too big. | ||
if (client._logWeight > 800000) { | ||
index._INTERNAL_flushLogsBuffer(client); | ||
client._logWeight = 0; | ||
} | ||
}); | ||
} | ||
@@ -189,3 +212,45 @@ | ||
/** | ||
* Estimate the size of a log in bytes. | ||
* | ||
* @param log - The log to estimate the size of. | ||
* @returns The estimated size of the log in bytes. | ||
*/ | ||
function estimateLogSizeInBytes(log) { | ||
let weight = 0; | ||
// Estimate byte size of 2 bytes per character. This is a rough estimate JS strings are stored as UTF-16. | ||
if (log.message) { | ||
weight += log.message.length * 2; | ||
} | ||
if (log.attributes) { | ||
Object.values(log.attributes).forEach(value => { | ||
if (Array.isArray(value)) { | ||
weight += value.length * estimatePrimitiveSizeInBytes(value[0]); | ||
} else if (is.isPrimitive(value)) { | ||
weight += estimatePrimitiveSizeInBytes(value); | ||
} else { | ||
// For objects values, we estimate the size of the object as 100 bytes | ||
weight += 100; | ||
} | ||
}); | ||
} | ||
return weight; | ||
} | ||
function estimatePrimitiveSizeInBytes(value) { | ||
if (typeof value === 'string') { | ||
return value.length * 2; | ||
} else if (typeof value === 'number') { | ||
return 8; | ||
} else if (typeof value === 'boolean') { | ||
return 4; | ||
} | ||
return 0; | ||
} | ||
exports.ServerRuntimeClient = ServerRuntimeClient; | ||
//# sourceMappingURL=server-runtime-client.js.map |
@@ -36,3 +36,5 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
const dsc = object.dropUndefinedKeys({ | ||
// Instead of conditionally adding non-undefined values, we add them and then remove them if needed | ||
// otherwise, the order of baggage entries changes, which "breaks" a bunch of tests etc. | ||
const dsc = { | ||
environment: options.environment || constants.DEFAULT_ENVIRONMENT, | ||
@@ -42,3 +44,3 @@ release: options.release, | ||
trace_id, | ||
}) ; | ||
}; | ||
@@ -45,0 +47,0 @@ client.emit('createDsc', dsc); |
@@ -8,3 +8,2 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
const logger = require('../utils-hoist/logger.js'); | ||
const object = require('../utils-hoist/object.js'); | ||
const propagationContext = require('../utils-hoist/propagationContext.js'); | ||
@@ -188,3 +187,3 @@ const time = require('../utils-hoist/time.js'); | ||
getSpanJSON() { | ||
return object.dropUndefinedKeys({ | ||
return { | ||
data: this._attributes, | ||
@@ -206,3 +205,3 @@ description: this._name, | ||
links: spanUtils.convertSpanLinksForEnvelope(this._links), | ||
}); | ||
}; | ||
} | ||
@@ -209,0 +208,0 @@ |
@@ -5,3 +5,2 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
const envelope = require('../utils-hoist/envelope.js'); | ||
const error = require('../utils-hoist/error.js'); | ||
const logger = require('../utils-hoist/logger.js'); | ||
@@ -76,4 +75,4 @@ const promisebuffer = require('../utils-hoist/promisebuffer.js'); | ||
result => result, | ||
error$1 => { | ||
if (error$1 instanceof error.SentryError) { | ||
error => { | ||
if (error === promisebuffer.SENTRY_BUFFER_FULL_ERROR) { | ||
debugBuild.DEBUG_BUILD && logger.logger.error('Skipped sending event because buffer is full.'); | ||
@@ -83,3 +82,3 @@ recordEnvelopeLoss('queue_overflow'); | ||
} else { | ||
throw error$1; | ||
throw error; | ||
} | ||
@@ -86,0 +85,0 @@ }, |
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
const nodeStackTrace = require('./node-stack-trace.js'); | ||
const object = require('./object.js'); | ||
const stacktrace = require('./stacktrace.js'); | ||
@@ -65,3 +64,3 @@ | ||
return object.dropUndefinedKeys({ | ||
return { | ||
filename, | ||
@@ -73,3 +72,3 @@ module: getModuleFromFilename(filename), | ||
in_app: filename ? nodeStackTrace.filenameIsInApp(filename) : undefined, | ||
}); | ||
}; | ||
} | ||
@@ -76,0 +75,0 @@ |
@@ -6,3 +6,2 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
const normalize = require('./normalize.js'); | ||
const object = require('./object.js'); | ||
const worldwide = require('./worldwide.js'); | ||
@@ -185,3 +184,3 @@ | ||
return [ | ||
object.dropUndefinedKeys({ | ||
{ | ||
type: 'attachment', | ||
@@ -192,3 +191,3 @@ length: buffer.length, | ||
attachment_type: attachment.attachmentType, | ||
}), | ||
}, | ||
buffer, | ||
@@ -195,0 +194,0 @@ ]; |
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/** An error emitted by Sentry SDKs and related utilities. */ | ||
/** | ||
* An error emitted by Sentry SDKs and related utilities. | ||
* @deprecated This class is no longer used and will be removed in a future version. Use `Error` instead. | ||
*/ | ||
class SentryError extends Error { | ||
@@ -5,0 +8,0 @@ |
@@ -196,2 +196,4 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
* Attention: This function keeps circular references in the returned object. | ||
* | ||
* @deprecated This function is no longer used by the SDK and will be removed in a future major version. | ||
*/ | ||
@@ -198,0 +200,0 @@ function dropUndefinedKeys(inputValue) { |
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
const error = require('./error.js'); | ||
const syncpromise = require('./syncpromise.js'); | ||
const SENTRY_BUFFER_FULL_ERROR = Symbol.for('SentryBufferFullError'); | ||
/** | ||
@@ -39,3 +40,3 @@ * Creates an new PromiseBuffer object with the specified limit | ||
if (!isReady()) { | ||
return syncpromise.rejectedSyncPromise(new error.SentryError('Not adding Promise because buffer limit was reached.')); | ||
return syncpromise.rejectedSyncPromise(SENTRY_BUFFER_FULL_ERROR); | ||
} | ||
@@ -104,3 +105,4 @@ | ||
exports.SENTRY_BUFFER_FULL_ERROR = SENTRY_BUFFER_FULL_ERROR; | ||
exports.makePromiseBuffer = makePromiseBuffer; | ||
//# sourceMappingURL=promisebuffer.js.map |
@@ -5,5 +5,5 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
const SDK_VERSION = "9.9.0" ; | ||
const SDK_VERSION = "9.10.0" ; | ||
exports.SDK_VERSION = SDK_VERSION; | ||
//# sourceMappingURL=version.js.map |
@@ -8,5 +8,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
* "__sentry_template_values__": ['first', 'second'] | ||
* | ||
* @param strings An array of string values splitted between expressions | ||
* @param values Expressions extracted from template string | ||
* @returns String with template information in __sentry_template_string__ and __sentry_template_values__ properties | ||
* | ||
* @returns A `ParameterizedString` object that can be passed into `captureMessage` or Sentry.logger.X methods. | ||
*/ | ||
@@ -20,3 +22,13 @@ function parameterize(strings, ...values) { | ||
/** | ||
* Tagged template function which returns parameterized representation of the message. | ||
* | ||
* @param strings An array of string values splitted between expressions | ||
* @param values Expressions extracted from template string | ||
* @returns A `ParameterizedString` object that can be passed into `captureMessage` or Sentry.logger.X methods. | ||
*/ | ||
const fmt = parameterize; | ||
exports.fmt = fmt; | ||
exports.parameterize = parameterize; | ||
//# sourceMappingURL=parameterize.js.map |
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
const object = require('../utils-hoist/object.js'); | ||
/** | ||
@@ -85,3 +83,3 @@ * Transforms a `Headers` object that implements the `Web Fetch API` (https://developer.mozilla.org/en-US/docs/Web/API/Headers) into a simple key-value dict. | ||
return object.dropUndefinedKeys({ | ||
return { | ||
url: absoluteUrl, | ||
@@ -93,3 +91,3 @@ method: request.method, | ||
data, | ||
}); | ||
}; | ||
} | ||
@@ -96,0 +94,0 @@ |
@@ -31,3 +31,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
return object.dropUndefinedKeys({ | ||
return { | ||
parent_span_id, | ||
@@ -41,3 +41,3 @@ span_id, | ||
links, | ||
}); | ||
}; | ||
} | ||
@@ -58,7 +58,7 @@ | ||
return object.dropUndefinedKeys({ | ||
return { | ||
parent_span_id, | ||
span_id, | ||
trace_id, | ||
}); | ||
}; | ||
} | ||
@@ -139,3 +139,3 @@ | ||
return object.dropUndefinedKeys({ | ||
return { | ||
span_id, | ||
@@ -153,3 +153,3 @@ trace_id, | ||
links: convertSpanLinksForEnvelope(links), | ||
}); | ||
}; | ||
} | ||
@@ -156,0 +156,0 @@ |
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
const semanticAttributes = require('../semanticAttributes.js'); | ||
require('../utils-hoist/debug-build.js'); | ||
require('../utils-hoist/logger.js'); | ||
const object = require('../utils-hoist/object.js'); | ||
require('../utils-hoist/time.js'); | ||
require('../utils-hoist/syncpromise.js'); | ||
@@ -16,3 +11,3 @@ /** | ||
return object.dropUndefinedKeys({ | ||
return { | ||
data: data ?? {}, | ||
@@ -32,3 +27,3 @@ description: event.transaction, | ||
is_segment: true, | ||
}); | ||
}; | ||
} | ||
@@ -40,3 +35,3 @@ | ||
function convertSpanJsonToTransactionEvent(span) { | ||
const event = { | ||
return { | ||
type: 'transaction', | ||
@@ -63,4 +58,2 @@ timestamp: span.timestamp, | ||
}; | ||
return object.dropUndefinedKeys(event); | ||
} | ||
@@ -67,0 +60,0 @@ |
@@ -12,3 +12,2 @@ import { getEnvelopeEndpointWithUrlEncodedAuth } from './api.js'; | ||
import { addItemToEnvelope, createAttachmentEnvelopeItem } from './utils-hoist/envelope.js'; | ||
import { SentryError } from './utils-hoist/error.js'; | ||
import { isPrimitive, isParameterizedString, isThenable, isPlainObject } from './utils-hoist/is.js'; | ||
@@ -29,2 +28,27 @@ import { logger } from './utils-hoist/logger.js'; | ||
const INTERNAL_ERROR_SYMBOL = Symbol.for('SentryInternalError'); | ||
const DO_NOT_SEND_EVENT_SYMBOL = Symbol.for('SentryDoNotSendEventError'); | ||
function _makeInternalError(message) { | ||
return { | ||
message, | ||
[INTERNAL_ERROR_SYMBOL]: true, | ||
}; | ||
} | ||
function _makeDoNotSendEventError(message) { | ||
return { | ||
message, | ||
[DO_NOT_SEND_EVENT_SYMBOL]: true, | ||
}; | ||
} | ||
function _isInternalError(error) { | ||
return !!error && typeof error === 'object' && INTERNAL_ERROR_SYMBOL in error; | ||
} | ||
function _isDoNotSendEventError(error) { | ||
return !!error && typeof error === 'object' && DO_NOT_SEND_EVENT_SYMBOL in error; | ||
} | ||
/** | ||
@@ -618,6 +642,6 @@ * Base implementation for all JavaScript SDK clients. | ||
if (DEBUG_BUILD) { | ||
// If something's gone wrong, log the error as a warning. If it's just us having used a `SentryError` for | ||
// control flow, log just the message (no stack) as a log-level log. | ||
if (reason instanceof SentryError && reason.logLevel === 'log') { | ||
if (_isDoNotSendEventError(reason)) { | ||
logger.log(reason.message); | ||
} else if (_isInternalError(reason)) { | ||
logger.warn(reason.message); | ||
} else { | ||
@@ -666,5 +690,4 @@ logger.warn(reason); | ||
return rejectedSyncPromise( | ||
new SentryError( | ||
_makeDoNotSendEventError( | ||
`Discarding event because it's not included in the random sample (sampling rate = ${sampleRate})`, | ||
'log', | ||
), | ||
@@ -680,3 +703,3 @@ ); | ||
this.recordDroppedEvent('event_processor', dataCategory); | ||
throw new SentryError('An event processor returned `null`, will not send event.', 'log'); | ||
throw _makeDoNotSendEventError('An event processor returned `null`, will not send event.'); | ||
} | ||
@@ -701,3 +724,3 @@ | ||
} | ||
throw new SentryError(`${beforeSendLabel} returned \`null\`, will not send event.`, 'log'); | ||
throw _makeDoNotSendEventError(`${beforeSendLabel} returned \`null\`, will not send event.`); | ||
} | ||
@@ -736,3 +759,3 @@ | ||
.then(null, reason => { | ||
if (reason instanceof SentryError) { | ||
if (_isDoNotSendEventError(reason) || _isInternalError(reason)) { | ||
throw reason; | ||
@@ -747,3 +770,3 @@ } | ||
}); | ||
throw new SentryError( | ||
throw _makeInternalError( | ||
`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${reason}`, | ||
@@ -844,3 +867,3 @@ ); | ||
if (!isPlainObject(event) && event !== null) { | ||
throw new SentryError(invalidValueError); | ||
throw _makeInternalError(invalidValueError); | ||
} | ||
@@ -850,7 +873,7 @@ return event; | ||
e => { | ||
throw new SentryError(`${beforeSendLabel} rejected with ${e}`); | ||
throw _makeInternalError(`${beforeSendLabel} rejected with ${e}`); | ||
}, | ||
); | ||
} else if (!isPlainObject(beforeSendResult) && beforeSendResult !== null) { | ||
throw new SentryError(invalidValueError); | ||
throw _makeInternalError(invalidValueError); | ||
} | ||
@@ -857,0 +880,0 @@ return beforeSendResult; |
@@ -36,3 +36,3 @@ export { registerSpanErrorInstrumentation } from './tracing/errors.js'; | ||
export { handleCallbackErrors } from './utils/handleCallbackErrors.js'; | ||
export { parameterize } from './utils/parameterize.js'; | ||
export { fmt, parameterize } from './utils/parameterize.js'; | ||
export { addAutoIpAddressToSession, addAutoIpAddressToUser } from './utils/ipAddress.js'; | ||
@@ -82,3 +82,3 @@ export { addChildSpanToSpan, convertSpanLinksForEnvelope, getActiveSpan, getRootSpan, getSpanDescendants, getStatusMessage, spanIsSampled, spanTimeInputToSeconds, spanToJSON, spanToTraceContext, spanToTraceHeader, updateSpanName } from './utils/spanUtils.js'; | ||
export { basename, dirname, isAbsolute, join, normalizePath, relative, resolve } from './utils-hoist/path.js'; | ||
export { makePromiseBuffer } from './utils-hoist/promisebuffer.js'; | ||
export { SENTRY_BUFFER_FULL_ERROR, makePromiseBuffer } from './utils-hoist/promisebuffer.js'; | ||
export { severityLevelFromString } from './utils-hoist/severity.js'; | ||
@@ -85,0 +85,0 @@ export { UNKNOWN_FUNCTION, createStackParser, getFramesFromEvent, getFunctionName, stackParserFromStackParserOptions, stripSentryFramesAndReverse } from './utils-hoist/stacktrace.js'; |
@@ -95,3 +95,2 @@ import { DEBUG_BUILD } from '../debug-build.js'; | ||
ignoreTransactions: [...(internalOptions.ignoreTransactions || []), ...(clientOptions.ignoreTransactions || [])], | ||
ignoreInternal: internalOptions.ignoreInternal !== undefined ? internalOptions.ignoreInternal : true, | ||
}; | ||
@@ -103,8 +102,2 @@ } | ||
// Filter errors | ||
if (options.ignoreInternal && _isSentryError(event)) { | ||
DEBUG_BUILD && | ||
logger.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${getEventDescription(event)}`); | ||
return true; | ||
} | ||
if (_isIgnoredError(event, options.ignoreErrors)) { | ||
@@ -191,12 +184,2 @@ DEBUG_BUILD && | ||
function _isSentryError(event) { | ||
try { | ||
// @ts-expect-error can't be a sentry error if undefined | ||
return event.exception.values[0].type === 'SentryError'; | ||
} catch (e) { | ||
// ignore | ||
} | ||
return false; | ||
} | ||
function _getLastValidUrl(frames = []) { | ||
@@ -203,0 +186,0 @@ for (let i = frames.length - 1; i >= 0; i--) { |
@@ -5,2 +5,3 @@ import { _getTraceInfoFromScope } from '../client.js'; | ||
import { SEVERITY_TEXT_TO_SEVERITY_NUMBER } from './constants.js'; | ||
import { isParameterizedString } from '../utils-hoist/is.js'; | ||
import '../utils-hoist/debug-build.js'; | ||
@@ -66,3 +67,3 @@ import { logger } from '../utils-hoist/logger.js'; | ||
*/ | ||
function _INTERNAL_captureLog(log, client = getClient(), scope = getCurrentScope()) { | ||
function _INTERNAL_captureLog(beforeLog, client = getClient(), scope = getCurrentScope()) { | ||
if (!client) { | ||
@@ -74,3 +75,4 @@ DEBUG_BUILD && logger.warn('No client available to capture log.'); | ||
const { _experiments, release, environment } = client.getOptions(); | ||
if (!_experiments?.enableLogs) { | ||
const { enableLogs = false, beforeSendLog } = _experiments ?? {}; | ||
if (!enableLogs) { | ||
DEBUG_BUILD && logger.warn('logging option not enabled, log will not be captured.'); | ||
@@ -80,2 +82,11 @@ return; | ||
client.emit('beforeCaptureLog', beforeLog); | ||
const log = beforeSendLog ? beforeSendLog(beforeLog) : beforeLog; | ||
if (!log) { | ||
client.recordDroppedEvent('before_send', 'log_item', 1); | ||
DEBUG_BUILD && logger.warn('beforeSendLog returned null, log will not be captured.'); | ||
return; | ||
} | ||
const [, traceContext] = _getTraceInfoFromScope(client, scope); | ||
@@ -97,2 +108,10 @@ | ||
if (isParameterizedString(message)) { | ||
const { __sentry_template_string__, __sentry_template_values__ = [] } = message; | ||
logAttributes['sentry.message.template'] = __sentry_template_string__; | ||
__sentry_template_values__.forEach((param, index) => { | ||
logAttributes[`sentry.message.param.${index}`] = param; | ||
}); | ||
} | ||
const span = _getSpanForScope(scope); | ||
@@ -118,10 +137,10 @@ if (span) { | ||
CLIENT_TO_LOG_BUFFER_MAP.set(client, [serializedLog]); | ||
// Every time we initialize a new log buffer, we start a new interval to flush the buffer | ||
return; | ||
} else { | ||
logBuffer.push(serializedLog); | ||
if (logBuffer.length > MAX_LOG_BUFFER_SIZE) { | ||
_INTERNAL_flushLogsBuffer(client, logBuffer); | ||
} | ||
} | ||
logBuffer.push(serializedLog); | ||
if (logBuffer.length > MAX_LOG_BUFFER_SIZE) { | ||
_INTERNAL_flushLogsBuffer(client, logBuffer); | ||
} | ||
client.emit('afterCaptureLog', log); | ||
} | ||
@@ -128,0 +147,0 @@ |
@@ -1,1 +0,1 @@ | ||
{"type":"module","version":"9.9.0","sideEffects":false} | ||
{"type":"module","version":"9.10.0","sideEffects":false} |
@@ -6,2 +6,3 @@ import { updateSession } from './session.js'; | ||
import { generateTraceId } from './utils-hoist/propagationContext.js'; | ||
import { truncate } from './utils-hoist/string.js'; | ||
import { dateTimestampInSeconds } from './utils-hoist/time.js'; | ||
@@ -397,2 +398,4 @@ import { merge } from './utils/merge.js'; | ||
...breadcrumb, | ||
// Breadcrumb messages can theoretically be infinitely large and they're held in memory so we truncate them not to leak (too much) memory | ||
message: breadcrumb.message ? truncate(breadcrumb.message, 2048) : breadcrumb.message, | ||
}; | ||
@@ -399,0 +402,0 @@ |
@@ -6,2 +6,3 @@ import { createCheckInEnvelope } from './checkin.js'; | ||
import { registerSpanErrorInstrumentation } from './tracing/errors.js'; | ||
import { isPrimitive } from './utils-hoist/is.js'; | ||
import './utils-hoist/debug-build.js'; | ||
@@ -13,2 +14,3 @@ import { logger } from './utils-hoist/logger.js'; | ||
import { eventFromUnknownInput, eventFromMessage } from './utils-hoist/eventbuilder.js'; | ||
import { _INTERNAL_flushLogsBuffer } from './logs/index.js'; | ||
@@ -21,2 +23,3 @@ /** | ||
extends Client { | ||
/** | ||
@@ -31,2 +34,22 @@ * Creates a new Edge SDK instance. | ||
super(options); | ||
this._logWeight = 0; | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
const client = this; | ||
this.on('flush', () => { | ||
_INTERNAL_flushLogsBuffer(client); | ||
}); | ||
this.on('afterCaptureLog', log => { | ||
client._logWeight += estimateLogSizeInBytes(log); | ||
// We flush the logs buffer if it exceeds 0.8 MB | ||
// The log weight is a rough estimate, so we flush way before | ||
// the payload gets too big. | ||
if (client._logWeight > 800000) { | ||
_INTERNAL_flushLogsBuffer(client); | ||
client._logWeight = 0; | ||
} | ||
}); | ||
} | ||
@@ -187,3 +210,45 @@ | ||
/** | ||
* Estimate the size of a log in bytes. | ||
* | ||
* @param log - The log to estimate the size of. | ||
* @returns The estimated size of the log in bytes. | ||
*/ | ||
function estimateLogSizeInBytes(log) { | ||
let weight = 0; | ||
// Estimate byte size of 2 bytes per character. This is a rough estimate JS strings are stored as UTF-16. | ||
if (log.message) { | ||
weight += log.message.length * 2; | ||
} | ||
if (log.attributes) { | ||
Object.values(log.attributes).forEach(value => { | ||
if (Array.isArray(value)) { | ||
weight += value.length * estimatePrimitiveSizeInBytes(value[0]); | ||
} else if (isPrimitive(value)) { | ||
weight += estimatePrimitiveSizeInBytes(value); | ||
} else { | ||
// For objects values, we estimate the size of the object as 100 bytes | ||
weight += 100; | ||
} | ||
}); | ||
} | ||
return weight; | ||
} | ||
function estimatePrimitiveSizeInBytes(value) { | ||
if (typeof value === 'string') { | ||
return value.length * 2; | ||
} else if (typeof value === 'number') { | ||
return 8; | ||
} else if (typeof value === 'boolean') { | ||
return 4; | ||
} | ||
return 0; | ||
} | ||
export { ServerRuntimeClient }; | ||
//# sourceMappingURL=server-runtime-client.js.map |
@@ -5,3 +5,3 @@ import { DEFAULT_ENVIRONMENT } from '../constants.js'; | ||
import { baggageHeaderToDynamicSamplingContext, dynamicSamplingContextToSentryBaggageHeader } from '../utils-hoist/baggage.js'; | ||
import { dropUndefinedKeys, addNonEnumerableProperty } from '../utils-hoist/object.js'; | ||
import { addNonEnumerableProperty } from '../utils-hoist/object.js'; | ||
import { hasSpansEnabled } from '../utils/hasSpansEnabled.js'; | ||
@@ -35,3 +35,5 @@ import { getRootSpan, spanToJSON, spanIsSampled } from '../utils/spanUtils.js'; | ||
const dsc = dropUndefinedKeys({ | ||
// Instead of conditionally adding non-undefined values, we add them and then remove them if needed | ||
// otherwise, the order of baggage entries changes, which "breaks" a bunch of tests etc. | ||
const dsc = { | ||
environment: options.environment || DEFAULT_ENVIRONMENT, | ||
@@ -41,3 +43,3 @@ release: options.release, | ||
trace_id, | ||
}) ; | ||
}; | ||
@@ -44,0 +46,0 @@ client.emit('createDsc', dsc); |
@@ -6,3 +6,2 @@ import { getClient, getCurrentScope } from '../currentScopes.js'; | ||
import { logger } from '../utils-hoist/logger.js'; | ||
import { dropUndefinedKeys } from '../utils-hoist/object.js'; | ||
import { generateTraceId, generateSpanId } from '../utils-hoist/propagationContext.js'; | ||
@@ -186,3 +185,3 @@ import { timestampInSeconds } from '../utils-hoist/time.js'; | ||
getSpanJSON() { | ||
return dropUndefinedKeys({ | ||
return { | ||
data: this._attributes, | ||
@@ -204,3 +203,3 @@ description: this._name, | ||
links: convertSpanLinksForEnvelope(this._links), | ||
}); | ||
}; | ||
} | ||
@@ -207,0 +206,0 @@ |
import { DEBUG_BUILD } from '../debug-build.js'; | ||
import { forEachEnvelopeItem, envelopeItemTypeToDataCategory, createEnvelope, serializeEnvelope } from '../utils-hoist/envelope.js'; | ||
import { SentryError } from '../utils-hoist/error.js'; | ||
import { logger } from '../utils-hoist/logger.js'; | ||
import { makePromiseBuffer } from '../utils-hoist/promisebuffer.js'; | ||
import { makePromiseBuffer, SENTRY_BUFFER_FULL_ERROR } from '../utils-hoist/promisebuffer.js'; | ||
import { isRateLimited, updateRateLimits } from '../utils-hoist/ratelimit.js'; | ||
@@ -74,3 +73,3 @@ import { resolvedSyncPromise } from '../utils-hoist/syncpromise.js'; | ||
error => { | ||
if (error instanceof SentryError) { | ||
if (error === SENTRY_BUFFER_FULL_ERROR) { | ||
DEBUG_BUILD && logger.error('Skipped sending event because buffer is full.'); | ||
@@ -77,0 +76,0 @@ recordEnvelopeLoss('queue_overflow'); |
import { filenameIsInApp } from './node-stack-trace.js'; | ||
import { dropUndefinedKeys } from './object.js'; | ||
import { UNKNOWN_FUNCTION } from './stacktrace.js'; | ||
@@ -63,3 +62,3 @@ | ||
return dropUndefinedKeys({ | ||
return { | ||
filename, | ||
@@ -71,3 +70,3 @@ module: getModuleFromFilename(filename), | ||
in_app: filename ? filenameIsInApp(filename) : undefined, | ||
}); | ||
}; | ||
} | ||
@@ -74,0 +73,0 @@ |
import { getSentryCarrier } from '../carrier.js'; | ||
import { dsnToString } from './dsn.js'; | ||
import { normalize } from './normalize.js'; | ||
import { dropUndefinedKeys } from './object.js'; | ||
import { GLOBAL_OBJ } from './worldwide.js'; | ||
@@ -182,3 +181,3 @@ | ||
return [ | ||
dropUndefinedKeys({ | ||
{ | ||
type: 'attachment', | ||
@@ -189,3 +188,3 @@ length: buffer.length, | ||
attachment_type: attachment.attachmentType, | ||
}), | ||
}, | ||
buffer, | ||
@@ -192,0 +191,0 @@ ]; |
@@ -1,2 +0,5 @@ | ||
/** An error emitted by Sentry SDKs and related utilities. */ | ||
/** | ||
* An error emitted by Sentry SDKs and related utilities. | ||
* @deprecated This class is no longer used and will be removed in a future version. Use `Error` instead. | ||
*/ | ||
class SentryError extends Error { | ||
@@ -3,0 +6,0 @@ |
@@ -194,2 +194,4 @@ import { htmlTreeAsString } from './browser.js'; | ||
* Attention: This function keeps circular references in the returned object. | ||
* | ||
* @deprecated This function is no longer used by the SDK and will be removed in a future major version. | ||
*/ | ||
@@ -196,0 +198,0 @@ function dropUndefinedKeys(inputValue) { |
@@ -1,4 +0,5 @@ | ||
import { SentryError } from './error.js'; | ||
import { SyncPromise, resolvedSyncPromise, rejectedSyncPromise } from './syncpromise.js'; | ||
const SENTRY_BUFFER_FULL_ERROR = Symbol.for('SentryBufferFullError'); | ||
/** | ||
@@ -37,3 +38,3 @@ * Creates an new PromiseBuffer object with the specified limit | ||
if (!isReady()) { | ||
return rejectedSyncPromise(new SentryError('Not adding Promise because buffer limit was reached.')); | ||
return rejectedSyncPromise(SENTRY_BUFFER_FULL_ERROR); | ||
} | ||
@@ -102,3 +103,3 @@ | ||
export { makePromiseBuffer }; | ||
export { SENTRY_BUFFER_FULL_ERROR, makePromiseBuffer }; | ||
//# sourceMappingURL=promisebuffer.js.map |
// This is a magic string replaced by rollup | ||
const SDK_VERSION = "9.9.0" ; | ||
const SDK_VERSION = "9.10.0" ; | ||
export { SDK_VERSION }; | ||
//# sourceMappingURL=version.js.map |
@@ -6,5 +6,7 @@ /** | ||
* "__sentry_template_values__": ['first', 'second'] | ||
* | ||
* @param strings An array of string values splitted between expressions | ||
* @param values Expressions extracted from template string | ||
* @returns String with template information in __sentry_template_string__ and __sentry_template_values__ properties | ||
* | ||
* @returns A `ParameterizedString` object that can be passed into `captureMessage` or Sentry.logger.X methods. | ||
*/ | ||
@@ -18,3 +20,12 @@ function parameterize(strings, ...values) { | ||
export { parameterize }; | ||
/** | ||
* Tagged template function which returns parameterized representation of the message. | ||
* | ||
* @param strings An array of string values splitted between expressions | ||
* @param values Expressions extracted from template string | ||
* @returns A `ParameterizedString` object that can be passed into `captureMessage` or Sentry.logger.X methods. | ||
*/ | ||
const fmt = parameterize; | ||
export { fmt, parameterize }; | ||
//# sourceMappingURL=parameterize.js.map |
@@ -1,3 +0,1 @@ | ||
import { dropUndefinedKeys } from '../utils-hoist/object.js'; | ||
/** | ||
@@ -83,3 +81,3 @@ * Transforms a `Headers` object that implements the `Web Fetch API` (https://developer.mozilla.org/en-US/docs/Web/API/Headers) into a simple key-value dict. | ||
return dropUndefinedKeys({ | ||
return { | ||
url: absoluteUrl, | ||
@@ -91,3 +89,3 @@ method: request.method, | ||
data, | ||
}); | ||
}; | ||
} | ||
@@ -94,0 +92,0 @@ |
@@ -8,3 +8,3 @@ import { getAsyncContextStrategy } from '../asyncContext/index.js'; | ||
import { consoleSandbox } from '../utils-hoist/logger.js'; | ||
import { dropUndefinedKeys, addNonEnumerableProperty } from '../utils-hoist/object.js'; | ||
import { addNonEnumerableProperty } from '../utils-hoist/object.js'; | ||
import { generateSpanId } from '../utils-hoist/propagationContext.js'; | ||
@@ -30,3 +30,3 @@ import { timestampInSeconds } from '../utils-hoist/time.js'; | ||
return dropUndefinedKeys({ | ||
return { | ||
parent_span_id, | ||
@@ -40,3 +40,3 @@ span_id, | ||
links, | ||
}); | ||
}; | ||
} | ||
@@ -57,7 +57,7 @@ | ||
return dropUndefinedKeys({ | ||
return { | ||
parent_span_id, | ||
span_id, | ||
trace_id, | ||
}); | ||
}; | ||
} | ||
@@ -138,3 +138,3 @@ | ||
return dropUndefinedKeys({ | ||
return { | ||
span_id, | ||
@@ -152,3 +152,3 @@ trace_id, | ||
links: convertSpanLinksForEnvelope(links), | ||
}); | ||
}; | ||
} | ||
@@ -155,0 +155,0 @@ |
import { SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME, SEMANTIC_ATTRIBUTE_PROFILE_ID } from '../semanticAttributes.js'; | ||
import '../utils-hoist/debug-build.js'; | ||
import '../utils-hoist/logger.js'; | ||
import { dropUndefinedKeys } from '../utils-hoist/object.js'; | ||
import '../utils-hoist/time.js'; | ||
import '../utils-hoist/syncpromise.js'; | ||
@@ -14,3 +9,3 @@ /** | ||
return dropUndefinedKeys({ | ||
return { | ||
data: data ?? {}, | ||
@@ -30,3 +25,3 @@ description: event.transaction, | ||
is_segment: true, | ||
}); | ||
}; | ||
} | ||
@@ -38,3 +33,3 @@ | ||
function convertSpanJsonToTransactionEvent(span) { | ||
const event = { | ||
return { | ||
type: 'transaction', | ||
@@ -61,4 +56,2 @@ timestamp: span.timestamp, | ||
}; | ||
return dropUndefinedKeys(event); | ||
} | ||
@@ -65,0 +58,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { Breadcrumb, BreadcrumbHint, CheckIn, ClientOptions, DataCategory, DsnComponents, DynamicSamplingContext, Envelope, Event, EventDropReason, EventHint, EventProcessor, FeedbackEvent, FetchBreadcrumbHint, Integration, MonitorConfig, Outcome, ParameterizedString, SdkMetadata, Session, SessionAggregates, SeverityLevel, Span, SpanAttributes, SpanContextData, StartSpanOptions, TraceContext, Transport, TransportMakeRequestResponse, XhrBreadcrumbHint } from './types-hoist'; | ||
import { Breadcrumb, BreadcrumbHint, CheckIn, ClientOptions, DataCategory, DsnComponents, DynamicSamplingContext, Envelope, Event, EventDropReason, EventHint, EventProcessor, FeedbackEvent, FetchBreadcrumbHint, Integration, Log, MonitorConfig, Outcome, ParameterizedString, SdkMetadata, Session, SessionAggregates, SeverityLevel, Span, SpanAttributes, SpanContextData, StartSpanOptions, TraceContext, Transport, TransportMakeRequestResponse, XhrBreadcrumbHint } from './types-hoist'; | ||
import { IntegrationIndex } from './integration'; | ||
@@ -290,2 +290,14 @@ import { Scope } from './scope'; | ||
on(hook: 'close', callback: () => void): () => void; | ||
/** | ||
* A hook that is called before a log is captured. This hooks runs before `beforeSendLog` is fired. | ||
* | ||
* @returns {() => void} A function that, when executed, removes the registered callback. | ||
*/ | ||
on(hook: 'beforeCaptureLog', callback: (log: Log) => void): () => void; | ||
/** | ||
* A hook that is called after a log is captured | ||
* | ||
* @returns {() => void} A function that, when executed, removes the registered callback. | ||
*/ | ||
on(hook: 'afterCaptureLog', callback: (log: Log) => void): () => void; | ||
/** Fire a hook whenever a span starts. */ | ||
@@ -380,2 +392,10 @@ emit(hook: 'spanStart', span: Span): void; | ||
/** | ||
* Emit a hook event for client before capturing a log. This hooks runs before `beforeSendLog` is fired. | ||
*/ | ||
emit(hook: 'beforeCaptureLog', log: Log): void; | ||
/** | ||
* Emit a hook event for client after capturing a log. | ||
*/ | ||
emit(hook: 'afterCaptureLog', log: Log): void; | ||
/** | ||
* Send an envelope to Sentry. | ||
@@ -382,0 +402,0 @@ */ |
@@ -34,3 +34,3 @@ export { ClientClass as SentryCoreCurrentScopes } from './sdk'; | ||
export { handleCallbackErrors } from './utils/handleCallbackErrors'; | ||
export { parameterize } from './utils/parameterize'; | ||
export { parameterize, fmt } from './utils/parameterize'; | ||
export { addAutoIpAddressToSession, addAutoIpAddressToUser } from './utils/ipAddress'; | ||
@@ -37,0 +37,0 @@ export { convertSpanLinksForEnvelope, spanToTraceHeader, spanToJSON, spanIsSampled, spanToTraceContext, getSpanDescendants, getStatusMessage, getRootSpan, getActiveSpan, addChildSpanToSpan, spanTimeInputToSeconds, updateSpanName, } from './utils/spanUtils'; |
@@ -22,3 +22,3 @@ import { Client } from '../client'; | ||
*/ | ||
export declare function _INTERNAL_captureLog(log: Log, client?: Client<import("../types-hoist").ClientOptions<import("../types-hoist").BaseTransportOptions>> | undefined, scope?: import("..").Scope): void; | ||
export declare function _INTERNAL_captureLog(beforeLog: Log, client?: Client<import("../types-hoist").ClientOptions<import("../types-hoist").BaseTransportOptions>> | undefined, scope?: import("..").Scope): void; | ||
/** | ||
@@ -25,0 +25,0 @@ * Flushes the logs buffer to Sentry. |
@@ -16,2 +16,3 @@ import { BaseTransportOptions, CheckIn, ClientOptions, Event, EventHint, MonitorConfig, ParameterizedString, SeverityLevel } from './types-hoist'; | ||
export declare class ServerRuntimeClient<O extends ClientOptions & ServerRuntimeClientOptions = ServerRuntimeClientOptions> extends Client<O> { | ||
private _logWeight; | ||
/** | ||
@@ -18,0 +19,0 @@ * Creates a new Edge SDK instance. |
@@ -24,3 +24,3 @@ import { CaptureContext, SdkProcessingMetadata } from '../scope'; | ||
message?: string; | ||
params?: string[]; | ||
params?: unknown[]; | ||
}; | ||
@@ -27,0 +27,0 @@ timestamp?: number; |
@@ -8,3 +8,3 @@ export { Attachment } from './attachment'; | ||
export { DebugImage, DebugMeta } from './debugMeta'; | ||
export { AttachmentItem, BaseEnvelopeHeaders, BaseEnvelopeItemHeaders, ClientReportEnvelope, ClientReportItem, DynamicSamplingContext, Envelope, EnvelopeItemType, EnvelopeItem, EventEnvelope, EventEnvelopeHeaders, EventItem, ReplayEnvelope, FeedbackItem, SessionEnvelope, SessionItem, UserFeedbackItem, CheckInItem, CheckInEnvelope, RawSecurityEnvelope, RawSecurityItem, ProfileItem, ProfileChunkEnvelope, ProfileChunkItem, SpanEnvelope, SpanItem, } from './envelope'; | ||
export { AttachmentItem, BaseEnvelopeHeaders, BaseEnvelopeItemHeaders, ClientReportEnvelope, ClientReportItem, DynamicSamplingContext, Envelope, EnvelopeItemType, EnvelopeItem, EventEnvelope, EventEnvelopeHeaders, EventItem, ReplayEnvelope, FeedbackItem, SessionEnvelope, SessionItem, UserFeedbackItem, CheckInItem, CheckInEnvelope, RawSecurityEnvelope, RawSecurityItem, ProfileItem, ProfileChunkEnvelope, ProfileChunkItem, SpanEnvelope, SpanItem, OtelLogEnvelope, OtelLogItem, } from './envelope'; | ||
export { ExtendedError } from './error'; | ||
@@ -11,0 +11,0 @@ export { Event, EventHint, EventType, ErrorEvent, TransactionEvent } from './event'; |
@@ -1,2 +0,3 @@ | ||
export type LogSeverityLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'critical'; | ||
import { ParameterizedString } from './parameterize'; | ||
export type LogSeverityLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'; | ||
export type SerializedLogAttributeValueType = { | ||
@@ -29,7 +30,7 @@ stringValue: string; | ||
*/ | ||
message: string; | ||
message: ParameterizedString; | ||
/** | ||
* Arbitrary structured data that stores information about the log - e.g., userId: 100. | ||
*/ | ||
attributes?: Record<string, string | number | boolean | Array<string | number | boolean>>; | ||
attributes?: Record<string, unknown>; | ||
/** | ||
@@ -36,0 +37,0 @@ * The severity number - generally higher severity are levels like 'error' and lower are levels like 'debug' |
@@ -5,2 +5,3 @@ import { CaptureContext } from '../scope'; | ||
import { Integration } from './integration'; | ||
import { Log } from './log'; | ||
import { TracesSamplerSamplingContext } from './samplingcontext'; | ||
@@ -165,2 +166,13 @@ import { SdkMetadata } from './sdkmetadata'; | ||
enableLogs?: boolean; | ||
/** | ||
* An event-processing callback for logs, guaranteed to be invoked after all other log | ||
* processors. This allows a log to be modified or dropped before it's sent. | ||
* | ||
* Note that you must return a valid log from this callback. If you do not wish to modify the log, simply return | ||
* it at the end. Returning `null` will cause the log to be dropped. | ||
* | ||
* @param log The log generated by the SDK. | ||
* @returns A new log that will be sent | null. | ||
*/ | ||
beforeSendLog?: (log: Log) => Log | null; | ||
}; | ||
@@ -167,0 +179,0 @@ /** |
export type ParameterizedString = string & { | ||
__sentry_template_string__?: string; | ||
__sentry_template_values__?: string[]; | ||
__sentry_template_values__?: unknown[]; | ||
}; | ||
//# sourceMappingURL=parameterize.d.ts.map |
import { ConsoleLevel } from '../types-hoist'; | ||
/** An error emitted by Sentry SDKs and related utilities. */ | ||
/** | ||
* An error emitted by Sentry SDKs and related utilities. | ||
* @deprecated This class is no longer used and will be removed in a future version. Use `Error` instead. | ||
*/ | ||
export declare class SentryError extends Error { | ||
@@ -4,0 +7,0 @@ message: string; |
@@ -22,3 +22,3 @@ export { applyAggregateErrorsToEvent } from './aggregate-errors'; | ||
export { basename, dirname, isAbsolute, join, normalizePath, relative, resolve } from './path'; | ||
export { makePromiseBuffer } from './promisebuffer'; | ||
export { makePromiseBuffer, SENTRY_BUFFER_FULL_ERROR } from './promisebuffer'; | ||
export { PromiseBuffer } from './promisebuffer'; | ||
@@ -25,0 +25,0 @@ export { severityLevelFromString } from './severity'; |
@@ -73,2 +73,4 @@ import { WrappedFunction } from '../types-hoist'; | ||
* Attention: This function keeps circular references in the returned object. | ||
* | ||
* @deprecated This function is no longer used by the SDK and will be removed in a future major version. | ||
*/ | ||
@@ -75,0 +77,0 @@ export declare function dropUndefinedKeys<T>(inputValue: T): T; |
@@ -6,2 +6,3 @@ export interface PromiseBuffer<T> { | ||
} | ||
export declare const SENTRY_BUFFER_FULL_ERROR: unique symbol; | ||
/** | ||
@@ -8,0 +9,0 @@ * Creates an new PromiseBuffer object with the specified limit |
@@ -7,7 +7,17 @@ import { ParameterizedString } from '../types-hoist'; | ||
* "__sentry_template_values__": ['first', 'second'] | ||
* | ||
* @param strings An array of string values splitted between expressions | ||
* @param values Expressions extracted from template string | ||
* @returns String with template information in __sentry_template_string__ and __sentry_template_values__ properties | ||
* | ||
* @returns A `ParameterizedString` object that can be passed into `captureMessage` or Sentry.logger.X methods. | ||
*/ | ||
export declare function parameterize(strings: TemplateStringsArray, ...values: string[]): ParameterizedString; | ||
export declare function parameterize(strings: TemplateStringsArray, ...values: unknown[]): ParameterizedString; | ||
/** | ||
* Tagged template function which returns parameterized representation of the message. | ||
* | ||
* @param strings An array of string values splitted between expressions | ||
* @param values Expressions extracted from template string | ||
* @returns A `ParameterizedString` object that can be passed into `captureMessage` or Sentry.logger.X methods. | ||
*/ | ||
export declare const fmt: typeof parameterize; | ||
//# sourceMappingURL=parameterize.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import type { Breadcrumb, BreadcrumbHint, CheckIn, ClientOptions, DataCategory, DsnComponents, DynamicSamplingContext, Envelope, Event, EventDropReason, EventHint, EventProcessor, FeedbackEvent, FetchBreadcrumbHint, Integration, MonitorConfig, Outcome, ParameterizedString, SdkMetadata, Session, SessionAggregates, SeverityLevel, Span, SpanAttributes, SpanContextData, StartSpanOptions, TraceContext, Transport, TransportMakeRequestResponse, XhrBreadcrumbHint } from './types-hoist'; | ||
import type { Breadcrumb, BreadcrumbHint, CheckIn, ClientOptions, DataCategory, DsnComponents, DynamicSamplingContext, Envelope, Event, EventDropReason, EventHint, EventProcessor, FeedbackEvent, FetchBreadcrumbHint, Integration, Log, MonitorConfig, Outcome, ParameterizedString, SdkMetadata, Session, SessionAggregates, SeverityLevel, Span, SpanAttributes, SpanContextData, StartSpanOptions, TraceContext, Transport, TransportMakeRequestResponse, XhrBreadcrumbHint } from './types-hoist'; | ||
import type { IntegrationIndex } from './integration'; | ||
@@ -290,2 +290,14 @@ import type { Scope } from './scope'; | ||
on(hook: 'close', callback: () => void): () => void; | ||
/** | ||
* A hook that is called before a log is captured. This hooks runs before `beforeSendLog` is fired. | ||
* | ||
* @returns {() => void} A function that, when executed, removes the registered callback. | ||
*/ | ||
on(hook: 'beforeCaptureLog', callback: (log: Log) => void): () => void; | ||
/** | ||
* A hook that is called after a log is captured | ||
* | ||
* @returns {() => void} A function that, when executed, removes the registered callback. | ||
*/ | ||
on(hook: 'afterCaptureLog', callback: (log: Log) => void): () => void; | ||
/** Fire a hook whenever a span starts. */ | ||
@@ -380,2 +392,10 @@ emit(hook: 'spanStart', span: Span): void; | ||
/** | ||
* Emit a hook event for client before capturing a log. This hooks runs before `beforeSendLog` is fired. | ||
*/ | ||
emit(hook: 'beforeCaptureLog', log: Log): void; | ||
/** | ||
* Emit a hook event for client after capturing a log. | ||
*/ | ||
emit(hook: 'afterCaptureLog', log: Log): void; | ||
/** | ||
* Send an envelope to Sentry. | ||
@@ -382,0 +402,0 @@ */ |
@@ -34,3 +34,3 @@ export type { ClientClass as SentryCoreCurrentScopes } from './sdk'; | ||
export { handleCallbackErrors } from './utils/handleCallbackErrors'; | ||
export { parameterize } from './utils/parameterize'; | ||
export { parameterize, fmt } from './utils/parameterize'; | ||
export { addAutoIpAddressToSession, addAutoIpAddressToUser } from './utils/ipAddress'; | ||
@@ -37,0 +37,0 @@ export { convertSpanLinksForEnvelope, spanToTraceHeader, spanToJSON, spanIsSampled, spanToTraceContext, getSpanDescendants, getStatusMessage, getRootSpan, getActiveSpan, addChildSpanToSpan, spanTimeInputToSeconds, updateSpanName, } from './utils/spanUtils'; |
@@ -22,3 +22,3 @@ import type { Client } from '../client'; | ||
*/ | ||
export declare function _INTERNAL_captureLog(log: Log, client?: Client<import("../types-hoist").ClientOptions<import("../types-hoist").BaseTransportOptions>> | undefined, scope?: import("..").Scope): void; | ||
export declare function _INTERNAL_captureLog(beforeLog: Log, client?: Client<import("../types-hoist").ClientOptions<import("../types-hoist").BaseTransportOptions>> | undefined, scope?: import("..").Scope): void; | ||
/** | ||
@@ -25,0 +25,0 @@ * Flushes the logs buffer to Sentry. |
@@ -16,2 +16,3 @@ import type { BaseTransportOptions, CheckIn, ClientOptions, Event, EventHint, MonitorConfig, ParameterizedString, SeverityLevel } from './types-hoist'; | ||
export declare class ServerRuntimeClient<O extends ClientOptions & ServerRuntimeClientOptions = ServerRuntimeClientOptions> extends Client<O> { | ||
private _logWeight; | ||
/** | ||
@@ -18,0 +19,0 @@ * Creates a new Edge SDK instance. |
@@ -24,3 +24,3 @@ import type { CaptureContext, SdkProcessingMetadata } from '../scope'; | ||
message?: string; | ||
params?: string[]; | ||
params?: unknown[]; | ||
}; | ||
@@ -27,0 +27,0 @@ timestamp?: number; |
@@ -8,3 +8,3 @@ export type { Attachment } from './attachment'; | ||
export type { DebugImage, DebugMeta } from './debugMeta'; | ||
export type { AttachmentItem, BaseEnvelopeHeaders, BaseEnvelopeItemHeaders, ClientReportEnvelope, ClientReportItem, DynamicSamplingContext, Envelope, EnvelopeItemType, EnvelopeItem, EventEnvelope, EventEnvelopeHeaders, EventItem, ReplayEnvelope, FeedbackItem, SessionEnvelope, SessionItem, UserFeedbackItem, CheckInItem, CheckInEnvelope, RawSecurityEnvelope, RawSecurityItem, ProfileItem, ProfileChunkEnvelope, ProfileChunkItem, SpanEnvelope, SpanItem, } from './envelope'; | ||
export type { AttachmentItem, BaseEnvelopeHeaders, BaseEnvelopeItemHeaders, ClientReportEnvelope, ClientReportItem, DynamicSamplingContext, Envelope, EnvelopeItemType, EnvelopeItem, EventEnvelope, EventEnvelopeHeaders, EventItem, ReplayEnvelope, FeedbackItem, SessionEnvelope, SessionItem, UserFeedbackItem, CheckInItem, CheckInEnvelope, RawSecurityEnvelope, RawSecurityItem, ProfileItem, ProfileChunkEnvelope, ProfileChunkItem, SpanEnvelope, SpanItem, OtelLogEnvelope, OtelLogItem, } from './envelope'; | ||
export type { ExtendedError } from './error'; | ||
@@ -11,0 +11,0 @@ export type { Event, EventHint, EventType, ErrorEvent, TransactionEvent } from './event'; |
@@ -1,2 +0,3 @@ | ||
export type LogSeverityLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'critical'; | ||
import type { ParameterizedString } from './parameterize'; | ||
export type LogSeverityLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'; | ||
export type SerializedLogAttributeValueType = { | ||
@@ -29,7 +30,7 @@ stringValue: string; | ||
*/ | ||
message: string; | ||
message: ParameterizedString; | ||
/** | ||
* Arbitrary structured data that stores information about the log - e.g., userId: 100. | ||
*/ | ||
attributes?: Record<string, string | number | boolean | Array<string | number | boolean>>; | ||
attributes?: Record<string, unknown>; | ||
/** | ||
@@ -36,0 +37,0 @@ * The severity number - generally higher severity are levels like 'error' and lower are levels like 'debug' |
@@ -5,2 +5,3 @@ import type { CaptureContext } from '../scope'; | ||
import type { Integration } from './integration'; | ||
import type { Log } from './log'; | ||
import type { TracesSamplerSamplingContext } from './samplingcontext'; | ||
@@ -165,2 +166,13 @@ import type { SdkMetadata } from './sdkmetadata'; | ||
enableLogs?: boolean; | ||
/** | ||
* An event-processing callback for logs, guaranteed to be invoked after all other log | ||
* processors. This allows a log to be modified or dropped before it's sent. | ||
* | ||
* Note that you must return a valid log from this callback. If you do not wish to modify the log, simply return | ||
* it at the end. Returning `null` will cause the log to be dropped. | ||
* | ||
* @param log The log generated by the SDK. | ||
* @returns A new log that will be sent | null. | ||
*/ | ||
beforeSendLog?: (log: Log) => Log | null; | ||
}; | ||
@@ -167,0 +179,0 @@ /** |
export type ParameterizedString = string & { | ||
__sentry_template_string__?: string; | ||
__sentry_template_values__?: string[]; | ||
__sentry_template_values__?: unknown[]; | ||
}; | ||
//# sourceMappingURL=parameterize.d.ts.map |
import type { ConsoleLevel } from '../types-hoist'; | ||
/** An error emitted by Sentry SDKs and related utilities. */ | ||
/** | ||
* An error emitted by Sentry SDKs and related utilities. | ||
* @deprecated This class is no longer used and will be removed in a future version. Use `Error` instead. | ||
*/ | ||
export declare class SentryError extends Error { | ||
@@ -4,0 +7,0 @@ message: string; |
@@ -22,3 +22,3 @@ export { applyAggregateErrorsToEvent } from './aggregate-errors'; | ||
export { basename, dirname, isAbsolute, join, normalizePath, relative, resolve } from './path'; | ||
export { makePromiseBuffer } from './promisebuffer'; | ||
export { makePromiseBuffer, SENTRY_BUFFER_FULL_ERROR } from './promisebuffer'; | ||
export type { PromiseBuffer } from './promisebuffer'; | ||
@@ -25,0 +25,0 @@ export { severityLevelFromString } from './severity'; |
@@ -73,2 +73,4 @@ import type { WrappedFunction } from '../types-hoist'; | ||
* Attention: This function keeps circular references in the returned object. | ||
* | ||
* @deprecated This function is no longer used by the SDK and will be removed in a future major version. | ||
*/ | ||
@@ -75,0 +77,0 @@ export declare function dropUndefinedKeys<T>(inputValue: T): T; |
@@ -6,2 +6,3 @@ export interface PromiseBuffer<T> { | ||
} | ||
export declare const SENTRY_BUFFER_FULL_ERROR: unique symbol; | ||
/** | ||
@@ -8,0 +9,0 @@ * Creates an new PromiseBuffer object with the specified limit |
@@ -7,7 +7,17 @@ import type { ParameterizedString } from '../types-hoist'; | ||
* "__sentry_template_values__": ['first', 'second'] | ||
* | ||
* @param strings An array of string values splitted between expressions | ||
* @param values Expressions extracted from template string | ||
* @returns String with template information in __sentry_template_string__ and __sentry_template_values__ properties | ||
* | ||
* @returns A `ParameterizedString` object that can be passed into `captureMessage` or Sentry.logger.X methods. | ||
*/ | ||
export declare function parameterize(strings: TemplateStringsArray, ...values: string[]): ParameterizedString; | ||
export declare function parameterize(strings: TemplateStringsArray, ...values: unknown[]): ParameterizedString; | ||
/** | ||
* Tagged template function which returns parameterized representation of the message. | ||
* | ||
* @param strings An array of string values splitted between expressions | ||
* @param values Expressions extracted from template string | ||
* @returns A `ParameterizedString` object that can be passed into `captureMessage` or Sentry.logger.X methods. | ||
*/ | ||
export declare const fmt: typeof parameterize; | ||
//# sourceMappingURL=parameterize.d.ts.map |
{ | ||
"name": "@sentry/core", | ||
"version": "9.9.0", | ||
"version": "9.10.0", | ||
"description": "Base implementation for all Sentry JavaScript SDKs", | ||
@@ -5,0 +5,0 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", |
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
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
3207498
0.73%38083
0.71%