Use session IDs to reconstruct exactly what happened during a user’s session and resolve support tickets faster.
A customer submits a support ticket: “My document disappeared and I didn’t do anything!” Before session tracking, this would require hours of log spelunking across multiple systems. With Immutable’s session tracking, you can reconstruct the exact sequence of events from the user’s session in seconds.
Support ticket #4821: “I was working on the Q3 Budget Report and it just vanished. I didn’t delete it. Please recover it ASAP.”Reporter: Lisa Wang (user_4f2a8c), submitted at 2026-03-27 10:15 AM.
from getimmutable import ImmutableClientclient = ImmutableClient( api_key="imk_sk_a1b2c3d4e5f6g7h8i9j0", base_url="https://getimmutable.dev")events = client.get_events(actor_id="user_4f2a8c", limit=50)sessions = list(set( e["session_id"] for e in events["data"] if e.get("session_id")))print("Recent sessions:", sessions)# ["sess_a8f3c2d1", "sess_7e4b9f2a", "sess_1c6d8e3f"]
The answer is clear: Lisa viewed and edited the document, then navigated to the Finance Team folder, moved the document to trash at 09:53:11, and emptied the trash 7 seconds later at 09:53:18. When she searched for the document 2 minutes later, it was gone.
This is not a bug — it’s user error. The session timeline provides clear evidence of the exact sequence of actions, eliminating guesswork and saving hours of investigation time.
import jsontrash_events = [ e for e in session_events["data"] if e["action"] in ("document.moved_to_trash", "trash.emptied")]for event in trash_events: print(f"\n--- {event['action']} ---") print(f"Time: {event['occurred_at']}") print(f"Resource: {event.get('resource_name')}") print(f"IP: {event['ip_address']} ({event['ip_city']}, {event['ip_country']})") print(f"Metadata: {json.dumps(event['metadata'], indent=2)}")
With this evidence, you can provide a clear, factual response:
Hi Lisa, I investigated ticket #4821. Our audit logs show that during your session on March 27th at 9:53 AM, the Q3 Budget Report was moved to the trash from the Finance Team folder, and the trash was emptied 7 seconds later. Both actions came from your IP address in Portland. This appears to have been accidental. I’ve restored the document from our backup — you should see it in your Finance Team folder now.
For session debugging to be effective, you need consistent session IDs across all events. Here’s how to set them up:
JavaScript
Python
Laravel
// Generate a session ID when the user logs inconst sessionId = `sess_${crypto.randomUUID().split("-")[0]}`;// Use the fluent builder to attach it to every eventconst session = client .actor(user.id, { name: user.name, type: "user" }) .session(sessionId);// All events in this session share the same session IDawait session.track("document.viewed", "document", { document_id: "doc_8f3a2c1d" });await session.track("document.edited", "document", { document_id: "doc_8f3a2c1d" });await session.track("document.saved", "document", { document_id: "doc_8f3a2c1d" });
import uuid# Generate a session ID when the user logs insession_id = f"sess_{uuid.uuid4().hex[:8]}"# Use the fluent builder to attach it to every eventsession = client.actor(user.id, name=user.name, type="user").session(session_id)# All events in this session share the same session IDsession.track("document.viewed", "document", {"document_id": "doc_8f3a2c1d"})session.track("document.edited", "document", {"document_id": "doc_8f3a2c1d"})session.track("document.saved", "document", {"document_id": "doc_8f3a2c1d"})
// In a middleware, set the session ID for all requestsAuditLog::fromAuth() ->session(session()->getId()) ->track('document.viewed', $document, [ 'document_id' => $document->id, ]);
Use your application’s existing session ID (from cookies or JWTs) as the Immutable session ID. This lets you correlate audit events with application logs and error tracking systems.