@flareapp/js 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +31 -8
- package/dist/index.mjs +31 -8
- package/package.json +1 -1
- package/src/browser/catchWindowErrors.ts +41 -7
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
38
|
// src/env/index.ts
|
|
39
|
-
var CLIENT_VERSION = false ? "?" : "1.2.
|
|
39
|
+
var CLIENT_VERSION = false ? "?" : "1.2.1";
|
|
40
40
|
var KEY = typeof FLARE_JS_KEY === "undefined" ? "" : FLARE_JS_KEY;
|
|
41
41
|
var SOURCEMAP_VERSION = typeof FLARE_SOURCEMAP_VERSION === "undefined" ? "" : FLARE_SOURCEMAP_VERSION;
|
|
42
42
|
|
|
@@ -592,16 +592,39 @@ function catchWindowErrors() {
|
|
|
592
592
|
flare2.report(reason);
|
|
593
593
|
return;
|
|
594
594
|
}
|
|
595
|
-
|
|
596
|
-
|
|
595
|
+
if (hasStack2(reason)) {
|
|
596
|
+
const error = new Error(rejectionReasonToMessage(reason));
|
|
597
|
+
error.stack = reason.stack;
|
|
598
|
+
flare2.report(error);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
flare2.reportMessage(rejectionReasonToMessage(reason), {}, "UnhandledPromiseRejection");
|
|
597
602
|
});
|
|
598
603
|
}
|
|
599
|
-
function
|
|
600
|
-
|
|
601
|
-
return
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
+
function rejectionReasonToMessage(reason) {
|
|
605
|
+
if (typeof reason === "string") {
|
|
606
|
+
return reason;
|
|
607
|
+
}
|
|
608
|
+
if (reason == null) {
|
|
609
|
+
return `Unhandled promise rejection (${reason})`;
|
|
604
610
|
}
|
|
611
|
+
if (typeof reason === "object") {
|
|
612
|
+
if ("message" in reason && typeof reason.message === "string") {
|
|
613
|
+
return reason.message;
|
|
614
|
+
}
|
|
615
|
+
try {
|
|
616
|
+
const json = JSON.stringify(reason);
|
|
617
|
+
if (json && json !== "{}") {
|
|
618
|
+
return `Unhandled promise rejection: ${json}`;
|
|
619
|
+
}
|
|
620
|
+
} catch {
|
|
621
|
+
}
|
|
622
|
+
return "Unhandled promise rejection with non-serializable object";
|
|
623
|
+
}
|
|
624
|
+
return `Unhandled promise rejection: ${String(reason)}`;
|
|
625
|
+
}
|
|
626
|
+
function hasStack2(value) {
|
|
627
|
+
return typeof value === "object" && value !== null && "stack" in value && typeof value.stack === "string";
|
|
605
628
|
}
|
|
606
629
|
|
|
607
630
|
// src/index.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/env/index.ts
|
|
2
|
-
var CLIENT_VERSION = false ? "?" : "1.2.
|
|
2
|
+
var CLIENT_VERSION = false ? "?" : "1.2.1";
|
|
3
3
|
var KEY = typeof FLARE_JS_KEY === "undefined" ? "" : FLARE_JS_KEY;
|
|
4
4
|
var SOURCEMAP_VERSION = typeof FLARE_SOURCEMAP_VERSION === "undefined" ? "" : FLARE_SOURCEMAP_VERSION;
|
|
5
5
|
|
|
@@ -555,16 +555,39 @@ function catchWindowErrors() {
|
|
|
555
555
|
flare2.report(reason);
|
|
556
556
|
return;
|
|
557
557
|
}
|
|
558
|
-
|
|
559
|
-
|
|
558
|
+
if (hasStack2(reason)) {
|
|
559
|
+
const error = new Error(rejectionReasonToMessage(reason));
|
|
560
|
+
error.stack = reason.stack;
|
|
561
|
+
flare2.report(error);
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
flare2.reportMessage(rejectionReasonToMessage(reason), {}, "UnhandledPromiseRejection");
|
|
560
565
|
});
|
|
561
566
|
}
|
|
562
|
-
function
|
|
563
|
-
|
|
564
|
-
return
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
+
function rejectionReasonToMessage(reason) {
|
|
568
|
+
if (typeof reason === "string") {
|
|
569
|
+
return reason;
|
|
570
|
+
}
|
|
571
|
+
if (reason == null) {
|
|
572
|
+
return `Unhandled promise rejection (${reason})`;
|
|
567
573
|
}
|
|
574
|
+
if (typeof reason === "object") {
|
|
575
|
+
if ("message" in reason && typeof reason.message === "string") {
|
|
576
|
+
return reason.message;
|
|
577
|
+
}
|
|
578
|
+
try {
|
|
579
|
+
const json = JSON.stringify(reason);
|
|
580
|
+
if (json && json !== "{}") {
|
|
581
|
+
return `Unhandled promise rejection: ${json}`;
|
|
582
|
+
}
|
|
583
|
+
} catch {
|
|
584
|
+
}
|
|
585
|
+
return "Unhandled promise rejection with non-serializable object";
|
|
586
|
+
}
|
|
587
|
+
return `Unhandled promise rejection: ${String(reason)}`;
|
|
588
|
+
}
|
|
589
|
+
function hasStack2(value) {
|
|
590
|
+
return typeof value === "object" && value !== null && "stack" in value && typeof value.stack === "string";
|
|
568
591
|
}
|
|
569
592
|
|
|
570
593
|
// src/index.ts
|
package/package.json
CHANGED
|
@@ -24,15 +24,49 @@ export function catchWindowErrors() {
|
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
if (hasStack(reason)) {
|
|
28
|
+
const error = new Error(rejectionReasonToMessage(reason));
|
|
29
|
+
error.stack = (reason as { stack: string }).stack;
|
|
30
|
+
flare.report(error);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
flare.reportMessage(rejectionReasonToMessage(reason), {}, 'UnhandledPromiseRejection');
|
|
29
35
|
});
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
return
|
|
35
|
-
} catch {
|
|
36
|
-
return String(value);
|
|
38
|
+
function rejectionReasonToMessage(reason: unknown): string {
|
|
39
|
+
if (typeof reason === 'string') {
|
|
40
|
+
return reason;
|
|
37
41
|
}
|
|
42
|
+
|
|
43
|
+
if (reason == null) {
|
|
44
|
+
return `Unhandled promise rejection (${reason})`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (typeof reason === 'object') {
|
|
48
|
+
if ('message' in reason && typeof (reason as Record<string, unknown>).message === 'string') {
|
|
49
|
+
return (reason as Record<string, unknown>).message as string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const json = JSON.stringify(reason);
|
|
54
|
+
if (json && json !== '{}') {
|
|
55
|
+
return `Unhandled promise rejection: ${json}`;
|
|
56
|
+
}
|
|
57
|
+
} catch {}
|
|
58
|
+
|
|
59
|
+
return 'Unhandled promise rejection with non-serializable object';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return `Unhandled promise rejection: ${String(reason)}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function hasStack(value: unknown): boolean {
|
|
66
|
+
return (
|
|
67
|
+
typeof value === 'object' &&
|
|
68
|
+
value !== null &&
|
|
69
|
+
'stack' in value &&
|
|
70
|
+
typeof (value as Record<string, unknown>).stack === 'string'
|
|
71
|
+
);
|
|
38
72
|
}
|