Module: Gitlab::Audit::Logging

Included in:
AuditEventService, Auditor
Defined in:
lib/gitlab/audit/logging.rb

Constant Summary collapse

ENTITY_TYPE_TO_CLASS =
{
  'User' => ::AuditEvents::UserAuditEvent,
  'Project' => ::AuditEvents::ProjectAuditEvent,
  'Group' => ::AuditEvents::GroupAuditEvent,
  'Gitlab::Audit::InstanceScope' => ::AuditEvents::InstanceAuditEvent
}.freeze

Instance Method Summary collapse

Instance Method Details

#log_to_new_tables(events, audit_operation) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/gitlab/audit/logging.rb', line 13

def log_to_new_tables(events, audit_operation)
  return [] if events.blank?

  events.group_by(&:entity_type).flat_map do |entity_type, entity_events|
    log_events(entity_type, entity_events)
  end
rescue ActiveRecord::RecordInvalid => e
  ::Gitlab::ErrorTracking.track_exception(e, audit_operation: audit_operation)
  []
end