How to hook into the Lead audit log

Hey there,

I would like to show data in the lead’s audit log (/contacts/auditlog/{leadId}).

It seems that the audit log offers no way to hook into.

The devdocs only mention hooking into the history.

Is there a way? If so, how?

Kind regards

You can listen for the LeadEvents::TIMELINE_ON_GENERATE event. Almost all bundles and plugins do so if you’d like more examples:

Thanks for your reply.

I had a short look into the LeadEvents::TIMELINE_ON_GENERATE event. I figured it lets you only hook into the contact’s history “log”, but not into the audit log (marked in the screenshot):

Am I mistaken?

Oh, in that tab. It shows all audit log entries that are in the audit_log table for that contact, right? Why don’t you just store the information you want to see there in that table?

I do. :smiley:

bundle object object_id
lead myplugin 462

I guess, since object!=lead the entry isn’t picked up. Hence, I asked how to hook into this page/table.

Well, of course. Your row must fit the where conditions as you mention in the forum post:

It should only show changes to the lead object. If it’s related to another object then it shouldn’t show up in the lead audit log. I’d re-consider if the entry shouldn’t show up in the timeline as that’s where all events related to the contact show up. But you know better what your use case is.

Gotcha. I had a wrong conception of the audit log.

I’ll figure out if a timeline entry is more fitting or changing this to lead event type, so it shows up in the audit log.

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.