@k-msg/analytics 0.1.1 → 0.1.2
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 +43 -4456
- package/dist/index.js.map +85 -1
- package/dist/index.mjs +45 -0
- package/dist/index.mjs.map +85 -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,164 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export interface AnalyticsConfig {
|
|
3
|
+
enableRealTimeTracking: boolean;
|
|
4
|
+
retentionDays: number;
|
|
5
|
+
aggregationIntervals: ("minute" | "hour" | "day" | "week" | "month")[];
|
|
6
|
+
enabledMetrics: MetricType[];
|
|
7
|
+
}
|
|
8
|
+
export declare enum MetricType {
|
|
9
|
+
MESSAGE_SENT = "message_sent",
|
|
10
|
+
MESSAGE_DELIVERED = "message_delivered",
|
|
11
|
+
MESSAGE_FAILED = "message_failed",
|
|
12
|
+
MESSAGE_CLICKED = "message_clicked",
|
|
13
|
+
TEMPLATE_USAGE = "template_usage",
|
|
14
|
+
PROVIDER_PERFORMANCE = "provider_performance",
|
|
15
|
+
CHANNEL_USAGE = "channel_usage",
|
|
16
|
+
ERROR_RATE = "error_rate",
|
|
17
|
+
DELIVERY_RATE = "delivery_rate",
|
|
18
|
+
CLICK_RATE = "click_rate"
|
|
19
|
+
}
|
|
20
|
+
export interface MetricData {
|
|
21
|
+
id: string;
|
|
22
|
+
type: MetricType;
|
|
23
|
+
timestamp: Date;
|
|
24
|
+
value: number;
|
|
25
|
+
dimensions: Record<string, string>;
|
|
26
|
+
metadata?: Record<string, any>;
|
|
27
|
+
}
|
|
28
|
+
export interface AggregatedMetric {
|
|
29
|
+
type: MetricType;
|
|
30
|
+
interval: "minute" | "hour" | "day" | "week" | "month";
|
|
31
|
+
timestamp: Date;
|
|
32
|
+
dimensions: Record<string, string>;
|
|
33
|
+
aggregations: {
|
|
34
|
+
count: number;
|
|
35
|
+
sum: number;
|
|
36
|
+
avg: number;
|
|
37
|
+
min: number;
|
|
38
|
+
max: number;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export interface AnalyticsReport {
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
dateRange: {
|
|
46
|
+
start: Date;
|
|
47
|
+
end: Date;
|
|
48
|
+
};
|
|
49
|
+
filters: Record<string, any>;
|
|
50
|
+
metrics: ReportMetric[];
|
|
51
|
+
generatedAt: Date;
|
|
52
|
+
format: "json" | "csv" | "pdf";
|
|
53
|
+
}
|
|
54
|
+
export interface ReportMetric {
|
|
55
|
+
type: MetricType;
|
|
56
|
+
value: number;
|
|
57
|
+
change?: number;
|
|
58
|
+
trend?: "up" | "down" | "stable";
|
|
59
|
+
breakdown?: Record<string, number>;
|
|
60
|
+
}
|
|
61
|
+
export interface InsightData {
|
|
62
|
+
id: string;
|
|
63
|
+
type: "anomaly" | "trend" | "recommendation";
|
|
64
|
+
title: string;
|
|
65
|
+
description: string;
|
|
66
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
67
|
+
metric: MetricType;
|
|
68
|
+
dimensions: Record<string, string>;
|
|
69
|
+
value: number;
|
|
70
|
+
expectedValue?: number;
|
|
71
|
+
confidence: number;
|
|
72
|
+
actionable: boolean;
|
|
73
|
+
recommendations?: string[];
|
|
74
|
+
detectedAt: Date;
|
|
75
|
+
}
|
|
76
|
+
export interface AnalyticsQuery {
|
|
77
|
+
metrics: MetricType[];
|
|
78
|
+
dateRange: {
|
|
79
|
+
start: Date;
|
|
80
|
+
end: Date;
|
|
81
|
+
};
|
|
82
|
+
interval?: "minute" | "hour" | "day" | "week" | "month";
|
|
83
|
+
filters?: Record<string, any>;
|
|
84
|
+
groupBy?: string[];
|
|
85
|
+
orderBy?: {
|
|
86
|
+
field: string;
|
|
87
|
+
direction: "asc" | "desc";
|
|
88
|
+
}[];
|
|
89
|
+
limit?: number;
|
|
90
|
+
offset?: number;
|
|
91
|
+
}
|
|
92
|
+
export interface AnalyticsResult {
|
|
93
|
+
query: AnalyticsQuery;
|
|
94
|
+
data: AggregatedMetric[];
|
|
95
|
+
summary: {
|
|
96
|
+
totalRecords: number;
|
|
97
|
+
dateRange: {
|
|
98
|
+
start: Date;
|
|
99
|
+
end: Date;
|
|
100
|
+
};
|
|
101
|
+
executionTime: number;
|
|
102
|
+
};
|
|
103
|
+
insights?: InsightData[];
|
|
104
|
+
}
|
|
105
|
+
export declare const MetricDataSchema: z.ZodObject<{
|
|
106
|
+
id: z.ZodString;
|
|
107
|
+
type: z.ZodEnum<typeof MetricType>;
|
|
108
|
+
timestamp: z.ZodDate;
|
|
109
|
+
value: z.ZodNumber;
|
|
110
|
+
dimensions: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
111
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
export declare const AnalyticsQuerySchema: z.ZodObject<{
|
|
114
|
+
metrics: z.ZodArray<z.ZodEnum<typeof MetricType>>;
|
|
115
|
+
dateRange: z.ZodObject<{
|
|
116
|
+
start: z.ZodDate;
|
|
117
|
+
end: z.ZodDate;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
interval: z.ZodOptional<z.ZodEnum<{
|
|
120
|
+
minute: "minute";
|
|
121
|
+
hour: "hour";
|
|
122
|
+
day: "day";
|
|
123
|
+
week: "week";
|
|
124
|
+
month: "month";
|
|
125
|
+
}>>;
|
|
126
|
+
filters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
127
|
+
groupBy: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
128
|
+
orderBy: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
129
|
+
field: z.ZodString;
|
|
130
|
+
direction: z.ZodEnum<{
|
|
131
|
+
asc: "asc";
|
|
132
|
+
desc: "desc";
|
|
133
|
+
}>;
|
|
134
|
+
}, z.core.$strip>>>;
|
|
135
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
136
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
137
|
+
}, z.core.$strip>;
|
|
138
|
+
export declare const InsightDataSchema: z.ZodObject<{
|
|
139
|
+
id: z.ZodString;
|
|
140
|
+
type: z.ZodEnum<{
|
|
141
|
+
anomaly: "anomaly";
|
|
142
|
+
trend: "trend";
|
|
143
|
+
recommendation: "recommendation";
|
|
144
|
+
}>;
|
|
145
|
+
title: z.ZodString;
|
|
146
|
+
description: z.ZodString;
|
|
147
|
+
severity: z.ZodEnum<{
|
|
148
|
+
low: "low";
|
|
149
|
+
medium: "medium";
|
|
150
|
+
high: "high";
|
|
151
|
+
critical: "critical";
|
|
152
|
+
}>;
|
|
153
|
+
metric: z.ZodEnum<typeof MetricType>;
|
|
154
|
+
dimensions: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
155
|
+
value: z.ZodNumber;
|
|
156
|
+
expectedValue: z.ZodOptional<z.ZodNumber>;
|
|
157
|
+
confidence: z.ZodNumber;
|
|
158
|
+
actionable: z.ZodBoolean;
|
|
159
|
+
recommendations: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
160
|
+
detectedAt: z.ZodDate;
|
|
161
|
+
}, z.core.$strip>;
|
|
162
|
+
export type MetricDataType = z.infer<typeof MetricDataSchema>;
|
|
163
|
+
export type AnalyticsQueryType = z.infer<typeof AnalyticsQuerySchema>;
|
|
164
|
+
export type InsightDataType = z.infer<typeof InsightDataSchema>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k-msg/analytics",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"packageManager": "bun@1.3.8",
|
|
4
5
|
"description": "Analytics and reporting engine for message tracking and insights",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "dist/index.js",
|
|
@@ -17,20 +18,24 @@
|
|
|
17
18
|
"access": "public"
|
|
18
19
|
},
|
|
19
20
|
"scripts": {
|
|
20
|
-
"build": "
|
|
21
|
+
"build": "bun run build:esm && bun run build:cjs && bun run build:types",
|
|
22
|
+
"build:esm": "bun build ./src/index.ts --outdir ./dist --format esm --minify --sourcemap --entry-naming '[name].mjs' --external 'bun:test'",
|
|
23
|
+
"build:cjs": "bun build ./src/index.ts --outdir ./dist --format cjs --minify --sourcemap --entry-naming '[name].js' --external 'bun:test'",
|
|
24
|
+
"build:types": "tsc",
|
|
21
25
|
"dev": "tsc --watch",
|
|
22
26
|
"test": "bun test",
|
|
23
|
-
"clean": "rm -rf dist"
|
|
27
|
+
"clean": "rm -rf dist",
|
|
28
|
+
"pack": "bun pm pack",
|
|
29
|
+
"publish": "bun publish --access public"
|
|
24
30
|
},
|
|
25
31
|
"dependencies": {
|
|
26
|
-
"zod": "
|
|
27
|
-
"@k-msg/messaging": "
|
|
32
|
+
"zod": "^4.0.14",
|
|
33
|
+
"@k-msg/messaging": "0.1.1"
|
|
28
34
|
},
|
|
29
35
|
"devDependencies": {
|
|
30
|
-
"typescript": "
|
|
31
|
-
"@types/bun": "
|
|
32
|
-
"@types/node": "
|
|
33
|
-
"tsup": "^8.5.0"
|
|
36
|
+
"typescript": "^5.7.2",
|
|
37
|
+
"@types/bun": "latest",
|
|
38
|
+
"@types/node": "^22.0.0"
|
|
34
39
|
},
|
|
35
40
|
"keywords": [
|
|
36
41
|
"analytics",
|
|
@@ -46,12 +51,12 @@
|
|
|
46
51
|
],
|
|
47
52
|
"repository": {
|
|
48
53
|
"type": "git",
|
|
49
|
-
"url": "git+https://github.com/k-otp/k-
|
|
54
|
+
"url": "git+https://github.com/k-otp/k-msg.git"
|
|
50
55
|
},
|
|
51
|
-
"homepage": "https://github.com/k-otp/k-
|
|
56
|
+
"homepage": "https://github.com/k-otp/k-msg",
|
|
52
57
|
"bugs": {
|
|
53
|
-
"url": "https://github.com/k-otp/k-
|
|
58
|
+
"url": "https://github.com/k-otp/k-msg/issues"
|
|
54
59
|
},
|
|
55
60
|
"author": "imjlk",
|
|
56
61
|
"license": "MIT"
|
|
57
|
-
}
|
|
62
|
+
}
|