@k-msg/analytics 0.1.1 → 0.1.3
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/aggregators/index.d.ts +5 -0
- package/dist/aggregators/metric.aggregator.d.ts +76 -0
- package/dist/aggregators/time-series.aggregator.d.ts +51 -0
- package/dist/collectors/event.collector.d.ts +86 -0
- package/dist/collectors/index.d.ts +5 -0
- package/dist/collectors/webhook.collector.d.ts +67 -0
- package/dist/index.d.ts +17 -1047
- package/dist/index.js +56 -4450
- package/dist/index.js.map +94 -1
- package/dist/index.mjs +64 -0
- package/dist/index.mjs.map +94 -0
- package/dist/insights/anomaly.detector.d.ts +81 -0
- package/dist/insights/index.d.ts +5 -0
- package/dist/insights/recommendation.engine.d.ts +131 -0
- package/dist/reports/dashboard.d.ts +143 -0
- package/dist/reports/export.manager.d.ts +104 -0
- package/dist/reports/index.d.ts +5 -0
- package/dist/services/analytics.service.d.ts +66 -0
- package/dist/services/insight.engine.d.ts +44 -0
- package/dist/services/metrics.collector.d.ts +58 -0
- package/dist/services/report.generator.d.ts +61 -0
- package/dist/types/analytics.types.d.ts +164 -0
- package/package.json +18 -13
- package/dist/index.cjs +0 -4497
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1048
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anomaly Detector
|
|
3
|
+
* 이상 징후 탐지 및 분석
|
|
4
|
+
*/
|
|
5
|
+
import type { AggregatedMetric, InsightData, MetricData } from "../types/analytics.types";
|
|
6
|
+
import { MetricType } from "../types/analytics.types";
|
|
7
|
+
export interface AnomalyDetectionConfig {
|
|
8
|
+
algorithms: AnomalyAlgorithm[];
|
|
9
|
+
sensitivity: "low" | "medium" | "high";
|
|
10
|
+
minDataPoints: number;
|
|
11
|
+
confidenceThreshold: number;
|
|
12
|
+
enableSeasonalAdjustment: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface AnomalyAlgorithm {
|
|
15
|
+
name: string;
|
|
16
|
+
type: "statistical" | "ml" | "rule-based";
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
config: Record<string, any>;
|
|
19
|
+
}
|
|
20
|
+
export interface Anomaly {
|
|
21
|
+
id: string;
|
|
22
|
+
metricType: MetricType;
|
|
23
|
+
timestamp: Date;
|
|
24
|
+
value: number;
|
|
25
|
+
expectedValue: number;
|
|
26
|
+
deviation: number;
|
|
27
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
28
|
+
confidence: number;
|
|
29
|
+
algorithm: string;
|
|
30
|
+
dimensions: Record<string, string>;
|
|
31
|
+
context?: {
|
|
32
|
+
trend: "increasing" | "decreasing" | "stable";
|
|
33
|
+
seasonality: boolean;
|
|
34
|
+
historicalComparison: number;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export declare class AnomalyDetector {
|
|
38
|
+
private config;
|
|
39
|
+
private historicalData;
|
|
40
|
+
private seasonalPatterns;
|
|
41
|
+
private baselines;
|
|
42
|
+
private defaultConfig;
|
|
43
|
+
constructor(config?: Partial<AnomalyDetectionConfig>);
|
|
44
|
+
/**
|
|
45
|
+
* 실시간 이상 탐지
|
|
46
|
+
*/
|
|
47
|
+
detectRealTimeAnomalies(metric: MetricData): Promise<Anomaly[]>;
|
|
48
|
+
/**
|
|
49
|
+
* 배치 이상 탐지
|
|
50
|
+
*/
|
|
51
|
+
detectBatchAnomalies(metrics: AggregatedMetric[], timeWindow?: {
|
|
52
|
+
start: Date;
|
|
53
|
+
end: Date;
|
|
54
|
+
}): Promise<Anomaly[]>;
|
|
55
|
+
/**
|
|
56
|
+
* 트렌드 변화 탐지
|
|
57
|
+
*/
|
|
58
|
+
detectTrendChanges(metrics: AggregatedMetric[], windowSize?: number): Promise<InsightData[]>;
|
|
59
|
+
/**
|
|
60
|
+
* 베이스라인 업데이트
|
|
61
|
+
*/
|
|
62
|
+
updateBaselines(metrics: AggregatedMetric[]): Promise<void>;
|
|
63
|
+
private runAlgorithm;
|
|
64
|
+
private zScoreDetection;
|
|
65
|
+
private iqrDetection;
|
|
66
|
+
private isolationForestDetection;
|
|
67
|
+
private thresholdDetection;
|
|
68
|
+
private calculateSeverity;
|
|
69
|
+
private calculateTrendSeverity;
|
|
70
|
+
private getMetricKey;
|
|
71
|
+
private updateHistoricalData;
|
|
72
|
+
private groupMetricsByTypeAndDimensions;
|
|
73
|
+
private adjustForSeasonality;
|
|
74
|
+
private calculateTrend;
|
|
75
|
+
private detectTrend;
|
|
76
|
+
private getSensitivityThreshold;
|
|
77
|
+
private calculateIsolationThreshold;
|
|
78
|
+
private calculateIsolationScore;
|
|
79
|
+
private deduplicateAndRankAnomalies;
|
|
80
|
+
private generateTrendRecommendations;
|
|
81
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Insights - 인사이트 생성 컴포넌트들
|
|
3
|
+
*/
|
|
4
|
+
export { type Anomaly, type AnomalyAlgorithm, type AnomalyDetectionConfig, AnomalyDetector, } from "./anomaly.detector";
|
|
5
|
+
export { type Recommendation, type RecommendationConfig, RecommendationEngine, type RecommendationRule, } from "./recommendation.engine";
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recommendation Engine
|
|
3
|
+
* 데이터 기반 추천 시스템
|
|
4
|
+
*/
|
|
5
|
+
import type { AggregatedMetric } from "../types/analytics.types";
|
|
6
|
+
import { MetricType } from "../types/analytics.types";
|
|
7
|
+
export interface RecommendationConfig {
|
|
8
|
+
rules: RecommendationRule[];
|
|
9
|
+
enableMachineLearning: boolean;
|
|
10
|
+
confidenceThreshold: number;
|
|
11
|
+
maxRecommendations: number;
|
|
12
|
+
categories: RecommendationCategory[];
|
|
13
|
+
}
|
|
14
|
+
export interface RecommendationRule {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
category: string;
|
|
18
|
+
priority: number;
|
|
19
|
+
conditions: RuleCondition[];
|
|
20
|
+
actions: RecommendationAction[];
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface RuleCondition {
|
|
24
|
+
metric: MetricType;
|
|
25
|
+
operator: "gt" | "lt" | "eq" | "gte" | "lte" | "between" | "trend";
|
|
26
|
+
value: number | [number, number];
|
|
27
|
+
timeWindow?: string;
|
|
28
|
+
dimensions?: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
export interface RecommendationAction {
|
|
31
|
+
type: "optimization" | "cost-saving" | "performance" | "reliability" | "security";
|
|
32
|
+
title: string;
|
|
33
|
+
description: string;
|
|
34
|
+
impact: "low" | "medium" | "high";
|
|
35
|
+
effort: "low" | "medium" | "high";
|
|
36
|
+
steps: string[];
|
|
37
|
+
estimatedBenefit?: {
|
|
38
|
+
metric: MetricType;
|
|
39
|
+
improvement: number;
|
|
40
|
+
unit: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface Recommendation {
|
|
44
|
+
id: string;
|
|
45
|
+
category: string;
|
|
46
|
+
priority: number;
|
|
47
|
+
title: string;
|
|
48
|
+
description: string;
|
|
49
|
+
rationale: string;
|
|
50
|
+
actions: RecommendationAction[];
|
|
51
|
+
confidence: number;
|
|
52
|
+
impact: "low" | "medium" | "high";
|
|
53
|
+
effort: "low" | "medium" | "high";
|
|
54
|
+
createdAt: Date;
|
|
55
|
+
validUntil?: Date;
|
|
56
|
+
metadata: {
|
|
57
|
+
ruleIds: string[];
|
|
58
|
+
triggeredBy: {
|
|
59
|
+
metrics: {
|
|
60
|
+
type: MetricType;
|
|
61
|
+
value: number;
|
|
62
|
+
timestamp: Date;
|
|
63
|
+
}[];
|
|
64
|
+
conditions: string[];
|
|
65
|
+
};
|
|
66
|
+
estimatedROI?: number;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export interface RecommendationCategory {
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
description: string;
|
|
73
|
+
weight: number;
|
|
74
|
+
}
|
|
75
|
+
export declare class RecommendationEngine {
|
|
76
|
+
private config;
|
|
77
|
+
private recommendations;
|
|
78
|
+
private ruleExecutionHistory;
|
|
79
|
+
private defaultConfig;
|
|
80
|
+
constructor(config?: Partial<RecommendationConfig>);
|
|
81
|
+
/**
|
|
82
|
+
* 메트릭 기반 추천 생성
|
|
83
|
+
*/
|
|
84
|
+
generateRecommendations(metrics: AggregatedMetric[]): Promise<Recommendation[]>;
|
|
85
|
+
/**
|
|
86
|
+
* 특정 카테고리 추천 조회
|
|
87
|
+
*/
|
|
88
|
+
getRecommendationsByCategory(category: string): Recommendation[];
|
|
89
|
+
/**
|
|
90
|
+
* 추천 실행 상태 업데이트
|
|
91
|
+
*/
|
|
92
|
+
markRecommendationAsImplemented(recommendationId: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* 추천 무시
|
|
95
|
+
*/
|
|
96
|
+
dismissRecommendation(recommendationId: string, reason?: string): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* 추천 통계
|
|
99
|
+
*/
|
|
100
|
+
getRecommendationStats(): {
|
|
101
|
+
total: number;
|
|
102
|
+
byCategory: Record<string, number>;
|
|
103
|
+
byImpact: Record<string, number>;
|
|
104
|
+
byPriority: Record<string, number>;
|
|
105
|
+
};
|
|
106
|
+
private generateRuleBasedRecommendations;
|
|
107
|
+
private generatePatternBasedRecommendations;
|
|
108
|
+
private generateComparisonBasedRecommendations;
|
|
109
|
+
private generateMLBasedRecommendations;
|
|
110
|
+
private evaluateRuleConditions;
|
|
111
|
+
private evaluateCondition;
|
|
112
|
+
private createRecommendationFromRule;
|
|
113
|
+
private analyzeTimePatterns;
|
|
114
|
+
private generateTimeBasedRecommendations;
|
|
115
|
+
private analyzeChannelPatterns;
|
|
116
|
+
private generateChannelBasedRecommendations;
|
|
117
|
+
private analyzeErrorPatterns;
|
|
118
|
+
private generateErrorBasedRecommendations;
|
|
119
|
+
private compareProviderPerformance;
|
|
120
|
+
private generateProviderRecommendations;
|
|
121
|
+
private compareChannelEfficiency;
|
|
122
|
+
private generateChannelEfficiencyRecommendations;
|
|
123
|
+
private generateCapacityRecommendations;
|
|
124
|
+
private calculateRuleConfidence;
|
|
125
|
+
private calculateAggregateImpact;
|
|
126
|
+
private calculateAggregateEffort;
|
|
127
|
+
private generateRationale;
|
|
128
|
+
private recordRuleExecution;
|
|
129
|
+
private deduplicateAndPrioritize;
|
|
130
|
+
private initializeDefaultRules;
|
|
131
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dashboard Report Generator
|
|
3
|
+
* 실시간 대시보드 데이터 생성
|
|
4
|
+
*/
|
|
5
|
+
import type { AggregatedMetric, AnalyticsQuery, InsightData } from "../types/analytics.types";
|
|
6
|
+
export interface DashboardConfig {
|
|
7
|
+
refreshInterval: number;
|
|
8
|
+
timeRange: {
|
|
9
|
+
default: string;
|
|
10
|
+
options: string[];
|
|
11
|
+
};
|
|
12
|
+
widgets: DashboardWidget[];
|
|
13
|
+
filters: DashboardFilter[];
|
|
14
|
+
}
|
|
15
|
+
export interface DashboardWidget {
|
|
16
|
+
id: string;
|
|
17
|
+
type: "metric" | "chart" | "table" | "gauge" | "heatmap" | "trend";
|
|
18
|
+
title: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
position: {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
};
|
|
26
|
+
query: AnalyticsQuery;
|
|
27
|
+
visualization: VisualizationConfig;
|
|
28
|
+
refreshInterval?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface VisualizationConfig {
|
|
31
|
+
chartType?: "line" | "bar" | "pie" | "area" | "scatter";
|
|
32
|
+
aggregation?: "sum" | "avg" | "min" | "max" | "count";
|
|
33
|
+
groupBy?: string[];
|
|
34
|
+
colors?: string[];
|
|
35
|
+
yAxis?: {
|
|
36
|
+
min?: number;
|
|
37
|
+
max?: number;
|
|
38
|
+
label?: string;
|
|
39
|
+
};
|
|
40
|
+
xAxis?: {
|
|
41
|
+
label?: string;
|
|
42
|
+
};
|
|
43
|
+
showLegend?: boolean;
|
|
44
|
+
showGrid?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface DashboardFilter {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
type: "select" | "date" | "range" | "multi-select";
|
|
50
|
+
field: string;
|
|
51
|
+
options?: Array<{
|
|
52
|
+
value: string;
|
|
53
|
+
label: string;
|
|
54
|
+
}>;
|
|
55
|
+
defaultValue?: any;
|
|
56
|
+
}
|
|
57
|
+
export interface DashboardData {
|
|
58
|
+
timestamp: Date;
|
|
59
|
+
timeRange: {
|
|
60
|
+
start: Date;
|
|
61
|
+
end: Date;
|
|
62
|
+
};
|
|
63
|
+
kpis: KPIData[];
|
|
64
|
+
widgets: WidgetData[];
|
|
65
|
+
insights: InsightData[];
|
|
66
|
+
filters: Record<string, any>;
|
|
67
|
+
}
|
|
68
|
+
export interface KPIData {
|
|
69
|
+
id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
value: number;
|
|
72
|
+
previousValue?: number;
|
|
73
|
+
change?: number;
|
|
74
|
+
changePercent?: number;
|
|
75
|
+
trend: "up" | "down" | "stable";
|
|
76
|
+
unit?: string;
|
|
77
|
+
target?: number;
|
|
78
|
+
status: "good" | "warning" | "critical";
|
|
79
|
+
}
|
|
80
|
+
export interface WidgetData {
|
|
81
|
+
id: string;
|
|
82
|
+
title: string;
|
|
83
|
+
type: string;
|
|
84
|
+
data: any;
|
|
85
|
+
lastUpdated: Date;
|
|
86
|
+
error?: string;
|
|
87
|
+
}
|
|
88
|
+
export declare class DashboardGenerator {
|
|
89
|
+
private config;
|
|
90
|
+
private dataCache;
|
|
91
|
+
private defaultConfig;
|
|
92
|
+
constructor(config?: Partial<DashboardConfig>);
|
|
93
|
+
/**
|
|
94
|
+
* 대시보드 데이터 생성
|
|
95
|
+
*/
|
|
96
|
+
generateDashboard(timeRange: {
|
|
97
|
+
start: Date;
|
|
98
|
+
end: Date;
|
|
99
|
+
}, filters?: Record<string, any>, metrics?: AggregatedMetric[]): Promise<DashboardData>;
|
|
100
|
+
/**
|
|
101
|
+
* 실시간 대시보드 스트림
|
|
102
|
+
*/
|
|
103
|
+
streamDashboard(timeRange: {
|
|
104
|
+
start: Date;
|
|
105
|
+
end: Date;
|
|
106
|
+
}, filters?: Record<string, any>): AsyncGenerator<DashboardData>;
|
|
107
|
+
/**
|
|
108
|
+
* 특정 위젯 데이터 업데이트
|
|
109
|
+
*/
|
|
110
|
+
updateWidget(widgetId: string, metrics: AggregatedMetric[], timeRange: {
|
|
111
|
+
start: Date;
|
|
112
|
+
end: Date;
|
|
113
|
+
}, filters?: Record<string, any>): Promise<WidgetData | null>;
|
|
114
|
+
/**
|
|
115
|
+
* 대시보드 구성 업데이트
|
|
116
|
+
*/
|
|
117
|
+
updateConfig(config: Partial<DashboardConfig>): void;
|
|
118
|
+
/**
|
|
119
|
+
* 위젯 추가
|
|
120
|
+
*/
|
|
121
|
+
addWidget(widget: DashboardWidget): void;
|
|
122
|
+
/**
|
|
123
|
+
* 위젯 제거
|
|
124
|
+
*/
|
|
125
|
+
removeWidget(widgetId: string): boolean;
|
|
126
|
+
private calculateKPIs;
|
|
127
|
+
private generateWidgetData;
|
|
128
|
+
private generateSingleWidgetData;
|
|
129
|
+
private generateMetricWidgetData;
|
|
130
|
+
private generateChartWidgetData;
|
|
131
|
+
private generateGroupedChartData;
|
|
132
|
+
private generateTableWidgetData;
|
|
133
|
+
private generateGaugeWidgetData;
|
|
134
|
+
private generateHeatmapWidgetData;
|
|
135
|
+
private generateTrendWidgetData;
|
|
136
|
+
private filterMetrics;
|
|
137
|
+
private applyQueryFilters;
|
|
138
|
+
private calculatePreviousPeriodValue;
|
|
139
|
+
private getAggregatedValue;
|
|
140
|
+
private formatValue;
|
|
141
|
+
private getDefaultColor;
|
|
142
|
+
private initializeDefaultWidgets;
|
|
143
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Export Manager
|
|
3
|
+
* 다양한 형식으로 데이터 내보내기
|
|
4
|
+
*/
|
|
5
|
+
import type { AggregatedMetric, AnalyticsReport, InsightData } from "../types/analytics.types";
|
|
6
|
+
export interface ExportConfig {
|
|
7
|
+
formats: ExportFormat[];
|
|
8
|
+
maxFileSize: number;
|
|
9
|
+
compressionEnabled: boolean;
|
|
10
|
+
watermark?: {
|
|
11
|
+
text: string;
|
|
12
|
+
position: "top" | "bottom";
|
|
13
|
+
};
|
|
14
|
+
scheduling?: {
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
cron: string;
|
|
17
|
+
recipients: string[];
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface ExportFormat {
|
|
21
|
+
type: "csv" | "excel" | "pdf" | "json" | "xml";
|
|
22
|
+
options?: Record<string, any>;
|
|
23
|
+
template?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ExportResult {
|
|
26
|
+
id: string;
|
|
27
|
+
format: string;
|
|
28
|
+
fileName: string;
|
|
29
|
+
filePath: string;
|
|
30
|
+
fileSize: number;
|
|
31
|
+
createdAt: Date;
|
|
32
|
+
downloadUrl?: string;
|
|
33
|
+
expiresAt?: Date;
|
|
34
|
+
}
|
|
35
|
+
export interface CSVExportOptions {
|
|
36
|
+
delimiter: string;
|
|
37
|
+
includeHeaders: boolean;
|
|
38
|
+
dateFormat: string;
|
|
39
|
+
encoding: "utf-8" | "utf-16";
|
|
40
|
+
}
|
|
41
|
+
export interface PDFExportOptions {
|
|
42
|
+
orientation: "portrait" | "landscape";
|
|
43
|
+
pageSize: "A4" | "A3" | "letter";
|
|
44
|
+
includeCharts: boolean;
|
|
45
|
+
template: "standard" | "executive" | "detailed";
|
|
46
|
+
}
|
|
47
|
+
export interface ExcelExportOptions {
|
|
48
|
+
worksheets: Array<{
|
|
49
|
+
name: string;
|
|
50
|
+
data: any[];
|
|
51
|
+
charts?: Array<{
|
|
52
|
+
type: "line" | "bar" | "pie";
|
|
53
|
+
title: string;
|
|
54
|
+
range: string;
|
|
55
|
+
}>;
|
|
56
|
+
}>;
|
|
57
|
+
formatting: {
|
|
58
|
+
autoFilter: boolean;
|
|
59
|
+
freezeFirstRow: boolean;
|
|
60
|
+
columnWidths: "auto" | number[];
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export declare class ExportManager {
|
|
64
|
+
private config;
|
|
65
|
+
private exports;
|
|
66
|
+
private exportQueue;
|
|
67
|
+
private defaultConfig;
|
|
68
|
+
constructor(config?: Partial<ExportConfig>);
|
|
69
|
+
/**
|
|
70
|
+
* 분석 보고서 내보내기
|
|
71
|
+
*/
|
|
72
|
+
exportReport(report: AnalyticsReport, format: ExportFormat, options?: any): Promise<ExportResult>;
|
|
73
|
+
/**
|
|
74
|
+
* 메트릭 데이터 내보내기
|
|
75
|
+
*/
|
|
76
|
+
exportMetrics(metrics: AggregatedMetric[], format: ExportFormat, options?: any): Promise<ExportResult>;
|
|
77
|
+
/**
|
|
78
|
+
* 인사이트 데이터 내보내기
|
|
79
|
+
*/
|
|
80
|
+
exportInsights(insights: InsightData[], format: ExportFormat, options?: any): Promise<ExportResult>;
|
|
81
|
+
/**
|
|
82
|
+
* 내보내기 상태 조회
|
|
83
|
+
*/
|
|
84
|
+
getExportStatus(exportId: string): ExportResult | null;
|
|
85
|
+
/**
|
|
86
|
+
* 내보내기 목록 조회
|
|
87
|
+
*/
|
|
88
|
+
listExports(limit?: number): ExportResult[];
|
|
89
|
+
/**
|
|
90
|
+
* 내보내기 삭제
|
|
91
|
+
*/
|
|
92
|
+
deleteExport(exportId: string): boolean;
|
|
93
|
+
private exportToCSV;
|
|
94
|
+
private exportToExcel;
|
|
95
|
+
private exportToPDF;
|
|
96
|
+
private exportToJSON;
|
|
97
|
+
private exportToXML;
|
|
98
|
+
private exportMetricsToCSV;
|
|
99
|
+
private exportMetricsToJSON;
|
|
100
|
+
private exportInsightsToCSV;
|
|
101
|
+
private exportInsightsToJSON;
|
|
102
|
+
private exportInsightsToPDF;
|
|
103
|
+
private generateExportId;
|
|
104
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reports - 보고서 생성 컴포넌트들
|
|
3
|
+
*/
|
|
4
|
+
export { type DashboardConfig, type DashboardData, DashboardGenerator, type DashboardWidget, type KPIData, type WidgetData, } from "./dashboard";
|
|
5
|
+
export { type ExportConfig, type ExportFormat, ExportManager, type ExportResult, } from "./export.manager";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { AggregatedMetric, AnalyticsConfig, AnalyticsQuery, AnalyticsResult, InsightData, MetricData, MetricType } from "../types/analytics.types";
|
|
2
|
+
export declare class AnalyticsService {
|
|
3
|
+
private config;
|
|
4
|
+
private metricsCollector;
|
|
5
|
+
private reportGenerator;
|
|
6
|
+
private insightEngine;
|
|
7
|
+
private metrics;
|
|
8
|
+
private aggregatedMetrics;
|
|
9
|
+
constructor(config: AnalyticsConfig);
|
|
10
|
+
/**
|
|
11
|
+
* 메트릭 데이터 수집
|
|
12
|
+
*/
|
|
13
|
+
collectMetric(metric: MetricData): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* 분석 쿼리 실행
|
|
16
|
+
*/
|
|
17
|
+
query(query: AnalyticsQuery): Promise<AnalyticsResult>;
|
|
18
|
+
/**
|
|
19
|
+
* 실시간 메트릭 스트림
|
|
20
|
+
*/
|
|
21
|
+
streamMetrics(types: MetricType[]): AsyncGenerator<MetricData>;
|
|
22
|
+
/**
|
|
23
|
+
* 대시보드 데이터 조회
|
|
24
|
+
*/
|
|
25
|
+
getDashboardData(timeRange: {
|
|
26
|
+
start: Date;
|
|
27
|
+
end: Date;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
timeRange: {
|
|
30
|
+
start: Date;
|
|
31
|
+
end: Date;
|
|
32
|
+
};
|
|
33
|
+
kpis: {
|
|
34
|
+
totalMessages: number;
|
|
35
|
+
deliveryRate: number;
|
|
36
|
+
errorRate: number;
|
|
37
|
+
clickRate: number;
|
|
38
|
+
};
|
|
39
|
+
metrics: AggregatedMetric[];
|
|
40
|
+
insights: InsightData[] | undefined;
|
|
41
|
+
trends: {};
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* 이상 탐지
|
|
45
|
+
*/
|
|
46
|
+
detectAnomalies(metricType: MetricType, timeRange: {
|
|
47
|
+
start: Date;
|
|
48
|
+
end: Date;
|
|
49
|
+
}): Promise<InsightData[]>;
|
|
50
|
+
private processRealTimeMetric;
|
|
51
|
+
private validateQuery;
|
|
52
|
+
private executeQuery;
|
|
53
|
+
private performAggregation;
|
|
54
|
+
private generateInsights;
|
|
55
|
+
private getOptimalInterval;
|
|
56
|
+
private calculateKPIs;
|
|
57
|
+
private calculateTrends;
|
|
58
|
+
private sumMetrics;
|
|
59
|
+
private calculateRate;
|
|
60
|
+
private generateCacheKey;
|
|
61
|
+
private startAggregationTasks;
|
|
62
|
+
private scheduleAggregation;
|
|
63
|
+
private getScheduleInterval;
|
|
64
|
+
private runAggregation;
|
|
65
|
+
private notifyAnomalies;
|
|
66
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AggregatedMetric, AnalyticsConfig, AnalyticsQuery, InsightData, MetricData } from "../types/analytics.types";
|
|
2
|
+
import { MetricType } from "../types/analytics.types";
|
|
3
|
+
export declare class InsightEngine {
|
|
4
|
+
private config;
|
|
5
|
+
private anomalyThresholds;
|
|
6
|
+
private historicalData;
|
|
7
|
+
constructor(config: AnalyticsConfig);
|
|
8
|
+
/**
|
|
9
|
+
* 실시간 이상 탐지
|
|
10
|
+
*/
|
|
11
|
+
detectRealTimeAnomalies(metric: MetricData): Promise<InsightData[]>;
|
|
12
|
+
/**
|
|
13
|
+
* 시계열 이상 탐지
|
|
14
|
+
*/
|
|
15
|
+
detectAnomalies(metricType: MetricType, timeRange: {
|
|
16
|
+
start: Date;
|
|
17
|
+
end: Date;
|
|
18
|
+
}): Promise<InsightData[]>;
|
|
19
|
+
/**
|
|
20
|
+
* 인사이트 생성
|
|
21
|
+
*/
|
|
22
|
+
generateInsights(query: AnalyticsQuery, data: AggregatedMetric[]): Promise<InsightData[]>;
|
|
23
|
+
/**
|
|
24
|
+
* 트렌드 예측
|
|
25
|
+
*/
|
|
26
|
+
predictTrends(metricType: MetricType, forecastDays: number): Promise<{
|
|
27
|
+
date: Date;
|
|
28
|
+
predicted: number;
|
|
29
|
+
confidence: number;
|
|
30
|
+
}[]>;
|
|
31
|
+
private initializeBaselines;
|
|
32
|
+
private detectTrendChange;
|
|
33
|
+
private detectSeasonalAnomalies;
|
|
34
|
+
private detectPatternAnomalies;
|
|
35
|
+
private detectThresholdAnomalies;
|
|
36
|
+
private generatePerformanceInsights;
|
|
37
|
+
private generateTrendInsights;
|
|
38
|
+
private generateComparisonInsights;
|
|
39
|
+
private generateRecommendationInsights;
|
|
40
|
+
private calculateSeverity;
|
|
41
|
+
private calculateConfidence;
|
|
42
|
+
private generateRecommendations;
|
|
43
|
+
private calculateTrend;
|
|
44
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { AnalyticsConfig, MetricData, MetricType } from "../types/analytics.types";
|
|
2
|
+
export declare class MetricsCollector {
|
|
3
|
+
private config;
|
|
4
|
+
private buffer;
|
|
5
|
+
private batchSize;
|
|
6
|
+
private flushInterval;
|
|
7
|
+
private storage;
|
|
8
|
+
constructor(config: AnalyticsConfig);
|
|
9
|
+
/**
|
|
10
|
+
* 메트릭 수집
|
|
11
|
+
*/
|
|
12
|
+
collect(metric: MetricData): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* 여러 메트릭 일괄 수집
|
|
15
|
+
*/
|
|
16
|
+
collectBatch(metrics: MetricData[]): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* 최근 메트릭 조회
|
|
19
|
+
*/
|
|
20
|
+
getRecentMetrics(types: MetricType[], durationMs: number): Promise<MetricData[]>;
|
|
21
|
+
/**
|
|
22
|
+
* 메트릭 통계 조회
|
|
23
|
+
*/
|
|
24
|
+
getMetricStats(type: MetricType, timeRange: {
|
|
25
|
+
start: Date;
|
|
26
|
+
end: Date;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
count: number;
|
|
29
|
+
sum: number;
|
|
30
|
+
avg: number;
|
|
31
|
+
min: number;
|
|
32
|
+
max: number;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* 메트릭 카운터 증가
|
|
36
|
+
*/
|
|
37
|
+
incrementCounter(type: MetricType, dimensions: Record<string, string>, value?: number): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* 메트릭 게이지 값 설정
|
|
40
|
+
*/
|
|
41
|
+
setGauge(type: MetricType, dimensions: Record<string, string>, value: number): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* 메트릭 히스토그램 기록
|
|
44
|
+
*/
|
|
45
|
+
recordHistogram(type: MetricType, dimensions: Record<string, string>, value: number): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* 메트릭 버퍼 플러시
|
|
48
|
+
*/
|
|
49
|
+
flush(): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* 메트릭 정리 (보존 기간 초과)
|
|
52
|
+
*/
|
|
53
|
+
cleanup(): Promise<void>;
|
|
54
|
+
private validateMetric;
|
|
55
|
+
private persistMetrics;
|
|
56
|
+
private startBatchProcessor;
|
|
57
|
+
private generateMetricId;
|
|
58
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { AnalyticsConfig, AnalyticsReport } from "../types/analytics.types";
|
|
2
|
+
import { MetricType } from "../types/analytics.types";
|
|
3
|
+
export declare class ReportGenerator {
|
|
4
|
+
private config;
|
|
5
|
+
constructor(config: AnalyticsConfig);
|
|
6
|
+
/**
|
|
7
|
+
* 일일 요약 보고서 생성
|
|
8
|
+
*/
|
|
9
|
+
generateDailySummary(date: Date): Promise<AnalyticsReport>;
|
|
10
|
+
/**
|
|
11
|
+
* 주간 보고서 생성
|
|
12
|
+
*/
|
|
13
|
+
generateWeeklyReport(weekStartDate: Date): Promise<AnalyticsReport>;
|
|
14
|
+
/**
|
|
15
|
+
* 월간 보고서 생성
|
|
16
|
+
*/
|
|
17
|
+
generateMonthlyReport(year: number, month: number): Promise<AnalyticsReport>;
|
|
18
|
+
/**
|
|
19
|
+
* 프로바이더별 성능 보고서
|
|
20
|
+
*/
|
|
21
|
+
generateProviderReport(providerId: string, dateRange: {
|
|
22
|
+
start: Date;
|
|
23
|
+
end: Date;
|
|
24
|
+
}): Promise<AnalyticsReport>;
|
|
25
|
+
/**
|
|
26
|
+
* 템플릿 사용량 보고서
|
|
27
|
+
*/
|
|
28
|
+
generateTemplateUsageReport(dateRange: {
|
|
29
|
+
start: Date;
|
|
30
|
+
end: Date;
|
|
31
|
+
}): Promise<AnalyticsReport>;
|
|
32
|
+
/**
|
|
33
|
+
* 커스텀 보고서 생성
|
|
34
|
+
*/
|
|
35
|
+
generateCustomReport(name: string, dateRange: {
|
|
36
|
+
start: Date;
|
|
37
|
+
end: Date;
|
|
38
|
+
}, filters: Record<string, any>, metricTypes: MetricType[]): Promise<AnalyticsReport>;
|
|
39
|
+
/**
|
|
40
|
+
* 보고서를 CSV 형식으로 내보내기
|
|
41
|
+
*/
|
|
42
|
+
exportToCSV(report: AnalyticsReport): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* 보고서를 JSON 형식으로 내보내기
|
|
45
|
+
*/
|
|
46
|
+
exportToJSON(report: AnalyticsReport): Promise<string>;
|
|
47
|
+
private generateReport;
|
|
48
|
+
private calculateDailyMetrics;
|
|
49
|
+
private calculateWeeklyMetrics;
|
|
50
|
+
private calculateMonthlyMetrics;
|
|
51
|
+
private calculateProviderMetrics;
|
|
52
|
+
private calculateTemplateMetrics;
|
|
53
|
+
private calculateCustomMetrics;
|
|
54
|
+
private getMetricValue;
|
|
55
|
+
private getProviderPerformance;
|
|
56
|
+
private getTemplateUsage;
|
|
57
|
+
private calculateChange;
|
|
58
|
+
private calculateTrend;
|
|
59
|
+
private getMetricPriority;
|
|
60
|
+
private validateReport;
|
|
61
|
+
}
|