Socket
Socket
Sign inDemoInstall

@sentry/core

Package Overview
Dependencies
Maintainers
9
Versions
515
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 0.4.0-beta.4 to 0.4.0-beta.5

dist/lib/base.d.ts

8

dist/index.d.ts

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

export { default as DSN } from './lib/dsn';
export { default as Client } from './lib/client';
export * from './lib/sentry';
export * from './lib/base';
export * from './lib/domain';
export * from './lib/dsn';
export * from './lib/error';
export * from './lib/interfaces';
export * from './lib/sdk';

@@ -6,8 +6,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var dsn_1 = require("./lib/dsn");
exports.DSN = dsn_1.default;
var client_1 = require("./lib/client");
exports.Client = client_1.default;
__export(require("./lib/sentry"));
__export(require("./lib/base"));
__export(require("./lib/domain"));
__export(require("./lib/dsn"));
__export(require("./lib/error"));
__export(require("./lib/interfaces"));
__export(require("./lib/sdk"));
//# sourceMappingURL=index.js.map

@@ -0,21 +1,52 @@

/** Supported Sentry transport protocols in a DSN. */
export declare type DSNProtocol = 'http' | 'https';
/** Primitive components of a DSN. */
export interface DSNComponents {
source: string;
protocol: string;
/** Protocol used to connect to Sentry. */
protocol: DSNProtocol;
/** Public authorization key. */
user: string;
pass: string;
/** Private authorization key (deprecated, optional). */
pass?: string;
/** Hostname of the Sentry instance. */
host: string;
port: string;
/** Port of the Sentry instance. */
port?: string;
/** Project path */
path: string;
}
export default class DSN implements DSNComponents {
source: string;
protocol: string;
/** Anything that can be parsed into a DSN. */
export declare type DSNLike = string | DSNComponents;
/** The Sentry DSN, identifying a Sentry instance and project. */
export declare class DSN implements DSNComponents {
/** Protocol used to connect to Sentry. */
protocol: DSNProtocol;
/** Public authorization key. */
user: string;
/** Private authorization key (deprecated, optional). */
pass: string;
/** Hostname of the Sentry instance. */
host: string;
/** Port of the Sentry instance. */
port: string;
/** Project path */
path: string;
constructor(from: string | DSNComponents);
toString(withPass?: boolean): string;
/** Creates a new DSN component */
constructor(from: DSNLike);
/**
* Renders the string representation of this DSN.
*
* By default, this will render the public representation without the password
* component. To get the deprecated private representation, set `withPassword`
* to true.
*
* @param withPassword When set to true, the password will be included.
*/
toString(withPassword?: boolean): string;
/** Parses a string into this DSN. */
private fromString(str);
/** Maps DSN components into this instance. */
private fromComponents(components);
/** Validates this DSN and throws on error. */
private validate();
}

@@ -18,6 +18,19 @@ "use strict";

};
var __values = (this && this.__values) || function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
};
Object.defineProperty(exports, "__esModule", { value: true });
var sentry_1 = require("./sentry");
var DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(:\w+)?@)([\w\.-]+)(?::(\d+))?\/(.+)/;
var error_1 = require("./error");
/** Regular expression used to parse a DSN. */
var DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w\.-]+)(?::(\d+))?\/(.+)/;
/** The Sentry DSN, identifying a Sentry instance and project. */
var DSN = /** @class */ (function () {
/** Creates a new DSN component */
function DSN(from) {

@@ -28,23 +41,68 @@ if (typeof from === 'string') {

else {
Object.assign(this, from);
this.fromComponents(from);
}
this.validate();
}
DSN.prototype.toString = function (withPass) {
if (withPass === void 0) { withPass = false; }
/**
* Renders the string representation of this DSN.
*
* By default, this will render the public representation without the password
* component. To get the deprecated private representation, set `withPassword`
* to true.
*
* @param withPassword When set to true, the password will be included.
*/
DSN.prototype.toString = function (withPassword) {
if (withPassword === void 0) { withPassword = false; }
// tslint:disable-next-line:no-this-assignment
var _a = this, host = _a.host, path = _a.path, pass = _a.pass, port = _a.port, protocol = _a.protocol, user = _a.user;
return (protocol + "://" + user + (withPass ? pass : '') +
("@" + host + (port ? ':' + port : '') + "/" + path));
return (protocol + "://" + user + (withPassword && pass ? ":" + pass : '') +
("@" + host + (port ? ":" + port : '') + "/" + path));
};
/** Parses a string into this DSN. */
DSN.prototype.fromString = function (str) {
var match = DSN_REGEX.exec(str);
if (!match) {
throw new sentry_1.SentryError('Invalid DSN');
throw new error_1.SentryError('Invalid DSN');
}
var _a = __read(match, 7), source = _a[0], protocol = _a[1], user = _a[2], _b = _a[3], pass = _b === void 0 ? '' : _b, host = _a[4], _c = _a[5], port = _c === void 0 ? '' : _c, path = _a[6];
Object.assign(this, { source: source, protocol: protocol, user: user, pass: pass, host: host, port: port, path: path });
var _a = __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, path = _a[5];
Object.assign(this, { host: host, pass: pass, path: path, port: port, protocol: protocol, user: user });
};
/** Maps DSN components into this instance. */
DSN.prototype.fromComponents = function (components) {
this.protocol = components.protocol;
this.user = components.user;
this.pass = components.pass || '';
this.host = components.host;
this.port = components.port || '';
this.path = components.path;
};
/** Validates this DSN and throws on error. */
DSN.prototype.validate = function () {
try {
for (var _a = __values(['protocol', 'user', 'host', 'path']), _b = _a.next(); !_b.done; _b = _a.next()) {
var component = _b.value;
if (!this[component]) {
throw new error_1.SentryError("Invalid DSN: Missing " + component);
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
}
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 + "\"");
}
if (this.port && isNaN(parseInt(this.port, 10))) {
throw new error_1.SentryError("Invalid DSN: Invalid port number \"" + this.port + "\"");
}
var e_1, _c;
};
return DSN;
}());
exports.default = DSN;
exports.DSN = DSN;
//# sourceMappingURL=dsn.js.map

@@ -1,135 +0,240 @@

export declare enum Severity {
Fatal = "fatal",
Error = "error",
Warning = "warning",
Info = "info",
Debug = "debug",
Critical = "critical",
}
export interface Breadcrumb {
type?: string;
level?: Severity;
event_id?: string;
category?: string;
message?: string;
data?: any;
timestamp?: number;
}
export interface User {
id?: string;
email?: string;
username?: string;
extra?: any;
}
export interface Context {
tags?: {
[key: string]: string;
};
extra?: object;
user?: User;
}
export interface SdkInfo {
version?: string;
name?: string;
integrations?: string[];
}
export interface StackFrame {
filename?: string;
function?: string;
module?: string;
platform?: string;
lineno?: number;
colno?: number;
abs_path?: string;
context_line?: string;
pre_context?: string;
post_context?: string;
in_app?: boolean;
vars?: {
[name: string]: any;
};
}
export interface Stacktrace {
frames?: StackFrame[];
frames_omitted?: [number, number];
}
export interface Thread {
id?: number;
name?: string;
stacktrace?: Stacktrace;
crashed?: boolean;
current?: boolean;
}
export interface SentryException {
type?: string;
value?: string;
module?: string;
thread_id?: number;
stacktrace?: Stacktrace;
}
export interface Request {
url?: string;
method?: string;
data?: any;
query_string?: string;
cookies?: {
[key: string]: string;
};
env?: {
[key: string]: string;
};
}
export interface SentryEvent extends Context {
event_id?: string;
message?: string;
timestamp?: number;
level?: Severity;
platform?: string;
logger?: string;
server?: string;
release?: string;
dist?: string;
environment?: string;
sdk?: SdkInfo;
request?: Request;
modules?: {
[key: string]: string;
};
fingerprint?: string[];
exception?: SentryException[];
stacktrace?: Stacktrace;
breadcrumbs?: Breadcrumb[];
}
import { Breadcrumb, Context, SentryEvent } from './domain';
import { DSN } from './dsn';
import { SendStatus } from './status';
/** Console logging verbosity for the SDK. */
export declare enum LogLevel {
/** No logs will be generated. */
None = 0,
/** Only SDK internal errors will be logged. */
Error = 1,
/** Information useful for debugging the SDK will be logged. */
Debug = 2,
/** All SDK actions will be logged. */
Verbose = 3,
}
/**
* Base configuration options for every SDK.
* Specific SDKs can add more options.
*/
export interface Options {
/**
* Specifies whether this SDK should activate and send events to Sentry.
* Disabling the SDK reduces all overhead from instrumentation, collecting
* breadcrumbs and capturing events.
* Defaults to true.
*/
enabled?: boolean;
/**
* The DSN used to connect to Sentry and identify the project.
* If omitted, the SDK will not send any data to Sentry.
*/
dsn?: string;
/**
* The release identifier used when uploading respective source maps.
* Specify this value to allow Sentry to resolve the correct source maps when
* processing events.
*/
release?: string;
/** The current environment of your application (e.g. "production"). */
environment?: string;
/** The maximum number of breadcrumbs sent with events. Defaults to 100. */
maxBreadcrumbs?: number;
/** Console logging verbosity for the SDK Client. */
logLevel?: LogLevel;
maxBreadcrumbs?: number;
ignoreErrors?: Array<string | RegExp>;
ignoreUrls?: Array<string | RegExp>;
whitelistUrls?: Array<string | RegExp>;
includePaths?: Array<string | RegExp>;
shouldSend?: (e: SentryEvent) => boolean;
beforeSend?: (e: SentryEvent) => SentryEvent;
afterSend?: (e: SentryEvent) => void;
shouldAddBreadcrumb?: (b: Breadcrumb) => boolean;
beforeBreadcrumb?: (b: Breadcrumb) => Breadcrumb;
afterBreadcrumb?: (b: Breadcrumb) => Breadcrumb;
/**
* A callback invoked during event submission, allowing to cancel the
* process. If unspecified, all events will be sent to Sentry.
*
* This function is called for both error and message events before all other
* callbacks. Note that the SDK might perform other actions after calling
* this function. Use {@link Options.beforeSend} for notifications on events
* instead.
*
* @param event The error or message event generated by the SDK.
* @returns True if the event should be sent, false otherwise.
*/
shouldSend?(event: SentryEvent): boolean;
/**
* A callback invoked during event submission, allowing to optionally modify
* the event before it is sent to Sentry.
*
* This function is called after {@link Options.shouldSend} and just before
* sending the event and must return synchronously.
*
* Note that you must return a valid event from this callback. If you do not
* wish to modify the event, simply return it at the end. To cancel event
* submission instead, use {@link Options.shouldSend}.
*
* @param event The error or message event generated by the SDK.
* @returns A new event that will be sent.
*/
beforeSend?(event: SentryEvent): SentryEvent;
/**
* A callback invoked after event submission has completed.
* @param event The error or message event sent to Sentry.
*/
afterSend?(event: SentryEvent, status: SendStatus): void;
/**
* A callback allowing to skip breadcrumbs.
*
* This function is called for both manual and automatic breadcrumbs before
* all other callbacks. Note that the SDK might perform other actions after
* calling this function. Use {@link Options.beforeBreadcrumb} for
* notifications on breadcrumbs instead.
*
* @param breadcrumb The breadcrumb as created by the SDK.
* @returns True if the breadcrumb should be added, false otherwise.
*/
shouldAddBreadcrumb?(breadcrumb: Breadcrumb): boolean;
/**
* A callback invoked when adding a breadcrumb, allowing to optionally modify
* it before adding it to future events.
*
* This function is called after {@link Options.shouldAddBreadcrumb} and just
* before persisting the breadcrumb. It must return synchronously.
*
* Note that you must return a valid breadcrumb from this callback. If you do
* not wish to modify the breadcrumb, simply return it at the end. To skip a
* breadcrumb instead, use {@link Options.shouldAddBreadcrumb}.
*
* @param breadcrumb The breadcrumb as created by the SDK.
* @returns The breadcrumb that will be added.
*/
beforeBreadcrumb?(breadcrumb: Breadcrumb): Breadcrumb;
/**
* A callback invoked after adding a breadcrumb.
* @param breadcrumb The breadcrumb as created by the SDK.
*/
afterBreadcrumb?(breadcrumb: Breadcrumb): void;
}
export interface Adapter {
readonly options: {};
/**
* User-Facing Sentry SDK Client Frontend.
*
* This interface contains all methods to interface with the SDK once it has
* been installed. It allows to send events to Sentry, record breadcrumbs and
* set a context included in every event. Since the SDK mutates its environment,
* there will only be one instance during runtime. To retrieve that instance,
* use {@link Client.getInstance}.
*
* Note that the call to {@link Frontend.install} should occur as early as
* possible so that even errors during startup can be recorded reliably:
*
* @example
* import { SentryClient } from '@sentry/node';
* SentryClient.create({ dsn: '__DSN__' });
*
* @example
* import { SentryClient } from '@sentry/node';
* SentryClient.captureMessage('Custom message');
*/
export interface Frontend<O extends Options = Options> {
/**
* Installs the SDK if it hasn't been installed already.
*
* Since this performs modifications in the environment, such as instrumenting
* library functionality or adding signal handlers, this method should only
* be called once.
*
* The installation is performed asynchronously. While it is possible to use
* the SDK before the installation has finished, it is advised to wait until
* the returned Promise has resolved before issuing methods such as
* {@link Frontend.captureException} or {@link Frontend.captureBreadcrumb}.
*
* @returns A Promise that resolves when installation has finished.
*/
install(): Promise<boolean>;
captureException(exception: any): Promise<SentryEvent>;
captureMessage(message: string): Promise<SentryEvent>;
captureBreadcrumb(breadcrumb: Breadcrumb): Promise<Breadcrumb>;
send(event: SentryEvent): Promise<void>;
setOptions(options: Options): Promise<void>;
/**
* Captures an exception event and sends it to Sentry.
*
* @param exception An exception-like object.
* @returns A Promise that resolves when the exception has been sent.
*/
captureException(exception: any): Promise<void>;
/**
* Captures a message event and sends it to Sentry.
*
* @param message The message to send to Sentry.
* @returns A Promise that resolves when the message has been sent.
*/
captureMessage(message: string): Promise<void>;
/**
* Captures a manually created event and sends it to Sentry.
*
* @param event The event to send to Sentry.
* @returns A Promise that resolves when the event has been sent.
*/
captureEvent(event: SentryEvent): Promise<void>;
/**
* Records a new breadcrumb which will be attached to future events.
*
* Breadcrumbs will be added to subsequent events to provide more context on
* user's actions prior to an error or crash. To configure the maximum number
* of breadcrumbs, use {@link Options.maxBreadcrumbs}.
*
* @param breadcrumb The breadcrumb to record.
* @returns A Promise that resolves when the breadcrumb has been persisted.
*/
addBreadcrumb(breadcrumb: Breadcrumb): Promise<void>;
/** Returns the current DSN. */
getDSN(): DSN | undefined;
/** Returns the current options. */
getOptions(): O;
/**
* Updates SDK options with the provided values.
*
* @param options A partial options object to merge into current options.
* @returns A Promise that resolves when the new options have been applied.
*/
setOptions(options: O): Promise<void>;
/** Resolves the current context. */
getContext(): Promise<Context>;
/**
* Updates context information (user, tags, extras) for future events.
*
* @param context A partial context object to merge into current context.
* @returns A Promise that resolves when the new context has been merged.
*/
setContext(context: Context): Promise<void>;
}
/**
* Internal platform-dependent Sentry SDK Backend.
*
* While {@link Frontend} 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 Frontend in their constructor. When a
* Backend automatically generates events or breadcrumbs, it must pass them to
* the Frontend for validation and processing first.
*
* Usually, the Frontend will be of corresponding type, e.g. NodeBackend
* receives NodeFrontend. 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 frontend also provides access to options via {@link Frontend.getOptions}
* and context via {@link Frontend.getContext}. Note that the user might update
* these any time and they should not be cached.
*/
export interface Backend {
/** Installs the SDK into the environment. */
install(): Promise<boolean>;
/** Creates a {@link SentryEvent} from an exception. */
eventFromException(exception: any): Promise<SentryEvent>;
/** Creates a {@link SentryEvent} from a plain message. */
eventFromMessage(message: string): Promise<SentryEvent>;
/** Submits the event to Sentry */
sendEvent(event: SentryEvent): Promise<number>;
/** Receives the full merged context and stores it persistently. */
storeContext(context: Context): Promise<void>;
/** Returns the latest context including SDK defaults. */
loadContext(): Promise<Context>;
/**
* Receives a list of breadcrumbs and stores them persistently. If previously
* stored breadcrumbs are missing, they should be deleted.
*/
storeBreadcrumbs(breadcrumbs: Breadcrumb[]): Promise<void>;
/** Returns the full list of stored breadcrumbs (or empty) */
loadBreadcrumbs(): Promise<Breadcrumb[]>;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Severity;
(function (Severity) {
Severity["Fatal"] = "fatal";
Severity["Error"] = "error";
Severity["Warning"] = "warning";
Severity["Info"] = "info";
Severity["Debug"] = "debug";
Severity["Critical"] = "critical";
})(Severity = exports.Severity || (exports.Severity = {}));
/** Console logging verbosity for the SDK. */
var LogLevel;
(function (LogLevel) {
/** No logs will be generated. */
LogLevel[LogLevel["None"] = 0] = "None";
/** Only SDK internal errors will be logged. */
LogLevel[LogLevel["Error"] = 1] = "Error";
/** Information useful for debugging the SDK will be logged. */
LogLevel[LogLevel["Debug"] = 2] = "Debug";
/** All SDK actions will be logged. */
LogLevel[LogLevel["Verbose"] = 3] = "Verbose";
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
//# sourceMappingURL=interfaces.js.map
{
"name": "@sentry/core",
"version": "0.4.0-beta.4",
"description": "Sentry core implementation for all JavaScript related SDKs",
"version": "0.4.0-beta.5",
"description": "Base implementation for all Sentry JavaScript SDKs",
"repository": "https://github.com/getsentry/raven-js",
"author": "Sentry",

@@ -16,37 +17,24 @@ "license": "MIT",

"devDependencies": {
"@types/jest": "*",
"jest": "*",
"npm-run-all": "*",
"prettier": "*",
"rimraf": "*",
"ts-jest": "*",
"tslint": "*",
"typescript": "*"
"chai": "^4.1.2",
"jest": "^22.4.2",
"npm-run-all": "^4.1.2",
"prettier": "^1.11.1",
"prettier-check": "^2.0.0",
"rimraf": "^2.6.2",
"sinon": "^4.4.2",
"tslint": "^5.9.1",
"typescript": "^2.7.2"
},
"scripts": {
"build": "tsc",
"build": "tsc -p tsconfig.build.json",
"clean": "rimraf dist coverage",
"lint": "tslint --config ../../tslint.json src/**/*",
"format": "prettier --config ../../.prettierrc.json src/**/* --write",
"lint": "run-s lint:prettier lint:tslint",
"lint:prettier": "prettier-check '{src,test}/**/*.ts'",
"lint:tslint": "tslint -t stylish -p .",
"fix": "run-s fix:tslint fix:prettier",
"fix:prettier": "prettier --write '{src,test}/**/*.ts'",
"fix:tslint": "tslint --fix -t stylish -p .",
"test": "jest",
"test:watch": "jest --watch --notify"
},
"jest": {
"globals": {
"ts-jest": {
"tsConfigFile": "./tsconfig.json"
}
},
"collectCoverage": true,
"transform": {
"^.+\\.ts$": "ts-jest"
},
"moduleFileExtensions": [
"js",
"ts"
],
"testMatch": [
"**/*.test.ts"
]
}
}
<p align="center">
<a href="https://sentry.io" target="_blank" align="center">
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
</a>
<br/>
<h1>Sentry Core JavaScript SDK Framework</h1>
<a href="https://sentry.io" target="_blank" align="center">
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
</a>
<br />
</p>
# Sentry JavaScript SDK Core
[![npm version](https://img.shields.io/npm/v/@sentry/core.svg)](https://www.npmjs.com/package/@sentry/core)

@@ -13,6 +14,4 @@ [![npm dm](https://img.shields.io/npm/dm/@sentry/core.svg)](https://www.npmjs.com/package/@sentry/core)

## General
This package is meant to be used with other SDK Packages like Browser, Cordova,
React Native. It is the public facing API and streamlines all JavaScript related
SDKs.
This package contains the base for all Sentry JavaScript SDKs, like
`@sentry/node`, `@sentry/browser` or `@sentry/cordova`. It contains common type
definitions, domain classes and base implementations.

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