Overview
APTIV Scrap Control maintains a complete audit trail of all system changes, providing accountability and compliance tracking for manufacturing operations.Audit Log Structure
types.ts
Database Schema
schema.sql
Tracked Events
Scrap Records
- Create: New scrap entry registered
- Update: Modification to weight, cost, or defect mode
- Delete: Soft delete (sets ELIMINADO=1)
User Management
- Create: New user account created
- Update: Role change, area reassignment, or password reset
- Deactivate: Account disabled (activo=0)
Catalog Changes
- Create: New catalog entry (part, defect, area, shift, line)
- Update: Modification to catalog data
- Delete: Catalog entry deactivated
Tolerance Configuration
- Create: New tolerance threshold defined
- Update: Threshold values or alert percentages changed
- Delete: Tolerance removed
Permission Changes
- Update: Role permissions modified
- Assign: User role changed
Audit Log Component
TheAuditPage.tsx component displays the audit trail with filtering and search:
AuditPage.tsx
Creating Audit Entries
Frontend Audit Helper
store.ts
Backend Audit Logging
audit.js
Audit Log Display
List View
The audit page displays logs in a table format:| Timestamp | User | Action | Entity | Record ID | Changes |
|---|---|---|---|---|---|
| 2024-03-06 14:30 | admin | update | pesaje | 1234 | View |
| 2024-03-06 14:15 | calidad | create | catnp | 567 | View |
| 2024-03-06 14:00 | supervisor1 | delete | pesaje | 890 | View |
Change Detail View
Clicking “View” expands the changes JSON:Filtering and Search
- By Action
- By Entity
- By Date Range
- By User
Filter by action type:
- Create: New records added
- Update: Existing records modified
- Delete: Records soft-deleted
Export Audit Logs
Audit logs can be exported for compliance reporting:Common Use Cases
Investigate Data Discrepancy
Investigate Data Discrepancy
When a scrap value doesn’t match expectations:
- Search for the record ID in audit logs
- Review all update actions
- Check who made changes and when
- Compare before/after values in changes JSON
Track User Activity
Track User Activity
Monitor what actions a user has performed:
- Filter by user ID
- Select date range (e.g., last week)
- Review create/update/delete patterns
- Identify any unusual behavior
Compliance Reporting
Compliance Reporting
Generate audit reports for regulatory requirements:
- Filter by date range (e.g., last quarter)
- Select relevant entities (e.g., pesaje, usuarios)
- Export to CSV
- Include in compliance documentation
Troubleshoot Configuration Changes
Troubleshoot Configuration Changes
Identify when a system setting was changed:
- Filter by entity type (roles, tolerancias)
- Review update actions
- Check changes JSON for the specific setting
- Revert if needed by manually updating
Retention and Cleanup
Audit logs are retained indefinitely by default. For database maintenance, implement a retention policy:Performance Considerations
For large audit log tables:-
Add indexes to speed up queries:
- Paginate results in the UI (show 50 logs per page)
- Archive old logs to a separate table or backup file
- Limit date range in queries to prevent full table scans
Related Pages
Roles & Permissions
Permission changes are tracked in audit logs
User Management
User account changes are logged
API: Audit
Retrieve audit logs via API
Backup & Restore
Audit logs are included in backups