Socket
Socket
Sign inDemoInstall

@sentry/core

Package Overview
Dependencies
Maintainers
9
Versions
526
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/core - npm Package Compare versions

Comparing version 5.0.3 to 5.0.5

89

esm/api.js
import { urlEncode } from '@sentry/utils/object';
import { Dsn } from './dsn';
const SENTRY_API_VERSION = '7';
var SENTRY_API_VERSION = '7';
/** Helper class to provide urls to different Sentry endpoints. */
export class API {
var API = /** @class */ (function () {
/** Create a new instance of API */
constructor(dsn) {
function API(dsn) {
this.dsn = dsn;

@@ -12,13 +12,13 @@ this._dsnObject = new Dsn(dsn);

/** Returns the Dsn object. */
getDsn() {
API.prototype.getDsn = function () {
return this._dsnObject;
}
};
/** Returns a string with auth headers in the url to the store endpoint. */
getStoreEndpoint() {
return `${this._getBaseUrl()}${this.getStoreEndpointPath()}`;
}
API.prototype.getStoreEndpoint = function () {
return "" + this._getBaseUrl() + this.getStoreEndpointPath();
};
/** Returns the store endpoint with auth added in url encoded. */
getStoreEndpointWithUrlEncodedAuth() {
const dsn = this._dsnObject;
const auth = {
API.prototype.getStoreEndpointWithUrlEncodedAuth = function () {
var dsn = this._dsnObject;
var auth = {
sentry_key: dsn.user,

@@ -29,25 +29,25 @@ sentry_version: SENTRY_API_VERSION,

// to avoid preflight CORS requests
return `${this.getStoreEndpoint()}?${urlEncode(auth)}`;
}
return this.getStoreEndpoint() + "?" + urlEncode(auth);
};
/** Returns the base path of the url including the port. */
_getBaseUrl() {
const dsn = this._dsnObject;
const protocol = dsn.protocol ? `${dsn.protocol}:` : '';
const port = dsn.port ? `:${dsn.port}` : '';
return `${protocol}//${dsn.host}${port}`;
}
API.prototype._getBaseUrl = function () {
var dsn = this._dsnObject;
var protocol = dsn.protocol ? dsn.protocol + ":" : '';
var port = dsn.port ? ":" + dsn.port : '';
return protocol + "//" + dsn.host + port;
};
/** Returns only the path component for the store endpoint. */
getStoreEndpointPath() {
const dsn = this._dsnObject;
return `${dsn.path ? `/${dsn.path}` : ''}/api/${dsn.projectId}/store/`;
}
API.prototype.getStoreEndpointPath = function () {
var dsn = this._dsnObject;
return (dsn.path ? "/" + dsn.path : '') + "/api/" + dsn.projectId + "/store/";
};
/** Returns an object that can be used in request headers. */
getRequestHeaders(clientName, clientVersion) {
const dsn = this._dsnObject;
const header = [`Sentry sentry_version=${SENTRY_API_VERSION}`];
header.push(`sentry_timestamp=${new Date().getTime()}`);
header.push(`sentry_client=${clientName}/${clientVersion}`);
header.push(`sentry_key=${dsn.user}`);
API.prototype.getRequestHeaders = function (clientName, clientVersion) {
var dsn = this._dsnObject;
var header = ["Sentry sentry_version=" + SENTRY_API_VERSION];
header.push("sentry_timestamp=" + new Date().getTime());
header.push("sentry_client=" + clientName + "/" + clientVersion);
header.push("sentry_key=" + dsn.user);
if (dsn.pass) {
header.push(`sentry_secret=${dsn.pass}`);
header.push("sentry_secret=" + dsn.pass);
}

@@ -58,10 +58,11 @@ return {

};
}
};
/** Returns the url to the report dialog endpoint. */
getReportDialogEndpoint(dialogOptions = {}) {
const dsn = this._dsnObject;
const endpoint = `${this._getBaseUrl()}${dsn.path ? `/${dsn.path}` : ''}/api/embed/error-page/`;
const encodedOptions = [];
encodedOptions.push(`dsn=${dsn.toString()}`);
for (const key in dialogOptions) {
API.prototype.getReportDialogEndpoint = function (dialogOptions) {
if (dialogOptions === void 0) { dialogOptions = {}; }
var dsn = this._dsnObject;
var endpoint = "" + this._getBaseUrl() + (dsn.path ? "/" + dsn.path : '') + "/api/embed/error-page/";
var encodedOptions = [];
encodedOptions.push("dsn=" + dsn.toString());
for (var key in dialogOptions) {
if (key === 'user') {

@@ -72,18 +73,20 @@ if (!dialogOptions.user) {

if (dialogOptions.user.name) {
encodedOptions.push(`name=${encodeURIComponent(dialogOptions.user.name)}`);
encodedOptions.push("name=" + encodeURIComponent(dialogOptions.user.name));
}
if (dialogOptions.user.email) {
encodedOptions.push(`email=${encodeURIComponent(dialogOptions.user.email)}`);
encodedOptions.push("email=" + encodeURIComponent(dialogOptions.user.email));
}
}
else {
encodedOptions.push(`${encodeURIComponent(key)}=${encodeURIComponent(dialogOptions[key])}`);
encodedOptions.push(encodeURIComponent(key) + "=" + encodeURIComponent(dialogOptions[key]));
}
}
if (encodedOptions.length) {
return `${endpoint}?${encodedOptions.join('&')}`;
return endpoint + "?" + encodedOptions.join('&');
}
return endpoint;
}
}
};
return API;
}());
export { API };
//# sourceMappingURL=api.js.map

@@ -8,5 +8,5 @@ import { SentryError } from '@sentry/utils/error';

*/
export class BaseBackend {
var BaseBackend = /** @class */ (function () {
/** Creates a new backend instance. */
constructor(options) {
function BaseBackend(options) {
this._options = options;

@@ -21,32 +21,34 @@ if (!this._options.dsn) {

*/
_setupTransport() {
BaseBackend.prototype._setupTransport = function () {
return new NoopTransport();
}
};
/**
* @inheritDoc
*/
eventFromException(_exception, _hint) {
BaseBackend.prototype.eventFromException = function (_exception, _hint) {
throw new SentryError('Backend has to implement `eventFromException` method');
}
};
/**
* @inheritDoc
*/
eventFromMessage(_message, _level, _hint) {
BaseBackend.prototype.eventFromMessage = function (_message, _level, _hint) {
throw new SentryError('Backend has to implement `eventFromMessage` method');
}
};
/**
* @inheritDoc
*/
sendEvent(event) {
this._transport.sendEvent(event).catch(reason => {
logger.error(`Error while sending event: ${reason}`);
BaseBackend.prototype.sendEvent = function (event) {
this._transport.sendEvent(event).catch(function (reason) {
logger.error("Error while sending event: " + reason);
});
}
};
/**
* @inheritDoc
*/
getTransport() {
BaseBackend.prototype.getTransport = function () {
return this._transport;
}
}
};
return BaseBackend;
}());
export { BaseBackend };
//# sourceMappingURL=basebackend.js.map

@@ -41,3 +41,3 @@ import * as tslib_1 from "tslib";

*/
export class BaseClient {
var BaseClient = /** @class */ (function () {
/**

@@ -49,3 +49,3 @@ * Initializes this client instance.

*/
constructor(backendClass, options) {
function BaseClient(backendClass, options) {
/** Is the client still processing a call? */

@@ -63,104 +63,115 @@ this._processing = false;

*/
captureException(exception, hint, scope) {
let eventId = hint && hint.event_id;
BaseClient.prototype.captureException = function (exception, hint, scope) {
var _this = this;
var eventId = hint && hint.event_id;
this._processing = true;
this._getBackend()
.eventFromException(exception, hint)
.then(event => this._processEvent(event, hint, scope))
.then(finalEvent => {
.then(function (event) { return _this._processEvent(event, hint, scope); })
.then(function (finalEvent) {
// We need to check for finalEvent in case beforeSend returned null
eventId = finalEvent && finalEvent.event_id;
this._processing = false;
_this._processing = false;
})
.catch(reason => {
.catch(function (reason) {
logger.log(reason);
this._processing = false;
_this._processing = false;
});
return eventId;
}
};
/**
* @inheritDoc
*/
captureMessage(message, level, hint, scope) {
let eventId = hint && hint.event_id;
BaseClient.prototype.captureMessage = function (message, level, hint, scope) {
var _this = this;
var eventId = hint && hint.event_id;
this._processing = true;
const promisedEvent = isPrimitive(message)
? this._getBackend().eventFromMessage(`${message}`, level, hint)
var promisedEvent = isPrimitive(message)
? this._getBackend().eventFromMessage("" + message, level, hint)
: this._getBackend().eventFromException(message, hint);
promisedEvent
.then(event => this._processEvent(event, hint, scope))
.then(finalEvent => {
.then(function (event) { return _this._processEvent(event, hint, scope); })
.then(function (finalEvent) {
// We need to check for finalEvent in case beforeSend returned null
eventId = finalEvent && finalEvent.event_id;
this._processing = false;
_this._processing = false;
})
.catch(reason => {
.catch(function (reason) {
logger.log(reason);
this._processing = false;
_this._processing = false;
});
return eventId;
}
};
/**
* @inheritDoc
*/
captureEvent(event, hint, scope) {
let eventId = hint && hint.event_id;
BaseClient.prototype.captureEvent = function (event, hint, scope) {
var _this = this;
var eventId = hint && hint.event_id;
this._processing = true;
this._processEvent(event, hint, scope)
.then(finalEvent => {
.then(function (finalEvent) {
// We need to check for finalEvent in case beforeSend returned null
eventId = finalEvent && finalEvent.event_id;
this._processing = false;
_this._processing = false;
})
.catch(reason => {
.catch(function (reason) {
logger.log(reason);
this._processing = false;
_this._processing = false;
});
return eventId;
}
};
/**
* @inheritDoc
*/
getDsn() {
BaseClient.prototype.getDsn = function () {
return this._dsn;
}
};
/**
* @inheritDoc
*/
getOptions() {
BaseClient.prototype.getOptions = function () {
return this._options;
}
};
/**
* @inheritDoc
*/
flush(timeout) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return (yield Promise.all([
this._getBackend()
.getTransport()
.close(timeout),
this._isClientProcessing(),
])).reduce((prev, current) => prev && current);
BaseClient.prototype.flush = function (timeout) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, Promise.all([
this._getBackend()
.getTransport()
.close(timeout),
this._isClientProcessing(),
])];
case 1: return [2 /*return*/, (_a.sent()).reduce(function (prev, current) { return prev && current; })];
}
});
});
}
};
/**
* @inheritDoc
*/
close(timeout) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.flush(timeout).finally(() => {
this.getOptions().enabled = false;
BaseClient.prototype.close = function (timeout) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, this.flush(timeout).finally(function () {
_this.getOptions().enabled = false;
})];
});
});
}
};
/**
* @inheritDoc
*/
getIntegrations() {
BaseClient.prototype.getIntegrations = function () {
return this._integrations || {};
}
};
/**
* @inheritDoc
*/
getIntegration(integration) {
BaseClient.prototype.getIntegration = function (integration) {
try {

@@ -170,35 +181,49 @@ return this._integrations[integration.id] || null;

catch (_oO) {
logger.warn(`Cannot retrieve integration ${integration.id} from the current Client`);
logger.warn("Cannot retrieve integration " + integration.id + " from the current Client");
return null;
}
}
};
/** Waits for the client to be done with processing. */
_isClientProcessing(counter = 0) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return new Promise(resolve => {
if (this._processing) {
// Safeguard in case of endless recursion
if (counter >= 10) {
resolve(false);
}
else {
setTimeout(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
resolve(yield this._isClientProcessing(counter + 1));
}), 10);
}
}
else {
resolve(true);
}
BaseClient.prototype._isClientProcessing = function (counter) {
if (counter === void 0) { counter = 0; }
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
if (_this._processing) {
// Safeguard in case of endless recursion
if (counter >= 10) {
resolve(false);
}
else {
setTimeout(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var _a;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = resolve;
return [4 /*yield*/, this._isClientProcessing(counter + 1)];
case 1:
_a.apply(void 0, [_b.sent()]);
return [2 /*return*/];
}
});
}); }, 10);
}
}
else {
resolve(true);
}
})];
});
});
}
};
/** Returns the current backend. */
_getBackend() {
BaseClient.prototype._getBackend = function () {
return this._backend;
}
};
/** Determines whether this SDK is enabled and a valid Dsn is present. */
_isEnabled() {
BaseClient.prototype._isEnabled = function () {
return this.getOptions().enabled !== false && this._dsn !== undefined;
}
};
/**

@@ -218,5 +243,5 @@ * Adds common information to events.

*/
_prepareEvent(event, scope, hint) {
const { environment, release, dist, maxValueLength = 250 } = this.getOptions();
const prepared = Object.assign({}, event);
BaseClient.prototype._prepareEvent = function (event, scope, hint) {
var _a = this.getOptions(), environment = _a.environment, release = _a.release, dist = _a.dist, _b = _a.maxValueLength, maxValueLength = _b === void 0 ? 250 : _b;
var prepared = tslib_1.__assign({}, event);
if (prepared.environment === undefined && environment !== undefined) {

@@ -234,7 +259,7 @@ prepared.environment = environment;

}
const exception = prepared.exception && prepared.exception.values && prepared.exception.values[0];
var exception = prepared.exception && prepared.exception.values && prepared.exception.values[0];
if (exception && exception.value) {
exception.value = truncate(exception.value, maxValueLength);
}
const request = prepared.request;
var request = prepared.request;
if (request && request.url) {

@@ -248,3 +273,3 @@ request.url = truncate(request.url, maxValueLength);

// We prepare the result here with a resolved Event.
let result = SyncPromise.resolve(prepared);
var result = SyncPromise.resolve(prepared);
// This should be the last thing called, since we want that

@@ -257,3 +282,3 @@ // {@link Hub.addEventProcessor} gets the finished prepared event.

return result;
}
};
/**

@@ -263,8 +288,8 @@ * This function adds all used integrations to the SDK info in the event.

*/
_addIntegrations(sdkInfo) {
const integrationsArray = Object.keys(this._integrations);
BaseClient.prototype._addIntegrations = function (sdkInfo) {
var integrationsArray = Object.keys(this._integrations);
if (sdkInfo && integrationsArray.length > 0) {
sdkInfo.integrations = integrationsArray;
}
}
};
/**

@@ -283,4 +308,5 @@ * Processes an event (either error or message) and sends it to Sentry.

*/
_processEvent(event, hint, scope) {
const { beforeSend, sampleRate } = this.getOptions();
BaseClient.prototype._processEvent = function (event, hint, scope) {
var _this = this;
var _a = this.getOptions(), beforeSend = _a.beforeSend, sampleRate = _a.sampleRate;
if (!this._isEnabled()) {

@@ -294,4 +320,4 @@ return SyncPromise.reject('SDK not enabled, will not send event.');

}
return new SyncPromise((resolve, reject) => {
this._prepareEvent(event, scope, hint).then(prepared => {
return new SyncPromise(function (resolve, reject) {
_this._prepareEvent(event, scope, hint).then(function (prepared) {
if (prepared === null) {

@@ -301,11 +327,11 @@ reject('An event processor returned null, will not send event.');

}
let finalEvent = prepared;
var finalEvent = prepared;
try {
const isInternalException = hint && hint.data && hint.data.__sentry__ === true;
var isInternalException = hint && hint.data && hint.data.__sentry__ === true;
if (isInternalException || !beforeSend) {
this._getBackend().sendEvent(finalEvent);
_this._getBackend().sendEvent(finalEvent);
resolve(finalEvent);
return;
}
const beforeSendResult = beforeSend(prepared, hint);
var beforeSendResult = beforeSend(prepared, hint);
if (typeof beforeSendResult === 'undefined') {

@@ -315,3 +341,3 @@ logger.error('`beforeSend` method has to return `null` or a valid event.');

else if (isThenable(beforeSendResult)) {
this._handleAsyncBeforeSend(beforeSendResult, resolve, reject);
_this._handleAsyncBeforeSend(beforeSendResult, resolve, reject);
}

@@ -326,3 +352,3 @@ else {

// From here on we are really async
this._getBackend().sendEvent(finalEvent);
_this._getBackend().sendEvent(finalEvent);
resolve(finalEvent);

@@ -332,3 +358,3 @@ }

catch (exception) {
this.captureException(exception, {
_this.captureException(exception, {
data: {

@@ -343,9 +369,10 @@ __sentry__: true,

});
}
};
/**
* Resolves before send Promise and calls resolve/reject on parent SyncPromise.
*/
_handleAsyncBeforeSend(beforeSend, resolve, reject) {
BaseClient.prototype._handleAsyncBeforeSend = function (beforeSend, resolve, reject) {
var _this = this;
beforeSend
.then(processedEvent => {
.then(function (processedEvent) {
if (processedEvent === null) {

@@ -356,10 +383,12 @@ reject('`beforeSend` returned `null`, will not send event.');

// From here on we are really async
this._getBackend().sendEvent(processedEvent);
_this._getBackend().sendEvent(processedEvent);
resolve(processedEvent);
})
.catch(e => {
reject(`beforeSend rejected with ${e}`);
.catch(function (e) {
reject("beforeSend rejected with " + e);
});
}
}
};
return BaseClient;
}());
export { BaseClient };
//# sourceMappingURL=baseclient.js.map

@@ -0,10 +1,11 @@

import * as tslib_1 from "tslib";
import { SentryError } from '@sentry/utils/error';
/** Regular expression used to parse a Dsn. */
const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w\.-]+)(?::(\d+))?\/(.+)/;
var DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w\.-]+)(?::(\d+))?\/(.+)/;
/** Error message */
const ERROR_MESSAGE = 'Invalid Dsn';
var ERROR_MESSAGE = 'Invalid Dsn';
/** The Sentry Dsn, identifying a Sentry instance and project. */
export class Dsn {
var Dsn = /** @class */ (function () {
/** Creates a new Dsn component */
constructor(from) {
function Dsn(from) {
if (typeof from === 'string') {

@@ -27,18 +28,19 @@ this._fromString(from);

*/
toString(withPassword = false) {
Dsn.prototype.toString = function (withPassword) {
if (withPassword === void 0) { withPassword = false; }
// tslint:disable-next-line:no-this-assignment
const { host, path, pass, port, projectId, protocol, user } = this;
return (`${protocol}://${user}${withPassword && pass ? `:${pass}` : ''}` +
`@${host}${port ? `:${port}` : ''}/${path ? `${path}/` : path}${projectId}`);
}
var _a = this, host = _a.host, path = _a.path, pass = _a.pass, port = _a.port, projectId = _a.projectId, protocol = _a.protocol, user = _a.user;
return (protocol + "://" + user + (withPassword && pass ? ":" + pass : '') +
("@" + host + (port ? ":" + port : '') + "/" + (path ? path + "/" : path) + projectId));
};
/** Parses a string into this Dsn. */
_fromString(str) {
const match = DSN_REGEX.exec(str);
Dsn.prototype._fromString = function (str) {
var match = DSN_REGEX.exec(str);
if (!match) {
throw new SentryError(ERROR_MESSAGE);
}
const [protocol, user, pass = '', host, port = '', lastPath] = match.slice(1);
let path = '';
let projectId = lastPath;
const split = projectId.split('/');
var _a = tslib_1.__read(match.slice(1), 6), protocol = _a[0], user = _a[1], _b = _a[2], pass = _b === void 0 ? '' : _b, host = _a[3], _c = _a[4], port = _c === void 0 ? '' : _c, lastPath = _a[5];
var path = '';
var projectId = lastPath;
var split = projectId.split('/');
if (split.length > 1) {

@@ -48,6 +50,6 @@ path = split.slice(0, -1).join('/');

}
Object.assign(this, { host, pass, path, projectId, port, protocol, user });
}
Object.assign(this, { host: host, pass: pass, path: path, projectId: projectId, port: port, protocol: protocol, user: user });
};
/** Maps Dsn components into this instance. */
_fromComponents(components) {
Dsn.prototype._fromComponents = function (components) {
this.protocol = components.protocol;

@@ -60,7 +62,8 @@ this.user = components.user;

this.projectId = components.projectId;
}
};
/** Validates this Dsn and throws on error. */
_validate() {
['protocol', 'user', 'host', 'projectId'].forEach(component => {
if (!this[component]) {
Dsn.prototype._validate = function () {
var _this = this;
['protocol', 'user', 'host', 'projectId'].forEach(function (component) {
if (!_this[component]) {
throw new SentryError(ERROR_MESSAGE);

@@ -75,4 +78,6 @@ }

}
}
}
};
return Dsn;
}());
export { Dsn };
//# sourceMappingURL=dsn.js.map

@@ -0,25 +1,26 @@

import * as tslib_1 from "tslib";
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/hub';
import { logger } from '@sentry/utils/logger';
export const installedIntegrations = [];
export var installedIntegrations = [];
/** Gets integration to install */
export function getIntegrationsToSetup(options) {
const defaultIntegrations = (options.defaultIntegrations && [...options.defaultIntegrations]) || [];
const userIntegrations = options.integrations;
let integrations = [];
var defaultIntegrations = (options.defaultIntegrations && tslib_1.__spread(options.defaultIntegrations)) || [];
var userIntegrations = options.integrations;
var integrations = [];
if (Array.isArray(userIntegrations)) {
const userIntegrationsNames = userIntegrations.map(i => i.name);
const pickedIntegrationsNames = [];
var userIntegrationsNames_1 = userIntegrations.map(function (i) { return i.name; });
var pickedIntegrationsNames_1 = [];
// Leave only unique default integrations, that were not overridden with provided user integrations
defaultIntegrations.forEach(defaultIntegration => {
if (userIntegrationsNames.indexOf(defaultIntegration.name) === -1 &&
pickedIntegrationsNames.indexOf(defaultIntegration.name) === -1) {
defaultIntegrations.forEach(function (defaultIntegration) {
if (userIntegrationsNames_1.indexOf(defaultIntegration.name) === -1 &&
pickedIntegrationsNames_1.indexOf(defaultIntegration.name) === -1) {
integrations.push(defaultIntegration);
pickedIntegrationsNames.push(defaultIntegration.name);
pickedIntegrationsNames_1.push(defaultIntegration.name);
}
});
// Don't add same user integration twice
userIntegrations.forEach(userIntegration => {
if (pickedIntegrationsNames.indexOf(userIntegration.name) === -1) {
userIntegrations.forEach(function (userIntegration) {
if (pickedIntegrationsNames_1.indexOf(userIntegration.name) === -1) {
integrations.push(userIntegration);
pickedIntegrationsNames.push(userIntegration.name);
pickedIntegrationsNames_1.push(userIntegration.name);
}

@@ -33,3 +34,3 @@ });

else {
return [...defaultIntegrations];
return tslib_1.__spread(defaultIntegrations);
}

@@ -45,3 +46,3 @@ return integrations;

installedIntegrations.push(integration.name);
logger.log(`Integration installed: ${integration.name}`);
logger.log("Integration installed: " + integration.name);
}

@@ -55,4 +56,4 @@ /**

export function setupIntegrations(options) {
const integrations = {};
getIntegrationsToSetup(options).forEach(integration => {
var integrations = {};
getIntegrationsToSetup(options).forEach(function (integration) {
integrations[integration.name] = integration;

@@ -59,0 +60,0 @@ setupIntegration(integration);

@@ -1,5 +0,5 @@

let originalFunctionToString;
var originalFunctionToString;
/** Patch toString calls to return proper name for wrapped functions */
export class FunctionToString {
constructor() {
var FunctionToString = /** @class */ (function () {
function FunctionToString() {
/**

@@ -13,15 +13,21 @@ * @inheritDoc

*/
setupOnce() {
FunctionToString.prototype.setupOnce = function () {
originalFunctionToString = Function.prototype.toString;
Function.prototype.toString = function (...args) {
const context = this.__sentry__ ? this.__sentry_original__ : this;
Function.prototype.toString = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var context = this.__sentry__ ? this.__sentry_original__ : this;
// tslint:disable-next-line:no-unsafe-any
return originalFunctionToString.apply(context, args);
};
}
}
/**
* @inheritDoc
*/
FunctionToString.id = 'FunctionToString';
};
/**
* @inheritDoc
*/
FunctionToString.id = 'FunctionToString';
return FunctionToString;
}());
export { FunctionToString };
//# sourceMappingURL=functiontostring.js.map

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

import * as tslib_1 from "tslib";
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/hub';

@@ -7,6 +8,7 @@ import { isRegExp } from '@sentry/utils/is';

// this is the result of a script being pulled in from an external domain and CORS.
const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script error\.? on line 0$/];
var DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script error\.? on line 0$/];
/** Inbound filters configurable by the user */
export class InboundFilters {
constructor(_options = {}) {
var InboundFilters = /** @class */ (function () {
function InboundFilters(_options) {
if (_options === void 0) { _options = {}; }
this._options = _options;

@@ -21,13 +23,13 @@ /**

*/
setupOnce() {
addGlobalEventProcessor((event) => {
const hub = getCurrentHub();
InboundFilters.prototype.setupOnce = function () {
addGlobalEventProcessor(function (event) {
var hub = getCurrentHub();
if (!hub) {
return event;
}
const self = hub.getIntegration(InboundFilters);
var self = hub.getIntegration(InboundFilters);
if (self) {
const client = hub.getClient();
const clientOptions = client ? client.getOptions() : {};
const options = self._mergeOptions(clientOptions);
var client = hub.getClient();
var clientOptions = client ? client.getOptions() : {};
var options = self._mergeOptions(clientOptions);
if (self._shouldDropEvent(event, options)) {

@@ -39,25 +41,26 @@ return null;

});
}
};
/** JSDoc */
_shouldDropEvent(event, options) {
InboundFilters.prototype._shouldDropEvent = function (event, options) {
if (this._isSentryError(event, options)) {
logger.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${getEventDescription(event)}`);
logger.warn("Event dropped due to being internal Sentry Error.\nEvent: " + getEventDescription(event));
return true;
}
if (this._isIgnoredError(event, options)) {
logger.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${getEventDescription(event)}`);
logger.warn("Event dropped due to being matched by `ignoreErrors` option.\nEvent: " + getEventDescription(event));
return true;
}
if (this._isBlacklistedUrl(event, options)) {
logger.warn(`Event dropped due to being matched by \`blacklistUrls\` option.\nEvent: ${getEventDescription(event)}.\nUrl: ${this._getEventFilterUrl(event)}`);
logger.warn("Event dropped due to being matched by `blacklistUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + this._getEventFilterUrl(event));
return true;
}
if (!this._isWhitelistedUrl(event, options)) {
logger.warn(`Event dropped due to not being matched by \`whitelistUrls\` option.\nEvent: ${getEventDescription(event)}.\nUrl: ${this._getEventFilterUrl(event)}`);
logger.warn("Event dropped due to not being matched by `whitelistUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + this._getEventFilterUrl(event));
return true;
}
return false;
}
};
/** JSDoc */
_isSentryError(event, options = {}) {
InboundFilters.prototype._isSentryError = function (event, options) {
if (options === void 0) { options = {}; }
if (!options.ignoreInternal) {

@@ -73,14 +76,19 @@ return false;

}
}
};
/** JSDoc */
_isIgnoredError(event, options = {}) {
InboundFilters.prototype._isIgnoredError = function (event, options) {
var _this = this;
if (options === void 0) { options = {}; }
if (!options.ignoreErrors || !options.ignoreErrors.length) {
return false;
}
return this._getPossibleEventMessages(event).some(message =>
// Not sure why TypeScript complains here...
options.ignoreErrors.some(pattern => this._isMatchingPattern(message, pattern)));
}
return this._getPossibleEventMessages(event).some(function (message) {
// Not sure why TypeScript complains here...
return options.ignoreErrors.some(function (pattern) { return _this._isMatchingPattern(message, pattern); });
});
};
/** JSDoc */
_isBlacklistedUrl(event, options = {}) {
InboundFilters.prototype._isBlacklistedUrl = function (event, options) {
var _this = this;
if (options === void 0) { options = {}; }
// TODO: Use Glob instead?

@@ -90,7 +98,9 @@ if (!options.blacklistUrls || !options.blacklistUrls.length) {

}
const url = this._getEventFilterUrl(event);
return !url ? false : options.blacklistUrls.some(pattern => this._isMatchingPattern(url, pattern));
}
var url = this._getEventFilterUrl(event);
return !url ? false : options.blacklistUrls.some(function (pattern) { return _this._isMatchingPattern(url, pattern); });
};
/** JSDoc */
_isWhitelistedUrl(event, options = {}) {
InboundFilters.prototype._isWhitelistedUrl = function (event, options) {
var _this = this;
if (options === void 0) { options = {}; }
// TODO: Use Glob instead?

@@ -100,20 +110,17 @@ if (!options.whitelistUrls || !options.whitelistUrls.length) {

}
const url = this._getEventFilterUrl(event);
return !url ? true : options.whitelistUrls.some(pattern => this._isMatchingPattern(url, pattern));
}
var url = this._getEventFilterUrl(event);
return !url ? true : options.whitelistUrls.some(function (pattern) { return _this._isMatchingPattern(url, pattern); });
};
/** JSDoc */
_mergeOptions(clientOptions = {}) {
InboundFilters.prototype._mergeOptions = function (clientOptions) {
if (clientOptions === void 0) { clientOptions = {}; }
return {
blacklistUrls: [...(this._options.blacklistUrls || []), ...(clientOptions.blacklistUrls || [])],
ignoreErrors: [
...(this._options.ignoreErrors || []),
...(clientOptions.ignoreErrors || []),
...DEFAULT_IGNORE_ERRORS,
],
blacklistUrls: tslib_1.__spread((this._options.blacklistUrls || []), (clientOptions.blacklistUrls || [])),
ignoreErrors: tslib_1.__spread((this._options.ignoreErrors || []), (clientOptions.ignoreErrors || []), DEFAULT_IGNORE_ERRORS),
ignoreInternal: typeof this._options.ignoreInternal !== 'undefined' ? this._options.ignoreInternal : true,
whitelistUrls: [...(this._options.whitelistUrls || []), ...(clientOptions.whitelistUrls || [])],
whitelistUrls: tslib_1.__spread((this._options.whitelistUrls || []), (clientOptions.whitelistUrls || [])),
};
}
};
/** JSDoc */
_isMatchingPattern(value, pattern) {
InboundFilters.prototype._isMatchingPattern = function (value, pattern) {
if (isRegExp(pattern)) {

@@ -126,5 +133,5 @@ return pattern.test(value);

return false;
}
};
/** JSDoc */
_getPossibleEventMessages(event) {
InboundFilters.prototype._getPossibleEventMessages = function (event) {
if (event.message) {

@@ -136,7 +143,7 @@ return [event.message];

// tslint:disable-next-line:no-unsafe-any
const { type, value } = event.exception.values[0];
return [`${value}`, `${type}: ${value}`];
var _a = event.exception.values[0], type = _a.type, value = _a.value;
return ["" + value, type + ": " + value];
}
catch (oO) {
logger.error(`Cannot extract message for event ${getEventDescription(event)}`);
logger.error("Cannot extract message for event " + getEventDescription(event));
return [];

@@ -146,15 +153,15 @@ }

return [];
}
};
/** JSDoc */
_getEventFilterUrl(event) {
InboundFilters.prototype._getEventFilterUrl = function (event) {
try {
if (event.stacktrace) {
// tslint:disable:no-unsafe-any
const frames = event.stacktrace.frames;
return frames[frames.length - 1].filename;
var frames_1 = event.stacktrace.frames;
return frames_1[frames_1.length - 1].filename;
}
if (event.exception) {
// tslint:disable:no-unsafe-any
const frames = event.exception.values[0].stacktrace.frames;
return frames[frames.length - 1].filename;
var frames_2 = event.exception.values[0].stacktrace.frames;
return frames_2[frames_2.length - 1].filename;
}

@@ -164,11 +171,13 @@ return null;

catch (oO) {
logger.error(`Cannot extract url for event ${getEventDescription(event)}`);
logger.error("Cannot extract url for event " + getEventDescription(event));
return null;
}
}
}
/**
* @inheritDoc
*/
InboundFilters.id = 'InboundFilters';
};
/**
* @inheritDoc
*/
InboundFilters.id = 'InboundFilters';
return InboundFilters;
}());
export { InboundFilters };
//# sourceMappingURL=inboundfilters.js.map
import * as tslib_1 from "tslib";
import { Status } from '@sentry/types';
/** Noop transport */
export class NoopTransport {
var NoopTransport = /** @class */ (function () {
function NoopTransport() {
}
/**
* @inheritDoc
*/
sendEvent(_) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return Promise.resolve({
reason: `NoopTransport: Event has been skipped because no Dsn is configured.`,
status: Status.Skipped,
NoopTransport.prototype.sendEvent = function (_) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, Promise.resolve({
reason: "NoopTransport: Event has been skipped because no Dsn is configured.",
status: Status.Skipped,
})];
});
});
}
};
/**
* @inheritDoc
*/
close(_) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return Promise.resolve(true);
NoopTransport.prototype.close = function (_) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, Promise.resolve(true)];
});
});
}
}
};
return NoopTransport;
}());
export { NoopTransport };
//# sourceMappingURL=noop.js.map
{
"name": "@sentry/core",
"version": "5.0.3",
"version": "5.0.5",
"description": "Base implementation for all Sentry JavaScript SDKs",

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

"dependencies": {
"@sentry/hub": "5.0.3",
"@sentry/minimal": "5.0.3",
"@sentry/types": "5.0.0",
"@sentry/utils": "5.0.0",
"@sentry/hub": "5.0.5",
"@sentry/minimal": "5.0.5",
"@sentry/types": "5.0.5",
"@sentry/utils": "5.0.5",
"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

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