@meshed-monitor/sdk
Version:
Official JavaScript/TypeScript SDK for MeshedMonitor - All-in-one monitoring platform. Supports both CommonJS and ES Modules.
104 lines (102 loc) • 3.21 kB
TypeScript
interface MeshedMonitorConfig {
apiKey: string;
apiUrl?: string;
environment?: string;
release?: string;
userId?: string;
debug?: boolean;
enableErrorTracking?: boolean;
enableLogStreaming?: boolean;
enableSupport?: boolean;
maxBatchSize?: number;
flushInterval?: number;
}
interface ErrorData {
message: string;
stack?: string;
level?: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'FATAL';
userId?: string;
userAgent?: string;
url?: string;
file?: string;
line?: number;
column?: number;
tags?: Record<string, any>;
context?: Record<string, any>;
fingerprint?: string;
}
interface LogData {
level?: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
message: string;
userId?: string;
source?: string;
tags?: Record<string, any>;
context?: Record<string, any>;
timestamp?: Date;
}
interface SupportTicketData {
type: 'BUG_REPORT' | 'FEATURE_REQUEST' | 'SUPPORT_REQUEST' | 'QUESTION';
title: string;
description: string;
userEmail?: string;
userName?: string;
userId?: string;
userAgent?: string;
url?: string;
tags?: Record<string, any>;
metadata?: Record<string, any>;
priority?: 'LOW' | 'MEDIUM' | 'HIGH' | 'URGENT';
}
interface MetricData {
name: string;
value: number;
unit?: string;
timestamp?: Date;
tags?: Record<string, any>;
aggregationType?: 'avg' | 'sum' | 'min' | 'max' | 'count';
}
declare class MeshedMonitor {
private config;
private logQueue;
private flushTimer?;
constructor(config: MeshedMonitorConfig);
private initialize;
private setupGlobalErrorHandling;
private startLogFlushTimer;
captureError(error: ErrorData): Promise<void>;
captureException(error: Error, context?: Record<string, any>): Promise<void>;
log(level: LogData['level'], message: string, context?: Record<string, any>): void;
debug(message: string, context?: Record<string, any>): void;
info(message: string, context?: Record<string, any>): void;
warn(message: string, context?: Record<string, any>): void;
error(message: string, context?: Record<string, any>): void;
flush(): Promise<void>;
private flushLogs;
createSupportTicket(ticket: SupportTicketData): Promise<{
id: string;
status: string;
}>;
trackMetric(metric: MetricData): Promise<void>;
trackMetrics(metrics: MetricData[]): Promise<void>;
setUser(userId: string): void;
setEnvironment(environment: string): void;
setRelease(release: string): void;
health(): Promise<any>;
private sendRequest;
destroy(): void;
}
declare class SupportWidget {
private monitor;
private container?;
constructor(monitor: MeshedMonitor);
show(options?: {
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
theme?: 'light' | 'dark';
}): void;
hide(): void;
private getWidgetHTML;
private getWidgetCSS;
private attachEventListeners;
private handleFormSubmit;
}
export { type ErrorData, type LogData, MeshedMonitor, type MeshedMonitorConfig, type MetricData, type SupportTicketData, SupportWidget, MeshedMonitor as default };