wingman-monitor
Version:
Runtime error monitoring package with React provider that automatically reports errors to webhook endpoints
83 lines • 2.53 kB
TypeScript
import React, { ReactNode } from 'react';
import { WingmanMonitor } from './monitor';
import { WingmanConfig } from './config';
interface WingmanContextType {
monitor: WingmanMonitor | null;
isActive: boolean;
}
export interface WingmanProviderProps {
children: ReactNode;
/**
* Custom configuration for Wingman Monitor
* If not provided, will load from wingman.config.json
*/
config?: Partial<WingmanConfig>;
/**
* Whether to automatically start monitoring when the provider mounts
* @default true
*/
autoStart?: boolean;
/**
* Custom project path for configuration loading
*/
projectPath?: string;
/**
* Enable error boundary for React component errors
* @default true
*/
enableErrorBoundary?: boolean;
/**
* Enable error reporting (overrides environment detection)
*/
enableErrorReporting?: boolean;
/**
* Enable performance monitoring
* @default true
*/
enablePerformanceMonitoring?: boolean;
}
interface WingmanProviderState {
hasError: boolean;
error?: Error;
isInitialized: boolean;
initError?: string;
}
export declare class WingmanProvider extends React.Component<WingmanProviderProps, WingmanProviderState> {
private monitor;
private isActive;
private handleError?;
private handleRejection?;
constructor(props: WingmanProviderProps);
static getDerivedStateFromError(error: Error): WingmanProviderState;
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
componentDidMount(): Promise<void>;
private setupGlobalErrorHandlers;
private removeGlobalErrorHandlers;
componentWillUnmount(): void;
render(): import("react/jsx-runtime").JSX.Element;
}
/**
* Hook to access the Wingman monitor instance and status
*/
export declare function useWingman(): WingmanContextType;
/**
* Hook to manually report errors to Wingman
*/
export declare function useWingmanReporting(): {
reportError: (error: Error | string, metadata?: Record<string, any>) => void;
reportInfo: (message: string, metadata?: Record<string, any>) => void;
isActive: boolean;
};
/**
* Hook to access environment configuration and settings
*/
export declare function useWingmanConfig(): {
isActive: boolean;
shouldReportErrors: boolean;
enableErrorReporting: boolean;
enablePerformanceMonitoring: boolean;
enableDebugLogs: boolean;
apiEndpoint: string;
};
export {};
//# sourceMappingURL=provider.d.ts.map