@error-explorer/react 1.1.1 → 1.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/dist/index.cjs CHANGED
@@ -163,22 +163,37 @@ var ErrorBoundary = class extends import_react2.Component {
163
163
  }
164
164
  componentDidCatch(error, errorInfo) {
165
165
  this.setState({ errorInfo });
166
- const { capture = true, tags = {}, context = {}, onError } = this.props;
166
+ const {
167
+ capture = true,
168
+ captureComponentStack = true,
169
+ beforeReactCapture,
170
+ tags = {},
171
+ context = {},
172
+ onError
173
+ } = this.props;
167
174
  if (onError) {
168
175
  onError(error, errorInfo);
169
176
  }
170
- if (capture) {
171
- import_browser2.ErrorExplorer.captureException(error, {
172
- tags: {
173
- "react.errorBoundary": "true",
174
- ...tags
175
- },
176
- extra: {
177
- componentStack: errorInfo.componentStack,
178
- ...context
179
- }
180
- });
177
+ if (!capture) {
178
+ return;
181
179
  }
180
+ if (beforeReactCapture) {
181
+ const shouldCapture = beforeReactCapture(error, errorInfo);
182
+ if (shouldCapture === false) {
183
+ return;
184
+ }
185
+ }
186
+ const extra = { ...context };
187
+ if (captureComponentStack && errorInfo.componentStack) {
188
+ extra.componentStack = errorInfo.componentStack;
189
+ }
190
+ import_browser2.ErrorExplorer.captureException(error, {
191
+ tags: {
192
+ "react.errorBoundary": "true",
193
+ ...tags
194
+ },
195
+ extra
196
+ });
182
197
  }
183
198
  componentDidUpdate(prevProps) {
184
199
  const { resetKeys } = this.props;
@@ -214,17 +229,28 @@ var ErrorBoundary = class extends import_react2.Component {
214
229
  };
215
230
  ErrorBoundary.defaultProps = {
216
231
  capture: true,
232
+ captureComponentStack: true,
217
233
  tags: {},
218
234
  context: {}
219
235
  };
220
236
  function withErrorBoundary(Component2, options = {}) {
221
- const { fallback, onError, capture = true, tags = {}, context = {} } = options;
237
+ const {
238
+ fallback,
239
+ onError,
240
+ capture = true,
241
+ captureComponentStack = true,
242
+ beforeReactCapture,
243
+ tags = {},
244
+ context = {}
245
+ } = options;
222
246
  const Wrapped = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
223
247
  ErrorBoundary,
224
248
  {
225
249
  fallback,
226
250
  onError,
227
251
  capture,
252
+ captureComponentStack,
253
+ beforeReactCapture,
228
254
  tags,
229
255
  context,
230
256
  children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component2, { ...props })
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/context.tsx","../src/ErrorBoundary.tsx","../src/hooks.ts"],"sourcesContent":["/**\n * @error-explorer/react\n * Error Explorer SDK for React - Automatic error tracking with React integration\n */\n\n// Import for default export\nimport { ErrorExplorerProvider as Provider } from './context';\n\n// Provider and initialization\nexport { ErrorExplorerProvider, ErrorExplorerContext, initErrorExplorer } from './context';\n\n// Error Boundary\nexport { ErrorBoundary, withErrorBoundary, useErrorBoundary } from './ErrorBoundary';\n\n// Hooks\nexport {\n useErrorExplorer,\n useErrorHandler,\n useUserContext,\n useActionTracker,\n useComponentBreadcrumbs,\n} from './hooks';\n\n// Types\nexport type {\n ReactErrorExplorerOptions,\n ReactComponentContext,\n ErrorBoundaryProps,\n ErrorBoundaryState,\n FallbackProps,\n ErrorExplorerProviderProps,\n ErrorExplorerContextValue,\n WithErrorBoundaryOptions,\n InitOptions,\n UserContext,\n Breadcrumb,\n CaptureContext,\n} from './types';\n\n// Re-export ErrorExplorer for direct access\nexport { ErrorExplorer } from '@error-explorer/browser';\n\n// Default export is the provider for convenience\nexport default Provider;\n","/**\n * React Context Provider for Error Explorer\n */\n\nimport React, { createContext, useEffect, useState, useMemo, type ReactNode } from 'react';\nimport { ErrorExplorer } from '@error-explorer/browser';\nimport type { Breadcrumb, CaptureContext, UserContext } from '@error-explorer/browser';\nimport type { ReactErrorExplorerOptions, ErrorExplorerContextValue } from './types';\n\n/**\n * React Context for Error Explorer\n */\nexport const ErrorExplorerContext = createContext<ErrorExplorerContextValue | null>(null);\n\n/**\n * Error Explorer Provider Component\n *\n * Initializes the Error Explorer SDK and provides context to child components.\n *\n * @example\n * ```tsx\n * function App() {\n * return (\n * <ErrorExplorerProvider\n * options={{\n * token: 'ee_your_token',\n * project: 'my-react-app',\n * environment: 'production',\n * }}\n * >\n * <MainContent />\n * </ErrorExplorerProvider>\n * );\n * }\n * ```\n */\nexport function ErrorExplorerProvider({\n options,\n children,\n}: {\n options: ReactErrorExplorerOptions;\n children: ReactNode;\n}) {\n const [isInitialized, setIsInitialized] = useState(false);\n\n // Initialize on mount\n useEffect(() => {\n if (!ErrorExplorer.isInitialized()) {\n ErrorExplorer.init(options);\n setIsInitialized(true);\n } else {\n setIsInitialized(true);\n }\n\n // Cleanup on unmount\n return () => {\n // Don't close on unmount as other components might still need it\n // ErrorExplorer.close();\n };\n }, []); // Only run once on mount\n\n // Create stable context value\n const contextValue = useMemo<ErrorExplorerContextValue>(\n () => ({\n isInitialized,\n captureException: (error: Error, context?: CaptureContext) =>\n ErrorExplorer.captureException(error, context),\n captureMessage: (message: string, level?: 'debug' | 'info' | 'warning' | 'error' | 'critical') =>\n ErrorExplorer.captureMessage(message, level),\n addBreadcrumb: (breadcrumb: Breadcrumb) => ErrorExplorer.addBreadcrumb(breadcrumb),\n setUser: (user: UserContext) => ErrorExplorer.setUser(user),\n clearUser: () => ErrorExplorer.clearUser(),\n setTag: (key: string, value: string) => ErrorExplorer.setTag(key, value),\n setTags: (tags: Record<string, string>) => ErrorExplorer.setTags(tags),\n setExtra: (extra: Record<string, unknown>) => ErrorExplorer.setExtra(extra),\n setContext: (name: string, context: Record<string, unknown>) =>\n ErrorExplorer.setContext(name, context),\n flush: (timeout?: number) => ErrorExplorer.flush(timeout),\n close: (timeout?: number) => ErrorExplorer.close(timeout),\n }),\n [isInitialized]\n );\n\n return (\n <ErrorExplorerContext.Provider value={contextValue}>\n {children}\n </ErrorExplorerContext.Provider>\n );\n}\n\n/**\n * Initialize Error Explorer directly (without provider)\n *\n * Use this if you don't need the React Context and just want to initialize\n * the SDK globally.\n *\n * @example\n * ```tsx\n * // In your entry file (main.tsx)\n * import { initErrorExplorer } from '@error-explorer/react';\n *\n * initErrorExplorer({\n * token: 'ee_your_token',\n * project: 'my-react-app',\n * environment: 'production',\n * });\n *\n * ReactDOM.createRoot(root).render(<App />);\n * ```\n */\nexport function initErrorExplorer(options: ReactErrorExplorerOptions): void {\n if (!ErrorExplorer.isInitialized()) {\n ErrorExplorer.init(options);\n }\n}\n","/**\n * ErrorBoundary component for React\n * Catches errors in child components and reports them to Error Explorer\n */\n\nimport React, { Component, type ReactNode, type ComponentType } from 'react';\nimport { ErrorExplorer } from '@error-explorer/browser';\nimport type {\n ErrorBoundaryProps,\n ErrorBoundaryState,\n FallbackProps,\n WithErrorBoundaryOptions,\n} from './types';\n\n/**\n * Default fallback component\n */\nconst DefaultFallback: React.FC<FallbackProps> = ({ error, resetErrorBoundary }) => (\n <div\n role=\"alert\"\n style={{\n padding: '20px',\n border: '1px solid #f5c6cb',\n borderRadius: '4px',\n backgroundColor: '#f8d7da',\n color: '#721c24',\n }}\n >\n <h2 style={{ margin: '0 0 10px 0' }}>Something went wrong</h2>\n <pre style={{\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n backgroundColor: 'rgba(0,0,0,0.1)',\n padding: '10px',\n borderRadius: '4px',\n fontSize: '14px',\n }}>\n {error.message}\n </pre>\n <button\n onClick={resetErrorBoundary}\n style={{\n marginTop: '10px',\n padding: '8px 16px',\n backgroundColor: '#721c24',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer',\n }}\n >\n Try again\n </button>\n </div>\n);\n\n/**\n * ErrorBoundary class component\n *\n * React Error Boundaries must be class components - there's no hook equivalent.\n *\n * @example\n * ```tsx\n * <ErrorBoundary fallback={<ErrorFallback />}>\n * <MyComponent />\n * </ErrorBoundary>\n * ```\n *\n * @example\n * With render prop fallback:\n * ```tsx\n * <ErrorBoundary\n * fallback={({ error, resetErrorBoundary }) => (\n * <div>\n * <p>Error: {error.message}</p>\n * <button onClick={resetErrorBoundary}>Retry</button>\n * </div>\n * )}\n * >\n * <MyComponent />\n * </ErrorBoundary>\n * ```\n */\nexport class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\n static defaultProps = {\n capture: true,\n tags: {},\n context: {},\n };\n\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {\n hasError: false,\n error: null,\n errorInfo: null,\n };\n }\n\n static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState> {\n return {\n hasError: true,\n error,\n };\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {\n this.setState({ errorInfo });\n\n const { capture = true, tags = {}, context = {}, onError } = this.props;\n\n // Call user's error handler\n if (onError) {\n onError(error, errorInfo);\n }\n\n // Capture to Error Explorer\n if (capture) {\n ErrorExplorer.captureException(error, {\n tags: {\n 'react.errorBoundary': 'true',\n ...tags,\n },\n extra: {\n componentStack: errorInfo.componentStack,\n ...context,\n },\n });\n }\n }\n\n componentDidUpdate(prevProps: ErrorBoundaryProps): void {\n const { resetKeys } = this.props;\n const { hasError } = this.state;\n\n // Reset if resetKeys changed\n if (hasError && resetKeys && prevProps.resetKeys) {\n const hasResetKeyChanged = resetKeys.some(\n (key, index) => key !== prevProps.resetKeys?.[index]\n );\n\n if (hasResetKeyChanged) {\n this.reset();\n }\n }\n }\n\n reset = (): void => {\n const { onReset } = this.props;\n\n this.setState({\n hasError: false,\n error: null,\n errorInfo: null,\n });\n\n if (onReset) {\n onReset();\n }\n };\n\n render(): ReactNode {\n const { hasError, error, errorInfo } = this.state;\n const { children, fallback } = this.props;\n\n if (hasError && error) {\n const fallbackProps: FallbackProps = {\n error,\n errorInfo,\n resetErrorBoundary: this.reset,\n };\n\n // Render function fallback\n if (typeof fallback === 'function') {\n return fallback(fallbackProps);\n }\n\n // Static fallback\n if (fallback) {\n return fallback;\n }\n\n // Default fallback\n return <DefaultFallback {...fallbackProps} />;\n }\n\n return children;\n }\n}\n\n/**\n * Higher-order component to wrap a component with ErrorBoundary\n *\n * @example\n * ```tsx\n * const SafeComponent = withErrorBoundary(MyComponent, {\n * fallback: <ErrorFallback />,\n * onError: (error) => console.error(error),\n * });\n * ```\n */\nexport function withErrorBoundary<P extends object>(\n Component: ComponentType<P>,\n options: WithErrorBoundaryOptions = {}\n): ComponentType<P> {\n const { fallback, onError, capture = true, tags = {}, context = {} } = options;\n\n const Wrapped: React.FC<P> = (props) => (\n <ErrorBoundary\n fallback={fallback}\n onError={onError}\n capture={capture}\n tags={tags}\n context={context}\n >\n <Component {...props} />\n </ErrorBoundary>\n );\n\n // Preserve display name for debugging\n const displayName = Component.displayName || Component.name || 'Component';\n Wrapped.displayName = `withErrorBoundary(${displayName})`;\n\n return Wrapped;\n}\n\n/**\n * useErrorBoundary hook for functional components\n *\n * Note: This doesn't create an error boundary - those must be class components.\n * Instead, this provides a way to show/trigger the nearest error boundary.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { showBoundary } = useErrorBoundary();\n *\n * const handleClick = async () => {\n * try {\n * await riskyOperation();\n * } catch (error) {\n * showBoundary(error);\n * }\n * };\n * }\n * ```\n */\nexport function useErrorBoundary() {\n const [error, setError] = React.useState<Error | null>(null);\n\n // If there's an error, throw it to be caught by the nearest error boundary\n if (error) {\n throw error;\n }\n\n return {\n /**\n * Trigger the nearest error boundary with the given error\n */\n showBoundary: (err: Error) => setError(err),\n\n /**\n * Reset the error state\n */\n resetBoundary: () => setError(null),\n };\n}\n","/**\n * React Hooks for Error Explorer\n */\n\nimport { useContext, useEffect, useCallback, useRef } from 'react';\nimport { ErrorExplorer } from '@error-explorer/browser';\nimport type { Breadcrumb, CaptureContext, UserContext } from '@error-explorer/browser';\nimport { ErrorExplorerContext } from './context';\n\n/**\n * Use Error Explorer instance\n *\n * Returns the Error Explorer SDK methods for capturing errors and managing context.\n *\n * @example\n * ```tsx\n * const { captureException, addBreadcrumb, setUser } = useErrorExplorer();\n *\n * try {\n * await riskyOperation();\n * } catch (error) {\n * captureException(error);\n * }\n * ```\n */\nexport function useErrorExplorer() {\n // Try to get from context first (if using provider)\n const contextValue = useContext(ErrorExplorerContext);\n\n // If context is available and initialized, use it\n if (contextValue?.isInitialized) {\n return contextValue;\n }\n\n // Fall back to singleton\n return {\n isInitialized: ErrorExplorer.isInitialized(),\n captureException: (error: Error, context?: CaptureContext) =>\n ErrorExplorer.captureException(error, context),\n captureMessage: (message: string, level?: 'debug' | 'info' | 'warning' | 'error' | 'critical') =>\n ErrorExplorer.captureMessage(message, level),\n addBreadcrumb: (breadcrumb: Breadcrumb) => ErrorExplorer.addBreadcrumb(breadcrumb),\n setUser: (user: UserContext) => ErrorExplorer.setUser(user),\n clearUser: () => ErrorExplorer.clearUser(),\n setTag: (key: string, value: string) => ErrorExplorer.setTag(key, value),\n setTags: (tags: Record<string, string>) => ErrorExplorer.setTags(tags),\n setExtra: (extra: Record<string, unknown>) => ErrorExplorer.setExtra(extra),\n setContext: (name: string, context: Record<string, unknown>) =>\n ErrorExplorer.setContext(name, context),\n flush: (timeout?: number) => ErrorExplorer.flush(timeout),\n close: (timeout?: number) => ErrorExplorer.close(timeout),\n };\n}\n\n/**\n * Error handler hook for async operations\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { handleError, wrapAsync } = useErrorHandler();\n *\n * // Option 1: Wrap async function\n * const safeSubmit = wrapAsync(async () => {\n * await api.submit(data);\n * });\n *\n * // Option 2: Manual handling\n * const handleClick = async () => {\n * try {\n * await riskyOperation();\n * } catch (error) {\n * handleError(error, { tags: { operation: 'risky' } });\n * }\n * };\n * }\n * ```\n */\nexport function useErrorHandler(defaultContext?: CaptureContext) {\n const { captureException } = useErrorExplorer();\n\n /**\n * Handle an error with optional context\n */\n const handleError = useCallback(\n (error: unknown, context?: CaptureContext): Error => {\n const err = error instanceof Error ? error : new Error(String(error));\n\n captureException(err, {\n ...defaultContext,\n ...context,\n tags: {\n ...defaultContext?.tags,\n ...context?.tags,\n },\n extra: {\n ...defaultContext?.extra,\n ...context?.extra,\n },\n });\n\n return err;\n },\n [captureException, defaultContext]\n );\n\n /**\n * Wrap an async function with error handling\n */\n const wrapAsync = useCallback(\n <T extends (...args: any[]) => Promise<any>>(\n fn: T,\n context?: CaptureContext\n ): ((...args: Parameters<T>) => Promise<Awaited<ReturnType<T>> | undefined>) => {\n return async (...args: Parameters<T>) => {\n try {\n return await fn(...args);\n } catch (error) {\n handleError(error, context);\n return undefined;\n }\n };\n },\n [handleError]\n );\n\n /**\n * Create a try-catch wrapper that captures errors\n */\n const tryCatch = useCallback(\n <T>(fn: () => T, context?: CaptureContext): T | undefined => {\n try {\n return fn();\n } catch (error) {\n handleError(error, context);\n return undefined;\n }\n },\n [handleError]\n );\n\n return {\n handleError,\n wrapAsync,\n tryCatch,\n };\n}\n\n/**\n * User context hook\n *\n * Sets the user context and cleans up on unmount.\n *\n * @example\n * ```tsx\n * function App() {\n * const user = useCurrentUser();\n *\n * useUserContext(user ? {\n * id: user.id,\n * email: user.email,\n * name: user.name,\n * } : null);\n *\n * return <MainContent />;\n * }\n * ```\n */\nexport function useUserContext(user: UserContext | null) {\n const { setUser, clearUser } = useErrorExplorer();\n const previousUser = useRef<UserContext | null>(null);\n\n useEffect(() => {\n // Only update if user changed\n if (JSON.stringify(user) !== JSON.stringify(previousUser.current)) {\n if (user) {\n setUser(user);\n } else {\n clearUser();\n }\n previousUser.current = user;\n }\n }, [user, setUser, clearUser]);\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n clearUser();\n };\n }, [clearUser]);\n\n return { setUser, clearUser };\n}\n\n/**\n * Action tracker hook for user interactions\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { trackAction, trackInteraction } = useActionTracker();\n *\n * const handleSubmit = () => {\n * trackAction('form_submitted', { formId: 'contact' });\n * // ... actual submit logic\n * };\n *\n * return (\n * <button\n * onClick={() => {\n * trackInteraction('submit-button', 'click');\n * handleSubmit();\n * }}\n * >\n * Submit\n * </button>\n * );\n * }\n * ```\n */\nexport function useActionTracker(componentName?: string) {\n const { addBreadcrumb } = useErrorExplorer();\n\n /**\n * Track a user action\n */\n const trackAction = useCallback(\n (action: string, data?: Record<string, unknown>) => {\n addBreadcrumb({\n type: 'user-action',\n category: 'action',\n message: action,\n level: 'info',\n data: {\n component: componentName,\n ...data,\n },\n });\n },\n [addBreadcrumb, componentName]\n );\n\n /**\n * Track a UI interaction\n */\n const trackInteraction = useCallback(\n (\n element: string,\n action: 'click' | 'input' | 'focus' | 'blur' | 'submit',\n data?: Record<string, unknown>\n ) => {\n addBreadcrumb({\n type: 'user-action',\n category: `ui.${action}`,\n message: `${action} on ${element}`,\n level: 'info',\n data: {\n component: componentName,\n element,\n ...data,\n },\n });\n },\n [addBreadcrumb, componentName]\n );\n\n return {\n trackAction,\n trackInteraction,\n };\n}\n\n/**\n * Component lifecycle tracking hook\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * useComponentBreadcrumbs('MyComponent');\n *\n * return <div>...</div>;\n * }\n * ```\n */\nexport function useComponentBreadcrumbs(componentName: string) {\n const { addBreadcrumb } = useErrorExplorer();\n\n useEffect(() => {\n addBreadcrumb({\n type: 'debug',\n category: 'react.lifecycle',\n message: `${componentName} mounted`,\n level: 'debug',\n });\n\n return () => {\n addBreadcrumb({\n type: 'debug',\n category: 'react.lifecycle',\n message: `${componentName} unmounted`,\n level: 'debug',\n });\n };\n }, [componentName, addBreadcrumb]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,mBAAmF;AACnF,qBAA8B;AA+E1B;AAxEG,IAAM,2BAAuB,4BAAgD,IAAI;AAwBjF,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AACF,GAGG;AACD,QAAM,CAAC,eAAe,gBAAgB,QAAI,uBAAS,KAAK;AAGxD,8BAAU,MAAM;AACd,QAAI,CAA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Ac;AAAA,QACZ,MAAM;AAAA,QACN,UAAU;AAAA,QACV,SAAS,GAAG,aAAa;AAAA,QACzB,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,eAAe,aAAa,CAAC;AACnC;;;AHxQA,IAAAC,kBAA8B;AAG9B,IAAO,cAAQ;","names":["import_react","import_browser","import_jsx_runtime","Component","React","import_react","import_browser","import_browser"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/context.tsx","../src/ErrorBoundary.tsx","../src/hooks.ts"],"sourcesContent":["/**\n * @error-explorer/react\n * Error Explorer SDK for React - Automatic error tracking with React integration\n */\n\n// Import for default export\nimport { ErrorExplorerProvider as Provider } from './context';\n\n// Provider and initialization\nexport { ErrorExplorerProvider, ErrorExplorerContext, initErrorExplorer } from './context';\n\n// Error Boundary\nexport { ErrorBoundary, withErrorBoundary, useErrorBoundary } from './ErrorBoundary';\n\n// Hooks\nexport {\n useErrorExplorer,\n useErrorHandler,\n useUserContext,\n useActionTracker,\n useComponentBreadcrumbs,\n} from './hooks';\n\n// Types\nexport type {\n ReactErrorExplorerOptions,\n ReactComponentContext,\n ErrorBoundaryProps,\n ErrorBoundaryState,\n FallbackProps,\n ErrorExplorerProviderProps,\n ErrorExplorerContextValue,\n WithErrorBoundaryOptions,\n InitOptions,\n UserContext,\n Breadcrumb,\n CaptureContext,\n} from './types';\n\n// Re-export ErrorExplorer for direct access\nexport { ErrorExplorer } from '@error-explorer/browser';\n\n// Default export is the provider for convenience\nexport default Provider;\n","/**\n * React Context Provider for Error Explorer\n */\n\nimport React, { createContext, useEffect, useState, useMemo, type ReactNode } from 'react';\nimport { ErrorExplorer } from '@error-explorer/browser';\nimport type { Breadcrumb, CaptureContext, UserContext } from '@error-explorer/browser';\nimport type { ReactErrorExplorerOptions, ErrorExplorerContextValue } from './types';\n\n/**\n * React Context for Error Explorer\n */\nexport const ErrorExplorerContext = createContext<ErrorExplorerContextValue | null>(null);\n\n/**\n * Error Explorer Provider Component\n *\n * Initializes the Error Explorer SDK and provides context to child components.\n *\n * @example\n * ```tsx\n * function App() {\n * return (\n * <ErrorExplorerProvider\n * options={{\n * token: 'ee_your_token',\n * project: 'my-react-app',\n * environment: 'production',\n * }}\n * >\n * <MainContent />\n * </ErrorExplorerProvider>\n * );\n * }\n * ```\n */\nexport function ErrorExplorerProvider({\n options,\n children,\n}: {\n options: ReactErrorExplorerOptions;\n children: ReactNode;\n}) {\n const [isInitialized, setIsInitialized] = useState(false);\n\n // Initialize on mount\n useEffect(() => {\n if (!ErrorExplorer.isInitialized()) {\n ErrorExplorer.init(options);\n setIsInitialized(true);\n } else {\n setIsInitialized(true);\n }\n\n // Cleanup on unmount\n return () => {\n // Don't close on unmount as other components might still need it\n // ErrorExplorer.close();\n };\n }, []); // Only run once on mount\n\n // Create stable context value\n const contextValue = useMemo<ErrorExplorerContextValue>(\n () => ({\n isInitialized,\n captureException: (error: Error, context?: CaptureContext) =>\n ErrorExplorer.captureException(error, context),\n captureMessage: (message: string, level?: 'debug' | 'info' | 'warning' | 'error' | 'critical') =>\n ErrorExplorer.captureMessage(message, level),\n addBreadcrumb: (breadcrumb: Breadcrumb) => ErrorExplorer.addBreadcrumb(breadcrumb),\n setUser: (user: UserContext) => ErrorExplorer.setUser(user),\n clearUser: () => ErrorExplorer.clearUser(),\n setTag: (key: string, value: string) => ErrorExplorer.setTag(key, value),\n setTags: (tags: Record<string, string>) => ErrorExplorer.setTags(tags),\n setExtra: (extra: Record<string, unknown>) => ErrorExplorer.setExtra(extra),\n setContext: (name: string, context: Record<string, unknown>) =>\n ErrorExplorer.setContext(name, context),\n flush: (timeout?: number) => ErrorExplorer.flush(timeout),\n close: (timeout?: number) => ErrorExplorer.close(timeout),\n }),\n [isInitialized]\n );\n\n return (\n <ErrorExplorerContext.Provider value={contextValue}>\n {children}\n </ErrorExplorerContext.Provider>\n );\n}\n\n/**\n * Initialize Error Explorer directly (without provider)\n *\n * Use this if you don't need the React Context and just want to initialize\n * the SDK globally.\n *\n * @example\n * ```tsx\n * // In your entry file (main.tsx)\n * import { initErrorExplorer } from '@error-explorer/react';\n *\n * initErrorExplorer({\n * token: 'ee_your_token',\n * project: 'my-react-app',\n * environment: 'production',\n * });\n *\n * ReactDOM.createRoot(root).render(<App />);\n * ```\n */\nexport function initErrorExplorer(options: ReactErrorExplorerOptions): void {\n if (!ErrorExplorer.isInitialized()) {\n ErrorExplorer.init(options);\n }\n}\n","/**\n * ErrorBoundary component for React\n * Catches errors in child components and reports them to Error Explorer\n */\n\nimport React, { Component, type ReactNode, type ComponentType } from 'react';\nimport { ErrorExplorer } from '@error-explorer/browser';\nimport type {\n ErrorBoundaryProps,\n ErrorBoundaryState,\n FallbackProps,\n WithErrorBoundaryOptions,\n} from './types';\n\n/**\n * Default fallback component\n */\nconst DefaultFallback: React.FC<FallbackProps> = ({ error, resetErrorBoundary }) => (\n <div\n role=\"alert\"\n style={{\n padding: '20px',\n border: '1px solid #f5c6cb',\n borderRadius: '4px',\n backgroundColor: '#f8d7da',\n color: '#721c24',\n }}\n >\n <h2 style={{ margin: '0 0 10px 0' }}>Something went wrong</h2>\n <pre style={{\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n backgroundColor: 'rgba(0,0,0,0.1)',\n padding: '10px',\n borderRadius: '4px',\n fontSize: '14px',\n }}>\n {error.message}\n </pre>\n <button\n onClick={resetErrorBoundary}\n style={{\n marginTop: '10px',\n padding: '8px 16px',\n backgroundColor: '#721c24',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer',\n }}\n >\n Try again\n </button>\n </div>\n);\n\n/**\n * ErrorBoundary class component\n *\n * React Error Boundaries must be class components - there's no hook equivalent.\n *\n * @example\n * ```tsx\n * <ErrorBoundary fallback={<ErrorFallback />}>\n * <MyComponent />\n * </ErrorBoundary>\n * ```\n *\n * @example\n * With render prop fallback:\n * ```tsx\n * <ErrorBoundary\n * fallback={({ error, resetErrorBoundary }) => (\n * <div>\n * <p>Error: {error.message}</p>\n * <button onClick={resetErrorBoundary}>Retry</button>\n * </div>\n * )}\n * >\n * <MyComponent />\n * </ErrorBoundary>\n * ```\n */\nexport class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\n static defaultProps = {\n capture: true,\n captureComponentStack: true,\n tags: {},\n context: {},\n };\n\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {\n hasError: false,\n error: null,\n errorInfo: null,\n };\n }\n\n static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState> {\n return {\n hasError: true,\n error,\n };\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {\n this.setState({ errorInfo });\n\n const {\n capture = true,\n captureComponentStack = true,\n beforeReactCapture,\n tags = {},\n context = {},\n onError,\n } = this.props;\n\n // Call user's error handler\n if (onError) {\n onError(error, errorInfo);\n }\n\n // Check if capture is enabled\n if (!capture) {\n return;\n }\n\n // Call beforeReactCapture hook - if it returns false, skip capturing\n if (beforeReactCapture) {\n const shouldCapture = beforeReactCapture(error, errorInfo);\n if (shouldCapture === false) {\n return;\n }\n }\n\n // Build extra context\n const extra: Record<string, unknown> = { ...context };\n\n // Only include component stack if enabled\n if (captureComponentStack && errorInfo.componentStack) {\n extra.componentStack = errorInfo.componentStack;\n }\n\n // Capture to Error Explorer\n ErrorExplorer.captureException(error, {\n tags: {\n 'react.errorBoundary': 'true',\n ...tags,\n },\n extra,\n });\n }\n\n componentDidUpdate(prevProps: ErrorBoundaryProps): void {\n const { resetKeys } = this.props;\n const { hasError } = this.state;\n\n // Reset if resetKeys changed\n if (hasError && resetKeys && prevProps.resetKeys) {\n const hasResetKeyChanged = resetKeys.some(\n (key, index) => key !== prevProps.resetKeys?.[index]\n );\n\n if (hasResetKeyChanged) {\n this.reset();\n }\n }\n }\n\n reset = (): void => {\n const { onReset } = this.props;\n\n this.setState({\n hasError: false,\n error: null,\n errorInfo: null,\n });\n\n if (onReset) {\n onReset();\n }\n };\n\n render(): ReactNode {\n const { hasError, error, errorInfo } = this.state;\n const { children, fallback } = this.props;\n\n if (hasError && error) {\n const fallbackProps: FallbackProps = {\n error,\n errorInfo,\n resetErrorBoundary: this.reset,\n };\n\n // Render function fallback\n if (typeof fallback === 'function') {\n return fallback(fallbackProps);\n }\n\n // Static fallback\n if (fallback) {\n return fallback;\n }\n\n // Default fallback\n return <DefaultFallback {...fallbackProps} />;\n }\n\n return children;\n }\n}\n\n/**\n * Higher-order component to wrap a component with ErrorBoundary\n *\n * @example\n * ```tsx\n * const SafeComponent = withErrorBoundary(MyComponent, {\n * fallback: <ErrorFallback />,\n * onError: (error) => console.error(error),\n * });\n * ```\n */\nexport function withErrorBoundary<P extends object>(\n Component: ComponentType<P>,\n options: WithErrorBoundaryOptions = {}\n): ComponentType<P> {\n const {\n fallback,\n onError,\n capture = true,\n captureComponentStack = true,\n beforeReactCapture,\n tags = {},\n context = {},\n } = options;\n\n const Wrapped: React.FC<P> = (props) => (\n <ErrorBoundary\n fallback={fallback}\n onError={onError}\n capture={capture}\n captureComponentStack={captureComponentStack}\n beforeReactCapture={beforeReactCapture}\n tags={tags}\n context={context}\n >\n <Component {...props} />\n </ErrorBoundary>\n );\n\n // Preserve display name for debugging\n const displayName = Component.displayName || Component.name || 'Component';\n Wrapped.displayName = `withErrorBoundary(${displayName})`;\n\n return Wrapped;\n}\n\n/**\n * useErrorBoundary hook for functional components\n *\n * Note: This doesn't create an error boundary - those must be class components.\n * Instead, this provides a way to show/trigger the nearest error boundary.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { showBoundary } = useErrorBoundary();\n *\n * const handleClick = async () => {\n * try {\n * await riskyOperation();\n * } catch (error) {\n * showBoundary(error);\n * }\n * };\n * }\n * ```\n */\nexport function useErrorBoundary() {\n const [error, setError] = React.useState<Error | null>(null);\n\n // If there's an error, throw it to be caught by the nearest error boundary\n if (error) {\n throw error;\n }\n\n return {\n /**\n * Trigger the nearest error boundary with the given error\n */\n showBoundary: (err: Error) => setError(err),\n\n /**\n * Reset the error state\n */\n resetBoundary: () => setError(null),\n };\n}\n","/**\n * React Hooks for Error Explorer\n */\n\nimport { useContext, useEffect, useCallback, useRef } from 'react';\nimport { ErrorExplorer } from '@error-explorer/browser';\nimport type { Breadcrumb, CaptureContext, UserContext } from '@error-explorer/browser';\nimport { ErrorExplorerContext } from './context';\n\n/**\n * Use Error Explorer instance\n *\n * Returns the Error Explorer SDK methods for capturing errors and managing context.\n *\n * @example\n * ```tsx\n * const { captureException, addBreadcrumb, setUser } = useErrorExplorer();\n *\n * try {\n * await riskyOperation();\n * } catch (error) {\n * captureException(error);\n * }\n * ```\n */\nexport function useErrorExplorer() {\n // Try to get from context first (if using provider)\n const contextValue = useContext(ErrorExplorerContext);\n\n // If context is available and initialized, use it\n if (contextValue?.isInitialized) {\n return contextValue;\n }\n\n // Fall back to singleton\n return {\n isInitialized: ErrorExplorer.isInitialized(),\n captureException: (error: Error, context?: CaptureContext) =>\n ErrorExplorer.captureException(error, context),\n captureMessage: (message: string, level?: 'debug' | 'info' | 'warning' | 'error' | 'critical') =>\n ErrorExplorer.captureMessage(message, level),\n addBreadcrumb: (breadcrumb: Breadcrumb) => ErrorExplorer.addBreadcrumb(breadcrumb),\n setUser: (user: UserContext) => ErrorExplorer.setUser(user),\n clearUser: () => ErrorExplorer.clearUser(),\n setTag: (key: string, value: string) => ErrorExplorer.setTag(key, value),\n setTags: (tags: Record<string, string>) => ErrorExplorer.setTags(tags),\n setExtra: (extra: Record<string, unknown>) => ErrorExplorer.setExtra(extra),\n setContext: (name: string, context: Record<string, unknown>) =>\n ErrorExplorer.setContext(name, context),\n flush: (timeout?: number) => ErrorExplorer.flush(timeout),\n close: (timeout?: number) => ErrorExplorer.close(timeout),\n };\n}\n\n/**\n * Error handler hook for async operations\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { handleError, wrapAsync } = useErrorHandler();\n *\n * // Option 1: Wrap async function\n * const safeSubmit = wrapAsync(async () => {\n * await api.submit(data);\n * });\n *\n * // Option 2: Manual handling\n * const handleClick = async () => {\n * try {\n * await riskyOperation();\n * } catch (error) {\n * handleError(error, { tags: { operation: 'risky' } });\n * }\n * };\n * }\n * ```\n */\nexport function useErrorHandler(defaultContext?: CaptureContext) {\n const { captureException } = useErrorExplorer();\n\n /**\n * Handle an error with optional context\n */\n const handleError = useCallback(\n (error: unknown, context?: CaptureContext): Error => {\n const err = error instanceof Error ? error : new Error(String(error));\n\n captureException(err, {\n ...defaultContext,\n ...context,\n tags: {\n ...defaultContext?.tags,\n ...context?.tags,\n },\n extra: {\n ...defaultContext?.extra,\n ...context?.extra,\n },\n });\n\n return err;\n },\n [captureException, defaultContext]\n );\n\n /**\n * Wrap an async function with error handling\n */\n const wrapAsync = useCallback(\n <T extends (...args: any[]) => Promise<any>>(\n fn: T,\n context?: CaptureContext\n ): ((...args: Parameters<T>) => Promise<Awaited<ReturnType<T>> | undefined>) => {\n return async (...args: Parameters<T>) => {\n try {\n return await fn(...args);\n } catch (error) {\n handleError(error, context);\n return undefined;\n }\n };\n },\n [handleError]\n );\n\n /**\n * Create a try-catch wrapper that captures errors\n */\n const tryCatch = useCallback(\n <T>(fn: () => T, context?: CaptureContext): T | undefined => {\n try {\n return fn();\n } catch (error) {\n handleError(error, context);\n return undefined;\n }\n },\n [handleError]\n );\n\n return {\n handleError,\n wrapAsync,\n tryCatch,\n };\n}\n\n/**\n * User context hook\n *\n * Sets the user context and cleans up on unmount.\n *\n * @example\n * ```tsx\n * function App() {\n * const user = useCurrentUser();\n *\n * useUserContext(user ? {\n * id: user.id,\n * email: user.email,\n * name: user.name,\n * } : null);\n *\n * return <MainContent />;\n * }\n * ```\n */\nexport function useUserContext(user: UserContext | null) {\n const { setUser, clearUser } = useErrorExplorer();\n const previousUser = useRef<UserContext | null>(null);\n\n useEffect(() => {\n // Only update if user changed\n if (JSON.stringify(user) !== JSON.stringify(previousUser.current)) {\n if (user) {\n setUser(user);\n } else {\n clearUser();\n }\n previousUser.current = user;\n }\n }, [user, setUser, clearUser]);\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n clearUser();\n };\n }, [clearUser]);\n\n return { setUser, clearUser };\n}\n\n/**\n * Action tracker hook for user interactions\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { trackAction, trackInteraction } = useActionTracker();\n *\n * const handleSubmit = () => {\n * trackAction('form_submitted', { formId: 'contact' });\n * // ... actual submit logic\n * };\n *\n * return (\n * <button\n * onClick={() => {\n * trackInteraction('submit-button', 'click');\n * handleSubmit();\n * }}\n * >\n * Submit\n * </button>\n * );\n * }\n * ```\n */\nexport function useActionTracker(componentName?: string) {\n const { addBreadcrumb } = useErrorExplorer();\n\n /**\n * Track a user action\n */\n const trackAction = useCallback(\n (action: string, data?: Record<string, unknown>) => {\n addBreadcrumb({\n type: 'user-action',\n category: 'action',\n message: action,\n level: 'info',\n data: {\n component: componentName,\n ...data,\n },\n });\n },\n [addBreadcrumb, componentName]\n );\n\n /**\n * Track a UI interaction\n */\n const trackInteraction = useCallback(\n (\n element: string,\n action: 'click' | 'input' | 'focus' | 'blur' | 'submit',\n data?: Record<string, unknown>\n ) => {\n addBreadcrumb({\n type: 'user-action',\n category: `ui.${action}`,\n message: `${action} on ${element}`,\n level: 'info',\n data: {\n component: componentName,\n element,\n ...data,\n },\n });\n },\n [addBreadcrumb, componentName]\n );\n\n return {\n trackAction,\n trackInteraction,\n };\n}\n\n/**\n * Component lifecycle tracking hook\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * useComponentBreadcrumbs('MyComponent');\n *\n * return <div>...</div>;\n * }\n * ```\n */\nexport function useComponentBreadcrumbs(componentName: string) {\n const { addBreadcrumb } = useErrorExplorer();\n\n useEffect(() => {\n addBreadcrumb({\n type: 'debug',\n category: 'react.lifecycle',\n message: `${componentName} mounted`,\n level: 'debug',\n });\n\n return () => {\n addBreadcrumb({\n type: 'debug',\n category: 'react.lifecycle',\n message: `${componentName} unmounted`,\n level: 'debug',\n });\n };\n }, [componentName, addBreadcrumb]);\n}\n"],"mappings":";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ACJ,WAAW;AAAA,UACX,GAAG;AAAA,QACL;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,eAAe,aAAa;AAAA,EAC/B;AAKA,QAAM,uBAAmB;AAAA,IACvB,CACE,SACA,QACA,SACG;AACH,oBAAc;AAAA,QACZ,MAAM;AAAA,QACN,UAAU,MAAM,MAAM;AAAA,QACtB,SAAS,GAAG,MAAM,OAAO,OAAO;AAAA,QAChC,OAAO;AAAA,QACP,MAAM;AAAA,UACJ,WAAW;AAAA,UACX;AAAA,UACA,GAAG;AAAA,QACL;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,eAAe,aAAa;AAAA,EAC/B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAcO,SAAS,wBAAwB,eAAuB;AAC7D,QAAM,EAAE,cAAc,IAAI,iBAAiB;AAE3C,+BAAU,MAAM;AACd,kBAAc;AAAA,MACZ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS,GAAG,aAAa;AAAA,MACzB,OAAO;AAAA,IACT,CAAC;AAED,WAAO,MAAM;AACX,oBAAc;AAAA,QACZ,MAAM;AAAA,QACN,UAAU;AAAA,QACV,SAAS,GAAG,aAAa;AAAA,QACzB,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,eAAe,aAAa,CAAC;AACnC;;;AHxQA,IAAAC,kBAA8B;AAG9B,IAAO,cAAQ;","names":["import_react","import_browser","import_jsx_runtime","Component","React","import_react","import_browser","import_browser"]}
package/dist/index.d.cts CHANGED
@@ -64,6 +64,16 @@ interface ErrorBoundaryProps {
64
64
  * @default true
65
65
  */
66
66
  capture?: boolean;
67
+ /**
68
+ * Whether to capture React component stack traces
69
+ * @default true
70
+ */
71
+ captureComponentStack?: boolean;
72
+ /**
73
+ * Hook called before capturing a React error
74
+ * Return false to skip capturing
75
+ */
76
+ beforeReactCapture?: (error: Error, errorInfo: React.ErrorInfo) => boolean;
67
77
  /**
68
78
  * Additional tags to add when capturing
69
79
  */
@@ -185,6 +195,16 @@ interface WithErrorBoundaryOptions {
185
195
  * @default true
186
196
  */
187
197
  capture?: boolean;
198
+ /**
199
+ * Whether to capture React component stack traces
200
+ * @default true
201
+ */
202
+ captureComponentStack?: boolean;
203
+ /**
204
+ * Hook called before capturing a React error
205
+ * Return false to skip capturing
206
+ */
207
+ beforeReactCapture?: (error: Error, errorInfo: React.ErrorInfo) => boolean;
188
208
  /**
189
209
  * Additional tags to add when capturing
190
210
  */
@@ -282,6 +302,7 @@ declare function initErrorExplorer(options: ReactErrorExplorerOptions): void;
282
302
  declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
283
303
  static defaultProps: {
284
304
  capture: boolean;
305
+ captureComponentStack: boolean;
285
306
  tags: {};
286
307
  context: {};
287
308
  };
package/dist/index.d.ts CHANGED
@@ -64,6 +64,16 @@ interface ErrorBoundaryProps {
64
64
  * @default true
65
65
  */
66
66
  capture?: boolean;
67
+ /**
68
+ * Whether to capture React component stack traces
69
+ * @default true
70
+ */
71
+ captureComponentStack?: boolean;
72
+ /**
73
+ * Hook called before capturing a React error
74
+ * Return false to skip capturing
75
+ */
76
+ beforeReactCapture?: (error: Error, errorInfo: React.ErrorInfo) => boolean;
67
77
  /**
68
78
  * Additional tags to add when capturing
69
79
  */
@@ -185,6 +195,16 @@ interface WithErrorBoundaryOptions {
185
195
  * @default true
186
196
  */
187
197
  capture?: boolean;
198
+ /**
199
+ * Whether to capture React component stack traces
200
+ * @default true
201
+ */
202
+ captureComponentStack?: boolean;
203
+ /**
204
+ * Hook called before capturing a React error
205
+ * Return false to skip capturing
206
+ */
207
+ beforeReactCapture?: (error: Error, errorInfo: React.ErrorInfo) => boolean;
188
208
  /**
189
209
  * Additional tags to add when capturing
190
210
  */
@@ -282,6 +302,7 @@ declare function initErrorExplorer(options: ReactErrorExplorerOptions): void;
282
302
  declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
283
303
  static defaultProps: {
284
304
  capture: boolean;
305
+ captureComponentStack: boolean;
285
306
  tags: {};
286
307
  context: {};
287
308
  };
package/dist/index.js CHANGED
@@ -115,22 +115,37 @@ var ErrorBoundary = class extends Component {
115
115
  }
116
116
  componentDidCatch(error, errorInfo) {
117
117
  this.setState({ errorInfo });
118
- const { capture = true, tags = {}, context = {}, onError } = this.props;
118
+ const {
119
+ capture = true,
120
+ captureComponentStack = true,
121
+ beforeReactCapture,
122
+ tags = {},
123
+ context = {},
124
+ onError
125
+ } = this.props;
119
126
  if (onError) {
120
127
  onError(error, errorInfo);
121
128
  }
122
- if (capture) {
123
- ErrorExplorer2.captureException(error, {
124
- tags: {
125
- "react.errorBoundary": "true",
126
- ...tags
127
- },
128
- extra: {
129
- componentStack: errorInfo.componentStack,
130
- ...context
131
- }
132
- });
129
+ if (!capture) {
130
+ return;
133
131
  }
132
+ if (beforeReactCapture) {
133
+ const shouldCapture = beforeReactCapture(error, errorInfo);
134
+ if (shouldCapture === false) {
135
+ return;
136
+ }
137
+ }
138
+ const extra = { ...context };
139
+ if (captureComponentStack && errorInfo.componentStack) {
140
+ extra.componentStack = errorInfo.componentStack;
141
+ }
142
+ ErrorExplorer2.captureException(error, {
143
+ tags: {
144
+ "react.errorBoundary": "true",
145
+ ...tags
146
+ },
147
+ extra
148
+ });
134
149
  }
135
150
  componentDidUpdate(prevProps) {
136
151
  const { resetKeys } = this.props;
@@ -166,17 +181,28 @@ var ErrorBoundary = class extends Component {
166
181
  };
167
182
  ErrorBoundary.defaultProps = {
168
183
  capture: true,
184
+ captureComponentStack: true,
169
185
  tags: {},
170
186
  context: {}
171
187
  };
172
188
  function withErrorBoundary(Component2, options = {}) {
173
- const { fallback, onError, capture = true, tags = {}, context = {} } = options;
189
+ const {
190
+ fallback,
191
+ onError,
192
+ capture = true,
193
+ captureComponentStack = true,
194
+ beforeReactCapture,
195
+ tags = {},
196
+ context = {}
197
+ } = options;
174
198
  const Wrapped = (props) => /* @__PURE__ */ jsx2(
175
199
  ErrorBoundary,
176
200
  {
177
201
  fallback,
178
202
  onError,
179
203
  capture,
204
+ captureComponentStack,
205
+ beforeReactCapture,
180
206
  tags,
181
207
  context,
182
208
  children: /* @__PURE__ */ jsx2(Component2, { ...props })
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context.tsx","../src/ErrorBoundary.tsx","../src/hooks.ts","../src/index.ts"],"sourcesContent":["/**\n * React Context Provider for Error Explorer\n */\n\nimport React, { createContext, useEffect, useState, useMemo, type ReactNode } from 'react';\nimport { ErrorExplorer } from '@error-explorer/browser';\nimport type { Breadcrumb, CaptureContext, UserContext } from '@error-explorer/browser';\nimport type { ReactErrorExplorerOptions, ErrorExplorerContextValue } from './types';\n\n/**\n * React Context for Error Explorer\n */\nexport const ErrorExplorerContext = createContext<ErrorExplorerContextValue | null>(null);\n\n/**\n * Error Explorer Provider Component\n *\n * Initializes the Error Explorer SDK and provides context to child components.\n *\n * @example\n * ```tsx\n * function App() {\n * return (\n * <ErrorExplorerProvider\n * options={{\n * token: 'ee_your_token',\n * project: 'my-react-app',\n * environment: 'production',\n * }}\n * >\n * <MainContent />\n * </ErrorExplorerProvider>\n * );\n * }\n * ```\n */\nexport function ErrorExplorerProvider({\n options,\n children,\n}: {\n options: ReactErrorExplorerOptions;\n children: ReactNode;\n}) {\n const [isInitialized, setIsInitialized] = useState(false);\n\n // Initialize on mount\n useEffect(() => {\n if (!ErrorExplorer.isInitialized()) {\n ErrorExplorer.init(options);\n setIsInitialized(true);\n } else {\n setIsInitialized(true);\n }\n\n // Cleanup on unmount\n return () => {\n // Don't close on unmount as other components might still need it\n // ErrorExplorer.close();\n };\n }, []); // Only run once on mount\n\n // Create stable context value\n const contextValue = useMemo<ErrorExplorerContextValue>(\n () => ({\n isInitialized,\n captureException: (error: Error, context?: CaptureContext) =>\n ErrorExplorer.captureException(error, context),\n captureMessage: (message: string, level?: 'debug' | 'info' | 'warning' | 'error' | 'critical') =>\n ErrorExplorer.captureMessage(message, level),\n addBreadcrumb: (breadcrumb: Breadcrumb) => ErrorExplorer.addBreadcrumb(breadcrumb),\n setUser: (user: UserContext) => ErrorExplorer.setUser(user),\n clearUser: () => ErrorExplorer.clearUser(),\n setTag: (key: string, value: string) => ErrorExplorer.setTag(key, value),\n setTags: (tags: Record<string, string>) => ErrorExplorer.setTags(tags),\n setExtra: (extra: Record<string, unknown>) => ErrorExplorer.setExtra(extra),\n setContext: (name: string, context: Record<string, unknown>) =>\n ErrorExplorer.setContext(name, context),\n flush: (timeout?: number) => ErrorExplorer.flush(timeout),\n close: (timeout?: number) => ErrorExplorer.close(timeout),\n }),\n [isInitialized]\n );\n\n return (\n <ErrorExplorerContext.Provider value={contextValue}>\n {children}\n </ErrorExplorerContext.Provider>\n );\n}\n\n/**\n * Initialize Error Explorer directly (without provider)\n *\n * Use this if you don't need the React Context and just want to initialize\n * the SDK globally.\n *\n * @example\n * ```tsx\n * // In your entry file (main.tsx)\n * import { initErrorExplorer } from '@error-explorer/react';\n *\n * initErrorExplorer({\n * token: 'ee_your_token',\n * project: 'my-react-app',\n * environment: 'production',\n * });\n *\n * ReactDOM.createRoot(root).render(<App />);\n * ```\n */\nexport function initErrorExplorer(options: ReactErrorExplorerOptions): void {\n if (!ErrorExplorer.isInitialized()) {\n ErrorExplorer.init(options);\n }\n}\n","/**\n * ErrorBoundary component for React\n * Catches errors in child components and reports them to Error Explorer\n */\n\nimport React, { Component, type ReactNode, type ComponentType } from 'react';\nimport { ErrorExplorer } from '@error-explorer/browser';\nimport type {\n ErrorBoundaryProps,\n ErrorBoundaryState,\n FallbackProps,\n WithErrorBoundaryOptions,\n} from './types';\n\n/**\n * Default fallback component\n */\nconst DefaultFallback: React.FC<FallbackProps> = ({ error, resetErrorBoundary }) => (\n <div\n role=\"alert\"\n style={{\n padding: '20px',\n border: '1px solid #f5c6cb',\n borderRadius: '4px',\n backgroundColor: '#f8d7da',\n color: '#721c24',\n }}\n >\n <h2 style={{ margin: '0 0 10px 0' }}>Something went wrong</h2>\n <pre style={{\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n backgroundColor: 'rgba(0,0,0,0.1)',\n padding: '10px',\n borderRadius: '4px',\n fontSize: '14px',\n }}>\n {error.message}\n </pre>\n <button\n onClick={resetErrorBoundary}\n style={{\n marginTop: '10px',\n padding: '8px 16px',\n backgroundColor: '#721c24',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer',\n }}\n >\n Try again\n </button>\n </div>\n);\n\n/**\n * ErrorBoundary class component\n *\n * React Error Boundaries must be class components - there's no hook equivalent.\n *\n * @example\n * ```tsx\n * <ErrorBoundary fallback={<ErrorFallback />}>\n * <MyComponent />\n * </ErrorBoundary>\n * ```\n *\n * @example\n * With render prop fallback:\n * ```tsx\n * <ErrorBoundary\n * fallback={({ error, resetErrorBoundary }) => (\n * <div>\n * <p>Error: {error.message}</p>\n * <button onClick={resetErrorBoundary}>Retry</button>\n * </div>\n * )}\n * >\n * <MyComponent />\n * </ErrorBoundary>\n * ```\n */\nexport class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\n static defaultProps = {\n capture: true,\n tags: {},\n context: {},\n };\n\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {\n hasError: false,\n error: null,\n errorInfo: null,\n };\n }\n\n static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState> {\n return {\n hasError: true,\n error,\n };\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {\n this.setState({ errorInfo });\n\n const { capture = true, tags = {}, context = {}, onError } = this.props;\n\n // Call user's error handler\n if (onError) {\n onError(error, errorInfo);\n }\n\n // Capture to Error Explorer\n if (capture) {\n ErrorExplorer.captureException(error, {\n tags: {\n 'react.errorBoundary': 'true',\n ...tags,\n },\n extra: {\n componentStack: errorInfo.componentStack,\n ...context,\n },\n });\n }\n }\n\n componentDidUpdate(prevProps: ErrorBoundaryProps): void {\n const { resetKeys } = this.props;\n const { hasError } = this.state;\n\n // Reset if resetKeys changed\n if (hasError && resetKeys && prevProps.resetKeys) {\n const hasResetKeyChanged = resetKeys.some(\n (key, index) => key !== prevProps.resetKeys?.[index]\n );\n\n if (hasResetKeyChanged) {\n this.reset();\n }\n }\n }\n\n reset = (): void => {\n const { onReset } = this.props;\n\n this.setState({\n hasError: false,\n error: null,\n errorInfo: null,\n });\n\n if (onReset) {\n onReset();\n }\n };\n\n render(): ReactNode {\n const { hasError, error, errorInfo } = this.state;\n const { children, fallback } = this.props;\n\n if (hasError && error) {\n const fallbackProps: FallbackProps = {\n error,\n errorInfo,\n resetErrorBoundary: this.reset,\n };\n\n // Render function fallback\n if (typeof fallback === 'function') {\n return fallback(fallbackProps);\n }\n\n // Static fallback\n if (fallback) {\n return fallback;\n }\n\n // Default fallback\n return <DefaultFallback {...fallbackProps} />;\n }\n\n return children;\n }\n}\n\n/**\n * Higher-order component to wrap a component with ErrorBoundary\n *\n * @example\n * ```tsx\n * const SafeComponent = withErrorBoundary(MyComponent, {\n * fallback: <ErrorFallback />,\n * onError: (error) => console.error(error),\n * });\n * ```\n */\nexport function withErrorBoundary<P extends object>(\n Component: ComponentType<P>,\n options: WithErrorBoundaryOptions = {}\n): ComponentType<P> {\n const { fallback, onError, capture = true, tags = {}, context = {} } = options;\n\n const Wrapped: React.FC<P> = (props) => (\n <ErrorBoundary\n fallback={fallback}\n onError={onError}\n capture={capture}\n tags={tags}\n context={context}\n >\n <Component {...props} />\n </ErrorBoundary>\n );\n\n // Preserve display name for debugging\n const displayName = Component.displayName || Component.name || 'Component';\n Wrapped.displayName = `withErrorBoundary(${displayName})`;\n\n return Wrapped;\n}\n\n/**\n * useErrorBoundary hook for functional components\n *\n * Note: This doesn't create an error boundary - those must be class components.\n * Instead, this provides a way to show/trigger the nearest error boundary.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { showBoundary } = useErrorBoundary();\n *\n * const handleClick = async () => {\n * try {\n * await riskyOperation();\n * } catch (error) {\n * showBoundary(error);\n * }\n * };\n * }\n * ```\n */\nexport function useErrorBoundary() {\n const [error, setError] = React.useState<Error | null>(null);\n\n // If there's an error, throw it to be caught by the nearest error boundary\n if (error) {\n throw error;\n }\n\n return {\n /**\n * Trigger the nearest error boundary with the given error\n */\n showBoundary: (err: Error) => setError(err),\n\n /**\n * Reset the error state\n */\n resetBoundary: () => setError(null),\n };\n}\n","/**\n * React Hooks for Error Explorer\n */\n\nimport { useContext, useEffect, useCallback, useRef } from 'react';\nimport { ErrorExplorer } from '@error-explorer/browser';\nimport type { Breadcrumb, CaptureContext, UserContext } from '@error-explorer/browser';\nimport { ErrorExplorerContext } from './context';\n\n/**\n * Use Error Explorer instance\n *\n * Returns the Error Explorer SDK methods for capturing errors and managing context.\n *\n * @example\n * ```tsx\n * const { captureException, addBreadcrumb, setUser } = useErrorExplorer();\n *\n * try {\n * await riskyOperation();\n * } catch (error) {\n * captureException(error);\n * }\n * ```\n */\nexport function useErrorExplorer() {\n // Try to get from context first (if using provider)\n const contextValue = useContext(ErrorExplorerContext);\n\n // If context is available and initialized, use it\n if (contextValue?.isInitialized) {\n return contextValue;\n }\n\n // Fall back to singleton\n return {\n isInitialized: ErrorExplorer.isInitialized(),\n captureException: (error: Error, context?: CaptureContext) =>\n ErrorExplorer.captureException(error, context),\n captureMessage: (message: string, level?: 'debug' | 'info' | 'warning' | 'error' | 'critical') =>\n ErrorExplorer.captureMessage(message, level),\n addBreadcrumb: (breadcrumb: Breadcrumb) => ErrorExplorer.addBreadcrumb(breadcrumb),\n setUser: (user: UserContext) => ErrorExplorer.setUser(user),\n clearUser: () => ErrorExplorer.clearUser(),\n setTag: (key: string, value: string) => ErrorExplorer.setTag(key, value),\n setTags: (tags: Record<string, string>) => ErrorExplorer.setTags(tags),\n setExtra: (extra: Record<string, unknown>) => ErrorExplorer.setExtra(extra),\n setContext: (name: string, context: Record<string, unknown>) =>\n ErrorExplorer.setContext(name, context),\n flush: (timeout?: number) => ErrorExplorer.flush(timeout),\n close: (timeout?: number) => ErrorExplorer.close(timeout),\n };\n}\n\n/**\n * Error handler hook for async operations\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { handleError, wrapAsync } = useErrorHandler();\n *\n * // Option 1: Wrap async function\n * const safeSubmit = wrapAsync(async () => {\n * await api.submit(data);\n * });\n *\n * // Option 2: Manual handling\n * const handleClick = async () => {\n * try {\n * await riskyOperation();\n * } catch (error) {\n * handleError(error, { tags: { operation: 'risky' } });\n * }\n * };\n * }\n * ```\n */\nexport function useErrorHandler(defaultContext?: CaptureContext) {\n const { captureException } = useErrorExplorer();\n\n /**\n * Handle an error with optional context\n */\n const handleError = useCallback(\n (error: unknown, context?: CaptureContext): Error => {\n const err = error instanceof Error ? error : new Error(String(error));\n\n captureException(err, {\n ...defaultContext,\n ...context,\n tags: {\n ...defaultContext?.tags,\n ...context?.tags,\n },\n extra: {\n ...defaultContext?.extra,\n ...context?.extra,\n },\n });\n\n return err;\n },\n [captureException, defaultContext]\n );\n\n /**\n * Wrap an async function with error handling\n */\n const wrapAsync = useCallback(\n <T extends (...args: any[]) => Promise<any>>(\n fn: T,\n context?: CaptureContext\n ): ((...args: Parameters<T>) => Promise<Awaited<ReturnType<T>> | undefined>) => {\n return async (...args: Parameters<T>) => {\n try {\n return await fn(...args);\n } catch (error) {\n handleError(error, context);\n return undefined;\n }\n };\n },\n [handleError]\n );\n\n /**\n * Create a try-catch wrapper that captures errors\n */\n const tryCatch = useCallback(\n <T>(fn: () => T, context?: CaptureContext): T | undefined => {\n try {\n return fn();\n } catch (error) {\n handleError(error, context);\n return undefined;\n }\n },\n [handleError]\n );\n\n return {\n handleError,\n wrapAsync,\n tryCatch,\n };\n}\n\n/**\n * User context hook\n *\n * Sets the user context and cleans up on unmount.\n *\n * @example\n * ```tsx\n * function App() {\n * const user = useCurrentUser();\n *\n * useUserContext(user ? {\n * id: user.id,\n * email: user.email,\n * name: user.name,\n * } : null);\n *\n * return <MainContent />;\n * }\n * ```\n */\nexport function useUserContext(user: UserContext | null) {\n const { setUser, clearUser } = useErrorExplorer();\n const previousUser = useRef<UserContext | null>(null);\n\n useEffect(() => {\n // Only update if user changed\n if (JSON.stringify(user) !== JSON.stringify(previousUser.current)) {\n if (user) {\n setUser(user);\n } else {\n clearUser();\n }\n previousUser.current = user;\n }\n }, [user, setUser, clearUser]);\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n clearUser();\n };\n }, [clearUser]);\n\n return { setUser, clearUser };\n}\n\n/**\n * Action tracker hook for user interactions\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { trackAction, trackInteraction } = useActionTracker();\n *\n * const handleSubmit = () => {\n * trackAction('form_submitted', { formId: 'contact' });\n * // ... actual submit logic\n * };\n *\n * return (\n * <button\n * onClick={() => {\n * trackInteraction('submit-button', 'click');\n * handleSubmit();\n * }}\n * >\n * Submit\n * </button>\n * );\n * }\n * ```\n */\nexport function useActionTracker(componentName?: string) {\n const { addBreadcrumb } = useErrorExplorer();\n\n /**\n * Track a user action\n */\n const trackAction = useCallback(\n (action: string, data?: Record<string, unknown>) => {\n addBreadcrumb({\n type: 'user-action',\n category: 'action',\n message: action,\n level: 'info',\n data: {\n component: componentName,\n ...data,\n },\n });\n },\n [addBreadcrumb, componentName]\n );\n\n /**\n * Track a UI interaction\n */\n const trackInteraction = useCallback(\n (\n element: string,\n action: 'click' | 'input' | 'focus' | 'blur' | 'submit',\n data?: Record<string, unknown>\n ) => {\n addBreadcrumb({\n type: 'user-action',\n category: `ui.${action}`,\n message: `${action} on ${element}`,\n level: 'info',\n data: {\n component: componentName,\n element,\n ...data,\n },\n });\n },\n [addBreadcrumb, componentName]\n );\n\n return {\n trackAction,\n trackInteraction,\n };\n}\n\n/**\n * Component lifecycle tracking hook\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * useComponentBreadcrumbs('MyComponent');\n *\n * return <div>...</div>;\n * }\n * ```\n */\nexport function useComponentBreadcrumbs(componentName: string) {\n const { addBreadcrumb } = useErrorExplorer();\n\n useEffect(() => {\n addBreadcrumb({\n type: 'debug',\n category: 'react.lifecycle',\n message: `${componentName} mounted`,\n level: 'debug',\n });\n\n return () => {\n addBreadcrumb({\n type: 'debug',\n category: 'react.lifecycle',\n message: `${componentName} unmounted`,\n level: 'debug',\n });\n };\n }, [componentName, addBreadcrumb]);\n}\n","/**\n * @error-explorer/react\n * Error Explorer SDK for React - Automatic error tracking with React integration\n */\n\n// Import for default export\nimport { ErrorExplorerProvider as Provider } from './context';\n\n// Provider and initialization\nexport { ErrorExplorerProvider, ErrorExplorerContext, initErrorExplorer } from './context';\n\n// Error Boundary\nexport { ErrorBoundary, withErrorBoundary, useErrorBoundary } from './ErrorBoundary';\n\n// Hooks\nexport {\n useErrorExplorer,\n useErrorHandler,\n useUserContext,\n useActionTracker,\n useComponentBreadcrumbs,\n} from './hooks';\n\n// Types\nexport type {\n ReactErrorExplorerOptions,\n ReactComponentContext,\n ErrorBoundaryProps,\n ErrorBoundaryState,\n FallbackProps,\n ErrorExplorerProviderProps,\n ErrorExplorerContextValue,\n WithErrorBoundaryOptions,\n InitOptions,\n UserContext,\n Breadcrumb,\n CaptureContext,\n} from './types';\n\n// Re-export ErrorExplorer for direct access\nexport { ErrorExplorer } from '@error-explorer/browser';\n\n// Default export is the provider for convenience\nexport default Provider;\n"],"mappings":";AAIA,SAAgB,eAAe,WAAW,UAAU,eAA+B;AACnF,SAAS,qBAAqB;AA+E1B;AAxEG,IAAM,uBAAuB,cAAgD,IAAI;AAwBjF,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AACF,GAGG;AACD,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,KAAK;AAGxD,YAAU,MAAM;AACd,QAAI,CAAC,cAAc,cAAc,GAAG;AAClC,oBAAc,KAAK,OAAO;AAC1B,uBAAiB,IAAI;AAAA,IACvB,OAAO;AACL,uBAAiB,IAAI;AAAA,IACvB;AAGA,WAAO,MAAM;AAAA,IAGb;AAAA,EACF,GAAG,CAAC,CAAC;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MACT,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,eAAe,aAAa,CAAC;AACnC;;;ACxQA,SAAS,iBAAAC,sBAAqB;AAG9B,IAAO,cAAQ;","names":["React","ErrorExplorer","jsx","Component","useEffect","ErrorExplorer","ErrorExplorer","useEffect","ErrorExplorer"]}
1
+ {"version":3,"sources":["../src/context.tsx","../src/ErrorBoundary.tsx","../src/hooks.ts","../src/index.ts"],"sourcesContent":["/**\n * React Context Provider for Error Explorer\n */\n\nimport React, { createContext, useEffect, useState, useMemo, type ReactNode } from 'react';\nimport { ErrorExplorer } from '@error-explorer/browser';\nimport type { Breadcrumb, CaptureContext, UserContext } from '@error-explorer/browser';\nimport type { ReactErrorExplorerOptions, ErrorExplorerContextValue } from './types';\n\n/**\n * React Context for Error Explorer\n */\nexport const ErrorExplorerContext = createContext<ErrorExplorerContextValue | null>(null);\n\n/**\n * Error Explorer Provider Component\n *\n * Initializes the Error Explorer SDK and provides context to child components.\n *\n * @example\n * ```tsx\n * function App() {\n * return (\n * <ErrorExplorerProvider\n * options={{\n * token: 'ee_your_token',\n * project: 'my-react-app',\n * environment: 'production',\n * }}\n * >\n * <MainContent />\n * </ErrorExplorerProvider>\n * );\n * }\n * ```\n */\nexport function ErrorExplorerProvider({\n options,\n children,\n}: {\n options: ReactErrorExplorerOptions;\n children: ReactNode;\n}) {\n const [isInitialized, setIsInitialized] = useState(false);\n\n // Initialize on mount\n useEffect(() => {\n if (!ErrorExplorer.isInitialized()) {\n ErrorExplorer.init(options);\n setIsInitialized(true);\n } else {\n setIsInitialized(true);\n }\n\n // Cleanup on unmount\n return () => {\n // Don't close on unmount as other components might still need it\n // ErrorExplorer.close();\n };\n }, []); // Only run once on mount\n\n // Create stable context value\n const contextValue = useMemo<ErrorExplorerContextValue>(\n () => ({\n isInitialized,\n captureException: (error: Error, context?: CaptureContext) =>\n ErrorExplorer.captureException(error, context),\n captureMessage: (message: string, level?: 'debug' | 'info' | 'warning' | 'error' | 'critical') =>\n ErrorExplorer.captureMessage(message, level),\n addBreadcrumb: (breadcrumb: Breadcrumb) => ErrorExplorer.addBreadcrumb(breadcrumb),\n setUser: (user: UserContext) => ErrorExplorer.setUser(user),\n clearUser: () => ErrorExplorer.clearUser(),\n setTag: (key: string, value: string) => ErrorExplorer.setTag(key, value),\n setTags: (tags: Record<string, string>) => ErrorExplorer.setTags(tags),\n setExtra: (extra: Record<string, unknown>) => ErrorExplorer.setExtra(extra),\n setContext: (name: string, context: Record<string, unknown>) =>\n ErrorExplorer.setContext(name, context),\n flush: (timeout?: number) => ErrorExplorer.flush(timeout),\n close: (timeout?: number) => ErrorExplorer.close(timeout),\n }),\n [isInitialized]\n );\n\n return (\n <ErrorExplorerContext.Provider value={contextValue}>\n {children}\n </ErrorExplorerContext.Provider>\n );\n}\n\n/**\n * Initialize Error Explorer directly (without provider)\n *\n * Use this if you don't need the React Context and just want to initialize\n * the SDK globally.\n *\n * @example\n * ```tsx\n * // In your entry file (main.tsx)\n * import { initErrorExplorer } from '@error-explorer/react';\n *\n * initErrorExplorer({\n * token: 'ee_your_token',\n * project: 'my-react-app',\n * environment: 'production',\n * });\n *\n * ReactDOM.createRoot(root).render(<App />);\n * ```\n */\nexport function initErrorExplorer(options: ReactErrorExplorerOptions): void {\n if (!ErrorExplorer.isInitialized()) {\n ErrorExplorer.init(options);\n }\n}\n","/**\n * ErrorBoundary component for React\n * Catches errors in child components and reports them to Error Explorer\n */\n\nimport React, { Component, type ReactNode, type ComponentType } from 'react';\nimport { ErrorExplorer } from '@error-explorer/browser';\nimport type {\n ErrorBoundaryProps,\n ErrorBoundaryState,\n FallbackProps,\n WithErrorBoundaryOptions,\n} from './types';\n\n/**\n * Default fallback component\n */\nconst DefaultFallback: React.FC<FallbackProps> = ({ error, resetErrorBoundary }) => (\n <div\n role=\"alert\"\n style={{\n padding: '20px',\n border: '1px solid #f5c6cb',\n borderRadius: '4px',\n backgroundColor: '#f8d7da',\n color: '#721c24',\n }}\n >\n <h2 style={{ margin: '0 0 10px 0' }}>Something went wrong</h2>\n <pre style={{\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n backgroundColor: 'rgba(0,0,0,0.1)',\n padding: '10px',\n borderRadius: '4px',\n fontSize: '14px',\n }}>\n {error.message}\n </pre>\n <button\n onClick={resetErrorBoundary}\n style={{\n marginTop: '10px',\n padding: '8px 16px',\n backgroundColor: '#721c24',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer',\n }}\n >\n Try again\n </button>\n </div>\n);\n\n/**\n * ErrorBoundary class component\n *\n * React Error Boundaries must be class components - there's no hook equivalent.\n *\n * @example\n * ```tsx\n * <ErrorBoundary fallback={<ErrorFallback />}>\n * <MyComponent />\n * </ErrorBoundary>\n * ```\n *\n * @example\n * With render prop fallback:\n * ```tsx\n * <ErrorBoundary\n * fallback={({ error, resetErrorBoundary }) => (\n * <div>\n * <p>Error: {error.message}</p>\n * <button onClick={resetErrorBoundary}>Retry</button>\n * </div>\n * )}\n * >\n * <MyComponent />\n * </ErrorBoundary>\n * ```\n */\nexport class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\n static defaultProps = {\n capture: true,\n captureComponentStack: true,\n tags: {},\n context: {},\n };\n\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {\n hasError: false,\n error: null,\n errorInfo: null,\n };\n }\n\n static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState> {\n return {\n hasError: true,\n error,\n };\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {\n this.setState({ errorInfo });\n\n const {\n capture = true,\n captureComponentStack = true,\n beforeReactCapture,\n tags = {},\n context = {},\n onError,\n } = this.props;\n\n // Call user's error handler\n if (onError) {\n onError(error, errorInfo);\n }\n\n // Check if capture is enabled\n if (!capture) {\n return;\n }\n\n // Call beforeReactCapture hook - if it returns false, skip capturing\n if (beforeReactCapture) {\n const shouldCapture = beforeReactCapture(error, errorInfo);\n if (shouldCapture === false) {\n return;\n }\n }\n\n // Build extra context\n const extra: Record<string, unknown> = { ...context };\n\n // Only include component stack if enabled\n if (captureComponentStack && errorInfo.componentStack) {\n extra.componentStack = errorInfo.componentStack;\n }\n\n // Capture to Error Explorer\n ErrorExplorer.captureException(error, {\n tags: {\n 'react.errorBoundary': 'true',\n ...tags,\n },\n extra,\n });\n }\n\n componentDidUpdate(prevProps: ErrorBoundaryProps): void {\n const { resetKeys } = this.props;\n const { hasError } = this.state;\n\n // Reset if resetKeys changed\n if (hasError && resetKeys && prevProps.resetKeys) {\n const hasResetKeyChanged = resetKeys.some(\n (key, index) => key !== prevProps.resetKeys?.[index]\n );\n\n if (hasResetKeyChanged) {\n this.reset();\n }\n }\n }\n\n reset = (): void => {\n const { onReset } = this.props;\n\n this.setState({\n hasError: false,\n error: null,\n errorInfo: null,\n });\n\n if (onReset) {\n onReset();\n }\n };\n\n render(): ReactNode {\n const { hasError, error, errorInfo } = this.state;\n const { children, fallback } = this.props;\n\n if (hasError && error) {\n const fallbackProps: FallbackProps = {\n error,\n errorInfo,\n resetErrorBoundary: this.reset,\n };\n\n // Render function fallback\n if (typeof fallback === 'function') {\n return fallback(fallbackProps);\n }\n\n // Static fallback\n if (fallback) {\n return fallback;\n }\n\n // Default fallback\n return <DefaultFallback {...fallbackProps} />;\n }\n\n return children;\n }\n}\n\n/**\n * Higher-order component to wrap a component with ErrorBoundary\n *\n * @example\n * ```tsx\n * const SafeComponent = withErrorBoundary(MyComponent, {\n * fallback: <ErrorFallback />,\n * onError: (error) => console.error(error),\n * });\n * ```\n */\nexport function withErrorBoundary<P extends object>(\n Component: ComponentType<P>,\n options: WithErrorBoundaryOptions = {}\n): ComponentType<P> {\n const {\n fallback,\n onError,\n capture = true,\n captureComponentStack = true,\n beforeReactCapture,\n tags = {},\n context = {},\n } = options;\n\n const Wrapped: React.FC<P> = (props) => (\n <ErrorBoundary\n fallback={fallback}\n onError={onError}\n capture={capture}\n captureComponentStack={captureComponentStack}\n beforeReactCapture={beforeReactCapture}\n tags={tags}\n context={context}\n >\n <Component {...props} />\n </ErrorBoundary>\n );\n\n // Preserve display name for debugging\n const displayName = Component.displayName || Component.name || 'Component';\n Wrapped.displayName = `withErrorBoundary(${displayName})`;\n\n return Wrapped;\n}\n\n/**\n * useErrorBoundary hook for functional components\n *\n * Note: This doesn't create an error boundary - those must be class components.\n * Instead, this provides a way to show/trigger the nearest error boundary.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { showBoundary } = useErrorBoundary();\n *\n * const handleClick = async () => {\n * try {\n * await riskyOperation();\n * } catch (error) {\n * showBoundary(error);\n * }\n * };\n * }\n * ```\n */\nexport function useErrorBoundary() {\n const [error, setError] = React.useState<Error | null>(null);\n\n // If there's an error, throw it to be caught by the nearest error boundary\n if (error) {\n throw error;\n }\n\n return {\n /**\n * Trigger the nearest error boundary with the given error\n */\n showBoundary: (err: Error) => setError(err),\n\n /**\n * Reset the error state\n */\n resetBoundary: () => setError(null),\n };\n}\n","/**\n * React Hooks for Error Explorer\n */\n\nimport { useContext, useEffect, useCallback, useRef } from 'react';\nimport { ErrorExplorer } from '@error-explorer/browser';\nimport type { Breadcrumb, CaptureContext, UserContext } from '@error-explorer/browser';\nimport { ErrorExplorerContext } from './context';\n\n/**\n * Use Error Explorer instance\n *\n * Returns the Error Explorer SDK methods for capturing errors and managing context.\n *\n * @example\n * ```tsx\n * const { captureException, addBreadcrumb, setUser } = useErrorExplorer();\n *\n * try {\n * await riskyOperation();\n * } catch (error) {\n * captureException(error);\n * }\n * ```\n */\nexport function useErrorExplorer() {\n // Try to get from context first (if using provider)\n const contextValue = useContext(ErrorExplorerContext);\n\n // If context is available and initialized, use it\n if (contextValue?.isInitialized) {\n return contextValue;\n }\n\n // Fall back to singleton\n return {\n isInitialized: ErrorExplorer.isInitialized(),\n captureException: (error: Error, context?: CaptureContext) =>\n ErrorExplorer.captureException(error, context),\n captureMessage: (message: string, level?: 'debug' | 'info' | 'warning' | 'error' | 'critical') =>\n ErrorExplorer.captureMessage(message, level),\n addBreadcrumb: (breadcrumb: Breadcrumb) => ErrorExplorer.addBreadcrumb(breadcrumb),\n setUser: (user: UserContext) => ErrorExplorer.setUser(user),\n clearUser: () => ErrorExplorer.clearUser(),\n setTag: (key: string, value: string) => ErrorExplorer.setTag(key, value),\n setTags: (tags: Record<string, string>) => ErrorExplorer.setTags(tags),\n setExtra: (extra: Record<string, unknown>) => ErrorExplorer.setExtra(extra),\n setContext: (name: string, context: Record<string, unknown>) =>\n ErrorExplorer.setContext(name, context),\n flush: (timeout?: number) => ErrorExplorer.flush(timeout),\n close: (timeout?: number) => ErrorExplorer.close(timeout),\n };\n}\n\n/**\n * Error handler hook for async operations\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { handleError, wrapAsync } = useErrorHandler();\n *\n * // Option 1: Wrap async function\n * const safeSubmit = wrapAsync(async () => {\n * await api.submit(data);\n * });\n *\n * // Option 2: Manual handling\n * const handleClick = async () => {\n * try {\n * await riskyOperation();\n * } catch (error) {\n * handleError(error, { tags: { operation: 'risky' } });\n * }\n * };\n * }\n * ```\n */\nexport function useErrorHandler(defaultContext?: CaptureContext) {\n const { captureException } = useErrorExplorer();\n\n /**\n * Handle an error with optional context\n */\n const handleError = useCallback(\n (error: unknown, context?: CaptureContext): Error => {\n const err = error instanceof Error ? error : new Error(String(error));\n\n captureException(err, {\n ...defaultContext,\n ...context,\n tags: {\n ...defaultContext?.tags,\n ...context?.tags,\n },\n extra: {\n ...defaultContext?.extra,\n ...context?.extra,\n },\n });\n\n return err;\n },\n [captureException, defaultContext]\n );\n\n /**\n * Wrap an async function with error handling\n */\n const wrapAsync = useCallback(\n <T extends (...args: any[]) => Promise<any>>(\n fn: T,\n context?: CaptureContext\n ): ((...args: Parameters<T>) => Promise<Awaited<ReturnType<T>> | undefined>) => {\n return async (...args: Parameters<T>) => {\n try {\n return await fn(...args);\n } catch (error) {\n handleError(error, context);\n return undefined;\n }\n };\n },\n [handleError]\n );\n\n /**\n * Create a try-catch wrapper that captures errors\n */\n const tryCatch = useCallback(\n <T>(fn: () => T, context?: CaptureContext): T | undefined => {\n try {\n return fn();\n } catch (error) {\n handleError(error, context);\n return undefined;\n }\n },\n [handleError]\n );\n\n return {\n handleError,\n wrapAsync,\n tryCatch,\n };\n}\n\n/**\n * User context hook\n *\n * Sets the user context and cleans up on unmount.\n *\n * @example\n * ```tsx\n * function App() {\n * const user = useCurrentUser();\n *\n * useUserContext(user ? {\n * id: user.id,\n * email: user.email,\n * name: user.name,\n * } : null);\n *\n * return <MainContent />;\n * }\n * ```\n */\nexport function useUserContext(user: UserContext | null) {\n const { setUser, clearUser } = useErrorExplorer();\n const previousUser = useRef<UserContext | null>(null);\n\n useEffect(() => {\n // Only update if user changed\n if (JSON.stringify(user) !== JSON.stringify(previousUser.current)) {\n if (user) {\n setUser(user);\n } else {\n clearUser();\n }\n previousUser.current = user;\n }\n }, [user, setUser, clearUser]);\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n clearUser();\n };\n }, [clearUser]);\n\n return { setUser, clearUser };\n}\n\n/**\n * Action tracker hook for user interactions\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { trackAction, trackInteraction } = useActionTracker();\n *\n * const handleSubmit = () => {\n * trackAction('form_submitted', { formId: 'contact' });\n * // ... actual submit logic\n * };\n *\n * return (\n * <button\n * onClick={() => {\n * trackInteraction('submit-button', 'click');\n * handleSubmit();\n * }}\n * >\n * Submit\n * </button>\n * );\n * }\n * ```\n */\nexport function useActionTracker(componentName?: string) {\n const { addBreadcrumb } = useErrorExplorer();\n\n /**\n * Track a user action\n */\n const trackAction = useCallback(\n (action: string, data?: Record<string, unknown>) => {\n addBreadcrumb({\n type: 'user-action',\n category: 'action',\n message: action,\n level: 'info',\n data: {\n component: componentName,\n ...data,\n },\n });\n },\n [addBreadcrumb, componentName]\n );\n\n /**\n * Track a UI interaction\n */\n const trackInteraction = useCallback(\n (\n element: string,\n action: 'click' | 'input' | 'focus' | 'blur' | 'submit',\n data?: Record<string, unknown>\n ) => {\n addBreadcrumb({\n type: 'user-action',\n category: `ui.${action}`,\n message: `${action} on ${element}`,\n level: 'info',\n data: {\n component: componentName,\n element,\n ...data,\n },\n });\n },\n [addBreadcrumb, componentName]\n );\n\n return {\n trackAction,\n trackInteraction,\n };\n}\n\n/**\n * Component lifecycle tracking hook\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * useComponentBreadcrumbs('MyComponent');\n *\n * return <div>...</div>;\n * }\n * ```\n */\nexport function useComponentBreadcrumbs(componentName: string) {\n const { addBreadcrumb } = useErrorExplorer();\n\n useEffect(() => {\n addBreadcrumb({\n type: 'debug',\n category: 'react.lifecycle',\n message: `${componentName} mounted`,\n level: 'debug',\n });\n\n return () => {\n addBreadcrumb({\n type: 'debug',\n category: 'react.lifecycle',\n message: `${componentName} unmounted`,\n level: 'debug',\n });\n };\n }, [componentName, addBreadcrumb]);\n}\n","/**\n * @error-explorer/react\n * Error Explorer SDK for React - Automatic error tracking with React integration\n */\n\n// Import for default export\nimport { ErrorExplorerProvider as Provider } from './context';\n\n// Provider and initialization\nexport { ErrorExplorerProvider, ErrorExplorerContext, initErrorExplorer } from './context';\n\n// Error Boundary\nexport { ErrorBoundary, withErrorBoundary, useErrorBoundary } from './ErrorBoundary';\n\n// Hooks\nexport {\n useErrorExplorer,\n useErrorHandler,\n useUserContext,\n useActionTracker,\n useComponentBreadcrumbs,\n} from './hooks';\n\n// Types\nexport type {\n ReactErrorExplorerOptions,\n ReactComponentContext,\n ErrorBoundaryProps,\n ErrorBoundaryState,\n FallbackProps,\n ErrorExplorerProviderProps,\n ErrorExplorerContextValue,\n WithErrorBoundaryOptions,\n InitOptions,\n UserContext,\n Breadcrumb,\n CaptureContext,\n} from './types';\n\n// Re-export ErrorExplorer for direct access\nexport { ErrorExplorer } from '@error-explorer/browser';\n\n// Default export is the provider for convenience\nexport default Provider;\n"],"mappings":";AAIA,SAAgB,eAAe,WAAW,UAAU,eAA+B;AACnF,SAAS,qBAAqB;AA+E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A,EAC/B;AAKA,QAAM,mBAAmB;AAAA,IACvB,CACE,SACA,QACA,SACG;AACH,oBAAc;AAAA,QACZ,MAAM;AAAA,QACN,UAAU,MAAM,MAAM;AAAA,QACtB,SAAS,GAAG,MAAM,OAAO,OAAO;AAAA,QAChC,OAAO;AAAA,QACP,MAAM;AAAA,UACJ,WAAW;AAAA,UACX;AAAA,UACA,GAAG;AAAA,QACL;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,eAAe,aAAa;AAAA,EAC/B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAcO,SAAS,wBAAwB,eAAuB;AAC7D,QAAM,EAAE,cAAc,IAAI,iBAAiB;AAE3C,EAAAA,WAAU,MAAM;AACd,kBAAc;AAAA,MACZ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS,GAAG,aAAa;AAAA,MACzB,OAAO;AAAA,IACT,CAAC;AAED,WAAO,MAAM;AACX,oBAAc;AAAA,QACZ,MAAM;AAAA,QACN,UAAU;AAAA,QACV,SAAS,GAAG,aAAa;AAAA,QACzB,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,eAAe,aAAa,CAAC;AACnC;;;ACxQA,SAAS,iBAAAC,sBAAqB;AAG9B,IAAO,cAAQ;","names":["React","ErrorExplorer","jsx","Component","useEffect","ErrorExplorer","ErrorExplorer","useEffect","ErrorExplorer"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@error-explorer/react",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Error Explorer SDK for React - Automatic error tracking with React integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",