Skip to content

Commit 3599acb

Browse files
authored
Merge pull request #11 from crashdeck/cleanup
update auto collecting of errors
2 parents 69bd93a + 62142ee commit 3599acb

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

index.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,33 @@ class Loggie {
1414
const vm = this;
1515

1616
window.addEventListener("error", function (event) {
17+
let formattedErrorType;
18+
const errorType = String(event.error).substr(
19+
0,
20+
(String(event.error) + ":").indexOf(":")
21+
);
22+
23+
const validErrorTypes = {
24+
SyntaxError: "Syntax Error",
25+
ReferenceError: "Reference Error",
26+
TypeError: "Type Error",
27+
};
28+
29+
if (validErrorTypes[errorType]) {
30+
formattedErrorType = validErrorTypes[errorType];
31+
}
32+
1733
const message = event.message || "Message not found";
1834
const fileName = event.filename || "Unable to get file name";
1935
const lineno = event.lineno || "Unable to get line number";
2036
const colno = event.colno || "Unable to get column number";
2137

2238
const crashdeckErrorMessage = `${message} in ${fileName} at line number: ${lineno} and column: ${colno}`;
2339

24-
vm.error({ message: crashdeckErrorMessage });
40+
vm.error({
41+
message: crashdeckErrorMessage,
42+
errorType: formattedErrorType || "",
43+
});
2544
});
2645
}
2746
}
@@ -77,7 +96,7 @@ class Loggie {
7796
},
7897
{
7998
headers: {
80-
"Authorization": `${this.secretKey}`,
99+
Authorization: `${this.secretKey}`,
81100
},
82101
}
83102
)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@crashdeck/crashdeck",
3-
"version": "0.0.10",
3+
"version": "0.0.11",
44
"description": "Log every thing in just few steps",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)