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

@sentry/node

Package Overview
Dependencies
Maintainers
9
Versions
532
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/node - npm Package Compare versions

Comparing version 0.5.4 to 4.0.0-beta.0

dist/client.d.ts

41

dist/backend.d.ts

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

import { Backend, Frontend, Options } from '@sentry/core';
import { SentryEvent } from '@sentry/shim';
import { Transport } from './raven';
import { Backend, Options } from '@sentry/core';
import { SentryEvent, SentryResponse } from '@sentry/types';
import { TransportOptions } from './transports';
/**
* Configuration options for the Sentry Node SDK.
* @see NodeFrontend for more information.
* @see NodeClient for more information.
*/

@@ -15,22 +15,14 @@ export interface NodeOptions extends Options {

captureUnhandledRejections?: boolean;
/** Callback that is executed when a fatal global error occurs. */
onFatalError?(error: Error): void;
/**
* Enables/disables automatic collection of breadcrumbs. Possible values are:
*
* - `false`: all automatic breadcrumb collection disabled (default)
* - `true`: all automatic breadcrumb collection enabled
* - A dictionary of individual breadcrumb types that can be
* enabled/disabled: e.g.: `{ console: true, http: false }`
* @inheritDoc
*/
autoBreadcrumbs?: {
[key: string]: boolean;
} | boolean;
/** Callback that is executed when a fatal global error occurs. */
onFatalError?(error: Error): void;
transportOptions?: TransportOptions;
}
/** The Sentry Node SDK Backend. */
export declare class NodeBackend implements Backend {
/** Handle to the SDK frontend for callbacks. */
private readonly frontend;
private readonly options;
/** Creates a new Node backend instance. */
constructor(frontend: Frontend<NodeOptions>);
constructor(options?: NodeOptions);
/**

@@ -51,3 +43,3 @@ * @inheritDoc

*/
sendEvent(event: SentryEvent): Promise<number>;
sendEvent(event: SentryEvent): Promise<SentryResponse>;
/**

@@ -60,12 +52,3 @@ * @inheritDoc

*/
storeContext(): boolean;
/**
* Set the transport module used for submitting events.
*
* This can be set to modules like "http" or "https" or any other object that
* provides a `request` method with options.
*
* @param transport The transport to use for submitting events.
*/
setTransport(transport: Transport): void;
storeScope(): void;
}

@@ -17,4 +17,4 @@ "use strict";

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -40,11 +40,21 @@ case 0: case 1: t = op; break;

var core_1 = require("@sentry/core");
var shim_1 = require("@sentry/shim");
var minimal_1 = require("@sentry/minimal");
var raven_1 = require("./raven");
/** Original Raven send function. */
var sendRavenEvent = raven_1.Raven.send.bind(raven_1.Raven);
var transports_1 = require("./transports");
/** Prepares an event so it can be send with raven-js. */
function normalizeEvent(ravenEvent) {
var event = ravenEvent;
// tslint:disable-next-line:no-unsafe-any
if (ravenEvent.exception && !ravenEvent.exception.values) {
// tslint:disable-next-line:no-unsafe-any
event.exception = { values: ravenEvent.exception };
}
return event;
}
/** The Sentry Node SDK Backend. */
var NodeBackend = /** @class */ (function () {
/** Creates a new Node backend instance. */
function NodeBackend(frontend) {
this.frontend = frontend;
function NodeBackend(options) {
if (options === void 0) { options = {}; }
this.options = options;
}

@@ -55,26 +65,33 @@ /**

NodeBackend.prototype.install = function () {
// We are only called by the frontend if the SDK is enabled and a valid DSN
// We are only called by the client if the SDK is enabled and a valid DSN
// has been configured. If no DSN is present, this indicates a programming
// error.
var dsn = this.frontend.getDSN();
var dsn = this.options.dsn;
if (!dsn) {
throw new core_1.SentryError('Invariant exception: install() must not be called when disabled');
}
var onFatalError = this.frontend.getOptions().onFatalError;
raven_1.Raven.config(dsn.toString(true), this.frontend.getOptions()).install(onFatalError);
raven_1.Raven.config(dsn, this.options);
// We need to leave it here for now, as we are skipping `install` call,
// due to integrations migration
// TODO: Remove it once we fully migrate our code
var onFatalError = this.options.onFatalError;
if (onFatalError) {
raven_1.Raven.onFatalError = onFatalError;
}
raven_1.Raven.installed = true;
// Hook into Raven's breadcrumb mechanism. This allows us to intercept both
// breadcrumbs created internally by Raven and pass them to the Frontend
// breadcrumbs created internally by Raven and pass them to the Client
// first, before actually capturing them.
raven_1.Raven.captureBreadcrumb = function (breadcrumb) {
shim_1.addBreadcrumb(breadcrumb);
minimal_1.addBreadcrumb(breadcrumb);
};
// Hook into Raven's internal event sending mechanism. This allows us to
// pass events to the frontend, before they will be sent back here for
// pass events to the client, before they will be sent back here for
// actual submission.
raven_1.Raven.send = function (event, callback) {
if (callback && callback.__SENTRY_CAPTURE__) {
callback(event);
callback(normalizeEvent(event));
}
else {
shim_1.captureEvent(event, callback);
minimal_1.captureEvent(normalizeEvent(event));
}

@@ -115,9 +132,19 @@ };

return __awaiter(this, void 0, void 0, function () {
var dsn, transportOptions, transport;
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
sendRavenEvent(event, function (error) {
// TODO: Check the response status code
resolve(error ? 500 : 200);
});
})];
if (!this.options.dsn) {
throw new core_1.SentryError('Cannot sendEvent without a valid DSN');
}
else {
dsn = new core_1.DSN(this.options.dsn);
}
transportOptions = this.options.transportOptions
? this.options.transportOptions
: { dsn: dsn };
transport = this.options.transport
? new this.options.transport({ dsn: dsn })
: dsn.protocol === 'http'
? new transports_1.HTTPTransport(transportOptions)
: new transports_1.HTTPSTransport(transportOptions);
return [2 /*return*/, transport.send(event)];
});

@@ -135,23 +162,5 @@ });

*/
NodeBackend.prototype.storeContext = function () {
return true;
NodeBackend.prototype.storeScope = function () {
// Noop
};
/**
* Set the transport module used for submitting events.
*
* This can be set to modules like "http" or "https" or any other object that
* provides a `request` method with options.
*
* @param transport The transport to use for submitting events.
*/
NodeBackend.prototype.setTransport = function (transport) {
var dsn = this.frontend.getDSN();
if (!dsn) {
return;
}
raven_1.Raven.transport =
dsn.protocol === 'http'
? new raven_1.HTTPTransport({ transport: transport })
: new raven_1.HTTPSTransport({ transport: transport });
};
return NodeBackend;

@@ -158,0 +167,0 @@ }());

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

export { Breadcrumb, Context, Request, SdkInfo, SentryEvent, SentryException, Severity, StackFrame, Stacktrace, Thread, User } from '@sentry/shim';
export { addBreadcrumb, captureMessage, captureException, captureEvent, clearScope, popScope, pushScope, setUserContext, setTagsContext, setExtraContext, withScope } from '@sentry/shim';
export { Breadcrumb, Request, SdkInfo, SentryEvent, SentryException, SentryResponse, Severity, StackFrame, Stacktrace, Status, Thread, User, } from '@sentry/types';
export { addBreadcrumb, captureMessage, captureException, captureEvent, configureScope, } from '@sentry/minimal';
export { getHubFromCarrier, Hub, Scope } from '@sentry/hub';
export { getDefaultHub } from './hub';
export { NodeBackend, NodeOptions } from './backend';
export { NodeFrontend } from './frontend';
export { init, getCurrentFrontend } from './sdk';
export { NodeClient } from './client';
export { init } from './sdk';
import * as Integrations from './integrations';
import * as Transports from './transports';
export { Integrations, Transports };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var shim_1 = require("@sentry/shim");
exports.Severity = shim_1.Severity;
var shim_2 = require("@sentry/shim");
exports.addBreadcrumb = shim_2.addBreadcrumb;
exports.captureMessage = shim_2.captureMessage;
exports.captureException = shim_2.captureException;
exports.captureEvent = shim_2.captureEvent;
exports.clearScope = shim_2.clearScope;
exports.popScope = shim_2.popScope;
exports.pushScope = shim_2.pushScope;
exports.setUserContext = shim_2.setUserContext;
exports.setTagsContext = shim_2.setTagsContext;
exports.setExtraContext = shim_2.setExtraContext;
exports.withScope = shim_2.withScope;
var types_1 = require("@sentry/types");
exports.Severity = types_1.Severity;
exports.Status = types_1.Status;
var minimal_1 = require("@sentry/minimal");
exports.addBreadcrumb = minimal_1.addBreadcrumb;
exports.captureMessage = minimal_1.captureMessage;
exports.captureException = minimal_1.captureException;
exports.captureEvent = minimal_1.captureEvent;
exports.configureScope = minimal_1.configureScope;
var hub_1 = require("@sentry/hub");
exports.getHubFromCarrier = hub_1.getHubFromCarrier;
exports.Hub = hub_1.Hub;
exports.Scope = hub_1.Scope;
var hub_2 = require("./hub");
exports.getDefaultHub = hub_2.getDefaultHub;
var backend_1 = require("./backend");
exports.NodeBackend = backend_1.NodeBackend;
var frontend_1 = require("./frontend");
exports.NodeFrontend = frontend_1.NodeFrontend;
var client_1 = require("./client");
exports.NodeClient = client_1.NodeClient;
var sdk_1 = require("./sdk");
exports.init = sdk_1.init;
exports.getCurrentFrontend = sdk_1.getCurrentFrontend;
var Integrations = require("./integrations");
exports.Integrations = Integrations;
var Transports = require("./transports");
exports.Transports = Transports;
//# sourceMappingURL=index.js.map

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

import { Breadcrumb, SentryEvent } from '@sentry/shim';
import { Breadcrumb, SentryEvent } from '@sentry/types';
export declare type SendMethod = (event: SentryEvent, cb?: (err: any) => void) => void;
/** A HTTP transport module. */
export interface Transport {
request(options: object | string): void;
}
/** A Raven transport wrapper. */
export interface RavenTransport {
send(): void;
}
/** A constructor class that creates a RavenTransport. */
export interface TransportClass {
new (options: {
transport: Transport;
}): RavenTransport;
}
/** Provides access to internal raven functionality. */

@@ -25,7 +11,8 @@ export interface RavenInternal {

send: SendMethod;
transport: RavenTransport;
version: string;
onFatalError(error: Error): void;
installed: boolean;
uncaughtErrorHandler(): void;
}
/** Casted raven instance with access to internal functions. */
export declare const Raven: RavenInternal;
export declare const HTTPSTransport: TransportClass, HTTPTransport: TransportClass;

@@ -7,5 +7,2 @@ "use strict";

exports.Raven = RavenNode;
exports.HTTPSTransport = (_a = RavenNode
.transports, _a.HTTPSTransport), exports.HTTPTransport = _a.HTTPTransport;
var _a;
//# sourceMappingURL=raven.js.map
import { NodeOptions } from './backend';
import { NodeFrontend } from './frontend';
/**

@@ -18,8 +17,9 @@ * The Sentry Node SDK Client.

*
*
* @example
* const { setContext } = require('@sentry/node');
* setContext({
* extra: { battery: 0.7 },
* tags: { user_mode: 'admin' },
* user: { id: '4711' },
* const { configureScope } = require('@sentry/node');
* configureScope((scope: Scope) => {
* scope.setExtra({ battery: 0.7 });
* scope.setTags({ user_mode: 'admin' });
* scope.setUser({ id: '4711' });
* });

@@ -29,3 +29,3 @@ *

* const { addBreadcrumb } = require('@sentry/node');
* SentryClient.addBreadcrumb({
* addBreadcrumb({
* message: 'My Breadcrumb',

@@ -49,3 +49,1 @@ * // ...

export declare function init(options: NodeOptions): void;
/** Returns the current NodeFrontend, if any. */
export declare function getCurrentFrontend(): NodeFrontend;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@sentry/core");
var shim_1 = require("@sentry/shim");
var frontend_1 = require("./frontend");
var client_1 = require("./client");
var integrations_1 = require("./integrations");
/**

@@ -21,8 +21,9 @@ * The Sentry Node SDK Client.

*
*
* @example
* const { setContext } = require('@sentry/node');
* setContext({
* extra: { battery: 0.7 },
* tags: { user_mode: 'admin' },
* user: { id: '4711' },
* const { configureScope } = require('@sentry/node');
* configureScope((scope: Scope) => {
* scope.setExtra({ battery: 0.7 });
* scope.setTags({ user_mode: 'admin' });
* scope.setUser({ id: '4711' });
* });

@@ -32,3 +33,3 @@ *

* const { addBreadcrumb } = require('@sentry/node');
* SentryClient.addBreadcrumb({
* addBreadcrumb({
* message: 'My Breadcrumb',

@@ -52,10 +53,10 @@ * // ...

function init(options) {
core_1.initAndBind(frontend_1.NodeFrontend, options);
core_1.initAndBind(client_1.NodeClient, options, [
new integrations_1.OnUncaughtException(),
new integrations_1.OnUnhandledRejection(),
new integrations_1.Console(),
new integrations_1.Http(),
]);
}
exports.init = init;
/** Returns the current NodeFrontend, if any. */
function getCurrentFrontend() {
return shim_1.getCurrentClient();
}
exports.getCurrentFrontend = getCurrentFrontend;
//# sourceMappingURL=sdk.js.map
{
"name": "@sentry/node",
"version": "0.5.4",
"version": "4.0.0-beta.0",
"description": "Offical Sentry SDK for Node.js",
"repository": "git://github.com/getsentry/raven-js.git",
"homepage": "https://github.com/getsentry/raven-js/tree/next/packages/node",
"homepage": "https://github.com/getsentry/raven-js/tree/master/packages/node",
"author": "Sentry",

@@ -18,8 +18,10 @@ "license": "BSD-3-Clause",

"dependencies": {
"@sentry/core": "0.5.4",
"@sentry/shim": "0.5.4",
"@sentry/core": "4.0.0-beta.0",
"@sentry/hub": "4.0.0-beta.0",
"@sentry/minimal": "4.0.0-beta.0",
"@sentry/types": "4.0.0-beta.0",
"@sentry/utils": "4.0.0-beta.0",
"raven": "^2.6.0"
},
"devDependencies": {
"chai": "^4.1.2",
"jest": "^22.4.3",

@@ -30,3 +32,2 @@ "npm-run-all": "^4.1.2",

"rimraf": "^2.6.2",
"sinon": "^5.0.3",
"tslint": "^5.9.1",

@@ -45,4 +46,25 @@ "typescript": "^2.8.3"

"test": "jest",
"test:watch": "jest --watch --notify"
}
"test:watch": "jest --watch --notify",
"version": "node ../../scripts/versionbump.js src/client.ts"
},
"jest": {
"collectCoverage": true,
"transform": {
"^.+\\.ts$": "ts-jest"
},
"moduleFileExtensions": [
"js",
"ts"
],
"testEnvironment": "node",
"testMatch": [
"**/*.test.ts"
],
"globals": {
"ts-jest": {
"tsConfigFile": "./tsconfig.json"
}
}
},
"gitHead": "a91da22f8bd3bddb38fab7f868326e376da82d4d"
}

@@ -15,4 +15,4 @@ <p align="center">

**WARNING:** This SDK is part of an early access preview for the
[next generation](https://github.com/getsentry/raven-js/tree/next#readme) of
Sentry JavaScript SDKs. Public interfaces might change and break backwards
[next generation](https://github.com/getsentry/raven-js/tree/master/packages#readme)
of Sentry JavaScript SDKs. Public interfaces might change and break backwards
compatibility from time to time. We absolutely recommend

@@ -42,5 +42,8 @@ [raven](https://github.com/getsentry/raven-node) in production!

// Set user information, as well as tags and further extras
Sentry.setExtraContext({ battery: 0.7 });
Sentry.setTagsContext({ user_mode: 'admin' });
Sentry.setUserContext({ id: '4711' });
Sentry.configureScope(scope => {
scope.setExtra('battery', 0.7);
scope.setTag('user_mode', 'admin');
scope.setUser({ id: '4711' });
// scope.clear();
});

@@ -70,5 +73,5 @@ // Add a breadcrumb for future events

```javascript
const { NodeFrontend } = require('@sentry/node');
const { NodeClient } = require('@sentry/node');
const client = new NodeFrontend({
const client = new NodeClient({
dsn: '__DSN__',

@@ -75,0 +78,0 @@ // ...

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc