feat(gateway): add system.sessionAnalytics usage snapshot RPC

This commit is contained in:
William Valentin
2026-02-16 14:07:42 -08:00
parent 426145386f
commit 3d7144b2c5
9 changed files with 245 additions and 3 deletions
+36
View File
@@ -303,6 +303,42 @@ Online/offline is inferred from inactivity threshold in the daemon.
}
```
#### `system.sessionAnalytics`
Return aggregate session analytics from the SQLite message history.
Useful for operator dashboards and trend checks (sessions/day, message volume, top active sessions).
**Request:**
```json
{
"id": 10,
"method": "system.sessionAnalytics",
"params": {
"days": 30,
"topLimit": 10
}
}
```
**Response:**
```json
{
"id": 10,
"result": {
"daily": [
{ "day": "2026-02-16", "sessions": 14, "messages": 228 }
],
"topSessions": [
{ "sessionId": "telegram:123456", "messages": 42, "lastActivity": 1739700300 }
],
"averageMessagesPerSession": 16.29,
"totalSessions": 14,
"totalMessages": 228
}
}
```
**Response:**
```json
{