@snapshot-labs/snapshot-sentry
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -9,2 +9,3 @@ /// <reference types="node" /> | ||
export declare function capture(e: any, captureContext?: any): void; | ||
export declare function normalizedCaptureContext(captureContext?: any): any; | ||
export declare function normalizedCaptureContext(e: any, captureContext?: any): any; | ||
export declare function normalizedError(e: any): any; |
@@ -26,3 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.normalizedCaptureContext = exports.capture = exports.fallbackLogger = exports.initLogger = exports.sensitiveDataToScrub = exports.scrubData = void 0; | ||
exports.normalizedError = exports.normalizedCaptureContext = exports.capture = exports.fallbackLogger = exports.initLogger = exports.sensitiveDataToScrub = exports.scrubData = void 0; | ||
const Sentry = __importStar(require("@sentry/node")); | ||
@@ -109,7 +109,7 @@ const DEFAULT_TRACE_SAMPLE_RATE = '0.01'; | ||
} | ||
Sentry.captureException(e, normalizedCaptureContext(captureContext)); | ||
Sentry.captureException(normalizedError(e), normalizedCaptureContext(e, captureContext)); | ||
} | ||
exports.capture = capture; | ||
function normalizedCaptureContext(captureContext) { | ||
if (!captureContext) { | ||
function normalizedCaptureContext(e, captureContext) { | ||
if (!captureContext && !isJsonRpcError(e)) { | ||
return; | ||
@@ -128,4 +128,20 @@ } | ||
} | ||
if (isJsonRpcError(e)) { | ||
_captureContext.contexts.jsonRpcError = e; | ||
} | ||
return _captureContext; | ||
} | ||
exports.normalizedCaptureContext = normalizedCaptureContext; | ||
function normalizedError(e) { | ||
if (isJsonRpcError(e)) { | ||
return new Error(e.message); | ||
} | ||
else if (typeof e === 'string') { | ||
return new Error(e); | ||
} | ||
return e; | ||
} | ||
exports.normalizedError = normalizedError; | ||
function isJsonRpcError(e) { | ||
return e.hasOwnProperty('code') && e.hasOwnProperty('message') && e.hasOwnProperty('data'); | ||
} |
{ | ||
"name": "@snapshot-labs/snapshot-sentry", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -100,7 +100,7 @@ import * as Sentry from '@sentry/node'; | ||
Sentry.captureException(e, normalizedCaptureContext(captureContext)); | ||
Sentry.captureException(normalizedError(e), normalizedCaptureContext(e, captureContext)); | ||
} | ||
export function normalizedCaptureContext(captureContext?: any) { | ||
if (!captureContext) { | ||
export function normalizedCaptureContext(e: any, captureContext?: any) { | ||
if (!captureContext && !isJsonRpcError(e)) { | ||
return; | ||
@@ -123,3 +123,21 @@ } | ||
if (isJsonRpcError(e)) { | ||
_captureContext.contexts.jsonRpcError = e; | ||
} | ||
return _captureContext; | ||
} | ||
export function normalizedError(e: any) { | ||
if (isJsonRpcError(e)) { | ||
return new Error(e.message); | ||
} else if (typeof e === 'string') { | ||
return new Error(e); | ||
} | ||
return e; | ||
} | ||
function isJsonRpcError(e: any) { | ||
return e.hasOwnProperty('code') && e.hasOwnProperty('message') && e.hasOwnProperty('data'); | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
14747
268
0