From 6fc804480f0f94418093db43f39440748883cf28 Mon Sep 17 00:00:00 2001 From: Jose Andres Tejerina Date: Tue, 7 Oct 2025 18:11:16 -0300 Subject: [PATCH] chore: add summit_id to OTLP log and flatten PersistentCollection data --- app/Audit/AuditLogOtlpStrategy.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/Audit/AuditLogOtlpStrategy.php b/app/Audit/AuditLogOtlpStrategy.php index 0142e8aca..87fdb5151 100644 --- a/app/Audit/AuditLogOtlpStrategy.php +++ b/app/Audit/AuditLogOtlpStrategy.php @@ -137,17 +137,28 @@ private function buildAuditLogData($entity, $subject, array $change_set, string 'audit.entity_class' => get_class($entity), 'audit.timestamp' => now()->toISOString(), 'audit.event_type' => $event_type, - 'auth.user.id' => $user_id, - 'auth.user.email' => $user_email, + 'auth.user.id' => $user_id ?? 'unknown', + 'auth.user.email' => $user_email ?? 'unknown', 'elasticsearch.index' => $this->elasticIndex, ]; + if (method_exists($entity, 'getSummitId')) { + $summitId = $entity->getSummitId(); + if ($summitId !== null) { + $auditData['audit.summit_id'] = (string) $summitId; + } + } + switch ($event_type) { case self::EVENT_COLLECTION_UPDATE: if ($subject instanceof PersistentCollection) { $auditData['audit.collection_type'] = $this->getCollectionType($subject); $auditData['audit.collection_count'] = count($subject); - $auditData['audit.collection_changes'] = $this->getCollectionChanges($subject, $change_set); + + $changes = $this->getCollectionChanges($subject, $change_set); + $auditData['audit.collection_current_count'] = $changes['current_count']; + $auditData['audit.collection_snapshot_count'] = $changes['snapshot_count']; + $auditData['audit.collection_is_dirty'] = $changes['is_dirty'] ? 'true' : 'false'; } break; }