Activity Log & Audit Trail Timeline (pkg/activitylog)
GoFilament features a comprehensive, production-grade Activity Log & Audit Trail package for tracking entity history, user actions, system events, and changesets:
1. Fluent Activity Logger#
// Log custom actions anywhere in your application
activitylog.Log("Customer credit limit increased").
Subject("Customer", "42").
Causer("Admin", "1", "Alice Admin").
Event("updated").
WithDiff(
map[string]any{"credit_limit": 5000},
map[string]any{"credit_limit": 15000},
).
Property("approved_by_finance", true).
IP(c.ClientIP()).
Save(c.Request.Context())
2. Automated Resource Auditing (Zero Boilerplate)#
Automatically track all Create, Update, and Delete actions with pre/post changeset diffs and authenticated causers:
userResource := filament.NewResource[*ent.User]("users")
// Automatically logs all CRUD actions on the resource
activitylog.EnableAuditLog(userResource)
// Or via the top-level helper:
gofilament.EnableAuditLog(userResource)
3. Vertical Audit Timeline & Infolist Component#
Embed visual audit timelines with interactive diff inspectors directly inside resource View schemas:
userResource.Infolist(func(infolist *infolists.Infolist) *infolists.Infolist {
return infolist.Schema(
infolists.Section("User Details").Schema(
infolists.TextEntry("name"),
infolists.TextEntry("email"),
),
infolists.Section("Audit Trail & History").Schema(
activitylog.TimelineEntry("activities").
Title("Recent Activity").
Filterable(true). // Live client-side event filtering and search
CollapsibleDiffs(true), // Expandable changeset diff accordions
),
)
})
- Interactive Changeset Diff Inspector: Expands before/after comparison tables showing field changes with strikethrough red pills for previous values and green pills for updated values.
- Continuous Connected Timeline Spine: Visual status node circles with event icons (plus for created, pencil for updated, trash for deleted, check for approved, etc.).
- Actor Badges & Fallbacks: Renders actor avatars or automatic initials badges (
AAfor Alice Admin) with hoverable exact timestamps and relative time representation (“just now”, “15 minutes ago”, “yesterday”). - Standalone Audit Resource: Mount
gofilament.NewActivityResource()(oractivitylog.NewActivityResource()) to provide administrators with a complete audit browsing and search interface in the panel navigation.