@k-msg/analytics 0.1.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/README.md +97 -0
- package/dist/index.cjs +4497 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1048 -0
- package/dist/index.d.ts +1048 -0
- package/dist/index.js +4458 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# @k-msg/analytics
|
|
2
|
+
|
|
3
|
+
Analytics and insights engine for the K-Message platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @k-msg/analytics @k-msg/core
|
|
9
|
+
# or
|
|
10
|
+
bun add @k-msg/analytics @k-msg/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Metrics Collection**: Comprehensive message and system metrics collection
|
|
16
|
+
- **Real-time Analytics**: Live analytics processing and aggregation
|
|
17
|
+
- **Anomaly Detection**: Intelligent anomaly detection for message patterns
|
|
18
|
+
- **Recommendation Engine**: AI-powered recommendations for optimization
|
|
19
|
+
- **Dashboard Generation**: Automated dashboard and report generation
|
|
20
|
+
- **Data Export**: Multiple export formats (CSV, JSON, Excel)
|
|
21
|
+
|
|
22
|
+
## Basic Usage
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { AnalyticsService, MetricsCollector } from '@k-msg/analytics';
|
|
26
|
+
|
|
27
|
+
const analytics = new AnalyticsService();
|
|
28
|
+
const collector = new MetricsCollector();
|
|
29
|
+
|
|
30
|
+
// Collect message metrics
|
|
31
|
+
await collector.collect({
|
|
32
|
+
type: 'MESSAGE_SENT',
|
|
33
|
+
provider: 'iwinv',
|
|
34
|
+
channel: 'alimtalk',
|
|
35
|
+
count: 1,
|
|
36
|
+
metadata: {
|
|
37
|
+
templateId: 'TPL001',
|
|
38
|
+
region: 'KR'
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Generate dashboard data
|
|
43
|
+
const dashboard = await analytics.generateDashboard({
|
|
44
|
+
timeRange: '24h',
|
|
45
|
+
metrics: ['delivery_rate', 'failure_rate', 'response_time']
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Insights and Recommendations
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { InsightEngine, RecommendationEngine } from '@k-msg/analytics';
|
|
53
|
+
|
|
54
|
+
const insightEngine = new InsightEngine();
|
|
55
|
+
const recommendationEngine = new RecommendationEngine();
|
|
56
|
+
|
|
57
|
+
// Generate insights
|
|
58
|
+
const insights = await insightEngine.generateInsights({
|
|
59
|
+
timeRange: '7d',
|
|
60
|
+
providers: ['iwinv'],
|
|
61
|
+
includeAnomalies: true
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Get optimization recommendations
|
|
65
|
+
const recommendations = await recommendationEngine.generateRecommendations({
|
|
66
|
+
metrics: insights.metrics,
|
|
67
|
+
thresholds: {
|
|
68
|
+
deliveryRate: 0.95,
|
|
69
|
+
errorRate: 0.05
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Export and Reporting
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { ExportManager } from '@k-msg/analytics';
|
|
78
|
+
|
|
79
|
+
const exportManager = new ExportManager();
|
|
80
|
+
|
|
81
|
+
// Export metrics to CSV
|
|
82
|
+
await exportManager.exportToCSV({
|
|
83
|
+
metrics: dashboard.metrics,
|
|
84
|
+
filename: 'monthly-report.csv',
|
|
85
|
+
timeRange: '30d'
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Export to JSON for API consumption
|
|
89
|
+
const jsonReport = await exportManager.exportToJSON({
|
|
90
|
+
includeRawData: true,
|
|
91
|
+
format: 'detailed'
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT
|