audit-stash
audit-stash copied to clipboard
Why doesn't AuditDeleteEvent track the original entity?
The AuditDeleteEvent implements EventInterface but unlike AuditCreateEvent and AuditUpdateEvent, does not extend the BaseEvent class and as such, does not keep track of the original and changed values.
We know that the changed value is meaningless on a delete, but it seems like it should be tracking the original value shouldn't it?
If this were to be added, could it simply be passed to the AuditDeleteEvent::__construct() as an optional (default null) value?
I'd be happy to patch unless there's a specific reason the original entity data is not being tracked on deletes.
Thanks!
What's the purpose of having the original data there for you?
For my uses, our application is mostly used internally by company employees, and being able to track when an entity was deleted (perhaps carelessly or mistakenly) by an employee seems useful. I can however also see why someone would not care to track that.
@kevinquinnyo but this does track when the entity was deleted, doesn't it? Or you mean that you wanted to store the last known state of the entity before it gets deleted
Or you mean that you wanted to store the last known state of the entity before it gets deleted
Yes. I was thinking that the ~~primary key of the record that was deleted~~ date the record was deleted isn't too meaningful from the perspective of an audit trail, so it would be nice to see what data was there previously.
edit: still need more coffee, brain not working
You also get the primary key of the record. The way I use this internally is that I show all events per primary key. I can see a full history of changes from the moment it gets created to the moment it gets deleted.
I don't see a problem in having the original entity in the delete event, though. If you send a PR with tests I'll merge it
@lorenzo that's a good point actually. It might still be a good idea to have it on the delete event in case the entity was originally seeded through migrations or otherwise not tracked by the behavior.
I might send a PR later if I think I still need it, thanks!
Having the deleted data would be useful for me, as most of my users just look through Kibana to see changes. This would save them some time for seeing what was deleted.
Hi.. very useful plugin, but as kevinquinnyo commented, it's useful to see what data was deleted and not only the primary key.. can you add this? I will try to add this functionality.. but if someone already did it.. please share..
I'm willing to accept pull requests for this
+1 Having the deleted entity captured would be helpful (for restoring entity in case of accidental deletion). @kevinquinnyo were you able to create a PR for this?
@bmudda @GeekWiinik @lorenzo I finally found a half hour today to try adding this. https://github.com/lorenzo/audit-stash/pull/35
The problem is making sure not to break backwards compatibility with the previous AuditDeleteEvent
signature, and I don't think it's quite right. I can probably add some tests soon.
Seems like PR was merged.