mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 05:37:20 +01:00
Add real-time session updates via Server-Sent Events
Implements push-based real-time updates for the Sessions page. New sessions now appear instantly without manual reload or polling. Changes: - Add SSE event emitter for session creation notifications - Create SSE stream endpoint at /api/websites/[id]/sessions/stream - Emit session events in tracking endpoint when sessions are created - Add useSessionStream hook to connect to SSE and invalidate queries - Fix LoadingPanel to prevent flicker during background refetches
This commit is contained in:
parent
81e27fc18c
commit
ef9a382cdd
7 changed files with 78 additions and 5 deletions
|
|
@ -12,6 +12,7 @@ import { parseRequest } from '@/lib/request';
|
|||
import { badRequest, forbidden, json, serverError } from '@/lib/response';
|
||||
import { anyObjectParam, urlOrPathParam } from '@/lib/schema';
|
||||
import { safeDecodeURI, safeDecodeURIComponent } from '@/lib/url';
|
||||
import { emitSessionCreated } from '@/lib/session-events';
|
||||
import { createSession, saveEvent, saveSessionData } from '@/queries/sql';
|
||||
|
||||
interface Cache {
|
||||
|
|
@ -151,6 +152,7 @@ export async function POST(request: Request) {
|
|||
distinctId: id,
|
||||
createdAt,
|
||||
});
|
||||
emitSessionCreated(sourceId, sessionId);
|
||||
}
|
||||
|
||||
// Visit info
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue