Overview
src/lib/logging/sms-aggregator.ts stores all SMS log records in a module-level array capped at 5,000 entries. In a high-volume SMS scenario this consumes significant heap memory, and all data is lost on server restart — making it impossible to query historical delivery metrics or troubleshoot past failures.
Specifications
Features:
- SMS logs are written to a persistent store (database or append-only log file)
- In-memory buffer is small (e.g., 100 entries) for fast recent-query access only
Tasks:
- Add a database table
sms_logs with columns for all fields tracked by the aggregator
- Flush the in-memory buffer to the database on a configurable interval or when the buffer reaches capacity
- Update query methods to fall back to database queries for historical data
Impacted Files:
src/lib/logging/sms-aggregator.ts
src/lib/db/ (new migration)
Acceptance Criteria
- SMS logs survive a server restart
- Historical queries beyond the in-memory buffer hit the database
- Memory usage does not grow with SMS volume
Overview
src/lib/logging/sms-aggregator.tsstores all SMS log records in a module-level array capped at 5,000 entries. In a high-volume SMS scenario this consumes significant heap memory, and all data is lost on server restart — making it impossible to query historical delivery metrics or troubleshoot past failures.Specifications
Features:
Tasks:
sms_logswith columns for all fields tracked by the aggregatorImpacted Files:
src/lib/logging/sms-aggregator.tssrc/lib/db/(new migration)Acceptance Criteria