GoFilament
You're reading the docs for v1.36.0, an older release. Go to v1.40.1 (latest).

Docs v1.36.0 Guide

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 (call it after the On* handlers)
activitylog.EnableAuditLog(userResource)
// Or via the top-level helper:
gofilament.EnableAuditLog(userResource)

// With options: never store these fields' values
activitylog.EnableAuditLogWith(userResource, activitylog.AuditOptions{Except: []string{"ssn"}})
  • Record history: the view and edit pages get a History section (who, when, each changed field before → after), the API serves it at GET /admin/api/resources/:slug/:id/history, and the Flutter record form has a History button. It is shown to users who can view the record; resource.HistoryVisible(fn) narrows that, AuditOptions.NoHistory turns it off.
  • Only fields that really changed are recorded (form fields are matched to the record’s keys, so FullName and full_name are the same field); an update that changes nothing is not logged. Inline cell edits and bulk deletes are logged too.
  • Password fields, fields named like *password*, *secret*, *token* and AuditOptions.Except are stored as “(hidden)” / “(changed)”, never their values.
  • In OnCreate, call filament.SetCreatedID(ctx, id) so the “created” entry belongs to the new record.

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 (AA for Alice Admin) with hoverable exact timestamps and relative time representation (“just now”, “15 minutes ago”, “yesterday”).
  • Standalone Audit Resource: Mount gofilament.NewActivityResource() (or activitylog.NewActivityResource()) to provide administrators with a complete audit browsing and search interface in the panel navigation.

Generated from README.md at v1.36.0 · released Nov 17, 2026