@@ -14,14 +14,33 @@ class Loggie {
14
14
const vm = this ;
15
15
16
16
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
+
17
33
const message = event . message || "Message not found" ;
18
34
const fileName = event . filename || "Unable to get file name" ;
19
35
const lineno = event . lineno || "Unable to get line number" ;
20
36
const colno = event . colno || "Unable to get column number" ;
21
37
22
38
const crashdeckErrorMessage = `${ message } in ${ fileName } at line number: ${ lineno } and column: ${ colno } ` ;
23
39
24
- vm . error ( { message : crashdeckErrorMessage } ) ;
40
+ vm . error ( {
41
+ message : crashdeckErrorMessage ,
42
+ errorType : formattedErrorType || "" ,
43
+ } ) ;
25
44
} ) ;
26
45
}
27
46
}
@@ -77,7 +96,7 @@ class Loggie {
77
96
} ,
78
97
{
79
98
headers : {
80
- " Authorization" : `${ this . secretKey } ` ,
99
+ Authorization : `${ this . secretKey } ` ,
81
100
} ,
82
101
}
83
102
)
0 commit comments