CognxSafeTrack
feat: backlog P0βP3 β toast system, payments, tenant isolation, feedback handler, i18n parity
6dd9bad Technical Debt Audit: WhatsApp Unification & AI Integration
1. Summary
Following the implementation of Phases 1 & 2 of the WhatsApp unification, this audit identifies remaining technical debt and areas for hardening before full production scaling.
2. Identified Debt Items
2.1. Typing & Type Safety (High Impact) β οΈ
- Issue: Extensive use of
anyinTemplateSelector.tsx,ConversationalDashboard.tsx, andCrmAIAssistant.tsxfor message payloads and template data. - Risk: Runtime crashes if API response structure changes (e.g., Meta API updates).
- Recommendation: Define central interfaces for
WhatsAppTemplate,CrmMessage, andBulkSendPayloadin a shared types package.
2.2. Centralized API Handling (Medium Impact) π
- Issue: Many components (Dashboard, Setup pages) use raw
fetchwith manual header injection (Authorization: Bearer ${token}). - Risk: Hard to maintain, inconsistent error handling (some use
alert(), othersconsole.error()). - Recommendation: Standardize usage of the existing
lib/api.ts(if it exists/is robust) or implement a centralapiClientwith automatic interceptors for 401/500 errors.
2.3. Internationalization Coverage (Medium Impact) π
- Issue: Some strings in
TemplateSelector.tsxandConversationalDashboard.tsxhave hardcoded defaults (e.g.,t('...', 'Default String')). - Risk: If new languages are added, these hardcoded strings might bypass the translation files.
- Recommendation: Audit
locales/files to ensure all new keys (crm.campaigns.select_template, etc.) are present in EN, FR, ES, PT.
2.4. Error State UI (Low Impact) π¨
- Issue: When
TemplateSelectorfails to fetch, it only logs to console. The user might see an empty list without knowing why. - Risk: Poor UX/Support overhead.
- Recommendation: Add a "Retry" button or a clear error message in the dropdown when fetching fails.
3. Post-Unification Hardening Tasks
- Migrate
TemplateSelectortemplates list fromany[]toWhatsAppTemplate[]. - Replace
alert()calls with a proper Toast notification system. - Centralize the
broadcastAPI endpoint logic to avoid duplicate fetch code.
Audit Date: 2026-05-08 Auditor: Antigravity (AI Assistant)