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 4.6.4 to 5.0.0-rc.0

4

dist/api.d.ts

@@ -7,3 +7,3 @@ import { DsnLike } from '@sentry/types';

/** The internally used Dsn object. */
private readonly dsnObject;
private readonly _dsnObject;
/** Create a new instance of API */

@@ -18,3 +18,3 @@ constructor(dsn: DsnLike);

/** Returns the base path of the url including the port. */
private getBaseUrl;
private _getBaseUrl;
/** Returns only the path component for the store endpoint. */

@@ -21,0 +21,0 @@ getStoreEndpointPath(): string;

@@ -11,15 +11,15 @@ "use strict";

this.dsn = dsn;
this.dsnObject = new dsn_1.Dsn(dsn);
this._dsnObject = new dsn_1.Dsn(dsn);
}
/** Returns the Dsn object. */
API.prototype.getDsn = function () {
return this.dsnObject;
return this._dsnObject;
};
/** Returns a string with auth headers in the url to the store endpoint. */
API.prototype.getStoreEndpoint = function () {
return "" + this.getBaseUrl() + this.getStoreEndpointPath();
return "" + this._getBaseUrl() + this.getStoreEndpointPath();
};
/** Returns the store endpoint with auth added in url encoded. */
API.prototype.getStoreEndpointWithUrlEncodedAuth = function () {
var dsn = this.dsnObject;
var dsn = this._dsnObject;
var auth = {

@@ -34,4 +34,4 @@ sentry_key: dsn.user,

/** Returns the base path of the url including the port. */
API.prototype.getBaseUrl = function () {
var dsn = this.dsnObject;
API.prototype._getBaseUrl = function () {
var dsn = this._dsnObject;
var protocol = dsn.protocol ? dsn.protocol + ":" : '';

@@ -43,3 +43,3 @@ var port = dsn.port ? ":" + dsn.port : '';

API.prototype.getStoreEndpointPath = function () {
var dsn = this.dsnObject;
var dsn = this._dsnObject;
return (dsn.path ? "/" + dsn.path : '') + "/api/" + dsn.projectId + "/store/";

@@ -49,3 +49,3 @@ };

API.prototype.getRequestHeaders = function (clientName, clientVersion) {
var dsn = this.dsnObject;
var dsn = this._dsnObject;
var header = ["Sentry sentry_version=" + SENTRY_API_VERSION];

@@ -66,4 +66,4 @@ header.push("sentry_timestamp=" + new Date().getTime());

if (dialogOptions === void 0) { dialogOptions = {}; }
var dsn = this.dsnObject;
var endpoint = "" + this.getBaseUrl() + (dsn.path ? "/" + dsn.path : '') + "/api/embed/error-page/";
var dsn = this._dsnObject;
var endpoint = "" + this._getBaseUrl() + (dsn.path ? "/" + dsn.path : '') + "/api/embed/error-page/";
var encodedOptions = [];

@@ -70,0 +70,0 @@ encodedOptions.push("dsn=" + dsn.toString());

@@ -1,17 +0,53 @@

import { Scope } from '@sentry/hub';
import { Breadcrumb, SentryEvent, SentryEventHint, SentryResponse, Severity, Transport } from '@sentry/types';
import { Backend, Options } from './interfaces';
/** A class object that can instanciate Backend objects. */
export interface BackendClass<B extends Backend, O extends Options> {
new (options: O): B;
import { Event, EventHint, Options, Severity, Transport } from '@sentry/types';
import { SyncPromise } from '@sentry/utils/syncpromise';
/**
* Internal platform-dependent Sentry SDK Backend.
*
* While {@link Client} contains business logic specific to an SDK, the
* Backend offers platform specific implementations for low-level operations.
* These are persisting and loading information, sending events, and hooking
* into the environment.
*
* Backends receive a handle to the Client in their constructor. When a
* Backend automatically generates events, it must pass them to
* the Client for validation and processing first.
*
* Usually, the Client will be of corresponding type, e.g. NodeBackend
* receives NodeClient. However, higher-level SDKs can choose to instanciate
* multiple Backends and delegate tasks between them. In this case, an event
* generated by one backend might very well be sent by another one.
*
* The client also provides access to options via {@link Client.getOptions}.
* @hidden
*/
export interface Backend {
/** Creates a {@link Event} from an exception. */
eventFromException(exception: any, hint?: EventHint): SyncPromise<Event>;
/** Creates a {@link Event} from a plain message. */
eventFromMessage(message: string, level?: Severity, hint?: EventHint): SyncPromise<Event>;
/** Submits the event to Sentry */
sendEvent(event: Event): void;
/**
* Returns the transport that is used by the backend.
* Please note that the transport gets lazy initialized so it will only be there once the first event has been sent.
*
* @returns The transport.
*/
getTransport(): Transport;
}
/**
* A class object that can instanciate Backend objects.
* @hidden
*/
export declare type BackendClass<B extends Backend, O extends Options> = new (options: O) => B;
/**
* This is the base implemention of a Backend.
* @hidden
*/
export declare abstract class BaseBackend<O extends Options> implements Backend {
/** Options passed to the SDK. */
protected readonly options: O;
protected readonly _options: O;
/** Cached transport used internally. */
protected transport: Transport;
/** Creates a new browser backend instance. */
protected _transport: Transport;
/** Creates a new backend instance. */
constructor(options: O);

@@ -21,27 +57,19 @@ /**

*/
protected setupTransport(): Transport;
protected _setupTransport(): Transport;
/**
* @inheritDoc
*/
eventFromException(_exception: any, _hint?: SentryEventHint): Promise<SentryEvent>;
eventFromException(_exception: any, _hint?: EventHint): SyncPromise<Event>;
/**
* @inheritDoc
*/
eventFromMessage(_message: string, _level?: Severity, _hint?: SentryEventHint): Promise<SentryEvent>;
eventFromMessage(_message: string, _level?: Severity, _hint?: EventHint): SyncPromise<Event>;
/**
* @inheritDoc
*/
sendEvent(event: SentryEvent): Promise<SentryResponse>;
sendEvent(event: Event): void;
/**
* @inheritDoc
*/
storeBreadcrumb(_: Breadcrumb): boolean;
/**
* @inheritDoc
*/
storeScope(_: Scope): void;
/**
* @inheritDoc
*/
getTransport(): Transport;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var error_1 = require("@sentry/utils/error");
var logger_1 = require("@sentry/utils/logger");
var object_1 = require("@sentry/utils/object");
var error_1 = require("./error");
var noop_1 = require("./transports/noop");
/**
* This is the base implemention of a Backend.
* @hidden
*/
var BaseBackend = /** @class */ (function () {
/** Creates a new browser backend instance. */
/** Creates a new backend instance. */
function BaseBackend(options) {
this.options = options;
if (!this.options.dsn) {
this._options = options;
if (!this._options.dsn) {
logger_1.logger.warn('No DSN provided, backend will not do anything.');
}
this.transport = this.setupTransport();
this._transport = this._setupTransport();
}

@@ -23,3 +22,3 @@ /**

*/
BaseBackend.prototype.setupTransport = function () {
BaseBackend.prototype._setupTransport = function () {
return new noop_1.NoopTransport();

@@ -31,7 +30,3 @@ };

BaseBackend.prototype.eventFromException = function (_exception, _hint) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
throw new error_1.SentryError('Backend has to implement `eventFromException` method');
});
});
throw new error_1.SentryError('Backend has to implement `eventFromException` method');
};

@@ -42,7 +37,3 @@ /**

BaseBackend.prototype.eventFromMessage = function (_message, _level, _hint) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
throw new error_1.SentryError('Backend has to implement `eventFromMessage` method');
});
});
throw new error_1.SentryError('Backend has to implement `eventFromMessage` method');
};

@@ -53,13 +44,4 @@ /**

BaseBackend.prototype.sendEvent = function (event) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
// TODO: Remove with v5
// tslint:disable-next-line
if (this.transport.captureEvent) {
// tslint:disable-next-line
return [2 /*return*/, this.transport.captureEvent(event)];
}
// --------------------
return [2 /*return*/, this.transport.sendEvent(object_1.serialize(event))];
});
this._transport.sendEvent(event).catch(function (reason) {
logger_1.logger.error("Error while sending event: " + reason);
});

@@ -70,16 +52,4 @@ };

*/
BaseBackend.prototype.storeBreadcrumb = function (_) {
return true;
};
/**
* @inheritDoc
*/
BaseBackend.prototype.storeScope = function (_) {
// Noop
};
/**
* @inheritDoc
*/
BaseBackend.prototype.getTransport = function () {
return this.transport;
return this._transport;
};

@@ -86,0 +56,0 @@ return BaseBackend;

import { Scope } from '@sentry/hub';
import { Breadcrumb, Integration, IntegrationClass, SentryBreadcrumbHint, SentryEvent, SentryEventHint, SentryResponse, Severity } from '@sentry/types';
import { BackendClass } from './basebackend';
import { Client, Event, EventHint, Integration, IntegrationClass, Options, Severity } from '@sentry/types';
import { SyncPromise } from '@sentry/utils/syncpromise';
import { Backend, BackendClass } from './basebackend';
import { Dsn } from './dsn';
import { IntegrationIndex } from './integration';
import { Backend, Client, Options } from './interfaces';
import { PromiseBuffer } from './promisebuffer';
/**

@@ -46,19 +45,11 @@ * Base implementation for all JavaScript SDK clients.

*/
private readonly backend;
protected readonly _backend: B;
/** Options passed to the SDK. */
private readonly options;
/**
* The client Dsn, if specified in options. Without this Dsn, the SDK will be
* disabled.
*/
private readonly dsn?;
/**
* Stores whether installation has been performed and was successful. Before
* installing, this is undefined. Then it contains the success state.
*/
private installed?;
protected readonly _options: O;
/** The client Dsn, if specified in options. Without this Dsn, the SDK will be disabled. */
protected readonly _dsn?: Dsn;
/** Array of used integrations. */
private readonly integrations;
/** A simple buffer holding all requests. */
protected readonly buffer: PromiseBuffer<SentryResponse>;
protected readonly _integrations: IntegrationIndex;
/** Is the client still processing a call? */
protected _processing: boolean;
/**

@@ -74,31 +65,41 @@ * Initializes this client instance.

*/
install(): boolean;
captureException(exception: any, hint?: EventHint, scope?: Scope): string | undefined;
/**
* @inheritDoc
*/
captureException(exception: any, hint?: SentryEventHint, scope?: Scope): Promise<SentryResponse>;
captureMessage(message: string, level?: Severity, hint?: EventHint, scope?: Scope): string | undefined;
/**
* @inheritDoc
*/
captureMessage(message: string, level?: Severity, hint?: SentryEventHint, scope?: Scope): Promise<SentryResponse>;
captureEvent(event: Event, hint?: EventHint, scope?: Scope): string | undefined;
/**
* @inheritDoc
*/
captureEvent(event: SentryEvent, hint?: SentryEventHint, scope?: Scope): Promise<SentryResponse>;
getDsn(): Dsn | undefined;
/**
* @inheritDoc
*/
addBreadcrumb(breadcrumb: Breadcrumb, hint?: SentryBreadcrumbHint, scope?: Scope): void;
getOptions(): O;
/**
* @inheritDoc
*/
getDsn(): Dsn | undefined;
flush(timeout?: number): Promise<boolean>;
/**
* @inheritDoc
*/
getOptions(): O;
close(timeout?: number): Promise<boolean>;
/**
* @inheritDoc
*/
getIntegrations(): IntegrationIndex;
/**
* @inheritDoc
*/
getIntegration<T extends Integration>(integration: IntegrationClass<T>): T | null;
/** Waits for the client to be done with processing. */
protected _isClientProcessing(counter?: number): Promise<boolean>;
/** Returns the current backend. */
protected getBackend(): B;
protected _getBackend(): B;
/** Determines whether this SDK is enabled and a valid Dsn is present. */
protected isEnabled(): boolean;
protected _isEnabled(): boolean;
/**

@@ -118,3 +119,3 @@ * Adds common information to events.

*/
protected prepareEvent(event: SentryEvent, scope?: Scope, hint?: SentryEventHint): Promise<SentryEvent | null>;
protected _prepareEvent(event: Event, scope?: Scope, hint?: EventHint): SyncPromise<Event | null>;
/**

@@ -127,30 +128,13 @@ * Processes an event (either error or message) and sends it to Sentry.

*
* The returned event status offers clues to whether the event was sent to
* Sentry and accepted there. If the {@link Options.shouldSend} hook returns
* `false`, the status will be {@link SendStatus.Skipped}. If the rate limit
* was exceeded, the status will be {@link SendStatus.RateLimit}.
*
* @param event The event to send to Sentry.
* @param send A function to actually send the event.
* @param hint May contain additional informartion about the original exception.
* @param scope A scope containing event metadata.
* @param hint May contain additional informartion about the original exception.
* @returns A Promise that resolves with the event status.
* @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send.
*/
protected processEvent(event: SentryEvent, send: (finalEvent: SentryEvent) => Promise<SentryResponse>, hint?: SentryEventHint, scope?: Scope): Promise<SentryResponse>;
protected _processEvent(event: Event, hint?: EventHint, scope?: Scope): SyncPromise<Event>;
/**
* @inheritDoc
* Resolves before send Promise and calls resolve/reject on parent SyncPromise.
*/
flush(timeout?: number): Promise<boolean>;
/**
* @inheritDoc
*/
close(timeout?: number): Promise<boolean>;
/**
* @inheritDoc
*/
getIntegrations(): IntegrationIndex;
/**
* @inheritDoc
*/
getIntegration<T extends Integration>(integration: IntegrationClass<T>): T | null;
private _handleAsyncBeforeSend;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var types_1 = require("@sentry/types");
var async_1 = require("@sentry/utils/async");
var is_1 = require("@sentry/utils/is");

@@ -10,20 +8,6 @@ var logger_1 = require("@sentry/utils/logger");

var string_1 = require("@sentry/utils/string");
var syncpromise_1 = require("@sentry/utils/syncpromise");
var dsn_1 = require("./dsn");
var integration_1 = require("./integration");
var promisebuffer_1 = require("./promisebuffer");
/**
* Default maximum number of breadcrumbs added to an event. Can be overwritten
* with {@link Options.maxBreadcrumbs}.
*/
var DEFAULT_BREADCRUMBS = 30;
/**
* Absolute maximum number of breadcrumbs added to an event. The
* `maxBreadcrumbs` option cannot be higher than this value.
*/
var MAX_BREADCRUMBS = 100;
/**
* By default, truncates URL values to 250 chars
*/
var MAX_URL_LENGTH = 250;
/**
* Base implementation for all JavaScript SDK clients.

@@ -68,12 +52,10 @@ *

function BaseClient(backendClass, options) {
/** A simple buffer holding all requests. */
this.buffer = new promisebuffer_1.PromiseBuffer();
this.backend = new backendClass(options);
this.options = options;
/** Is the client still processing a call? */
this._processing = false;
this._backend = new backendClass(options);
this._options = options;
if (options.dsn) {
this.dsn = new dsn_1.Dsn(options.dsn);
this._dsn = new dsn_1.Dsn(options.dsn);
}
// We have to setup the integrations in the constructor since we do not want
// that anyone needs to call client.install();
this.integrations = integration_1.setupIntegrations(this.options);
this._integrations = integration_1.setupIntegrations(this._options);
}

@@ -83,11 +65,19 @@ /**

*/
BaseClient.prototype.install = function () {
if (!this.isEnabled()) {
return (this.installed = false);
}
var backend = this.getBackend();
if (!this.installed && backend.install) {
backend.install();
}
return (this.installed = true);
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(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;
})
.catch(function (reason) {
logger_1.logger.log(reason);
_this._processing = false;
});
return eventId;
};

@@ -97,19 +87,21 @@ /**

*/
BaseClient.prototype.captureException = function (exception, hint, scope) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, this.buffer.add((function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var event;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getBackend().eventFromException(exception, hint)];
case 1:
event = _a.sent();
return [2 /*return*/, this.captureEvent(event, hint, scope)];
}
});
}); })())];
});
BaseClient.prototype.captureMessage = function (message, level, hint, scope) {
var _this = this;
var eventId = hint && hint.event_id;
this._processing = true;
var promisedEvent = is_1.isPrimitive(message)
? this._getBackend().eventFromMessage("" + message, level, hint)
: this._getBackend().eventFromException(message, hint);
promisedEvent
.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;
})
.catch(function (reason) {
logger_1.logger.log(reason);
_this._processing = false;
});
return eventId;
};

@@ -119,26 +111,45 @@ /**

*/
BaseClient.prototype.captureMessage = function (message, level, hint, scope) {
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(function (finalEvent) {
// We need to check for finalEvent in case beforeSend returned null
eventId = finalEvent && finalEvent.event_id;
_this._processing = false;
})
.catch(function (reason) {
logger_1.logger.log(reason);
_this._processing = false;
});
return eventId;
};
/**
* @inheritDoc
*/
BaseClient.prototype.getDsn = function () {
return this._dsn;
};
/**
* @inheritDoc
*/
BaseClient.prototype.getOptions = function () {
return this._options;
};
/**
* @inheritDoc
*/
BaseClient.prototype.flush = 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.buffer.add((function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var event, _a;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!is_1.isPrimitive(message)) return [3 /*break*/, 2];
return [4 /*yield*/, this.getBackend().eventFromMessage("" + message, level, hint)];
case 1:
_a = _b.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, this.getBackend().eventFromException(message, hint)];
case 3:
_a = _b.sent();
_b.label = 4;
case 4:
event = _a;
return [2 /*return*/, this.captureEvent(event, hint, scope)];
}
});
}); })())];
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; })];
}
});

@@ -150,17 +161,9 @@ });

*/
BaseClient.prototype.captureEvent = function (event, hint, scope) {
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) {
// Adding this here is technically not correct since if you call captureMessage/captureException it's already
// buffered. But since we not really need the count and we only need to know if the buffer is full or not,
// This is fine...
return [2 /*return*/, this.buffer.add((function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var _this = this;
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, this.processEvent(event, function (finalEvent) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, this.getBackend().sendEvent(finalEvent)];
}); }); }, hint, scope)];
});
}); })())];
return [2 /*return*/, this.flush(timeout).finally(function () {
_this.getOptions().enabled = false;
})];
});

@@ -172,18 +175,4 @@ });

*/
BaseClient.prototype.addBreadcrumb = function (breadcrumb, hint, scope) {
var _a = this.getOptions(), beforeBreadcrumb = _a.beforeBreadcrumb, _b = _a.maxBreadcrumbs, maxBreadcrumbs = _b === void 0 ? DEFAULT_BREADCRUMBS : _b;
if (maxBreadcrumbs <= 0) {
return;
}
var timestamp = new Date().getTime() / 1000;
var mergedBreadcrumb = tslib_1.__assign({ timestamp: timestamp }, breadcrumb);
var finalBreadcrumb = beforeBreadcrumb
? misc_1.consoleSandbox(function () { return beforeBreadcrumb(mergedBreadcrumb, hint); })
: mergedBreadcrumb;
if (finalBreadcrumb === null) {
return;
}
if (this.getBackend().storeBreadcrumb(finalBreadcrumb) && scope) {
scope.addBreadcrumb(finalBreadcrumb, Math.min(maxBreadcrumbs, MAX_BREADCRUMBS));
}
BaseClient.prototype.getIntegrations = function () {
return this._integrations || {};
};

@@ -193,18 +182,53 @@ /**

*/
BaseClient.prototype.getDsn = function () {
return this.dsn;
BaseClient.prototype.getIntegration = function (integration) {
try {
return this._integrations[integration.id] || null;
}
catch (_oO) {
logger_1.logger.warn("Cannot retrieve integration " + integration.id + " from the current Client");
return null;
}
};
/**
* @inheritDoc
*/
BaseClient.prototype.getOptions = function () {
return this.options;
/** Waits for the client to be done with processing. */
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. */
BaseClient.prototype.getBackend = function () {
return this.backend;
BaseClient.prototype._getBackend = function () {
return this._backend;
};
/** Determines whether this SDK is enabled and a valid Dsn is present. */
BaseClient.prototype.isEnabled = function () {
return this.getOptions().enabled !== false && this.dsn !== undefined;
BaseClient.prototype._isEnabled = function () {
return this.getOptions().enabled !== false && this._dsn !== undefined;
};

@@ -225,39 +249,37 @@ /**

*/
BaseClient.prototype.prepareEvent = function (event, scope, hint) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, environment, _b, maxBreadcrumbs, release, dist, prepared, exception, request;
return tslib_1.__generator(this, function (_c) {
_a = this.getOptions(), environment = _a.environment, _b = _a.maxBreadcrumbs, maxBreadcrumbs = _b === void 0 ? DEFAULT_BREADCRUMBS : _b, release = _a.release, dist = _a.dist;
prepared = tslib_1.__assign({}, event);
if (prepared.environment === undefined && environment !== undefined) {
prepared.environment = environment;
}
if (prepared.release === undefined && release !== undefined) {
prepared.release = release;
}
if (prepared.dist === undefined && dist !== undefined) {
prepared.dist = dist;
}
if (prepared.message) {
prepared.message = string_1.truncate(prepared.message, MAX_URL_LENGTH);
}
exception = prepared.exception && prepared.exception.values && prepared.exception.values[0];
if (exception && exception.value) {
exception.value = string_1.truncate(exception.value, MAX_URL_LENGTH);
}
request = prepared.request;
if (request && request.url) {
request.url = string_1.truncate(request.url, MAX_URL_LENGTH);
}
if (prepared.event_id === undefined) {
prepared.event_id = misc_1.uuid4();
}
// This should be the last thing called, since we want that
// {@link Hub.addEventProcessor} gets the finished prepared event.
if (scope) {
return [2 /*return*/, scope.applyToEvent(prepared, hint, Math.min(maxBreadcrumbs, MAX_BREADCRUMBS))];
}
return [2 /*return*/, prepared];
});
});
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) {
prepared.environment = environment;
}
if (prepared.release === undefined && release !== undefined) {
prepared.release = release;
}
if (prepared.dist === undefined && dist !== undefined) {
prepared.dist = dist;
}
if (prepared.message) {
prepared.message = string_1.truncate(prepared.message, maxValueLength);
}
var exception = prepared.exception && prepared.exception.values && prepared.exception.values[0];
if (exception && exception.value) {
exception.value = string_1.truncate(exception.value, maxValueLength);
}
var request = prepared.request;
if (request && request.url) {
request.url = string_1.truncate(request.url, maxValueLength);
}
if (prepared.event_id === undefined) {
prepared.event_id = misc_1.uuid4();
}
// We prepare the result here with a resolved Event.
var result = syncpromise_1.SyncPromise.resolve(prepared);
// This should be the last thing called, since we want that
// {@link Hub.addEventProcessor} gets the finished prepared event.
if (scope) {
// In case we have a hub we reassign it.
result = scope.applyToEvent(prepared, hint);
}
return result;
};

@@ -271,113 +293,60 @@ /**

*
* The returned event status offers clues to whether the event was sent to
* Sentry and accepted there. If the {@link Options.shouldSend} hook returns
* `false`, the status will be {@link SendStatus.Skipped}. If the rate limit
* was exceeded, the status will be {@link SendStatus.RateLimit}.
*
* @param event The event to send to Sentry.
* @param send A function to actually send the event.
* @param hint May contain additional informartion about the original exception.
* @param scope A scope containing event metadata.
* @param hint May contain additional informartion about the original exception.
* @returns A Promise that resolves with the event status.
* @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send.
*/
BaseClient.prototype.processEvent = function (event, send, hint, scope) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, beforeSend, sampleRate, prepared, finalEvent, isInternalException, exception_1, response, error_1;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!this.isEnabled()) {
return [2 /*return*/, {
status: types_1.Status.Skipped,
}];
}
_a = this.getOptions(), beforeSend = _a.beforeSend, sampleRate = _a.sampleRate;
// 1.0 === 100% events are sent
// 0.0 === 0% events are sent
if (typeof sampleRate === 'number' && Math.random() > sampleRate) {
return [2 /*return*/, {
status: types_1.Status.Skipped,
}];
}
return [4 /*yield*/, this.prepareEvent(event, scope, hint)];
case 1:
prepared = _b.sent();
if (prepared === null) {
return [2 /*return*/, {
status: types_1.Status.Skipped,
}];
}
finalEvent = prepared;
_b.label = 2;
case 2:
_b.trys.push([2, 5, , 6]);
isInternalException = hint && hint.data && hint.data.__sentry__ === true;
if (!(!isInternalException && beforeSend)) return [3 /*break*/, 4];
return [4 /*yield*/, beforeSend(prepared, hint)];
case 3:
finalEvent = _b.sent();
if (typeof finalEvent === 'undefined') {
logger_1.logger.error('`beforeSend` method has to return `null` or a valid event');
}
_b.label = 4;
case 4: return [3 /*break*/, 6];
case 5:
exception_1 = _b.sent();
async_1.forget(this.captureException(exception_1, {
data: {
__sentry__: true,
},
originalException: exception_1,
}));
return [2 /*return*/, {
reason: 'Event processing in beforeSend method threw an exception',
status: types_1.Status.Invalid,
}];
case 6:
BaseClient.prototype._processEvent = function (event, hint, scope) {
var _this = this;
var _a = this.getOptions(), beforeSend = _a.beforeSend, sampleRate = _a.sampleRate;
if (!this._isEnabled()) {
return syncpromise_1.SyncPromise.reject('SDK not enabled, will not send event.');
}
// 1.0 === 100% events are sent
// 0.0 === 0% events are sent
if (typeof sampleRate === 'number' && Math.random() > sampleRate) {
return syncpromise_1.SyncPromise.reject('This event has been sampled, will not send event.');
}
return new syncpromise_1.SyncPromise(function (resolve, reject) {
_this._prepareEvent(event, scope, hint).then(function (prepared) {
if (prepared === null) {
reject('An event processor returned null, will not send event.');
return;
}
var finalEvent = prepared;
try {
var isInternalException = hint && hint.data && hint.data.__sentry__ === true;
if (isInternalException || !beforeSend) {
_this._getBackend().sendEvent(finalEvent);
resolve(finalEvent);
return;
}
var beforeSendResult = beforeSend(prepared, hint);
if (typeof beforeSendResult === 'undefined') {
logger_1.logger.error('`beforeSend` method has to return `null` or a valid event.');
}
else if (is_1.isThenable(beforeSendResult)) {
_this._handleAsyncBeforeSend(beforeSendResult, resolve, reject);
}
else {
finalEvent = beforeSendResult;
if (finalEvent === null) {
return [2 /*return*/, {
reason: 'Event dropped due to being discarded by beforeSend method',
status: types_1.Status.Skipped,
}];
logger_1.logger.log('`beforeSend` returned `null`, will not send event.');
resolve(null);
return;
}
_b.label = 7;
case 7:
_b.trys.push([7, 9, , 10]);
return [4 /*yield*/, send(finalEvent)];
case 8:
response = _b.sent();
response.event = finalEvent;
if (response.status === types_1.Status.RateLimit) {
// TODO: Handle rate limits and maintain a queue. For now, we require SDK
// implementors to override this method and handle it themselves.
}
return [2 /*return*/, response];
case 9:
error_1 = _b.sent();
// We have a catch here since the transport can reject the request internally.
// If we do not catch this here, we will run into an endless loop.
logger_1.logger.error("" + error_1);
return [2 /*return*/, {
reason: "" + error_1,
status: types_1.Status.Failed,
}];
case 10: return [2 /*return*/];
// From here on we are really async
_this._getBackend().sendEvent(finalEvent);
resolve(finalEvent);
}
}
});
});
};
/**
* @inheritDoc
*/
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.buffer.drain(timeout),
])];
case 1: return [2 /*return*/, (_a.sent()).reduce(function (prev, current) { return prev && current; })];
catch (exception) {
_this.captureException(exception, {
data: {
__sentry__: true,
},
originalException: exception,
});
reject('`beforeSend` throw an error, will not send event.');
}

@@ -388,29 +357,20 @@ });

/**
* @inheritDoc
* Resolves before send Promise and calls resolve/reject on parent SyncPromise.
*/
BaseClient.prototype.close = function (timeout) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, this.flush(timeout)];
});
BaseClient.prototype._handleAsyncBeforeSend = function (beforeSend, resolve, reject) {
var _this = this;
beforeSend
.then(function (processedEvent) {
if (processedEvent === null) {
reject('`beforeSend` returned `null`, will not send event.');
return;
}
// From here on we are really async
_this._getBackend().sendEvent(processedEvent);
resolve(processedEvent);
})
.catch(function (e) {
reject("beforeSend rejected with " + e);
});
};
/**
* @inheritDoc
*/
BaseClient.prototype.getIntegrations = function () {
return this.integrations || {};
};
/**
* @inheritDoc
*/
BaseClient.prototype.getIntegration = function (integration) {
try {
return this.integrations[integration.id] || null;
}
catch (_oO) {
logger_1.logger.warn("Cannot retrieve integration " + integration.id + " from the current Client");
return null;
}
};
return BaseClient;

@@ -417,0 +377,0 @@ }());

@@ -8,3 +8,3 @@ import { DsnComponents, DsnLike, DsnProtocol } from '@sentry/types';

user: string;
/** Private authorization key (deprecated, optional). */
/** private _authorization key (deprecated, optional). */
pass: string;

@@ -25,3 +25,3 @@ /** Hostname of the Sentry instance. */

* By default, this will render the public representation without the password
* component. To get the deprecated private representation, set `withPassword`
* component. To get the deprecated private _representation, set `withPassword`
* to true.

@@ -33,7 +33,7 @@ *

/** Parses a string into this Dsn. */
private fromString;
private _fromString;
/** Maps Dsn components into this instance. */
private fromComponents;
private _fromComponents;
/** Validates this Dsn and throws on error. */
private validate;
private _validate;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var is_1 = require("@sentry/utils/is");
var object_1 = require("@sentry/utils/object");
var error_1 = require("./error");
var error_1 = require("@sentry/utils/error");
/** Regular expression used to parse a Dsn. */
var DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w\.-]+)(?::(\d+))?\/(.+)/;
/** Error message */
var ERROR_MESSAGE = 'Invalid Dsn';
/** The Sentry Dsn, identifying a Sentry instance and project. */

@@ -14,8 +14,8 @@ var Dsn = /** @class */ (function () {

if (typeof from === 'string') {
this.fromString(from);
this._fromString(from);
}
else {
this.fromComponents(from);
this._fromComponents(from);
}
this.validate();
this._validate();
}

@@ -26,3 +26,3 @@ /**

* By default, this will render the public representation without the password
* component. To get the deprecated private representation, set `withPassword`
* component. To get the deprecated private _representation, set `withPassword`
* to true.

@@ -40,6 +40,6 @@ *

/** Parses a string into this Dsn. */
Dsn.prototype.fromString = function (str) {
Dsn.prototype._fromString = function (str) {
var match = DSN_REGEX.exec(str);
if (!match) {
throw new error_1.SentryError('Invalid Dsn');
throw new error_1.SentryError(ERROR_MESSAGE);
}

@@ -54,6 +54,6 @@ 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];

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

@@ -68,24 +68,14 @@ this.user = components.user;

/** Validates this Dsn and throws on error. */
Dsn.prototype.validate = function () {
var e_1, _a;
try {
for (var _b = tslib_1.__values(['protocol', 'user', 'host', 'projectId']), _c = _b.next(); !_c.done; _c = _b.next()) {
var component = _c.value;
if (!this[component]) {
throw new error_1.SentryError("Invalid Dsn: Missing " + component);
}
Dsn.prototype._validate = function () {
var _this = this;
['protocol', 'user', 'host', 'projectId'].forEach(function (component) {
if (!_this[component]) {
throw new error_1.SentryError(ERROR_MESSAGE);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
});
if (this.protocol !== 'http' && this.protocol !== 'https') {
throw new error_1.SentryError("Invalid Dsn: Unsupported protocol \"" + this.protocol + "\"");
throw new error_1.SentryError(ERROR_MESSAGE);
}
if (this.port && is_1.isNaN(parseInt(this.port, 10))) {
throw new error_1.SentryError("Invalid Dsn: Invalid port number \"" + this.port + "\"");
if (this.port && Number.isNaN(parseInt(this.port, 10))) {
throw new error_1.SentryError(ERROR_MESSAGE);
}

@@ -92,0 +82,0 @@ };

@@ -7,5 +7,2 @@ export { addBreadcrumb, captureException, captureEvent, captureMessage, configureScope, withScope, } from '@sentry/minimal';

export { Dsn } from './dsn';
export { SentryError } from './error';
export { PromiseBuffer } from './promisebuffer';
export { Backend, Client, LogLevel, Options } from './interfaces';
export { initAndBind, ClientClass } from './sdk';

@@ -12,0 +9,0 @@ export { NoopTransport } from './transports/noop';

@@ -24,8 +24,2 @@ "use strict";

exports.Dsn = dsn_1.Dsn;
var error_1 = require("./error");
exports.SentryError = error_1.SentryError;
var promisebuffer_1 = require("./promisebuffer");
exports.PromiseBuffer = promisebuffer_1.PromiseBuffer;
var interfaces_1 = require("./interfaces");
exports.LogLevel = interfaces_1.LogLevel;
var sdk_1 = require("./sdk");

@@ -32,0 +26,0 @@ exports.initAndBind = sdk_1.initAndBind;

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

import { Integration } from '@sentry/types';
import { Options } from './interfaces';
import { Integration, Options } from '@sentry/types';
export declare const installedIntegrations: string[];

@@ -11,3 +10,3 @@ /** Map of integrations assigned to a client */

/** Setup given integration */
export declare function setupIntegration(integration: Integration, options: Options): void;
export declare function setupIntegration(integration: Integration): void;
/**

@@ -14,0 +13,0 @@ * Given a list of integration instances this installs them all. When `withDefaults` is set to `true` then all default

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var hub_1 = require("@sentry/hub");
var logger_1 = require("@sentry/utils/logger");

@@ -8,3 +9,2 @@ exports.installedIntegrations = [];

function getIntegrationsToSetup(options) {
var e_1, _a, e_2, _b;
var defaultIntegrations = (options.defaultIntegrations && tslib_1.__spread(options.defaultIntegrations)) || [];

@@ -14,39 +14,19 @@ var userIntegrations = options.integrations;

if (Array.isArray(userIntegrations)) {
var userIntegrationsNames = userIntegrations.map(function (i) { return i.name; });
var pickedIntegrationsNames = [];
try {
// Leave only unique default integrations, that were not overridden with provided user integrations
for (var defaultIntegrations_1 = tslib_1.__values(defaultIntegrations), defaultIntegrations_1_1 = defaultIntegrations_1.next(); !defaultIntegrations_1_1.done; defaultIntegrations_1_1 = defaultIntegrations_1.next()) {
var defaultIntegration = defaultIntegrations_1_1.value;
if (userIntegrationsNames.indexOf(getIntegrationName(defaultIntegration)) === -1 &&
pickedIntegrationsNames.indexOf(getIntegrationName(defaultIntegration)) === -1) {
integrations.push(defaultIntegration);
pickedIntegrationsNames.push(getIntegrationName(defaultIntegration));
}
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(function (defaultIntegration) {
if (userIntegrationsNames_1.indexOf(getIntegrationName(defaultIntegration)) === -1 &&
pickedIntegrationsNames_1.indexOf(getIntegrationName(defaultIntegration)) === -1) {
integrations.push(defaultIntegration);
pickedIntegrationsNames_1.push(getIntegrationName(defaultIntegration));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (defaultIntegrations_1_1 && !defaultIntegrations_1_1.done && (_a = defaultIntegrations_1.return)) _a.call(defaultIntegrations_1);
});
// Don't add same user integration twice
userIntegrations.forEach(function (userIntegration) {
if (pickedIntegrationsNames_1.indexOf(getIntegrationName(userIntegration)) === -1) {
integrations.push(userIntegration);
pickedIntegrationsNames_1.push(getIntegrationName(userIntegration));
}
finally { if (e_1) throw e_1.error; }
}
try {
// Don't add same user integration twice
for (var userIntegrations_1 = tslib_1.__values(userIntegrations), userIntegrations_1_1 = userIntegrations_1.next(); !userIntegrations_1_1.done; userIntegrations_1_1 = userIntegrations_1.next()) {
var userIntegration = userIntegrations_1_1.value;
if (pickedIntegrationsNames.indexOf(getIntegrationName(userIntegration)) === -1) {
integrations.push(userIntegration);
pickedIntegrationsNames.push(getIntegrationName(userIntegration));
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (userIntegrations_1_1 && !userIntegrations_1_1.done && (_b = userIntegrations_1.return)) _b.call(userIntegrations_1);
}
finally { if (e_2) throw e_2.error; }
}
});
}

@@ -64,19 +44,7 @@ else if (typeof userIntegrations === 'function') {

/** Setup given integration */
function setupIntegration(integration, options) {
function setupIntegration(integration) {
if (exports.installedIntegrations.indexOf(getIntegrationName(integration)) !== -1) {
return;
}
try {
integration.setupOnce();
}
catch (_Oo) {
/** @deprecated */
// TODO: Remove in v5
// tslint:disable:deprecation
if (integration.install) {
logger_1.logger.warn("Integration " + getIntegrationName(integration) + ": The install method is deprecated. Use \"setupOnce\".");
integration.install(options);
}
// tslint:enable:deprecation
}
integration.setupOnce(hub_1.addGlobalEventProcessor, hub_1.getCurrentHub);
exports.installedIntegrations.push(getIntegrationName(integration));

@@ -96,3 +64,3 @@ logger_1.logger.log("Integration installed: " + getIntegrationName(integration));

integrations[getIntegrationName(integration)] = integration;
setupIntegration(integration, options);
setupIntegration(integration);
});

@@ -99,0 +67,0 @@ return integrations;

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

import { Integration, SentryEvent } from '@sentry/types';
import { Integration } from '@sentry/types';
/** JSDoc */

@@ -11,3 +11,3 @@ interface InboundFiltersOptions {

export declare class InboundFilters implements Integration {
private readonly options;
private readonly _options;
/**

@@ -21,3 +21,3 @@ * @inheritDoc

static id: string;
constructor(options?: InboundFiltersOptions);
constructor(_options?: InboundFiltersOptions);
/**

@@ -28,20 +28,20 @@ * @inheritDoc

/** JSDoc */
shouldDropEvent(event: SentryEvent, options: InboundFiltersOptions): boolean;
private _shouldDropEvent;
/** JSDoc */
isSentryError(event: SentryEvent, options?: InboundFiltersOptions): boolean;
private _isSentryError;
/** JSDoc */
isIgnoredError(event: SentryEvent, options?: InboundFiltersOptions): boolean;
private _isIgnoredError;
/** JSDoc */
isBlacklistedUrl(event: SentryEvent, options?: InboundFiltersOptions): boolean;
private _isBlacklistedUrl;
/** JSDoc */
isWhitelistedUrl(event: SentryEvent, options?: InboundFiltersOptions): boolean;
private _isWhitelistedUrl;
/** JSDoc */
mergeOptions(clientOptions?: InboundFiltersOptions): InboundFiltersOptions;
private _mergeOptions;
/** JSDoc */
private isMatchingPattern;
private _isMatchingPattern;
/** JSDoc */
private getPossibleEventMessages;
private _getPossibleEventMessages;
/** JSDoc */
private getEventFilterUrl;
private _getEventFilterUrl;
}
export {};

@@ -8,3 +8,2 @@ "use strict";

var misc_1 = require("@sentry/utils/misc");
var string_1 = require("@sentry/utils/string");
// "Script error." is hard coded into browsers for errors that it can't read.

@@ -15,5 +14,5 @@ // this is the result of a script being pulled in from an external domain and CORS.

var InboundFilters = /** @class */ (function () {
function InboundFilters(options) {
if (options === void 0) { options = {}; }
this.options = options;
function InboundFilters(_options) {
if (_options === void 0) { _options = {}; }
this._options = _options;
/**

@@ -28,39 +27,35 @@ * @inheritDoc

InboundFilters.prototype.setupOnce = function () {
var _this = this;
hub_1.addGlobalEventProcessor(function (event) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var hub, self, client, clientOptions, options;
return tslib_1.__generator(this, function (_a) {
hub = hub_1.getCurrentHub();
if (!hub) {
return [2 /*return*/, event];
hub_1.addGlobalEventProcessor(function (event) {
var hub = hub_1.getCurrentHub();
if (!hub) {
return event;
}
var self = hub.getIntegration(InboundFilters);
if (self) {
var client = hub.getClient();
var clientOptions = client ? client.getOptions() : {};
var options = self._mergeOptions(clientOptions);
if (self._shouldDropEvent(event, options)) {
return null;
}
self = hub.getIntegration(InboundFilters);
if (self) {
client = hub.getClient();
clientOptions = client ? client.getOptions() : {};
options = self.mergeOptions(clientOptions);
if (self.shouldDropEvent(event, options)) {
return [2 /*return*/, null];
}
}
return [2 /*return*/, event];
});
}); });
}
return event;
});
};
/** JSDoc */
InboundFilters.prototype.shouldDropEvent = function (event, options) {
if (this.isSentryError(event, options)) {
InboundFilters.prototype._shouldDropEvent = function (event, options) {
if (this._isSentryError(event, options)) {
logger_1.logger.warn("Event dropped due to being internal Sentry Error.\nEvent: " + misc_1.getEventDescription(event));
return true;
}
if (this.isIgnoredError(event, options)) {
if (this._isIgnoredError(event, options)) {
logger_1.logger.warn("Event dropped due to being matched by `ignoreErrors` option.\nEvent: " + misc_1.getEventDescription(event));
return true;
}
if (this.isBlacklistedUrl(event, options)) {
logger_1.logger.warn("Event dropped due to being matched by `blacklistUrls` option.\nEvent: " + misc_1.getEventDescription(event) + ".\nUrl: " + this.getEventFilterUrl(event));
if (this._isBlacklistedUrl(event, options)) {
logger_1.logger.warn("Event dropped due to being matched by `blacklistUrls` option.\nEvent: " + misc_1.getEventDescription(event) + ".\nUrl: " + this._getEventFilterUrl(event));
return true;
}
if (!this.isWhitelistedUrl(event, options)) {
logger_1.logger.warn("Event dropped due to not being matched by `whitelistUrls` option.\nEvent: " + misc_1.getEventDescription(event) + ".\nUrl: " + this.getEventFilterUrl(event));
if (!this._isWhitelistedUrl(event, options)) {
logger_1.logger.warn("Event dropped due to not being matched by `whitelistUrls` option.\nEvent: " + misc_1.getEventDescription(event) + ".\nUrl: " + this._getEventFilterUrl(event));
return true;

@@ -71,3 +66,3 @@ }

/** JSDoc */
InboundFilters.prototype.isSentryError = function (event, options) {
InboundFilters.prototype._isSentryError = function (event, options) {
if (options === void 0) { options = {}; }

@@ -86,3 +81,3 @@ if (!options.ignoreInternal) {

/** JSDoc */
InboundFilters.prototype.isIgnoredError = function (event, options) {
InboundFilters.prototype._isIgnoredError = function (event, options) {
var _this = this;

@@ -93,9 +88,9 @@ if (options === void 0) { options = {}; }

}
return this.getPossibleEventMessages(event).some(function (message) {
return this._getPossibleEventMessages(event).some(function (message) {
// Not sure why TypeScript complains here...
return options.ignoreErrors.some(function (pattern) { return _this.isMatchingPattern(message, pattern); });
return options.ignoreErrors.some(function (pattern) { return _this._isMatchingPattern(message, pattern); });
});
};
/** JSDoc */
InboundFilters.prototype.isBlacklistedUrl = function (event, options) {
InboundFilters.prototype._isBlacklistedUrl = function (event, options) {
var _this = this;

@@ -107,7 +102,7 @@ if (options === void 0) { options = {}; }

}
var url = this.getEventFilterUrl(event);
return !url ? false : options.blacklistUrls.some(function (pattern) { return _this.isMatchingPattern(url, pattern); });
var url = this._getEventFilterUrl(event);
return !url ? false : options.blacklistUrls.some(function (pattern) { return _this._isMatchingPattern(url, pattern); });
};
/** JSDoc */
InboundFilters.prototype.isWhitelistedUrl = function (event, options) {
InboundFilters.prototype._isWhitelistedUrl = function (event, options) {
var _this = this;

@@ -119,33 +114,31 @@ if (options === void 0) { options = {}; }

}
var url = this.getEventFilterUrl(event);
return !url ? true : options.whitelistUrls.some(function (pattern) { return _this.isMatchingPattern(url, pattern); });
var url = this._getEventFilterUrl(event);
return !url ? true : options.whitelistUrls.some(function (pattern) { return _this._isMatchingPattern(url, pattern); });
};
/** JSDoc */
InboundFilters.prototype.mergeOptions = function (clientOptions) {
InboundFilters.prototype._mergeOptions = function (clientOptions) {
if (clientOptions === void 0) { clientOptions = {}; }
return {
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: tslib_1.__spread((this.options.whitelistUrls || []), (clientOptions.whitelistUrls || [])),
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: tslib_1.__spread((this._options.whitelistUrls || []), (clientOptions.whitelistUrls || [])),
};
};
/** JSDoc */
InboundFilters.prototype.isMatchingPattern = function (value, pattern) {
InboundFilters.prototype._isMatchingPattern = function (value, pattern) {
if (is_1.isRegExp(pattern)) {
return pattern.test(value);
}
else if (typeof pattern === 'string') {
return string_1.includes(value, pattern);
if (typeof pattern === 'string') {
return value.includes(pattern);
}
else {
return false;
}
return false;
};
/** JSDoc */
InboundFilters.prototype.getPossibleEventMessages = function (event) {
InboundFilters.prototype._getPossibleEventMessages = function (event) {
if (event.message) {
return [event.message];
}
else if (event.exception) {
if (event.exception) {
try {

@@ -161,8 +154,6 @@ // tslint:disable-next-line:no-unsafe-any

}
else {
return [];
}
return [];
};
/** JSDoc */
InboundFilters.prototype.getEventFilterUrl = function (event) {
InboundFilters.prototype._getEventFilterUrl = function (event) {
try {

@@ -174,3 +165,3 @@ if (event.stacktrace) {

}
else if (event.exception) {
if (event.exception) {
// tslint:disable:no-unsafe-any

@@ -180,5 +171,3 @@ var frames_2 = event.exception.values[0].stacktrace.frames;

}
else {
return null;
}
return null;
}

@@ -185,0 +174,0 @@ catch (oO) {

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

export { Dedupe } from './dedupe';
export { FunctionToString } from './functiontostring';
export { SDKInformation } from './sdkinformation';
export { InboundFilters } from './inboundfilters';
export { ExtraErrorData } from './extraerrordata';
export { Debug } from './pluggable/debug';
export { RewriteFrames } from './pluggable/rewriteframes';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var dedupe_1 = require("./dedupe");
exports.Dedupe = dedupe_1.Dedupe;
var functiontostring_1 = require("./functiontostring");
exports.FunctionToString = functiontostring_1.FunctionToString;
var sdkinformation_1 = require("./sdkinformation");
exports.SDKInformation = sdkinformation_1.SDKInformation;
var inboundfilters_1 = require("./inboundfilters");
exports.InboundFilters = inboundfilters_1.InboundFilters;
var extraerrordata_1 = require("./extraerrordata");
exports.ExtraErrorData = extraerrordata_1.ExtraErrorData;
var debug_1 = require("./pluggable/debug");
exports.Debug = debug_1.Debug;
var rewriteframes_1 = require("./pluggable/rewriteframes");
exports.RewriteFrames = rewriteframes_1.RewriteFrames;
//# sourceMappingURL=index.js.map

@@ -1,6 +0,4 @@

import { Client, Options } from './interfaces';
import { Client, Options } from '@sentry/types';
/** A class object that can instanciate Client objects. */
export interface ClientClass<F extends Client, O extends Options> {
new (options: O): F;
}
export declare type ClientClass<F extends Client, O extends Options> = new (options: O) => F;
/**

@@ -12,4 +10,3 @@ * Internal function to create a new SDK client instance. The client is

* @param options Options to pass to the client.
* @returns The installed and bound client instance.
*/
export declare function initAndBind<F extends Client, O extends Options>(clientClass: ClientClass<F, O>, options: O): void;

@@ -11,3 +11,2 @@ "use strict";

* @param options Options to pass to the client.
* @returns The installed and bound client instance.
*/

@@ -18,7 +17,5 @@ function initAndBind(clientClass, options) {

}
var client = new clientClass(options);
hub_1.getCurrentHub().bindClient(client);
client.install();
hub_1.getCurrentHub().bindClient(new clientClass(options));
}
exports.initAndBind = initAndBind;
//# sourceMappingURL=sdk.js.map

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

import { SentryResponse, Transport } from '@sentry/types';
import { Event, Response, Transport } from '@sentry/types';
/** Noop transport */

@@ -7,3 +7,3 @@ export declare class NoopTransport implements Transport {

*/
sendEvent(_: string): Promise<SentryResponse>;
sendEvent(_: Event): Promise<Response>;
/**

@@ -10,0 +10,0 @@ * @inheritDoc

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

import { DsnLike } from '@sentry/types/esm';
import { DsnLike } from '@sentry/types';
import { Dsn } from './dsn';

@@ -7,3 +7,3 @@ /** Helper class to provide urls to different Sentry endpoints. */

/** The internally used Dsn object. */
private readonly dsnObject;
private readonly _dsnObject;
/** Create a new instance of API */

@@ -18,3 +18,3 @@ constructor(dsn: DsnLike);

/** Returns the base path of the url including the port. */
private getBaseUrl;
private _getBaseUrl;
/** Returns only the path component for the store endpoint. */

@@ -21,0 +21,0 @@ getStoreEndpointPath(): string;

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

import { urlEncode } from '@sentry/utils/esm/object';
import { urlEncode } from '@sentry/utils/object';
import { Dsn } from './dsn';

@@ -9,15 +9,15 @@ const SENTRY_API_VERSION = '7';

this.dsn = dsn;
this.dsnObject = new Dsn(dsn);
this._dsnObject = new Dsn(dsn);
}
/** Returns the Dsn object. */
getDsn() {
return this.dsnObject;
return this._dsnObject;
}
/** Returns a string with auth headers in the url to the store endpoint. */
getStoreEndpoint() {
return `${this.getBaseUrl()}${this.getStoreEndpointPath()}`;
return `${this._getBaseUrl()}${this.getStoreEndpointPath()}`;
}
/** Returns the store endpoint with auth added in url encoded. */
getStoreEndpointWithUrlEncodedAuth() {
const dsn = this.dsnObject;
const dsn = this._dsnObject;
const auth = {

@@ -32,4 +32,4 @@ sentry_key: dsn.user,

/** Returns the base path of the url including the port. */
getBaseUrl() {
const dsn = this.dsnObject;
_getBaseUrl() {
const dsn = this._dsnObject;
const protocol = dsn.protocol ? `${dsn.protocol}:` : '';

@@ -41,3 +41,3 @@ const port = dsn.port ? `:${dsn.port}` : '';

getStoreEndpointPath() {
const dsn = this.dsnObject;
const dsn = this._dsnObject;
return `${dsn.path ? `/${dsn.path}` : ''}/api/${dsn.projectId}/store/`;

@@ -47,3 +47,3 @@ }

getRequestHeaders(clientName, clientVersion) {
const dsn = this.dsnObject;
const dsn = this._dsnObject;
const header = [`Sentry sentry_version=${SENTRY_API_VERSION}`];

@@ -63,4 +63,4 @@ header.push(`sentry_timestamp=${new Date().getTime()}`);

getReportDialogEndpoint(dialogOptions = {}) {
const dsn = this.dsnObject;
const endpoint = `${this.getBaseUrl()}${dsn.path ? `/${dsn.path}` : ''}/api/embed/error-page/`;
const dsn = this._dsnObject;
const endpoint = `${this._getBaseUrl()}${dsn.path ? `/${dsn.path}` : ''}/api/embed/error-page/`;
const encodedOptions = [];

@@ -67,0 +67,0 @@ encodedOptions.push(`dsn=${dsn.toString()}`);

@@ -1,17 +0,53 @@

import { Scope } from '@sentry/hub/esm';
import { Breadcrumb, SentryEvent, SentryEventHint, SentryResponse, Severity, Transport } from '@sentry/types/esm';
import { Backend, Options } from './interfaces';
/** A class object that can instanciate Backend objects. */
export interface BackendClass<B extends Backend, O extends Options> {
new (options: O): B;
import { Event, EventHint, Options, Severity, Transport } from '@sentry/types';
import { SyncPromise } from '@sentry/utils/syncpromise';
/**
* Internal platform-dependent Sentry SDK Backend.
*
* While {@link Client} contains business logic specific to an SDK, the
* Backend offers platform specific implementations for low-level operations.
* These are persisting and loading information, sending events, and hooking
* into the environment.
*
* Backends receive a handle to the Client in their constructor. When a
* Backend automatically generates events, it must pass them to
* the Client for validation and processing first.
*
* Usually, the Client will be of corresponding type, e.g. NodeBackend
* receives NodeClient. However, higher-level SDKs can choose to instanciate
* multiple Backends and delegate tasks between them. In this case, an event
* generated by one backend might very well be sent by another one.
*
* The client also provides access to options via {@link Client.getOptions}.
* @hidden
*/
export interface Backend {
/** Creates a {@link Event} from an exception. */
eventFromException(exception: any, hint?: EventHint): SyncPromise<Event>;
/** Creates a {@link Event} from a plain message. */
eventFromMessage(message: string, level?: Severity, hint?: EventHint): SyncPromise<Event>;
/** Submits the event to Sentry */
sendEvent(event: Event): void;
/**
* Returns the transport that is used by the backend.
* Please note that the transport gets lazy initialized so it will only be there once the first event has been sent.
*
* @returns The transport.
*/
getTransport(): Transport;
}
/**
* A class object that can instanciate Backend objects.
* @hidden
*/
export declare type BackendClass<B extends Backend, O extends Options> = new (options: O) => B;
/**
* This is the base implemention of a Backend.
* @hidden
*/
export declare abstract class BaseBackend<O extends Options> implements Backend {
/** Options passed to the SDK. */
protected readonly options: O;
protected readonly _options: O;
/** Cached transport used internally. */
protected transport: Transport;
/** Creates a new browser backend instance. */
protected _transport: Transport;
/** Creates a new backend instance. */
constructor(options: O);

@@ -21,27 +57,19 @@ /**

*/
protected setupTransport(): Transport;
protected _setupTransport(): Transport;
/**
* @inheritDoc
*/
eventFromException(_exception: any, _hint?: SentryEventHint): Promise<SentryEvent>;
eventFromException(_exception: any, _hint?: EventHint): SyncPromise<Event>;
/**
* @inheritDoc
*/
eventFromMessage(_message: string, _level?: Severity, _hint?: SentryEventHint): Promise<SentryEvent>;
eventFromMessage(_message: string, _level?: Severity, _hint?: EventHint): SyncPromise<Event>;
/**
* @inheritDoc
*/
sendEvent(event: SentryEvent): Promise<SentryResponse>;
sendEvent(event: Event): void;
/**
* @inheritDoc
*/
storeBreadcrumb(_: Breadcrumb): boolean;
/**
* @inheritDoc
*/
storeScope(_: Scope): void;
/**
* @inheritDoc
*/
getTransport(): Transport;
}

@@ -1,16 +0,16 @@

import { logger } from '@sentry/utils/esm/logger';
import { serialize } from '@sentry/utils/esm/object';
import { SentryError } from './error';
import { SentryError } from '@sentry/utils/error';
import { logger } from '@sentry/utils/logger';
import { NoopTransport } from './transports/noop';
/**
* This is the base implemention of a Backend.
* @hidden
*/
export class BaseBackend {
/** Creates a new browser backend instance. */
/** Creates a new backend instance. */
constructor(options) {
this.options = options;
if (!this.options.dsn) {
this._options = options;
if (!this._options.dsn) {
logger.warn('No DSN provided, backend will not do anything.');
}
this.transport = this.setupTransport();
this._transport = this._setupTransport();
}

@@ -20,3 +20,3 @@ /**

*/
setupTransport() {
_setupTransport() {
return new NoopTransport();

@@ -27,3 +27,3 @@ }

*/
async eventFromException(_exception, _hint) {
eventFromException(_exception, _hint) {
throw new SentryError('Backend has to implement `eventFromException` method');

@@ -34,3 +34,3 @@ }

*/
async eventFromMessage(_message, _level, _hint) {
eventFromMessage(_message, _level, _hint) {
throw new SentryError('Backend has to implement `eventFromMessage` method');

@@ -41,11 +41,6 @@ }

*/
async sendEvent(event) {
// TODO: Remove with v5
// tslint:disable-next-line
if (this.transport.captureEvent) {
// tslint:disable-next-line
return this.transport.captureEvent(event);
}
// --------------------
return this.transport.sendEvent(serialize(event));
sendEvent(event) {
this._transport.sendEvent(event).catch(reason => {
logger.error(`Error while sending event: ${reason}`);
});
}

@@ -55,18 +50,6 @@ /**

*/
storeBreadcrumb(_) {
return true;
}
/**
* @inheritDoc
*/
storeScope(_) {
// Noop
}
/**
* @inheritDoc
*/
getTransport() {
return this.transport;
return this._transport;
}
}
//# sourceMappingURL=basebackend.js.map

@@ -1,8 +0,7 @@

import { Scope } from '@sentry/hub/esm';
import { Breadcrumb, Integration, IntegrationClass, SentryBreadcrumbHint, SentryEvent, SentryEventHint, SentryResponse, Severity } from '@sentry/types/esm';
import { BackendClass } from './basebackend';
import { Scope } from '@sentry/hub';
import { Client, Event, EventHint, Integration, IntegrationClass, Options, Severity } from '@sentry/types';
import { SyncPromise } from '@sentry/utils/syncpromise';
import { Backend, BackendClass } from './basebackend';
import { Dsn } from './dsn';
import { IntegrationIndex } from './integration';
import { Backend, Client, Options } from './interfaces';
import { PromiseBuffer } from './promisebuffer';
/**

@@ -46,19 +45,11 @@ * Base implementation for all JavaScript SDK clients.

*/
private readonly backend;
protected readonly _backend: B;
/** Options passed to the SDK. */
private readonly options;
/**
* The client Dsn, if specified in options. Without this Dsn, the SDK will be
* disabled.
*/
private readonly dsn?;
/**
* Stores whether installation has been performed and was successful. Before
* installing, this is undefined. Then it contains the success state.
*/
private installed?;
protected readonly _options: O;
/** The client Dsn, if specified in options. Without this Dsn, the SDK will be disabled. */
protected readonly _dsn?: Dsn;
/** Array of used integrations. */
private readonly integrations;
/** A simple buffer holding all requests. */
protected readonly buffer: PromiseBuffer<SentryResponse>;
protected readonly _integrations: IntegrationIndex;
/** Is the client still processing a call? */
protected _processing: boolean;
/**

@@ -74,31 +65,41 @@ * Initializes this client instance.

*/
install(): boolean;
captureException(exception: any, hint?: EventHint, scope?: Scope): string | undefined;
/**
* @inheritDoc
*/
captureException(exception: any, hint?: SentryEventHint, scope?: Scope): Promise<SentryResponse>;
captureMessage(message: string, level?: Severity, hint?: EventHint, scope?: Scope): string | undefined;
/**
* @inheritDoc
*/
captureMessage(message: string, level?: Severity, hint?: SentryEventHint, scope?: Scope): Promise<SentryResponse>;
captureEvent(event: Event, hint?: EventHint, scope?: Scope): string | undefined;
/**
* @inheritDoc
*/
captureEvent(event: SentryEvent, hint?: SentryEventHint, scope?: Scope): Promise<SentryResponse>;
getDsn(): Dsn | undefined;
/**
* @inheritDoc
*/
addBreadcrumb(breadcrumb: Breadcrumb, hint?: SentryBreadcrumbHint, scope?: Scope): void;
getOptions(): O;
/**
* @inheritDoc
*/
getDsn(): Dsn | undefined;
flush(timeout?: number): Promise<boolean>;
/**
* @inheritDoc
*/
getOptions(): O;
close(timeout?: number): Promise<boolean>;
/**
* @inheritDoc
*/
getIntegrations(): IntegrationIndex;
/**
* @inheritDoc
*/
getIntegration<T extends Integration>(integration: IntegrationClass<T>): T | null;
/** Waits for the client to be done with processing. */
protected _isClientProcessing(counter?: number): Promise<boolean>;
/** Returns the current backend. */
protected getBackend(): B;
protected _getBackend(): B;
/** Determines whether this SDK is enabled and a valid Dsn is present. */
protected isEnabled(): boolean;
protected _isEnabled(): boolean;
/**

@@ -118,3 +119,3 @@ * Adds common information to events.

*/
protected prepareEvent(event: SentryEvent, scope?: Scope, hint?: SentryEventHint): Promise<SentryEvent | null>;
protected _prepareEvent(event: Event, scope?: Scope, hint?: EventHint): SyncPromise<Event | null>;
/**

@@ -127,30 +128,13 @@ * Processes an event (either error or message) and sends it to Sentry.

*
* The returned event status offers clues to whether the event was sent to
* Sentry and accepted there. If the {@link Options.shouldSend} hook returns
* `false`, the status will be {@link SendStatus.Skipped}. If the rate limit
* was exceeded, the status will be {@link SendStatus.RateLimit}.
*
* @param event The event to send to Sentry.
* @param send A function to actually send the event.
* @param hint May contain additional informartion about the original exception.
* @param scope A scope containing event metadata.
* @param hint May contain additional informartion about the original exception.
* @returns A Promise that resolves with the event status.
* @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send.
*/
protected processEvent(event: SentryEvent, send: (finalEvent: SentryEvent) => Promise<SentryResponse>, hint?: SentryEventHint, scope?: Scope): Promise<SentryResponse>;
protected _processEvent(event: Event, hint?: EventHint, scope?: Scope): SyncPromise<Event>;
/**
* @inheritDoc
* Resolves before send Promise and calls resolve/reject on parent SyncPromise.
*/
flush(timeout?: number): Promise<boolean>;
/**
* @inheritDoc
*/
close(timeout?: number): Promise<boolean>;
/**
* @inheritDoc
*/
getIntegrations(): IntegrationIndex;
/**
* @inheritDoc
*/
getIntegration<T extends Integration>(integration: IntegrationClass<T>): T | null;
private _handleAsyncBeforeSend;
}

@@ -1,25 +0,10 @@

import { Status, } from '@sentry/types/esm';
import { forget } from '@sentry/utils/esm/async';
import { isPrimitive } from '@sentry/utils/esm/is';
import { logger } from '@sentry/utils/esm/logger';
import { consoleSandbox, uuid4 } from '@sentry/utils/esm/misc';
import { truncate } from '@sentry/utils/esm/string';
import * as tslib_1 from "tslib";
import { isPrimitive, isThenable } from '@sentry/utils/is';
import { logger } from '@sentry/utils/logger';
import { uuid4 } from '@sentry/utils/misc';
import { truncate } from '@sentry/utils/string';
import { SyncPromise } from '@sentry/utils/syncpromise';
import { Dsn } from './dsn';
import { setupIntegrations } from './integration';
import { PromiseBuffer } from './promisebuffer';
/**
* Default maximum number of breadcrumbs added to an event. Can be overwritten
* with {@link Options.maxBreadcrumbs}.
*/
const DEFAULT_BREADCRUMBS = 30;
/**
* Absolute maximum number of breadcrumbs added to an event. The
* `maxBreadcrumbs` option cannot be higher than this value.
*/
const MAX_BREADCRUMBS = 100;
/**
* By default, truncates URL values to 250 chars
*/
const MAX_URL_LENGTH = 250;
/**
* Base implementation for all JavaScript SDK clients.

@@ -64,12 +49,10 @@ *

constructor(backendClass, options) {
/** A simple buffer holding all requests. */
this.buffer = new PromiseBuffer();
this.backend = new backendClass(options);
this.options = options;
/** Is the client still processing a call? */
this._processing = false;
this._backend = new backendClass(options);
this._options = options;
if (options.dsn) {
this.dsn = new Dsn(options.dsn);
this._dsn = new Dsn(options.dsn);
}
// We have to setup the integrations in the constructor since we do not want
// that anyone needs to call client.install();
this.integrations = setupIntegrations(this.options);
this._integrations = setupIntegrations(this._options);
}

@@ -79,11 +62,18 @@ /**

*/
install() {
if (!this.isEnabled()) {
return (this.installed = false);
}
const backend = this.getBackend();
if (!this.installed && backend.install) {
backend.install();
}
return (this.installed = true);
captureException(exception, hint, scope) {
let eventId = hint && hint.event_id;
this._processing = true;
this._getBackend()
.eventFromException(exception, hint)
.then(event => this._processEvent(event, hint, scope))
.then(finalEvent => {
// We need to check for finalEvent in case beforeSend returned null
eventId = finalEvent && finalEvent.event_id;
this._processing = false;
})
.catch(reason => {
logger.log(reason);
this._processing = false;
});
return eventId;
}

@@ -93,7 +83,20 @@ /**

*/
async captureException(exception, hint, scope) {
return this.buffer.add((async () => {
const event = await this.getBackend().eventFromException(exception, hint);
return this.captureEvent(event, hint, scope);
})());
captureMessage(message, level, hint, scope) {
let eventId = hint && hint.event_id;
this._processing = true;
const promisedEvent = isPrimitive(message)
? this._getBackend().eventFromMessage(`${message}`, level, hint)
: this._getBackend().eventFromException(message, hint);
promisedEvent
.then(event => this._processEvent(event, hint, scope))
.then(finalEvent => {
// We need to check for finalEvent in case beforeSend returned null
eventId = finalEvent && finalEvent.event_id;
this._processing = false;
})
.catch(reason => {
logger.log(reason);
this._processing = false;
});
return eventId;
}

@@ -103,9 +106,16 @@ /**

*/
async captureMessage(message, level, hint, scope) {
return this.buffer.add((async () => {
const event = isPrimitive(message)
? await this.getBackend().eventFromMessage(`${message}`, level, hint)
: await this.getBackend().eventFromException(message, hint);
return this.captureEvent(event, hint, scope);
})());
captureEvent(event, hint, scope) {
let eventId = hint && hint.event_id;
this._processing = true;
this._processEvent(event, hint, scope)
.then(finalEvent => {
// We need to check for finalEvent in case beforeSend returned null
eventId = finalEvent && finalEvent.event_id;
this._processing = false;
})
.catch(reason => {
logger.log(reason);
this._processing = false;
});
return eventId;
}

@@ -115,7 +125,4 @@ /**

*/
async captureEvent(event, hint, scope) {
// Adding this here is technically not correct since if you call captureMessage/captureException it's already
// buffered. But since we not really need the count and we only need to know if the buffer is full or not,
// This is fine...
return this.buffer.add((async () => this.processEvent(event, async (finalEvent) => this.getBackend().sendEvent(finalEvent), hint, scope))());
getDsn() {
return this._dsn;
}

@@ -125,18 +132,4 @@ /**

*/
addBreadcrumb(breadcrumb, hint, scope) {
const { beforeBreadcrumb, maxBreadcrumbs = DEFAULT_BREADCRUMBS } = this.getOptions();
if (maxBreadcrumbs <= 0) {
return;
}
const timestamp = new Date().getTime() / 1000;
const mergedBreadcrumb = { timestamp, ...breadcrumb };
const finalBreadcrumb = beforeBreadcrumb
? consoleSandbox(() => beforeBreadcrumb(mergedBreadcrumb, hint))
: mergedBreadcrumb;
if (finalBreadcrumb === null) {
return;
}
if (this.getBackend().storeBreadcrumb(finalBreadcrumb) && scope) {
scope.addBreadcrumb(finalBreadcrumb, Math.min(maxBreadcrumbs, MAX_BREADCRUMBS));
}
getOptions() {
return this._options;
}

@@ -146,4 +139,11 @@ /**

*/
getDsn() {
return this.dsn;
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);
});
}

@@ -153,12 +153,55 @@ /**

*/
getOptions() {
return this.options;
close(timeout) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.flush(timeout).finally(() => {
this.getOptions().enabled = false;
});
});
}
/**
* @inheritDoc
*/
getIntegrations() {
return this._integrations || {};
}
/**
* @inheritDoc
*/
getIntegration(integration) {
try {
return this._integrations[integration.id] || null;
}
catch (_oO) {
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);
}
});
});
}
/** Returns the current backend. */
getBackend() {
return this.backend;
_getBackend() {
return this._backend;
}
/** Determines whether this SDK is enabled and a valid Dsn is present. */
isEnabled() {
return this.getOptions().enabled !== false && this.dsn !== undefined;
_isEnabled() {
return this.getOptions().enabled !== false && this._dsn !== undefined;
}

@@ -179,5 +222,5 @@ /**

*/
async prepareEvent(event, scope, hint) {
const { environment, maxBreadcrumbs = DEFAULT_BREADCRUMBS, release, dist } = this.getOptions();
const prepared = { ...event };
_prepareEvent(event, scope, hint) {
const { environment, release, dist, maxValueLength = 250 } = this.getOptions();
const prepared = Object.assign({}, event);
if (prepared.environment === undefined && environment !== undefined) {

@@ -193,11 +236,11 @@ prepared.environment = environment;

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

@@ -207,8 +250,11 @@ if (prepared.event_id === undefined) {

}
// We prepare the result here with a resolved Event.
let result = SyncPromise.resolve(prepared);
// This should be the last thing called, since we want that
// {@link Hub.addEventProcessor} gets the finished prepared event.
if (scope) {
return scope.applyToEvent(prepared, hint, Math.min(maxBreadcrumbs, MAX_BREADCRUMBS));
// In case we have a hub we reassign it.
result = scope.applyToEvent(prepared, hint);
}
return prepared;
return result;
}

@@ -222,116 +268,82 @@ /**

*
* The returned event status offers clues to whether the event was sent to
* Sentry and accepted there. If the {@link Options.shouldSend} hook returns
* `false`, the status will be {@link SendStatus.Skipped}. If the rate limit
* was exceeded, the status will be {@link SendStatus.RateLimit}.
*
* @param event The event to send to Sentry.
* @param send A function to actually send the event.
* @param hint May contain additional informartion about the original exception.
* @param scope A scope containing event metadata.
* @param hint May contain additional informartion about the original exception.
* @returns A Promise that resolves with the event status.
* @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send.
*/
async processEvent(event, send, hint, scope) {
if (!this.isEnabled()) {
return {
status: Status.Skipped,
};
_processEvent(event, hint, scope) {
const { beforeSend, sampleRate } = this.getOptions();
if (!this._isEnabled()) {
return SyncPromise.reject('SDK not enabled, will not send event.');
}
const { beforeSend, sampleRate } = this.getOptions();
// 1.0 === 100% events are sent
// 0.0 === 0% events are sent
if (typeof sampleRate === 'number' && Math.random() > sampleRate) {
return {
status: Status.Skipped,
};
return SyncPromise.reject('This event has been sampled, will not send event.');
}
const prepared = await this.prepareEvent(event, scope, hint);
if (prepared === null) {
return {
status: Status.Skipped,
};
}
let finalEvent = prepared;
try {
const isInternalException = hint && hint.data && hint.data.__sentry__ === true;
if (!isInternalException && beforeSend) {
finalEvent = await beforeSend(prepared, hint);
if (typeof finalEvent === 'undefined') {
logger.error('`beforeSend` method has to return `null` or a valid event');
return new SyncPromise((resolve, reject) => {
this._prepareEvent(event, scope, hint).then(prepared => {
if (prepared === null) {
reject('An event processor returned null, will not send event.');
return;
}
}
}
catch (exception) {
forget(this.captureException(exception, {
data: {
__sentry__: true,
},
originalException: exception,
}));
return {
reason: 'Event processing in beforeSend method threw an exception',
status: Status.Invalid,
};
}
if (finalEvent === null) {
return {
reason: 'Event dropped due to being discarded by beforeSend method',
status: Status.Skipped,
};
}
try {
const response = await send(finalEvent);
response.event = finalEvent;
if (response.status === Status.RateLimit) {
// TODO: Handle rate limits and maintain a queue. For now, we require SDK
// implementors to override this method and handle it themselves.
}
return response;
}
catch (error) {
// We have a catch here since the transport can reject the request internally.
// If we do not catch this here, we will run into an endless loop.
logger.error(`${error}`);
return {
reason: `${error}`,
status: Status.Failed,
};
}
let finalEvent = prepared;
try {
const isInternalException = hint && hint.data && hint.data.__sentry__ === true;
if (isInternalException || !beforeSend) {
this._getBackend().sendEvent(finalEvent);
resolve(finalEvent);
return;
}
const beforeSendResult = beforeSend(prepared, hint);
if (typeof beforeSendResult === 'undefined') {
logger.error('`beforeSend` method has to return `null` or a valid event.');
}
else if (isThenable(beforeSendResult)) {
this._handleAsyncBeforeSend(beforeSendResult, resolve, reject);
}
else {
finalEvent = beforeSendResult;
if (finalEvent === null) {
logger.log('`beforeSend` returned `null`, will not send event.');
resolve(null);
return;
}
// From here on we are really async
this._getBackend().sendEvent(finalEvent);
resolve(finalEvent);
}
}
catch (exception) {
this.captureException(exception, {
data: {
__sentry__: true,
},
originalException: exception,
});
reject('`beforeSend` throw an error, will not send event.');
}
});
});
}
/**
* @inheritDoc
* Resolves before send Promise and calls resolve/reject on parent SyncPromise.
*/
async flush(timeout) {
return (await Promise.all([
this.getBackend()
.getTransport()
.close(timeout),
this.buffer.drain(timeout),
])).reduce((prev, current) => prev && current);
_handleAsyncBeforeSend(beforeSend, resolve, reject) {
beforeSend
.then(processedEvent => {
if (processedEvent === null) {
reject('`beforeSend` returned `null`, will not send event.');
return;
}
// From here on we are really async
this._getBackend().sendEvent(processedEvent);
resolve(processedEvent);
})
.catch(e => {
reject(`beforeSend rejected with ${e}`);
});
}
/**
* @inheritDoc
*/
async close(timeout) {
return this.flush(timeout);
}
/**
* @inheritDoc
*/
getIntegrations() {
return this.integrations || {};
}
/**
* @inheritDoc
*/
getIntegration(integration) {
try {
return this.integrations[integration.id] || null;
}
catch (_oO) {
logger.warn(`Cannot retrieve integration ${integration.id} from the current Client`);
return null;
}
}
}
//# sourceMappingURL=baseclient.js.map

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

import { DsnComponents, DsnLike, DsnProtocol } from '@sentry/types/esm';
import { DsnComponents, DsnLike, DsnProtocol } from '@sentry/types';
/** The Sentry Dsn, identifying a Sentry instance and project. */

@@ -8,3 +8,3 @@ export declare class Dsn implements DsnComponents {

user: string;
/** Private authorization key (deprecated, optional). */
/** private _authorization key (deprecated, optional). */
pass: string;

@@ -25,3 +25,3 @@ /** Hostname of the Sentry instance. */

* By default, this will render the public representation without the password
* component. To get the deprecated private representation, set `withPassword`
* component. To get the deprecated private _representation, set `withPassword`
* to true.

@@ -33,7 +33,7 @@ *

/** Parses a string into this Dsn. */
private fromString;
private _fromString;
/** Maps Dsn components into this instance. */
private fromComponents;
private _fromComponents;
/** Validates this Dsn and throws on error. */
private validate;
private _validate;
}

@@ -1,6 +0,6 @@

import { isNaN } from '@sentry/utils/esm/is';
import { assign } from '@sentry/utils/esm/object';
import { SentryError } from './error';
import { SentryError } from '@sentry/utils/error';
/** Regular expression used to parse a Dsn. */
const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w\.-]+)(?::(\d+))?\/(.+)/;
/** Error message */
const ERROR_MESSAGE = 'Invalid Dsn';
/** The Sentry Dsn, identifying a Sentry instance and project. */

@@ -11,8 +11,8 @@ export class Dsn {

if (typeof from === 'string') {
this.fromString(from);
this._fromString(from);
}
else {
this.fromComponents(from);
this._fromComponents(from);
}
this.validate();
this._validate();
}

@@ -23,3 +23,3 @@ /**

* By default, this will render the public representation without the password
* component. To get the deprecated private representation, set `withPassword`
* component. To get the deprecated private _representation, set `withPassword`
* to true.

@@ -36,6 +36,6 @@ *

/** Parses a string into this Dsn. */
fromString(str) {
_fromString(str) {
const match = DSN_REGEX.exec(str);
if (!match) {
throw new SentryError('Invalid Dsn');
throw new SentryError(ERROR_MESSAGE);
}

@@ -50,6 +50,6 @@ const [protocol, user, pass = '', host, port = '', lastPath] = match.slice(1);

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

@@ -64,13 +64,13 @@ this.user = components.user;

/** Validates this Dsn and throws on error. */
validate() {
for (const component of ['protocol', 'user', 'host', 'projectId']) {
_validate() {
['protocol', 'user', 'host', 'projectId'].forEach(component => {
if (!this[component]) {
throw new SentryError(`Invalid Dsn: Missing ${component}`);
throw new SentryError(ERROR_MESSAGE);
}
}
});
if (this.protocol !== 'http' && this.protocol !== 'https') {
throw new SentryError(`Invalid Dsn: Unsupported protocol "${this.protocol}"`);
throw new SentryError(ERROR_MESSAGE);
}
if (this.port && isNaN(parseInt(this.port, 10))) {
throw new SentryError(`Invalid Dsn: Invalid port number "${this.port}"`);
if (this.port && Number.isNaN(parseInt(this.port, 10))) {
throw new SentryError(ERROR_MESSAGE);
}

@@ -77,0 +77,0 @@ }

@@ -1,3 +0,3 @@

export { addBreadcrumb, captureException, captureEvent, captureMessage, configureScope, withScope, } from '@sentry/minimal/esm';
export { addGlobalEventProcessor, getCurrentHub, Hub, getHubFromCarrier, Scope } from '@sentry/hub/esm';
export { addBreadcrumb, captureException, captureEvent, captureMessage, configureScope, withScope, } from '@sentry/minimal';
export { addGlobalEventProcessor, getCurrentHub, Hub, getHubFromCarrier, Scope } from '@sentry/hub';
export { API } from './api';

@@ -7,5 +7,2 @@ export { BaseClient } from './baseclient';

export { Dsn } from './dsn';
export { SentryError } from './error';
export { PromiseBuffer } from './promisebuffer';
export { Backend, Client, LogLevel, Options } from './interfaces';
export { initAndBind, ClientClass } from './sdk';

@@ -12,0 +9,0 @@ export { NoopTransport } from './transports/noop';

@@ -1,3 +0,3 @@

export { addBreadcrumb, captureException, captureEvent, captureMessage, configureScope, withScope, } from '@sentry/minimal/esm';
export { addGlobalEventProcessor, getCurrentHub, Hub, getHubFromCarrier, Scope } from '@sentry/hub/esm';
export { addBreadcrumb, captureException, captureEvent, captureMessage, configureScope, withScope, } from '@sentry/minimal';
export { addGlobalEventProcessor, getCurrentHub, Hub, getHubFromCarrier, Scope } from '@sentry/hub';
export { API } from './api';

@@ -7,5 +7,2 @@ export { BaseClient } from './baseclient';

export { Dsn } from './dsn';
export { SentryError } from './error';
export { PromiseBuffer } from './promisebuffer';
export { LogLevel } from './interfaces';
export { initAndBind } from './sdk';

@@ -12,0 +9,0 @@ export { NoopTransport } from './transports/noop';

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

import { Integration } from '@sentry/types/esm';
import { Options } from './interfaces';
import { Integration, Options } from '@sentry/types';
export declare const installedIntegrations: string[];

@@ -11,3 +10,3 @@ /** Map of integrations assigned to a client */

/** Setup given integration */
export declare function setupIntegration(integration: Integration, options: Options): void;
export declare function setupIntegration(integration: Integration): void;
/**

@@ -14,0 +13,0 @@ * Given a list of integration instances this installs them all. When `withDefaults` is set to `true` then all default

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

import { logger } from '@sentry/utils/esm/logger';
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/hub';
import { logger } from '@sentry/utils/logger';
export const installedIntegrations = [];

@@ -12,3 +13,3 @@ /** Gets integration to install */

// Leave only unique default integrations, that were not overridden with provided user integrations
for (const defaultIntegration of defaultIntegrations) {
defaultIntegrations.forEach(defaultIntegration => {
if (userIntegrationsNames.indexOf(getIntegrationName(defaultIntegration)) === -1 &&

@@ -19,5 +20,5 @@ pickedIntegrationsNames.indexOf(getIntegrationName(defaultIntegration)) === -1) {

}
}
});
// Don't add same user integration twice
for (const userIntegration of userIntegrations) {
userIntegrations.forEach(userIntegration => {
if (pickedIntegrationsNames.indexOf(getIntegrationName(userIntegration)) === -1) {

@@ -27,3 +28,3 @@ integrations.push(userIntegration);

}
}
});
}

@@ -40,19 +41,7 @@ else if (typeof userIntegrations === 'function') {

/** Setup given integration */
export function setupIntegration(integration, options) {
export function setupIntegration(integration) {
if (installedIntegrations.indexOf(getIntegrationName(integration)) !== -1) {
return;
}
try {
integration.setupOnce();
}
catch (_Oo) {
/** @deprecated */
// TODO: Remove in v5
// tslint:disable:deprecation
if (integration.install) {
logger.warn(`Integration ${getIntegrationName(integration)}: The install method is deprecated. Use "setupOnce".`);
integration.install(options);
}
// tslint:enable:deprecation
}
integration.setupOnce(addGlobalEventProcessor, getCurrentHub);
installedIntegrations.push(getIntegrationName(integration));

@@ -71,3 +60,3 @@ logger.log(`Integration installed: ${getIntegrationName(integration)}`);

integrations[getIntegrationName(integration)] = integration;
setupIntegration(integration, options);
setupIntegration(integration);
});

@@ -74,0 +63,0 @@ return integrations;

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

import { Integration } from '@sentry/types/esm';
import { Integration } from '@sentry/types';
/** Patch toString calls to return proper name for wrapped functions */

@@ -3,0 +3,0 @@ export declare class FunctionToString implements Integration {

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

import { Integration, SentryEvent } from '@sentry/types/esm';
import { Integration } from '@sentry/types';
/** JSDoc */

@@ -11,3 +11,3 @@ interface InboundFiltersOptions {

export declare class InboundFilters implements Integration {
private readonly options;
private readonly _options;
/**

@@ -21,3 +21,3 @@ * @inheritDoc

static id: string;
constructor(options?: InboundFiltersOptions);
constructor(_options?: InboundFiltersOptions);
/**

@@ -28,20 +28,20 @@ * @inheritDoc

/** JSDoc */
shouldDropEvent(event: SentryEvent, options: InboundFiltersOptions): boolean;
private _shouldDropEvent;
/** JSDoc */
isSentryError(event: SentryEvent, options?: InboundFiltersOptions): boolean;
private _isSentryError;
/** JSDoc */
isIgnoredError(event: SentryEvent, options?: InboundFiltersOptions): boolean;
private _isIgnoredError;
/** JSDoc */
isBlacklistedUrl(event: SentryEvent, options?: InboundFiltersOptions): boolean;
private _isBlacklistedUrl;
/** JSDoc */
isWhitelistedUrl(event: SentryEvent, options?: InboundFiltersOptions): boolean;
private _isWhitelistedUrl;
/** JSDoc */
mergeOptions(clientOptions?: InboundFiltersOptions): InboundFiltersOptions;
private _mergeOptions;
/** JSDoc */
private isMatchingPattern;
private _isMatchingPattern;
/** JSDoc */
private getPossibleEventMessages;
private _getPossibleEventMessages;
/** JSDoc */
private getEventFilterUrl;
private _getEventFilterUrl;
}
export {};

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

import { addGlobalEventProcessor, getCurrentHub } from '@sentry/hub/esm';
import { isRegExp } from '@sentry/utils/esm/is';
import { logger } from '@sentry/utils/esm/logger';
import { getEventDescription } from '@sentry/utils/esm/misc';
import { includes } from '@sentry/utils/esm/string';
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/hub';
import { isRegExp } from '@sentry/utils/is';
import { logger } from '@sentry/utils/logger';
import { getEventDescription } from '@sentry/utils/misc';
// "Script error." is hard coded into browsers for errors that it can't read.

@@ -11,4 +10,4 @@ // this is the result of a script being pulled in from an external domain and CORS.

export class InboundFilters {
constructor(options = {}) {
this.options = options;
constructor(_options = {}) {
this._options = _options;
/**

@@ -23,3 +22,3 @@ * @inheritDoc

setupOnce() {
addGlobalEventProcessor(async (event) => {
addGlobalEventProcessor((event) => {
const hub = getCurrentHub();

@@ -33,4 +32,4 @@ if (!hub) {

const clientOptions = client ? client.getOptions() : {};
const options = self.mergeOptions(clientOptions);
if (self.shouldDropEvent(event, options)) {
const options = self._mergeOptions(clientOptions);
if (self._shouldDropEvent(event, options)) {
return null;

@@ -43,17 +42,17 @@ }

/** JSDoc */
shouldDropEvent(event, options) {
if (this.isSentryError(event, options)) {
_shouldDropEvent(event, options) {
if (this._isSentryError(event, options)) {
logger.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${getEventDescription(event)}`);
return true;
}
if (this.isIgnoredError(event, options)) {
if (this._isIgnoredError(event, options)) {
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)}`);
if (this._isBlacklistedUrl(event, options)) {
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)}`);
if (!this._isWhitelistedUrl(event, options)) {
logger.warn(`Event dropped due to not being matched by \`whitelistUrls\` option.\nEvent: ${getEventDescription(event)}.\nUrl: ${this._getEventFilterUrl(event)}`);
return true;

@@ -64,3 +63,3 @@ }

/** JSDoc */
isSentryError(event, options = {}) {
_isSentryError(event, options = {}) {
if (!options.ignoreInternal) {

@@ -78,12 +77,12 @@ return false;

/** JSDoc */
isIgnoredError(event, options = {}) {
_isIgnoredError(event, options = {}) {
if (!options.ignoreErrors || !options.ignoreErrors.length) {
return false;
}
return this.getPossibleEventMessages(event).some(message =>
return this._getPossibleEventMessages(event).some(message =>
// Not sure why TypeScript complains here...
options.ignoreErrors.some(pattern => this.isMatchingPattern(message, pattern)));
options.ignoreErrors.some(pattern => this._isMatchingPattern(message, pattern)));
}
/** JSDoc */
isBlacklistedUrl(event, options = {}) {
_isBlacklistedUrl(event, options = {}) {
// TODO: Use Glob instead?

@@ -93,7 +92,7 @@ if (!options.blacklistUrls || !options.blacklistUrls.length) {

}
const url = this.getEventFilterUrl(event);
return !url ? false : options.blacklistUrls.some(pattern => this.isMatchingPattern(url, pattern));
const url = this._getEventFilterUrl(event);
return !url ? false : options.blacklistUrls.some(pattern => this._isMatchingPattern(url, pattern));
}
/** JSDoc */
isWhitelistedUrl(event, options = {}) {
_isWhitelistedUrl(event, options = {}) {
// TODO: Use Glob instead?

@@ -103,36 +102,34 @@ if (!options.whitelistUrls || !options.whitelistUrls.length) {

}
const url = this.getEventFilterUrl(event);
return !url ? true : options.whitelistUrls.some(pattern => this.isMatchingPattern(url, pattern));
const url = this._getEventFilterUrl(event);
return !url ? true : options.whitelistUrls.some(pattern => this._isMatchingPattern(url, pattern));
}
/** JSDoc */
mergeOptions(clientOptions = {}) {
_mergeOptions(clientOptions = {}) {
return {
blacklistUrls: [...(this.options.blacklistUrls || []), ...(clientOptions.blacklistUrls || [])],
blacklistUrls: [...(this._options.blacklistUrls || []), ...(clientOptions.blacklistUrls || [])],
ignoreErrors: [
...(this.options.ignoreErrors || []),
...(this._options.ignoreErrors || []),
...(clientOptions.ignoreErrors || []),
...DEFAULT_IGNORE_ERRORS,
],
ignoreInternal: typeof this.options.ignoreInternal !== 'undefined' ? this.options.ignoreInternal : true,
whitelistUrls: [...(this.options.whitelistUrls || []), ...(clientOptions.whitelistUrls || [])],
ignoreInternal: typeof this._options.ignoreInternal !== 'undefined' ? this._options.ignoreInternal : true,
whitelistUrls: [...(this._options.whitelistUrls || []), ...(clientOptions.whitelistUrls || [])],
};
}
/** JSDoc */
isMatchingPattern(value, pattern) {
_isMatchingPattern(value, pattern) {
if (isRegExp(pattern)) {
return pattern.test(value);
}
else if (typeof pattern === 'string') {
return includes(value, pattern);
if (typeof pattern === 'string') {
return value.includes(pattern);
}
else {
return false;
}
return false;
}
/** JSDoc */
getPossibleEventMessages(event) {
_getPossibleEventMessages(event) {
if (event.message) {
return [event.message];
}
else if (event.exception) {
if (event.exception) {
try {

@@ -148,8 +145,6 @@ // tslint:disable-next-line:no-unsafe-any

}
else {
return [];
}
return [];
}
/** JSDoc */
getEventFilterUrl(event) {
_getEventFilterUrl(event) {
try {

@@ -161,3 +156,3 @@ if (event.stacktrace) {

}
else if (event.exception) {
if (event.exception) {
// tslint:disable:no-unsafe-any

@@ -167,5 +162,3 @@ const frames = event.exception.values[0].stacktrace.frames;

}
else {
return null;
}
return null;
}

@@ -172,0 +165,0 @@ catch (oO) {

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

export { Dedupe } from './dedupe';
export { FunctionToString } from './functiontostring';
export { SDKInformation } from './sdkinformation';
export { InboundFilters } from './inboundfilters';
export { ExtraErrorData } from './extraerrordata';
export { Debug } from './pluggable/debug';
export { RewriteFrames } from './pluggable/rewriteframes';

@@ -1,8 +0,3 @@

export { Dedupe } from './dedupe';
export { FunctionToString } from './functiontostring';
export { SDKInformation } from './sdkinformation';
export { InboundFilters } from './inboundfilters';
export { ExtraErrorData } from './extraerrordata';
export { Debug } from './pluggable/debug';
export { RewriteFrames } from './pluggable/rewriteframes';
//# sourceMappingURL=index.js.map

@@ -1,6 +0,4 @@

import { Client, Options } from './interfaces';
import { Client, Options } from '@sentry/types';
/** A class object that can instanciate Client objects. */
export interface ClientClass<F extends Client, O extends Options> {
new (options: O): F;
}
export declare type ClientClass<F extends Client, O extends Options> = new (options: O) => F;
/**

@@ -12,4 +10,3 @@ * Internal function to create a new SDK client instance. The client is

* @param options Options to pass to the client.
* @returns The installed and bound client instance.
*/
export declare function initAndBind<F extends Client, O extends Options>(clientClass: ClientClass<F, O>, options: O): void;

@@ -1,3 +0,3 @@

import { getCurrentHub } from '@sentry/hub/esm';
import { logger } from '@sentry/utils/esm/logger';
import { getCurrentHub } from '@sentry/hub';
import { logger } from '@sentry/utils/logger';
/**

@@ -9,3 +9,2 @@ * Internal function to create a new SDK client instance. The client is

* @param options Options to pass to the client.
* @returns The installed and bound client instance.
*/

@@ -16,6 +15,4 @@ export function initAndBind(clientClass, options) {

}
const client = new clientClass(options);
getCurrentHub().bindClient(client);
client.install();
getCurrentHub().bindClient(new clientClass(options));
}
//# sourceMappingURL=sdk.js.map

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

import { SentryResponse, Transport } from '@sentry/types/esm';
import { Event, Response, Transport } from '@sentry/types';
/** Noop transport */

@@ -7,3 +7,3 @@ export declare class NoopTransport implements Transport {

*/
sendEvent(_: string): Promise<SentryResponse>;
sendEvent(_: Event): Promise<Response>;
/**

@@ -10,0 +10,0 @@ * @inheritDoc

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

import { Status } from '@sentry/types/esm';
import * as tslib_1 from "tslib";
import { Status } from '@sentry/types';
/** Noop transport */

@@ -7,6 +8,8 @@ export class NoopTransport {

*/
async sendEvent(_) {
return Promise.resolve({
reason: `NoopTransport: Event has been skipped because no Dsn is configured.`,
status: Status.Skipped,
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,
});
});

@@ -17,6 +20,8 @@ }

*/
async close(_) {
return Promise.resolve(true);
close(_) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return Promise.resolve(true);
});
}
}
//# sourceMappingURL=noop.js.map
{
"name": "@sentry/core",
"version": "4.6.4",
"version": "5.0.0-rc.0",
"description": "Base implementation for all Sentry JavaScript SDKs",

@@ -13,2 +13,3 @@ "repository": "git://github.com/getsentry/sentry-javascript.git",

"main": "dist/index.js",
"module": "esm/index.js",
"types": "dist/index.d.ts",

@@ -19,16 +20,16 @@ "publishConfig": {

"dependencies": {
"@sentry/hub": "4.6.4",
"@sentry/minimal": "4.6.4",
"@sentry/types": "4.5.3",
"@sentry/utils": "4.6.4",
"@sentry/hub": "5.0.0-rc.0",
"@sentry/minimal": "5.0.0-rc.0",
"@sentry/types": "5.0.0-rc.0",
"@sentry/utils": "5.0.0-rc.0",
"tslib": "^1.9.3"
},
"devDependencies": {
"jest": "^22.4.3",
"jest": "^24.5.0",
"npm-run-all": "^4.1.2",
"prettier": "^1.14.0",
"prettier": "^1.16.4",
"prettier-check": "^2.0.0",
"rimraf": "^2.6.2",
"tslint": "^5.11.0",
"typescript": "^3.2.0"
"rimraf": "^2.6.3",
"tslint": "^5.14.0",
"typescript": "^3.3.3333"
},

@@ -38,7 +39,8 @@ "scripts": {

"build:es5": "tsc -p tsconfig.build.json",
"build:esm": "run-s build:esm:transpile build:esm:rewrite",
"build:esm:transpile": "tsc -p tsconfig.esm.json",
"build:esm:rewrite": "node ../../scripts/esm-rewrite.js",
"build:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
"build:esm": "tsc -p tsconfig.esm.json",
"build:watch": "run-p build:watch:es5 build:watch:esm",
"build:watch:es5": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
"build:watch:esm": "tsc -p tsconfig.esm.json -w --preserveWatchOutput",
"clean": "rimraf dist coverage",
"link:yarn": "yarn link",
"lint": "run-s lint:prettier lint:tslint",

@@ -45,0 +47,0 @@ "lint:prettier": "prettier-check \"{src,test}/**/*.ts\"",

@@ -24,1 +24,3 @@ <p align="center">

`@sentry/node` or `@sentry/browser`.
Please consider all classes and exported functions and interfaces `internal`.

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

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