@flareapp/js 2.0.0 → 2.0.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.cjs +25 -4
- package/dist/index.d.cts +5 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.mjs +25 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -35,20 +35,20 @@ function catchWindowErrors() {
|
|
|
35
35
|
window.addEventListener("error", (event) => {
|
|
36
36
|
const flare = window.flare;
|
|
37
37
|
if (!flare) return;
|
|
38
|
-
if (event.error instanceof Error)
|
|
38
|
+
if (event.error instanceof Error) flare.reportSilently(event.error);
|
|
39
39
|
});
|
|
40
40
|
window.addEventListener("unhandledrejection", (event) => {
|
|
41
41
|
const flare = window.flare;
|
|
42
42
|
if (!flare) return;
|
|
43
43
|
const reason = event.reason;
|
|
44
44
|
if (reason instanceof Error) {
|
|
45
|
-
|
|
45
|
+
flare.reportSilently(reason);
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
if (hasStack$1(reason)) {
|
|
49
49
|
const error = new Error(describeRejectionReason(reason));
|
|
50
50
|
error.stack = reason.stack;
|
|
51
|
-
|
|
51
|
+
flare.reportSilently(error);
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
Promise.resolve(flare.reportUnhandledRejection(describeRejectionReason(reason))).catch(() => {});
|
|
@@ -73,7 +73,7 @@ function hasStack$1(value) {
|
|
|
73
73
|
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/env/index.ts
|
|
76
|
-
const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.0.
|
|
76
|
+
const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.0.1" : "?";
|
|
77
77
|
const KEY = typeof FLARE_JS_KEY === "undefined" ? "" : FLARE_JS_KEY;
|
|
78
78
|
const SOURCEMAP_VERSION = typeof FLARE_SOURCEMAP_VERSION === "undefined" ? "" : FLARE_SOURCEMAP_VERSION;
|
|
79
79
|
|
|
@@ -84,6 +84,22 @@ function assert(value, message, debug) {
|
|
|
84
84
|
return !!value;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/util/convertToError.ts
|
|
89
|
+
function convertToError(error) {
|
|
90
|
+
if (error instanceof Error) return error;
|
|
91
|
+
if (typeof error === "string") return new Error(error);
|
|
92
|
+
if (typeof error === "object" && error !== null) {
|
|
93
|
+
const obj = error;
|
|
94
|
+
const message = typeof obj.message === "string" ? obj.message : String(error);
|
|
95
|
+
const converted = new Error(message);
|
|
96
|
+
if (typeof obj.stack === "string") converted.stack = obj.stack;
|
|
97
|
+
if (typeof obj.name === "string") converted.name = obj.name;
|
|
98
|
+
return converted;
|
|
99
|
+
}
|
|
100
|
+
return new Error(String(error));
|
|
101
|
+
}
|
|
102
|
+
|
|
87
103
|
//#endregion
|
|
88
104
|
//#region src/util/assertKey.ts
|
|
89
105
|
function assertKey(key, debug) {
|
|
@@ -475,6 +491,7 @@ var Flare = class {
|
|
|
475
491
|
}
|
|
476
492
|
setFramework(framework) {
|
|
477
493
|
this.framework = framework;
|
|
494
|
+
this.addContext("framework", framework.name.toLowerCase());
|
|
478
495
|
return this;
|
|
479
496
|
}
|
|
480
497
|
async report(error, attributes = {}) {
|
|
@@ -487,6 +504,9 @@ var Flare = class {
|
|
|
487
504
|
if (!report) return;
|
|
488
505
|
return this.sendReport(report);
|
|
489
506
|
}
|
|
507
|
+
reportSilently(error, attributes = {}) {
|
|
508
|
+
Promise.resolve(this.report(error, attributes)).catch(() => {});
|
|
509
|
+
}
|
|
490
510
|
async reportUnhandledRejection(message, attributes = {}) {
|
|
491
511
|
if (Math.random() >= this._config.sampleRate) return;
|
|
492
512
|
const seenAtUnixNano = Date.now() * 1e6;
|
|
@@ -598,6 +618,7 @@ if (typeof window !== "undefined" && window) {
|
|
|
598
618
|
//#endregion
|
|
599
619
|
exports.DEFAULT_URL_DENYLIST = DEFAULT_URL_DENYLIST;
|
|
600
620
|
exports.Flare = Flare;
|
|
621
|
+
exports.convertToError = convertToError;
|
|
601
622
|
exports.flare = flare;
|
|
602
623
|
exports.redactFullPath = redactFullPath;
|
|
603
624
|
exports.resolveDenylist = resolveDenylist;
|
package/dist/index.d.cts
CHANGED
|
@@ -104,6 +104,7 @@ declare class Flare {
|
|
|
104
104
|
setSdkInfo(info: SdkInfo): Flare;
|
|
105
105
|
setFramework(framework: Framework): Flare;
|
|
106
106
|
report(error: Error, attributes?: Attributes): Promise<void>;
|
|
107
|
+
reportSilently(error: Error, attributes?: Attributes): void;
|
|
107
108
|
reportUnhandledRejection(message: string, attributes?: Attributes): Promise<void>;
|
|
108
109
|
reportMessage(message: string, level?: MessageLevel, attributes?: Attributes): Promise<void>;
|
|
109
110
|
createReportFromError(error: Error, attributes?: Attributes, seenAtUnixNano?: number): Promise<Report | false>;
|
|
@@ -111,6 +112,9 @@ declare class Flare {
|
|
|
111
112
|
sendReport(report: Report): Promise<void>;
|
|
112
113
|
}
|
|
113
114
|
//#endregion
|
|
115
|
+
//#region src/util/convertToError.d.ts
|
|
116
|
+
declare function convertToError(error: unknown): Error;
|
|
117
|
+
//#endregion
|
|
114
118
|
//#region src/util/redactUrl.d.ts
|
|
115
119
|
declare const DEFAULT_URL_DENYLIST: RegExp;
|
|
116
120
|
declare function resolveDenylist(custom?: RegExp, replaceDefault?: boolean, defaultDenylist?: RegExp): RegExp;
|
|
@@ -119,4 +123,4 @@ declare function redactFullPath(fullPath: string, denylist?: RegExp): string;
|
|
|
119
123
|
//#region src/index.d.ts
|
|
120
124
|
declare const flare: Flare;
|
|
121
125
|
//#endregion
|
|
122
|
-
export { type AttributeValue, type Attributes, type Config, DEFAULT_URL_DENYLIST, type EntryPointHandler, Flare, type Framework, type Glow, type MessageLevel, type OverriddenGrouping, type Report, type SdkInfo, type SpanEvent, type StackFrame, flare, redactFullPath, resolveDenylist };
|
|
126
|
+
export { type AttributeValue, type Attributes, type Config, DEFAULT_URL_DENYLIST, type EntryPointHandler, Flare, type Framework, type Glow, type MessageLevel, type OverriddenGrouping, type Report, type SdkInfo, type SpanEvent, type StackFrame, convertToError, flare, redactFullPath, resolveDenylist };
|
package/dist/index.d.mts
CHANGED
|
@@ -104,6 +104,7 @@ declare class Flare {
|
|
|
104
104
|
setSdkInfo(info: SdkInfo): Flare;
|
|
105
105
|
setFramework(framework: Framework): Flare;
|
|
106
106
|
report(error: Error, attributes?: Attributes): Promise<void>;
|
|
107
|
+
reportSilently(error: Error, attributes?: Attributes): void;
|
|
107
108
|
reportUnhandledRejection(message: string, attributes?: Attributes): Promise<void>;
|
|
108
109
|
reportMessage(message: string, level?: MessageLevel, attributes?: Attributes): Promise<void>;
|
|
109
110
|
createReportFromError(error: Error, attributes?: Attributes, seenAtUnixNano?: number): Promise<Report | false>;
|
|
@@ -111,6 +112,9 @@ declare class Flare {
|
|
|
111
112
|
sendReport(report: Report): Promise<void>;
|
|
112
113
|
}
|
|
113
114
|
//#endregion
|
|
115
|
+
//#region src/util/convertToError.d.ts
|
|
116
|
+
declare function convertToError(error: unknown): Error;
|
|
117
|
+
//#endregion
|
|
114
118
|
//#region src/util/redactUrl.d.ts
|
|
115
119
|
declare const DEFAULT_URL_DENYLIST: RegExp;
|
|
116
120
|
declare function resolveDenylist(custom?: RegExp, replaceDefault?: boolean, defaultDenylist?: RegExp): RegExp;
|
|
@@ -119,4 +123,4 @@ declare function redactFullPath(fullPath: string, denylist?: RegExp): string;
|
|
|
119
123
|
//#region src/index.d.ts
|
|
120
124
|
declare const flare: Flare;
|
|
121
125
|
//#endregion
|
|
122
|
-
export { type AttributeValue, type Attributes, type Config, DEFAULT_URL_DENYLIST, type EntryPointHandler, Flare, type Framework, type Glow, type MessageLevel, type OverriddenGrouping, type Report, type SdkInfo, type SpanEvent, type StackFrame, flare, redactFullPath, resolveDenylist };
|
|
126
|
+
export { type AttributeValue, type Attributes, type Config, DEFAULT_URL_DENYLIST, type EntryPointHandler, Flare, type Framework, type Glow, type MessageLevel, type OverriddenGrouping, type Report, type SdkInfo, type SpanEvent, type StackFrame, convertToError, flare, redactFullPath, resolveDenylist };
|
package/dist/index.mjs
CHANGED
|
@@ -6,20 +6,20 @@ function catchWindowErrors() {
|
|
|
6
6
|
window.addEventListener("error", (event) => {
|
|
7
7
|
const flare = window.flare;
|
|
8
8
|
if (!flare) return;
|
|
9
|
-
if (event.error instanceof Error)
|
|
9
|
+
if (event.error instanceof Error) flare.reportSilently(event.error);
|
|
10
10
|
});
|
|
11
11
|
window.addEventListener("unhandledrejection", (event) => {
|
|
12
12
|
const flare = window.flare;
|
|
13
13
|
if (!flare) return;
|
|
14
14
|
const reason = event.reason;
|
|
15
15
|
if (reason instanceof Error) {
|
|
16
|
-
|
|
16
|
+
flare.reportSilently(reason);
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
if (hasStack$1(reason)) {
|
|
20
20
|
const error = new Error(describeRejectionReason(reason));
|
|
21
21
|
error.stack = reason.stack;
|
|
22
|
-
|
|
22
|
+
flare.reportSilently(error);
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
Promise.resolve(flare.reportUnhandledRejection(describeRejectionReason(reason))).catch(() => {});
|
|
@@ -44,7 +44,7 @@ function hasStack$1(value) {
|
|
|
44
44
|
|
|
45
45
|
//#endregion
|
|
46
46
|
//#region src/env/index.ts
|
|
47
|
-
const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.0.
|
|
47
|
+
const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.0.1" : "?";
|
|
48
48
|
const KEY = typeof FLARE_JS_KEY === "undefined" ? "" : FLARE_JS_KEY;
|
|
49
49
|
const SOURCEMAP_VERSION = typeof FLARE_SOURCEMAP_VERSION === "undefined" ? "" : FLARE_SOURCEMAP_VERSION;
|
|
50
50
|
|
|
@@ -55,6 +55,22 @@ function assert(value, message, debug) {
|
|
|
55
55
|
return !!value;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/util/convertToError.ts
|
|
60
|
+
function convertToError(error) {
|
|
61
|
+
if (error instanceof Error) return error;
|
|
62
|
+
if (typeof error === "string") return new Error(error);
|
|
63
|
+
if (typeof error === "object" && error !== null) {
|
|
64
|
+
const obj = error;
|
|
65
|
+
const message = typeof obj.message === "string" ? obj.message : String(error);
|
|
66
|
+
const converted = new Error(message);
|
|
67
|
+
if (typeof obj.stack === "string") converted.stack = obj.stack;
|
|
68
|
+
if (typeof obj.name === "string") converted.name = obj.name;
|
|
69
|
+
return converted;
|
|
70
|
+
}
|
|
71
|
+
return new Error(String(error));
|
|
72
|
+
}
|
|
73
|
+
|
|
58
74
|
//#endregion
|
|
59
75
|
//#region src/util/assertKey.ts
|
|
60
76
|
function assertKey(key, debug) {
|
|
@@ -446,6 +462,7 @@ var Flare = class {
|
|
|
446
462
|
}
|
|
447
463
|
setFramework(framework) {
|
|
448
464
|
this.framework = framework;
|
|
465
|
+
this.addContext("framework", framework.name.toLowerCase());
|
|
449
466
|
return this;
|
|
450
467
|
}
|
|
451
468
|
async report(error, attributes = {}) {
|
|
@@ -458,6 +475,9 @@ var Flare = class {
|
|
|
458
475
|
if (!report) return;
|
|
459
476
|
return this.sendReport(report);
|
|
460
477
|
}
|
|
478
|
+
reportSilently(error, attributes = {}) {
|
|
479
|
+
Promise.resolve(this.report(error, attributes)).catch(() => {});
|
|
480
|
+
}
|
|
461
481
|
async reportUnhandledRejection(message, attributes = {}) {
|
|
462
482
|
if (Math.random() >= this._config.sampleRate) return;
|
|
463
483
|
const seenAtUnixNano = Date.now() * 1e6;
|
|
@@ -567,4 +587,4 @@ if (typeof window !== "undefined" && window) {
|
|
|
567
587
|
}
|
|
568
588
|
|
|
569
589
|
//#endregion
|
|
570
|
-
export { DEFAULT_URL_DENYLIST, Flare, flare, redactFullPath, resolveDenylist };
|
|
590
|
+
export { DEFAULT_URL_DENYLIST, Flare, convertToError, flare, redactFullPath, resolveDenylist };
|