@sentry/core
Advanced tools
Comparing version 7.109.0 to 7.110.0
@@ -64,2 +64,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function configureScope(callback) { | ||
@@ -78,2 +79,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function addBreadcrumb(breadcrumb, hint) { | ||
@@ -89,3 +91,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, deprecation/deprecation | ||
function setContext(name, context) { | ||
@@ -100,2 +102,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function setExtras(extras) { | ||
@@ -111,2 +114,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function setExtra(key, extra) { | ||
@@ -121,2 +125,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function setTags(tags) { | ||
@@ -135,2 +140,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function setTag(key, value) { | ||
@@ -146,2 +152,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function setUser(user) { | ||
@@ -253,2 +260,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
customSamplingContext, | ||
// eslint-disable-next-line deprecation/deprecation | ||
) { | ||
@@ -255,0 +263,0 @@ // eslint-disable-next-line deprecation/deprecation |
@@ -27,4 +27,13 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/** | ||
* @inheritDoc | ||
* @deprecated The `Hub` class will be removed in version 8 of the SDK in favour of `Scope` and `Client` objects. | ||
* | ||
* If you previously used the `Hub` class directly, replace it with `Scope` and `Client` objects. More information: | ||
* - [Multiple Sentry Instances](https://docs.sentry.io/platforms/javascript/best-practices/multiple-sentry-instances/) | ||
* - [Browser Extensions](https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/) | ||
* | ||
* Some of our APIs are typed with the Hub class instead of the interface (e.g. `getCurrentHub`). Most of them are deprecated | ||
* themselves and will also be removed in version 8. More information: | ||
* - [Migration Guide](https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#deprecate-hub) | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
class Hub { | ||
@@ -452,2 +461,3 @@ /** Is a {@link Layer}[] containing the client and scope */ | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
run(callback) { | ||
@@ -661,2 +671,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function makeMain(hub) { | ||
@@ -678,2 +689,3 @@ const registry = getMainCarrier(); | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function getCurrentHub() { | ||
@@ -705,2 +717,3 @@ // Get main carrier (global for every environment) | ||
// eslint-disable-next-line deprecation/deprecation | ||
function getGlobalHub(registry = getMainCarrier()) { | ||
@@ -727,2 +740,3 @@ // If there's no hub, or its an old API, assign a new one | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function ensureHubOnCarrier(carrier, parent = getGlobalHub()) { | ||
@@ -790,2 +804,3 @@ // If there's no hub on current domain, or it's an old API, assign a new one | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function getHubFromCarrier(carrier) { | ||
@@ -802,2 +817,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function setHubOnCarrier(carrier, hub) { | ||
@@ -804,0 +820,0 @@ if (!carrier) return false; |
@@ -20,2 +20,5 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
// Cast to any so that it can use Node.js timeout | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// SDKs are required to shift the flush interval by random() * rollup_in_seconds. | ||
@@ -34,3 +37,10 @@ // That shift is determined once per startup to create jittering. | ||
this._bucketsTotalWeight = 0; | ||
this._interval = setInterval(() => this._flush(), constants.DEFAULT_FLUSH_INTERVAL); | ||
this._interval = setInterval(() => this._flush(), constants.DEFAULT_FLUSH_INTERVAL) ; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
if (this._interval.unref) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
this._interval.unref(); | ||
} | ||
this._flushShift = Math.floor((Math.random() * constants.DEFAULT_FLUSH_INTERVAL) / 1000); | ||
@@ -47,3 +57,3 @@ this._forceFlush = false; | ||
value, | ||
unit = 'none', | ||
unsanitizedUnit = 'none', | ||
unsanitizedTags = {}, | ||
@@ -53,4 +63,5 @@ maybeFloatTimestamp = utils$1.timestampInSeconds(), | ||
const timestamp = Math.floor(maybeFloatTimestamp); | ||
const name = unsanitizedName.replace(constants.NAME_AND_TAG_KEY_NORMALIZATION_REGEX, '_'); | ||
const name = utils.sanitizeMetricKey(unsanitizedName); | ||
const tags = utils.sanitizeTags(unsanitizedTags); | ||
const unit = utils.sanitizeUnit(unsanitizedUnit ); | ||
@@ -57,0 +68,0 @@ const bucketKey = utils.getBucketKey(metricType, name, unit, tags); |
@@ -32,3 +32,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
value, | ||
unit = 'none', | ||
unsanitizedUnit = 'none', | ||
unsanitizedTags = {}, | ||
@@ -38,4 +38,5 @@ maybeFloatTimestamp = utils$1.timestampInSeconds(), | ||
const timestamp = Math.floor(maybeFloatTimestamp); | ||
const name = unsanitizedName.replace(constants.NAME_AND_TAG_KEY_NORMALIZATION_REGEX, '_'); | ||
const name = utils.sanitizeMetricKey(unsanitizedName); | ||
const tags = utils.sanitizeTags(unsanitizedTags); | ||
const unit = utils.sanitizeUnit(unsanitizedUnit ); | ||
@@ -80,2 +81,3 @@ const bucketKey = utils.getBucketKey(metricType, name, unit, tags); | ||
} | ||
if (this._client.captureAggregateMetrics) { | ||
@@ -86,2 +88,3 @@ // TODO(@anonrig): Use Object.values() when we support ES6+ | ||
} | ||
this._buckets.clear(); | ||
@@ -88,0 +91,0 @@ } |
@@ -9,22 +9,2 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/** | ||
* Normalization regex for metric names and metric tag names. | ||
* | ||
* This enforces that names and tag keys only contain alphanumeric characters, | ||
* underscores, forward slashes, periods, and dashes. | ||
* | ||
* See: https://develop.sentry.dev/sdk/metrics/#normalization | ||
*/ | ||
const NAME_AND_TAG_KEY_NORMALIZATION_REGEX = /[^a-zA-Z0-9_/.-]+/g; | ||
/** | ||
* Normalization regex for metric tag values. | ||
* | ||
* This enforces that values only contain words, digits, or the following | ||
* special characters: _:/@.{}[\]$- | ||
* | ||
* See: https://develop.sentry.dev/sdk/metrics/#normalization | ||
*/ | ||
const TAG_VALUE_NORMALIZATION_REGEX = /[^\w\d\s_:/@.{}[\]$-]+/g; | ||
/** | ||
* This does not match spec in https://develop.sentry.dev/sdk/metrics | ||
@@ -52,5 +32,3 @@ * but was chosen to optimize for the most common case in browser environments. | ||
exports.MAX_WEIGHT = MAX_WEIGHT; | ||
exports.NAME_AND_TAG_KEY_NORMALIZATION_REGEX = NAME_AND_TAG_KEY_NORMALIZATION_REGEX; | ||
exports.SET_METRIC_TYPE = SET_METRIC_TYPE; | ||
exports.TAG_VALUE_NORMALIZATION_REGEX = TAG_VALUE_NORMALIZATION_REGEX; | ||
//# sourceMappingURL=constants.js.map |
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const utils = require('@sentry/utils'); | ||
const constants = require('./constants.js'); | ||
@@ -57,2 +56,39 @@ /** | ||
/** Sanitizes units */ | ||
function sanitizeUnit(unit) { | ||
return unit.replace(/[^\w]+/gi, '_'); | ||
} | ||
/** Sanitizes metric keys */ | ||
function sanitizeMetricKey(key) { | ||
return key.replace(/[^\w\-.]+/gi, '_'); | ||
} | ||
function sanitizeTagKey(key) { | ||
return key.replace(/[^\w\-./]+/gi, ''); | ||
} | ||
const tagValueReplacements = [ | ||
['\n', '\\n'], | ||
['\r', '\\r'], | ||
['\t', '\\t'], | ||
['\\', '\\\\'], | ||
['|', '\\u{7c}'], | ||
[',', '\\u{2c}'], | ||
]; | ||
function getCharOrReplacement(input) { | ||
for (const [search, replacement] of tagValueReplacements) { | ||
if (input === search) { | ||
return replacement; | ||
} | ||
} | ||
return input; | ||
} | ||
function sanitizeTagValue(value) { | ||
return [...value].reduce((acc, char) => acc + getCharOrReplacement(char), ''); | ||
} | ||
/** | ||
@@ -65,4 +101,4 @@ * Sanitizes tags. | ||
if (Object.prototype.hasOwnProperty.call(unsanitizedTags, key)) { | ||
const sanitizedKey = key.replace(constants.NAME_AND_TAG_KEY_NORMALIZATION_REGEX, '_'); | ||
tags[sanitizedKey] = String(unsanitizedTags[key]).replace(constants.TAG_VALUE_NORMALIZATION_REGEX, ''); | ||
const sanitizedKey = sanitizeTagKey(key); | ||
tags[sanitizedKey] = sanitizeTagValue(String(unsanitizedTags[key])); | ||
} | ||
@@ -74,5 +110,7 @@ } | ||
exports.getBucketKey = getBucketKey; | ||
exports.sanitizeMetricKey = sanitizeMetricKey; | ||
exports.sanitizeTags = sanitizeTags; | ||
exports.sanitizeUnit = sanitizeUnit; | ||
exports.serializeMetricBuckets = serializeMetricBuckets; | ||
exports.simpleHash = simpleHash; | ||
//# sourceMappingURL=utils.js.map |
@@ -11,2 +11,5 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
// Cast to any so that it can use Node.js timeout | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
constructor(client, attrs) { | ||
@@ -18,4 +21,9 @@ this._client = client; | ||
// Call to setInterval, so that flush is called every 60 seconds | ||
// Call to setInterval, so that flush is called every 60 seconds. | ||
this._intervalId = setInterval(() => this.flush(), this.flushTimeout * 1000); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
if (this._intervalId.unref) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
this._intervalId.unref(); | ||
} | ||
this._sessionAttrs = attrs; | ||
@@ -22,0 +30,0 @@ } |
@@ -13,2 +13,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/** Returns all trace headers that are currently on the top scope. */ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function traceHeaders() { | ||
@@ -43,2 +44,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
function _startTransaction( | ||
// eslint-disable-next-line deprecation/deprecation | ||
@@ -92,2 +94,3 @@ transactionContext, | ||
function startIdleTransaction( | ||
// eslint-disable-next-line deprecation/deprecation | ||
hub, | ||
@@ -94,0 +97,0 @@ transactionContext, |
@@ -88,2 +88,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
transactionContext, | ||
// eslint-disable-next-line deprecation/deprecation | ||
_idleHub, | ||
@@ -90,0 +91,0 @@ /** |
@@ -123,3 +123,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
} | ||
if (spanContext.exclusiveTime) { | ||
if (spanContext.exclusiveTime !== undefined) { | ||
this._exclusiveTime = spanContext.exclusiveTime; | ||
@@ -126,0 +126,0 @@ } |
@@ -276,2 +276,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
function createChildSpanOrTransaction( | ||
// eslint-disable-next-line deprecation/deprecation | ||
hub$1, | ||
@@ -278,0 +279,0 @@ { |
@@ -18,2 +18,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
@@ -31,2 +32,3 @@ // DO NOT yet remove this property, it is used in a hack for v7 backwards compatibility. | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
constructor(transactionContext, hub$1) { | ||
@@ -234,2 +236,3 @@ super(transactionContext); | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
setHub(hub) { | ||
@@ -236,0 +239,0 @@ this._hub = hub; |
@@ -11,2 +11,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function getActiveTransaction(maybeHub) { | ||
@@ -13,0 +14,0 @@ // eslint-disable-next-line deprecation/deprecation |
@@ -29,6 +29,6 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
utils.forEachEnvelopeItem(envelope, (item, type) => { | ||
const envelopeItemDataCategory = utils.envelopeItemTypeToDataCategory(type); | ||
if (utils.isRateLimited(rateLimits, envelopeItemDataCategory)) { | ||
const dataCategory = utils.envelopeItemTypeToDataCategory(type); | ||
if (utils.isRateLimited(rateLimits, dataCategory)) { | ||
const event = getEventForEnvelopeItem(item, type); | ||
options.recordDroppedEvent('ratelimit_backoff', envelopeItemDataCategory, event); | ||
options.recordDroppedEvent('ratelimit_backoff', dataCategory, event); | ||
} else { | ||
@@ -35,0 +35,0 @@ filteredEnvelopeItems.push(item); |
@@ -9,2 +9,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function isSentryRequestUrl(url, hubOrClient) { | ||
@@ -38,2 +39,3 @@ const client = | ||
// eslint-disable-next-line deprecation/deprecation | ||
function isHub(hubOrClient) { | ||
@@ -40,0 +42,0 @@ // eslint-disable-next-line deprecation/deprecation |
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const SDK_VERSION = '7.109.0'; | ||
const SDK_VERSION = '7.110.0'; | ||
exports.SDK_VERSION = SDK_VERSION; | ||
//# sourceMappingURL=version.js.map |
@@ -62,2 +62,3 @@ import { logger, uuid4, timestampInSeconds, isThenable, GLOBAL_OBJ } from '@sentry/utils'; | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function configureScope(callback) { | ||
@@ -76,2 +77,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function addBreadcrumb(breadcrumb, hint) { | ||
@@ -87,3 +89,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, deprecation/deprecation | ||
function setContext(name, context) { | ||
@@ -98,2 +100,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function setExtras(extras) { | ||
@@ -109,2 +112,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function setExtra(key, extra) { | ||
@@ -119,2 +123,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function setTags(tags) { | ||
@@ -133,2 +138,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function setTag(key, value) { | ||
@@ -144,2 +150,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function setUser(user) { | ||
@@ -251,2 +258,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
customSamplingContext, | ||
// eslint-disable-next-line deprecation/deprecation | ||
) { | ||
@@ -253,0 +261,0 @@ // eslint-disable-next-line deprecation/deprecation |
@@ -25,4 +25,13 @@ import { isThenable, uuid4, dateTimestampInSeconds, consoleSandbox, logger, GLOBAL_OBJ, getGlobalSingleton } from '@sentry/utils'; | ||
/** | ||
* @inheritDoc | ||
* @deprecated The `Hub` class will be removed in version 8 of the SDK in favour of `Scope` and `Client` objects. | ||
* | ||
* If you previously used the `Hub` class directly, replace it with `Scope` and `Client` objects. More information: | ||
* - [Multiple Sentry Instances](https://docs.sentry.io/platforms/javascript/best-practices/multiple-sentry-instances/) | ||
* - [Browser Extensions](https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/) | ||
* | ||
* Some of our APIs are typed with the Hub class instead of the interface (e.g. `getCurrentHub`). Most of them are deprecated | ||
* themselves and will also be removed in version 8. More information: | ||
* - [Migration Guide](https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#deprecate-hub) | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
class Hub { | ||
@@ -450,2 +459,3 @@ /** Is a {@link Layer}[] containing the client and scope */ | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
run(callback) { | ||
@@ -659,2 +669,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function makeMain(hub) { | ||
@@ -676,2 +687,3 @@ const registry = getMainCarrier(); | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function getCurrentHub() { | ||
@@ -703,2 +715,3 @@ // Get main carrier (global for every environment) | ||
// eslint-disable-next-line deprecation/deprecation | ||
function getGlobalHub(registry = getMainCarrier()) { | ||
@@ -725,2 +738,3 @@ // If there's no hub, or its an old API, assign a new one | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function ensureHubOnCarrier(carrier, parent = getGlobalHub()) { | ||
@@ -788,2 +802,3 @@ // If there's no hub on current domain, or it's an old API, assign a new one | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function getHubFromCarrier(carrier) { | ||
@@ -800,2 +815,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function setHubOnCarrier(carrier, hub) { | ||
@@ -802,0 +818,0 @@ if (!carrier) return false; |
import { timestampInSeconds } from '@sentry/utils'; | ||
import { DEFAULT_FLUSH_INTERVAL, NAME_AND_TAG_KEY_NORMALIZATION_REGEX, SET_METRIC_TYPE, MAX_WEIGHT } from './constants.js'; | ||
import { DEFAULT_FLUSH_INTERVAL, SET_METRIC_TYPE, MAX_WEIGHT } from './constants.js'; | ||
import { METRIC_MAP } from './instance.js'; | ||
import { updateMetricSummaryOnActiveSpan } from './metric-summary.js'; | ||
import { sanitizeTags, getBucketKey } from './utils.js'; | ||
import { sanitizeMetricKey, sanitizeTags, sanitizeUnit, getBucketKey } from './utils.js'; | ||
@@ -18,2 +18,5 @@ /** | ||
// Cast to any so that it can use Node.js timeout | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// SDKs are required to shift the flush interval by random() * rollup_in_seconds. | ||
@@ -32,3 +35,10 @@ // That shift is determined once per startup to create jittering. | ||
this._bucketsTotalWeight = 0; | ||
this._interval = setInterval(() => this._flush(), DEFAULT_FLUSH_INTERVAL); | ||
this._interval = setInterval(() => this._flush(), DEFAULT_FLUSH_INTERVAL) ; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
if (this._interval.unref) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
this._interval.unref(); | ||
} | ||
this._flushShift = Math.floor((Math.random() * DEFAULT_FLUSH_INTERVAL) / 1000); | ||
@@ -45,3 +55,3 @@ this._forceFlush = false; | ||
value, | ||
unit = 'none', | ||
unsanitizedUnit = 'none', | ||
unsanitizedTags = {}, | ||
@@ -51,4 +61,5 @@ maybeFloatTimestamp = timestampInSeconds(), | ||
const timestamp = Math.floor(maybeFloatTimestamp); | ||
const name = unsanitizedName.replace(NAME_AND_TAG_KEY_NORMALIZATION_REGEX, '_'); | ||
const name = sanitizeMetricKey(unsanitizedName); | ||
const tags = sanitizeTags(unsanitizedTags); | ||
const unit = sanitizeUnit(unsanitizedUnit ); | ||
@@ -55,0 +66,0 @@ const bucketKey = getBucketKey(metricType, name, unit, tags); |
import { timestampInSeconds } from '@sentry/utils'; | ||
import { DEFAULT_BROWSER_FLUSH_INTERVAL, NAME_AND_TAG_KEY_NORMALIZATION_REGEX, SET_METRIC_TYPE } from './constants.js'; | ||
import { DEFAULT_BROWSER_FLUSH_INTERVAL, SET_METRIC_TYPE } from './constants.js'; | ||
import { METRIC_MAP } from './instance.js'; | ||
import { updateMetricSummaryOnActiveSpan } from './metric-summary.js'; | ||
import { sanitizeTags, getBucketKey } from './utils.js'; | ||
import { sanitizeMetricKey, sanitizeTags, sanitizeUnit, getBucketKey } from './utils.js'; | ||
@@ -30,3 +30,3 @@ /** | ||
value, | ||
unit = 'none', | ||
unsanitizedUnit = 'none', | ||
unsanitizedTags = {}, | ||
@@ -36,4 +36,5 @@ maybeFloatTimestamp = timestampInSeconds(), | ||
const timestamp = Math.floor(maybeFloatTimestamp); | ||
const name = unsanitizedName.replace(NAME_AND_TAG_KEY_NORMALIZATION_REGEX, '_'); | ||
const name = sanitizeMetricKey(unsanitizedName); | ||
const tags = sanitizeTags(unsanitizedTags); | ||
const unit = sanitizeUnit(unsanitizedUnit ); | ||
@@ -78,2 +79,3 @@ const bucketKey = getBucketKey(metricType, name, unit, tags); | ||
} | ||
if (this._client.captureAggregateMetrics) { | ||
@@ -84,2 +86,3 @@ // TODO(@anonrig): Use Object.values() when we support ES6+ | ||
} | ||
this._buckets.clear(); | ||
@@ -86,0 +89,0 @@ } |
@@ -7,22 +7,2 @@ const COUNTER_METRIC_TYPE = 'c' ; | ||
/** | ||
* Normalization regex for metric names and metric tag names. | ||
* | ||
* This enforces that names and tag keys only contain alphanumeric characters, | ||
* underscores, forward slashes, periods, and dashes. | ||
* | ||
* See: https://develop.sentry.dev/sdk/metrics/#normalization | ||
*/ | ||
const NAME_AND_TAG_KEY_NORMALIZATION_REGEX = /[^a-zA-Z0-9_/.-]+/g; | ||
/** | ||
* Normalization regex for metric tag values. | ||
* | ||
* This enforces that values only contain words, digits, or the following | ||
* special characters: _:/@.{}[\]$- | ||
* | ||
* See: https://develop.sentry.dev/sdk/metrics/#normalization | ||
*/ | ||
const TAG_VALUE_NORMALIZATION_REGEX = /[^\w\d\s_:/@.{}[\]$-]+/g; | ||
/** | ||
* This does not match spec in https://develop.sentry.dev/sdk/metrics | ||
@@ -44,3 +24,3 @@ * but was chosen to optimize for the most common case in browser environments. | ||
export { COUNTER_METRIC_TYPE, DEFAULT_BROWSER_FLUSH_INTERVAL, DEFAULT_FLUSH_INTERVAL, DISTRIBUTION_METRIC_TYPE, GAUGE_METRIC_TYPE, MAX_WEIGHT, NAME_AND_TAG_KEY_NORMALIZATION_REGEX, SET_METRIC_TYPE, TAG_VALUE_NORMALIZATION_REGEX }; | ||
export { COUNTER_METRIC_TYPE, DEFAULT_BROWSER_FLUSH_INTERVAL, DEFAULT_FLUSH_INTERVAL, DISTRIBUTION_METRIC_TYPE, GAUGE_METRIC_TYPE, MAX_WEIGHT, SET_METRIC_TYPE }; | ||
//# sourceMappingURL=constants.js.map |
import { dropUndefinedKeys } from '@sentry/utils'; | ||
import { NAME_AND_TAG_KEY_NORMALIZATION_REGEX, TAG_VALUE_NORMALIZATION_REGEX } from './constants.js'; | ||
@@ -55,2 +54,39 @@ /** | ||
/** Sanitizes units */ | ||
function sanitizeUnit(unit) { | ||
return unit.replace(/[^\w]+/gi, '_'); | ||
} | ||
/** Sanitizes metric keys */ | ||
function sanitizeMetricKey(key) { | ||
return key.replace(/[^\w\-.]+/gi, '_'); | ||
} | ||
function sanitizeTagKey(key) { | ||
return key.replace(/[^\w\-./]+/gi, ''); | ||
} | ||
const tagValueReplacements = [ | ||
['\n', '\\n'], | ||
['\r', '\\r'], | ||
['\t', '\\t'], | ||
['\\', '\\\\'], | ||
['|', '\\u{7c}'], | ||
[',', '\\u{2c}'], | ||
]; | ||
function getCharOrReplacement(input) { | ||
for (const [search, replacement] of tagValueReplacements) { | ||
if (input === search) { | ||
return replacement; | ||
} | ||
} | ||
return input; | ||
} | ||
function sanitizeTagValue(value) { | ||
return [...value].reduce((acc, char) => acc + getCharOrReplacement(char), ''); | ||
} | ||
/** | ||
@@ -63,4 +99,4 @@ * Sanitizes tags. | ||
if (Object.prototype.hasOwnProperty.call(unsanitizedTags, key)) { | ||
const sanitizedKey = key.replace(NAME_AND_TAG_KEY_NORMALIZATION_REGEX, '_'); | ||
tags[sanitizedKey] = String(unsanitizedTags[key]).replace(TAG_VALUE_NORMALIZATION_REGEX, ''); | ||
const sanitizedKey = sanitizeTagKey(key); | ||
tags[sanitizedKey] = sanitizeTagValue(String(unsanitizedTags[key])); | ||
} | ||
@@ -71,3 +107,3 @@ } | ||
export { getBucketKey, sanitizeTags, serializeMetricBuckets, simpleHash }; | ||
export { getBucketKey, sanitizeMetricKey, sanitizeTags, sanitizeUnit, serializeMetricBuckets, simpleHash }; | ||
//# sourceMappingURL=utils.js.map |
@@ -9,2 +9,5 @@ import { dropUndefinedKeys } from '@sentry/utils'; | ||
// Cast to any so that it can use Node.js timeout | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
constructor(client, attrs) { | ||
@@ -16,4 +19,9 @@ this._client = client; | ||
// Call to setInterval, so that flush is called every 60 seconds | ||
// Call to setInterval, so that flush is called every 60 seconds. | ||
this._intervalId = setInterval(() => this.flush(), this.flushTimeout * 1000); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
if (this._intervalId.unref) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
this._intervalId.unref(); | ||
} | ||
this._sessionAttrs = attrs; | ||
@@ -20,0 +28,0 @@ } |
@@ -11,2 +11,3 @@ import { logger } from '@sentry/utils'; | ||
/** Returns all trace headers that are currently on the top scope. */ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function traceHeaders() { | ||
@@ -41,2 +42,3 @@ // eslint-disable-next-line deprecation/deprecation | ||
function _startTransaction( | ||
// eslint-disable-next-line deprecation/deprecation | ||
@@ -90,2 +92,3 @@ transactionContext, | ||
function startIdleTransaction( | ||
// eslint-disable-next-line deprecation/deprecation | ||
hub, | ||
@@ -92,0 +95,0 @@ transactionContext, |
@@ -86,2 +86,3 @@ import { logger, timestampInSeconds } from '@sentry/utils'; | ||
transactionContext, | ||
// eslint-disable-next-line deprecation/deprecation | ||
_idleHub, | ||
@@ -88,0 +89,0 @@ /** |
@@ -121,3 +121,3 @@ import { uuid4, timestampInSeconds, logger, dropUndefinedKeys } from '@sentry/utils'; | ||
} | ||
if (spanContext.exclusiveTime) { | ||
if (spanContext.exclusiveTime !== undefined) { | ||
this._exclusiveTime = spanContext.exclusiveTime; | ||
@@ -124,0 +124,0 @@ } |
@@ -274,2 +274,3 @@ import { tracingContextFromHeaders, logger, dropUndefinedKeys, addNonEnumerableProperty } from '@sentry/utils'; | ||
function createChildSpanOrTransaction( | ||
// eslint-disable-next-line deprecation/deprecation | ||
hub, | ||
@@ -276,0 +277,0 @@ { |
@@ -16,2 +16,3 @@ import { dropUndefinedKeys, logger } from '@sentry/utils'; | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
@@ -29,2 +30,3 @@ // DO NOT yet remove this property, it is used in a hack for v7 backwards compatibility. | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
constructor(transactionContext, hub) { | ||
@@ -232,2 +234,3 @@ super(transactionContext); | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
setHub(hub) { | ||
@@ -234,0 +237,0 @@ this._hub = hub; |
@@ -10,2 +10,3 @@ import { extractTraceparentData as extractTraceparentData$1 } from '@sentry/utils'; | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function getActiveTransaction(maybeHub) { | ||
@@ -12,0 +13,0 @@ // eslint-disable-next-line deprecation/deprecation |
@@ -27,6 +27,6 @@ import { makePromiseBuffer, forEachEnvelopeItem, envelopeItemTypeToDataCategory, isRateLimited, resolvedSyncPromise, createEnvelope, SentryError, logger, serializeEnvelope, updateRateLimits } from '@sentry/utils'; | ||
forEachEnvelopeItem(envelope, (item, type) => { | ||
const envelopeItemDataCategory = envelopeItemTypeToDataCategory(type); | ||
if (isRateLimited(rateLimits, envelopeItemDataCategory)) { | ||
const dataCategory = envelopeItemTypeToDataCategory(type); | ||
if (isRateLimited(rateLimits, dataCategory)) { | ||
const event = getEventForEnvelopeItem(item, type); | ||
options.recordDroppedEvent('ratelimit_backoff', envelopeItemDataCategory, event); | ||
options.recordDroppedEvent('ratelimit_backoff', dataCategory, event); | ||
} else { | ||
@@ -33,0 +33,0 @@ filteredEnvelopeItems.push(item); |
@@ -7,2 +7,3 @@ /** | ||
*/ | ||
// eslint-disable-next-line deprecation/deprecation | ||
function isSentryRequestUrl(url, hubOrClient) { | ||
@@ -36,2 +37,3 @@ const client = | ||
// eslint-disable-next-line deprecation/deprecation | ||
function isHub(hubOrClient) { | ||
@@ -38,0 +40,0 @@ // eslint-disable-next-line deprecation/deprecation |
@@ -1,4 +0,4 @@ | ||
const SDK_VERSION = '7.109.0'; | ||
const SDK_VERSION = '7.110.0'; | ||
export { SDK_VERSION }; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@sentry/core", | ||
"version": "7.109.0", | ||
"version": "7.110.0", | ||
"description": "Base implementation for all Sentry JavaScript SDKs", | ||
@@ -32,4 +32,4 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@sentry/types": "7.109.0", | ||
"@sentry/utils": "7.109.0" | ||
"@sentry/types": "7.110.0", | ||
"@sentry/utils": "7.110.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "madge": { |
@@ -58,3 +58,11 @@ import { Breadcrumb, BreadcrumbHint, Client, CustomSamplingContext, Event, EventHint, Extra, Extras, Hub as HubInterface, Integration, IntegrationClass, Primitive, Session, SessionContext, Severity, SeverityLevel, Transaction, TransactionContext, User } from '@sentry/types'; | ||
/** | ||
* @inheritDoc | ||
* @deprecated The `Hub` class will be removed in version 8 of the SDK in favour of `Scope` and `Client` objects. | ||
* | ||
* If you previously used the `Hub` class directly, replace it with `Scope` and `Client` objects. More information: | ||
* - [Multiple Sentry Instances](https://docs.sentry.io/platforms/javascript/best-practices/multiple-sentry-instances/) | ||
* - [Browser Extensions](https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/) | ||
* | ||
* Some of our APIs are typed with the Hub class instead of the interface (e.g. `getCurrentHub`). Most of them are deprecated | ||
* themselves and will also be removed in version 8. More information: | ||
* - [Migration Guide](https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#deprecate-hub) | ||
*/ | ||
@@ -61,0 +69,0 @@ export declare class Hub implements HubInterface { |
@@ -33,3 +33,3 @@ export { ClientClass } from './sdk'; | ||
export { parameterize } from './utils/parameterize'; | ||
export { spanToTraceHeader, spanToJSON, spanIsSampled, spanToTraceContext, } from './utils/spanUtils'; | ||
export { spanToTraceHeader, spanToJSON, spanIsSampled, spanToTraceContext } from './utils/spanUtils'; | ||
export { getRootSpan } from './utils/getRootSpan'; | ||
@@ -36,0 +36,0 @@ export { applySdkMetadata } from './utils/sdkMetadata'; |
@@ -17,3 +17,3 @@ import { Client, ClientOptions, MeasurementUnit, MetricsAggregator as MetricsAggregatorBase, Primitive } from '@sentry/types'; | ||
*/ | ||
add(metricType: MetricType, unsanitizedName: string, value: number | string, unit?: MeasurementUnit, unsanitizedTags?: Record<string, Primitive>, maybeFloatTimestamp?: number): void; | ||
add(metricType: MetricType, unsanitizedName: string, value: number | string, unsanitizedUnit?: MeasurementUnit, unsanitizedTags?: Record<string, Primitive>, maybeFloatTimestamp?: number): void; | ||
/** | ||
@@ -20,0 +20,0 @@ * Flushes the current metrics to the transport via the transport. |
@@ -17,3 +17,3 @@ import { Client, ClientOptions, MeasurementUnit, MetricsAggregator, Primitive } from '@sentry/types'; | ||
*/ | ||
add(metricType: MetricType, unsanitizedName: string, value: number | string, unit?: MeasurementUnit | undefined, unsanitizedTags?: Record<string, Primitive> | undefined, maybeFloatTimestamp?: number | undefined): void; | ||
add(metricType: MetricType, unsanitizedName: string, value: number | string, unsanitizedUnit?: MeasurementUnit | undefined, unsanitizedTags?: Record<string, Primitive> | undefined, maybeFloatTimestamp?: number | undefined): void; | ||
/** | ||
@@ -20,0 +20,0 @@ * @inheritDoc |
@@ -6,20 +6,2 @@ export declare const COUNTER_METRIC_TYPE: "c"; | ||
/** | ||
* Normalization regex for metric names and metric tag names. | ||
* | ||
* This enforces that names and tag keys only contain alphanumeric characters, | ||
* underscores, forward slashes, periods, and dashes. | ||
* | ||
* See: https://develop.sentry.dev/sdk/metrics/#normalization | ||
*/ | ||
export declare const NAME_AND_TAG_KEY_NORMALIZATION_REGEX: RegExp; | ||
/** | ||
* Normalization regex for metric tag values. | ||
* | ||
* This enforces that values only contain words, digits, or the following | ||
* special characters: _:/@.{}[\]$- | ||
* | ||
* See: https://develop.sentry.dev/sdk/metrics/#normalization | ||
*/ | ||
export declare const TAG_VALUE_NORMALIZATION_REGEX: RegExp; | ||
/** | ||
* This does not match spec in https://develop.sentry.dev/sdk/metrics | ||
@@ -26,0 +8,0 @@ * but was chosen to optimize for the most common case in browser environments. |
@@ -25,2 +25,6 @@ import { MeasurementUnit, MetricBucketItem, Primitive } from '@sentry/types'; | ||
export declare function serializeMetricBuckets(metricBucketItems: MetricBucketItem[]): string; | ||
/** Sanitizes units */ | ||
export declare function sanitizeUnit(unit: string): string; | ||
/** Sanitizes metric keys */ | ||
export declare function sanitizeMetricKey(key: string): string; | ||
/** | ||
@@ -27,0 +31,0 @@ * Sanitizes tags. |
@@ -1,2 +0,2 @@ | ||
export declare const SDK_VERSION = "7.109.0"; | ||
export declare const SDK_VERSION = "7.110.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -58,3 +58,11 @@ import type { Breadcrumb, BreadcrumbHint, Client, CustomSamplingContext, Event, EventHint, Extra, Extras, Hub as HubInterface, Integration, IntegrationClass, Primitive, Session, SessionContext, Severity, SeverityLevel, Transaction, TransactionContext, User } from '@sentry/types'; | ||
/** | ||
* @inheritDoc | ||
* @deprecated The `Hub` class will be removed in version 8 of the SDK in favour of `Scope` and `Client` objects. | ||
* | ||
* If you previously used the `Hub` class directly, replace it with `Scope` and `Client` objects. More information: | ||
* - [Multiple Sentry Instances](https://docs.sentry.io/platforms/javascript/best-practices/multiple-sentry-instances/) | ||
* - [Browser Extensions](https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/) | ||
* | ||
* Some of our APIs are typed with the Hub class instead of the interface (e.g. `getCurrentHub`). Most of them are deprecated | ||
* themselves and will also be removed in version 8. More information: | ||
* - [Migration Guide](https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#deprecate-hub) | ||
*/ | ||
@@ -61,0 +69,0 @@ export declare class Hub implements HubInterface { |
@@ -33,3 +33,3 @@ export type { ClientClass } from './sdk'; | ||
export { parameterize } from './utils/parameterize'; | ||
export { spanToTraceHeader, spanToJSON, spanIsSampled, spanToTraceContext, } from './utils/spanUtils'; | ||
export { spanToTraceHeader, spanToJSON, spanIsSampled, spanToTraceContext } from './utils/spanUtils'; | ||
export { getRootSpan } from './utils/getRootSpan'; | ||
@@ -36,0 +36,0 @@ export { applySdkMetadata } from './utils/sdkMetadata'; |
@@ -17,3 +17,3 @@ import type { Client, ClientOptions, MeasurementUnit, MetricsAggregator as MetricsAggregatorBase, Primitive } from '@sentry/types'; | ||
*/ | ||
add(metricType: MetricType, unsanitizedName: string, value: number | string, unit?: MeasurementUnit, unsanitizedTags?: Record<string, Primitive>, maybeFloatTimestamp?: number): void; | ||
add(metricType: MetricType, unsanitizedName: string, value: number | string, unsanitizedUnit?: MeasurementUnit, unsanitizedTags?: Record<string, Primitive>, maybeFloatTimestamp?: number): void; | ||
/** | ||
@@ -20,0 +20,0 @@ * Flushes the current metrics to the transport via the transport. |
@@ -17,3 +17,3 @@ import type { Client, ClientOptions, MeasurementUnit, MetricsAggregator, Primitive } from '@sentry/types'; | ||
*/ | ||
add(metricType: MetricType, unsanitizedName: string, value: number | string, unit?: MeasurementUnit | undefined, unsanitizedTags?: Record<string, Primitive> | undefined, maybeFloatTimestamp?: number | undefined): void; | ||
add(metricType: MetricType, unsanitizedName: string, value: number | string, unsanitizedUnit?: MeasurementUnit | undefined, unsanitizedTags?: Record<string, Primitive> | undefined, maybeFloatTimestamp?: number | undefined): void; | ||
/** | ||
@@ -20,0 +20,0 @@ * @inheritDoc |
@@ -6,20 +6,2 @@ export declare const COUNTER_METRIC_TYPE: "c"; | ||
/** | ||
* Normalization regex for metric names and metric tag names. | ||
* | ||
* This enforces that names and tag keys only contain alphanumeric characters, | ||
* underscores, forward slashes, periods, and dashes. | ||
* | ||
* See: https://develop.sentry.dev/sdk/metrics/#normalization | ||
*/ | ||
export declare const NAME_AND_TAG_KEY_NORMALIZATION_REGEX: RegExp; | ||
/** | ||
* Normalization regex for metric tag values. | ||
* | ||
* This enforces that values only contain words, digits, or the following | ||
* special characters: _:/@.{}[\]$- | ||
* | ||
* See: https://develop.sentry.dev/sdk/metrics/#normalization | ||
*/ | ||
export declare const TAG_VALUE_NORMALIZATION_REGEX: RegExp; | ||
/** | ||
* This does not match spec in https://develop.sentry.dev/sdk/metrics | ||
@@ -26,0 +8,0 @@ * but was chosen to optimize for the most common case in browser environments. |
@@ -25,2 +25,6 @@ import type { MeasurementUnit, MetricBucketItem, Primitive } from '@sentry/types'; | ||
export declare function serializeMetricBuckets(metricBucketItems: MetricBucketItem[]): string; | ||
/** Sanitizes units */ | ||
export declare function sanitizeUnit(unit: string): string; | ||
/** Sanitizes metric keys */ | ||
export declare function sanitizeMetricKey(key: string): string; | ||
/** | ||
@@ -27,0 +31,0 @@ * Sanitizes tags. |
@@ -1,2 +0,2 @@ | ||
export declare const SDK_VERSION = "7.109.0"; | ||
export declare const SDK_VERSION = "7.110.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
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
1915399
21973
+ Added@sentry/types@7.110.0(transitive)
+ Added@sentry/utils@7.110.0(transitive)
- Removed@sentry/types@7.109.0(transitive)
- Removed@sentry/utils@7.109.0(transitive)
Updated@sentry/types@7.110.0
Updated@sentry/utils@7.110.0