@argusdev/sdk-react 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/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # @argusdev/sdk-react
2
+
3
+ React SDK for [Argus](https://github.com/oluwatobicode/argus) — an error boundary on top of `@argusdev/sdk-browser`. Catches render crashes that `window.onerror` misses.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @argusdev/sdk-react
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import { init, ArgusErrorBoundary } from "@argusdev/sdk-react";
15
+
16
+ init({ dsn: "https://<publicKey>@<host>/<projectId>" });
17
+
18
+ function Root() {
19
+ return (
20
+ <ArgusErrorBoundary fallback={<p>Something went wrong.</p>}>
21
+ <App />
22
+ </ArgusErrorBoundary>
23
+ );
24
+ }
25
+ ```
26
+
27
+ `init()` sets up the same global handlers as `@argusdev/sdk-browser` (so you only need one import), and the boundary reports React render errors with the crashing component.
28
+
29
+ MIT © Treasure Odetokun
@@ -0,0 +1,15 @@
1
+ import { Component, type ErrorInfo, type ReactNode } from "react";
2
+ interface Props {
3
+ children?: ReactNode;
4
+ fallback?: ReactNode;
5
+ }
6
+ interface State {
7
+ hasError: boolean;
8
+ }
9
+ export declare class ArgusErrorBoundary extends Component<Props, State> {
10
+ state: State;
11
+ static getDerivedStateFromError(): State;
12
+ componentDidCatch(error: Error, info: ErrorInfo): void;
13
+ render(): ReactNode;
14
+ }
15
+ export {};
@@ -0,0 +1,36 @@
1
+ import { Component } from "react";
2
+ import { captureException } from "@argusdev/sdk-browser";
3
+ /*
4
+ * Usage:
5
+ * <ArgusErrorBoundary fallback={<p>Something went wrong</p>}>
6
+ * <App />
7
+ * </ArgusErrorBoundary>
8
+ *
9
+ * React render crashes don't reach window.onerror in production builds —
10
+ * boundaries are the only reliable hook, and they must be class components
11
+ * (React exposes componentDidCatch nowhere else).
12
+ */
13
+ export class ArgusErrorBoundary extends Component {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.state = { hasError: false };
17
+ }
18
+ static getDerivedStateFromError() {
19
+ return { hasError: true };
20
+ }
21
+ componentDidCatch(error, info) {
22
+ void captureException(error, {
23
+ /* componentStack is the React tree path to the crash — goldmine for debugging */
24
+ tags: info.componentStack
25
+ ? { componentStack: info.componentStack.trim().split("\n")[0] ?? "" }
26
+ : undefined,
27
+ });
28
+ }
29
+ render() {
30
+ if (this.state.hasError) {
31
+ return this.props.fallback ?? null;
32
+ }
33
+ return this.props.children;
34
+ }
35
+ }
36
+ //# sourceMappingURL=ErrorBoundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../src/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkC,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAYzD;;;;;;;;;GASG;AACH,MAAM,OAAO,kBAAmB,SAAQ,SAAuB;IAA/D;;QACE,UAAK,GAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAqBrC,CAAC;IAnBC,MAAM,CAAC,wBAAwB;QAC7B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED,iBAAiB,CAAC,KAAY,EAAE,IAAe;QAC7C,KAAK,gBAAgB,CAAC,KAAK,EAAE;YAC3B,iFAAiF;YACjF,IAAI,EAAE,IAAI,CAAC,cAAc;gBACvB,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE;gBACrE,CAAC,CAAC,SAAS;SACd,CAAC,CAAC;IACL,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export { ArgusErrorBoundary } from "./ErrorBoundary";
2
+ export { init, captureException } from "@argusdev/sdk-browser";
3
+ export type { InitOptions } from "@argusdev/sdk-browser";
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ /* Public surface of @argusdev/sdk-react */
2
+ export { ArgusErrorBoundary } from "./ErrorBoundary";
3
+ /* re-export the browser SDK so React users need exactly one import:
4
+ import { init, ArgusErrorBoundary } from "@argusdev/sdk-react" */
5
+ export { init, captureException } from "@argusdev/sdk-browser";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAE3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD;oEACoE;AACpE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@argusdev/sdk-react",
3
+ "version": "0.1.0",
4
+ "description": "Argus SDK for React — ErrorBoundary component on top of @argusdev/sdk-browser.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "dev": "tsc --watch",
20
+ "typecheck": "tsc --noEmit"
21
+ },
22
+ "dependencies": {
23
+ "@argusdev/sdk-browser": "workspace:*",
24
+ "@argusdev/sdk-core": "workspace:*"
25
+ },
26
+ "peerDependencies": {
27
+ "react": ">=18"
28
+ },
29
+ "devDependencies": {
30
+ "@types/react": "^19.0.0",
31
+ "typescript": "~6.0.3"
32
+ },
33
+ "license": "MIT",
34
+ "author": "Treasure Odetokun",
35
+ "homepage": "https://github.com/oluwatobicode/argus#readme",
36
+ "keywords": [
37
+ "argus",
38
+ "error-tracking",
39
+ "monitoring",
40
+ "sdk",
41
+ "react"
42
+ ],
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/oluwatobicode/argus.git",
46
+ "directory": "packages/sdk-react"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ }
51
+ }