browser-error-log-react 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +62 -2
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/package.json +42 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hyeonse Im
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,63 @@
|
|
|
1
|
-
#
|
|
1
|
+
# browser-error-log-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A React Error Boundary for Browser Error Log. It forwards render errors and React component stacks to an existing browser SDK client, so React errors use the same collector and collection policies as the rest of your app.
|
|
4
|
+
|
|
5
|
+
The declared React peer range is `>=18 <20`; this range is not a claim of verification against every React version or framework.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
In a React app, install the browser SDK and adapter:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install browser-error-log browser-error-log-react
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
React must already be installed in your app. The adapter does not bundle React. For local source-checkout tarballs before publication, follow the [SDK guide](https://github.com/hyeonse-swing/browser-error-log/blob/main/docs/personal-sdk.md) to install protocol, browser, and React tarballs together.
|
|
16
|
+
|
|
17
|
+
## Use in your browser entry point
|
|
18
|
+
|
|
19
|
+
Start the repository's self-hosted collector with your app origin allowed:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
MICRO_PROJECTS=my-web MICRO_ALLOWED_ORIGINS=http://localhost:5173 npm run micro
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Initialize a client once in browser code, then wrap the part of the UI you want to protect:
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { init } from 'browser-error-log';
|
|
29
|
+
import { ErrorBoundary } from 'browser-error-log-react';
|
|
30
|
+
|
|
31
|
+
const errorLog = init({
|
|
32
|
+
project: 'my-web',
|
|
33
|
+
endpoint: 'http://127.0.0.1:4319/api/events',
|
|
34
|
+
environment: 'development',
|
|
35
|
+
release: 'my-release',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export function Root() {
|
|
39
|
+
return (
|
|
40
|
+
<ErrorBoundary
|
|
41
|
+
client={errorLog}
|
|
42
|
+
fallback={(_error, reset) => (
|
|
43
|
+
<section>
|
|
44
|
+
<p>This view could not be displayed.</p>
|
|
45
|
+
<button onClick={reset}>Try again</button>
|
|
46
|
+
</section>
|
|
47
|
+
)}
|
|
48
|
+
>
|
|
49
|
+
<App />
|
|
50
|
+
</ErrorBoundary>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`App` above is your application component. The fallback can be a React node or a function receiving the error and a reset callback. Reset clears the boundary's error state and retries rendering its children; fix the underlying state if rendering would fail again. With no fallback, a failed boundary renders nothing.
|
|
56
|
+
|
|
57
|
+
Use a client entry point in SSR frameworks. Importing the SDK on the server is safe but does not collect server errors. This boundary handles errors React passes to `componentDidCatch`; use `captureException` for handled errors and the base SDK for global JavaScript, promise, and network error capture. It is not native crash monitoring or a server-side error handler.
|
|
58
|
+
|
|
59
|
+
Open `http://127.0.0.1:4319/` to inspect collected events. For an externally accessible deployment, use your own HTTPS collector and the [self-hosting guide](https://github.com/hyeonse-swing/browser-error-log/blob/main/docs/micro-server.md). Never put the viewer password in browser code.
|
|
60
|
+
|
|
61
|
+
## Hosting and costs
|
|
62
|
+
|
|
63
|
+
Infrastructure is not included. Hosting, servers, databases, storage, bandwidth, domains, backups, and third-party services are selected and paid for by each operator. Any charges are billed independently by their providers, not by this project or its maintainers.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var l=Object.create;var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var h=(r,e,t)=>e in r?a(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var R=(r,e)=>{for(var t in e)a(r,t,{get:e[t],enumerable:!0})},i=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of u(e))!f.call(r,o)&&o!==t&&a(r,o,{get:()=>e[o],enumerable:!(n=d(e,o))||n.enumerable});return r};var y=(r,e,t)=>(t=r!=null?l(E(r)):{},i(e||!r||!r.__esModule?a(t,"default",{value:r,enumerable:!0}):t,r)),m=r=>i(a({},"__esModule",{value:!0}),r);var c=(r,e,t)=>h(r,typeof e!="symbol"?e+"":e,t);var S={};R(S,{ErrorBoundary:()=>s});module.exports=m(S);var p=y(require("react"),1);var s=class extends p.Component{constructor(){super(...arguments);c(this,"state",{error:null});c(this,"reset",()=>{this.setState({error:null})})}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){try{this.props.client.captureException(t,{type:"react",componentStack:n.componentStack??void 0})}catch{}}render(){let t=this.state.error;return t?typeof this.props.fallback=="function"?this.props.fallback(t,this.reset):this.props.fallback??null:this.props.children}};
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport type { BrowserErrorLogClient } from 'browser-error-log';\n\nexport interface ErrorBoundaryProps {\n client: BrowserErrorLogClient;\n children: React.ReactNode;\n fallback?: React.ReactNode | ((error: Error, reset: () => void) => React.ReactNode);\n}\n\ninterface ErrorBoundaryState { error: Error | null }\n\nexport class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {\n state: ErrorBoundaryState = { error: null };\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return { error };\n }\n\n componentDidCatch(error: Error, info: React.ErrorInfo): void {\n try {\n this.props.client.captureException(error, {\n type: 'react',\n componentStack: info.componentStack ?? undefined,\n });\n } catch { /* a diagnostics hook must not replace the render error */ }\n }\n\n private readonly reset = (): void => { this.setState({ error: null }); };\n\n render(): React.ReactNode {\n const error = this.state.error;\n if (!error) return this.props.children;\n return typeof this.props.fallback === 'function'\n ? this.props.fallback(error, this.reset)\n : (this.props.fallback ?? null);\n }\n}\n"],
|
|
5
|
+
"mappings": "ksBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAuB,sBAWhB,IAAMC,EAAN,cAAkC,WAAkD,CAApF,kCACLC,EAAA,aAA4B,CAAE,MAAO,IAAK,GAe1CA,EAAA,KAAiB,QAAQ,IAAY,CAAE,KAAK,SAAS,CAAE,MAAO,IAAK,CAAC,CAAG,GAbvE,OAAO,yBAAyBC,EAAkC,CAChE,MAAO,CAAE,MAAAA,CAAM,CACjB,CAEA,kBAAkBA,EAAcC,EAA6B,CAC3D,GAAI,CACF,KAAK,MAAM,OAAO,iBAAiBD,EAAO,CACxC,KAAM,QACN,eAAgBC,EAAK,gBAAkB,MACzC,CAAC,CACH,MAAQ,CAA6D,CACvE,CAIA,QAA0B,CACxB,IAAMD,EAAQ,KAAK,MAAM,MACzB,OAAKA,EACE,OAAO,KAAK,MAAM,UAAa,WAClC,KAAK,MAAM,SAASA,EAAO,KAAK,KAAK,EACpC,KAAK,MAAM,UAAY,KAHT,KAAK,MAAM,QAIhC,CACF",
|
|
6
|
+
"names": ["index_exports", "__export", "ErrorBoundary", "__toCommonJS", "React", "ErrorBoundary", "__publicField", "error", "info"]
|
|
7
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { BrowserErrorLogClient } from 'browser-error-log';
|
|
3
|
+
export interface ErrorBoundaryProps {
|
|
4
|
+
client: BrowserErrorLogClient;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
fallback?: React.ReactNode | ((error: Error, reset: () => void) => React.ReactNode);
|
|
7
|
+
}
|
|
8
|
+
interface ErrorBoundaryState {
|
|
9
|
+
error: Error | null;
|
|
10
|
+
}
|
|
11
|
+
export declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
12
|
+
state: ErrorBoundaryState;
|
|
13
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
14
|
+
componentDidCatch(error: Error, info: React.ErrorInfo): void;
|
|
15
|
+
private readonly reset;
|
|
16
|
+
render(): React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/react/src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;CACrF;AAED,UAAU,kBAAkB;IAAG,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;CAAE;AAEpD,qBAAa,aAAc,SAAQ,KAAK,CAAC,SAAS,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IACxF,KAAK,EAAE,kBAAkB,CAAmB;IAE5C,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,kBAAkB,CAEhE;IAED,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAO3D;IAED,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmD;IAEzE,MAAM,IAAI,KAAK,CAAC,SAAS,CAMxB;CACF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var s=Object.defineProperty;var i=(t,e,r)=>e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var o=(t,e,r)=>i(t,typeof e!="symbol"?e+"":e,r);import*as n from"react";var a=class extends n.Component{constructor(){super(...arguments);o(this,"state",{error:null});o(this,"reset",()=>{this.setState({error:null})})}static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,c){try{this.props.client.captureException(r,{type:"react",componentStack:c.componentStack??void 0})}catch{}}render(){let r=this.state.error;return r?typeof this.props.fallback=="function"?this.props.fallback(r,this.reset):this.props.fallback??null:this.props.children}};export{a as ErrorBoundary};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport type { BrowserErrorLogClient } from 'browser-error-log';\n\nexport interface ErrorBoundaryProps {\n client: BrowserErrorLogClient;\n children: React.ReactNode;\n fallback?: React.ReactNode | ((error: Error, reset: () => void) => React.ReactNode);\n}\n\ninterface ErrorBoundaryState { error: Error | null }\n\nexport class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {\n state: ErrorBoundaryState = { error: null };\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return { error };\n }\n\n componentDidCatch(error: Error, info: React.ErrorInfo): void {\n try {\n this.props.client.captureException(error, {\n type: 'react',\n componentStack: info.componentStack ?? undefined,\n });\n } catch { /* a diagnostics hook must not replace the render error */ }\n }\n\n private readonly reset = (): void => { this.setState({ error: null }); };\n\n render(): React.ReactNode {\n const error = this.state.error;\n if (!error) return this.props.children;\n return typeof this.props.fallback === 'function'\n ? this.props.fallback(error, this.reset)\n : (this.props.fallback ?? null);\n }\n}\n"],
|
|
5
|
+
"mappings": "oKAAA,UAAYA,MAAW,QAWhB,IAAMC,EAAN,cAAkC,WAAkD,CAApF,kCACLC,EAAA,aAA4B,CAAE,MAAO,IAAK,GAe1CA,EAAA,KAAiB,QAAQ,IAAY,CAAE,KAAK,SAAS,CAAE,MAAO,IAAK,CAAC,CAAG,GAbvE,OAAO,yBAAyBC,EAAkC,CAChE,MAAO,CAAE,MAAAA,CAAM,CACjB,CAEA,kBAAkBA,EAAcC,EAA6B,CAC3D,GAAI,CACF,KAAK,MAAM,OAAO,iBAAiBD,EAAO,CACxC,KAAM,QACN,eAAgBC,EAAK,gBAAkB,MACzC,CAAC,CACH,MAAQ,CAA6D,CACvE,CAIA,QAA0B,CACxB,IAAMD,EAAQ,KAAK,MAAM,MACzB,OAAKA,EACE,OAAO,KAAK,MAAM,UAAa,WAClC,KAAK,MAAM,SAASA,EAAO,KAAK,KAAK,EACpC,KAAK,MAAM,UAAY,KAHT,KAAK,MAAM,QAIhC,CACF",
|
|
6
|
+
"names": ["React", "ErrorBoundary", "__publicField", "error", "info"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-error-log-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A React Error Boundary adapter for the self-hosted Browser Error Log SDK.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"error-boundary",
|
|
8
|
+
"error-monitoring",
|
|
9
|
+
"self-hosted"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"registry": "https://registry.npmjs.org/"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"require": "./dist/index.cjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"react": ">=18 <20"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"browser-error-log": "0.1.0"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/hyeonse-swing/browser-error-log.git",
|
|
38
|
+
"directory": "packages/react"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/hyeonse-swing/browser-error-log#readme",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/hyeonse-swing/browser-error-log/issues"
|
|
43
|
+
}
|
|
44
|
+
}
|