An application can register its own Event Types and Group Types, which for convenience can be mapped in static entities.
Each
Group Type and
Event Type should have a unique Id, to make sure it doesn't clash with another event type from a different application. The easiest way to guarantee that is to use UUIDs for each event type. Don't worry, you will only need to define the UUID once in the static entity. You can generate UUIDs at the following web site: .
https://www.uuidgenerator.net/guidEach
Group Type should indicate if the audit changes should be saved as JSONs (before and after) or field differences. For this add an attribute in the static entity to store that value. Each
Event Type should be related to a
Group Type, through a static attribute in the static entity mapping the respective foreing key.
To generate an audit log with change tracking, you can use either AuditEvent_WithObject or AuditEvent_WithJSON actions. These actions allow to specify a Before and After serialization, to record changes made by a user. The AuditEvent_WithObject receives two objects and automatically serializes them to JSON. The AuditEvent_WithJSON requires the developer to provide the JSON.
The simpler AuditEvent action may be used when there's no need for change tracking.
All audit actions automatically capture user information and date/time information, as well as many other information derived from the application context.
You can list audit logs by querying the entity AuditLog.