Add authentication, Redis pub/sub, and error handling to SSE

Improvements:
- Add Redis pub/sub support for multi-server deployments
- Add authentication check to SSE stream endpoint
- Add 30s heartbeat keepalive for long-lived connections
- Implement exponential backoff reconnection logic in client
- Fix TypeScript types (websiteId optional, timer types)
- Use specific query key invalidation instead of broad match
- Fix undefined access in session-events listener map
This commit is contained in:
Arthur Sepiol 2025-12-10 16:06:18 +03:00
parent ef9a382cdd
commit 5874cf80f5
4 changed files with 114 additions and 11 deletions

View file

@ -152,7 +152,7 @@ export async function POST(request: Request) {
distinctId: id,
createdAt,
});
emitSessionCreated(sourceId, sessionId);
await emitSessionCreated(sourceId, sessionId);
}
// Visit info