Repository navigation
Closed
Labels
priority: highHigh priority
Description
Problem Statement
As a B2B commercial project, Tale needs comprehensive audit logging for:
- SOC 2 Compliance: User activity tracking, access logs, change logs
- GDPR Compliance: Right to access audit, data subject requests
- Security: Detection of unauthorized changes, suspicious patterns
- Operational: Troubleshooting who made what change when
Current State
- NO dedicated audit logging exists in the codebase
- TODO comments in
member.ts:432andmember.ts:604: "Add audit log entry in a dedicated audit table" - Existing infrastructure available:
- RLS system with user/organization context
- Better Auth for authentication
- Multi-tenancy (organization + team model)
Proposed Solution
Create a comprehensive audit logging system with:
- Dedicated
auditLogsConvex table with proper indexing - Reusable audit logging helper functions
- Integration with all critical mutations (92 total identified)
- Query/export API for compliance reporting
- Retention policy with archival strategy
Affected Components
-
convex/schema.ts- Add auditLogs table definition -
convex/lib/audit/- New audit logging helpers -
convex/model/audit_logs/- Validators and model functions -
convex/audit_logs.ts- Public query/mutation API -
convex/member.ts- Add audit logging to member mutations -
convex/team_members.ts- Add audit logging -
convex/integrations.ts- Add audit logging -
convex/email_providers.ts- Add audit logging -
convex/products.ts- Add audit logging -
convex/customers.ts- Add audit logging -
convex/documents.ts- Add audit logging -
convex/vendors.ts- Add audit logging -
convex/wf_definitions.ts- Add audit logging -
convex/approvals.ts- Add audit logging -
convex/crons.ts- Add retention job - Admin UI for viewing audit logs
Acceptance Criteria
-
auditLogstable created with proper schema and indexes - Audit logging helpers created with sensitive field redaction
- All Priority 1 mutations (member management) have audit logging
- All Priority 2 mutations (integrations) have audit logging
- All Priority 3 mutations (business data CRUD) have audit logging
- All Priority 4 mutations (workflows/approvals) have audit logging
- Query API supports filtering by category, resourceType, actor, date range
- Export functionality for CSV/JSON format
- Admin UI for viewing audit logs
- Retention policy implemented (90 days hot, 7 years archived)
- SOC 2 compliance requirements met
- GDPR compliance requirements met
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
priority: highHigh priority
Activity
larryro commentedon Jan 15, 2026
Implementation Plan
Phase 1: Foundation - Schema & Core Helpers
1.1 Add
auditLogstable to schemaFile:
services/platform/convex/schema.ts1.2 Create audit logging helpers
New files:
convex/lib/audit/create_audit_log.ts- Core logging function with sensitive field redactionconvex/lib/audit/audit_helpers.ts- Convenient wrappers for different operation typesconvex/lib/audit/index.ts- Barrel exportconvex/model/audit_logs/validators.ts- Validators for audit log typesKey features:
Phase 2: Add Audit Logging to Critical Mutations
Priority 1: Member & Access Control (Most Critical)
member.tsaddMemberadd_membermember.tsremoveMemberremove_membermember.tsupdateMemberRoleupdate_rolemember.tsupdateMemberDisplayNameupdate_nameteam_members.tsaddMemberadd_team_memberteam_members.tsremoveMemberremove_team_memberPriority 2: Integration & Security Operations
integrations.tscreatecreate_integrationintegrations.tsupdateupdate_integrationintegrations.tsdeleteIntegrationdelete_integrationemail_providers.tscreatecreate_email_provideremail_providers.tsdeleteProviderdelete_email_provideremail_providers.tsstoreOAuth2Tokensupdate_oauth_tokensPriority 3: Business Data CRUD
products.tscreateProductPublic,updateProduct,deleteProductcreate,update,deletecustomers.tsupdateCustomer,deleteCustomer,bulkCreateCustomersupdate,delete,bulk_createdocuments.tscreateDocumentFromUpload,updateDocument,deleteDocumentcreate,update,deletevendors.tsupdateVendor,deleteVendor,bulkCreateVendorsupdate,delete,bulk_createPriority 4: Workflow & Approvals
wf_definitions.tspublishDraftPublic,deleteWorkflowPublicpublish_workflow,delete_workflowapprovals.tsupdateApprovalStatusPublic,executeApprovedIntegrationOperationapprove/reject,execute_integration_operationPhase 3: Query & Export API
New file:
convex/audit_logs.tsgetAuditLogs- Paginated logs with filtering (category, resourceType, actor, date range)getResourceAuditTrail- Audit history for a specific resourcegetActivitySummary- Dashboard statisticsexportAuditLogs- CSV/JSON export for compliance reportingPhase 4: Admin UI
New files in:
src/app/[locale]/(default)/settings/audit-logs/page.tsx- Audit logs list page with filterscomponents/audit-log-table.tsx- Data table componentcomponents/audit-log-filters.tsx- Filter controlscomponents/audit-log-detail-dialog.tsx- Detail viewPhase 5: Retention & Archival
Add scheduled job to
crons.ts:Files to Modify
convex/schema.tsauditLogstable definitionconvex/lib/audit/*.tsconvex/model/audit_logs/*.tsconvex/audit_logs.tsconvex/member.tsconvex/team_members.tsconvex/integrations.tsconvex/email_providers.tsconvex/products.tsconvex/customers.tsconvex/documents.tsconvex/vendors.tsconvex/wf_definitions.tsconvex/approvals.tsconvex/crons.tssrc/app/.../settings/audit-logs/*.tsxmessages/en.json,messages/zh.jsonPotential Risks
Testing Strategy
turbo run build --filter=platformturbo run typecheck --filter=platformCompliance Features
🤖 Generated with Claude Code
larryro commentedon Jan 15, 2026
Related to #190 (Add example on how to export audit logs) - This issue implements the comprehensive audit logging system that #190 will document export examples for.
feat(audit-logs): add audit logs schema and core helpers
feat(audit-logs): integrate audit logging into member mutations
feat(audit-logs): integrate audit logging into integration mutations
feat(audit-logs): integrate audit logging into approval mutations
feat(audit-logs): add retention cron job
feat(audit-logs): add audit logs admin UI