how can I track the time amount in a spesific room...
# ask-ai
n
how can I track the time amount in a spesific room or call?
t
Thanks for reaching out, Berfin. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your question about tracking how much time is spent in a specific room or call. You have two straightforward ways to track time: use LiveKit Cloud analytics (built-in, easiest) or track it programmatically in your app (flexible, server- or client-side). • LiveKit Cloud analytics (recommended if you use LiveKit Cloud) ◦ The Cloud dashboard shows session-level and participant-level metrics such as total connection minutes and session duration. You can view session pages to see total connection minutes and participant pages to see how long each participant stayed in the session. ◦ This gives you an out-of-the-box view without adding tracking code. • Programmatic tracking (useful if you need custom reporting or want to record durations yourself) a. Track session start/end using Room lifecycle events: • Listen for the room connection event (e.g.,
RoomEvent.Connected
) as the start time. • Listen for the disconnect event (e.g.,
RoomEvent.Disconnected
) as the end time. • Compute end_time - start_time to get session duration. • Example pattern (pseudo):
Copy code
start_time = None

       @room.on("connected")
       def on_connected():
           global start_time
           start_time = time.time()

       @room.on("disconnected")
       def on_disconnected():
           if start_time:
               duration = time.time() - start_time
               # store/report duration
1. Track per-participant duration: ◦ Record when each participant joins and leaves (participant connected/disconnected events). ◦ Save timestamps server-side or in your analytics store to calculate per-user durations and aggregate totals for the room. 1. For SIP calls: ◦ Monitor SIP call lifecycle attributes (e.g.,
sip.callStatus
values like "dialing", "active", "hangup") to determine when the call is active and compute duration from active → hangup. 1. For Agents / automated sessions: ◦ Use the session or job context (e.g.,
JobContext
in Agents) together with manual timing to capture session start/end and include session reports after completion. If you’d like, tell me: • Are you using LiveKit Cloud or self-hosted LiveKit? • Do you want total room time (sum of all participants), per-participant time, or just wall-clock duration for the room itself? • Do you prefer dashboard/automatic tracking or a programmatic approach so I can provide a short code example tailored to your SDK (JavaScript, Python, etc.)? I can then give exact code snippets or steps for your setup. Sources: Say hello to improved Cloud analytics | Agents (Python) | livekit/livekit_composite | DeepWiki | SIP Lifecycle Management Agent | LiveKit Documentation