@sentry/node
Advanced tools
Comparing version 4.0.0-beta.6 to 4.0.0-beta.7
@@ -8,8 +8,2 @@ import { Backend, Options } from '@sentry/core'; | ||
export interface NodeOptions extends Options { | ||
/** | ||
* Whether unhandled Promise rejections should be captured or not. If true, | ||
* this will install an error handler and prevent the process from crashing. | ||
* Defaults to false. | ||
*/ | ||
captureUnhandledRejections?: boolean; | ||
/** Callback that is executed when a fatal global error occurs. */ | ||
@@ -26,6 +20,2 @@ onFatalError?(error: Error): void; | ||
*/ | ||
install(): boolean; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
eventFromException(exception: any): Promise<SentryEvent>; | ||
@@ -32,0 +22,0 @@ /** |
@@ -39,15 +39,9 @@ "use strict"; | ||
var core_1 = require("@sentry/core"); | ||
var minimal_1 = require("@sentry/minimal"); | ||
var raven_1 = require("./raven"); | ||
var hub_1 = require("@sentry/hub"); | ||
var is_1 = require("@sentry/utils/is"); | ||
var object_1 = require("@sentry/utils/object"); | ||
var md5 = require("md5"); | ||
var stacktrace = require("stack-trace"); | ||
var parsers_1 = require("./parsers"); | ||
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. */ | ||
@@ -63,58 +57,40 @@ var NodeBackend = /** @class */ (function () { | ||
*/ | ||
NodeBackend.prototype.install = function () { | ||
// 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.options.dsn; | ||
if (!dsn) { | ||
throw new core_1.SentryError('Invariant exception: install() must not be called when disabled'); | ||
} | ||
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 Client | ||
// first, before actually capturing them. | ||
raven_1.Raven.captureBreadcrumb = function (breadcrumb) { | ||
minimal_1.addBreadcrumb(breadcrumb); | ||
}; | ||
// Hook into Raven's internal event sending mechanism. This allows us to | ||
// 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(normalizeEvent(event)); | ||
} | ||
else { | ||
// This "if" needs to be here in order for raven-node to propergate | ||
// internal callbacks like in makeErrorHandler -> captureException | ||
// correctly. Also the setTimeout is a dirty hack because in case of a | ||
// fatal error, raven-node exits the process and our consturct of | ||
// hub -> client doesn't have enough time to send the event. | ||
if (callback) { | ||
setTimeout(function () { | ||
callback(event); | ||
}, 1000); | ||
} | ||
minimal_1.captureEvent(normalizeEvent(event)); | ||
} | ||
}; | ||
return true; | ||
}; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
NodeBackend.prototype.eventFromException = function (exception) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve) { | ||
resolve.__SENTRY_CAPTURE__ = true; | ||
raven_1.Raven.captureException(exception, resolve); | ||
})]; | ||
var stack, ex, keys_1, message, event, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
ex = exception; | ||
if (!is_1.isError(exception)) { | ||
if (is_1.isPlainObject(exception)) { | ||
keys_1 = Object.keys(exception).sort(); | ||
message = "Non-Error exception captured with keys: " + object_1.serializeKeysToEventMessage(keys_1); | ||
// TODO: We also set `event.message` here previously, check if it works without it as well | ||
hub_1.getDefaultHub().configureScope(function (scope) { | ||
scope.setExtra('__serialized__', object_1.limitObjectDepthToSize(exception)); | ||
scope.setFingerprint([md5(keys_1.join(''))]); | ||
}); | ||
ex = new Error(message); | ||
} | ||
else { | ||
// This handles when someone does: `throw "something awesome";` | ||
// We synthesize an Error here so we can extract a (rough) stack trace. | ||
ex = new Error(exception); | ||
} | ||
stack = stacktrace.get(); | ||
} | ||
if (!stack) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, parsers_1.parseError(ex, stack)]; | ||
case 1: | ||
_a = _b.sent(); | ||
return [3 /*break*/, 4]; | ||
case 2: return [4 /*yield*/, parsers_1.parseError(ex)]; | ||
case 3: | ||
_a = _b.sent(); | ||
_b.label = 4; | ||
case 4: | ||
event = _a; | ||
return [2 /*return*/, event]; | ||
} | ||
}); | ||
@@ -128,7 +104,18 @@ }); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var stack, frames, event; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve) { | ||
resolve.__SENTRY_CAPTURE__ = true; | ||
raven_1.Raven.captureMessage(message, resolve); | ||
})]; | ||
switch (_a.label) { | ||
case 0: | ||
stack = stacktrace.get(); | ||
return [4 /*yield*/, parsers_1.parseStack(stack)]; | ||
case 1: | ||
frames = _a.sent(); | ||
event = { | ||
message: message, | ||
stacktrace: { | ||
frames: parsers_1.prepareFramesForEvent(frames), | ||
}, | ||
}; | ||
return [2 /*return*/, event]; | ||
} | ||
}); | ||
@@ -135,0 +122,0 @@ }); |
@@ -36,3 +36,3 @@ "use strict"; | ||
name: 'sentry-node', | ||
version: '4.0.0-beta.6', | ||
version: '4.0.0-beta.7', | ||
}; | ||
@@ -39,0 +39,0 @@ }; |
@@ -8,4 +8,5 @@ export { Breadcrumb, Request, SdkInfo, SentryEvent, SentryException, SentryResponse, Severity, StackFrame, Stacktrace, Status, Thread, User, } from '@sentry/types'; | ||
export { defaultIntegrations, init } from './sdk'; | ||
import * as Handlers from './handlers'; | ||
import * as Integrations from './integrations'; | ||
import * as Transports from './transports'; | ||
export { Integrations, Transports }; | ||
export { Integrations, Transports, Handlers }; |
@@ -25,2 +25,4 @@ "use strict"; | ||
exports.init = sdk_1.init; | ||
var Handlers = require("./handlers"); | ||
exports.Handlers = Handlers; | ||
var Integrations = require("./integrations"); | ||
@@ -27,0 +29,0 @@ exports.Integrations = Integrations; |
import { Integration } from '@sentry/types'; | ||
/** Global Promise Rejection handler */ | ||
export declare class OnUncaughtException implements Integration { | ||
private readonly options; | ||
/** | ||
@@ -11,3 +12,13 @@ * @inheritDoc | ||
*/ | ||
readonly handler: (error: Error) => void; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
constructor(options?: { | ||
onFatalError?(firstError: Error, secondError?: Error): void; | ||
}); | ||
/** | ||
* @inheritDoc | ||
*/ | ||
install(): void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var raven_1 = require("../raven"); | ||
var handlers_1 = require("../handlers"); | ||
/** Global Promise Rejection handler */ | ||
var OnUncaughtException = /** @class */ (function () { | ||
function OnUncaughtException() { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
function OnUncaughtException(options) { | ||
if (options === void 0) { options = {}; } | ||
this.options = options; | ||
/** | ||
@@ -11,2 +16,8 @@ * @inheritDoc | ||
this.name = 'OnUncaughtException'; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
this.handler = handlers_1.makeErrorHandler( | ||
// tslint:disable-next-line | ||
this.options.onFatalError); | ||
} | ||
@@ -17,3 +28,3 @@ /** | ||
OnUncaughtException.prototype.install = function () { | ||
global.process.on('uncaughtException', raven_1.Raven.uncaughtErrorHandler.bind(raven_1.Raven)); | ||
global.process.on('uncaughtException', this.handler); | ||
}; | ||
@@ -20,0 +31,0 @@ return OnUncaughtException; |
{ | ||
"name": "@sentry/node", | ||
"version": "4.0.0-beta.6", | ||
"version": "4.0.0-beta.7", | ||
"description": "Offical Sentry SDK for Node.js", | ||
@@ -18,8 +18,14 @@ "repository": "git://github.com/getsentry/raven-js.git", | ||
"dependencies": { | ||
"@sentry/core": "4.0.0-beta.6", | ||
"@sentry/hub": "4.0.0-beta.6", | ||
"@sentry/minimal": "4.0.0-beta.6", | ||
"@sentry/types": "4.0.0-beta.6", | ||
"@sentry/utils": "4.0.0-beta.6", | ||
"raven": "^2.6.0" | ||
"@sentry/core": "4.0.0-beta.7", | ||
"@sentry/hub": "4.0.0-beta.7", | ||
"@sentry/minimal": "4.0.0-beta.7", | ||
"@sentry/types": "4.0.0-beta.7", | ||
"@sentry/utils": "4.0.0-beta.7", | ||
"@types/cookie": "0.3.1", | ||
"@types/md5": "2.1.32", | ||
"@types/stack-trace": "0.0.29", | ||
"cookie": "0.3.1", | ||
"lsmod": "1.0.0", | ||
"md5": "2.2.1", | ||
"stack-trace": "0.0.10" | ||
}, | ||
@@ -26,0 +32,0 @@ "devDependencies": { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
150196
51
1837
12
+ Added@types/cookie@0.3.1
+ Added@types/md5@2.1.32
+ Added@types/stack-trace@0.0.29
+ Addedcookie@0.3.1
+ Addedlsmod@1.0.0
+ Addedmd5@2.2.1
+ Addedstack-trace@0.0.10
+ Added@sentry/core@4.0.0-beta.7(transitive)
+ Added@sentry/hub@4.0.0-beta.7(transitive)
+ Added@sentry/minimal@4.0.0-beta.7(transitive)
+ Added@sentry/types@4.0.0-beta.7(transitive)
+ Added@sentry/utils@4.0.0-beta.7(transitive)
+ Added@types/cookie@0.3.1(transitive)
+ Added@types/md5@2.1.32(transitive)
+ Added@types/node@22.9.0(transitive)
+ Added@types/stack-trace@0.0.29(transitive)
+ Addedlsmod@1.0.0(transitive)
+ Addedmd5@2.2.1(transitive)
+ Addedundici-types@6.19.8(transitive)
- Removedraven@^2.6.0
- Removed@sentry/core@4.0.0-beta.6(transitive)
- Removed@sentry/hub@4.0.0-beta.6(transitive)
- Removed@sentry/minimal@4.0.0-beta.6(transitive)
- Removed@sentry/types@4.0.0-beta.6(transitive)
- Removed@sentry/utils@4.0.0-beta.6(transitive)
- Removedmd5@2.3.0(transitive)
- Removedraven@2.6.4(transitive)
- Removedtimed-out@4.0.1(transitive)
- Removeduuid@3.3.2(transitive)
Updated@sentry/core@4.0.0-beta.7
Updated@sentry/hub@4.0.0-beta.7
Updated@sentry/minimal@4.0.0-beta.7
Updated@sentry/types@4.0.0-beta.7
Updated@sentry/utils@4.0.0-beta.7