@flareapp/react 2.4.0 → 2.5.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/README.md +10 -0
- package/dist/flareReactErrorHandler-4Vgqlths.d.cts +95 -0
- package/dist/flareReactErrorHandler-BECMhASE.cjs +289 -0
- package/dist/flareReactErrorHandler-BcVYRMtC.d.mts +95 -0
- package/dist/flareReactErrorHandler-FqJ6hQZc.mjs +233 -0
- package/dist/index.cjs +5 -221
- package/dist/index.d.cts +1 -89
- package/dist/index.d.mts +1 -89
- package/dist/index.mjs +4 -193
- package/dist/inject.cjs +5 -0
- package/dist/inject.d.cts +2 -0
- package/dist/inject.d.mts +2 -0
- package/dist/inject.mjs +3 -0
- package/package.json +22 -3
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Component, version } from "react";
|
|
3
|
+
import { convertToError } from "@flareapp/core";
|
|
4
|
+
|
|
5
|
+
//#region src/constants.ts
|
|
6
|
+
const CHROMIUM_STACK_REGEX = /^at\s+(\S+)(?:\s+\((.+):(\d+):(\d+)\))?$/;
|
|
7
|
+
const FIREFOX_SAFARI_STACK_REGEX = /^(\S+?)@(.+):(\d+):(\d+)$/;
|
|
8
|
+
const PACKAGE_VERSION = typeof process !== "undefined" && true ? "2.5.1" : "?";
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/identify.ts
|
|
12
|
+
const sdkTagged = /* @__PURE__ */ new WeakSet();
|
|
13
|
+
const frameworkTagged = /* @__PURE__ */ new WeakSet();
|
|
14
|
+
function registerReactSdkIdentity(flare) {
|
|
15
|
+
if (!sdkTagged.has(flare)) {
|
|
16
|
+
sdkTagged.add(flare);
|
|
17
|
+
flare.setSdkInfo({
|
|
18
|
+
name: "@flareapp/react",
|
|
19
|
+
version: PACKAGE_VERSION
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
tagReactFramework(flare);
|
|
23
|
+
}
|
|
24
|
+
function tagReactFramework(flare) {
|
|
25
|
+
if (frameworkTagged.has(flare)) return;
|
|
26
|
+
frameworkTagged.add(flare);
|
|
27
|
+
flare.setFramework({
|
|
28
|
+
name: "React",
|
|
29
|
+
version: React.version
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/resolveFlare.ts
|
|
35
|
+
let defaultProvider = null;
|
|
36
|
+
function isDevMode() {
|
|
37
|
+
try {
|
|
38
|
+
return process.env.NODE_ENV !== "production";
|
|
39
|
+
} catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function registerDefaultFlare(provider) {
|
|
44
|
+
if (typeof window !== "undefined" && window.__flare) {
|
|
45
|
+
const message = "[flare] @flareapp/react (web root) was imported in a renderer where the Electron bridge is present, pulling the keyed @flareapp/js singleton into the renderer. Import @flareapp/react/inject and pass the @flareapp/electron/renderer instance instead.";
|
|
46
|
+
if (isDevMode()) throw new Error(message);
|
|
47
|
+
console.warn(message);
|
|
48
|
+
}
|
|
49
|
+
defaultProvider = provider;
|
|
50
|
+
}
|
|
51
|
+
function resolveFlare(explicit) {
|
|
52
|
+
if (explicit) return explicit;
|
|
53
|
+
if (defaultProvider) return defaultProvider();
|
|
54
|
+
throw new Error("[flare] No Flare instance available. Pass `flare` (e.g. from @flareapp/electron/renderer), or import @flareapp/react (the package root) to use the @flareapp/js default singleton.");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/formatComponentStack.ts
|
|
59
|
+
function formatComponentStack(stack) {
|
|
60
|
+
return stack.split(/\s*\n\s*/g).filter((line) => line.length > 0);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/parseComponentStack.ts
|
|
65
|
+
function parseComponentStack(stack) {
|
|
66
|
+
return stack.split(/\s*\n\s*/g).filter((line) => line.length > 0).map((line) => {
|
|
67
|
+
const chromeMatch = line.match(CHROMIUM_STACK_REGEX);
|
|
68
|
+
if (chromeMatch) return {
|
|
69
|
+
component: chromeMatch[1],
|
|
70
|
+
file: chromeMatch[2] ?? null,
|
|
71
|
+
line: chromeMatch[3] ? Number(chromeMatch[3]) : null,
|
|
72
|
+
column: chromeMatch[4] ? Number(chromeMatch[4]) : null
|
|
73
|
+
};
|
|
74
|
+
const firefoxSafariMatch = line.match(FIREFOX_SAFARI_STACK_REGEX);
|
|
75
|
+
if (firefoxSafariMatch) return {
|
|
76
|
+
component: firefoxSafariMatch[1],
|
|
77
|
+
file: firefoxSafariMatch[2],
|
|
78
|
+
line: Number(firefoxSafariMatch[3]),
|
|
79
|
+
column: Number(firefoxSafariMatch[4])
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
component: line.replace(/^at\s+/, ""),
|
|
83
|
+
file: null,
|
|
84
|
+
line: null,
|
|
85
|
+
column: null
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/parseMinifiedReactError.ts
|
|
92
|
+
const NUMBER_PATTERN = /Minified React error #(\d+)/;
|
|
93
|
+
const ARG_PATTERN = /args\[\]=([^&\s]*)/g;
|
|
94
|
+
const URL_PATTERN = /(https?:\/\/\S+)/;
|
|
95
|
+
function safeDecode(value) {
|
|
96
|
+
try {
|
|
97
|
+
return decodeURIComponent(value);
|
|
98
|
+
} catch {
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function parseMinifiedReactError(error) {
|
|
103
|
+
const message = error?.message;
|
|
104
|
+
if (!message) return null;
|
|
105
|
+
const numberMatch = message.match(NUMBER_PATTERN);
|
|
106
|
+
if (!numberMatch) return null;
|
|
107
|
+
const args = [];
|
|
108
|
+
for (const match of message.matchAll(ARG_PATTERN)) args.push(safeDecode(match[1]));
|
|
109
|
+
const urlMatch = message.match(URL_PATTERN);
|
|
110
|
+
return {
|
|
111
|
+
number: Number(numberMatch[1]),
|
|
112
|
+
args,
|
|
113
|
+
url: urlMatch ? urlMatch[1] : null
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/buildReactContext.ts
|
|
119
|
+
function buildReactContext(rawStack, error) {
|
|
120
|
+
const minifiedError = parseMinifiedReactError(error);
|
|
121
|
+
return { react: {
|
|
122
|
+
componentStack: formatComponentStack(rawStack),
|
|
123
|
+
componentStackFrames: parseComponentStack(rawStack),
|
|
124
|
+
version,
|
|
125
|
+
...minifiedError ? { minifiedError } : {}
|
|
126
|
+
} };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/contextToAttributes.ts
|
|
131
|
+
function contextToAttributes(context) {
|
|
132
|
+
return { "context.custom": { react: {
|
|
133
|
+
componentStack: context.react.componentStack,
|
|
134
|
+
componentStackFrames: context.react.componentStackFrames,
|
|
135
|
+
...context.react.version ? { version: context.react.version } : {},
|
|
136
|
+
...context.react.minifiedError ? { minifiedError: context.react.minifiedError } : {}
|
|
137
|
+
} } };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/FlareErrorBoundary.ts
|
|
142
|
+
var FlareErrorBoundary = class extends Component {
|
|
143
|
+
flare;
|
|
144
|
+
constructor(props) {
|
|
145
|
+
super(props);
|
|
146
|
+
this.flare = resolveFlare(props.flare);
|
|
147
|
+
tagReactFramework(this.flare);
|
|
148
|
+
}
|
|
149
|
+
state = {
|
|
150
|
+
error: null,
|
|
151
|
+
componentStack: []
|
|
152
|
+
};
|
|
153
|
+
static getDerivedStateFromError(error) {
|
|
154
|
+
return { error };
|
|
155
|
+
}
|
|
156
|
+
componentDidCatch(error, errorInfo) {
|
|
157
|
+
this.props.beforeEvaluate?.({
|
|
158
|
+
error,
|
|
159
|
+
errorInfo
|
|
160
|
+
});
|
|
161
|
+
const context = buildReactContext(errorInfo.componentStack ?? "", error);
|
|
162
|
+
const finalContext = this.props.beforeSubmit?.({
|
|
163
|
+
error,
|
|
164
|
+
errorInfo,
|
|
165
|
+
context
|
|
166
|
+
}) ?? context;
|
|
167
|
+
this.setState({ componentStack: finalContext.react.componentStack });
|
|
168
|
+
this.flare.reportSilently(error, contextToAttributes(finalContext));
|
|
169
|
+
this.props.afterSubmit?.({
|
|
170
|
+
error,
|
|
171
|
+
errorInfo,
|
|
172
|
+
context: finalContext
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
componentDidUpdate(prevProps) {
|
|
176
|
+
if (this.state.error === null || !this.props.resetKeys) return;
|
|
177
|
+
const prevKeys = prevProps.resetKeys;
|
|
178
|
+
const nextKeys = this.props.resetKeys;
|
|
179
|
+
const lengthChanged = prevKeys?.length !== nextKeys.length;
|
|
180
|
+
const valuesChanged = nextKeys.some((key, i) => !Object.is(key, prevKeys?.[i]));
|
|
181
|
+
if (lengthChanged || valuesChanged) this.reset();
|
|
182
|
+
}
|
|
183
|
+
reset = () => {
|
|
184
|
+
const { error } = this.state;
|
|
185
|
+
this.props.onReset?.(error);
|
|
186
|
+
this.setState({
|
|
187
|
+
error: null,
|
|
188
|
+
componentStack: []
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
render() {
|
|
192
|
+
const { error } = this.state;
|
|
193
|
+
if (error !== null) {
|
|
194
|
+
const { fallback } = this.props;
|
|
195
|
+
if (typeof fallback === "function") return fallback({
|
|
196
|
+
error,
|
|
197
|
+
componentStack: this.state.componentStack,
|
|
198
|
+
resetErrorBoundary: this.reset
|
|
199
|
+
});
|
|
200
|
+
return fallback ?? null;
|
|
201
|
+
}
|
|
202
|
+
return this.props.children;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/flareReactErrorHandler.ts
|
|
208
|
+
function flareReactErrorHandler(options) {
|
|
209
|
+
const flare = resolveFlare(options?.flare);
|
|
210
|
+
tagReactFramework(flare);
|
|
211
|
+
return (error, errorInfo) => {
|
|
212
|
+
const errorObject = convertToError(error);
|
|
213
|
+
options?.beforeEvaluate?.({
|
|
214
|
+
error: errorObject,
|
|
215
|
+
errorInfo
|
|
216
|
+
});
|
|
217
|
+
const context = buildReactContext(errorInfo.componentStack ?? "", errorObject);
|
|
218
|
+
const finalContext = options?.beforeSubmit?.({
|
|
219
|
+
error: errorObject,
|
|
220
|
+
errorInfo,
|
|
221
|
+
context
|
|
222
|
+
}) ?? context;
|
|
223
|
+
flare.reportSilently(errorObject, contextToAttributes(finalContext));
|
|
224
|
+
options?.afterSubmit?.({
|
|
225
|
+
error: errorObject,
|
|
226
|
+
errorInfo,
|
|
227
|
+
context: finalContext
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
//#endregion
|
|
233
|
+
export { registerReactSdkIdentity as i, FlareErrorBoundary as n, registerDefaultFlare as r, flareReactErrorHandler as t };
|
package/dist/index.cjs
CHANGED
|
@@ -1,227 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
-
key = keys[i];
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: ((k) => from[k]).bind(null, key),
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
-
value: mod,
|
|
25
|
-
enumerable: true
|
|
26
|
-
}) : target, mod));
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
2
|
+
const require_flareReactErrorHandler = require('./flareReactErrorHandler-BECMhASE.cjs');
|
|
29
3
|
let _flareapp_js = require("@flareapp/js");
|
|
30
|
-
let react = require("react");
|
|
31
|
-
react = __toESM(react);
|
|
32
|
-
|
|
33
|
-
//#region src/constants.ts
|
|
34
|
-
const CHROMIUM_STACK_REGEX = /^at\s+(\S+)(?:\s+\((.+):(\d+):(\d+)\))?$/;
|
|
35
|
-
const FIREFOX_SAFARI_STACK_REGEX = /^(\S+?)@(.+):(\d+):(\d+)$/;
|
|
36
|
-
const PACKAGE_VERSION = typeof process !== "undefined" && true ? "2.4.0" : "?";
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/identify.ts
|
|
40
|
-
let registered = false;
|
|
41
|
-
function registerReactSdkIdentity() {
|
|
42
|
-
if (registered) return;
|
|
43
|
-
registered = true;
|
|
44
|
-
_flareapp_js.flare.setSdkInfo({
|
|
45
|
-
name: "@flareapp/react",
|
|
46
|
-
version: PACKAGE_VERSION
|
|
47
|
-
});
|
|
48
|
-
_flareapp_js.flare.setFramework({
|
|
49
|
-
name: "React",
|
|
50
|
-
version: react.version
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/formatComponentStack.ts
|
|
56
|
-
function formatComponentStack(stack) {
|
|
57
|
-
return stack.split(/\s*\n\s*/g).filter((line) => line.length > 0);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
//#endregion
|
|
61
|
-
//#region src/parseComponentStack.ts
|
|
62
|
-
function parseComponentStack(stack) {
|
|
63
|
-
return stack.split(/\s*\n\s*/g).filter((line) => line.length > 0).map((line) => {
|
|
64
|
-
const chromeMatch = line.match(CHROMIUM_STACK_REGEX);
|
|
65
|
-
if (chromeMatch) return {
|
|
66
|
-
component: chromeMatch[1],
|
|
67
|
-
file: chromeMatch[2] ?? null,
|
|
68
|
-
line: chromeMatch[3] ? Number(chromeMatch[3]) : null,
|
|
69
|
-
column: chromeMatch[4] ? Number(chromeMatch[4]) : null
|
|
70
|
-
};
|
|
71
|
-
const firefoxSafariMatch = line.match(FIREFOX_SAFARI_STACK_REGEX);
|
|
72
|
-
if (firefoxSafariMatch) return {
|
|
73
|
-
component: firefoxSafariMatch[1],
|
|
74
|
-
file: firefoxSafariMatch[2],
|
|
75
|
-
line: Number(firefoxSafariMatch[3]),
|
|
76
|
-
column: Number(firefoxSafariMatch[4])
|
|
77
|
-
};
|
|
78
|
-
return {
|
|
79
|
-
component: line.replace(/^at\s+/, ""),
|
|
80
|
-
file: null,
|
|
81
|
-
line: null,
|
|
82
|
-
column: null
|
|
83
|
-
};
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/parseMinifiedReactError.ts
|
|
89
|
-
const NUMBER_PATTERN = /Minified React error #(\d+)/;
|
|
90
|
-
const ARG_PATTERN = /args\[\]=([^&\s]*)/g;
|
|
91
|
-
const URL_PATTERN = /(https?:\/\/\S+)/;
|
|
92
|
-
function safeDecode(value) {
|
|
93
|
-
try {
|
|
94
|
-
return decodeURIComponent(value);
|
|
95
|
-
} catch {
|
|
96
|
-
return value;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function parseMinifiedReactError(error) {
|
|
100
|
-
const message = error?.message;
|
|
101
|
-
if (!message) return null;
|
|
102
|
-
const numberMatch = message.match(NUMBER_PATTERN);
|
|
103
|
-
if (!numberMatch) return null;
|
|
104
|
-
const args = [];
|
|
105
|
-
for (const match of message.matchAll(ARG_PATTERN)) args.push(safeDecode(match[1]));
|
|
106
|
-
const urlMatch = message.match(URL_PATTERN);
|
|
107
|
-
return {
|
|
108
|
-
number: Number(numberMatch[1]),
|
|
109
|
-
args,
|
|
110
|
-
url: urlMatch ? urlMatch[1] : null
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region src/buildReactContext.ts
|
|
116
|
-
function buildReactContext(rawStack, error) {
|
|
117
|
-
const minifiedError = parseMinifiedReactError(error);
|
|
118
|
-
return { react: {
|
|
119
|
-
componentStack: formatComponentStack(rawStack),
|
|
120
|
-
componentStackFrames: parseComponentStack(rawStack),
|
|
121
|
-
version: react.version,
|
|
122
|
-
...minifiedError ? { minifiedError } : {}
|
|
123
|
-
} };
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
//#endregion
|
|
127
|
-
//#region src/contextToAttributes.ts
|
|
128
|
-
function contextToAttributes(context) {
|
|
129
|
-
return { "context.custom": { react: {
|
|
130
|
-
componentStack: context.react.componentStack,
|
|
131
|
-
componentStackFrames: context.react.componentStackFrames,
|
|
132
|
-
...context.react.version ? { version: context.react.version } : {},
|
|
133
|
-
...context.react.minifiedError ? { minifiedError: context.react.minifiedError } : {}
|
|
134
|
-
} } };
|
|
135
|
-
}
|
|
136
4
|
|
|
137
|
-
//#endregion
|
|
138
|
-
//#region src/FlareErrorBoundary.ts
|
|
139
|
-
var FlareErrorBoundary = class extends react.Component {
|
|
140
|
-
state = {
|
|
141
|
-
error: null,
|
|
142
|
-
componentStack: []
|
|
143
|
-
};
|
|
144
|
-
static getDerivedStateFromError(error) {
|
|
145
|
-
return { error };
|
|
146
|
-
}
|
|
147
|
-
componentDidCatch(error, errorInfo) {
|
|
148
|
-
this.props.beforeEvaluate?.({
|
|
149
|
-
error,
|
|
150
|
-
errorInfo
|
|
151
|
-
});
|
|
152
|
-
const context = buildReactContext(errorInfo.componentStack ?? "", error);
|
|
153
|
-
const finalContext = this.props.beforeSubmit?.({
|
|
154
|
-
error,
|
|
155
|
-
errorInfo,
|
|
156
|
-
context
|
|
157
|
-
}) ?? context;
|
|
158
|
-
this.setState({ componentStack: finalContext.react.componentStack });
|
|
159
|
-
_flareapp_js.flare.reportSilently(error, contextToAttributes(finalContext));
|
|
160
|
-
this.props.afterSubmit?.({
|
|
161
|
-
error,
|
|
162
|
-
errorInfo,
|
|
163
|
-
context: finalContext
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
componentDidUpdate(prevProps) {
|
|
167
|
-
if (this.state.error === null || !this.props.resetKeys) return;
|
|
168
|
-
const prevKeys = prevProps.resetKeys;
|
|
169
|
-
const nextKeys = this.props.resetKeys;
|
|
170
|
-
const lengthChanged = prevKeys?.length !== nextKeys.length;
|
|
171
|
-
const valuesChanged = nextKeys.some((key, i) => !Object.is(key, prevKeys?.[i]));
|
|
172
|
-
if (lengthChanged || valuesChanged) this.reset();
|
|
173
|
-
}
|
|
174
|
-
reset = () => {
|
|
175
|
-
const { error } = this.state;
|
|
176
|
-
this.props.onReset?.(error);
|
|
177
|
-
this.setState({
|
|
178
|
-
error: null,
|
|
179
|
-
componentStack: []
|
|
180
|
-
});
|
|
181
|
-
};
|
|
182
|
-
render() {
|
|
183
|
-
const { error } = this.state;
|
|
184
|
-
if (error !== null) {
|
|
185
|
-
const { fallback } = this.props;
|
|
186
|
-
if (typeof fallback === "function") return fallback({
|
|
187
|
-
error,
|
|
188
|
-
componentStack: this.state.componentStack,
|
|
189
|
-
resetErrorBoundary: this.reset
|
|
190
|
-
});
|
|
191
|
-
return fallback ?? null;
|
|
192
|
-
}
|
|
193
|
-
return this.props.children;
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
//#endregion
|
|
198
|
-
//#region src/flareReactErrorHandler.ts
|
|
199
|
-
function flareReactErrorHandler(options) {
|
|
200
|
-
return (error, errorInfo) => {
|
|
201
|
-
const errorObject = (0, _flareapp_js.convertToError)(error);
|
|
202
|
-
options?.beforeEvaluate?.({
|
|
203
|
-
error: errorObject,
|
|
204
|
-
errorInfo
|
|
205
|
-
});
|
|
206
|
-
const context = buildReactContext(errorInfo.componentStack ?? "", errorObject);
|
|
207
|
-
const finalContext = options?.beforeSubmit?.({
|
|
208
|
-
error: errorObject,
|
|
209
|
-
errorInfo,
|
|
210
|
-
context
|
|
211
|
-
}) ?? context;
|
|
212
|
-
_flareapp_js.flare.reportSilently(errorObject, contextToAttributes(finalContext));
|
|
213
|
-
options?.afterSubmit?.({
|
|
214
|
-
error: errorObject,
|
|
215
|
-
errorInfo,
|
|
216
|
-
context: finalContext
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
//#endregion
|
|
222
5
|
//#region src/index.ts
|
|
223
|
-
|
|
6
|
+
require_flareReactErrorHandler.registerDefaultFlare(() => _flareapp_js.flare);
|
|
7
|
+
require_flareReactErrorHandler.registerReactSdkIdentity(_flareapp_js.flare);
|
|
224
8
|
|
|
225
9
|
//#endregion
|
|
226
|
-
exports.FlareErrorBoundary = FlareErrorBoundary;
|
|
227
|
-
exports.flareReactErrorHandler = flareReactErrorHandler;
|
|
10
|
+
exports.FlareErrorBoundary = require_flareReactErrorHandler.FlareErrorBoundary;
|
|
11
|
+
exports.flareReactErrorHandler = require_flareReactErrorHandler.flareReactErrorHandler;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,90 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/types.d.ts
|
|
4
|
-
type ComponentStackFrame = {
|
|
5
|
-
component: string;
|
|
6
|
-
file: string | null;
|
|
7
|
-
line: number | null;
|
|
8
|
-
column: number | null;
|
|
9
|
-
};
|
|
10
|
-
type MinifiedReactError = {
|
|
11
|
-
number: number;
|
|
12
|
-
args: string[];
|
|
13
|
-
url: string | null;
|
|
14
|
-
};
|
|
15
|
-
type FlareReactContext = {
|
|
16
|
-
react: {
|
|
17
|
-
componentStack: string[];
|
|
18
|
-
componentStackFrames: ComponentStackFrame[];
|
|
19
|
-
version?: string;
|
|
20
|
-
minifiedError?: MinifiedReactError;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/FlareErrorBoundary.d.ts
|
|
25
|
-
type FlareErrorBoundaryFallbackProps = {
|
|
26
|
-
error: Error;
|
|
27
|
-
componentStack: string[];
|
|
28
|
-
resetErrorBoundary: () => void;
|
|
29
|
-
};
|
|
30
|
-
type FlareErrorBoundaryProps = PropsWithChildren<{
|
|
31
|
-
fallback?: ReactNode | ((props: FlareErrorBoundaryFallbackProps) => ReactNode);
|
|
32
|
-
resetKeys?: unknown[];
|
|
33
|
-
beforeEvaluate?: (params: {
|
|
34
|
-
error: Error;
|
|
35
|
-
errorInfo: ErrorInfo;
|
|
36
|
-
}) => void;
|
|
37
|
-
beforeSubmit?: (params: {
|
|
38
|
-
error: Error;
|
|
39
|
-
errorInfo: ErrorInfo;
|
|
40
|
-
context: FlareReactContext;
|
|
41
|
-
}) => FlareReactContext;
|
|
42
|
-
afterSubmit?: (params: {
|
|
43
|
-
error: Error;
|
|
44
|
-
errorInfo: ErrorInfo;
|
|
45
|
-
context: FlareReactContext;
|
|
46
|
-
}) => void;
|
|
47
|
-
onReset?: (error: Error | null) => void;
|
|
48
|
-
}>;
|
|
49
|
-
type FlareErrorBoundaryState = {
|
|
50
|
-
error: Error | null;
|
|
51
|
-
componentStack: string[];
|
|
52
|
-
};
|
|
53
|
-
declare class FlareErrorBoundary extends Component<FlareErrorBoundaryProps, FlareErrorBoundaryState> {
|
|
54
|
-
state: FlareErrorBoundaryState;
|
|
55
|
-
static getDerivedStateFromError(error: Error): Partial<FlareErrorBoundaryState>;
|
|
56
|
-
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
57
|
-
componentDidUpdate(prevProps: FlareErrorBoundaryProps): void;
|
|
58
|
-
reset: () => void;
|
|
59
|
-
render(): ReactNode;
|
|
60
|
-
}
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/flareReactErrorHandler.d.ts
|
|
63
|
-
type FlareReactErrorHandlerCallback = (error: unknown, errorInfo: {
|
|
64
|
-
componentStack?: string;
|
|
65
|
-
}) => void;
|
|
66
|
-
type FlareReactErrorHandlerOptions = {
|
|
67
|
-
beforeEvaluate?: (params: {
|
|
68
|
-
error: Error;
|
|
69
|
-
errorInfo: {
|
|
70
|
-
componentStack?: string;
|
|
71
|
-
};
|
|
72
|
-
}) => void;
|
|
73
|
-
beforeSubmit?: (params: {
|
|
74
|
-
error: Error;
|
|
75
|
-
errorInfo: {
|
|
76
|
-
componentStack?: string;
|
|
77
|
-
};
|
|
78
|
-
context: FlareReactContext;
|
|
79
|
-
}) => FlareReactContext;
|
|
80
|
-
afterSubmit?: (params: {
|
|
81
|
-
error: Error;
|
|
82
|
-
errorInfo: {
|
|
83
|
-
componentStack?: string;
|
|
84
|
-
};
|
|
85
|
-
context: FlareReactContext;
|
|
86
|
-
}) => void;
|
|
87
|
-
};
|
|
88
|
-
declare function flareReactErrorHandler(options?: FlareReactErrorHandlerOptions): FlareReactErrorHandlerCallback;
|
|
89
|
-
//#endregion
|
|
1
|
+
import { a as FlareErrorBoundaryFallbackProps, c as FlareReactContext, i as FlareErrorBoundary, l as MinifiedReactError, n as FlareReactErrorHandlerOptions, o as FlareErrorBoundaryProps, r as flareReactErrorHandler, s as ComponentStackFrame, t as FlareReactErrorHandlerCallback } from "./flareReactErrorHandler-4Vgqlths.cjs";
|
|
90
2
|
export { type ComponentStackFrame, FlareErrorBoundary, type FlareErrorBoundaryFallbackProps, type FlareErrorBoundaryProps, type FlareReactContext, type FlareReactErrorHandlerCallback, type FlareReactErrorHandlerOptions, type MinifiedReactError, flareReactErrorHandler };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,90 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/types.d.ts
|
|
4
|
-
type ComponentStackFrame = {
|
|
5
|
-
component: string;
|
|
6
|
-
file: string | null;
|
|
7
|
-
line: number | null;
|
|
8
|
-
column: number | null;
|
|
9
|
-
};
|
|
10
|
-
type MinifiedReactError = {
|
|
11
|
-
number: number;
|
|
12
|
-
args: string[];
|
|
13
|
-
url: string | null;
|
|
14
|
-
};
|
|
15
|
-
type FlareReactContext = {
|
|
16
|
-
react: {
|
|
17
|
-
componentStack: string[];
|
|
18
|
-
componentStackFrames: ComponentStackFrame[];
|
|
19
|
-
version?: string;
|
|
20
|
-
minifiedError?: MinifiedReactError;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/FlareErrorBoundary.d.ts
|
|
25
|
-
type FlareErrorBoundaryFallbackProps = {
|
|
26
|
-
error: Error;
|
|
27
|
-
componentStack: string[];
|
|
28
|
-
resetErrorBoundary: () => void;
|
|
29
|
-
};
|
|
30
|
-
type FlareErrorBoundaryProps = PropsWithChildren<{
|
|
31
|
-
fallback?: ReactNode | ((props: FlareErrorBoundaryFallbackProps) => ReactNode);
|
|
32
|
-
resetKeys?: unknown[];
|
|
33
|
-
beforeEvaluate?: (params: {
|
|
34
|
-
error: Error;
|
|
35
|
-
errorInfo: ErrorInfo;
|
|
36
|
-
}) => void;
|
|
37
|
-
beforeSubmit?: (params: {
|
|
38
|
-
error: Error;
|
|
39
|
-
errorInfo: ErrorInfo;
|
|
40
|
-
context: FlareReactContext;
|
|
41
|
-
}) => FlareReactContext;
|
|
42
|
-
afterSubmit?: (params: {
|
|
43
|
-
error: Error;
|
|
44
|
-
errorInfo: ErrorInfo;
|
|
45
|
-
context: FlareReactContext;
|
|
46
|
-
}) => void;
|
|
47
|
-
onReset?: (error: Error | null) => void;
|
|
48
|
-
}>;
|
|
49
|
-
type FlareErrorBoundaryState = {
|
|
50
|
-
error: Error | null;
|
|
51
|
-
componentStack: string[];
|
|
52
|
-
};
|
|
53
|
-
declare class FlareErrorBoundary extends Component<FlareErrorBoundaryProps, FlareErrorBoundaryState> {
|
|
54
|
-
state: FlareErrorBoundaryState;
|
|
55
|
-
static getDerivedStateFromError(error: Error): Partial<FlareErrorBoundaryState>;
|
|
56
|
-
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
57
|
-
componentDidUpdate(prevProps: FlareErrorBoundaryProps): void;
|
|
58
|
-
reset: () => void;
|
|
59
|
-
render(): ReactNode;
|
|
60
|
-
}
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/flareReactErrorHandler.d.ts
|
|
63
|
-
type FlareReactErrorHandlerCallback = (error: unknown, errorInfo: {
|
|
64
|
-
componentStack?: string;
|
|
65
|
-
}) => void;
|
|
66
|
-
type FlareReactErrorHandlerOptions = {
|
|
67
|
-
beforeEvaluate?: (params: {
|
|
68
|
-
error: Error;
|
|
69
|
-
errorInfo: {
|
|
70
|
-
componentStack?: string;
|
|
71
|
-
};
|
|
72
|
-
}) => void;
|
|
73
|
-
beforeSubmit?: (params: {
|
|
74
|
-
error: Error;
|
|
75
|
-
errorInfo: {
|
|
76
|
-
componentStack?: string;
|
|
77
|
-
};
|
|
78
|
-
context: FlareReactContext;
|
|
79
|
-
}) => FlareReactContext;
|
|
80
|
-
afterSubmit?: (params: {
|
|
81
|
-
error: Error;
|
|
82
|
-
errorInfo: {
|
|
83
|
-
componentStack?: string;
|
|
84
|
-
};
|
|
85
|
-
context: FlareReactContext;
|
|
86
|
-
}) => void;
|
|
87
|
-
};
|
|
88
|
-
declare function flareReactErrorHandler(options?: FlareReactErrorHandlerOptions): FlareReactErrorHandlerCallback;
|
|
89
|
-
//#endregion
|
|
1
|
+
import { a as FlareErrorBoundaryFallbackProps, c as FlareReactContext, i as FlareErrorBoundary, l as MinifiedReactError, n as FlareReactErrorHandlerOptions, o as FlareErrorBoundaryProps, r as flareReactErrorHandler, s as ComponentStackFrame, t as FlareReactErrorHandlerCallback } from "./flareReactErrorHandler-BcVYRMtC.mjs";
|
|
90
2
|
export { type ComponentStackFrame, FlareErrorBoundary, type FlareErrorBoundaryFallbackProps, type FlareErrorBoundaryProps, type FlareReactContext, type FlareReactErrorHandlerCallback, type FlareReactErrorHandlerOptions, type MinifiedReactError, flareReactErrorHandler };
|