@drieam/appsignal-plugin-window-events
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -55,3 +55,3 @@ "use strict"; | ||
name: "UnhandledPromiseRejectionError", | ||
message: error && typeof error.reason === "string" ? error.reason : JSON.stringify(error === null || error === void 0 ? void 0 : error.reason), | ||
message: _reasonFromError(error), | ||
stack: ((_a = error === null || error === void 0 ? void 0 : error.reason) === null || _a === void 0 ? void 0 : _a.stack) || "No stacktrace available", | ||
@@ -64,2 +64,26 @@ }); | ||
} | ||
function _reasonFromError(error) { | ||
if (!error) { | ||
return undefined; | ||
} | ||
if (typeof error.reason === "string") { | ||
return error.reason; | ||
} | ||
return JSON.stringify(error.reason, circularReplacer()); | ||
} | ||
function circularReplacer() { | ||
var seenValue = []; | ||
var seenKey = []; | ||
return function (key, value) { | ||
if (typeof value === "object" && value !== null) { | ||
var i = seenValue.indexOf(value); | ||
if (i !== -1) { | ||
return "[cyclic value: " + (seenKey[i] || "root object") + "]"; | ||
} | ||
seenValue.push(value); | ||
seenKey.push(key); | ||
} | ||
return value; | ||
}; | ||
} | ||
if (opts.onerror) { | ||
@@ -66,0 +90,0 @@ ctx.onerror = _onErrorHandler; |
@@ -52,3 +52,3 @@ var __assign = (this && this.__assign) || function () { | ||
name: "UnhandledPromiseRejectionError", | ||
message: error && typeof error.reason === "string" ? error.reason : JSON.stringify(error === null || error === void 0 ? void 0 : error.reason), | ||
message: _reasonFromError(error), | ||
stack: ((_a = error === null || error === void 0 ? void 0 : error.reason) === null || _a === void 0 ? void 0 : _a.stack) || "No stacktrace available", | ||
@@ -61,2 +61,26 @@ }); | ||
} | ||
function _reasonFromError(error) { | ||
if (!error) { | ||
return undefined; | ||
} | ||
if (typeof error.reason === "string") { | ||
return error.reason; | ||
} | ||
return JSON.stringify(error.reason, circularReplacer()); | ||
} | ||
function circularReplacer() { | ||
var seenValue = []; | ||
var seenKey = []; | ||
return function (key, value) { | ||
if (typeof value === "object" && value !== null) { | ||
var i = seenValue.indexOf(value); | ||
if (i !== -1) { | ||
return "[cyclic value: " + (seenKey[i] || "root object") + "]"; | ||
} | ||
seenValue.push(value); | ||
seenKey.push(key); | ||
} | ||
return value; | ||
}; | ||
} | ||
if (opts.onerror) { | ||
@@ -63,0 +87,0 @@ ctx.onerror = _onErrorHandler; |
{ | ||
"name": "@drieam/appsignal-plugin-window-events", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"main": "dist/cjs/index.js", | ||
@@ -22,3 +22,3 @@ "module": "dist/esm/index.js", | ||
"dependencies": { | ||
"@appsignal/types": "^2.0.5" | ||
"@appsignal/types": "=3.0.0" | ||
}, | ||
@@ -29,3 +29,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "b2ee66b6c43841a5a7d435d0c8249b6ceb7e8503" | ||
"gitHead": "6b7887e38c97003229fba8a1849e4024f6ddaf21" | ||
} |
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
15735
199
10
- Removed@appsignal/types@2.1.7(transitive)
Updated@appsignal/types@=3.0.0