Add audit event when the "Collect usage data" setting is changed
What does this MR do and why?
Adds an audit event when the "Collect usage data" (ai_usage_data_collection_enabled) setting is changed on a group. This allows administrators to track who changed the setting and when.
Closes #595736
Implementation
The ai_usage_data_collection_enabled setting is stored in the namespace_ai_settings table (via Ai::NamespaceSetting), separate from the namespace_settings table that is already audited by NamespaceSettingChangesAuditor.
This MR adds:
-
Namespaces::AiNamespaceSettingChangesAuditor- A new auditor class following the same pattern asNamespaceSettingChangesAuditor, but for thenamespace_ai_settingstable. Currently auditsai_usage_data_collection_enabled, but is designed to be extensible for futureAi::NamespaceSettingcolumns. -
Integration into
GroupChangesAuditor- The new auditor is called fromGroupChangesAuditor#execute, alongside the existingNamespaceSettingChangesAuditorandNamespaceDetailChangesAuditorcalls. -
Audit event type YAML -
ai_usage_data_collection_enabled_updatedevent type definition. -
Tests - RSpec tests for the new auditor.
References
- Issue: #595736
- Related feature: #587976 (closed)
Screenshots or screen recordings
No UI changes.
| Before | After |
|---|---|
| No audit event logged when "Collect usage data" setting is changed | Audit event ai_usage_data_collection_enabled_updated is logged with from/to values and actor |
How to set up and validate locally
- Enable the feature in rails console or via the group settings UI
- Navigate to a group's GitLab Duo settings and toggle the "Collect usage data" setting
- Check the audit log for the group - you should see an
ai_usage_data_collection_enabled_updatedevent with the old and new values
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
