@uncaughtdev/react 0.1.0 → 0.2.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 +30 -3
- package/dist/index.d.mts +40 -3
- package/dist/index.d.ts +40 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ React and Next.js SDK for [Uncaught](https://github.com/AjeeshDevops/uncaught) e
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npx
|
|
8
|
+
npx uncaughtdev init
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Or manually:
|
|
@@ -17,11 +17,38 @@ npm install @uncaughtdev/react
|
|
|
17
17
|
## What's included
|
|
18
18
|
|
|
19
19
|
- `<UncaughtProvider>` — wraps your app, auto-captures errors
|
|
20
|
-
- React Error Boundary with componentStack capture
|
|
20
|
+
- React Error Boundary with componentStack capture and user feedback widget
|
|
21
|
+
- `useErrorHandler` hook — wraps event handlers (onClick, onChange) with error capture
|
|
22
|
+
- `withErrorCapture` HOF — standalone error wrapping for class components
|
|
23
|
+
- Web Vitals tracking (LCP, FID, CLS, FCP, TTFB) via native PerformanceObserver
|
|
24
|
+
- DOM breadcrumbs (clicks, navigation, fetch tracking, XHR tracking)
|
|
21
25
|
- Global error and unhandled rejection handlers
|
|
22
|
-
- DOM breadcrumbs (clicks, navigation, fetch tracking)
|
|
23
26
|
- Next.js App Router and Pages Router support
|
|
24
27
|
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { UncaughtProvider, UncaughtErrorBoundary, useErrorHandler } from '@uncaughtdev/react';
|
|
32
|
+
|
|
33
|
+
function App() {
|
|
34
|
+
return (
|
|
35
|
+
<UncaughtProvider projectKey="my-app">
|
|
36
|
+
<UncaughtErrorBoundary showDialog>
|
|
37
|
+
<MyApp />
|
|
38
|
+
</UncaughtErrorBoundary>
|
|
39
|
+
</UncaughtProvider>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function MyComponent() {
|
|
44
|
+
const handleClick = useErrorHandler(() => {
|
|
45
|
+
riskyOperation(); // Errors captured automatically
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return <button onClick={handleClick}>Click</button>;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
25
52
|
## License
|
|
26
53
|
|
|
27
54
|
MIT
|
package/dist/index.d.mts
CHANGED
|
@@ -106,12 +106,20 @@ declare const UncaughtContext: React$1.Context<UncaughtContextValue>;
|
|
|
106
106
|
* </UncaughtErrorBoundary>
|
|
107
107
|
* ```
|
|
108
108
|
*/
|
|
109
|
-
declare class UncaughtErrorBoundary extends Component<UncaughtErrorBoundaryProps, ErrorBoundaryState
|
|
109
|
+
declare class UncaughtErrorBoundary extends Component<UncaughtErrorBoundaryProps, ErrorBoundaryState & {
|
|
110
|
+
feedback: string;
|
|
111
|
+
feedbackSent: boolean;
|
|
112
|
+
lastEventId: string | null;
|
|
113
|
+
}> {
|
|
110
114
|
static contextType: React__default.Context<UncaughtContextValue>;
|
|
111
115
|
context: React__default.ContextType<typeof UncaughtContext>;
|
|
112
116
|
private removePopstateListener;
|
|
113
117
|
constructor(props: UncaughtErrorBoundaryProps);
|
|
114
|
-
static getDerivedStateFromError(error: Error): ErrorBoundaryState
|
|
118
|
+
static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState & {
|
|
119
|
+
feedback: string;
|
|
120
|
+
feedbackSent: boolean;
|
|
121
|
+
lastEventId: string | null;
|
|
122
|
+
}>;
|
|
115
123
|
componentDidCatch(error: Error, errorInfo: React__default.ErrorInfo): void;
|
|
116
124
|
componentDidMount(): void;
|
|
117
125
|
componentWillUnmount(): void;
|
|
@@ -143,8 +151,37 @@ declare function useReportError(): (error: Error, context?: Record<string, unkno
|
|
|
143
151
|
*
|
|
144
152
|
* @returns A function `(breadcrumb: Partial<Breadcrumb>) => void`
|
|
145
153
|
*/
|
|
154
|
+
/**
|
|
155
|
+
* Wraps a callback function with error capture.
|
|
156
|
+
* Use this for event handlers (onClick, onChange, etc.) that React Error
|
|
157
|
+
* Boundary does not catch.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```tsx
|
|
161
|
+
* const handleClick = useErrorHandler((e) => {
|
|
162
|
+
* // risky code that might throw
|
|
163
|
+
* });
|
|
164
|
+
* <button onClick={handleClick}>Click</button>
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
declare function useErrorHandler<T extends (...args: unknown[]) => unknown>(fn: T): T;
|
|
168
|
+
/**
|
|
169
|
+
* Standalone HOF (non-hook) that wraps a function with error capture.
|
|
170
|
+
* Use in class components or outside React context.
|
|
171
|
+
*/
|
|
172
|
+
declare function withErrorCapture<T extends (...args: unknown[]) => unknown>(fn: T, client?: UncaughtClient | null): T;
|
|
146
173
|
declare function useBreadcrumb(): (breadcrumb: Partial<Breadcrumb>) => void;
|
|
147
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Set up Core Web Vitals tracking using native PerformanceObserver.
|
|
177
|
+
* Records LCP, FID/INP, CLS, FCP, and TTFB as breadcrumbs.
|
|
178
|
+
*
|
|
179
|
+
* No external dependencies — uses browser-native APIs only.
|
|
180
|
+
*
|
|
181
|
+
* @returns Cleanup function to disconnect observers.
|
|
182
|
+
*/
|
|
183
|
+
declare function setupWebVitals(client: UncaughtClient): () => void;
|
|
184
|
+
|
|
148
185
|
/**
|
|
149
186
|
* Result of Next.js environment detection.
|
|
150
187
|
*/
|
|
@@ -216,4 +253,4 @@ declare function withUncaught(config: UncaughtConfig): UncaughtConfig & {
|
|
|
216
253
|
__nextjs: boolean;
|
|
217
254
|
};
|
|
218
255
|
|
|
219
|
-
export { type ErrorBoundaryState, type NextJsDetection, UncaughtContext, type UncaughtContextValue, UncaughtErrorBoundary, type UncaughtErrorBoundaryProps, UncaughtProvider, type UncaughtProviderProps, detectNextJs, setupNextJsNavigation, useBreadcrumb, useReportError, useUncaught, withUncaught };
|
|
256
|
+
export { type ErrorBoundaryState, type NextJsDetection, UncaughtContext, type UncaughtContextValue, UncaughtErrorBoundary, type UncaughtErrorBoundaryProps, UncaughtProvider, type UncaughtProviderProps, detectNextJs, setupNextJsNavigation, setupWebVitals, useBreadcrumb, useErrorHandler, useReportError, useUncaught, withErrorCapture, withUncaught };
|
package/dist/index.d.ts
CHANGED
|
@@ -106,12 +106,20 @@ declare const UncaughtContext: React$1.Context<UncaughtContextValue>;
|
|
|
106
106
|
* </UncaughtErrorBoundary>
|
|
107
107
|
* ```
|
|
108
108
|
*/
|
|
109
|
-
declare class UncaughtErrorBoundary extends Component<UncaughtErrorBoundaryProps, ErrorBoundaryState
|
|
109
|
+
declare class UncaughtErrorBoundary extends Component<UncaughtErrorBoundaryProps, ErrorBoundaryState & {
|
|
110
|
+
feedback: string;
|
|
111
|
+
feedbackSent: boolean;
|
|
112
|
+
lastEventId: string | null;
|
|
113
|
+
}> {
|
|
110
114
|
static contextType: React__default.Context<UncaughtContextValue>;
|
|
111
115
|
context: React__default.ContextType<typeof UncaughtContext>;
|
|
112
116
|
private removePopstateListener;
|
|
113
117
|
constructor(props: UncaughtErrorBoundaryProps);
|
|
114
|
-
static getDerivedStateFromError(error: Error): ErrorBoundaryState
|
|
118
|
+
static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState & {
|
|
119
|
+
feedback: string;
|
|
120
|
+
feedbackSent: boolean;
|
|
121
|
+
lastEventId: string | null;
|
|
122
|
+
}>;
|
|
115
123
|
componentDidCatch(error: Error, errorInfo: React__default.ErrorInfo): void;
|
|
116
124
|
componentDidMount(): void;
|
|
117
125
|
componentWillUnmount(): void;
|
|
@@ -143,8 +151,37 @@ declare function useReportError(): (error: Error, context?: Record<string, unkno
|
|
|
143
151
|
*
|
|
144
152
|
* @returns A function `(breadcrumb: Partial<Breadcrumb>) => void`
|
|
145
153
|
*/
|
|
154
|
+
/**
|
|
155
|
+
* Wraps a callback function with error capture.
|
|
156
|
+
* Use this for event handlers (onClick, onChange, etc.) that React Error
|
|
157
|
+
* Boundary does not catch.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```tsx
|
|
161
|
+
* const handleClick = useErrorHandler((e) => {
|
|
162
|
+
* // risky code that might throw
|
|
163
|
+
* });
|
|
164
|
+
* <button onClick={handleClick}>Click</button>
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
declare function useErrorHandler<T extends (...args: unknown[]) => unknown>(fn: T): T;
|
|
168
|
+
/**
|
|
169
|
+
* Standalone HOF (non-hook) that wraps a function with error capture.
|
|
170
|
+
* Use in class components or outside React context.
|
|
171
|
+
*/
|
|
172
|
+
declare function withErrorCapture<T extends (...args: unknown[]) => unknown>(fn: T, client?: UncaughtClient | null): T;
|
|
146
173
|
declare function useBreadcrumb(): (breadcrumb: Partial<Breadcrumb>) => void;
|
|
147
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Set up Core Web Vitals tracking using native PerformanceObserver.
|
|
177
|
+
* Records LCP, FID/INP, CLS, FCP, and TTFB as breadcrumbs.
|
|
178
|
+
*
|
|
179
|
+
* No external dependencies — uses browser-native APIs only.
|
|
180
|
+
*
|
|
181
|
+
* @returns Cleanup function to disconnect observers.
|
|
182
|
+
*/
|
|
183
|
+
declare function setupWebVitals(client: UncaughtClient): () => void;
|
|
184
|
+
|
|
148
185
|
/**
|
|
149
186
|
* Result of Next.js environment detection.
|
|
150
187
|
*/
|
|
@@ -216,4 +253,4 @@ declare function withUncaught(config: UncaughtConfig): UncaughtConfig & {
|
|
|
216
253
|
__nextjs: boolean;
|
|
217
254
|
};
|
|
218
255
|
|
|
219
|
-
export { type ErrorBoundaryState, type NextJsDetection, UncaughtContext, type UncaughtContextValue, UncaughtErrorBoundary, type UncaughtErrorBoundaryProps, UncaughtProvider, type UncaughtProviderProps, detectNextJs, setupNextJsNavigation, useBreadcrumb, useReportError, useUncaught, withUncaught };
|
|
256
|
+
export { type ErrorBoundaryState, type NextJsDetection, UncaughtContext, type UncaughtContextValue, UncaughtErrorBoundary, type UncaughtErrorBoundaryProps, UncaughtProvider, type UncaughtProviderProps, detectNextJs, setupNextJsNavigation, setupWebVitals, useBreadcrumb, useErrorHandler, useReportError, useUncaught, withErrorCapture, withUncaught };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var j=require('react'),core=require('@uncaughtdev/core'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var j__default=/*#__PURE__*/_interopDefault(j);var g=j.createContext({client:null});g.displayName="UncaughtContext";var v=class extends j.Component{constructor(r){super(r);this.removePopstateListener=null;this.resetError=()=>{this.setState({hasError:false,error:null});};this.state={hasError:false,error:null,feedback:"",feedbackSent:false,lastEventId:null};}static getDerivedStateFromError(r){return {hasError:true,error:r,feedback:"",feedbackSent:false,lastEventId:null}}componentDidCatch(r,e){try{let o=this.context?.client??null,{onError:s,beforeCapture:a}=this.props,i=e.componentStack??void 0;o&&(o.captureError(r,{componentStack:i}),o.addBreadcrumb({type:"custom",category:"react.error_boundary",message:`Error boundary caught: ${r.message}`,level:"error"})),s&&s(r,e);}catch(o){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Error in componentDidCatch handler:",o);}}componentDidMount(){if(typeof window<"u"){let r=()=>{this.state.hasError&&this.resetError();};window.addEventListener("popstate",r),this.removePopstateListener=()=>{window.removeEventListener("popstate",r);};}}componentWillUnmount(){this.removePopstateListener&&(this.removePopstateListener(),this.removePopstateListener=null);}render(){let{hasError:r,error:e}=this.state,{children:o,fallback:s,showDialog:a}=this.props;if(!r||!e)return o;if(typeof s=="function")try{return s(e)}catch(i){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Fallback render function threw:",i);}if(s!==void 0&&typeof s!="function")return s;if(a){let{feedback:i,feedbackSent:c}=this.state,u=this.context?.client??null;return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"100vh",padding:"20px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',backgroundColor:"#f8f9fa"},children:jsxRuntime.jsxs("div",{style:{maxWidth:"480px",width:"100%",backgroundColor:"#ffffff",borderRadius:"12px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",padding:"32px",textAlign:"center"},children:[jsxRuntime.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"50%",backgroundColor:"#fee2e2",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 16px",fontSize:"24px",color:"#dc2626"},children:"!"}),jsxRuntime.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",fontWeight:600,color:"#111827"},children:"Something went wrong"}),jsxRuntime.jsx("p",{style:{margin:"0 0 16px",fontSize:"14px",color:"#6b7280",lineHeight:1.5},children:"An unexpected error occurred. Our team has been notified and is working on a fix."}),process.env.NODE_ENV==="development"&&jsxRuntime.jsxs("pre",{style:{textAlign:"left",backgroundColor:"#f3f4f6",padding:"12px",borderRadius:"8px",fontSize:"12px",color:"#dc2626",overflow:"auto",maxHeight:"120px",marginBottom:"16px",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[e.message,e.stack&&`
|
|
2
2
|
|
|
3
|
-
${
|
|
4
|
-
`)[0]);}else if(t==="input"||t==="textarea"){let u=e.placeholder,c=e.getAttribute("name");a=u||c||null;}let o=e.id?`#${e.id}`:"";return `Clicked${a?` '${y(a,50)}'`:""} ${r}${o}`}function T(e){let t=n=>{try{let r=n.target;if(!r||!r.tagName||r.tagName.toLowerCase()==="input"&&r.type?.toLowerCase()==="password")return;let a=O(r);e.addBreadcrumb({timestamp:new Date().toISOString(),type:"click",category:"ui.click",message:y(a,200),level:"info",data:{tag:r.tagName.toLowerCase(),id:r.id||void 0,className:typeof r.className=="string"?y(r.className,100):void 0}});}catch{}};return document.addEventListener("click",t,true),()=>document.removeEventListener("click",t,true)}function M(e){let t=window.location.href,n=o=>{try{let i=t;t=o,e.addBreadcrumb({timestamp:new Date().toISOString(),type:"navigation",category:"navigation",message:`Navigated to ${o}`,level:"info",data:{from:i,to:o}});}catch{}},r=()=>{n(window.location.href);};window.addEventListener("popstate",r);let a=history.pushState.bind(history),s=history.replaceState.bind(history);return history.pushState=function(o,i,u){if(a(o,i,u),u)try{let c=new URL(String(u),window.location.href).href;n(c);}catch{n(String(u));}},history.replaceState=function(o,i,u){if(s(o,i,u),u)try{let c=new URL(String(u),window.location.href).href;n(c);}catch{n(String(u));}},()=>{window.removeEventListener("popstate",r),history.pushState=a,history.replaceState=s;}}function V(e){let t=window.fetch.bind(window),n=e.getConfig?.()??{},r=n.endpoint??n.dsn??"",a=[];if(typeof r=="string"&&r)try{let o=new URL(r);a.push(o.hostname);}catch{a.push(r);}a.push("uncaught.dev"),a.push("api.uncaught");let s=o=>a.some(i=>i&&o.includes(i));return window.fetch=async function(o,i){let u=o instanceof Request?o.url:o instanceof URL?o.href:String(o),c=(i?.method??(o instanceof Request?o.method:"GET")).toUpperCase();if(s(u))return t(o,i);let l=Date.now();try{let d=await t(o,i),m=Date.now()-l,g=d.status>=400;try{let p=y(u,150);e.addBreadcrumb({timestamp:new Date().toISOString(),type:"api_call",category:"fetch",message:`${c} ${p} [${d.status}]`,level:g?"error":"info",data:{method:c,url:p,status:d.status,statusText:d.statusText,duration:m}});}catch{}return d}catch(d){let m=Date.now()-l;try{let g=y(u,150);e.addBreadcrumb({timestamp:new Date().toISOString(),type:"api_call",category:"fetch",message:`${c} ${g} [Network Error]`,level:"error",data:{method:c,url:g,status:0,error:d instanceof Error?d.message:"Network error",duration:m}});}catch{}throw d}},()=>{window.fetch=t;}}function R(e){if(typeof window>"u")return ()=>{};let t=[];try{t.push(T(e));}catch(n){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up click tracking:",n);}try{t.push(M(e));}catch(n){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up navigation tracking:",n);}try{t.push(V(e));}catch(n){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up fetch tracking:",n);}return ()=>{t.forEach(n=>{try{n();}catch{}});}}function w(){if(typeof window>"u")return {isNextJs:false,isAppRouter:false,isPagesRouter:false};let e=window,t=e.__NEXT_DATA__!==void 0,n=e.__next_f!==void 0,r=false;try{r=document.querySelector('meta[name="next-size-adjust"]')!==null;}catch{}return {isNextJs:t||n||r,isAppRouter:n,isPagesRouter:t&&!n}}function x(e){if(typeof window>"u")return ()=>{};let t=w(),n=[];try{e.addBreadcrumb({type:"navigation",category:"nextjs",message:`Next.js detected: ${t.isAppRouter?"App Router":t.isPagesRouter?"Pages Router":"Unknown Router"}`,level:"info",data:{isAppRouter:t.isAppRouter,isPagesRouter:t.isPagesRouter}});}catch{}if(t.isPagesRouter)try{let a=window.next?.router?.events;if(a){let s=0,o=c=>{try{s=Date.now(),e.addBreadcrumb({type:"navigation",category:"nextjs.route",message:`Route change started: ${String(c)}`,level:"info",data:{to:String(c)}});}catch{}},i=c=>{try{let l=s>0?Date.now()-s:void 0;e.addBreadcrumb({type:"navigation",category:"nextjs.route",message:`Route change completed: ${String(c)}`,level:"info",data:{to:String(c),duration:l}});}catch{}},u=(c,l)=>{try{let d=s>0?Date.now()-s:void 0;e.addBreadcrumb({type:"navigation",category:"nextjs.route",message:`Route change error: ${String(l)}`,level:"error",data:{to:String(l),error:c instanceof Error?c.message:String(c),duration:d}});}catch{}};a.on("routeChangeStart",o),a.on("routeChangeComplete",i),a.on("routeChangeError",u),n.push(()=>{try{a.off("routeChangeStart",o),a.off("routeChangeComplete",i),a.off("routeChangeError",u);}catch{}});}}catch(r){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up Next.js Pages Router navigation:",r);}return ()=>{n.forEach(r=>{try{r();}catch{}});}}function j(e){return {...e,__nextjs:true}}function J({children:e,fallback:t,showDialog:n,...r}){let[a,s]=$.useState(null),o=$.useRef([]),i=$.useRef(false);$.useEffect(()=>{if(i.current)return;i.current=true;let c=true,l=[];try{let{__nextjs:d,...m}=r,g=core.initUncaught(m);if(!g){process.env.NODE_ENV==="development"&&console.warn("[Uncaught] initUncaught returned null/undefined. Error monitoring is disabled.");return}try{let p=C(g);l.push(p);}catch(p){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up global handlers:",p);}try{let p=R(g);l.push(p);}catch(p){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up DOM breadcrumbs:",p);}if(typeof window<"u")try{if(w().isNextJs||d){let D=x(g);l.push(D);}}catch(p){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up Next.js integration:",p);}o.current=l,c&&s(g);}catch(d){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to initialize:",d);}return ()=>{c=false,o.current.forEach(d=>{try{d();}catch{}}),o.current=[],i.current=false;}},[]);let u=$__default.default.useMemo(()=>({client:a}),[a]);return jsxRuntime.jsx(f.Provider,{value:u,children:jsxRuntime.jsx(h,{fallback:t,showDialog:n,children:e})})}function z(){let{client:e}=$.useContext(f);if(!e)throw new Error("useUncaught must be used within an <UncaughtProvider>. Wrap your application in <UncaughtProvider> to use this hook.");return e}function W(){let{client:e}=$.useContext(f);return $.useCallback((t,n)=>{try{if(!e){process.env.NODE_ENV==="development"&&console.warn("[Uncaught] useReportError called but no UncaughtClient is available. Make sure <UncaughtProvider> is mounted.");return}e.captureError(t);}catch(r){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to report error:",r);}},[e])}function G(){let{client:e}=$.useContext(f);return $.useCallback(t=>{try{if(!e){process.env.NODE_ENV==="development"&&console.warn("[Uncaught] useBreadcrumb called but no UncaughtClient is available. Make sure <UncaughtProvider> is mounted.");return}e.addBreadcrumb({type:t.type??"custom",category:t.category??"custom",message:t.message??"",level:t.level??"info",data:t.data});}catch(n){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to add breadcrumb:",n);}},[e])}Object.defineProperty(exports,"getClient",{enumerable:true,get:function(){return core.getClient}});Object.defineProperty(exports,"initUncaught",{enumerable:true,get:function(){return core.initUncaught}});exports.UncaughtContext=f;exports.UncaughtErrorBoundary=h;exports.UncaughtProvider=J;exports.detectNextJs=w;exports.setupNextJsNavigation=x;exports.useBreadcrumb=G;exports.useReportError=W;exports.useUncaught=z;exports.withUncaught=j;//# sourceMappingURL=index.js.map
|
|
3
|
+
${e.stack}`]}),c?jsxRuntime.jsx("p",{style:{fontSize:"13px",color:"#059669",marginBottom:"16px"},children:"Thank you for your feedback!"}):jsxRuntime.jsxs("div",{style:{marginBottom:"16px",textAlign:"left"},children:[jsxRuntime.jsx("label",{htmlFor:"uncaught-feedback",style:{display:"block",fontSize:"13px",fontWeight:500,color:"#374151",marginBottom:"6px"},children:"What were you doing when this happened?"}),jsxRuntime.jsx("textarea",{id:"uncaught-feedback",value:i,onChange:d=>this.setState({feedback:d.target.value}),placeholder:"Describe what you were doing...",style:{width:"100%",minHeight:"80px",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:"8px",fontSize:"14px",fontFamily:"inherit",resize:"vertical",boxSizing:"border-box"}}),i.trim()&&jsxRuntime.jsx("button",{onClick:()=>{try{u&&i.trim()&&(u.submitFeedback?.("",i.trim()),this.setState({feedbackSent:!0}));}catch{}},style:{marginTop:"8px",backgroundColor:"#059669",color:"#ffffff",border:"none",borderRadius:"6px",padding:"8px 16px",fontSize:"13px",fontWeight:500,cursor:"pointer"},children:"Send Feedback"})]}),jsxRuntime.jsx("button",{onClick:()=>{try{typeof window<"u"&&window.location.reload();}catch{}},style:{backgroundColor:"#3b82f6",color:"#ffffff",border:"none",borderRadius:"8px",padding:"10px 24px",fontSize:"14px",fontWeight:500,cursor:"pointer",transition:"background-color 0.15s ease"},onMouseOver:d=>{d.target.style.backgroundColor="#2563eb";},onMouseOut:d=>{d.target.style.backgroundColor="#3b82f6";},children:"Reload Page"})]})})}return null}};v.contextType=g;var B=[/ResizeObserver loop/i,/^Script error\.?$/i,/chrome-extension:\/\//i,/moz-extension:\/\//i,/safari-extension:\/\//i,/safari-web-extension:\/\//i,/extension:\/\//i];function N(t){return B.some(n=>n.test(t))}function S(t,n){return !n||n.length===0?false:n.some(r=>typeof r=="string"?t.includes(r):r.test(t))}function M(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(t!=null)try{return new Error(JSON.stringify(t))}catch{return new Error(String(t))}return new Error("Unhandled promise rejection with no reason")}function _(t){if(typeof window>"u")return ()=>{};let r=(t.getConfig?.()??{}).ignoreErrors,e=s=>{try{let{error:a,message:i,filename:c}=s;if(!a&&(!i||i==="Script error.")&&!c)return;let u=a?.message??i??"Unknown error";if(N(u)||S(u,r))return;let d=a instanceof Error?a:new Error(u);t.captureError(d,{tags:{source:"window.onerror"},extra:{filename:c??void 0,lineno:s.lineno??void 0,colno:s.colno??void 0}});}catch(a){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Error in global error handler:",a);}},o=s=>{try{let a=M(s.reason),i=a.message;if(N(i)||S(i,r))return;t.captureError(a,{tags:{source:"unhandledrejection",unhandled:"true"}});}catch(a){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Error in unhandled rejection handler:",a);}};return window.addEventListener("error",e),window.addEventListener("unhandledrejection",o),()=>{window.removeEventListener("error",e),window.removeEventListener("unhandledrejection",o);}}function y(t,n){return t.length<=n?t:t.slice(0,n-3)+"..."}function A(t){let n=t.tagName?.toLowerCase()??"unknown",r=n==="input"?t.type?.toLowerCase():void 0;if(r==="password")return "password input";let e;n==="button"||t.getAttribute("role")==="button"?e="button":n==="a"?e="link":n==="input"?e=`${r??"text"} input`:n==="select"?e="dropdown":n==="textarea"?e="textarea":e=n;let o=null,s=t.getAttribute("aria-label");if(s)o=s;else if(n==="button"||n==="a"){let c=t.innerText?.trim();c&&(o=c.split(`
|
|
4
|
+
`)[0]);}else if(n==="input"||n==="textarea"){let c=t.placeholder,u=t.getAttribute("name");o=c||u||null;}let a=t.id?`#${t.id}`:"";return `Clicked${o?` '${y(o,50)}'`:""} ${e}${a}`}function V(t){let n=r=>{try{let e=r.target;if(!e||!e.tagName||e.tagName.toLowerCase()==="input"&&e.type?.toLowerCase()==="password")return;let o=A(e);t.addBreadcrumb({timestamp:new Date().toISOString(),type:"click",category:"ui.click",message:y(o,200),level:"info",data:{tag:e.tagName.toLowerCase(),id:e.id||void 0,className:typeof e.className=="string"?y(e.className,100):void 0}});}catch{}};return document.addEventListener("click",n,true),()=>document.removeEventListener("click",n,true)}function H(t){let n=window.location.href,r=a=>{try{let i=n;n=a,t.addBreadcrumb({timestamp:new Date().toISOString(),type:"navigation",category:"navigation",message:`Navigated to ${a}`,level:"info",data:{from:i,to:a}});}catch{}},e=()=>{r(window.location.href);};window.addEventListener("popstate",e);let o=history.pushState.bind(history),s=history.replaceState.bind(history);return history.pushState=function(a,i,c){if(o(a,i,c),c)try{let u=new URL(String(c),window.location.href).href;r(u);}catch{r(String(c));}},history.replaceState=function(a,i,c){if(s(a,i,c),c)try{let u=new URL(String(c),window.location.href).href;r(u);}catch{r(String(c));}},()=>{window.removeEventListener("popstate",e),history.pushState=o,history.replaceState=s;}}function F(t){let n=window.fetch.bind(window),r=t.getConfig?.()??{},e=r.endpoint??r.dsn??"",o=[];if(typeof e=="string"&&e)try{let a=new URL(e);o.push(a.hostname);}catch{o.push(e);}o.push("uncaught.dev"),o.push("api.uncaught");let s=a=>o.some(i=>i&&a.includes(i));return window.fetch=async function(a,i){let c=a instanceof Request?a.url:a instanceof URL?a.href:String(a),u=(i?.method??(a instanceof Request?a.method:"GET")).toUpperCase();if(s(c))return n(a,i);let d=Date.now();try{let p=await n(a,i),m=Date.now()-d,f=p.status>=400;try{let l=y(c,150);t.addBreadcrumb({timestamp:new Date().toISOString(),type:"api_call",category:"fetch",message:`${u} ${l} [${p.status}]`,level:f?"error":"info",data:{method:u,url:l,status:p.status,statusText:p.statusText,duration:m}});}catch{}return p}catch(p){let m=Date.now()-d;try{let f=y(c,150);t.addBreadcrumb({timestamp:new Date().toISOString(),type:"api_call",category:"fetch",message:`${u} ${f} [Network Error]`,level:"error",data:{method:u,url:f,status:0,error:p instanceof Error?p.message:"Network error",duration:m}});}catch{}throw p}},()=>{window.fetch=n;}}function $(t){if(typeof XMLHttpRequest>"u")return ()=>{};let n=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send,e=t.getConfig?.()??{},o=e.endpoint??e.dsn??"",s=["uncaught.dev","api.uncaught"];if(typeof o=="string"&&o)try{s.push(new URL(o).hostname);}catch{s.push(o);}let a=i=>s.some(c=>c&&i.includes(c));return XMLHttpRequest.prototype.open=function(i,c,...u){return this._uncaught_method=i.toUpperCase(),this._uncaught_url=String(c),n.apply(this,[i,c,...u])},XMLHttpRequest.prototype.send=function(i){let c=this,u=c._uncaught_method??"GET",d=c._uncaught_url??"";if(a(d))return r.call(this,i);let p=Date.now(),m=()=>{try{let f=Date.now()-p,l=c.status,x=l===0||l>=400,C=y(d,150);t.addBreadcrumb({type:"api_call",category:"xhr",message:`${u} ${C} [${l||"Error"}]`,level:x?"error":"info",data:{method:u,url:C,status:l,statusText:c.statusText,duration:f}});}catch{}};return c.addEventListener("loadend",m),r.call(this,i)},()=>{XMLHttpRequest.prototype.open=n,XMLHttpRequest.prototype.send=r;}}function P(t){if(typeof window>"u")return ()=>{};let n=[];try{n.push(V(t));}catch(r){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up click tracking:",r);}try{n.push(H(t));}catch(r){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up navigation tracking:",r);}try{n.push(F(t));}catch(r){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up fetch tracking:",r);}try{n.push($(t));}catch(r){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up XHR tracking:",r);}return ()=>{n.forEach(r=>{try{r();}catch{}});}}function w(){if(typeof window>"u")return {isNextJs:false,isAppRouter:false,isPagesRouter:false};let t=window,n=t.__NEXT_DATA__!==void 0,r=t.__next_f!==void 0,e=false;try{e=document.querySelector('meta[name="next-size-adjust"]')!==null;}catch{}return {isNextJs:n||r||e,isAppRouter:r,isPagesRouter:n&&!r}}function U(t){if(typeof window>"u")return ()=>{};let n=w(),r=[];try{t.addBreadcrumb({type:"navigation",category:"nextjs",message:`Next.js detected: ${n.isAppRouter?"App Router":n.isPagesRouter?"Pages Router":"Unknown Router"}`,level:"info",data:{isAppRouter:n.isAppRouter,isPagesRouter:n.isPagesRouter}});}catch{}if(n.isPagesRouter)try{let o=window.next?.router?.events;if(o){let s=0,a=u=>{try{s=Date.now(),t.addBreadcrumb({type:"navigation",category:"nextjs.route",message:`Route change started: ${String(u)}`,level:"info",data:{to:String(u)}});}catch{}},i=u=>{try{let d=s>0?Date.now()-s:void 0;t.addBreadcrumb({type:"navigation",category:"nextjs.route",message:`Route change completed: ${String(u)}`,level:"info",data:{to:String(u),duration:d}});}catch{}},c=(u,d)=>{try{let p=s>0?Date.now()-s:void 0;t.addBreadcrumb({type:"navigation",category:"nextjs.route",message:`Route change error: ${String(d)}`,level:"error",data:{to:String(d),error:u instanceof Error?u.message:String(u),duration:p}});}catch{}};o.on("routeChangeStart",a),o.on("routeChangeComplete",i),o.on("routeChangeError",c),r.push(()=>{try{o.off("routeChangeStart",a),o.off("routeChangeComplete",i),o.off("routeChangeError",c);}catch{}});}}catch(e){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up Next.js Pages Router navigation:",e);}return ()=>{r.forEach(e=>{try{e();}catch{}});}}function I(t){return {...t,__nextjs:true}}function R(t){if(typeof window>"u"||typeof PerformanceObserver>"u")return ()=>{};let n=[];function r(e,o,s="ms"){try{let a=s==="ms"?`${Math.round(o)}ms`:o.toFixed(3);t.addBreadcrumb({type:"web_vital",category:"web-vital",message:`${e}: ${a}`,level:"info",data:{name:e,value:o,unit:s}});}catch{}}try{let e=new PerformanceObserver(o=>{let s=o.getEntries(),a=s[s.length-1];a&&r("LCP",a.startTime);});e.observe({type:"largest-contentful-paint",buffered:!0}),n.push(e);}catch{}try{let e=new PerformanceObserver(o=>{let a=o.getEntries()[0];a&&r("FID",a.processingStart-a.startTime);});e.observe({type:"first-input",buffered:!0}),n.push(e);}catch{}try{let e=0,o=new PerformanceObserver(a=>{for(let i of a.getEntries()){let c=i;!c.hadRecentInput&&c.value&&(e+=c.value);}});o.observe({type:"layout-shift",buffered:!0}),n.push(o);let s=()=>{e>0&&r("CLS",e,"score");};window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&s();});}catch{}try{let e=new PerformanceObserver(o=>{let a=o.getEntries().find(i=>i.name==="first-contentful-paint");a&&r("FCP",a.startTime);});e.observe({type:"paint",buffered:!0}),n.push(e);}catch{}try{let e=performance.getEntriesByType("navigation");if(e.length>0){let o=e[0];o.responseStart>0&&r("TTFB",o.responseStart-o.requestStart);}}catch{}return ()=>{n.forEach(e=>{try{e.disconnect();}catch{}});}}function W({children:t,fallback:n,showDialog:r,...e}){let[o,s]=j.useState(null),a=j.useRef([]),i=j.useRef(false);j.useEffect(()=>{if(i.current)return;i.current=true;let u=true,d=[];try{let{__nextjs:p,...m}=e,f=core.initUncaught(m);if(!f){process.env.NODE_ENV==="development"&&console.warn("[Uncaught] initUncaught returned null/undefined. Error monitoring is disabled.");return}try{let l=_(f);d.push(l);}catch(l){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up global handlers:",l);}try{let l=P(f);d.push(l);}catch(l){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up DOM breadcrumbs:",l);}try{let l=R(f);d.push(l);}catch(l){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up Web Vitals:",l);}if(typeof window<"u")try{if(w().isNextJs||p){let x=U(f);d.push(x);}}catch(l){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up Next.js integration:",l);}a.current=d,u&&s(f);}catch(p){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to initialize:",p);}return ()=>{u=false,a.current.forEach(p=>{try{p();}catch{}}),a.current=[],i.current=false;}},[]);let c=j__default.default.useMemo(()=>({client:o}),[o]);return jsxRuntime.jsx(g.Provider,{value:c,children:jsxRuntime.jsx(v,{fallback:n,showDialog:r,children:t})})}function J(){let{client:t}=j.useContext(g);if(!t)throw new Error("useUncaught must be used within an <UncaughtProvider>. Wrap your application in <UncaughtProvider> to use this hook.");return t}function G(){let{client:t}=j.useContext(g);return j.useCallback((n,r)=>{try{if(!t){process.env.NODE_ENV==="development"&&console.warn("[Uncaught] useReportError called but no UncaughtClient is available. Make sure <UncaughtProvider> is mounted.");return}t.captureError(n);}catch(e){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to report error:",e);}},[t])}function K(t){let{client:n}=j.useContext(g);return j.useCallback(((...r)=>{try{let e=t(...r);return e instanceof Promise?e.catch(o=>{try{n&&n.captureError(o);}catch{}throw o}):e}catch(e){try{n&&n.captureError(e);}catch{}throw e}}),[t,n])}function Q(t,n){return((...r)=>{try{let e=t(...r);return e instanceof Promise?e.catch(o=>{try{n&&n.captureError(o);}catch{}throw o}):e}catch(e){try{n&&n.captureError(e);}catch{}throw e}})}function Y(){let{client:t}=j.useContext(g);return j.useCallback(n=>{try{if(!t){process.env.NODE_ENV==="development"&&console.warn("[Uncaught] useBreadcrumb called but no UncaughtClient is available. Make sure <UncaughtProvider> is mounted.");return}t.addBreadcrumb({type:n.type??"custom",category:n.category??"custom",message:n.message??"",level:n.level??"info",data:n.data});}catch(r){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to add breadcrumb:",r);}},[t])}Object.defineProperty(exports,"getClient",{enumerable:true,get:function(){return core.getClient}});Object.defineProperty(exports,"initUncaught",{enumerable:true,get:function(){return core.initUncaught}});exports.UncaughtContext=g;exports.UncaughtErrorBoundary=v;exports.UncaughtProvider=W;exports.detectNextJs=w;exports.setupNextJsNavigation=U;exports.setupWebVitals=R;exports.useBreadcrumb=Y;exports.useErrorHandler=K;exports.useReportError=G;exports.useUncaught=J;exports.withErrorCapture=Q;exports.withUncaught=I;//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context.ts","../src/error-boundary.tsx","../src/global-handlers.ts","../src/dom-breadcrumbs.ts","../src/next-integration.ts","../src/provider.tsx","../src/hooks.ts"],"names":["UncaughtContext","createContext","UncaughtErrorBoundary","Component","props","error","errorInfo","client","onError","beforeCapture","componentStack","e","handlePopState","hasError","children","fallback","showDialog","jsx","jsxs","NOISE_PATTERNS","isNoiseError","message","pattern","isIgnoredByConfig","ignoreErrors","normalizeRejectionReason","reason","setupGlobalHandlers","handleError","event","filename","errorMessage","errorObj","handleRejection","truncate","str","maxLen","describeElement","element","tag","type","role","text","ariaLabel","innerText","placeholder","name","id","setupClickTracking","handleClick","target","setupNavigationTracking","currentUrl","recordNavigation","to","from","originalPushState","originalReplaceState","data","unused","url","resolvedUrl","setupFetchTracking","originalFetch","config","apiEndpoint","uncaughtEndpoints","isUncaughtRequest","endpoint","input","init","method","startTime","response","duration","isError","displayUrl","setupDomBreadcrumbs","cleanups","cleanup","detectNextJs","win","hasPagesData","hasAppRouterData","hasNextMeta","setupNextJsNavigation","detection","routerEvents","navigationStartTime","handleRouteChangeStart","handleRouteChangeComplete","handleRouteChangeError","err","withUncaught","UncaughtProvider","setClient","useState","cleanupRef","useRef","initializedRef","useEffect","mounted","__nextjs","coreConfig","uncaughtClient","initUncaught","cleanupGlobal","cleanupDom","cleanupNext","contextValue","React","useUncaught","useContext","useReportError","useCallback","context","useBreadcrumb","breadcrumb"],"mappings":"kOASaA,CAAAA,CAAkBC,eAAAA,CAAoC,CACjE,MAAA,CAAQ,IACV,CAAC,EAEDD,CAAAA,CAAgB,YAAc,iBAAA,CCOvB,IAAME,EAAN,cAAo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B,KAAA,CAAOA,CAAAA,CAAW,OAAS,MAAA,CAC3B,IAAA,CAAMA,EAAW,IACnB,CAAC,EACH,CAAA,MAAS1G,CAAAA,CAAG,CAEN,OAAA,CAAQ,IAAI,QAAA,GAAa,aAAA,EAC3B,QAAQ,KAAA,CAAM,sCAAA,CAAwCA,CAAC,EAE3D,CACF,EACA,CAACJ,CAAM,CACT,CACF","file":"index.js","sourcesContent":["'use client';\n\nimport { createContext } from 'react';\nimport type { UncaughtContextValue } from './types';\n\n/**\n * React context that provides the UncaughtClient instance to descendant components.\n * The context value is null when no UncaughtProvider is present in the tree.\n */\nexport const UncaughtContext = createContext<UncaughtContextValue>({\n client: null,\n});\n\nUncaughtContext.displayName = 'UncaughtContext';\n","'use client';\n\nimport React, { Component } from 'react';\nimport type { UncaughtClient } from '@uncaughtdev/core';\nimport { UncaughtContext } from './context';\nimport type { UncaughtErrorBoundaryProps, ErrorBoundaryState } from './types';\n\n/**\n * React Error Boundary that captures errors and reports them to Uncaught.\n *\n * Must be a class component as React does not support error boundaries\n * via function components / hooks.\n *\n * Usage:\n * ```tsx\n * <UncaughtErrorBoundary fallback={<div>Something went wrong</div>}>\n * <MyApp />\n * </UncaughtErrorBoundary>\n * ```\n */\nexport class UncaughtErrorBoundary extends Component<\n UncaughtErrorBoundaryProps,\n ErrorBoundaryState\n> {\n static contextType = UncaughtContext;\n declare context: React.ContextType<typeof UncaughtContext>;\n\n private removePopstateListener: (() => void) | null = null;\n\n constructor(props: UncaughtErrorBoundaryProps) {\n super(props);\n this.state = {\n hasError: false,\n error: null,\n };\n }\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return {\n hasError: true,\n error,\n };\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {\n try {\n const client: UncaughtClient | null = this.context?.client ?? null;\n const { onError, beforeCapture } = this.props;\n\n // Extract component stack for richer error context\n const componentStack = errorInfo.componentStack ?? undefined;\n\n if (client) {\n client.captureError(error, {\n componentStack,\n });\n\n // Add a breadcrumb noting the error boundary source\n client.addBreadcrumb({\n type: 'custom',\n category: 'react.error_boundary',\n message: `Error boundary caught: ${error.message}`,\n level: 'error',\n });\n }\n\n // Invoke the user's onError callback if provided\n if (onError) {\n onError(error, errorInfo);\n }\n } catch (e) {\n // Never crash the host app from error reporting itself\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Error in componentDidCatch handler:', e);\n }\n }\n }\n\n componentDidMount(): void {\n // Auto-reset the error boundary when the user navigates via browser back/forward\n if (typeof window !== 'undefined') {\n const handlePopState = (): void => {\n if (this.state.hasError) {\n this.resetError();\n }\n };\n\n window.addEventListener('popstate', handlePopState);\n this.removePopstateListener = () => {\n window.removeEventListener('popstate', handlePopState);\n };\n }\n }\n\n componentWillUnmount(): void {\n if (this.removePopstateListener) {\n this.removePopstateListener();\n this.removePopstateListener = null;\n }\n }\n\n /**\n * Reset the error boundary state, allowing children to re-render.\n */\n resetError = (): void => {\n this.setState({\n hasError: false,\n error: null,\n });\n };\n\n render(): React.ReactNode {\n const { hasError, error } = this.state;\n const { children, fallback, showDialog } = this.props;\n\n if (!hasError || !error) {\n return children;\n }\n\n // Custom fallback: render function\n if (typeof fallback === 'function') {\n try {\n return fallback(error);\n } catch (e) {\n // If the fallback itself throws, fall through to default\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Fallback render function threw:', e);\n }\n }\n }\n\n // Custom fallback: ReactNode\n if (fallback !== undefined && typeof fallback !== 'function') {\n return fallback;\n }\n\n // Default dialog UI\n if (showDialog) {\n return (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: '100vh',\n padding: '20px',\n fontFamily:\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif',\n backgroundColor: '#f8f9fa',\n }}\n >\n <div\n style={{\n maxWidth: '480px',\n width: '100%',\n backgroundColor: '#ffffff',\n borderRadius: '12px',\n boxShadow:\n '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)',\n padding: '32px',\n textAlign: 'center',\n }}\n >\n <div\n style={{\n width: '48px',\n height: '48px',\n borderRadius: '50%',\n backgroundColor: '#fee2e2',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n margin: '0 auto 16px',\n fontSize: '24px',\n color: '#dc2626',\n }}\n >\n !\n </div>\n <h2\n style={{\n margin: '0 0 8px',\n fontSize: '20px',\n fontWeight: 600,\n color: '#111827',\n }}\n >\n Something went wrong\n </h2>\n <p\n style={{\n margin: '0 0 24px',\n fontSize: '14px',\n color: '#6b7280',\n lineHeight: 1.5,\n }}\n >\n An unexpected error occurred. Our team has been notified and is\n working on a fix.\n </p>\n {process.env.NODE_ENV === 'development' && (\n <pre\n style={{\n textAlign: 'left',\n backgroundColor: '#f3f4f6',\n padding: '12px',\n borderRadius: '8px',\n fontSize: '12px',\n color: '#dc2626',\n overflow: 'auto',\n maxHeight: '120px',\n marginBottom: '24px',\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n }}\n >\n {error.message}\n {error.stack && `\\n\\n${error.stack}`}\n </pre>\n )}\n <button\n onClick={() => {\n try {\n if (typeof window !== 'undefined') {\n window.location.reload();\n }\n } catch {\n // Silently ignore reload failures\n }\n }}\n style={{\n backgroundColor: '#3b82f6',\n color: '#ffffff',\n border: 'none',\n borderRadius: '8px',\n padding: '10px 24px',\n fontSize: '14px',\n fontWeight: 500,\n cursor: 'pointer',\n transition: 'background-color 0.15s ease',\n }}\n onMouseOver={(e) => {\n (e.target as HTMLButtonElement).style.backgroundColor =\n '#2563eb';\n }}\n onMouseOut={(e) => {\n (e.target as HTMLButtonElement).style.backgroundColor =\n '#3b82f6';\n }}\n >\n Reload Page\n </button>\n </div>\n </div>\n );\n }\n\n // No fallback and no dialog: render nothing (transparent failure)\n return null;\n }\n}\n","import type { UncaughtClient } from '@uncaughtdev/core';\n\n/**\n * Patterns for errors that are typically noise and should be ignored.\n * These are errors produced by the browser, extensions, or third-party scripts\n * that provide no actionable information.\n */\nconst NOISE_PATTERNS: RegExp[] = [\n // ResizeObserver loop errors are benign and happen in many apps\n /ResizeObserver loop/i,\n // \"Script error.\" with no useful info (cross-origin scripts without CORS headers)\n /^Script error\\.?$/i,\n // Browser extension errors\n /chrome-extension:\\/\\//i,\n /moz-extension:\\/\\//i,\n /safari-extension:\\/\\//i,\n /safari-web-extension:\\/\\//i,\n // Edge extension errors\n /extension:\\/\\//i,\n];\n\n/**\n * Check if an error message matches any of the known noise patterns.\n */\nfunction isNoiseError(message: string): boolean {\n return NOISE_PATTERNS.some((pattern) => pattern.test(message));\n}\n\n/**\n * Check if an error matches any user-defined ignoreErrors patterns.\n */\nfunction isIgnoredByConfig(\n message: string,\n ignoreErrors?: Array<string | RegExp>\n): boolean {\n if (!ignoreErrors || ignoreErrors.length === 0) {\n return false;\n }\n\n return ignoreErrors.some((pattern) => {\n if (typeof pattern === 'string') {\n return message.includes(pattern);\n }\n return pattern.test(message);\n });\n}\n\n/**\n * Normalize a promise rejection reason into a proper Error object.\n */\nfunction normalizeRejectionReason(reason: unknown): Error {\n if (reason instanceof Error) {\n return reason;\n }\n\n if (typeof reason === 'string') {\n return new Error(reason);\n }\n\n if (reason !== null && reason !== undefined) {\n try {\n return new Error(JSON.stringify(reason));\n } catch {\n return new Error(String(reason));\n }\n }\n\n return new Error('Unhandled promise rejection with no reason');\n}\n\n/**\n * Set up global error handlers to capture uncaught exceptions and\n * unhandled promise rejections.\n *\n * @param client - The UncaughtClient instance to report errors to.\n * @returns A cleanup function that removes the event listeners.\n */\nexport function setupGlobalHandlers(client: UncaughtClient): () => void {\n // Guard for SSR environments\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const config = client.getConfig?.() ?? {};\n const ignoreErrors = (config as Record<string, unknown>)\n .ignoreErrors as Array<string | RegExp> | undefined;\n\n /**\n * Handle uncaught exceptions via window.onerror / 'error' event.\n */\n const handleError = (event: ErrorEvent): void => {\n try {\n const { error, message, filename } = event;\n\n // \"Script error.\" with no stack and no filename is cross-origin noise\n if (\n !error &&\n (!message || message === 'Script error.') &&\n !filename\n ) {\n return;\n }\n\n const errorMessage =\n error?.message ?? message ?? 'Unknown error';\n\n // Filter out noise errors\n if (isNoiseError(errorMessage)) {\n return;\n }\n\n // Filter out user-configured ignored errors\n if (isIgnoredByConfig(errorMessage, ignoreErrors)) {\n return;\n }\n\n // Build the error object\n const errorObj =\n error instanceof Error ? error : new Error(errorMessage);\n\n client.captureError(errorObj, {\n tags: { source: 'window.onerror' },\n extra: {\n filename: filename ?? undefined,\n lineno: event.lineno ?? undefined,\n colno: event.colno ?? undefined,\n },\n });\n\n // Do NOT call event.preventDefault() - let the browser still log the error\n } catch (e) {\n // Never crash the host app from our error handler\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Error in global error handler:', e);\n }\n }\n };\n\n /**\n * Handle unhandled promise rejections.\n */\n const handleRejection = (event: PromiseRejectionEvent): void => {\n try {\n const error = normalizeRejectionReason(event.reason);\n const errorMessage = error.message;\n\n // Filter out noise errors\n if (isNoiseError(errorMessage)) {\n return;\n }\n\n // Filter out user-configured ignored errors\n if (isIgnoredByConfig(errorMessage, ignoreErrors)) {\n return;\n }\n\n client.captureError(error, {\n tags: {\n source: 'unhandledrejection',\n unhandled: 'true',\n },\n });\n\n // Do NOT call event.preventDefault() - let the browser still log\n } catch (e) {\n // Never crash the host app from our error handler\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Error in unhandled rejection handler:',\n e\n );\n }\n }\n };\n\n window.addEventListener('error', handleError);\n window.addEventListener('unhandledrejection', handleRejection);\n\n // Return cleanup function\n return () => {\n window.removeEventListener('error', handleError);\n window.removeEventListener('unhandledrejection', handleRejection);\n };\n}\n","import type { UncaughtClient } from '@uncaughtdev/core';\n\n/**\n * Maximum length for breadcrumb messages to avoid excessively large payloads.\n */\nconst MAX_MESSAGE_LENGTH = 200;\n\n/**\n * Truncate a string to a maximum length, appending \"...\" if truncated.\n */\nfunction truncate(str: string, maxLen: number): string {\n if (str.length <= maxLen) return str;\n return str.slice(0, maxLen - 3) + '...';\n}\n\n/**\n * Extract a human-readable description of a clicked element.\n */\nfunction describeElement(element: HTMLElement): string {\n const tag = element.tagName?.toLowerCase() ?? 'unknown';\n const type =\n tag === 'input'\n ? (element as HTMLInputElement).type?.toLowerCase()\n : undefined;\n\n // Don't record anything from password inputs\n if (type === 'password') {\n return 'password input';\n }\n\n // Determine element role for description\n let role: string;\n if (tag === 'button' || element.getAttribute('role') === 'button') {\n role = 'button';\n } else if (tag === 'a') {\n role = 'link';\n } else if (tag === 'input') {\n role = `${type ?? 'text'} input`;\n } else if (tag === 'select') {\n role = 'dropdown';\n } else if (tag === 'textarea') {\n role = 'textarea';\n } else {\n role = tag;\n }\n\n // Get meaningful text content\n let text: string | null = null;\n\n // aria-label is highest priority for meaningful text\n const ariaLabel = element.getAttribute('aria-label');\n if (ariaLabel) {\n text = ariaLabel;\n }\n // For buttons and links, try innerText\n else if (tag === 'button' || tag === 'a') {\n const innerText = element.innerText?.trim();\n if (innerText) {\n text = innerText.split('\\n')[0]; // First line only\n }\n }\n // For inputs, use placeholder or name\n else if (tag === 'input' || tag === 'textarea') {\n const placeholder = (element as HTMLInputElement).placeholder;\n const name = element.getAttribute('name');\n text = placeholder || name || null;\n }\n\n // Build description\n const id = element.id ? `#${element.id}` : '';\n const textPart = text ? ` '${truncate(text, 50)}'` : '';\n\n return `Clicked${textPart} ${role}${id}`;\n}\n\n/**\n * Set up click tracking as breadcrumbs.\n * Uses capture phase to intercept clicks before they may be stopped.\n */\nfunction setupClickTracking(client: UncaughtClient): () => void {\n const handleClick = (event: MouseEvent): void => {\n try {\n const target = event.target as HTMLElement | null;\n if (!target || !target.tagName) return;\n\n // Don't record clicks on password inputs\n if (\n target.tagName.toLowerCase() === 'input' &&\n (target as HTMLInputElement).type?.toLowerCase() === 'password'\n ) {\n return;\n }\n\n const message = describeElement(target);\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'click',\n category: 'ui.click',\n message: truncate(message, MAX_MESSAGE_LENGTH),\n level: 'info',\n data: {\n tag: target.tagName.toLowerCase(),\n id: target.id || undefined,\n className:\n typeof target.className === 'string'\n ? truncate(target.className, 100)\n : undefined,\n },\n });\n } catch {\n // Silently ignore - never crash the host app\n }\n };\n\n document.addEventListener('click', handleClick, true); // capture phase\n return () => document.removeEventListener('click', handleClick, true);\n}\n\n/**\n * Set up navigation tracking as breadcrumbs.\n * Tracks popstate events and monkey-patches history.pushState / replaceState.\n */\nfunction setupNavigationTracking(client: UncaughtClient): () => void {\n let currentUrl = window.location.href;\n\n const recordNavigation = (to: string): void => {\n try {\n const from = currentUrl;\n currentUrl = to;\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'navigation',\n category: 'navigation',\n message: `Navigated to ${to}`,\n level: 'info',\n data: {\n from,\n to,\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n // popstate fires on back/forward\n const handlePopState = (): void => {\n recordNavigation(window.location.href);\n };\n\n window.addEventListener('popstate', handlePopState);\n\n // Monkey-patch pushState and replaceState\n const originalPushState = history.pushState.bind(history);\n const originalReplaceState = history.replaceState.bind(history);\n\n history.pushState = function (\n data: unknown,\n unused: string,\n url?: string | URL | null\n ): void {\n originalPushState(data, unused, url);\n if (url) {\n try {\n const resolvedUrl = new URL(\n String(url),\n window.location.href\n ).href;\n recordNavigation(resolvedUrl);\n } catch {\n recordNavigation(String(url));\n }\n }\n };\n\n history.replaceState = function (\n data: unknown,\n unused: string,\n url?: string | URL | null\n ): void {\n originalReplaceState(data, unused, url);\n if (url) {\n try {\n const resolvedUrl = new URL(\n String(url),\n window.location.href\n ).href;\n recordNavigation(resolvedUrl);\n } catch {\n recordNavigation(String(url));\n }\n }\n };\n\n return () => {\n window.removeEventListener('popstate', handlePopState);\n history.pushState = originalPushState;\n history.replaceState = originalReplaceState;\n };\n}\n\n/**\n * Set up fetch tracking as breadcrumbs.\n * Monkey-patches window.fetch to record API calls with method, URL, status, and duration.\n * Does NOT record request/response bodies. Skips requests to the Uncaught API.\n */\nfunction setupFetchTracking(client: UncaughtClient): () => void {\n const originalFetch = window.fetch.bind(window);\n\n // Get the Uncaught API endpoint to exclude self-reporting requests\n const config = client.getConfig?.() ?? {};\n const apiEndpoint =\n (config as Record<string, unknown>).endpoint ??\n (config as Record<string, unknown>).dsn ??\n '';\n const uncaughtEndpoints: string[] = [];\n\n if (typeof apiEndpoint === 'string' && apiEndpoint) {\n try {\n const url = new URL(apiEndpoint);\n uncaughtEndpoints.push(url.hostname);\n } catch {\n uncaughtEndpoints.push(apiEndpoint);\n }\n }\n\n // Also exclude common Uncaught API patterns\n uncaughtEndpoints.push('uncaught.dev');\n uncaughtEndpoints.push('api.uncaught');\n\n const isUncaughtRequest = (url: string): boolean => {\n return uncaughtEndpoints.some(\n (endpoint) => endpoint && url.includes(endpoint)\n );\n };\n\n window.fetch = async function (\n input: RequestInfo | URL,\n init?: RequestInit\n ): Promise<Response> {\n const url =\n input instanceof Request\n ? input.url\n : input instanceof URL\n ? input.href\n : String(input);\n\n const method = (\n init?.method ??\n (input instanceof Request ? input.method : 'GET')\n ).toUpperCase();\n\n // Skip Uncaught's own requests to prevent infinite loops\n if (isUncaughtRequest(url)) {\n return originalFetch(input, init);\n }\n\n const startTime = Date.now();\n\n try {\n const response = await originalFetch(input, init);\n const duration = Date.now() - startTime;\n const isError = response.status >= 400;\n\n try {\n // Truncate URL for the breadcrumb to avoid huge payloads\n const displayUrl = truncate(url, 150);\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'api_call',\n category: 'fetch',\n message: `${method} ${displayUrl} [${response.status}]`,\n level: isError ? 'error' : 'info',\n data: {\n method,\n url: displayUrl,\n status: response.status,\n statusText: response.statusText,\n duration,\n },\n });\n } catch {\n // Silently ignore breadcrumb failures\n }\n\n return response;\n } catch (error) {\n const duration = Date.now() - startTime;\n\n try {\n const displayUrl = truncate(url, 150);\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'api_call',\n category: 'fetch',\n message: `${method} ${displayUrl} [Network Error]`,\n level: 'error',\n data: {\n method,\n url: displayUrl,\n status: 0,\n error:\n error instanceof Error\n ? error.message\n : 'Network error',\n duration,\n },\n });\n } catch {\n // Silently ignore breadcrumb failures\n }\n\n throw error; // Re-throw so the app's error handling still works\n }\n };\n\n return () => {\n window.fetch = originalFetch;\n };\n}\n\n/**\n * Set up automatic DOM breadcrumb tracking including clicks,\n * navigation changes, and fetch API calls.\n *\n * @param client - The UncaughtClient instance to add breadcrumbs to.\n * @returns A cleanup function that removes all listeners and restores patched functions.\n */\nexport function setupDomBreadcrumbs(client: UncaughtClient): () => void {\n // Guard for SSR environments\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const cleanups: Array<() => void> = [];\n\n try {\n cleanups.push(setupClickTracking(client));\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to set up click tracking:', e);\n }\n }\n\n try {\n cleanups.push(setupNavigationTracking(client));\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up navigation tracking:',\n e\n );\n }\n }\n\n try {\n cleanups.push(setupFetchTracking(client));\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to set up fetch tracking:', e);\n }\n }\n\n return () => {\n cleanups.forEach((cleanup) => {\n try {\n cleanup();\n } catch {\n // Silently ignore cleanup failures\n }\n });\n };\n}\n","import type { UncaughtClient, UncaughtConfig } from '@uncaughtdev/core';\n\n/**\n * Augmented Window interface to access Next.js internals.\n * These are undocumented but stable properties Next.js sets on the window.\n */\ninterface NextWindow extends Window {\n /** Present in Pages Router - contains build-time page data */\n __NEXT_DATA__?: {\n page?: string;\n query?: Record<string, unknown>;\n buildId?: string;\n props?: Record<string, unknown>;\n };\n /** Present in App Router - contains flight response data */\n __next_f?: unknown[];\n /** Next.js router instance (Pages Router) */\n next?: {\n router?: {\n events?: {\n on: (event: string, handler: (...args: unknown[]) => void) => void;\n off: (event: string, handler: (...args: unknown[]) => void) => void;\n };\n };\n };\n}\n\n/**\n * Result of Next.js environment detection.\n */\nexport interface NextJsDetection {\n /** Whether the app appears to be running in a Next.js context */\n isNextJs: boolean;\n /** Whether the App Router is detected */\n isAppRouter: boolean;\n /** Whether the Pages Router is detected */\n isPagesRouter: boolean;\n}\n\n/**\n * Detect if the current environment is a Next.js application,\n * and which router (App Router vs Pages Router) is being used.\n *\n * This detection is best-effort and relies on undocumented\n * but stable Next.js window properties.\n *\n * @returns Detection result with router type information.\n */\nexport function detectNextJs(): NextJsDetection {\n if (typeof window === 'undefined') {\n return {\n isNextJs: false,\n isAppRouter: false,\n isPagesRouter: false,\n };\n }\n\n const win = window as NextWindow;\n\n const hasPagesData = win.__NEXT_DATA__ !== undefined;\n const hasAppRouterData = win.__next_f !== undefined;\n\n // Check for Next.js meta tag as an additional signal\n let hasNextMeta = false;\n try {\n const nextMeta = document.querySelector('meta[name=\"next-size-adjust\"]');\n hasNextMeta = nextMeta !== null;\n } catch {\n // Ignore DOM query errors\n }\n\n const isPagesRouter = hasPagesData && !hasAppRouterData;\n const isAppRouter = hasAppRouterData;\n const isNextJs = hasPagesData || hasAppRouterData || hasNextMeta;\n\n return {\n isNextJs,\n isAppRouter,\n isPagesRouter,\n };\n}\n\n/**\n * Set up navigation tracking specifically for Next.js routing.\n *\n * For the Pages Router, hooks into Next.js router events (routeChangeStart,\n * routeChangeComplete, routeChangeError).\n *\n * For the App Router, navigation is tracked via the general DOM breadcrumbs\n * (history.pushState monkey-patch), so this function primarily adds\n * Next.js-specific context.\n *\n * @param client - The UncaughtClient instance.\n * @returns A cleanup function that removes the event listeners.\n */\nexport function setupNextJsNavigation(client: UncaughtClient): () => void {\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const detection = detectNextJs();\n const cleanups: Array<() => void> = [];\n\n // Add Next.js context to the client\n try {\n client.addBreadcrumb({\n\n type: 'navigation',\n category: 'nextjs',\n message: `Next.js detected: ${\n detection.isAppRouter\n ? 'App Router'\n : detection.isPagesRouter\n ? 'Pages Router'\n : 'Unknown Router'\n }`,\n level: 'info',\n data: {\n isAppRouter: detection.isAppRouter,\n isPagesRouter: detection.isPagesRouter,\n },\n });\n } catch {\n // Silently ignore\n }\n\n // Pages Router: hook into router events\n if (detection.isPagesRouter) {\n try {\n const win = window as NextWindow;\n const routerEvents = win.next?.router?.events;\n\n if (routerEvents) {\n let navigationStartTime = 0;\n\n const handleRouteChangeStart = (url: unknown): void => {\n try {\n navigationStartTime = Date.now();\n client.addBreadcrumb({\n \n type: 'navigation',\n category: 'nextjs.route',\n message: `Route change started: ${String(url)}`,\n level: 'info',\n data: {\n to: String(url),\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n const handleRouteChangeComplete = (url: unknown): void => {\n try {\n const duration =\n navigationStartTime > 0\n ? Date.now() - navigationStartTime\n : undefined;\n\n client.addBreadcrumb({\n \n type: 'navigation',\n category: 'nextjs.route',\n message: `Route change completed: ${String(url)}`,\n level: 'info',\n data: {\n to: String(url),\n duration,\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n const handleRouteChangeError = (\n err: unknown,\n url: unknown\n ): void => {\n try {\n const duration =\n navigationStartTime > 0\n ? Date.now() - navigationStartTime\n : undefined;\n\n client.addBreadcrumb({\n \n type: 'navigation',\n category: 'nextjs.route',\n message: `Route change error: ${String(url)}`,\n level: 'error',\n data: {\n to: String(url),\n error:\n err instanceof Error\n ? err.message\n : String(err),\n duration,\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n routerEvents.on('routeChangeStart', handleRouteChangeStart);\n routerEvents.on(\n 'routeChangeComplete',\n handleRouteChangeComplete\n );\n routerEvents.on('routeChangeError', handleRouteChangeError);\n\n cleanups.push(() => {\n try {\n routerEvents.off(\n 'routeChangeStart',\n handleRouteChangeStart\n );\n routerEvents.off(\n 'routeChangeComplete',\n handleRouteChangeComplete\n );\n routerEvents.off(\n 'routeChangeError',\n handleRouteChangeError\n );\n } catch {\n // Silently ignore\n }\n });\n }\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up Next.js Pages Router navigation:',\n e\n );\n }\n }\n }\n\n return () => {\n cleanups.forEach((cleanup) => {\n try {\n cleanup();\n } catch {\n // Silently ignore cleanup failures\n }\n });\n };\n}\n\n/**\n * Higher-order function for wrapping Next.js App Router layouts.\n *\n * Returns the configuration object needed to initialize UncaughtProvider\n * with Next.js-specific defaults applied.\n *\n * Usage in layout.tsx:\n * ```tsx\n * import { UncaughtProvider } from '@uncaughtdev/react';\n * import { withUncaught } from '@uncaughtdev/react';\n *\n * const uncaughtConfig = withUncaught({\n * dsn: 'your-dsn-here',\n * environment: 'production',\n * });\n *\n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * <UncaughtProvider {...uncaughtConfig}>\n * {children}\n * </UncaughtProvider>\n * </body>\n * </html>\n * );\n * }\n * ```\n *\n * @param config - Base UncaughtConfig to extend with Next.js defaults.\n * @returns Configuration object with Next.js-specific settings applied.\n */\nexport function withUncaught(\n config: UncaughtConfig\n): UncaughtConfig & { __nextjs: boolean } {\n return {\n ...config,\n __nextjs: true,\n };\n}\n","'use client';\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport { initUncaught } from '@uncaughtdev/core';\nimport type { UncaughtClient } from '@uncaughtdev/core';\nimport { UncaughtContext } from './context';\nimport { UncaughtErrorBoundary } from './error-boundary';\nimport { setupGlobalHandlers } from './global-handlers';\nimport { setupDomBreadcrumbs } from './dom-breadcrumbs';\nimport { setupNextJsNavigation, detectNextJs } from './next-integration';\nimport type { UncaughtProviderProps } from './types';\n\n/**\n * UncaughtProvider initializes the Uncaught error monitoring client and\n * provides it to all descendant components via React context.\n *\n * It automatically:\n * - Initializes the UncaughtClient with the provided configuration\n * - Sets up global error handlers (window.onerror, unhandledrejection)\n * - Sets up DOM breadcrumb tracking (clicks, navigation, fetch)\n * - Detects and integrates with Next.js routing if present\n * - Wraps children in an error boundary\n * - Cleans up all listeners on unmount\n *\n * Usage:\n * ```tsx\n * <UncaughtProvider dsn=\"your-dsn\" environment=\"production\">\n * <App />\n * </UncaughtProvider>\n * ```\n *\n * @param props - Configuration props extending UncaughtConfig plus children, fallback, and showDialog.\n */\nexport function UncaughtProvider({\n children,\n fallback,\n showDialog,\n ...config\n}: UncaughtProviderProps): React.ReactElement {\n const [client, setClient] = useState<UncaughtClient | null>(null);\n const cleanupRef = useRef<Array<() => void>>([]);\n const initializedRef = useRef(false);\n\n useEffect(() => {\n // Prevent double-initialization in React StrictMode\n if (initializedRef.current) {\n return;\n }\n initializedRef.current = true;\n\n let mounted = true;\n const cleanups: Array<() => void> = [];\n\n try {\n // Strip React-specific props before passing to core\n const { __nextjs, ...coreConfig } = config as Record<string, unknown> & {\n __nextjs?: boolean;\n };\n\n // Initialize the core client\n const uncaughtClient = initUncaught(\n coreConfig as Parameters<typeof initUncaught>[0]\n );\n\n if (!uncaughtClient) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '[Uncaught] initUncaught returned null/undefined. Error monitoring is disabled.'\n );\n }\n return;\n }\n\n // Set up global error handlers\n try {\n const cleanupGlobal = setupGlobalHandlers(uncaughtClient);\n cleanups.push(cleanupGlobal);\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up global handlers:',\n e\n );\n }\n }\n\n // Set up DOM breadcrumbs\n try {\n const cleanupDom = setupDomBreadcrumbs(uncaughtClient);\n cleanups.push(cleanupDom);\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up DOM breadcrumbs:',\n e\n );\n }\n }\n\n // Set up Next.js integration if detected or explicitly configured\n if (typeof window !== 'undefined') {\n try {\n const nextDetection = detectNextJs();\n if (nextDetection.isNextJs || __nextjs) {\n const cleanupNext = setupNextJsNavigation(uncaughtClient);\n cleanups.push(cleanupNext);\n }\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up Next.js integration:',\n e\n );\n }\n }\n }\n\n // Store cleanups for unmount\n cleanupRef.current = cleanups;\n\n // Only update state if still mounted\n if (mounted) {\n setClient(uncaughtClient);\n }\n } catch (e) {\n // Never crash the host app during initialization\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to initialize:', e);\n }\n }\n\n return () => {\n mounted = false;\n // Run all cleanup functions\n cleanupRef.current.forEach((cleanup) => {\n try {\n cleanup();\n } catch {\n // Silently ignore cleanup failures\n }\n });\n cleanupRef.current = [];\n initializedRef.current = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // Initialize once on mount - config changes require remounting\n\n const contextValue = React.useMemo(() => ({ client }), [client]);\n\n return (\n <UncaughtContext.Provider value={contextValue}>\n <UncaughtErrorBoundary fallback={fallback} showDialog={showDialog}>\n {children}\n </UncaughtErrorBoundary>\n </UncaughtContext.Provider>\n );\n}\n","'use client';\n\nimport { useContext, useCallback } from 'react';\nimport type { UncaughtClient, Breadcrumb } from '@uncaughtdev/core';\nimport { UncaughtContext } from './context';\n\n/**\n * Returns the UncaughtClient instance from context.\n * Must be called within an UncaughtProvider.\n *\n * @throws {Error} If called outside of an UncaughtProvider.\n * @returns The UncaughtClient instance.\n */\nexport function useUncaught(): UncaughtClient {\n const { client } = useContext(UncaughtContext);\n\n if (!client) {\n throw new Error(\n 'useUncaught must be used within an <UncaughtProvider>. ' +\n 'Wrap your application in <UncaughtProvider> to use this hook.'\n );\n }\n\n return client;\n}\n\n/**\n * Returns a function that reports an error to Uncaught.\n * Safe to call even if the client is not yet initialized (will silently no-op).\n *\n * @returns A function `(error: Error, context?: Record<string, unknown>) => void`\n */\nexport function useReportError(): (\n error: Error,\n context?: Record<string, unknown>\n) => void {\n const { client } = useContext(UncaughtContext);\n\n return useCallback(\n (error: Error, context?: Record<string, unknown>) => {\n try {\n if (!client) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '[Uncaught] useReportError called but no UncaughtClient is available. ' +\n 'Make sure <UncaughtProvider> is mounted.'\n );\n }\n return;\n }\n\n client.captureError(error);\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to report error:', e);\n }\n }\n },\n [client]\n );\n}\n\n/**\n * Returns a function that adds a breadcrumb to the current Uncaught session.\n * Safe to call even if the client is not yet initialized (will silently no-op).\n *\n * @returns A function `(breadcrumb: Partial<Breadcrumb>) => void`\n */\nexport function useBreadcrumb(): (breadcrumb: Partial<Breadcrumb>) => void {\n const { client } = useContext(UncaughtContext);\n\n return useCallback(\n (breadcrumb: Partial<Breadcrumb>) => {\n try {\n if (!client) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '[Uncaught] useBreadcrumb called but no UncaughtClient is available. ' +\n 'Make sure <UncaughtProvider> is mounted.'\n );\n }\n return;\n }\n\n client.addBreadcrumb({\n type: breadcrumb.type ?? 'custom',\n category: breadcrumb.category ?? 'custom',\n message: breadcrumb.message ?? '',\n level: breadcrumb.level ?? 'info',\n data: breadcrumb.data,\n });\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to add breadcrumb:', e);\n }\n }\n },\n [client]\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/context.ts","../src/error-boundary.tsx","../src/global-handlers.ts","../src/dom-breadcrumbs.ts","../src/next-integration.ts","../src/web-vitals.ts","../src/provider.tsx","../src/hooks.ts"],"names":["UncaughtContext","createContext","UncaughtErrorBoundary","Component","props","error","errorInfo","client","onError","beforeCapture","componentStack","e","handlePopState","hasError","children","fallback","showDialog","feedback","feedbackSent","jsx","jsxs","NOISE_PATTERNS","isNoiseError","message","pattern","isIgnoredByConfig","ignoreErrors","normalizeRejectionReason","reason","setupGlobalHandlers","handleError","event","filename","errorMessage","errorObj","handleRejection","truncate","str","maxLen","describeElement","element","tag","type","role","text","ariaLabel","innerText","placeholder","name","id","setupClickTracking","handleClick","target","setupNavigationTracking","currentUrl","recordNavigation","to","from","originalPushState","originalReplaceState","data","unused","url","resolvedUrl","setupFetchTracking","originalFetch","config","apiEndpoint","uncaughtEndpoints","isUncaughtRequest","endpoint","input","init","method","startTime","response","duration","isError","displayUrl","setupXhrTracking","originalOpen","originalSend","ep","rest","body","xhr","handleEnd","status","setupDomBreadcrumbs","cleanups","cleanup","detectNextJs","win","hasPagesData","hasAppRouterData","hasNextMeta","setupNextJsNavigation","detection","routerEvents","navigationStartTime","handleRouteChangeStart","handleRouteChangeComplete","handleRouteChangeError","err","withUncaught","setupWebVitals","observers","recordVital","value","unit","displayValue","lcpObserver","list","entries","last","fidObserver","first","clsValue","clsObserver","entry","layoutShift","reportCLS","fcpObserver","fcp","navEntries","nav","o","UncaughtProvider","setClient","useState","cleanupRef","useRef","initializedRef","useEffect","mounted","__nextjs","coreConfig","uncaughtClient","initUncaught","cleanupGlobal","cleanupDom","cleanupVitals","cleanupNext","contextValue","React","useUncaught","useContext","useReportError","useCallback","context","useErrorHandler","fn","args","result","withErrorCapture","useBreadcrumb","breadcrumb"],"mappings":"8NASO,IAAMA,EAAkBC,eAAAA,CAAoC,CACjE,MAAA,CAAQ,IACV,CAAC,EAEDD,EAAgB,WAAA,CAAc,iBAAA,CCOvB,IAAME,EAAN,cAAoCC,WAGzC,CAMA,WAAA,CAAYC,CAAAA,CAAmC,CAC7C,KAAA,CAAMA,CAAK,CAAA,CAHb,IAAA,CAAQ,sBAAA,CAA8C,IAAA,CAmFtD,gBAAa,IAAY,CACvB,KAAK,QAAA,CAAS,CACZ,SAAU,KAAA,CACV,KAAA,CAAO,IACT,CAAC,EACH,CAAA,CApFE,KAAK,KAAA,CAAQ,CACX,SAAU,KAAA,CACV,KAAA,CAAO,KACP,QAAA,CAAU,EAAA,CACV,YAAA,CAAc,KAAA,CACd,WAAA,CAAa,IACf,EACF,CAEA,OAAO,yBAAyBC,CAAAA,CAAqH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CAAQ,GAAA,CAAI,QAAA,GAAa,aAAA,EAC3B,OAAA,CAAQ,KACN,8GAEF,CAAA,CAEF,MACF,CAEAA,CAAAA,CAAO,aAAA,CAAc,CACnB,IAAA,CAAMqJ,CAAAA,CAAW,IAAA,EAAQ,QAAA,CACzB,QAAA,CAAUA,CAAAA,CAAW,QAAA,EAAY,QAAA,CACjC,OAAA,CAASA,EAAW,OAAA,EAAW,EAAA,CAC/B,KAAA,CAAOA,CAAAA,CAAW,KAAA,EAAS,MAAA,CAC3B,IAAA,CAAMA,CAAAA,CAAW,IACnB,CAAC,EACH,CAAA,MAASjJ,CAAAA,CAAG,CAEN,OAAA,CAAQ,GAAA,CAAI,WAAa,aAAA,EAC3B,OAAA,CAAQ,KAAA,CAAM,sCAAA,CAAwCA,CAAC,EAE3D,CACF,CAAA,CACA,CAACJ,CAAM,CACT,CACF","file":"index.js","sourcesContent":["'use client';\n\nimport { createContext } from 'react';\nimport type { UncaughtContextValue } from './types';\n\n/**\n * React context that provides the UncaughtClient instance to descendant components.\n * The context value is null when no UncaughtProvider is present in the tree.\n */\nexport const UncaughtContext = createContext<UncaughtContextValue>({\n client: null,\n});\n\nUncaughtContext.displayName = 'UncaughtContext';\n","'use client';\n\nimport React, { Component } from 'react';\nimport type { UncaughtClient } from '@uncaughtdev/core';\nimport { UncaughtContext } from './context';\nimport type { UncaughtErrorBoundaryProps, ErrorBoundaryState } from './types';\n\n/**\n * React Error Boundary that captures errors and reports them to Uncaught.\n *\n * Must be a class component as React does not support error boundaries\n * via function components / hooks.\n *\n * Usage:\n * ```tsx\n * <UncaughtErrorBoundary fallback={<div>Something went wrong</div>}>\n * <MyApp />\n * </UncaughtErrorBoundary>\n * ```\n */\nexport class UncaughtErrorBoundary extends Component<\n UncaughtErrorBoundaryProps,\n ErrorBoundaryState & { feedback: string; feedbackSent: boolean; lastEventId: string | null }\n> {\n static contextType = UncaughtContext;\n declare context: React.ContextType<typeof UncaughtContext>;\n\n private removePopstateListener: (() => void) | null = null;\n\n constructor(props: UncaughtErrorBoundaryProps) {\n super(props);\n this.state = {\n hasError: false,\n error: null,\n feedback: '',\n feedbackSent: false,\n lastEventId: null,\n };\n }\n\n static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState & { feedback: string; feedbackSent: boolean; lastEventId: string | null }> {\n return {\n hasError: true,\n error,\n feedback: '',\n feedbackSent: false,\n lastEventId: null,\n };\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {\n try {\n const client: UncaughtClient | null = this.context?.client ?? null;\n const { onError, beforeCapture } = this.props;\n\n // Extract component stack for richer error context\n const componentStack = errorInfo.componentStack ?? undefined;\n\n if (client) {\n client.captureError(error, {\n componentStack,\n });\n\n // Add a breadcrumb noting the error boundary source\n client.addBreadcrumb({\n type: 'custom',\n category: 'react.error_boundary',\n message: `Error boundary caught: ${error.message}`,\n level: 'error',\n });\n }\n\n // Invoke the user's onError callback if provided\n if (onError) {\n onError(error, errorInfo);\n }\n } catch (e) {\n // Never crash the host app from error reporting itself\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Error in componentDidCatch handler:', e);\n }\n }\n }\n\n componentDidMount(): void {\n // Auto-reset the error boundary when the user navigates via browser back/forward\n if (typeof window !== 'undefined') {\n const handlePopState = (): void => {\n if (this.state.hasError) {\n this.resetError();\n }\n };\n\n window.addEventListener('popstate', handlePopState);\n this.removePopstateListener = () => {\n window.removeEventListener('popstate', handlePopState);\n };\n }\n }\n\n componentWillUnmount(): void {\n if (this.removePopstateListener) {\n this.removePopstateListener();\n this.removePopstateListener = null;\n }\n }\n\n /**\n * Reset the error boundary state, allowing children to re-render.\n */\n resetError = (): void => {\n this.setState({\n hasError: false,\n error: null,\n });\n };\n\n render(): React.ReactNode {\n const { hasError, error } = this.state;\n const { children, fallback, showDialog } = this.props;\n\n if (!hasError || !error) {\n return children;\n }\n\n // Custom fallback: render function\n if (typeof fallback === 'function') {\n try {\n return fallback(error);\n } catch (e) {\n // If the fallback itself throws, fall through to default\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Fallback render function threw:', e);\n }\n }\n }\n\n // Custom fallback: ReactNode\n if (fallback !== undefined && typeof fallback !== 'function') {\n return fallback;\n }\n\n // Default dialog UI with feedback form\n if (showDialog) {\n const { feedback, feedbackSent } = this.state;\n const client: UncaughtClient | null = this.context?.client ?? null;\n\n return (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: '100vh',\n padding: '20px',\n fontFamily:\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif',\n backgroundColor: '#f8f9fa',\n }}\n >\n <div\n style={{\n maxWidth: '480px',\n width: '100%',\n backgroundColor: '#ffffff',\n borderRadius: '12px',\n boxShadow:\n '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)',\n padding: '32px',\n textAlign: 'center',\n }}\n >\n <div\n style={{\n width: '48px',\n height: '48px',\n borderRadius: '50%',\n backgroundColor: '#fee2e2',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n margin: '0 auto 16px',\n fontSize: '24px',\n color: '#dc2626',\n }}\n >\n !\n </div>\n <h2\n style={{\n margin: '0 0 8px',\n fontSize: '20px',\n fontWeight: 600,\n color: '#111827',\n }}\n >\n Something went wrong\n </h2>\n <p\n style={{\n margin: '0 0 16px',\n fontSize: '14px',\n color: '#6b7280',\n lineHeight: 1.5,\n }}\n >\n An unexpected error occurred. Our team has been notified and is\n working on a fix.\n </p>\n {process.env.NODE_ENV === 'development' && (\n <pre\n style={{\n textAlign: 'left',\n backgroundColor: '#f3f4f6',\n padding: '12px',\n borderRadius: '8px',\n fontSize: '12px',\n color: '#dc2626',\n overflow: 'auto',\n maxHeight: '120px',\n marginBottom: '16px',\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n }}\n >\n {error.message}\n {error.stack && `\\n\\n${error.stack}`}\n </pre>\n )}\n {/* User feedback form */}\n {!feedbackSent ? (\n <div style={{ marginBottom: '16px', textAlign: 'left' }}>\n <label\n htmlFor=\"uncaught-feedback\"\n style={{\n display: 'block',\n fontSize: '13px',\n fontWeight: 500,\n color: '#374151',\n marginBottom: '6px',\n }}\n >\n What were you doing when this happened?\n </label>\n <textarea\n id=\"uncaught-feedback\"\n value={feedback}\n onChange={(e) => this.setState({ feedback: e.target.value })}\n placeholder=\"Describe what you were doing...\"\n style={{\n width: '100%',\n minHeight: '80px',\n padding: '8px 12px',\n border: '1px solid #d1d5db',\n borderRadius: '8px',\n fontSize: '14px',\n fontFamily: 'inherit',\n resize: 'vertical',\n boxSizing: 'border-box',\n }}\n />\n {feedback.trim() && (\n <button\n onClick={() => {\n try {\n if (client && feedback.trim()) {\n client.submitFeedback?.('', feedback.trim());\n this.setState({ feedbackSent: true });\n }\n } catch {\n // Never crash\n }\n }}\n style={{\n marginTop: '8px',\n backgroundColor: '#059669',\n color: '#ffffff',\n border: 'none',\n borderRadius: '6px',\n padding: '8px 16px',\n fontSize: '13px',\n fontWeight: 500,\n cursor: 'pointer',\n }}\n >\n Send Feedback\n </button>\n )}\n </div>\n ) : (\n <p\n style={{\n fontSize: '13px',\n color: '#059669',\n marginBottom: '16px',\n }}\n >\n Thank you for your feedback!\n </p>\n )}\n <button\n onClick={() => {\n try {\n if (typeof window !== 'undefined') {\n window.location.reload();\n }\n } catch {\n // Silently ignore reload failures\n }\n }}\n style={{\n backgroundColor: '#3b82f6',\n color: '#ffffff',\n border: 'none',\n borderRadius: '8px',\n padding: '10px 24px',\n fontSize: '14px',\n fontWeight: 500,\n cursor: 'pointer',\n transition: 'background-color 0.15s ease',\n }}\n onMouseOver={(e) => {\n (e.target as HTMLButtonElement).style.backgroundColor =\n '#2563eb';\n }}\n onMouseOut={(e) => {\n (e.target as HTMLButtonElement).style.backgroundColor =\n '#3b82f6';\n }}\n >\n Reload Page\n </button>\n </div>\n </div>\n );\n }\n\n // No fallback and no dialog: render nothing (transparent failure)\n return null;\n }\n}\n","import type { UncaughtClient } from '@uncaughtdev/core';\n\n/**\n * Patterns for errors that are typically noise and should be ignored.\n * These are errors produced by the browser, extensions, or third-party scripts\n * that provide no actionable information.\n */\nconst NOISE_PATTERNS: RegExp[] = [\n // ResizeObserver loop errors are benign and happen in many apps\n /ResizeObserver loop/i,\n // \"Script error.\" with no useful info (cross-origin scripts without CORS headers)\n /^Script error\\.?$/i,\n // Browser extension errors\n /chrome-extension:\\/\\//i,\n /moz-extension:\\/\\//i,\n /safari-extension:\\/\\//i,\n /safari-web-extension:\\/\\//i,\n // Edge extension errors\n /extension:\\/\\//i,\n];\n\n/**\n * Check if an error message matches any of the known noise patterns.\n */\nfunction isNoiseError(message: string): boolean {\n return NOISE_PATTERNS.some((pattern) => pattern.test(message));\n}\n\n/**\n * Check if an error matches any user-defined ignoreErrors patterns.\n */\nfunction isIgnoredByConfig(\n message: string,\n ignoreErrors?: Array<string | RegExp>\n): boolean {\n if (!ignoreErrors || ignoreErrors.length === 0) {\n return false;\n }\n\n return ignoreErrors.some((pattern) => {\n if (typeof pattern === 'string') {\n return message.includes(pattern);\n }\n return pattern.test(message);\n });\n}\n\n/**\n * Normalize a promise rejection reason into a proper Error object.\n */\nfunction normalizeRejectionReason(reason: unknown): Error {\n if (reason instanceof Error) {\n return reason;\n }\n\n if (typeof reason === 'string') {\n return new Error(reason);\n }\n\n if (reason !== null && reason !== undefined) {\n try {\n return new Error(JSON.stringify(reason));\n } catch {\n return new Error(String(reason));\n }\n }\n\n return new Error('Unhandled promise rejection with no reason');\n}\n\n/**\n * Set up global error handlers to capture uncaught exceptions and\n * unhandled promise rejections.\n *\n * @param client - The UncaughtClient instance to report errors to.\n * @returns A cleanup function that removes the event listeners.\n */\nexport function setupGlobalHandlers(client: UncaughtClient): () => void {\n // Guard for SSR environments\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const config = client.getConfig?.() ?? {};\n const ignoreErrors = (config as Record<string, unknown>)\n .ignoreErrors as Array<string | RegExp> | undefined;\n\n /**\n * Handle uncaught exceptions via window.onerror / 'error' event.\n */\n const handleError = (event: ErrorEvent): void => {\n try {\n const { error, message, filename } = event;\n\n // \"Script error.\" with no stack and no filename is cross-origin noise\n if (\n !error &&\n (!message || message === 'Script error.') &&\n !filename\n ) {\n return;\n }\n\n const errorMessage =\n error?.message ?? message ?? 'Unknown error';\n\n // Filter out noise errors\n if (isNoiseError(errorMessage)) {\n return;\n }\n\n // Filter out user-configured ignored errors\n if (isIgnoredByConfig(errorMessage, ignoreErrors)) {\n return;\n }\n\n // Build the error object\n const errorObj =\n error instanceof Error ? error : new Error(errorMessage);\n\n client.captureError(errorObj, {\n tags: { source: 'window.onerror' },\n extra: {\n filename: filename ?? undefined,\n lineno: event.lineno ?? undefined,\n colno: event.colno ?? undefined,\n },\n });\n\n // Do NOT call event.preventDefault() - let the browser still log the error\n } catch (e) {\n // Never crash the host app from our error handler\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Error in global error handler:', e);\n }\n }\n };\n\n /**\n * Handle unhandled promise rejections.\n */\n const handleRejection = (event: PromiseRejectionEvent): void => {\n try {\n const error = normalizeRejectionReason(event.reason);\n const errorMessage = error.message;\n\n // Filter out noise errors\n if (isNoiseError(errorMessage)) {\n return;\n }\n\n // Filter out user-configured ignored errors\n if (isIgnoredByConfig(errorMessage, ignoreErrors)) {\n return;\n }\n\n client.captureError(error, {\n tags: {\n source: 'unhandledrejection',\n unhandled: 'true',\n },\n });\n\n // Do NOT call event.preventDefault() - let the browser still log\n } catch (e) {\n // Never crash the host app from our error handler\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Error in unhandled rejection handler:',\n e\n );\n }\n }\n };\n\n window.addEventListener('error', handleError);\n window.addEventListener('unhandledrejection', handleRejection);\n\n // Return cleanup function\n return () => {\n window.removeEventListener('error', handleError);\n window.removeEventListener('unhandledrejection', handleRejection);\n };\n}\n","import type { UncaughtClient } from '@uncaughtdev/core';\n\n/**\n * Maximum length for breadcrumb messages to avoid excessively large payloads.\n */\nconst MAX_MESSAGE_LENGTH = 200;\n\n/**\n * Truncate a string to a maximum length, appending \"...\" if truncated.\n */\nfunction truncate(str: string, maxLen: number): string {\n if (str.length <= maxLen) return str;\n return str.slice(0, maxLen - 3) + '...';\n}\n\n/**\n * Extract a human-readable description of a clicked element.\n */\nfunction describeElement(element: HTMLElement): string {\n const tag = element.tagName?.toLowerCase() ?? 'unknown';\n const type =\n tag === 'input'\n ? (element as HTMLInputElement).type?.toLowerCase()\n : undefined;\n\n // Don't record anything from password inputs\n if (type === 'password') {\n return 'password input';\n }\n\n // Determine element role for description\n let role: string;\n if (tag === 'button' || element.getAttribute('role') === 'button') {\n role = 'button';\n } else if (tag === 'a') {\n role = 'link';\n } else if (tag === 'input') {\n role = `${type ?? 'text'} input`;\n } else if (tag === 'select') {\n role = 'dropdown';\n } else if (tag === 'textarea') {\n role = 'textarea';\n } else {\n role = tag;\n }\n\n // Get meaningful text content\n let text: string | null = null;\n\n // aria-label is highest priority for meaningful text\n const ariaLabel = element.getAttribute('aria-label');\n if (ariaLabel) {\n text = ariaLabel;\n }\n // For buttons and links, try innerText\n else if (tag === 'button' || tag === 'a') {\n const innerText = element.innerText?.trim();\n if (innerText) {\n text = innerText.split('\\n')[0]; // First line only\n }\n }\n // For inputs, use placeholder or name\n else if (tag === 'input' || tag === 'textarea') {\n const placeholder = (element as HTMLInputElement).placeholder;\n const name = element.getAttribute('name');\n text = placeholder || name || null;\n }\n\n // Build description\n const id = element.id ? `#${element.id}` : '';\n const textPart = text ? ` '${truncate(text, 50)}'` : '';\n\n return `Clicked${textPart} ${role}${id}`;\n}\n\n/**\n * Set up click tracking as breadcrumbs.\n * Uses capture phase to intercept clicks before they may be stopped.\n */\nfunction setupClickTracking(client: UncaughtClient): () => void {\n const handleClick = (event: MouseEvent): void => {\n try {\n const target = event.target as HTMLElement | null;\n if (!target || !target.tagName) return;\n\n // Don't record clicks on password inputs\n if (\n target.tagName.toLowerCase() === 'input' &&\n (target as HTMLInputElement).type?.toLowerCase() === 'password'\n ) {\n return;\n }\n\n const message = describeElement(target);\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'click',\n category: 'ui.click',\n message: truncate(message, MAX_MESSAGE_LENGTH),\n level: 'info',\n data: {\n tag: target.tagName.toLowerCase(),\n id: target.id || undefined,\n className:\n typeof target.className === 'string'\n ? truncate(target.className, 100)\n : undefined,\n },\n });\n } catch {\n // Silently ignore - never crash the host app\n }\n };\n\n document.addEventListener('click', handleClick, true); // capture phase\n return () => document.removeEventListener('click', handleClick, true);\n}\n\n/**\n * Set up navigation tracking as breadcrumbs.\n * Tracks popstate events and monkey-patches history.pushState / replaceState.\n */\nfunction setupNavigationTracking(client: UncaughtClient): () => void {\n let currentUrl = window.location.href;\n\n const recordNavigation = (to: string): void => {\n try {\n const from = currentUrl;\n currentUrl = to;\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'navigation',\n category: 'navigation',\n message: `Navigated to ${to}`,\n level: 'info',\n data: {\n from,\n to,\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n // popstate fires on back/forward\n const handlePopState = (): void => {\n recordNavigation(window.location.href);\n };\n\n window.addEventListener('popstate', handlePopState);\n\n // Monkey-patch pushState and replaceState\n const originalPushState = history.pushState.bind(history);\n const originalReplaceState = history.replaceState.bind(history);\n\n history.pushState = function (\n data: unknown,\n unused: string,\n url?: string | URL | null\n ): void {\n originalPushState(data, unused, url);\n if (url) {\n try {\n const resolvedUrl = new URL(\n String(url),\n window.location.href\n ).href;\n recordNavigation(resolvedUrl);\n } catch {\n recordNavigation(String(url));\n }\n }\n };\n\n history.replaceState = function (\n data: unknown,\n unused: string,\n url?: string | URL | null\n ): void {\n originalReplaceState(data, unused, url);\n if (url) {\n try {\n const resolvedUrl = new URL(\n String(url),\n window.location.href\n ).href;\n recordNavigation(resolvedUrl);\n } catch {\n recordNavigation(String(url));\n }\n }\n };\n\n return () => {\n window.removeEventListener('popstate', handlePopState);\n history.pushState = originalPushState;\n history.replaceState = originalReplaceState;\n };\n}\n\n/**\n * Set up fetch tracking as breadcrumbs.\n * Monkey-patches window.fetch to record API calls with method, URL, status, and duration.\n * Does NOT record request/response bodies. Skips requests to the Uncaught API.\n */\nfunction setupFetchTracking(client: UncaughtClient): () => void {\n const originalFetch = window.fetch.bind(window);\n\n // Get the Uncaught API endpoint to exclude self-reporting requests\n const config = client.getConfig?.() ?? {};\n const apiEndpoint =\n (config as Record<string, unknown>).endpoint ??\n (config as Record<string, unknown>).dsn ??\n '';\n const uncaughtEndpoints: string[] = [];\n\n if (typeof apiEndpoint === 'string' && apiEndpoint) {\n try {\n const url = new URL(apiEndpoint);\n uncaughtEndpoints.push(url.hostname);\n } catch {\n uncaughtEndpoints.push(apiEndpoint);\n }\n }\n\n // Also exclude common Uncaught API patterns\n uncaughtEndpoints.push('uncaught.dev');\n uncaughtEndpoints.push('api.uncaught');\n\n const isUncaughtRequest = (url: string): boolean => {\n return uncaughtEndpoints.some(\n (endpoint) => endpoint && url.includes(endpoint)\n );\n };\n\n window.fetch = async function (\n input: RequestInfo | URL,\n init?: RequestInit\n ): Promise<Response> {\n const url =\n input instanceof Request\n ? input.url\n : input instanceof URL\n ? input.href\n : String(input);\n\n const method = (\n init?.method ??\n (input instanceof Request ? input.method : 'GET')\n ).toUpperCase();\n\n // Skip Uncaught's own requests to prevent infinite loops\n if (isUncaughtRequest(url)) {\n return originalFetch(input, init);\n }\n\n const startTime = Date.now();\n\n try {\n const response = await originalFetch(input, init);\n const duration = Date.now() - startTime;\n const isError = response.status >= 400;\n\n try {\n // Truncate URL for the breadcrumb to avoid huge payloads\n const displayUrl = truncate(url, 150);\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'api_call',\n category: 'fetch',\n message: `${method} ${displayUrl} [${response.status}]`,\n level: isError ? 'error' : 'info',\n data: {\n method,\n url: displayUrl,\n status: response.status,\n statusText: response.statusText,\n duration,\n },\n });\n } catch {\n // Silently ignore breadcrumb failures\n }\n\n return response;\n } catch (error) {\n const duration = Date.now() - startTime;\n\n try {\n const displayUrl = truncate(url, 150);\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'api_call',\n category: 'fetch',\n message: `${method} ${displayUrl} [Network Error]`,\n level: 'error',\n data: {\n method,\n url: displayUrl,\n status: 0,\n error:\n error instanceof Error\n ? error.message\n : 'Network error',\n duration,\n },\n });\n } catch {\n // Silently ignore breadcrumb failures\n }\n\n throw error; // Re-throw so the app's error handling still works\n }\n };\n\n return () => {\n window.fetch = originalFetch;\n };\n}\n\n/**\n * Set up XHR tracking as breadcrumbs.\n * Monkey-patches XMLHttpRequest to record API calls with method, URL, status, and duration.\n * Captures requests made by Axios and other XHR-based libraries.\n */\nfunction setupXhrTracking(client: UncaughtClient): () => void {\n if (typeof XMLHttpRequest === 'undefined') {\n return () => {};\n }\n\n const originalOpen = XMLHttpRequest.prototype.open;\n const originalSend = XMLHttpRequest.prototype.send;\n\n // Get the Uncaught API endpoint to exclude self-reporting requests\n const config = client.getConfig?.() ?? {};\n const apiEndpoint =\n (config as Record<string, unknown>).endpoint ??\n (config as Record<string, unknown>).dsn ??\n '';\n const uncaughtEndpoints: string[] = ['uncaught.dev', 'api.uncaught'];\n if (typeof apiEndpoint === 'string' && apiEndpoint) {\n try {\n uncaughtEndpoints.push(new URL(apiEndpoint).hostname);\n } catch {\n uncaughtEndpoints.push(apiEndpoint);\n }\n }\n\n const isUncaughtRequest = (url: string): boolean =>\n uncaughtEndpoints.some((ep) => ep && url.includes(ep));\n\n XMLHttpRequest.prototype.open = function (\n method: string,\n url: string | URL,\n ...rest: unknown[]\n ): void {\n (this as XMLHttpRequest & { _uncaught_method?: string; _uncaught_url?: string })._uncaught_method = method.toUpperCase();\n (this as XMLHttpRequest & { _uncaught_url?: string })._uncaught_url = String(url);\n return originalOpen.apply(this, [method, url, ...rest] as Parameters<typeof originalOpen>);\n };\n\n XMLHttpRequest.prototype.send = function (\n body?: Document | XMLHttpRequestBodyInit | null\n ): void {\n const xhr = this as XMLHttpRequest & { _uncaught_method?: string; _uncaught_url?: string };\n const method = xhr._uncaught_method ?? 'GET';\n const url = xhr._uncaught_url ?? '';\n\n if (isUncaughtRequest(url)) {\n return originalSend.call(this, body);\n }\n\n const startTime = Date.now();\n\n const handleEnd = (): void => {\n try {\n const duration = Date.now() - startTime;\n const status = xhr.status;\n const isError = status === 0 || status >= 400;\n const displayUrl = truncate(url, 150);\n\n client.addBreadcrumb({\n type: 'api_call',\n category: 'xhr',\n message: `${method} ${displayUrl} [${status || 'Error'}]`,\n level: isError ? 'error' : 'info',\n data: {\n method,\n url: displayUrl,\n status,\n statusText: xhr.statusText,\n duration,\n },\n });\n } catch {\n // Never crash\n }\n };\n\n xhr.addEventListener('loadend', handleEnd);\n\n return originalSend.call(this, body);\n };\n\n return () => {\n XMLHttpRequest.prototype.open = originalOpen;\n XMLHttpRequest.prototype.send = originalSend;\n };\n}\n\n/**\n * Set up automatic DOM breadcrumb tracking including clicks,\n * navigation changes, fetch API calls, and XHR requests.\n *\n * @param client - The UncaughtClient instance to add breadcrumbs to.\n * @returns A cleanup function that removes all listeners and restores patched functions.\n */\nexport function setupDomBreadcrumbs(client: UncaughtClient): () => void {\n // Guard for SSR environments\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const cleanups: Array<() => void> = [];\n\n try {\n cleanups.push(setupClickTracking(client));\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to set up click tracking:', e);\n }\n }\n\n try {\n cleanups.push(setupNavigationTracking(client));\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up navigation tracking:',\n e\n );\n }\n }\n\n try {\n cleanups.push(setupFetchTracking(client));\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to set up fetch tracking:', e);\n }\n }\n\n try {\n cleanups.push(setupXhrTracking(client));\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to set up XHR tracking:', e);\n }\n }\n\n return () => {\n cleanups.forEach((cleanup) => {\n try {\n cleanup();\n } catch {\n // Silently ignore cleanup failures\n }\n });\n };\n}\n","import type { UncaughtClient, UncaughtConfig } from '@uncaughtdev/core';\n\n/**\n * Augmented Window interface to access Next.js internals.\n * These are undocumented but stable properties Next.js sets on the window.\n */\ninterface NextWindow extends Window {\n /** Present in Pages Router - contains build-time page data */\n __NEXT_DATA__?: {\n page?: string;\n query?: Record<string, unknown>;\n buildId?: string;\n props?: Record<string, unknown>;\n };\n /** Present in App Router - contains flight response data */\n __next_f?: unknown[];\n /** Next.js router instance (Pages Router) */\n next?: {\n router?: {\n events?: {\n on: (event: string, handler: (...args: unknown[]) => void) => void;\n off: (event: string, handler: (...args: unknown[]) => void) => void;\n };\n };\n };\n}\n\n/**\n * Result of Next.js environment detection.\n */\nexport interface NextJsDetection {\n /** Whether the app appears to be running in a Next.js context */\n isNextJs: boolean;\n /** Whether the App Router is detected */\n isAppRouter: boolean;\n /** Whether the Pages Router is detected */\n isPagesRouter: boolean;\n}\n\n/**\n * Detect if the current environment is a Next.js application,\n * and which router (App Router vs Pages Router) is being used.\n *\n * This detection is best-effort and relies on undocumented\n * but stable Next.js window properties.\n *\n * @returns Detection result with router type information.\n */\nexport function detectNextJs(): NextJsDetection {\n if (typeof window === 'undefined') {\n return {\n isNextJs: false,\n isAppRouter: false,\n isPagesRouter: false,\n };\n }\n\n const win = window as NextWindow;\n\n const hasPagesData = win.__NEXT_DATA__ !== undefined;\n const hasAppRouterData = win.__next_f !== undefined;\n\n // Check for Next.js meta tag as an additional signal\n let hasNextMeta = false;\n try {\n const nextMeta = document.querySelector('meta[name=\"next-size-adjust\"]');\n hasNextMeta = nextMeta !== null;\n } catch {\n // Ignore DOM query errors\n }\n\n const isPagesRouter = hasPagesData && !hasAppRouterData;\n const isAppRouter = hasAppRouterData;\n const isNextJs = hasPagesData || hasAppRouterData || hasNextMeta;\n\n return {\n isNextJs,\n isAppRouter,\n isPagesRouter,\n };\n}\n\n/**\n * Set up navigation tracking specifically for Next.js routing.\n *\n * For the Pages Router, hooks into Next.js router events (routeChangeStart,\n * routeChangeComplete, routeChangeError).\n *\n * For the App Router, navigation is tracked via the general DOM breadcrumbs\n * (history.pushState monkey-patch), so this function primarily adds\n * Next.js-specific context.\n *\n * @param client - The UncaughtClient instance.\n * @returns A cleanup function that removes the event listeners.\n */\nexport function setupNextJsNavigation(client: UncaughtClient): () => void {\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const detection = detectNextJs();\n const cleanups: Array<() => void> = [];\n\n // Add Next.js context to the client\n try {\n client.addBreadcrumb({\n\n type: 'navigation',\n category: 'nextjs',\n message: `Next.js detected: ${\n detection.isAppRouter\n ? 'App Router'\n : detection.isPagesRouter\n ? 'Pages Router'\n : 'Unknown Router'\n }`,\n level: 'info',\n data: {\n isAppRouter: detection.isAppRouter,\n isPagesRouter: detection.isPagesRouter,\n },\n });\n } catch {\n // Silently ignore\n }\n\n // Pages Router: hook into router events\n if (detection.isPagesRouter) {\n try {\n const win = window as NextWindow;\n const routerEvents = win.next?.router?.events;\n\n if (routerEvents) {\n let navigationStartTime = 0;\n\n const handleRouteChangeStart = (url: unknown): void => {\n try {\n navigationStartTime = Date.now();\n client.addBreadcrumb({\n \n type: 'navigation',\n category: 'nextjs.route',\n message: `Route change started: ${String(url)}`,\n level: 'info',\n data: {\n to: String(url),\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n const handleRouteChangeComplete = (url: unknown): void => {\n try {\n const duration =\n navigationStartTime > 0\n ? Date.now() - navigationStartTime\n : undefined;\n\n client.addBreadcrumb({\n \n type: 'navigation',\n category: 'nextjs.route',\n message: `Route change completed: ${String(url)}`,\n level: 'info',\n data: {\n to: String(url),\n duration,\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n const handleRouteChangeError = (\n err: unknown,\n url: unknown\n ): void => {\n try {\n const duration =\n navigationStartTime > 0\n ? Date.now() - navigationStartTime\n : undefined;\n\n client.addBreadcrumb({\n \n type: 'navigation',\n category: 'nextjs.route',\n message: `Route change error: ${String(url)}`,\n level: 'error',\n data: {\n to: String(url),\n error:\n err instanceof Error\n ? err.message\n : String(err),\n duration,\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n routerEvents.on('routeChangeStart', handleRouteChangeStart);\n routerEvents.on(\n 'routeChangeComplete',\n handleRouteChangeComplete\n );\n routerEvents.on('routeChangeError', handleRouteChangeError);\n\n cleanups.push(() => {\n try {\n routerEvents.off(\n 'routeChangeStart',\n handleRouteChangeStart\n );\n routerEvents.off(\n 'routeChangeComplete',\n handleRouteChangeComplete\n );\n routerEvents.off(\n 'routeChangeError',\n handleRouteChangeError\n );\n } catch {\n // Silently ignore\n }\n });\n }\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up Next.js Pages Router navigation:',\n e\n );\n }\n }\n }\n\n return () => {\n cleanups.forEach((cleanup) => {\n try {\n cleanup();\n } catch {\n // Silently ignore cleanup failures\n }\n });\n };\n}\n\n/**\n * Higher-order function for wrapping Next.js App Router layouts.\n *\n * Returns the configuration object needed to initialize UncaughtProvider\n * with Next.js-specific defaults applied.\n *\n * Usage in layout.tsx:\n * ```tsx\n * import { UncaughtProvider } from '@uncaughtdev/react';\n * import { withUncaught } from '@uncaughtdev/react';\n *\n * const uncaughtConfig = withUncaught({\n * dsn: 'your-dsn-here',\n * environment: 'production',\n * });\n *\n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * <UncaughtProvider {...uncaughtConfig}>\n * {children}\n * </UncaughtProvider>\n * </body>\n * </html>\n * );\n * }\n * ```\n *\n * @param config - Base UncaughtConfig to extend with Next.js defaults.\n * @returns Configuration object with Next.js-specific settings applied.\n */\nexport function withUncaught(\n config: UncaughtConfig\n): UncaughtConfig & { __nextjs: boolean } {\n return {\n ...config,\n __nextjs: true,\n };\n}\n","import type { UncaughtClient } from '@uncaughtdev/core';\n\n/**\n * Set up Core Web Vitals tracking using native PerformanceObserver.\n * Records LCP, FID/INP, CLS, FCP, and TTFB as breadcrumbs.\n *\n * No external dependencies — uses browser-native APIs only.\n *\n * @returns Cleanup function to disconnect observers.\n */\nexport function setupWebVitals(client: UncaughtClient): () => void {\n if (typeof window === 'undefined' || typeof PerformanceObserver === 'undefined') {\n return () => {};\n }\n\n const observers: PerformanceObserver[] = [];\n\n function recordVital(name: string, value: number, unit: string = 'ms'): void {\n try {\n const displayValue = unit === 'ms'\n ? `${Math.round(value)}ms`\n : value.toFixed(3);\n\n client.addBreadcrumb({\n type: 'web_vital',\n category: 'web-vital',\n message: `${name}: ${displayValue}`,\n level: 'info',\n data: { name, value, unit },\n });\n } catch {\n // Never crash\n }\n }\n\n // --- LCP (Largest Contentful Paint) ---\n try {\n const lcpObserver = new PerformanceObserver((list) => {\n const entries = list.getEntries();\n const last = entries[entries.length - 1];\n if (last) {\n recordVital('LCP', last.startTime);\n }\n });\n lcpObserver.observe({ type: 'largest-contentful-paint', buffered: true });\n observers.push(lcpObserver);\n } catch {\n // Not supported\n }\n\n // --- FID (First Input Delay) ---\n try {\n const fidObserver = new PerformanceObserver((list) => {\n const entries = list.getEntries();\n const first = entries[0] as PerformanceEventTiming | undefined;\n if (first) {\n recordVital('FID', first.processingStart - first.startTime);\n }\n });\n fidObserver.observe({ type: 'first-input', buffered: true });\n observers.push(fidObserver);\n } catch {\n // Not supported\n }\n\n // --- CLS (Cumulative Layout Shift) ---\n try {\n let clsValue = 0;\n const clsObserver = new PerformanceObserver((list) => {\n for (const entry of list.getEntries()) {\n const layoutShift = entry as PerformanceEntry & { hadRecentInput?: boolean; value?: number };\n if (!layoutShift.hadRecentInput && layoutShift.value) {\n clsValue += layoutShift.value;\n }\n }\n });\n clsObserver.observe({ type: 'layout-shift', buffered: true });\n observers.push(clsObserver);\n\n // Report CLS on page hide\n const reportCLS = (): void => {\n if (clsValue > 0) {\n recordVital('CLS', clsValue, 'score');\n }\n };\n window.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'hidden') reportCLS();\n });\n } catch {\n // Not supported\n }\n\n // --- FCP (First Contentful Paint) ---\n try {\n const fcpObserver = new PerformanceObserver((list) => {\n const entries = list.getEntries();\n const fcp = entries.find((e) => e.name === 'first-contentful-paint');\n if (fcp) {\n recordVital('FCP', fcp.startTime);\n }\n });\n fcpObserver.observe({ type: 'paint', buffered: true });\n observers.push(fcpObserver);\n } catch {\n // Not supported\n }\n\n // --- TTFB (Time to First Byte) ---\n try {\n const navEntries = performance.getEntriesByType('navigation') as PerformanceNavigationTiming[];\n if (navEntries.length > 0) {\n const nav = navEntries[0];\n if (nav.responseStart > 0) {\n recordVital('TTFB', nav.responseStart - nav.requestStart);\n }\n }\n } catch {\n // Not supported\n }\n\n return () => {\n observers.forEach((o) => {\n try { o.disconnect(); } catch { /* ignore */ }\n });\n };\n}\n\n// Type augmentation for PerformanceEventTiming (not in all TS libs)\ninterface PerformanceEventTiming extends PerformanceEntry {\n processingStart: number;\n}\n","'use client';\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport { initUncaught } from '@uncaughtdev/core';\nimport type { UncaughtClient } from '@uncaughtdev/core';\nimport { UncaughtContext } from './context';\nimport { UncaughtErrorBoundary } from './error-boundary';\nimport { setupGlobalHandlers } from './global-handlers';\nimport { setupDomBreadcrumbs } from './dom-breadcrumbs';\nimport { setupNextJsNavigation, detectNextJs } from './next-integration';\nimport { setupWebVitals } from './web-vitals';\nimport type { UncaughtProviderProps } from './types';\n\n/**\n * UncaughtProvider initializes the Uncaught error monitoring client and\n * provides it to all descendant components via React context.\n *\n * It automatically:\n * - Initializes the UncaughtClient with the provided configuration\n * - Sets up global error handlers (window.onerror, unhandledrejection)\n * - Sets up DOM breadcrumb tracking (clicks, navigation, fetch)\n * - Detects and integrates with Next.js routing if present\n * - Wraps children in an error boundary\n * - Cleans up all listeners on unmount\n *\n * Usage:\n * ```tsx\n * <UncaughtProvider dsn=\"your-dsn\" environment=\"production\">\n * <App />\n * </UncaughtProvider>\n * ```\n *\n * @param props - Configuration props extending UncaughtConfig plus children, fallback, and showDialog.\n */\nexport function UncaughtProvider({\n children,\n fallback,\n showDialog,\n ...config\n}: UncaughtProviderProps): React.ReactElement {\n const [client, setClient] = useState<UncaughtClient | null>(null);\n const cleanupRef = useRef<Array<() => void>>([]);\n const initializedRef = useRef(false);\n\n useEffect(() => {\n // Prevent double-initialization in React StrictMode\n if (initializedRef.current) {\n return;\n }\n initializedRef.current = true;\n\n let mounted = true;\n const cleanups: Array<() => void> = [];\n\n try {\n // Strip React-specific props before passing to core\n const { __nextjs, ...coreConfig } = config as Record<string, unknown> & {\n __nextjs?: boolean;\n };\n\n // Initialize the core client\n const uncaughtClient = initUncaught(\n coreConfig as Parameters<typeof initUncaught>[0]\n );\n\n if (!uncaughtClient) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '[Uncaught] initUncaught returned null/undefined. Error monitoring is disabled.'\n );\n }\n return;\n }\n\n // Set up global error handlers\n try {\n const cleanupGlobal = setupGlobalHandlers(uncaughtClient);\n cleanups.push(cleanupGlobal);\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up global handlers:',\n e\n );\n }\n }\n\n // Set up DOM breadcrumbs\n try {\n const cleanupDom = setupDomBreadcrumbs(uncaughtClient);\n cleanups.push(cleanupDom);\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up DOM breadcrumbs:',\n e\n );\n }\n }\n\n // Set up Web Vitals tracking\n try {\n const cleanupVitals = setupWebVitals(uncaughtClient);\n cleanups.push(cleanupVitals);\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to set up Web Vitals:', e);\n }\n }\n\n // Set up Next.js integration if detected or explicitly configured\n if (typeof window !== 'undefined') {\n try {\n const nextDetection = detectNextJs();\n if (nextDetection.isNextJs || __nextjs) {\n const cleanupNext = setupNextJsNavigation(uncaughtClient);\n cleanups.push(cleanupNext);\n }\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up Next.js integration:',\n e\n );\n }\n }\n }\n\n // Store cleanups for unmount\n cleanupRef.current = cleanups;\n\n // Only update state if still mounted\n if (mounted) {\n setClient(uncaughtClient);\n }\n } catch (e) {\n // Never crash the host app during initialization\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to initialize:', e);\n }\n }\n\n return () => {\n mounted = false;\n // Run all cleanup functions\n cleanupRef.current.forEach((cleanup) => {\n try {\n cleanup();\n } catch {\n // Silently ignore cleanup failures\n }\n });\n cleanupRef.current = [];\n initializedRef.current = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // Initialize once on mount - config changes require remounting\n\n const contextValue = React.useMemo(() => ({ client }), [client]);\n\n return (\n <UncaughtContext.Provider value={contextValue}>\n <UncaughtErrorBoundary fallback={fallback} showDialog={showDialog}>\n {children}\n </UncaughtErrorBoundary>\n </UncaughtContext.Provider>\n );\n}\n","'use client';\n\nimport { useContext, useCallback } from 'react';\nimport type { UncaughtClient, Breadcrumb } from '@uncaughtdev/core';\nimport { UncaughtContext } from './context';\n\n/**\n * Returns the UncaughtClient instance from context.\n * Must be called within an UncaughtProvider.\n *\n * @throws {Error} If called outside of an UncaughtProvider.\n * @returns The UncaughtClient instance.\n */\nexport function useUncaught(): UncaughtClient {\n const { client } = useContext(UncaughtContext);\n\n if (!client) {\n throw new Error(\n 'useUncaught must be used within an <UncaughtProvider>. ' +\n 'Wrap your application in <UncaughtProvider> to use this hook.'\n );\n }\n\n return client;\n}\n\n/**\n * Returns a function that reports an error to Uncaught.\n * Safe to call even if the client is not yet initialized (will silently no-op).\n *\n * @returns A function `(error: Error, context?: Record<string, unknown>) => void`\n */\nexport function useReportError(): (\n error: Error,\n context?: Record<string, unknown>\n) => void {\n const { client } = useContext(UncaughtContext);\n\n return useCallback(\n (error: Error, context?: Record<string, unknown>) => {\n try {\n if (!client) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '[Uncaught] useReportError called but no UncaughtClient is available. ' +\n 'Make sure <UncaughtProvider> is mounted.'\n );\n }\n return;\n }\n\n client.captureError(error);\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to report error:', e);\n }\n }\n },\n [client]\n );\n}\n\n/**\n * Returns a function that adds a breadcrumb to the current Uncaught session.\n * Safe to call even if the client is not yet initialized (will silently no-op).\n *\n * @returns A function `(breadcrumb: Partial<Breadcrumb>) => void`\n */\n/**\n * Wraps a callback function with error capture.\n * Use this for event handlers (onClick, onChange, etc.) that React Error\n * Boundary does not catch.\n *\n * @example\n * ```tsx\n * const handleClick = useErrorHandler((e) => {\n * // risky code that might throw\n * });\n * <button onClick={handleClick}>Click</button>\n * ```\n */\nexport function useErrorHandler<T extends (...args: unknown[]) => unknown>(\n fn: T\n): T {\n const { client } = useContext(UncaughtContext);\n\n return useCallback(\n ((...args: unknown[]) => {\n try {\n const result = fn(...args);\n // Handle async functions\n if (result instanceof Promise) {\n return result.catch((error: unknown) => {\n try {\n if (client) {\n client.captureError(error);\n }\n } catch {\n // Never crash\n }\n throw error; // Re-throw so app error handling still works\n });\n }\n return result;\n } catch (error) {\n try {\n if (client) {\n client.captureError(error);\n }\n } catch {\n // Never crash\n }\n throw error; // Re-throw so app error handling still works\n }\n }) as T,\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [fn, client]\n );\n}\n\n/**\n * Standalone HOF (non-hook) that wraps a function with error capture.\n * Use in class components or outside React context.\n */\nexport function withErrorCapture<T extends (...args: unknown[]) => unknown>(\n fn: T,\n client?: UncaughtClient | null\n): T {\n return ((...args: unknown[]) => {\n try {\n const result = fn(...args);\n if (result instanceof Promise) {\n return result.catch((error: unknown) => {\n try {\n if (client) {\n client.captureError(error);\n }\n } catch {\n // Never crash\n }\n throw error;\n });\n }\n return result;\n } catch (error) {\n try {\n if (client) {\n client.captureError(error);\n }\n } catch {\n // Never crash\n }\n throw error;\n }\n }) as T;\n}\n\nexport function useBreadcrumb(): (breadcrumb: Partial<Breadcrumb>) => void {\n const { client } = useContext(UncaughtContext);\n\n return useCallback(\n (breadcrumb: Partial<Breadcrumb>) => {\n try {\n if (!client) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '[Uncaught] useBreadcrumb called but no UncaughtClient is available. ' +\n 'Make sure <UncaughtProvider> is mounted.'\n );\n }\n return;\n }\n\n client.addBreadcrumb({\n type: breadcrumb.type ?? 'custom',\n category: breadcrumb.category ?? 'custom',\n message: breadcrumb.message ?? '',\n level: breadcrumb.level ?? 'info',\n data: breadcrumb.data,\n });\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to add breadcrumb:', e);\n }\n }\n },\n [client]\n );\n}\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import j,{createContext,Component,useState,useRef,useEffect,useContext,useCallback}from'react';import {initUncaught}from'@uncaughtdev/core';export{getClient,initUncaught}from'@uncaughtdev/core';import {jsx,jsxs}from'react/jsx-runtime';var g=createContext({client:null});g.displayName="UncaughtContext";var v=class extends Component{constructor(r){super(r);this.removePopstateListener=null;this.resetError=()=>{this.setState({hasError:false,error:null});};this.state={hasError:false,error:null,feedback:"",feedbackSent:false,lastEventId:null};}static getDerivedStateFromError(r){return {hasError:true,error:r,feedback:"",feedbackSent:false,lastEventId:null}}componentDidCatch(r,e){try{let o=this.context?.client??null,{onError:s,beforeCapture:a}=this.props,i=e.componentStack??void 0;o&&(o.captureError(r,{componentStack:i}),o.addBreadcrumb({type:"custom",category:"react.error_boundary",message:`Error boundary caught: ${r.message}`,level:"error"})),s&&s(r,e);}catch(o){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Error in componentDidCatch handler:",o);}}componentDidMount(){if(typeof window<"u"){let r=()=>{this.state.hasError&&this.resetError();};window.addEventListener("popstate",r),this.removePopstateListener=()=>{window.removeEventListener("popstate",r);};}}componentWillUnmount(){this.removePopstateListener&&(this.removePopstateListener(),this.removePopstateListener=null);}render(){let{hasError:r,error:e}=this.state,{children:o,fallback:s,showDialog:a}=this.props;if(!r||!e)return o;if(typeof s=="function")try{return s(e)}catch(i){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Fallback render function threw:",i);}if(s!==void 0&&typeof s!="function")return s;if(a){let{feedback:i,feedbackSent:c}=this.state,u=this.context?.client??null;return jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"100vh",padding:"20px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',backgroundColor:"#f8f9fa"},children:jsxs("div",{style:{maxWidth:"480px",width:"100%",backgroundColor:"#ffffff",borderRadius:"12px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",padding:"32px",textAlign:"center"},children:[jsx("div",{style:{width:"48px",height:"48px",borderRadius:"50%",backgroundColor:"#fee2e2",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 16px",fontSize:"24px",color:"#dc2626"},children:"!"}),jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",fontWeight:600,color:"#111827"},children:"Something went wrong"}),jsx("p",{style:{margin:"0 0 16px",fontSize:"14px",color:"#6b7280",lineHeight:1.5},children:"An unexpected error occurred. Our team has been notified and is working on a fix."}),process.env.NODE_ENV==="development"&&jsxs("pre",{style:{textAlign:"left",backgroundColor:"#f3f4f6",padding:"12px",borderRadius:"8px",fontSize:"12px",color:"#dc2626",overflow:"auto",maxHeight:"120px",marginBottom:"16px",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[e.message,e.stack&&`
|
|
2
2
|
|
|
3
|
-
${
|
|
4
|
-
`)[0]);}else if(t==="input"||t==="textarea"){let u=e.placeholder,c=e.getAttribute("name");a=u||c||null;}let o=e.id?`#${e.id}`:"";return `Clicked${a?` '${y(a,50)}'`:""} ${r}${o}`}function T(e){let t=n=>{try{let r=n.target;if(!r||!r.tagName||r.tagName.toLowerCase()==="input"&&r.type?.toLowerCase()==="password")return;let a=O(r);e.addBreadcrumb({timestamp:new Date().toISOString(),type:"click",category:"ui.click",message:y(a,200),level:"info",data:{tag:r.tagName.toLowerCase(),id:r.id||void 0,className:typeof r.className=="string"?y(r.className,100):void 0}});}catch{}};return document.addEventListener("click",t,true),()=>document.removeEventListener("click",t,true)}function M(e){let t=window.location.href,n=o=>{try{let i=t;t=o,e.addBreadcrumb({timestamp:new Date().toISOString(),type:"navigation",category:"navigation",message:`Navigated to ${o}`,level:"info",data:{from:i,to:o}});}catch{}},r=()=>{n(window.location.href);};window.addEventListener("popstate",r);let a=history.pushState.bind(history),s=history.replaceState.bind(history);return history.pushState=function(o,i,u){if(a(o,i,u),u)try{let c=new URL(String(u),window.location.href).href;n(c);}catch{n(String(u));}},history.replaceState=function(o,i,u){if(s(o,i,u),u)try{let c=new URL(String(u),window.location.href).href;n(c);}catch{n(String(u));}},()=>{window.removeEventListener("popstate",r),history.pushState=a,history.replaceState=s;}}function V(e){let t=window.fetch.bind(window),n=e.getConfig?.()??{},r=n.endpoint??n.dsn??"",a=[];if(typeof r=="string"&&r)try{let o=new URL(r);a.push(o.hostname);}catch{a.push(r);}a.push("uncaught.dev"),a.push("api.uncaught");let s=o=>a.some(i=>i&&o.includes(i));return window.fetch=async function(o,i){let u=o instanceof Request?o.url:o instanceof URL?o.href:String(o),c=(i?.method??(o instanceof Request?o.method:"GET")).toUpperCase();if(s(u))return t(o,i);let l=Date.now();try{let d=await t(o,i),m=Date.now()-l,g=d.status>=400;try{let p=y(u,150);e.addBreadcrumb({timestamp:new Date().toISOString(),type:"api_call",category:"fetch",message:`${c} ${p} [${d.status}]`,level:g?"error":"info",data:{method:c,url:p,status:d.status,statusText:d.statusText,duration:m}});}catch{}return d}catch(d){let m=Date.now()-l;try{let g=y(u,150);e.addBreadcrumb({timestamp:new Date().toISOString(),type:"api_call",category:"fetch",message:`${c} ${g} [Network Error]`,level:"error",data:{method:c,url:g,status:0,error:d instanceof Error?d.message:"Network error",duration:m}});}catch{}throw d}},()=>{window.fetch=t;}}function R(e){if(typeof window>"u")return ()=>{};let t=[];try{t.push(T(e));}catch(n){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up click tracking:",n);}try{t.push(M(e));}catch(n){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up navigation tracking:",n);}try{t.push(V(e));}catch(n){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up fetch tracking:",n);}return ()=>{t.forEach(n=>{try{n();}catch{}});}}function w(){if(typeof window>"u")return {isNextJs:false,isAppRouter:false,isPagesRouter:false};let e=window,t=e.__NEXT_DATA__!==void 0,n=e.__next_f!==void 0,r=false;try{r=document.querySelector('meta[name="next-size-adjust"]')!==null;}catch{}return {isNextJs:t||n||r,isAppRouter:n,isPagesRouter:t&&!n}}function x(e){if(typeof window>"u")return ()=>{};let t=w(),n=[];try{e.addBreadcrumb({type:"navigation",category:"nextjs",message:`Next.js detected: ${t.isAppRouter?"App Router":t.isPagesRouter?"Pages Router":"Unknown Router"}`,level:"info",data:{isAppRouter:t.isAppRouter,isPagesRouter:t.isPagesRouter}});}catch{}if(t.isPagesRouter)try{let a=window.next?.router?.events;if(a){let s=0,o=c=>{try{s=Date.now(),e.addBreadcrumb({type:"navigation",category:"nextjs.route",message:`Route change started: ${String(c)}`,level:"info",data:{to:String(c)}});}catch{}},i=c=>{try{let l=s>0?Date.now()-s:void 0;e.addBreadcrumb({type:"navigation",category:"nextjs.route",message:`Route change completed: ${String(c)}`,level:"info",data:{to:String(c),duration:l}});}catch{}},u=(c,l)=>{try{let d=s>0?Date.now()-s:void 0;e.addBreadcrumb({type:"navigation",category:"nextjs.route",message:`Route change error: ${String(l)}`,level:"error",data:{to:String(l),error:c instanceof Error?c.message:String(c),duration:d}});}catch{}};a.on("routeChangeStart",o),a.on("routeChangeComplete",i),a.on("routeChangeError",u),n.push(()=>{try{a.off("routeChangeStart",o),a.off("routeChangeComplete",i),a.off("routeChangeError",u);}catch{}});}}catch(r){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up Next.js Pages Router navigation:",r);}return ()=>{n.forEach(r=>{try{r();}catch{}});}}function j(e){return {...e,__nextjs:true}}function J({children:e,fallback:t,showDialog:n,...r}){let[a,s]=useState(null),o=useRef([]),i=useRef(false);useEffect(()=>{if(i.current)return;i.current=true;let c=true,l=[];try{let{__nextjs:d,...m}=r,g=initUncaught(m);if(!g){process.env.NODE_ENV==="development"&&console.warn("[Uncaught] initUncaught returned null/undefined. Error monitoring is disabled.");return}try{let p=C(g);l.push(p);}catch(p){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up global handlers:",p);}try{let p=R(g);l.push(p);}catch(p){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up DOM breadcrumbs:",p);}if(typeof window<"u")try{if(w().isNextJs||d){let D=x(g);l.push(D);}}catch(p){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up Next.js integration:",p);}o.current=l,c&&s(g);}catch(d){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to initialize:",d);}return ()=>{c=false,o.current.forEach(d=>{try{d();}catch{}}),o.current=[],i.current=false;}},[]);let u=$.useMemo(()=>({client:a}),[a]);return jsx(f.Provider,{value:u,children:jsx(h,{fallback:t,showDialog:n,children:e})})}function z(){let{client:e}=useContext(f);if(!e)throw new Error("useUncaught must be used within an <UncaughtProvider>. Wrap your application in <UncaughtProvider> to use this hook.");return e}function W(){let{client:e}=useContext(f);return useCallback((t,n)=>{try{if(!e){process.env.NODE_ENV==="development"&&console.warn("[Uncaught] useReportError called but no UncaughtClient is available. Make sure <UncaughtProvider> is mounted.");return}e.captureError(t);}catch(r){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to report error:",r);}},[e])}function G(){let{client:e}=useContext(f);return useCallback(t=>{try{if(!e){process.env.NODE_ENV==="development"&&console.warn("[Uncaught] useBreadcrumb called but no UncaughtClient is available. Make sure <UncaughtProvider> is mounted.");return}e.addBreadcrumb({type:t.type??"custom",category:t.category??"custom",message:t.message??"",level:t.level??"info",data:t.data});}catch(n){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to add breadcrumb:",n);}},[e])}export{f as UncaughtContext,h as UncaughtErrorBoundary,J as UncaughtProvider,w as detectNextJs,x as setupNextJsNavigation,G as useBreadcrumb,W as useReportError,z as useUncaught,j as withUncaught};//# sourceMappingURL=index.mjs.map
|
|
3
|
+
${e.stack}`]}),c?jsx("p",{style:{fontSize:"13px",color:"#059669",marginBottom:"16px"},children:"Thank you for your feedback!"}):jsxs("div",{style:{marginBottom:"16px",textAlign:"left"},children:[jsx("label",{htmlFor:"uncaught-feedback",style:{display:"block",fontSize:"13px",fontWeight:500,color:"#374151",marginBottom:"6px"},children:"What were you doing when this happened?"}),jsx("textarea",{id:"uncaught-feedback",value:i,onChange:d=>this.setState({feedback:d.target.value}),placeholder:"Describe what you were doing...",style:{width:"100%",minHeight:"80px",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:"8px",fontSize:"14px",fontFamily:"inherit",resize:"vertical",boxSizing:"border-box"}}),i.trim()&&jsx("button",{onClick:()=>{try{u&&i.trim()&&(u.submitFeedback?.("",i.trim()),this.setState({feedbackSent:!0}));}catch{}},style:{marginTop:"8px",backgroundColor:"#059669",color:"#ffffff",border:"none",borderRadius:"6px",padding:"8px 16px",fontSize:"13px",fontWeight:500,cursor:"pointer"},children:"Send Feedback"})]}),jsx("button",{onClick:()=>{try{typeof window<"u"&&window.location.reload();}catch{}},style:{backgroundColor:"#3b82f6",color:"#ffffff",border:"none",borderRadius:"8px",padding:"10px 24px",fontSize:"14px",fontWeight:500,cursor:"pointer",transition:"background-color 0.15s ease"},onMouseOver:d=>{d.target.style.backgroundColor="#2563eb";},onMouseOut:d=>{d.target.style.backgroundColor="#3b82f6";},children:"Reload Page"})]})})}return null}};v.contextType=g;var B=[/ResizeObserver loop/i,/^Script error\.?$/i,/chrome-extension:\/\//i,/moz-extension:\/\//i,/safari-extension:\/\//i,/safari-web-extension:\/\//i,/extension:\/\//i];function N(t){return B.some(n=>n.test(t))}function S(t,n){return !n||n.length===0?false:n.some(r=>typeof r=="string"?t.includes(r):r.test(t))}function M(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(t!=null)try{return new Error(JSON.stringify(t))}catch{return new Error(String(t))}return new Error("Unhandled promise rejection with no reason")}function _(t){if(typeof window>"u")return ()=>{};let r=(t.getConfig?.()??{}).ignoreErrors,e=s=>{try{let{error:a,message:i,filename:c}=s;if(!a&&(!i||i==="Script error.")&&!c)return;let u=a?.message??i??"Unknown error";if(N(u)||S(u,r))return;let d=a instanceof Error?a:new Error(u);t.captureError(d,{tags:{source:"window.onerror"},extra:{filename:c??void 0,lineno:s.lineno??void 0,colno:s.colno??void 0}});}catch(a){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Error in global error handler:",a);}},o=s=>{try{let a=M(s.reason),i=a.message;if(N(i)||S(i,r))return;t.captureError(a,{tags:{source:"unhandledrejection",unhandled:"true"}});}catch(a){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Error in unhandled rejection handler:",a);}};return window.addEventListener("error",e),window.addEventListener("unhandledrejection",o),()=>{window.removeEventListener("error",e),window.removeEventListener("unhandledrejection",o);}}function y(t,n){return t.length<=n?t:t.slice(0,n-3)+"..."}function A(t){let n=t.tagName?.toLowerCase()??"unknown",r=n==="input"?t.type?.toLowerCase():void 0;if(r==="password")return "password input";let e;n==="button"||t.getAttribute("role")==="button"?e="button":n==="a"?e="link":n==="input"?e=`${r??"text"} input`:n==="select"?e="dropdown":n==="textarea"?e="textarea":e=n;let o=null,s=t.getAttribute("aria-label");if(s)o=s;else if(n==="button"||n==="a"){let c=t.innerText?.trim();c&&(o=c.split(`
|
|
4
|
+
`)[0]);}else if(n==="input"||n==="textarea"){let c=t.placeholder,u=t.getAttribute("name");o=c||u||null;}let a=t.id?`#${t.id}`:"";return `Clicked${o?` '${y(o,50)}'`:""} ${e}${a}`}function V(t){let n=r=>{try{let e=r.target;if(!e||!e.tagName||e.tagName.toLowerCase()==="input"&&e.type?.toLowerCase()==="password")return;let o=A(e);t.addBreadcrumb({timestamp:new Date().toISOString(),type:"click",category:"ui.click",message:y(o,200),level:"info",data:{tag:e.tagName.toLowerCase(),id:e.id||void 0,className:typeof e.className=="string"?y(e.className,100):void 0}});}catch{}};return document.addEventListener("click",n,true),()=>document.removeEventListener("click",n,true)}function H(t){let n=window.location.href,r=a=>{try{let i=n;n=a,t.addBreadcrumb({timestamp:new Date().toISOString(),type:"navigation",category:"navigation",message:`Navigated to ${a}`,level:"info",data:{from:i,to:a}});}catch{}},e=()=>{r(window.location.href);};window.addEventListener("popstate",e);let o=history.pushState.bind(history),s=history.replaceState.bind(history);return history.pushState=function(a,i,c){if(o(a,i,c),c)try{let u=new URL(String(c),window.location.href).href;r(u);}catch{r(String(c));}},history.replaceState=function(a,i,c){if(s(a,i,c),c)try{let u=new URL(String(c),window.location.href).href;r(u);}catch{r(String(c));}},()=>{window.removeEventListener("popstate",e),history.pushState=o,history.replaceState=s;}}function F(t){let n=window.fetch.bind(window),r=t.getConfig?.()??{},e=r.endpoint??r.dsn??"",o=[];if(typeof e=="string"&&e)try{let a=new URL(e);o.push(a.hostname);}catch{o.push(e);}o.push("uncaught.dev"),o.push("api.uncaught");let s=a=>o.some(i=>i&&a.includes(i));return window.fetch=async function(a,i){let c=a instanceof Request?a.url:a instanceof URL?a.href:String(a),u=(i?.method??(a instanceof Request?a.method:"GET")).toUpperCase();if(s(c))return n(a,i);let d=Date.now();try{let p=await n(a,i),m=Date.now()-d,f=p.status>=400;try{let l=y(c,150);t.addBreadcrumb({timestamp:new Date().toISOString(),type:"api_call",category:"fetch",message:`${u} ${l} [${p.status}]`,level:f?"error":"info",data:{method:u,url:l,status:p.status,statusText:p.statusText,duration:m}});}catch{}return p}catch(p){let m=Date.now()-d;try{let f=y(c,150);t.addBreadcrumb({timestamp:new Date().toISOString(),type:"api_call",category:"fetch",message:`${u} ${f} [Network Error]`,level:"error",data:{method:u,url:f,status:0,error:p instanceof Error?p.message:"Network error",duration:m}});}catch{}throw p}},()=>{window.fetch=n;}}function $(t){if(typeof XMLHttpRequest>"u")return ()=>{};let n=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send,e=t.getConfig?.()??{},o=e.endpoint??e.dsn??"",s=["uncaught.dev","api.uncaught"];if(typeof o=="string"&&o)try{s.push(new URL(o).hostname);}catch{s.push(o);}let a=i=>s.some(c=>c&&i.includes(c));return XMLHttpRequest.prototype.open=function(i,c,...u){return this._uncaught_method=i.toUpperCase(),this._uncaught_url=String(c),n.apply(this,[i,c,...u])},XMLHttpRequest.prototype.send=function(i){let c=this,u=c._uncaught_method??"GET",d=c._uncaught_url??"";if(a(d))return r.call(this,i);let p=Date.now(),m=()=>{try{let f=Date.now()-p,l=c.status,x=l===0||l>=400,C=y(d,150);t.addBreadcrumb({type:"api_call",category:"xhr",message:`${u} ${C} [${l||"Error"}]`,level:x?"error":"info",data:{method:u,url:C,status:l,statusText:c.statusText,duration:f}});}catch{}};return c.addEventListener("loadend",m),r.call(this,i)},()=>{XMLHttpRequest.prototype.open=n,XMLHttpRequest.prototype.send=r;}}function P(t){if(typeof window>"u")return ()=>{};let n=[];try{n.push(V(t));}catch(r){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up click tracking:",r);}try{n.push(H(t));}catch(r){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up navigation tracking:",r);}try{n.push(F(t));}catch(r){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up fetch tracking:",r);}try{n.push($(t));}catch(r){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up XHR tracking:",r);}return ()=>{n.forEach(r=>{try{r();}catch{}});}}function w(){if(typeof window>"u")return {isNextJs:false,isAppRouter:false,isPagesRouter:false};let t=window,n=t.__NEXT_DATA__!==void 0,r=t.__next_f!==void 0,e=false;try{e=document.querySelector('meta[name="next-size-adjust"]')!==null;}catch{}return {isNextJs:n||r||e,isAppRouter:r,isPagesRouter:n&&!r}}function U(t){if(typeof window>"u")return ()=>{};let n=w(),r=[];try{t.addBreadcrumb({type:"navigation",category:"nextjs",message:`Next.js detected: ${n.isAppRouter?"App Router":n.isPagesRouter?"Pages Router":"Unknown Router"}`,level:"info",data:{isAppRouter:n.isAppRouter,isPagesRouter:n.isPagesRouter}});}catch{}if(n.isPagesRouter)try{let o=window.next?.router?.events;if(o){let s=0,a=u=>{try{s=Date.now(),t.addBreadcrumb({type:"navigation",category:"nextjs.route",message:`Route change started: ${String(u)}`,level:"info",data:{to:String(u)}});}catch{}},i=u=>{try{let d=s>0?Date.now()-s:void 0;t.addBreadcrumb({type:"navigation",category:"nextjs.route",message:`Route change completed: ${String(u)}`,level:"info",data:{to:String(u),duration:d}});}catch{}},c=(u,d)=>{try{let p=s>0?Date.now()-s:void 0;t.addBreadcrumb({type:"navigation",category:"nextjs.route",message:`Route change error: ${String(d)}`,level:"error",data:{to:String(d),error:u instanceof Error?u.message:String(u),duration:p}});}catch{}};o.on("routeChangeStart",a),o.on("routeChangeComplete",i),o.on("routeChangeError",c),r.push(()=>{try{o.off("routeChangeStart",a),o.off("routeChangeComplete",i),o.off("routeChangeError",c);}catch{}});}}catch(e){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up Next.js Pages Router navigation:",e);}return ()=>{r.forEach(e=>{try{e();}catch{}});}}function I(t){return {...t,__nextjs:true}}function R(t){if(typeof window>"u"||typeof PerformanceObserver>"u")return ()=>{};let n=[];function r(e,o,s="ms"){try{let a=s==="ms"?`${Math.round(o)}ms`:o.toFixed(3);t.addBreadcrumb({type:"web_vital",category:"web-vital",message:`${e}: ${a}`,level:"info",data:{name:e,value:o,unit:s}});}catch{}}try{let e=new PerformanceObserver(o=>{let s=o.getEntries(),a=s[s.length-1];a&&r("LCP",a.startTime);});e.observe({type:"largest-contentful-paint",buffered:!0}),n.push(e);}catch{}try{let e=new PerformanceObserver(o=>{let a=o.getEntries()[0];a&&r("FID",a.processingStart-a.startTime);});e.observe({type:"first-input",buffered:!0}),n.push(e);}catch{}try{let e=0,o=new PerformanceObserver(a=>{for(let i of a.getEntries()){let c=i;!c.hadRecentInput&&c.value&&(e+=c.value);}});o.observe({type:"layout-shift",buffered:!0}),n.push(o);let s=()=>{e>0&&r("CLS",e,"score");};window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&s();});}catch{}try{let e=new PerformanceObserver(o=>{let a=o.getEntries().find(i=>i.name==="first-contentful-paint");a&&r("FCP",a.startTime);});e.observe({type:"paint",buffered:!0}),n.push(e);}catch{}try{let e=performance.getEntriesByType("navigation");if(e.length>0){let o=e[0];o.responseStart>0&&r("TTFB",o.responseStart-o.requestStart);}}catch{}return ()=>{n.forEach(e=>{try{e.disconnect();}catch{}});}}function W({children:t,fallback:n,showDialog:r,...e}){let[o,s]=useState(null),a=useRef([]),i=useRef(false);useEffect(()=>{if(i.current)return;i.current=true;let u=true,d=[];try{let{__nextjs:p,...m}=e,f=initUncaught(m);if(!f){process.env.NODE_ENV==="development"&&console.warn("[Uncaught] initUncaught returned null/undefined. Error monitoring is disabled.");return}try{let l=_(f);d.push(l);}catch(l){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up global handlers:",l);}try{let l=P(f);d.push(l);}catch(l){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up DOM breadcrumbs:",l);}try{let l=R(f);d.push(l);}catch(l){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up Web Vitals:",l);}if(typeof window<"u")try{if(w().isNextJs||p){let x=U(f);d.push(x);}}catch(l){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to set up Next.js integration:",l);}a.current=d,u&&s(f);}catch(p){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to initialize:",p);}return ()=>{u=false,a.current.forEach(p=>{try{p();}catch{}}),a.current=[],i.current=false;}},[]);let c=j.useMemo(()=>({client:o}),[o]);return jsx(g.Provider,{value:c,children:jsx(v,{fallback:n,showDialog:r,children:t})})}function J(){let{client:t}=useContext(g);if(!t)throw new Error("useUncaught must be used within an <UncaughtProvider>. Wrap your application in <UncaughtProvider> to use this hook.");return t}function G(){let{client:t}=useContext(g);return useCallback((n,r)=>{try{if(!t){process.env.NODE_ENV==="development"&&console.warn("[Uncaught] useReportError called but no UncaughtClient is available. Make sure <UncaughtProvider> is mounted.");return}t.captureError(n);}catch(e){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to report error:",e);}},[t])}function K(t){let{client:n}=useContext(g);return useCallback(((...r)=>{try{let e=t(...r);return e instanceof Promise?e.catch(o=>{try{n&&n.captureError(o);}catch{}throw o}):e}catch(e){try{n&&n.captureError(e);}catch{}throw e}}),[t,n])}function Q(t,n){return((...r)=>{try{let e=t(...r);return e instanceof Promise?e.catch(o=>{try{n&&n.captureError(o);}catch{}throw o}):e}catch(e){try{n&&n.captureError(e);}catch{}throw e}})}function Y(){let{client:t}=useContext(g);return useCallback(n=>{try{if(!t){process.env.NODE_ENV==="development"&&console.warn("[Uncaught] useBreadcrumb called but no UncaughtClient is available. Make sure <UncaughtProvider> is mounted.");return}t.addBreadcrumb({type:n.type??"custom",category:n.category??"custom",message:n.message??"",level:n.level??"info",data:n.data});}catch(r){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to add breadcrumb:",r);}},[t])}export{g as UncaughtContext,v as UncaughtErrorBoundary,W as UncaughtProvider,w as detectNextJs,U as setupNextJsNavigation,R as setupWebVitals,Y as useBreadcrumb,K as useErrorHandler,G as useReportError,J as useUncaught,Q as withErrorCapture,I as withUncaught};//# sourceMappingURL=index.mjs.map
|
|
5
5
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context.ts","../src/error-boundary.tsx","../src/global-handlers.ts","../src/dom-breadcrumbs.ts","../src/next-integration.ts","../src/provider.tsx","../src/hooks.ts"],"names":["UncaughtContext","createContext","UncaughtErrorBoundary","Component","props","error","errorInfo","client","onError","beforeCapture","componentStack","e","handlePopState","hasError","children","fallback","showDialog","jsx","jsxs","NOISE_PATTERNS","isNoiseError","message","pattern","isIgnoredByConfig","ignoreErrors","normalizeRejectionReason","reason","setupGlobalHandlers","handleError","event","filename","errorMessage","errorObj","handleRejection","truncate","str","maxLen","describeElement","element","tag","type","role","text","ariaLabel","innerText","placeholder","name","id","setupClickTracking","handleClick","target","setupNavigationTracking","currentUrl","recordNavigation","to","from","originalPushState","originalReplaceState","data","unused","url","resolvedUrl","setupFetchTracking","originalFetch","config","apiEndpoint","uncaughtEndpoints","isUncaughtRequest","endpoint","input","init","method","startTime","response","duration","isError","displayUrl","setupDomBreadcrumbs","cleanups","cleanup","detectNextJs","win","hasPagesData","hasAppRouterData","hasNextMeta","setupNextJsNavigation","detection","routerEvents","navigationStartTime","handleRouteChangeStart","handleRouteChangeComplete","handleRouteChangeError","err","withUncaught","UncaughtProvider","setClient","useState","cleanupRef","useRef","initializedRef","useEffect","mounted","__nextjs","coreConfig","uncaughtClient","initUncaught","cleanupGlobal","cleanupDom","cleanupNext","contextValue","React","useUncaught","useContext","useReportError","useCallback","context","useBreadcrumb","breadcrumb"],"mappings":"+OASaA,CAAAA,CAAkBC,aAAAA,CAAoC,CACjE,MAAA,CAAQ,IACV,CAAC,EAEDD,CAAAA,CAAgB,YAAc,iBAAA,CCOvB,IAAME,EAAN,cAAoCC,SAGzC,CAMA,WAAA,CAAYC,CAAAA,CAAmC,CAC7C,KAAA,CAAMA,CAAK,CAAA,CAHb,KAAQ,sBAAA,CAA8C,IAAA,CA6EtD,gBAAa,IAAY,CACvB,KAAK,QAAA,CAAS,CACZ,SAAU,KAAA,CACV,KAAA,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,CAAwCA,CAAC,EAE3D,CACF,EACA,CAACJ,CAAM,CACT,CACF","file":"index.mjs","sourcesContent":["'use client';\n\nimport { createContext } from 'react';\nimport type { UncaughtContextValue } from './types';\n\n/**\n * React context that provides the UncaughtClient instance to descendant components.\n * The context value is null when no UncaughtProvider is present in the tree.\n */\nexport const UncaughtContext = createContext<UncaughtContextValue>({\n client: null,\n});\n\nUncaughtContext.displayName = 'UncaughtContext';\n","'use client';\n\nimport React, { Component } from 'react';\nimport type { UncaughtClient } from '@uncaughtdev/core';\nimport { UncaughtContext } from './context';\nimport type { UncaughtErrorBoundaryProps, ErrorBoundaryState } from './types';\n\n/**\n * React Error Boundary that captures errors and reports them to Uncaught.\n *\n * Must be a class component as React does not support error boundaries\n * via function components / hooks.\n *\n * Usage:\n * ```tsx\n * <UncaughtErrorBoundary fallback={<div>Something went wrong</div>}>\n * <MyApp />\n * </UncaughtErrorBoundary>\n * ```\n */\nexport class UncaughtErrorBoundary extends Component<\n UncaughtErrorBoundaryProps,\n ErrorBoundaryState\n> {\n static contextType = UncaughtContext;\n declare context: React.ContextType<typeof UncaughtContext>;\n\n private removePopstateListener: (() => void) | null = null;\n\n constructor(props: UncaughtErrorBoundaryProps) {\n super(props);\n this.state = {\n hasError: false,\n error: null,\n };\n }\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return {\n hasError: true,\n error,\n };\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {\n try {\n const client: UncaughtClient | null = this.context?.client ?? null;\n const { onError, beforeCapture } = this.props;\n\n // Extract component stack for richer error context\n const componentStack = errorInfo.componentStack ?? undefined;\n\n if (client) {\n client.captureError(error, {\n componentStack,\n });\n\n // Add a breadcrumb noting the error boundary source\n client.addBreadcrumb({\n type: 'custom',\n category: 'react.error_boundary',\n message: `Error boundary caught: ${error.message}`,\n level: 'error',\n });\n }\n\n // Invoke the user's onError callback if provided\n if (onError) {\n onError(error, errorInfo);\n }\n } catch (e) {\n // Never crash the host app from error reporting itself\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Error in componentDidCatch handler:', e);\n }\n }\n }\n\n componentDidMount(): void {\n // Auto-reset the error boundary when the user navigates via browser back/forward\n if (typeof window !== 'undefined') {\n const handlePopState = (): void => {\n if (this.state.hasError) {\n this.resetError();\n }\n };\n\n window.addEventListener('popstate', handlePopState);\n this.removePopstateListener = () => {\n window.removeEventListener('popstate', handlePopState);\n };\n }\n }\n\n componentWillUnmount(): void {\n if (this.removePopstateListener) {\n this.removePopstateListener();\n this.removePopstateListener = null;\n }\n }\n\n /**\n * Reset the error boundary state, allowing children to re-render.\n */\n resetError = (): void => {\n this.setState({\n hasError: false,\n error: null,\n });\n };\n\n render(): React.ReactNode {\n const { hasError, error } = this.state;\n const { children, fallback, showDialog } = this.props;\n\n if (!hasError || !error) {\n return children;\n }\n\n // Custom fallback: render function\n if (typeof fallback === 'function') {\n try {\n return fallback(error);\n } catch (e) {\n // If the fallback itself throws, fall through to default\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Fallback render function threw:', e);\n }\n }\n }\n\n // Custom fallback: ReactNode\n if (fallback !== undefined && typeof fallback !== 'function') {\n return fallback;\n }\n\n // Default dialog UI\n if (showDialog) {\n return (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: '100vh',\n padding: '20px',\n fontFamily:\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif',\n backgroundColor: '#f8f9fa',\n }}\n >\n <div\n style={{\n maxWidth: '480px',\n width: '100%',\n backgroundColor: '#ffffff',\n borderRadius: '12px',\n boxShadow:\n '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)',\n padding: '32px',\n textAlign: 'center',\n }}\n >\n <div\n style={{\n width: '48px',\n height: '48px',\n borderRadius: '50%',\n backgroundColor: '#fee2e2',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n margin: '0 auto 16px',\n fontSize: '24px',\n color: '#dc2626',\n }}\n >\n !\n </div>\n <h2\n style={{\n margin: '0 0 8px',\n fontSize: '20px',\n fontWeight: 600,\n color: '#111827',\n }}\n >\n Something went wrong\n </h2>\n <p\n style={{\n margin: '0 0 24px',\n fontSize: '14px',\n color: '#6b7280',\n lineHeight: 1.5,\n }}\n >\n An unexpected error occurred. Our team has been notified and is\n working on a fix.\n </p>\n {process.env.NODE_ENV === 'development' && (\n <pre\n style={{\n textAlign: 'left',\n backgroundColor: '#f3f4f6',\n padding: '12px',\n borderRadius: '8px',\n fontSize: '12px',\n color: '#dc2626',\n overflow: 'auto',\n maxHeight: '120px',\n marginBottom: '24px',\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n }}\n >\n {error.message}\n {error.stack && `\\n\\n${error.stack}`}\n </pre>\n )}\n <button\n onClick={() => {\n try {\n if (typeof window !== 'undefined') {\n window.location.reload();\n }\n } catch {\n // Silently ignore reload failures\n }\n }}\n style={{\n backgroundColor: '#3b82f6',\n color: '#ffffff',\n border: 'none',\n borderRadius: '8px',\n padding: '10px 24px',\n fontSize: '14px',\n fontWeight: 500,\n cursor: 'pointer',\n transition: 'background-color 0.15s ease',\n }}\n onMouseOver={(e) => {\n (e.target as HTMLButtonElement).style.backgroundColor =\n '#2563eb';\n }}\n onMouseOut={(e) => {\n (e.target as HTMLButtonElement).style.backgroundColor =\n '#3b82f6';\n }}\n >\n Reload Page\n </button>\n </div>\n </div>\n );\n }\n\n // No fallback and no dialog: render nothing (transparent failure)\n return null;\n }\n}\n","import type { UncaughtClient } from '@uncaughtdev/core';\n\n/**\n * Patterns for errors that are typically noise and should be ignored.\n * These are errors produced by the browser, extensions, or third-party scripts\n * that provide no actionable information.\n */\nconst NOISE_PATTERNS: RegExp[] = [\n // ResizeObserver loop errors are benign and happen in many apps\n /ResizeObserver loop/i,\n // \"Script error.\" with no useful info (cross-origin scripts without CORS headers)\n /^Script error\\.?$/i,\n // Browser extension errors\n /chrome-extension:\\/\\//i,\n /moz-extension:\\/\\//i,\n /safari-extension:\\/\\//i,\n /safari-web-extension:\\/\\//i,\n // Edge extension errors\n /extension:\\/\\//i,\n];\n\n/**\n * Check if an error message matches any of the known noise patterns.\n */\nfunction isNoiseError(message: string): boolean {\n return NOISE_PATTERNS.some((pattern) => pattern.test(message));\n}\n\n/**\n * Check if an error matches any user-defined ignoreErrors patterns.\n */\nfunction isIgnoredByConfig(\n message: string,\n ignoreErrors?: Array<string | RegExp>\n): boolean {\n if (!ignoreErrors || ignoreErrors.length === 0) {\n return false;\n }\n\n return ignoreErrors.some((pattern) => {\n if (typeof pattern === 'string') {\n return message.includes(pattern);\n }\n return pattern.test(message);\n });\n}\n\n/**\n * Normalize a promise rejection reason into a proper Error object.\n */\nfunction normalizeRejectionReason(reason: unknown): Error {\n if (reason instanceof Error) {\n return reason;\n }\n\n if (typeof reason === 'string') {\n return new Error(reason);\n }\n\n if (reason !== null && reason !== undefined) {\n try {\n return new Error(JSON.stringify(reason));\n } catch {\n return new Error(String(reason));\n }\n }\n\n return new Error('Unhandled promise rejection with no reason');\n}\n\n/**\n * Set up global error handlers to capture uncaught exceptions and\n * unhandled promise rejections.\n *\n * @param client - The UncaughtClient instance to report errors to.\n * @returns A cleanup function that removes the event listeners.\n */\nexport function setupGlobalHandlers(client: UncaughtClient): () => void {\n // Guard for SSR environments\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const config = client.getConfig?.() ?? {};\n const ignoreErrors = (config as Record<string, unknown>)\n .ignoreErrors as Array<string | RegExp> | undefined;\n\n /**\n * Handle uncaught exceptions via window.onerror / 'error' event.\n */\n const handleError = (event: ErrorEvent): void => {\n try {\n const { error, message, filename } = event;\n\n // \"Script error.\" with no stack and no filename is cross-origin noise\n if (\n !error &&\n (!message || message === 'Script error.') &&\n !filename\n ) {\n return;\n }\n\n const errorMessage =\n error?.message ?? message ?? 'Unknown error';\n\n // Filter out noise errors\n if (isNoiseError(errorMessage)) {\n return;\n }\n\n // Filter out user-configured ignored errors\n if (isIgnoredByConfig(errorMessage, ignoreErrors)) {\n return;\n }\n\n // Build the error object\n const errorObj =\n error instanceof Error ? error : new Error(errorMessage);\n\n client.captureError(errorObj, {\n tags: { source: 'window.onerror' },\n extra: {\n filename: filename ?? undefined,\n lineno: event.lineno ?? undefined,\n colno: event.colno ?? undefined,\n },\n });\n\n // Do NOT call event.preventDefault() - let the browser still log the error\n } catch (e) {\n // Never crash the host app from our error handler\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Error in global error handler:', e);\n }\n }\n };\n\n /**\n * Handle unhandled promise rejections.\n */\n const handleRejection = (event: PromiseRejectionEvent): void => {\n try {\n const error = normalizeRejectionReason(event.reason);\n const errorMessage = error.message;\n\n // Filter out noise errors\n if (isNoiseError(errorMessage)) {\n return;\n }\n\n // Filter out user-configured ignored errors\n if (isIgnoredByConfig(errorMessage, ignoreErrors)) {\n return;\n }\n\n client.captureError(error, {\n tags: {\n source: 'unhandledrejection',\n unhandled: 'true',\n },\n });\n\n // Do NOT call event.preventDefault() - let the browser still log\n } catch (e) {\n // Never crash the host app from our error handler\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Error in unhandled rejection handler:',\n e\n );\n }\n }\n };\n\n window.addEventListener('error', handleError);\n window.addEventListener('unhandledrejection', handleRejection);\n\n // Return cleanup function\n return () => {\n window.removeEventListener('error', handleError);\n window.removeEventListener('unhandledrejection', handleRejection);\n };\n}\n","import type { UncaughtClient } from '@uncaughtdev/core';\n\n/**\n * Maximum length for breadcrumb messages to avoid excessively large payloads.\n */\nconst MAX_MESSAGE_LENGTH = 200;\n\n/**\n * Truncate a string to a maximum length, appending \"...\" if truncated.\n */\nfunction truncate(str: string, maxLen: number): string {\n if (str.length <= maxLen) return str;\n return str.slice(0, maxLen - 3) + '...';\n}\n\n/**\n * Extract a human-readable description of a clicked element.\n */\nfunction describeElement(element: HTMLElement): string {\n const tag = element.tagName?.toLowerCase() ?? 'unknown';\n const type =\n tag === 'input'\n ? (element as HTMLInputElement).type?.toLowerCase()\n : undefined;\n\n // Don't record anything from password inputs\n if (type === 'password') {\n return 'password input';\n }\n\n // Determine element role for description\n let role: string;\n if (tag === 'button' || element.getAttribute('role') === 'button') {\n role = 'button';\n } else if (tag === 'a') {\n role = 'link';\n } else if (tag === 'input') {\n role = `${type ?? 'text'} input`;\n } else if (tag === 'select') {\n role = 'dropdown';\n } else if (tag === 'textarea') {\n role = 'textarea';\n } else {\n role = tag;\n }\n\n // Get meaningful text content\n let text: string | null = null;\n\n // aria-label is highest priority for meaningful text\n const ariaLabel = element.getAttribute('aria-label');\n if (ariaLabel) {\n text = ariaLabel;\n }\n // For buttons and links, try innerText\n else if (tag === 'button' || tag === 'a') {\n const innerText = element.innerText?.trim();\n if (innerText) {\n text = innerText.split('\\n')[0]; // First line only\n }\n }\n // For inputs, use placeholder or name\n else if (tag === 'input' || tag === 'textarea') {\n const placeholder = (element as HTMLInputElement).placeholder;\n const name = element.getAttribute('name');\n text = placeholder || name || null;\n }\n\n // Build description\n const id = element.id ? `#${element.id}` : '';\n const textPart = text ? ` '${truncate(text, 50)}'` : '';\n\n return `Clicked${textPart} ${role}${id}`;\n}\n\n/**\n * Set up click tracking as breadcrumbs.\n * Uses capture phase to intercept clicks before they may be stopped.\n */\nfunction setupClickTracking(client: UncaughtClient): () => void {\n const handleClick = (event: MouseEvent): void => {\n try {\n const target = event.target as HTMLElement | null;\n if (!target || !target.tagName) return;\n\n // Don't record clicks on password inputs\n if (\n target.tagName.toLowerCase() === 'input' &&\n (target as HTMLInputElement).type?.toLowerCase() === 'password'\n ) {\n return;\n }\n\n const message = describeElement(target);\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'click',\n category: 'ui.click',\n message: truncate(message, MAX_MESSAGE_LENGTH),\n level: 'info',\n data: {\n tag: target.tagName.toLowerCase(),\n id: target.id || undefined,\n className:\n typeof target.className === 'string'\n ? truncate(target.className, 100)\n : undefined,\n },\n });\n } catch {\n // Silently ignore - never crash the host app\n }\n };\n\n document.addEventListener('click', handleClick, true); // capture phase\n return () => document.removeEventListener('click', handleClick, true);\n}\n\n/**\n * Set up navigation tracking as breadcrumbs.\n * Tracks popstate events and monkey-patches history.pushState / replaceState.\n */\nfunction setupNavigationTracking(client: UncaughtClient): () => void {\n let currentUrl = window.location.href;\n\n const recordNavigation = (to: string): void => {\n try {\n const from = currentUrl;\n currentUrl = to;\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'navigation',\n category: 'navigation',\n message: `Navigated to ${to}`,\n level: 'info',\n data: {\n from,\n to,\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n // popstate fires on back/forward\n const handlePopState = (): void => {\n recordNavigation(window.location.href);\n };\n\n window.addEventListener('popstate', handlePopState);\n\n // Monkey-patch pushState and replaceState\n const originalPushState = history.pushState.bind(history);\n const originalReplaceState = history.replaceState.bind(history);\n\n history.pushState = function (\n data: unknown,\n unused: string,\n url?: string | URL | null\n ): void {\n originalPushState(data, unused, url);\n if (url) {\n try {\n const resolvedUrl = new URL(\n String(url),\n window.location.href\n ).href;\n recordNavigation(resolvedUrl);\n } catch {\n recordNavigation(String(url));\n }\n }\n };\n\n history.replaceState = function (\n data: unknown,\n unused: string,\n url?: string | URL | null\n ): void {\n originalReplaceState(data, unused, url);\n if (url) {\n try {\n const resolvedUrl = new URL(\n String(url),\n window.location.href\n ).href;\n recordNavigation(resolvedUrl);\n } catch {\n recordNavigation(String(url));\n }\n }\n };\n\n return () => {\n window.removeEventListener('popstate', handlePopState);\n history.pushState = originalPushState;\n history.replaceState = originalReplaceState;\n };\n}\n\n/**\n * Set up fetch tracking as breadcrumbs.\n * Monkey-patches window.fetch to record API calls with method, URL, status, and duration.\n * Does NOT record request/response bodies. Skips requests to the Uncaught API.\n */\nfunction setupFetchTracking(client: UncaughtClient): () => void {\n const originalFetch = window.fetch.bind(window);\n\n // Get the Uncaught API endpoint to exclude self-reporting requests\n const config = client.getConfig?.() ?? {};\n const apiEndpoint =\n (config as Record<string, unknown>).endpoint ??\n (config as Record<string, unknown>).dsn ??\n '';\n const uncaughtEndpoints: string[] = [];\n\n if (typeof apiEndpoint === 'string' && apiEndpoint) {\n try {\n const url = new URL(apiEndpoint);\n uncaughtEndpoints.push(url.hostname);\n } catch {\n uncaughtEndpoints.push(apiEndpoint);\n }\n }\n\n // Also exclude common Uncaught API patterns\n uncaughtEndpoints.push('uncaught.dev');\n uncaughtEndpoints.push('api.uncaught');\n\n const isUncaughtRequest = (url: string): boolean => {\n return uncaughtEndpoints.some(\n (endpoint) => endpoint && url.includes(endpoint)\n );\n };\n\n window.fetch = async function (\n input: RequestInfo | URL,\n init?: RequestInit\n ): Promise<Response> {\n const url =\n input instanceof Request\n ? input.url\n : input instanceof URL\n ? input.href\n : String(input);\n\n const method = (\n init?.method ??\n (input instanceof Request ? input.method : 'GET')\n ).toUpperCase();\n\n // Skip Uncaught's own requests to prevent infinite loops\n if (isUncaughtRequest(url)) {\n return originalFetch(input, init);\n }\n\n const startTime = Date.now();\n\n try {\n const response = await originalFetch(input, init);\n const duration = Date.now() - startTime;\n const isError = response.status >= 400;\n\n try {\n // Truncate URL for the breadcrumb to avoid huge payloads\n const displayUrl = truncate(url, 150);\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'api_call',\n category: 'fetch',\n message: `${method} ${displayUrl} [${response.status}]`,\n level: isError ? 'error' : 'info',\n data: {\n method,\n url: displayUrl,\n status: response.status,\n statusText: response.statusText,\n duration,\n },\n });\n } catch {\n // Silently ignore breadcrumb failures\n }\n\n return response;\n } catch (error) {\n const duration = Date.now() - startTime;\n\n try {\n const displayUrl = truncate(url, 150);\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'api_call',\n category: 'fetch',\n message: `${method} ${displayUrl} [Network Error]`,\n level: 'error',\n data: {\n method,\n url: displayUrl,\n status: 0,\n error:\n error instanceof Error\n ? error.message\n : 'Network error',\n duration,\n },\n });\n } catch {\n // Silently ignore breadcrumb failures\n }\n\n throw error; // Re-throw so the app's error handling still works\n }\n };\n\n return () => {\n window.fetch = originalFetch;\n };\n}\n\n/**\n * Set up automatic DOM breadcrumb tracking including clicks,\n * navigation changes, and fetch API calls.\n *\n * @param client - The UncaughtClient instance to add breadcrumbs to.\n * @returns A cleanup function that removes all listeners and restores patched functions.\n */\nexport function setupDomBreadcrumbs(client: UncaughtClient): () => void {\n // Guard for SSR environments\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const cleanups: Array<() => void> = [];\n\n try {\n cleanups.push(setupClickTracking(client));\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to set up click tracking:', e);\n }\n }\n\n try {\n cleanups.push(setupNavigationTracking(client));\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up navigation tracking:',\n e\n );\n }\n }\n\n try {\n cleanups.push(setupFetchTracking(client));\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to set up fetch tracking:', e);\n }\n }\n\n return () => {\n cleanups.forEach((cleanup) => {\n try {\n cleanup();\n } catch {\n // Silently ignore cleanup failures\n }\n });\n };\n}\n","import type { UncaughtClient, UncaughtConfig } from '@uncaughtdev/core';\n\n/**\n * Augmented Window interface to access Next.js internals.\n * These are undocumented but stable properties Next.js sets on the window.\n */\ninterface NextWindow extends Window {\n /** Present in Pages Router - contains build-time page data */\n __NEXT_DATA__?: {\n page?: string;\n query?: Record<string, unknown>;\n buildId?: string;\n props?: Record<string, unknown>;\n };\n /** Present in App Router - contains flight response data */\n __next_f?: unknown[];\n /** Next.js router instance (Pages Router) */\n next?: {\n router?: {\n events?: {\n on: (event: string, handler: (...args: unknown[]) => void) => void;\n off: (event: string, handler: (...args: unknown[]) => void) => void;\n };\n };\n };\n}\n\n/**\n * Result of Next.js environment detection.\n */\nexport interface NextJsDetection {\n /** Whether the app appears to be running in a Next.js context */\n isNextJs: boolean;\n /** Whether the App Router is detected */\n isAppRouter: boolean;\n /** Whether the Pages Router is detected */\n isPagesRouter: boolean;\n}\n\n/**\n * Detect if the current environment is a Next.js application,\n * and which router (App Router vs Pages Router) is being used.\n *\n * This detection is best-effort and relies on undocumented\n * but stable Next.js window properties.\n *\n * @returns Detection result with router type information.\n */\nexport function detectNextJs(): NextJsDetection {\n if (typeof window === 'undefined') {\n return {\n isNextJs: false,\n isAppRouter: false,\n isPagesRouter: false,\n };\n }\n\n const win = window as NextWindow;\n\n const hasPagesData = win.__NEXT_DATA__ !== undefined;\n const hasAppRouterData = win.__next_f !== undefined;\n\n // Check for Next.js meta tag as an additional signal\n let hasNextMeta = false;\n try {\n const nextMeta = document.querySelector('meta[name=\"next-size-adjust\"]');\n hasNextMeta = nextMeta !== null;\n } catch {\n // Ignore DOM query errors\n }\n\n const isPagesRouter = hasPagesData && !hasAppRouterData;\n const isAppRouter = hasAppRouterData;\n const isNextJs = hasPagesData || hasAppRouterData || hasNextMeta;\n\n return {\n isNextJs,\n isAppRouter,\n isPagesRouter,\n };\n}\n\n/**\n * Set up navigation tracking specifically for Next.js routing.\n *\n * For the Pages Router, hooks into Next.js router events (routeChangeStart,\n * routeChangeComplete, routeChangeError).\n *\n * For the App Router, navigation is tracked via the general DOM breadcrumbs\n * (history.pushState monkey-patch), so this function primarily adds\n * Next.js-specific context.\n *\n * @param client - The UncaughtClient instance.\n * @returns A cleanup function that removes the event listeners.\n */\nexport function setupNextJsNavigation(client: UncaughtClient): () => void {\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const detection = detectNextJs();\n const cleanups: Array<() => void> = [];\n\n // Add Next.js context to the client\n try {\n client.addBreadcrumb({\n\n type: 'navigation',\n category: 'nextjs',\n message: `Next.js detected: ${\n detection.isAppRouter\n ? 'App Router'\n : detection.isPagesRouter\n ? 'Pages Router'\n : 'Unknown Router'\n }`,\n level: 'info',\n data: {\n isAppRouter: detection.isAppRouter,\n isPagesRouter: detection.isPagesRouter,\n },\n });\n } catch {\n // Silently ignore\n }\n\n // Pages Router: hook into router events\n if (detection.isPagesRouter) {\n try {\n const win = window as NextWindow;\n const routerEvents = win.next?.router?.events;\n\n if (routerEvents) {\n let navigationStartTime = 0;\n\n const handleRouteChangeStart = (url: unknown): void => {\n try {\n navigationStartTime = Date.now();\n client.addBreadcrumb({\n \n type: 'navigation',\n category: 'nextjs.route',\n message: `Route change started: ${String(url)}`,\n level: 'info',\n data: {\n to: String(url),\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n const handleRouteChangeComplete = (url: unknown): void => {\n try {\n const duration =\n navigationStartTime > 0\n ? Date.now() - navigationStartTime\n : undefined;\n\n client.addBreadcrumb({\n \n type: 'navigation',\n category: 'nextjs.route',\n message: `Route change completed: ${String(url)}`,\n level: 'info',\n data: {\n to: String(url),\n duration,\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n const handleRouteChangeError = (\n err: unknown,\n url: unknown\n ): void => {\n try {\n const duration =\n navigationStartTime > 0\n ? Date.now() - navigationStartTime\n : undefined;\n\n client.addBreadcrumb({\n \n type: 'navigation',\n category: 'nextjs.route',\n message: `Route change error: ${String(url)}`,\n level: 'error',\n data: {\n to: String(url),\n error:\n err instanceof Error\n ? err.message\n : String(err),\n duration,\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n routerEvents.on('routeChangeStart', handleRouteChangeStart);\n routerEvents.on(\n 'routeChangeComplete',\n handleRouteChangeComplete\n );\n routerEvents.on('routeChangeError', handleRouteChangeError);\n\n cleanups.push(() => {\n try {\n routerEvents.off(\n 'routeChangeStart',\n handleRouteChangeStart\n );\n routerEvents.off(\n 'routeChangeComplete',\n handleRouteChangeComplete\n );\n routerEvents.off(\n 'routeChangeError',\n handleRouteChangeError\n );\n } catch {\n // Silently ignore\n }\n });\n }\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up Next.js Pages Router navigation:',\n e\n );\n }\n }\n }\n\n return () => {\n cleanups.forEach((cleanup) => {\n try {\n cleanup();\n } catch {\n // Silently ignore cleanup failures\n }\n });\n };\n}\n\n/**\n * Higher-order function for wrapping Next.js App Router layouts.\n *\n * Returns the configuration object needed to initialize UncaughtProvider\n * with Next.js-specific defaults applied.\n *\n * Usage in layout.tsx:\n * ```tsx\n * import { UncaughtProvider } from '@uncaughtdev/react';\n * import { withUncaught } from '@uncaughtdev/react';\n *\n * const uncaughtConfig = withUncaught({\n * dsn: 'your-dsn-here',\n * environment: 'production',\n * });\n *\n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * <UncaughtProvider {...uncaughtConfig}>\n * {children}\n * </UncaughtProvider>\n * </body>\n * </html>\n * );\n * }\n * ```\n *\n * @param config - Base UncaughtConfig to extend with Next.js defaults.\n * @returns Configuration object with Next.js-specific settings applied.\n */\nexport function withUncaught(\n config: UncaughtConfig\n): UncaughtConfig & { __nextjs: boolean } {\n return {\n ...config,\n __nextjs: true,\n };\n}\n","'use client';\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport { initUncaught } from '@uncaughtdev/core';\nimport type { UncaughtClient } from '@uncaughtdev/core';\nimport { UncaughtContext } from './context';\nimport { UncaughtErrorBoundary } from './error-boundary';\nimport { setupGlobalHandlers } from './global-handlers';\nimport { setupDomBreadcrumbs } from './dom-breadcrumbs';\nimport { setupNextJsNavigation, detectNextJs } from './next-integration';\nimport type { UncaughtProviderProps } from './types';\n\n/**\n * UncaughtProvider initializes the Uncaught error monitoring client and\n * provides it to all descendant components via React context.\n *\n * It automatically:\n * - Initializes the UncaughtClient with the provided configuration\n * - Sets up global error handlers (window.onerror, unhandledrejection)\n * - Sets up DOM breadcrumb tracking (clicks, navigation, fetch)\n * - Detects and integrates with Next.js routing if present\n * - Wraps children in an error boundary\n * - Cleans up all listeners on unmount\n *\n * Usage:\n * ```tsx\n * <UncaughtProvider dsn=\"your-dsn\" environment=\"production\">\n * <App />\n * </UncaughtProvider>\n * ```\n *\n * @param props - Configuration props extending UncaughtConfig plus children, fallback, and showDialog.\n */\nexport function UncaughtProvider({\n children,\n fallback,\n showDialog,\n ...config\n}: UncaughtProviderProps): React.ReactElement {\n const [client, setClient] = useState<UncaughtClient | null>(null);\n const cleanupRef = useRef<Array<() => void>>([]);\n const initializedRef = useRef(false);\n\n useEffect(() => {\n // Prevent double-initialization in React StrictMode\n if (initializedRef.current) {\n return;\n }\n initializedRef.current = true;\n\n let mounted = true;\n const cleanups: Array<() => void> = [];\n\n try {\n // Strip React-specific props before passing to core\n const { __nextjs, ...coreConfig } = config as Record<string, unknown> & {\n __nextjs?: boolean;\n };\n\n // Initialize the core client\n const uncaughtClient = initUncaught(\n coreConfig as Parameters<typeof initUncaught>[0]\n );\n\n if (!uncaughtClient) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '[Uncaught] initUncaught returned null/undefined. Error monitoring is disabled.'\n );\n }\n return;\n }\n\n // Set up global error handlers\n try {\n const cleanupGlobal = setupGlobalHandlers(uncaughtClient);\n cleanups.push(cleanupGlobal);\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up global handlers:',\n e\n );\n }\n }\n\n // Set up DOM breadcrumbs\n try {\n const cleanupDom = setupDomBreadcrumbs(uncaughtClient);\n cleanups.push(cleanupDom);\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up DOM breadcrumbs:',\n e\n );\n }\n }\n\n // Set up Next.js integration if detected or explicitly configured\n if (typeof window !== 'undefined') {\n try {\n const nextDetection = detectNextJs();\n if (nextDetection.isNextJs || __nextjs) {\n const cleanupNext = setupNextJsNavigation(uncaughtClient);\n cleanups.push(cleanupNext);\n }\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up Next.js integration:',\n e\n );\n }\n }\n }\n\n // Store cleanups for unmount\n cleanupRef.current = cleanups;\n\n // Only update state if still mounted\n if (mounted) {\n setClient(uncaughtClient);\n }\n } catch (e) {\n // Never crash the host app during initialization\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to initialize:', e);\n }\n }\n\n return () => {\n mounted = false;\n // Run all cleanup functions\n cleanupRef.current.forEach((cleanup) => {\n try {\n cleanup();\n } catch {\n // Silently ignore cleanup failures\n }\n });\n cleanupRef.current = [];\n initializedRef.current = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // Initialize once on mount - config changes require remounting\n\n const contextValue = React.useMemo(() => ({ client }), [client]);\n\n return (\n <UncaughtContext.Provider value={contextValue}>\n <UncaughtErrorBoundary fallback={fallback} showDialog={showDialog}>\n {children}\n </UncaughtErrorBoundary>\n </UncaughtContext.Provider>\n );\n}\n","'use client';\n\nimport { useContext, useCallback } from 'react';\nimport type { UncaughtClient, Breadcrumb } from '@uncaughtdev/core';\nimport { UncaughtContext } from './context';\n\n/**\n * Returns the UncaughtClient instance from context.\n * Must be called within an UncaughtProvider.\n *\n * @throws {Error} If called outside of an UncaughtProvider.\n * @returns The UncaughtClient instance.\n */\nexport function useUncaught(): UncaughtClient {\n const { client } = useContext(UncaughtContext);\n\n if (!client) {\n throw new Error(\n 'useUncaught must be used within an <UncaughtProvider>. ' +\n 'Wrap your application in <UncaughtProvider> to use this hook.'\n );\n }\n\n return client;\n}\n\n/**\n * Returns a function that reports an error to Uncaught.\n * Safe to call even if the client is not yet initialized (will silently no-op).\n *\n * @returns A function `(error: Error, context?: Record<string, unknown>) => void`\n */\nexport function useReportError(): (\n error: Error,\n context?: Record<string, unknown>\n) => void {\n const { client } = useContext(UncaughtContext);\n\n return useCallback(\n (error: Error, context?: Record<string, unknown>) => {\n try {\n if (!client) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '[Uncaught] useReportError called but no UncaughtClient is available. ' +\n 'Make sure <UncaughtProvider> is mounted.'\n );\n }\n return;\n }\n\n client.captureError(error);\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to report error:', e);\n }\n }\n },\n [client]\n );\n}\n\n/**\n * Returns a function that adds a breadcrumb to the current Uncaught session.\n * Safe to call even if the client is not yet initialized (will silently no-op).\n *\n * @returns A function `(breadcrumb: Partial<Breadcrumb>) => void`\n */\nexport function useBreadcrumb(): (breadcrumb: Partial<Breadcrumb>) => void {\n const { client } = useContext(UncaughtContext);\n\n return useCallback(\n (breadcrumb: Partial<Breadcrumb>) => {\n try {\n if (!client) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '[Uncaught] useBreadcrumb called but no UncaughtClient is available. ' +\n 'Make sure <UncaughtProvider> is mounted.'\n );\n }\n return;\n }\n\n client.addBreadcrumb({\n type: breadcrumb.type ?? 'custom',\n category: breadcrumb.category ?? 'custom',\n message: breadcrumb.message ?? '',\n level: breadcrumb.level ?? 'info',\n data: breadcrumb.data,\n });\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to add breadcrumb:', e);\n }\n }\n },\n [client]\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/context.ts","../src/error-boundary.tsx","../src/global-handlers.ts","../src/dom-breadcrumbs.ts","../src/next-integration.ts","../src/web-vitals.ts","../src/provider.tsx","../src/hooks.ts"],"names":["UncaughtContext","createContext","UncaughtErrorBoundary","Component","props","error","errorInfo","client","onError","beforeCapture","componentStack","e","handlePopState","hasError","children","fallback","showDialog","feedback","feedbackSent","jsx","jsxs","NOISE_PATTERNS","isNoiseError","message","pattern","isIgnoredByConfig","ignoreErrors","normalizeRejectionReason","reason","setupGlobalHandlers","handleError","event","filename","errorMessage","errorObj","handleRejection","truncate","str","maxLen","describeElement","element","tag","type","role","text","ariaLabel","innerText","placeholder","name","id","setupClickTracking","handleClick","target","setupNavigationTracking","currentUrl","recordNavigation","to","from","originalPushState","originalReplaceState","data","unused","url","resolvedUrl","setupFetchTracking","originalFetch","config","apiEndpoint","uncaughtEndpoints","isUncaughtRequest","endpoint","input","init","method","startTime","response","duration","isError","displayUrl","setupXhrTracking","originalOpen","originalSend","ep","rest","body","xhr","handleEnd","status","setupDomBreadcrumbs","cleanups","cleanup","detectNextJs","win","hasPagesData","hasAppRouterData","hasNextMeta","setupNextJsNavigation","detection","routerEvents","navigationStartTime","handleRouteChangeStart","handleRouteChangeComplete","handleRouteChangeError","err","withUncaught","setupWebVitals","observers","recordVital","value","unit","displayValue","lcpObserver","list","entries","last","fidObserver","first","clsValue","clsObserver","entry","layoutShift","reportCLS","fcpObserver","fcp","navEntries","nav","o","UncaughtProvider","setClient","useState","cleanupRef","useRef","initializedRef","useEffect","mounted","__nextjs","coreConfig","uncaughtClient","initUncaught","cleanupGlobal","cleanupDom","cleanupVitals","cleanupNext","contextValue","React","useUncaught","useContext","useReportError","useCallback","context","useErrorHandler","fn","args","result","withErrorCapture","useBreadcrumb","breadcrumb"],"mappings":"2OASO,IAAMA,EAAkBC,aAAAA,CAAoC,CACjE,MAAA,CAAQ,IACV,CAAC,EAEDD,EAAgB,WAAA,CAAc,iBAAA,CCOvB,IAAME,EAAN,cAAoCC,SAGzC,CAMA,WAAA,CAAYC,CAAAA,CAAmC,CAC7C,KAAA,CAAMA,CAAK,CAAA,CAHb,IAAA,CAAQ,sBAAA,CAA8C,IAAA,CAmFtD,gBAAa,IAAY,CACvB,KAAK,QAAA,CAAS,CACZ,SAAU,KAAA,CACV,KAAA,CAAO,IACT,CAAC,EACH,CAAA,CApFE,KAAK,KAAA,CAAQ,CACX,SAAU,KAAA,CACV,KAAA,CAAO,KACP,QAAA,CAAU,EAAA,CACV,YAAA,CAAc,KAAA,CACd,WAAA,CAAa,IACf,EACF,CAEA,OAAO,yBAAyBC,CAAAA,CAAqH,CACnJ,OAAO,CACL,QAAA,CAAU,IAAA,CACV,KAAA,CAAAA,CAAAA,CACA,QAAA,CAAU,GACV,YAAA,CAAc,KAAA,CACd,WAAA,CAAa,IACf,CACF,CAEA,kBAAkBA,CAAAA,CAAcC,CAAAA,CAAkC,CAChE,GAAI,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AUA,CAAAA,CAAW,QAAA,EAAY,QAAA,CACjC,OAAA,CAASA,EAAW,OAAA,EAAW,EAAA,CAC/B,KAAA,CAAOA,CAAAA,CAAW,KAAA,EAAS,MAAA,CAC3B,IAAA,CAAMA,CAAAA,CAAW,IACnB,CAAC,EACH,CAAA,MAASjJ,CAAAA,CAAG,CAEN,OAAA,CAAQ,GAAA,CAAI,WAAa,aAAA,EAC3B,OAAA,CAAQ,KAAA,CAAM,sCAAA,CAAwCA,CAAC,EAE3D,CACF,CAAA,CACA,CAACJ,CAAM,CACT,CACF","file":"index.mjs","sourcesContent":["'use client';\n\nimport { createContext } from 'react';\nimport type { UncaughtContextValue } from './types';\n\n/**\n * React context that provides the UncaughtClient instance to descendant components.\n * The context value is null when no UncaughtProvider is present in the tree.\n */\nexport const UncaughtContext = createContext<UncaughtContextValue>({\n client: null,\n});\n\nUncaughtContext.displayName = 'UncaughtContext';\n","'use client';\n\nimport React, { Component } from 'react';\nimport type { UncaughtClient } from '@uncaughtdev/core';\nimport { UncaughtContext } from './context';\nimport type { UncaughtErrorBoundaryProps, ErrorBoundaryState } from './types';\n\n/**\n * React Error Boundary that captures errors and reports them to Uncaught.\n *\n * Must be a class component as React does not support error boundaries\n * via function components / hooks.\n *\n * Usage:\n * ```tsx\n * <UncaughtErrorBoundary fallback={<div>Something went wrong</div>}>\n * <MyApp />\n * </UncaughtErrorBoundary>\n * ```\n */\nexport class UncaughtErrorBoundary extends Component<\n UncaughtErrorBoundaryProps,\n ErrorBoundaryState & { feedback: string; feedbackSent: boolean; lastEventId: string | null }\n> {\n static contextType = UncaughtContext;\n declare context: React.ContextType<typeof UncaughtContext>;\n\n private removePopstateListener: (() => void) | null = null;\n\n constructor(props: UncaughtErrorBoundaryProps) {\n super(props);\n this.state = {\n hasError: false,\n error: null,\n feedback: '',\n feedbackSent: false,\n lastEventId: null,\n };\n }\n\n static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState & { feedback: string; feedbackSent: boolean; lastEventId: string | null }> {\n return {\n hasError: true,\n error,\n feedback: '',\n feedbackSent: false,\n lastEventId: null,\n };\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {\n try {\n const client: UncaughtClient | null = this.context?.client ?? null;\n const { onError, beforeCapture } = this.props;\n\n // Extract component stack for richer error context\n const componentStack = errorInfo.componentStack ?? undefined;\n\n if (client) {\n client.captureError(error, {\n componentStack,\n });\n\n // Add a breadcrumb noting the error boundary source\n client.addBreadcrumb({\n type: 'custom',\n category: 'react.error_boundary',\n message: `Error boundary caught: ${error.message}`,\n level: 'error',\n });\n }\n\n // Invoke the user's onError callback if provided\n if (onError) {\n onError(error, errorInfo);\n }\n } catch (e) {\n // Never crash the host app from error reporting itself\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Error in componentDidCatch handler:', e);\n }\n }\n }\n\n componentDidMount(): void {\n // Auto-reset the error boundary when the user navigates via browser back/forward\n if (typeof window !== 'undefined') {\n const handlePopState = (): void => {\n if (this.state.hasError) {\n this.resetError();\n }\n };\n\n window.addEventListener('popstate', handlePopState);\n this.removePopstateListener = () => {\n window.removeEventListener('popstate', handlePopState);\n };\n }\n }\n\n componentWillUnmount(): void {\n if (this.removePopstateListener) {\n this.removePopstateListener();\n this.removePopstateListener = null;\n }\n }\n\n /**\n * Reset the error boundary state, allowing children to re-render.\n */\n resetError = (): void => {\n this.setState({\n hasError: false,\n error: null,\n });\n };\n\n render(): React.ReactNode {\n const { hasError, error } = this.state;\n const { children, fallback, showDialog } = this.props;\n\n if (!hasError || !error) {\n return children;\n }\n\n // Custom fallback: render function\n if (typeof fallback === 'function') {\n try {\n return fallback(error);\n } catch (e) {\n // If the fallback itself throws, fall through to default\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Fallback render function threw:', e);\n }\n }\n }\n\n // Custom fallback: ReactNode\n if (fallback !== undefined && typeof fallback !== 'function') {\n return fallback;\n }\n\n // Default dialog UI with feedback form\n if (showDialog) {\n const { feedback, feedbackSent } = this.state;\n const client: UncaughtClient | null = this.context?.client ?? null;\n\n return (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: '100vh',\n padding: '20px',\n fontFamily:\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif',\n backgroundColor: '#f8f9fa',\n }}\n >\n <div\n style={{\n maxWidth: '480px',\n width: '100%',\n backgroundColor: '#ffffff',\n borderRadius: '12px',\n boxShadow:\n '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)',\n padding: '32px',\n textAlign: 'center',\n }}\n >\n <div\n style={{\n width: '48px',\n height: '48px',\n borderRadius: '50%',\n backgroundColor: '#fee2e2',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n margin: '0 auto 16px',\n fontSize: '24px',\n color: '#dc2626',\n }}\n >\n !\n </div>\n <h2\n style={{\n margin: '0 0 8px',\n fontSize: '20px',\n fontWeight: 600,\n color: '#111827',\n }}\n >\n Something went wrong\n </h2>\n <p\n style={{\n margin: '0 0 16px',\n fontSize: '14px',\n color: '#6b7280',\n lineHeight: 1.5,\n }}\n >\n An unexpected error occurred. Our team has been notified and is\n working on a fix.\n </p>\n {process.env.NODE_ENV === 'development' && (\n <pre\n style={{\n textAlign: 'left',\n backgroundColor: '#f3f4f6',\n padding: '12px',\n borderRadius: '8px',\n fontSize: '12px',\n color: '#dc2626',\n overflow: 'auto',\n maxHeight: '120px',\n marginBottom: '16px',\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n }}\n >\n {error.message}\n {error.stack && `\\n\\n${error.stack}`}\n </pre>\n )}\n {/* User feedback form */}\n {!feedbackSent ? (\n <div style={{ marginBottom: '16px', textAlign: 'left' }}>\n <label\n htmlFor=\"uncaught-feedback\"\n style={{\n display: 'block',\n fontSize: '13px',\n fontWeight: 500,\n color: '#374151',\n marginBottom: '6px',\n }}\n >\n What were you doing when this happened?\n </label>\n <textarea\n id=\"uncaught-feedback\"\n value={feedback}\n onChange={(e) => this.setState({ feedback: e.target.value })}\n placeholder=\"Describe what you were doing...\"\n style={{\n width: '100%',\n minHeight: '80px',\n padding: '8px 12px',\n border: '1px solid #d1d5db',\n borderRadius: '8px',\n fontSize: '14px',\n fontFamily: 'inherit',\n resize: 'vertical',\n boxSizing: 'border-box',\n }}\n />\n {feedback.trim() && (\n <button\n onClick={() => {\n try {\n if (client && feedback.trim()) {\n client.submitFeedback?.('', feedback.trim());\n this.setState({ feedbackSent: true });\n }\n } catch {\n // Never crash\n }\n }}\n style={{\n marginTop: '8px',\n backgroundColor: '#059669',\n color: '#ffffff',\n border: 'none',\n borderRadius: '6px',\n padding: '8px 16px',\n fontSize: '13px',\n fontWeight: 500,\n cursor: 'pointer',\n }}\n >\n Send Feedback\n </button>\n )}\n </div>\n ) : (\n <p\n style={{\n fontSize: '13px',\n color: '#059669',\n marginBottom: '16px',\n }}\n >\n Thank you for your feedback!\n </p>\n )}\n <button\n onClick={() => {\n try {\n if (typeof window !== 'undefined') {\n window.location.reload();\n }\n } catch {\n // Silently ignore reload failures\n }\n }}\n style={{\n backgroundColor: '#3b82f6',\n color: '#ffffff',\n border: 'none',\n borderRadius: '8px',\n padding: '10px 24px',\n fontSize: '14px',\n fontWeight: 500,\n cursor: 'pointer',\n transition: 'background-color 0.15s ease',\n }}\n onMouseOver={(e) => {\n (e.target as HTMLButtonElement).style.backgroundColor =\n '#2563eb';\n }}\n onMouseOut={(e) => {\n (e.target as HTMLButtonElement).style.backgroundColor =\n '#3b82f6';\n }}\n >\n Reload Page\n </button>\n </div>\n </div>\n );\n }\n\n // No fallback and no dialog: render nothing (transparent failure)\n return null;\n }\n}\n","import type { UncaughtClient } from '@uncaughtdev/core';\n\n/**\n * Patterns for errors that are typically noise and should be ignored.\n * These are errors produced by the browser, extensions, or third-party scripts\n * that provide no actionable information.\n */\nconst NOISE_PATTERNS: RegExp[] = [\n // ResizeObserver loop errors are benign and happen in many apps\n /ResizeObserver loop/i,\n // \"Script error.\" with no useful info (cross-origin scripts without CORS headers)\n /^Script error\\.?$/i,\n // Browser extension errors\n /chrome-extension:\\/\\//i,\n /moz-extension:\\/\\//i,\n /safari-extension:\\/\\//i,\n /safari-web-extension:\\/\\//i,\n // Edge extension errors\n /extension:\\/\\//i,\n];\n\n/**\n * Check if an error message matches any of the known noise patterns.\n */\nfunction isNoiseError(message: string): boolean {\n return NOISE_PATTERNS.some((pattern) => pattern.test(message));\n}\n\n/**\n * Check if an error matches any user-defined ignoreErrors patterns.\n */\nfunction isIgnoredByConfig(\n message: string,\n ignoreErrors?: Array<string | RegExp>\n): boolean {\n if (!ignoreErrors || ignoreErrors.length === 0) {\n return false;\n }\n\n return ignoreErrors.some((pattern) => {\n if (typeof pattern === 'string') {\n return message.includes(pattern);\n }\n return pattern.test(message);\n });\n}\n\n/**\n * Normalize a promise rejection reason into a proper Error object.\n */\nfunction normalizeRejectionReason(reason: unknown): Error {\n if (reason instanceof Error) {\n return reason;\n }\n\n if (typeof reason === 'string') {\n return new Error(reason);\n }\n\n if (reason !== null && reason !== undefined) {\n try {\n return new Error(JSON.stringify(reason));\n } catch {\n return new Error(String(reason));\n }\n }\n\n return new Error('Unhandled promise rejection with no reason');\n}\n\n/**\n * Set up global error handlers to capture uncaught exceptions and\n * unhandled promise rejections.\n *\n * @param client - The UncaughtClient instance to report errors to.\n * @returns A cleanup function that removes the event listeners.\n */\nexport function setupGlobalHandlers(client: UncaughtClient): () => void {\n // Guard for SSR environments\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const config = client.getConfig?.() ?? {};\n const ignoreErrors = (config as Record<string, unknown>)\n .ignoreErrors as Array<string | RegExp> | undefined;\n\n /**\n * Handle uncaught exceptions via window.onerror / 'error' event.\n */\n const handleError = (event: ErrorEvent): void => {\n try {\n const { error, message, filename } = event;\n\n // \"Script error.\" with no stack and no filename is cross-origin noise\n if (\n !error &&\n (!message || message === 'Script error.') &&\n !filename\n ) {\n return;\n }\n\n const errorMessage =\n error?.message ?? message ?? 'Unknown error';\n\n // Filter out noise errors\n if (isNoiseError(errorMessage)) {\n return;\n }\n\n // Filter out user-configured ignored errors\n if (isIgnoredByConfig(errorMessage, ignoreErrors)) {\n return;\n }\n\n // Build the error object\n const errorObj =\n error instanceof Error ? error : new Error(errorMessage);\n\n client.captureError(errorObj, {\n tags: { source: 'window.onerror' },\n extra: {\n filename: filename ?? undefined,\n lineno: event.lineno ?? undefined,\n colno: event.colno ?? undefined,\n },\n });\n\n // Do NOT call event.preventDefault() - let the browser still log the error\n } catch (e) {\n // Never crash the host app from our error handler\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Error in global error handler:', e);\n }\n }\n };\n\n /**\n * Handle unhandled promise rejections.\n */\n const handleRejection = (event: PromiseRejectionEvent): void => {\n try {\n const error = normalizeRejectionReason(event.reason);\n const errorMessage = error.message;\n\n // Filter out noise errors\n if (isNoiseError(errorMessage)) {\n return;\n }\n\n // Filter out user-configured ignored errors\n if (isIgnoredByConfig(errorMessage, ignoreErrors)) {\n return;\n }\n\n client.captureError(error, {\n tags: {\n source: 'unhandledrejection',\n unhandled: 'true',\n },\n });\n\n // Do NOT call event.preventDefault() - let the browser still log\n } catch (e) {\n // Never crash the host app from our error handler\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Error in unhandled rejection handler:',\n e\n );\n }\n }\n };\n\n window.addEventListener('error', handleError);\n window.addEventListener('unhandledrejection', handleRejection);\n\n // Return cleanup function\n return () => {\n window.removeEventListener('error', handleError);\n window.removeEventListener('unhandledrejection', handleRejection);\n };\n}\n","import type { UncaughtClient } from '@uncaughtdev/core';\n\n/**\n * Maximum length for breadcrumb messages to avoid excessively large payloads.\n */\nconst MAX_MESSAGE_LENGTH = 200;\n\n/**\n * Truncate a string to a maximum length, appending \"...\" if truncated.\n */\nfunction truncate(str: string, maxLen: number): string {\n if (str.length <= maxLen) return str;\n return str.slice(0, maxLen - 3) + '...';\n}\n\n/**\n * Extract a human-readable description of a clicked element.\n */\nfunction describeElement(element: HTMLElement): string {\n const tag = element.tagName?.toLowerCase() ?? 'unknown';\n const type =\n tag === 'input'\n ? (element as HTMLInputElement).type?.toLowerCase()\n : undefined;\n\n // Don't record anything from password inputs\n if (type === 'password') {\n return 'password input';\n }\n\n // Determine element role for description\n let role: string;\n if (tag === 'button' || element.getAttribute('role') === 'button') {\n role = 'button';\n } else if (tag === 'a') {\n role = 'link';\n } else if (tag === 'input') {\n role = `${type ?? 'text'} input`;\n } else if (tag === 'select') {\n role = 'dropdown';\n } else if (tag === 'textarea') {\n role = 'textarea';\n } else {\n role = tag;\n }\n\n // Get meaningful text content\n let text: string | null = null;\n\n // aria-label is highest priority for meaningful text\n const ariaLabel = element.getAttribute('aria-label');\n if (ariaLabel) {\n text = ariaLabel;\n }\n // For buttons and links, try innerText\n else if (tag === 'button' || tag === 'a') {\n const innerText = element.innerText?.trim();\n if (innerText) {\n text = innerText.split('\\n')[0]; // First line only\n }\n }\n // For inputs, use placeholder or name\n else if (tag === 'input' || tag === 'textarea') {\n const placeholder = (element as HTMLInputElement).placeholder;\n const name = element.getAttribute('name');\n text = placeholder || name || null;\n }\n\n // Build description\n const id = element.id ? `#${element.id}` : '';\n const textPart = text ? ` '${truncate(text, 50)}'` : '';\n\n return `Clicked${textPart} ${role}${id}`;\n}\n\n/**\n * Set up click tracking as breadcrumbs.\n * Uses capture phase to intercept clicks before they may be stopped.\n */\nfunction setupClickTracking(client: UncaughtClient): () => void {\n const handleClick = (event: MouseEvent): void => {\n try {\n const target = event.target as HTMLElement | null;\n if (!target || !target.tagName) return;\n\n // Don't record clicks on password inputs\n if (\n target.tagName.toLowerCase() === 'input' &&\n (target as HTMLInputElement).type?.toLowerCase() === 'password'\n ) {\n return;\n }\n\n const message = describeElement(target);\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'click',\n category: 'ui.click',\n message: truncate(message, MAX_MESSAGE_LENGTH),\n level: 'info',\n data: {\n tag: target.tagName.toLowerCase(),\n id: target.id || undefined,\n className:\n typeof target.className === 'string'\n ? truncate(target.className, 100)\n : undefined,\n },\n });\n } catch {\n // Silently ignore - never crash the host app\n }\n };\n\n document.addEventListener('click', handleClick, true); // capture phase\n return () => document.removeEventListener('click', handleClick, true);\n}\n\n/**\n * Set up navigation tracking as breadcrumbs.\n * Tracks popstate events and monkey-patches history.pushState / replaceState.\n */\nfunction setupNavigationTracking(client: UncaughtClient): () => void {\n let currentUrl = window.location.href;\n\n const recordNavigation = (to: string): void => {\n try {\n const from = currentUrl;\n currentUrl = to;\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'navigation',\n category: 'navigation',\n message: `Navigated to ${to}`,\n level: 'info',\n data: {\n from,\n to,\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n // popstate fires on back/forward\n const handlePopState = (): void => {\n recordNavigation(window.location.href);\n };\n\n window.addEventListener('popstate', handlePopState);\n\n // Monkey-patch pushState and replaceState\n const originalPushState = history.pushState.bind(history);\n const originalReplaceState = history.replaceState.bind(history);\n\n history.pushState = function (\n data: unknown,\n unused: string,\n url?: string | URL | null\n ): void {\n originalPushState(data, unused, url);\n if (url) {\n try {\n const resolvedUrl = new URL(\n String(url),\n window.location.href\n ).href;\n recordNavigation(resolvedUrl);\n } catch {\n recordNavigation(String(url));\n }\n }\n };\n\n history.replaceState = function (\n data: unknown,\n unused: string,\n url?: string | URL | null\n ): void {\n originalReplaceState(data, unused, url);\n if (url) {\n try {\n const resolvedUrl = new URL(\n String(url),\n window.location.href\n ).href;\n recordNavigation(resolvedUrl);\n } catch {\n recordNavigation(String(url));\n }\n }\n };\n\n return () => {\n window.removeEventListener('popstate', handlePopState);\n history.pushState = originalPushState;\n history.replaceState = originalReplaceState;\n };\n}\n\n/**\n * Set up fetch tracking as breadcrumbs.\n * Monkey-patches window.fetch to record API calls with method, URL, status, and duration.\n * Does NOT record request/response bodies. Skips requests to the Uncaught API.\n */\nfunction setupFetchTracking(client: UncaughtClient): () => void {\n const originalFetch = window.fetch.bind(window);\n\n // Get the Uncaught API endpoint to exclude self-reporting requests\n const config = client.getConfig?.() ?? {};\n const apiEndpoint =\n (config as Record<string, unknown>).endpoint ??\n (config as Record<string, unknown>).dsn ??\n '';\n const uncaughtEndpoints: string[] = [];\n\n if (typeof apiEndpoint === 'string' && apiEndpoint) {\n try {\n const url = new URL(apiEndpoint);\n uncaughtEndpoints.push(url.hostname);\n } catch {\n uncaughtEndpoints.push(apiEndpoint);\n }\n }\n\n // Also exclude common Uncaught API patterns\n uncaughtEndpoints.push('uncaught.dev');\n uncaughtEndpoints.push('api.uncaught');\n\n const isUncaughtRequest = (url: string): boolean => {\n return uncaughtEndpoints.some(\n (endpoint) => endpoint && url.includes(endpoint)\n );\n };\n\n window.fetch = async function (\n input: RequestInfo | URL,\n init?: RequestInit\n ): Promise<Response> {\n const url =\n input instanceof Request\n ? input.url\n : input instanceof URL\n ? input.href\n : String(input);\n\n const method = (\n init?.method ??\n (input instanceof Request ? input.method : 'GET')\n ).toUpperCase();\n\n // Skip Uncaught's own requests to prevent infinite loops\n if (isUncaughtRequest(url)) {\n return originalFetch(input, init);\n }\n\n const startTime = Date.now();\n\n try {\n const response = await originalFetch(input, init);\n const duration = Date.now() - startTime;\n const isError = response.status >= 400;\n\n try {\n // Truncate URL for the breadcrumb to avoid huge payloads\n const displayUrl = truncate(url, 150);\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'api_call',\n category: 'fetch',\n message: `${method} ${displayUrl} [${response.status}]`,\n level: isError ? 'error' : 'info',\n data: {\n method,\n url: displayUrl,\n status: response.status,\n statusText: response.statusText,\n duration,\n },\n });\n } catch {\n // Silently ignore breadcrumb failures\n }\n\n return response;\n } catch (error) {\n const duration = Date.now() - startTime;\n\n try {\n const displayUrl = truncate(url, 150);\n\n client.addBreadcrumb({\n timestamp: new Date().toISOString(),\n type: 'api_call',\n category: 'fetch',\n message: `${method} ${displayUrl} [Network Error]`,\n level: 'error',\n data: {\n method,\n url: displayUrl,\n status: 0,\n error:\n error instanceof Error\n ? error.message\n : 'Network error',\n duration,\n },\n });\n } catch {\n // Silently ignore breadcrumb failures\n }\n\n throw error; // Re-throw so the app's error handling still works\n }\n };\n\n return () => {\n window.fetch = originalFetch;\n };\n}\n\n/**\n * Set up XHR tracking as breadcrumbs.\n * Monkey-patches XMLHttpRequest to record API calls with method, URL, status, and duration.\n * Captures requests made by Axios and other XHR-based libraries.\n */\nfunction setupXhrTracking(client: UncaughtClient): () => void {\n if (typeof XMLHttpRequest === 'undefined') {\n return () => {};\n }\n\n const originalOpen = XMLHttpRequest.prototype.open;\n const originalSend = XMLHttpRequest.prototype.send;\n\n // Get the Uncaught API endpoint to exclude self-reporting requests\n const config = client.getConfig?.() ?? {};\n const apiEndpoint =\n (config as Record<string, unknown>).endpoint ??\n (config as Record<string, unknown>).dsn ??\n '';\n const uncaughtEndpoints: string[] = ['uncaught.dev', 'api.uncaught'];\n if (typeof apiEndpoint === 'string' && apiEndpoint) {\n try {\n uncaughtEndpoints.push(new URL(apiEndpoint).hostname);\n } catch {\n uncaughtEndpoints.push(apiEndpoint);\n }\n }\n\n const isUncaughtRequest = (url: string): boolean =>\n uncaughtEndpoints.some((ep) => ep && url.includes(ep));\n\n XMLHttpRequest.prototype.open = function (\n method: string,\n url: string | URL,\n ...rest: unknown[]\n ): void {\n (this as XMLHttpRequest & { _uncaught_method?: string; _uncaught_url?: string })._uncaught_method = method.toUpperCase();\n (this as XMLHttpRequest & { _uncaught_url?: string })._uncaught_url = String(url);\n return originalOpen.apply(this, [method, url, ...rest] as Parameters<typeof originalOpen>);\n };\n\n XMLHttpRequest.prototype.send = function (\n body?: Document | XMLHttpRequestBodyInit | null\n ): void {\n const xhr = this as XMLHttpRequest & { _uncaught_method?: string; _uncaught_url?: string };\n const method = xhr._uncaught_method ?? 'GET';\n const url = xhr._uncaught_url ?? '';\n\n if (isUncaughtRequest(url)) {\n return originalSend.call(this, body);\n }\n\n const startTime = Date.now();\n\n const handleEnd = (): void => {\n try {\n const duration = Date.now() - startTime;\n const status = xhr.status;\n const isError = status === 0 || status >= 400;\n const displayUrl = truncate(url, 150);\n\n client.addBreadcrumb({\n type: 'api_call',\n category: 'xhr',\n message: `${method} ${displayUrl} [${status || 'Error'}]`,\n level: isError ? 'error' : 'info',\n data: {\n method,\n url: displayUrl,\n status,\n statusText: xhr.statusText,\n duration,\n },\n });\n } catch {\n // Never crash\n }\n };\n\n xhr.addEventListener('loadend', handleEnd);\n\n return originalSend.call(this, body);\n };\n\n return () => {\n XMLHttpRequest.prototype.open = originalOpen;\n XMLHttpRequest.prototype.send = originalSend;\n };\n}\n\n/**\n * Set up automatic DOM breadcrumb tracking including clicks,\n * navigation changes, fetch API calls, and XHR requests.\n *\n * @param client - The UncaughtClient instance to add breadcrumbs to.\n * @returns A cleanup function that removes all listeners and restores patched functions.\n */\nexport function setupDomBreadcrumbs(client: UncaughtClient): () => void {\n // Guard for SSR environments\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const cleanups: Array<() => void> = [];\n\n try {\n cleanups.push(setupClickTracking(client));\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to set up click tracking:', e);\n }\n }\n\n try {\n cleanups.push(setupNavigationTracking(client));\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up navigation tracking:',\n e\n );\n }\n }\n\n try {\n cleanups.push(setupFetchTracking(client));\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to set up fetch tracking:', e);\n }\n }\n\n try {\n cleanups.push(setupXhrTracking(client));\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to set up XHR tracking:', e);\n }\n }\n\n return () => {\n cleanups.forEach((cleanup) => {\n try {\n cleanup();\n } catch {\n // Silently ignore cleanup failures\n }\n });\n };\n}\n","import type { UncaughtClient, UncaughtConfig } from '@uncaughtdev/core';\n\n/**\n * Augmented Window interface to access Next.js internals.\n * These are undocumented but stable properties Next.js sets on the window.\n */\ninterface NextWindow extends Window {\n /** Present in Pages Router - contains build-time page data */\n __NEXT_DATA__?: {\n page?: string;\n query?: Record<string, unknown>;\n buildId?: string;\n props?: Record<string, unknown>;\n };\n /** Present in App Router - contains flight response data */\n __next_f?: unknown[];\n /** Next.js router instance (Pages Router) */\n next?: {\n router?: {\n events?: {\n on: (event: string, handler: (...args: unknown[]) => void) => void;\n off: (event: string, handler: (...args: unknown[]) => void) => void;\n };\n };\n };\n}\n\n/**\n * Result of Next.js environment detection.\n */\nexport interface NextJsDetection {\n /** Whether the app appears to be running in a Next.js context */\n isNextJs: boolean;\n /** Whether the App Router is detected */\n isAppRouter: boolean;\n /** Whether the Pages Router is detected */\n isPagesRouter: boolean;\n}\n\n/**\n * Detect if the current environment is a Next.js application,\n * and which router (App Router vs Pages Router) is being used.\n *\n * This detection is best-effort and relies on undocumented\n * but stable Next.js window properties.\n *\n * @returns Detection result with router type information.\n */\nexport function detectNextJs(): NextJsDetection {\n if (typeof window === 'undefined') {\n return {\n isNextJs: false,\n isAppRouter: false,\n isPagesRouter: false,\n };\n }\n\n const win = window as NextWindow;\n\n const hasPagesData = win.__NEXT_DATA__ !== undefined;\n const hasAppRouterData = win.__next_f !== undefined;\n\n // Check for Next.js meta tag as an additional signal\n let hasNextMeta = false;\n try {\n const nextMeta = document.querySelector('meta[name=\"next-size-adjust\"]');\n hasNextMeta = nextMeta !== null;\n } catch {\n // Ignore DOM query errors\n }\n\n const isPagesRouter = hasPagesData && !hasAppRouterData;\n const isAppRouter = hasAppRouterData;\n const isNextJs = hasPagesData || hasAppRouterData || hasNextMeta;\n\n return {\n isNextJs,\n isAppRouter,\n isPagesRouter,\n };\n}\n\n/**\n * Set up navigation tracking specifically for Next.js routing.\n *\n * For the Pages Router, hooks into Next.js router events (routeChangeStart,\n * routeChangeComplete, routeChangeError).\n *\n * For the App Router, navigation is tracked via the general DOM breadcrumbs\n * (history.pushState monkey-patch), so this function primarily adds\n * Next.js-specific context.\n *\n * @param client - The UncaughtClient instance.\n * @returns A cleanup function that removes the event listeners.\n */\nexport function setupNextJsNavigation(client: UncaughtClient): () => void {\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const detection = detectNextJs();\n const cleanups: Array<() => void> = [];\n\n // Add Next.js context to the client\n try {\n client.addBreadcrumb({\n\n type: 'navigation',\n category: 'nextjs',\n message: `Next.js detected: ${\n detection.isAppRouter\n ? 'App Router'\n : detection.isPagesRouter\n ? 'Pages Router'\n : 'Unknown Router'\n }`,\n level: 'info',\n data: {\n isAppRouter: detection.isAppRouter,\n isPagesRouter: detection.isPagesRouter,\n },\n });\n } catch {\n // Silently ignore\n }\n\n // Pages Router: hook into router events\n if (detection.isPagesRouter) {\n try {\n const win = window as NextWindow;\n const routerEvents = win.next?.router?.events;\n\n if (routerEvents) {\n let navigationStartTime = 0;\n\n const handleRouteChangeStart = (url: unknown): void => {\n try {\n navigationStartTime = Date.now();\n client.addBreadcrumb({\n \n type: 'navigation',\n category: 'nextjs.route',\n message: `Route change started: ${String(url)}`,\n level: 'info',\n data: {\n to: String(url),\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n const handleRouteChangeComplete = (url: unknown): void => {\n try {\n const duration =\n navigationStartTime > 0\n ? Date.now() - navigationStartTime\n : undefined;\n\n client.addBreadcrumb({\n \n type: 'navigation',\n category: 'nextjs.route',\n message: `Route change completed: ${String(url)}`,\n level: 'info',\n data: {\n to: String(url),\n duration,\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n const handleRouteChangeError = (\n err: unknown,\n url: unknown\n ): void => {\n try {\n const duration =\n navigationStartTime > 0\n ? Date.now() - navigationStartTime\n : undefined;\n\n client.addBreadcrumb({\n \n type: 'navigation',\n category: 'nextjs.route',\n message: `Route change error: ${String(url)}`,\n level: 'error',\n data: {\n to: String(url),\n error:\n err instanceof Error\n ? err.message\n : String(err),\n duration,\n },\n });\n } catch {\n // Silently ignore\n }\n };\n\n routerEvents.on('routeChangeStart', handleRouteChangeStart);\n routerEvents.on(\n 'routeChangeComplete',\n handleRouteChangeComplete\n );\n routerEvents.on('routeChangeError', handleRouteChangeError);\n\n cleanups.push(() => {\n try {\n routerEvents.off(\n 'routeChangeStart',\n handleRouteChangeStart\n );\n routerEvents.off(\n 'routeChangeComplete',\n handleRouteChangeComplete\n );\n routerEvents.off(\n 'routeChangeError',\n handleRouteChangeError\n );\n } catch {\n // Silently ignore\n }\n });\n }\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up Next.js Pages Router navigation:',\n e\n );\n }\n }\n }\n\n return () => {\n cleanups.forEach((cleanup) => {\n try {\n cleanup();\n } catch {\n // Silently ignore cleanup failures\n }\n });\n };\n}\n\n/**\n * Higher-order function for wrapping Next.js App Router layouts.\n *\n * Returns the configuration object needed to initialize UncaughtProvider\n * with Next.js-specific defaults applied.\n *\n * Usage in layout.tsx:\n * ```tsx\n * import { UncaughtProvider } from '@uncaughtdev/react';\n * import { withUncaught } from '@uncaughtdev/react';\n *\n * const uncaughtConfig = withUncaught({\n * dsn: 'your-dsn-here',\n * environment: 'production',\n * });\n *\n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * <UncaughtProvider {...uncaughtConfig}>\n * {children}\n * </UncaughtProvider>\n * </body>\n * </html>\n * );\n * }\n * ```\n *\n * @param config - Base UncaughtConfig to extend with Next.js defaults.\n * @returns Configuration object with Next.js-specific settings applied.\n */\nexport function withUncaught(\n config: UncaughtConfig\n): UncaughtConfig & { __nextjs: boolean } {\n return {\n ...config,\n __nextjs: true,\n };\n}\n","import type { UncaughtClient } from '@uncaughtdev/core';\n\n/**\n * Set up Core Web Vitals tracking using native PerformanceObserver.\n * Records LCP, FID/INP, CLS, FCP, and TTFB as breadcrumbs.\n *\n * No external dependencies — uses browser-native APIs only.\n *\n * @returns Cleanup function to disconnect observers.\n */\nexport function setupWebVitals(client: UncaughtClient): () => void {\n if (typeof window === 'undefined' || typeof PerformanceObserver === 'undefined') {\n return () => {};\n }\n\n const observers: PerformanceObserver[] = [];\n\n function recordVital(name: string, value: number, unit: string = 'ms'): void {\n try {\n const displayValue = unit === 'ms'\n ? `${Math.round(value)}ms`\n : value.toFixed(3);\n\n client.addBreadcrumb({\n type: 'web_vital',\n category: 'web-vital',\n message: `${name}: ${displayValue}`,\n level: 'info',\n data: { name, value, unit },\n });\n } catch {\n // Never crash\n }\n }\n\n // --- LCP (Largest Contentful Paint) ---\n try {\n const lcpObserver = new PerformanceObserver((list) => {\n const entries = list.getEntries();\n const last = entries[entries.length - 1];\n if (last) {\n recordVital('LCP', last.startTime);\n }\n });\n lcpObserver.observe({ type: 'largest-contentful-paint', buffered: true });\n observers.push(lcpObserver);\n } catch {\n // Not supported\n }\n\n // --- FID (First Input Delay) ---\n try {\n const fidObserver = new PerformanceObserver((list) => {\n const entries = list.getEntries();\n const first = entries[0] as PerformanceEventTiming | undefined;\n if (first) {\n recordVital('FID', first.processingStart - first.startTime);\n }\n });\n fidObserver.observe({ type: 'first-input', buffered: true });\n observers.push(fidObserver);\n } catch {\n // Not supported\n }\n\n // --- CLS (Cumulative Layout Shift) ---\n try {\n let clsValue = 0;\n const clsObserver = new PerformanceObserver((list) => {\n for (const entry of list.getEntries()) {\n const layoutShift = entry as PerformanceEntry & { hadRecentInput?: boolean; value?: number };\n if (!layoutShift.hadRecentInput && layoutShift.value) {\n clsValue += layoutShift.value;\n }\n }\n });\n clsObserver.observe({ type: 'layout-shift', buffered: true });\n observers.push(clsObserver);\n\n // Report CLS on page hide\n const reportCLS = (): void => {\n if (clsValue > 0) {\n recordVital('CLS', clsValue, 'score');\n }\n };\n window.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'hidden') reportCLS();\n });\n } catch {\n // Not supported\n }\n\n // --- FCP (First Contentful Paint) ---\n try {\n const fcpObserver = new PerformanceObserver((list) => {\n const entries = list.getEntries();\n const fcp = entries.find((e) => e.name === 'first-contentful-paint');\n if (fcp) {\n recordVital('FCP', fcp.startTime);\n }\n });\n fcpObserver.observe({ type: 'paint', buffered: true });\n observers.push(fcpObserver);\n } catch {\n // Not supported\n }\n\n // --- TTFB (Time to First Byte) ---\n try {\n const navEntries = performance.getEntriesByType('navigation') as PerformanceNavigationTiming[];\n if (navEntries.length > 0) {\n const nav = navEntries[0];\n if (nav.responseStart > 0) {\n recordVital('TTFB', nav.responseStart - nav.requestStart);\n }\n }\n } catch {\n // Not supported\n }\n\n return () => {\n observers.forEach((o) => {\n try { o.disconnect(); } catch { /* ignore */ }\n });\n };\n}\n\n// Type augmentation for PerformanceEventTiming (not in all TS libs)\ninterface PerformanceEventTiming extends PerformanceEntry {\n processingStart: number;\n}\n","'use client';\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport { initUncaught } from '@uncaughtdev/core';\nimport type { UncaughtClient } from '@uncaughtdev/core';\nimport { UncaughtContext } from './context';\nimport { UncaughtErrorBoundary } from './error-boundary';\nimport { setupGlobalHandlers } from './global-handlers';\nimport { setupDomBreadcrumbs } from './dom-breadcrumbs';\nimport { setupNextJsNavigation, detectNextJs } from './next-integration';\nimport { setupWebVitals } from './web-vitals';\nimport type { UncaughtProviderProps } from './types';\n\n/**\n * UncaughtProvider initializes the Uncaught error monitoring client and\n * provides it to all descendant components via React context.\n *\n * It automatically:\n * - Initializes the UncaughtClient with the provided configuration\n * - Sets up global error handlers (window.onerror, unhandledrejection)\n * - Sets up DOM breadcrumb tracking (clicks, navigation, fetch)\n * - Detects and integrates with Next.js routing if present\n * - Wraps children in an error boundary\n * - Cleans up all listeners on unmount\n *\n * Usage:\n * ```tsx\n * <UncaughtProvider dsn=\"your-dsn\" environment=\"production\">\n * <App />\n * </UncaughtProvider>\n * ```\n *\n * @param props - Configuration props extending UncaughtConfig plus children, fallback, and showDialog.\n */\nexport function UncaughtProvider({\n children,\n fallback,\n showDialog,\n ...config\n}: UncaughtProviderProps): React.ReactElement {\n const [client, setClient] = useState<UncaughtClient | null>(null);\n const cleanupRef = useRef<Array<() => void>>([]);\n const initializedRef = useRef(false);\n\n useEffect(() => {\n // Prevent double-initialization in React StrictMode\n if (initializedRef.current) {\n return;\n }\n initializedRef.current = true;\n\n let mounted = true;\n const cleanups: Array<() => void> = [];\n\n try {\n // Strip React-specific props before passing to core\n const { __nextjs, ...coreConfig } = config as Record<string, unknown> & {\n __nextjs?: boolean;\n };\n\n // Initialize the core client\n const uncaughtClient = initUncaught(\n coreConfig as Parameters<typeof initUncaught>[0]\n );\n\n if (!uncaughtClient) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '[Uncaught] initUncaught returned null/undefined. Error monitoring is disabled.'\n );\n }\n return;\n }\n\n // Set up global error handlers\n try {\n const cleanupGlobal = setupGlobalHandlers(uncaughtClient);\n cleanups.push(cleanupGlobal);\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up global handlers:',\n e\n );\n }\n }\n\n // Set up DOM breadcrumbs\n try {\n const cleanupDom = setupDomBreadcrumbs(uncaughtClient);\n cleanups.push(cleanupDom);\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up DOM breadcrumbs:',\n e\n );\n }\n }\n\n // Set up Web Vitals tracking\n try {\n const cleanupVitals = setupWebVitals(uncaughtClient);\n cleanups.push(cleanupVitals);\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to set up Web Vitals:', e);\n }\n }\n\n // Set up Next.js integration if detected or explicitly configured\n if (typeof window !== 'undefined') {\n try {\n const nextDetection = detectNextJs();\n if (nextDetection.isNextJs || __nextjs) {\n const cleanupNext = setupNextJsNavigation(uncaughtClient);\n cleanups.push(cleanupNext);\n }\n } catch (e) {\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to set up Next.js integration:',\n e\n );\n }\n }\n }\n\n // Store cleanups for unmount\n cleanupRef.current = cleanups;\n\n // Only update state if still mounted\n if (mounted) {\n setClient(uncaughtClient);\n }\n } catch (e) {\n // Never crash the host app during initialization\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to initialize:', e);\n }\n }\n\n return () => {\n mounted = false;\n // Run all cleanup functions\n cleanupRef.current.forEach((cleanup) => {\n try {\n cleanup();\n } catch {\n // Silently ignore cleanup failures\n }\n });\n cleanupRef.current = [];\n initializedRef.current = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // Initialize once on mount - config changes require remounting\n\n const contextValue = React.useMemo(() => ({ client }), [client]);\n\n return (\n <UncaughtContext.Provider value={contextValue}>\n <UncaughtErrorBoundary fallback={fallback} showDialog={showDialog}>\n {children}\n </UncaughtErrorBoundary>\n </UncaughtContext.Provider>\n );\n}\n","'use client';\n\nimport { useContext, useCallback } from 'react';\nimport type { UncaughtClient, Breadcrumb } from '@uncaughtdev/core';\nimport { UncaughtContext } from './context';\n\n/**\n * Returns the UncaughtClient instance from context.\n * Must be called within an UncaughtProvider.\n *\n * @throws {Error} If called outside of an UncaughtProvider.\n * @returns The UncaughtClient instance.\n */\nexport function useUncaught(): UncaughtClient {\n const { client } = useContext(UncaughtContext);\n\n if (!client) {\n throw new Error(\n 'useUncaught must be used within an <UncaughtProvider>. ' +\n 'Wrap your application in <UncaughtProvider> to use this hook.'\n );\n }\n\n return client;\n}\n\n/**\n * Returns a function that reports an error to Uncaught.\n * Safe to call even if the client is not yet initialized (will silently no-op).\n *\n * @returns A function `(error: Error, context?: Record<string, unknown>) => void`\n */\nexport function useReportError(): (\n error: Error,\n context?: Record<string, unknown>\n) => void {\n const { client } = useContext(UncaughtContext);\n\n return useCallback(\n (error: Error, context?: Record<string, unknown>) => {\n try {\n if (!client) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '[Uncaught] useReportError called but no UncaughtClient is available. ' +\n 'Make sure <UncaughtProvider> is mounted.'\n );\n }\n return;\n }\n\n client.captureError(error);\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to report error:', e);\n }\n }\n },\n [client]\n );\n}\n\n/**\n * Returns a function that adds a breadcrumb to the current Uncaught session.\n * Safe to call even if the client is not yet initialized (will silently no-op).\n *\n * @returns A function `(breadcrumb: Partial<Breadcrumb>) => void`\n */\n/**\n * Wraps a callback function with error capture.\n * Use this for event handlers (onClick, onChange, etc.) that React Error\n * Boundary does not catch.\n *\n * @example\n * ```tsx\n * const handleClick = useErrorHandler((e) => {\n * // risky code that might throw\n * });\n * <button onClick={handleClick}>Click</button>\n * ```\n */\nexport function useErrorHandler<T extends (...args: unknown[]) => unknown>(\n fn: T\n): T {\n const { client } = useContext(UncaughtContext);\n\n return useCallback(\n ((...args: unknown[]) => {\n try {\n const result = fn(...args);\n // Handle async functions\n if (result instanceof Promise) {\n return result.catch((error: unknown) => {\n try {\n if (client) {\n client.captureError(error);\n }\n } catch {\n // Never crash\n }\n throw error; // Re-throw so app error handling still works\n });\n }\n return result;\n } catch (error) {\n try {\n if (client) {\n client.captureError(error);\n }\n } catch {\n // Never crash\n }\n throw error; // Re-throw so app error handling still works\n }\n }) as T,\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [fn, client]\n );\n}\n\n/**\n * Standalone HOF (non-hook) that wraps a function with error capture.\n * Use in class components or outside React context.\n */\nexport function withErrorCapture<T extends (...args: unknown[]) => unknown>(\n fn: T,\n client?: UncaughtClient | null\n): T {\n return ((...args: unknown[]) => {\n try {\n const result = fn(...args);\n if (result instanceof Promise) {\n return result.catch((error: unknown) => {\n try {\n if (client) {\n client.captureError(error);\n }\n } catch {\n // Never crash\n }\n throw error;\n });\n }\n return result;\n } catch (error) {\n try {\n if (client) {\n client.captureError(error);\n }\n } catch {\n // Never crash\n }\n throw error;\n }\n }) as T;\n}\n\nexport function useBreadcrumb(): (breadcrumb: Partial<Breadcrumb>) => void {\n const { client } = useContext(UncaughtContext);\n\n return useCallback(\n (breadcrumb: Partial<Breadcrumb>) => {\n try {\n if (!client) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '[Uncaught] useBreadcrumb called but no UncaughtClient is available. ' +\n 'Make sure <UncaughtProvider> is mounted.'\n );\n }\n return;\n }\n\n client.addBreadcrumb({\n type: breadcrumb.type ?? 'custom',\n category: breadcrumb.category ?? 'custom',\n message: breadcrumb.message ?? '',\n level: breadcrumb.level ?? 'info',\n data: breadcrumb.data,\n });\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to add breadcrumb:', e);\n }\n }\n },\n [client]\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uncaughtdev/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React and Next.js SDK for Uncaught error monitoring",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Uncaught",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": ">=17.0.0",
|
|
37
37
|
"react-dom": ">=17.0.0",
|
|
38
|
-
"@uncaughtdev/core": "0.
|
|
38
|
+
"@uncaughtdev/core": "0.2.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@uncaughtdev/core": "0.
|
|
41
|
+
"@uncaughtdev/core": "0.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"react": "^18.3.0",
|