Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sentry/apm

Package Overview
Dependencies
Maintainers
12
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/apm - npm Package Compare versions

Comparing version 5.10.0 to 5.10.1

22

dist/integrations/tracing.d.ts

@@ -56,2 +56,7 @@ import { EventProcessor, Hub, Integration, Span, SpanContext, SpanStatus } from '@sentry/types';

}
/** JSDoc */
interface Activity {
name: string;
span?: Span;
}
/**

@@ -71,7 +76,2 @@ * Tracing Integration

/**
* If we have an xhr we need to store the url in the instance.
*
*/
private _xhrUrl?;
/**
* Is Tracing enabled, this will be determined once per pageload.

@@ -88,3 +88,5 @@ */

private static _currentIndex;
private static readonly _activities;
static readonly _activities: {
[key: number]: Activity;
};
private static _debounce;

@@ -102,10 +104,2 @@ /**

/**
* JSDoc
*/
private _traceXHR;
/**
* JSDoc
*/
private _traceFetch;
/**
* Is tracing enabled

@@ -112,0 +106,0 @@ */

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

var origins = (_options && _options.tracingOrigins) || defaultTracingOrigins;
return origins.some(function (origin) { return utils_1.isMatchingPattern(url, origin); });
return (origins.some(function (origin) { return utils_1.isMatchingPattern(url, origin); }) &&
!utils_1.isMatchingPattern(url, 'sentry_key'));
},

@@ -54,3 +55,2 @@ startTransactionOnLocationChange: true,

});
this._traceXHR(getCurrentHub);
}

@@ -63,3 +63,2 @@ // tslint:disable-next-line: no-non-null-assertion

});
this._traceFetch(getCurrentHub);
}

@@ -82,111 +81,2 @@ // tslint:disable-next-line: no-non-null-assertion

/**
* JSDoc
*/
Tracing.prototype._traceXHR = function (getCurrentHub) {
if (!('XMLHttpRequest' in utils_1.getGlobalObject())) {
return;
}
var xhrproto = XMLHttpRequest.prototype;
utils_1.fill(xhrproto, 'open', function (originalOpen) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// @ts-ignore
var self = getCurrentHub().getIntegration(Tracing);
if (self) {
self._xhrUrl = args[1];
}
// tslint:disable-next-line: no-unsafe-any
return originalOpen.apply(this, args);
};
});
utils_1.fill(xhrproto, 'send', function (originalSend) {
return function () {
var _this = this;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// @ts-ignore
var self = getCurrentHub().getIntegration(Tracing);
// tslint:disable-next-line: no-non-null-assertion
if (self && self._xhrUrl && self._options.tracingOrigins) {
var url_1 = self._xhrUrl;
var headers_1 = getCurrentHub().traceHeaders();
// tslint:disable-next-line: prefer-for-of no-non-null-assertion
var isWhitelisted = self._options.tracingOrigins.some(function (origin) {
return utils_1.isMatchingPattern(url_1, origin);
});
if (utils_1.isMatchingPattern(url_1, 'sentry_key')) {
// If sentry_key is in the url, it's an internal store request to sentry
// we do not want to add the trace header to store requests
isWhitelisted = false;
}
if (isWhitelisted && this.setRequestHeader) {
Object.keys(headers_1).forEach(function (key) {
_this.setRequestHeader(key, headers_1[key]);
});
}
}
// tslint:disable-next-line: no-unsafe-any
return originalSend.apply(this, args);
};
});
};
/**
* JSDoc
*/
Tracing.prototype._traceFetch = function (getCurrentHub) {
if (!utils_1.supportsNativeFetch()) {
return;
}
// tslint:disable: only-arrow-functions
utils_1.fill(utils_1.getGlobalObject(), 'fetch', function (originalFetch) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// @ts-ignore
var hub = getCurrentHub();
var self = hub.getIntegration(Tracing);
// tslint:disable-next-line: no-non-null-assertion
if (self && self._options.tracingOrigins) {
var url_2 = args[0];
var options = (args[1] = args[1] || {});
var isWhitelisted_1 = false;
// tslint:disable-next-line: no-non-null-assertion
self._options.tracingOrigins.forEach(function (whiteListUrl) {
if (!isWhitelisted_1) {
isWhitelisted_1 = utils_1.isMatchingPattern(url_2, whiteListUrl);
}
});
if (utils_1.isMatchingPattern(url_2, 'sentry_key')) {
// If sentry_key is in the url, it's an internal store request to sentry
// we do not want to add the trace header to store requests
isWhitelisted_1 = false;
}
if (isWhitelisted_1) {
if (options.headers) {
if (Array.isArray(options.headers)) {
options.headers = tslib_1.__spread(options.headers, Object.entries(hub.traceHeaders()));
}
else {
options.headers = tslib_1.__assign({}, options.headers, hub.traceHeaders());
}
}
else {
options.headers = hub.traceHeaders();
}
}
}
// tslint:disable-next-line: no-unsafe-any
return originalFetch.apply(utils_1.getGlobalObject(), args);
};
});
// tslint:enable: only-arrow-functions
};
/**
* Is tracing enabled

@@ -371,2 +261,10 @@ */

});
// Adding the trace header to the span
var activity = Tracing._activities[handlerData.xhr.__sentry_xhr_activity_id__];
if (activity) {
var span = activity.span;
if (span && handlerData.xhr.setRequestHeader) {
handlerData.xhr.setRequestHeader('sentry-trace', span.toTraceparent());
}
}
// tslint:enable: no-unsafe-any

@@ -382,7 +280,10 @@ }

}
if (handlerData.endTimestamp && handlerData.__activity) {
Tracing.popActivity(handlerData.__activity, handlerData.fetchData);
if (!Tracing.options.shouldCreateSpanForRequest(handlerData.fetchData.url)) {
return;
}
if (handlerData.endTimestamp && handlerData.fetchData.__activity) {
Tracing.popActivity(handlerData.fetchData.__activity, handlerData.fetchData);
}
else {
handlerData.__activity = Tracing.pushActivity('fetch', {
handlerData.fetchData.__activity = Tracing.pushActivity('fetch', {
data: tslib_1.__assign({}, handlerData.fetchData, { type: 'fetch' }),

@@ -392,6 +293,21 @@ description: handlerData.fetchData.method + " " + handlerData.fetchData.url,

});
var activity = Tracing._activities[handlerData.fetchData.__activity];
if (activity) {
var span = activity.span;
if (span) {
var options = (handlerData.args[1] = handlerData.args[1] || {});
if (options.headers) {
if (Array.isArray(options.headers)) {
options.headers = tslib_1.__spread(options.headers, [{ 'sentry-trace': span.toTraceparent() }]);
}
else {
options.headers = tslib_1.__assign({}, options.headers, { 'sentry-trace': span.toTraceparent() });
}
}
else {
options.headers = { 'sentry-trace': span.toTraceparent() };
}
}
}
}
// if (handlerData.error) {
// } else {
// }
// tslint:enable: no-unsafe-any

@@ -398,0 +314,0 @@ }

@@ -56,2 +56,7 @@ import { EventProcessor, Hub, Integration, Span, SpanContext, SpanStatus } from '@sentry/types';

}
/** JSDoc */
interface Activity {
name: string;
span?: Span;
}
/**

@@ -71,7 +76,2 @@ * Tracing Integration

/**
* If we have an xhr we need to store the url in the instance.
*
*/
private _xhrUrl?;
/**
* Is Tracing enabled, this will be determined once per pageload.

@@ -88,3 +88,5 @@ */

private static _currentIndex;
private static readonly _activities;
static readonly _activities: {
[key: number]: Activity;
};
private static _debounce;

@@ -102,10 +104,2 @@ /**

/**
* JSDoc
*/
private _traceXHR;
/**
* JSDoc
*/
private _traceFetch;
/**
* Is tracing enabled

@@ -112,0 +106,0 @@ */

import * as tslib_1 from "tslib";
import { addInstrumentationHandler, fill, getGlobalObject, isMatchingPattern, logger, supportsNativeFetch, } from '@sentry/utils';
import { addInstrumentationHandler, getGlobalObject, isMatchingPattern, logger } from '@sentry/utils';
var global = getGlobalObject();

@@ -24,3 +24,4 @@ /**

var origins = (_options && _options.tracingOrigins) || defaultTracingOrigins;
return origins.some(function (origin) { return isMatchingPattern(url, origin); });
return (origins.some(function (origin) { return isMatchingPattern(url, origin); }) &&
!isMatchingPattern(url, 'sentry_key'));
},

@@ -53,3 +54,2 @@ startTransactionOnLocationChange: true,

});
this._traceXHR(getCurrentHub);
}

@@ -62,3 +62,2 @@ // tslint:disable-next-line: no-non-null-assertion

});
this._traceFetch(getCurrentHub);
}

@@ -81,111 +80,2 @@ // tslint:disable-next-line: no-non-null-assertion

/**
* JSDoc
*/
Tracing.prototype._traceXHR = function (getCurrentHub) {
if (!('XMLHttpRequest' in getGlobalObject())) {
return;
}
var xhrproto = XMLHttpRequest.prototype;
fill(xhrproto, 'open', function (originalOpen) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// @ts-ignore
var self = getCurrentHub().getIntegration(Tracing);
if (self) {
self._xhrUrl = args[1];
}
// tslint:disable-next-line: no-unsafe-any
return originalOpen.apply(this, args);
};
});
fill(xhrproto, 'send', function (originalSend) {
return function () {
var _this = this;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// @ts-ignore
var self = getCurrentHub().getIntegration(Tracing);
// tslint:disable-next-line: no-non-null-assertion
if (self && self._xhrUrl && self._options.tracingOrigins) {
var url_1 = self._xhrUrl;
var headers_1 = getCurrentHub().traceHeaders();
// tslint:disable-next-line: prefer-for-of no-non-null-assertion
var isWhitelisted = self._options.tracingOrigins.some(function (origin) {
return isMatchingPattern(url_1, origin);
});
if (isMatchingPattern(url_1, 'sentry_key')) {
// If sentry_key is in the url, it's an internal store request to sentry
// we do not want to add the trace header to store requests
isWhitelisted = false;
}
if (isWhitelisted && this.setRequestHeader) {
Object.keys(headers_1).forEach(function (key) {
_this.setRequestHeader(key, headers_1[key]);
});
}
}
// tslint:disable-next-line: no-unsafe-any
return originalSend.apply(this, args);
};
});
};
/**
* JSDoc
*/
Tracing.prototype._traceFetch = function (getCurrentHub) {
if (!supportsNativeFetch()) {
return;
}
// tslint:disable: only-arrow-functions
fill(getGlobalObject(), 'fetch', function (originalFetch) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// @ts-ignore
var hub = getCurrentHub();
var self = hub.getIntegration(Tracing);
// tslint:disable-next-line: no-non-null-assertion
if (self && self._options.tracingOrigins) {
var url_2 = args[0];
var options = (args[1] = args[1] || {});
var isWhitelisted_1 = false;
// tslint:disable-next-line: no-non-null-assertion
self._options.tracingOrigins.forEach(function (whiteListUrl) {
if (!isWhitelisted_1) {
isWhitelisted_1 = isMatchingPattern(url_2, whiteListUrl);
}
});
if (isMatchingPattern(url_2, 'sentry_key')) {
// If sentry_key is in the url, it's an internal store request to sentry
// we do not want to add the trace header to store requests
isWhitelisted_1 = false;
}
if (isWhitelisted_1) {
if (options.headers) {
if (Array.isArray(options.headers)) {
options.headers = tslib_1.__spread(options.headers, Object.entries(hub.traceHeaders()));
}
else {
options.headers = tslib_1.__assign({}, options.headers, hub.traceHeaders());
}
}
else {
options.headers = hub.traceHeaders();
}
}
}
// tslint:disable-next-line: no-unsafe-any
return originalFetch.apply(getGlobalObject(), args);
};
});
// tslint:enable: only-arrow-functions
};
/**
* Is tracing enabled

@@ -370,2 +260,10 @@ */

});
// Adding the trace header to the span
var activity = Tracing._activities[handlerData.xhr.__sentry_xhr_activity_id__];
if (activity) {
var span = activity.span;
if (span && handlerData.xhr.setRequestHeader) {
handlerData.xhr.setRequestHeader('sentry-trace', span.toTraceparent());
}
}
// tslint:enable: no-unsafe-any

@@ -381,7 +279,10 @@ }

}
if (handlerData.endTimestamp && handlerData.__activity) {
Tracing.popActivity(handlerData.__activity, handlerData.fetchData);
if (!Tracing.options.shouldCreateSpanForRequest(handlerData.fetchData.url)) {
return;
}
if (handlerData.endTimestamp && handlerData.fetchData.__activity) {
Tracing.popActivity(handlerData.fetchData.__activity, handlerData.fetchData);
}
else {
handlerData.__activity = Tracing.pushActivity('fetch', {
handlerData.fetchData.__activity = Tracing.pushActivity('fetch', {
data: tslib_1.__assign({}, handlerData.fetchData, { type: 'fetch' }),

@@ -391,6 +292,21 @@ description: handlerData.fetchData.method + " " + handlerData.fetchData.url,

});
var activity = Tracing._activities[handlerData.fetchData.__activity];
if (activity) {
var span = activity.span;
if (span) {
var options = (handlerData.args[1] = handlerData.args[1] || {});
if (options.headers) {
if (Array.isArray(options.headers)) {
options.headers = tslib_1.__spread(options.headers, [{ 'sentry-trace': span.toTraceparent() }]);
}
else {
options.headers = tslib_1.__assign({}, options.headers, { 'sentry-trace': span.toTraceparent() });
}
}
else {
options.headers = { 'sentry-trace': span.toTraceparent() };
}
}
}
}
// if (handlerData.error) {
// } else {
// }
// tslint:enable: no-unsafe-any

@@ -397,0 +313,0 @@ }

{
"name": "@sentry/apm",
"version": "5.10.0",
"version": "5.10.1",
"description": "Extensions for APM",

@@ -19,6 +19,6 @@ "repository": "git://github.com/getsentry/sentry-javascript.git",

"dependencies": {
"@sentry/hub": "5.10.0",
"@sentry/minimal": "5.10.0",
"@sentry/hub": "5.10.1",
"@sentry/minimal": "5.10.1",
"@sentry/types": "5.10.0",
"@sentry/utils": "5.10.0",
"@sentry/utils": "5.10.1",
"tslib": "^1.9.3"

@@ -25,0 +25,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc