@ttt-productions/monitoring-core 0.2.16 → 0.3.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/dist/react/error-boundary.d.ts +25 -0
- package/dist/react/error-boundary.d.ts.map +1 -0
- package/dist/react/error-boundary.js +26 -0
- package/dist/react/error-boundary.js.map +1 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +3 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +19 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Component, type ErrorInfo, type ReactNode } from "react";
|
|
2
|
+
export interface ErrorBoundaryProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
/** Rendered when an error has been caught. */
|
|
5
|
+
fallback: ReactNode;
|
|
6
|
+
/** Identifier sent to monitoring (e.g. "checkout-page"). */
|
|
7
|
+
context: string;
|
|
8
|
+
/** Optional callback invoked alongside captureException. */
|
|
9
|
+
onError?: (error: Error, info: ErrorInfo) => void;
|
|
10
|
+
}
|
|
11
|
+
interface ErrorBoundaryState {
|
|
12
|
+
hasError: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Generic React Error Boundary that reports to the configured monitoring
|
|
16
|
+
* provider via `captureException`. The fallback UI is fully consumer-owned.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
19
|
+
state: ErrorBoundaryState;
|
|
20
|
+
static getDerivedStateFromError(): ErrorBoundaryState;
|
|
21
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
22
|
+
render(): ReactNode;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=error-boundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../../src/react/error-boundary.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,8CAA8C;IAC9C,QAAQ,EAAE,SAAS,CAAC;IACpB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACnD;AAED,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AACH,qBAAa,aAAc,SAAQ,SAAS,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAClF,KAAK,EAAE,kBAAkB,CAAuB;IAEhD,MAAM,CAAC,wBAAwB,IAAI,kBAAkB;IAIrD,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS;IAQpD,MAAM;CAIP"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Component } from "react";
|
|
3
|
+
import { captureException } from "../api.js";
|
|
4
|
+
/**
|
|
5
|
+
* Generic React Error Boundary that reports to the configured monitoring
|
|
6
|
+
* provider via `captureException`. The fallback UI is fully consumer-owned.
|
|
7
|
+
*/
|
|
8
|
+
export class ErrorBoundary extends Component {
|
|
9
|
+
state = { hasError: false };
|
|
10
|
+
static getDerivedStateFromError() {
|
|
11
|
+
return { hasError: true };
|
|
12
|
+
}
|
|
13
|
+
componentDidCatch(error, errorInfo) {
|
|
14
|
+
captureException(error, {
|
|
15
|
+
componentStack: errorInfo.componentStack,
|
|
16
|
+
context: this.props.context,
|
|
17
|
+
});
|
|
18
|
+
this.props.onError?.(error, errorInfo);
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
if (this.state.hasError)
|
|
22
|
+
return this.props.fallback;
|
|
23
|
+
return this.props.children;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=error-boundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-boundary.js","sourceRoot":"","sources":["../../src/react/error-boundary.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAAkC,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAgB7C;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAiD;IAClF,KAAK,GAAuB,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAEhD,MAAM,CAAC,wBAAwB;QAC7B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED,iBAAiB,CAAC,KAAY,EAAE,SAAoB;QAClD,gBAAgB,CAAC,KAAK,EAAE;YACtB,cAAc,EAAE,SAAS,CAAC,cAAc;YACxC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;SAC5B,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACzC,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttt-productions/monitoring-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/ttt-productions/ttt-packages.git",
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
".": {
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
23
|
"default": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./react": {
|
|
26
|
+
"types": "./dist/react/index.d.ts",
|
|
27
|
+
"default": "./dist/react/index.js"
|
|
24
28
|
}
|
|
25
29
|
},
|
|
26
30
|
"scripts": {
|
|
@@ -31,7 +35,9 @@
|
|
|
31
35
|
},
|
|
32
36
|
"peerDependencies": {
|
|
33
37
|
"@sentry/nextjs": "^10.32.1",
|
|
34
|
-
"@sentry/node": "^10.32.1"
|
|
38
|
+
"@sentry/node": "^10.32.1",
|
|
39
|
+
"react": ">=18.0.0",
|
|
40
|
+
"react-dom": ">=18.0.0"
|
|
35
41
|
},
|
|
36
42
|
"peerDependenciesMeta": {
|
|
37
43
|
"@sentry/nextjs": {
|
|
@@ -39,12 +45,22 @@
|
|
|
39
45
|
},
|
|
40
46
|
"@sentry/node": {
|
|
41
47
|
"optional": true
|
|
48
|
+
},
|
|
49
|
+
"react": {
|
|
50
|
+
"optional": true
|
|
51
|
+
},
|
|
52
|
+
"react-dom": {
|
|
53
|
+
"optional": true
|
|
42
54
|
}
|
|
43
55
|
},
|
|
44
56
|
"devDependencies": {
|
|
45
57
|
"typescript": "^5.8.3",
|
|
46
58
|
"@sentry/nextjs": "^10.32.1",
|
|
47
|
-
"@sentry/node": "^10.32.1"
|
|
59
|
+
"@sentry/node": "^10.32.1",
|
|
60
|
+
"react": "^19.2.0",
|
|
61
|
+
"react-dom": "^19.2.0",
|
|
62
|
+
"@types/react": "^19.0.0",
|
|
63
|
+
"@types/react-dom": "^19.0.0"
|
|
48
64
|
},
|
|
49
65
|
"author": "DJ (TTT Productions)",
|
|
50
66
|
"license": "MIT"
|