Audit Trail & Call Logs (Admin)
Audience: Support escalations · Engineering · Ops · Where in app: Admin → Logs & Events → Audit Trail (/admin/audit-logs) and Call Logs (/admin/call-logs) · Access: Super-admin only — both controllers return 403 unless request.user.user_type === 'admin'.
Two read-only forensic surfaces. The Audit Trail answers "who changed this setting/record, when, from what to what". Call Logs answers "what happened, step by step, on this call" — across server, sockets, the widget and the dashboard.
Audit Trail — /admin/audit-logs
How it works
backend/app/lib/auditLog.js is a Mongoose schema plugin (auditPlugin) attached to 39 models. On every create/update/delete it reads the document before and after, diffs the leaves, and writes one row to audit_logs (AuditLogModel). Shipped 2026-10-06 (378faa826/e4f72967c, frontend 6be764ec).
- Actor.
app.middlewares.passportwraps the request inrunWithActor(anAsyncLocalStoragecontext), so every write the request causes is stamped withactor.{user_id, email, user_type}andactor.source="<METHOD> <path>". Writes outside a passport request (cron jobs, webhooks, api-key/migrations/*routes) log assource: 'system'. - Best-effort. Audit writes never fail or delay the audited write.
- Diff shape.
changesis{ 'path.to.field': { from, to } }; arrays compare whole; values over 2,000 chars are truncated.select:falsefields are read too, so a secret rotation shows up (as[redacted]→[redacted]). - Redaction. Any path matching
pass(word)|token|secret|api_key|private|hash|otp|credential|invite_key|*_enc|authorization|signing|webhook_url|webhook_headeris[redacted], including keys nested inside arrays (e.g. an agent'swebhook_secret). Models can add extraredactpaths. - Ignored paths. Per-model
ignorelists machine-written fields (counters, heartbeats, online status, token refreshes, billing cursors,knox.cumulative_*, recaplast_sent_at…). A write that touches only ignored paths skips auditing and its before/after reads entirely — this is what keeps the plugin cheap on hot paths. - Bulk actions.
updateMany,deleteMany, multi-docinsertManyandbulkWritewrite one entry withbulk: true,record_ids(max 1,000;truncated: truebeyond),record_count, and the redacted filter/update inoperation— not a per-document diff. - Identity records.
people/person_profiles(resolver-owned): deletes always (ids only, no snapshot), edits only when the actor is a super-admin repairing by hand, not viaPOST /admin/identity/maintenance/*sweeps (adminEditsAndDeletes). Resolver traffic is never logged. - Settings.
settingsskips its two job-cursor keys. Upsert-creates are logged ascreate. - Tenant stamp.
company_id/agency_idare filled from the record so a company filter finds its rows. - Retention. TTL index on
created_at— 180 days.
Audited collections: companies, agencies, users, teams, branches, subscriptions, agency_subscription, user_invoices, agency_client_billings, packages, agency_packages, addons, agency_addons, agency_invites, agency_domains, webhooks, platform_webhooks, automation_rules, bot_flows, chatbots, page_rules, call_auto_trigger, company_faqs, company_websites, ai_conversations, blocked, do_not_contacts, knox_visitor_directives, identity_graph_defaults, people, person_profiles, settings, certification_applicants, certification_cohorts, certification_tests, partner_certifications, partner_invite_codes, defaultvideos, default_call_background. To audit another model add Schema.plugin(auditPlugin, { ignore: [...] }) — and list its machine-written fields in ignore, or every heartbeat becomes an entry.
Screen
Filters: record type (grouped Accounts / Billing / Integrations / Tenant config / Identity / …), action (create / update / delete), record ID, company ID, actor email (case-insensitive substring), date range. Rows expand to the field-by-field changes, or for bulk entries to the operation and the affected ids. ?record_id= and ?company_id= deep-link a record's or tenant's history. Record/company IDs only enter the query once they are a complete ObjectId; search inputs debounce 500 ms like every admin list.
Endpoint
GET /admin/audit-logs (AuditLogController@index, routes/auditLogRoutes.js) — query collection_name, action, record_id, company_id, actor, start_date, end_date, skip, limit (max 100). A record_id filter also matches bulk entries whose record_ids contain it. Queries cap at maxTimeMS 15 s; an unfiltered count uses estimatedDocumentCount. Indexes: {collection_name, record_id, created_at}, {record_ids, created_at} (sparse), {company_id, created_at}, {actor.user_id, created_at}.
Not to be confused with the Nox Funnel Audit (/admin/nox-funnel/audit-logs, funnel signal trail — see Nox admin), the person-level identity audit on Person detail, or AI Credit Logs (credit ledger).
Call Logs — /admin/call-logs
How it works
Every call — AI or human, web or phone — has a service_rooms document, so its id is the call id. Since 2026-10-06 (backend 0e183b2e1/60c81f408, frontend 460ff2a7, ms-communication 6f8798e) each room carries call_logs, an array of step entries { at, source, event, message, level, data } written by ms-communication's app/helpers/CallLogHelper.js:
source | Where it comes from |
|---|---|
server | every LokiService.log(service_room_id, …) in ms-communication (call lifecycle) |
socket | call socket events that name a room (SocketService middleware) |
widget / dashboard | client steps sent on the call-log socket event — the dashboard's src/utils/callLog.js batches per room and flushes every second (e.g. ringing, room joined, hang-up) |
- Writes are batched (one
$pushper room per second) and capped at the last 1,000 entries ($slice). Logging never throws or blocks the call path. datadrops keys matchingtoken|secret|password|authorization|api_key(Twilio access tokens never land here) and is truncated at 4,000 chars; messages at 500.- Client timestamps are trusted only within 5 minutes of server time, else the arrival time is used.
- The field is
select: falseand everyCallControlleraggregate projects it out — read it only withselect('+call_logs').
Screen & endpoints
The list shows calls that have at least one log entry, newest first, with log/error/warn counts and the last step time; filters: company ID, search by service-room id or session id, kind (AI / human), errors only, date range, page size. A row opens the step timeline (CallLogTimeline.vue).
GET /admin/calls/logs(AdminCallsController@listCallLogs) —company_id,search(must be an ObjectId),kind=ai|human,errors_only=true,start_date/end_date(applied as an_idrange),skip,limit(default 5, max 100).GET /admin/calls/:id/logs(@showCallLogs) — the room's call metadata + its logs sorted byat.
Related
- Admin overview · Media & logs (API request, email and system logs)
- Backend service · Observability