Edit history / audit — automatic change tracking
Grounded against origin/releases/7.0 (MibClient2 MediaiBox.Core.Audit, MibMicroServices EditHistory, MibServer3
EditHistoryDashboardRepository + PageHistoryV2Controller/UserHistoryV2Controller).
MIB records who changed which field of which entity, when — automatically, per field. Every create/update/delete flows through a repository listener that computes the field-level diff and writes an audit record to MongoDB (not SQL). Capture is global (every media type, minus configured ignore-lists) — you don't opt a media type IN. What a customization DOES control is visibility: the per-page "view history" drawer and the history dashboard are gated by a page flag. Use it for compliance trails, "who changed this and when", and per-user activity.
What gets recorded
Each change is a MibObjectChanges document (MibClient2 · MediaiBox.Core.Audit/MibAuditObjectChanges.cs:13-60):
| Field | Meaning |
|---|---|
RegisterId |
the row that changed |
MediaType |
the entity type (e.g. PRODUCT) |
User / Date |
who / when (UTC) |
Operation |
Added / Changed / Removed / AddedRelation / RemovedRelation |
ChangeDetails[] |
per field: { Field, PreviousValue, NewValue, Operation } |
PageKey / Source / RequestId / InstanceId |
where / origin / trace / tenant |
Capture is automatic (and global) — via a repository listener
On every save/create/delete the repository fires IRepositoryNotificationListener, which computes the diff and writes
it — either in-process to Mongo (MibAuditListener) or via the EditHistory microservice
(MibEditHistoryListener → MibEditHistoryMicroServiceClient). Storage is MongoDB, one collection per media type;
there is no SQL audit table. Capture is not opt-in per media type — it's on for all, tuned by config
(MibObjectNotificationConfig / MibMongoDbConfig.mibconfig, flattened like any .mibconfig — see
mib get playbook.config-change-mechanics):
mediaTypesToIgnore— comma-sep media types to skip (use for high-churn/temp tables).userIdsToIgnore— skip system/bot users (id1= system).listenerEnsureIndex(default true) — index onRegisterId.maximumEventsToBeProcess/intervalToCollectEvents— microservice batch size / window.
Viewing it — the dashboard & the two APIs
The audit trail surfaces two ways, both gated per page (so history isn't exposed everywhere capture happens):
- In-page "view history" drawer — one entity's timeline.
- History dashboard — changes across pages (
EditHistoryDashboardRepository+EditHistoryDashboard*PermissionChecker, which also honors SOURCE read scope —building-block.content-source).
APIs (MibServer3 · Controllers/API):
| Endpoint | Role |
|---|---|
GET /api/v2/edition-history/{pageKey}/{id}/mediaType/{mediaType} |
one entity's change timeline — the in-page "view history" drawer (EditionHistoryV2Controller) |
GET /api/v2/page-history/{pageKey}?id=&user=&startDate=… |
changes to records on a page (PageHistoryV2Controller) |
GET /api/v2/user-history?user=&pageKey=&mediaType= |
everything a user touched (UserHistoryV2Controller) |
POST /api/v2/user-history/export |
async TSV export of a filtered trail (202 → notification when ready) |
Enable the view for a custom page
Capture already happens; you enable the view with the page flag ALLOW_AUDIT_VIEW — grounded as
config-key.allow-audit-view → DisplayConfiguration.AllowAuditView (bool, default false, scope page-config, read
at render by DisplayWorkflow). Set it as page configuration the way your project sets any other page config; once on,
the stock page renders the history affordance and calls /api/v2/page-history/{pageKey} — no component code needed.
(The dashboard additionally honors a VisibleInHistoryDashboard-style flag to list a page in the global dashboard.)
Gotchas (grounded)
- Capture is global, not per-type — you can't turn it ON for one media type; you turn it OFF for others via
mediaTypesToIgnore. High-churn tables bloat Mongo fast. - No built-in retention (CANNOT-CONFIRM any purge in 7.0) — the audit store grows unbounded; archiving old collections is an ops/customization job.
- History outlives the row — deleting an entity does not clean its history (no FK cleanup); a
RegisterIdcan be orphaned. - No per-field ACL — visibility is page/mediatype-level; assume old values (incl. PII) are visible to anyone with history access. Mask upstream if needed.
- View ≠ capture — an off
AllowAuditViewhides the trail; it does NOT stop recording. - Dashboard honors SOURCE — the dashboard permission checker filters by source read scope, so a source-restricted
user sees a partial trail (
EditHistoryDashboardRepository.cs:162). - A related row's own edits and the parent's drawer (fixed in 7.0.5). Editing a field of an existing
related-list row, or deleting a child through a
Directrelation, is a request to the child's media type, so it was recorded under the child's history and never showed in the parent record's drawer. From 7.0.5 (MEDIAIBOX-12245) the related-list save sends the parent (_parentmediatype/_parentidon the PUT;AuditInformation.ParentMediaType/ParentRegisterId), the change document stores it, and the drawer joins child documents by it for every relation type — plus the olderDirect-column match, so documents written before the fix still show. Edits made before 7.0.5 carry no parent reference and stay invisible from the parent, except for rows of aDirectrelation: the drawer shows the whole history of such a row (its creation, its later edits and its deletion) for as long as it belonged to the record, from the entry that set its relation column to the record until the one that moved it elsewhere. That also covers components that write the row without sending the parent, such as GVP's live channels and device type actions, as long as the row's creation was audited. A table with noDirectrelation to the record inADM_RELATEDS(GVP's time shift) has nothing to join, so it needs that relation, plus audit permission on its media type, to show up. The drawer lists each stored entry once, even when a component re-reads a media type the main record already joined. Needs MibServer3, MibServerApi, MibClient2 and the EditHistory microservice at 7.0.5. The same release fixed aKeyNotFoundExceptionthat failed the whole save of an ordered related list when an existing row had no etag. - The record's drawer when the Edit History service cannot be read (7.0.x vs 7.1).
AuditWorkflow.GetListlogs the failure as[EditHistoryMicroService] Message: …and answersError = true. Up to 7.0.7 that answer carried no list, andEditHistoryDashboardWorkflow.GetHistoryListByItemenumerated it, soGET /api/v2/user-history?…&id=<record>&pageKey=<page>failed with a 500ArgumentNullException("Value cannot be null. (Parameter 'source')") and the drawer never left its loading state, on every page withALLOW_AUDIT_VIEW. From 7.1.0 the BFF answers that read with the 503 of MEDIAIBOX-12045 ("Not possible to access history…"), and MEDIAIBOX-12431 makes the error answer carry an empty list, so no caller can hit the null again (MibServer3 main · MediaiBox.Cms.FrontEnd.Workflow.Mvc/Audit/AuditWorkflow.cs:70,…/EditHistoryDashboard/EditHistoryDashboardWorkflow.cs:305-313). A 7.0.x environment that shows this 500 has the unavailable service of the 503, not a page bug: find the[EditHistoryMicroService]line in the BFF log and restore the service.
Discover
mib get building-block.edit-history · the enable flag: mib get config-key.allow-audit-view · config flattening:
mib get playbook.config-change-mechanics · source scoping: mib get building-block.content-source.