Audit log

I am looking to add an audit log within the form model for CDM, and I’m wondering if A12 has a library to track CDM changes or if there’s any recommended approach for achieving this. Initially, I considered using event listeners, but they seem to capture only DM changes. However, I specifically need to capture CDM changes. I am aiming for a dynamic solution, where changes in the CDM will be automatically reflected in the audit logs for the modified fields. Any suggestions or insights on how to achieve this would be greatly appreciated.

The CDM functionality itself is based on the DocumentGraph and Changelog concepts. Any change to a CDD (Composed Data Document - the data to a CDM) is reflected in the DocumentGraph and the Changelog. Those two parts are always updated whenever the data changes.
The changelog keeps track of modified documents & added/removed/modified links. The granularity is documents & links. It does not go to the field level.
You should find those types in the Client API documentation in the DocumentGraph (and CDM) extension.
If the changelog does not contain the information that you need, I would propose to listen to the DocumentGraph and CDD actions. Most notably: CDD/addCddLink, CDD/changeCddDocument and DG/removeLink. Those should hopefully contain the information you’re interested in.

Please check the redux state and its transitions with the redux dev tool in the browser. It should help you to quickly find out which changes are already tracked.

However, please note that this API is currently declared as experimental. Thus, you have to be aware that upcoming A12 versions might break your solution.