recoder-analytics
Version:
Comprehensive analytics and monitoring for the Recoder.xyz ecosystem
111 lines • 3.06 kB
TypeScript
/**
* Multi-Channel Notification Service
*
* Handles sending alerts and notifications through multiple channels including
* Slack, email, webhooks, and SMS with intelligent routing and fallbacks.
*/
import { EventEmitter } from 'events';
export interface NotificationChannel {
id: string;
name: string;
type: 'slack' | 'email' | 'webhook' | 'sms' | 'teams' | 'discord';
enabled: boolean;
config: Record<string, any>;
priority: number;
conditions?: {
severities?: string[];
sources?: string[];
tags?: string[];
};
}
export interface NotificationTemplate {
id: string;
name: string;
channel: string;
alertTemplate: string;
resolutionTemplate: string;
variables: string[];
}
export interface NotificationResult {
channelId: string;
success: boolean;
timestamp: Date;
error?: string;
responseTime: number;
}
export interface NotificationHistory {
alertId: string;
channelId: string;
timestamp: Date;
success: boolean;
message: string;
error?: string;
}
export declare class NotificationService extends EventEmitter {
private channels;
private templates;
private history;
private rateLimits;
private config;
private isRunning;
constructor();
private initializeDefaultChannels;
private initializeDefaultTemplates;
/**
* Start notification service
*/
start(): Promise<void>;
/**
* Stop notification service
*/
stop(): Promise<void>;
/**
* Send alert notification through specified channels
*/
sendAlert(alert: any, channelIds: string[]): Promise<NotificationResult[]>;
/**
* Send resolution notification
*/
sendResolution(alert: any, channelIds: string[]): Promise<NotificationResult[]>;
/**
* Add or update notification channel
*/
addChannel(channel: NotificationChannel): Promise<void>;
/**
* Get all notification channels
*/
getChannels(): NotificationChannel[];
/**
* Get notification history
*/
getHistory(alertId?: string, channelId?: string, limit?: number): NotificationHistory[];
/**
* Get notification statistics
*/
getStatistics(timeframe?: string): {
totalSent: number;
successRate: number;
byChannel: Record<string, {
sent: number;
success: number;
successRate: number;
}>;
averageResponseTime: number;
};
private sendToChannel;
private sendSlackNotification;
private sendEmailNotification;
private sendWebhookNotification;
private sendTeamsNotification;
private sendDiscordNotification;
private sendHttpRequest;
private renderTemplate;
private alertMatchesChannelConditions;
private isRateLimited;
private recordNotification;
private testChannels;
private testChannel;
private getTimeframeCutoff;
}
export declare const notificationService: NotificationService;
//# sourceMappingURL=notification-service.d.ts.map