- Phases 1-5 : masquage JSON avancé, chat IA global (AdminChat),
onboarding WhatsApp guidé, templates assistés IA, agent IA setup guidé
- i18n exhaustif : ~70 nouvelles clés en FR/EN/ES/PT pour tous les
composants ajoutés (AdminChat, AIAgentSetup, SettingsPage,
TemplatesPage, OnboardingWizard)
- Chat IA multilingue : l'assistant répond désormais dans la langue
de l'utilisateur (FR/EN/ES/PT) sur toutes les pages
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Frontend (BillingPage):
- Renommage "Wallet" → "Crédits disponibles" (langage non-technique)
- Badge projection dynamique "À ce rythme : encore ~X jours" calculé
depuis les transactions des 7 derniers jours
- Questions suggérées cliquables (quick-reply chips) avant le 1er message
- Suppression "Tokens entrants/sortants" (jargon incompréhensible)
- Transactions filtrées : BYOK masqué, layout liste simple vs tableau
- Section "Où vont vos crédits IA ?" remplace le jargon feature/type
- Indicateur de frappe animé (3 points) dans le chat
- Packs recharge avec explication "≈ N messages IA" et badge populaire
- Texte WhatsApp clarifié : "Gratuit pour vous — Meta facture directement"
Backend (billing.ts /chat):
- Wallet balance + isHardStopped ajoutés dans le contexte IA
→ l'assistant peut maintenant répondre "combien de crédits me reste-t-il"
- Burn rate (débit moyen 7j) calculé et injecté : "À ce rythme,
votre solde durera encore X jours"
- Statut wallet (SUSPENDU / bas / actif) expl…
feat(billing): close 3 remaining wallet gaps from implementation plan
CognxSafeTrack+1: Claude Sonnet 4.6
f5126bc
⑫ sendTextMessage() wallet debit coverage:
- Add organizationId?: string to sendTextMessage() config — calls trackWhatsAppSent() automatically after each successful send
- NudgeHandler, ContentHandler, EnrollHandler, MediaHandler, AdminHandler: pass organizationId in tenantConfig so every outbound message triggers the debit without touching each callsite individually
⑯ GET /billing/summary now includes wallet block:
- wallet: { balance, isHardStopped, creditToFcfa, balanceFcfa } appended to every summary response
⑱ BillingPage: wallet transaction table:
- Table showing last 20 transactions (date, type, description, amount, balance after)
- Type labels with emoji (recharge vs debit), BYOK badge, red/green amount colouring
- Inserted between feature breakdown and chat widget
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feat(billing): implement full wallet/ledger system with hard-stop enforcement
CognxSafeTrack+1: Claude Sonnet 4.6
0fd3320
- Add walletBalance + isHardStopped to Organization schema; WalletTransaction ledger model with full audit trail
- wallet.ts (worker): debitWallet (atomic $transaction), creditWallet (with AuditLog), checkWalletBalance (Redis 30s cache), alert queuing (low/critical/exhausted/restored)
- wallet.ts (api): creditWallet for admin top-up with cache invalidation
- usage-tracker.ts: debitWallet integrated into trackAiUsage, trackAudioUsage, trackWhatsAppSent; BYOK orgs skipped
- BroadcastHandler + CampaignHandler: bulk debit after send (BROADCAST_PER_USER per recipient)
- requireCredits.ts: migrated from aiCreditsUsed/Limit to walletBalance/isHardStopped; shares Redis cache key with worker
- whatsapp-logic.ts: replaced assertCredits/CreditExhaustedError with checkWalletBalance/WalletExhaustedError
- ai.ts: added requireCredits preHandler to all 11 AI routes (was 4)
- billing.ts: /admin/allocate now calls creditWallet(); new GET /wallet route (balance + 20 last txns)
- BillingPage: wallet card…
feat(billing): enforce AI credit limits across all surfaces
CognxSafeTrack+1: Claude Sonnet 4.6
6484585
- credit-guard.ts (worker): assertCredits() blocks AI when creditsUsed >=
creditsLimit; Redis cache 60s prevents DB hit on every message
- whatsapp-logic.ts: credit guard injected before handler chain; RECHARGE
keyword bypasses the guard so users can always request a payment link
- CommandHandler: new RECHARGE keyword sends payment URL or contact message
- i18n: credit_exhausted + recharge_link + recharge_contact in 5 languages
- requireCredits middleware (api): 402 on personalize-lesson, tts,
generate-feedback, crm/generate-campaign
- billing route: POST /v1/billing/admin/allocate (SUPER_ADMIN only)
supports set/add actions + optional usage reset + Redis cache invalidation
- ClientsManagementView: "Crédits IA" button (SUPER_ADMIN only) per org
opens allocation modal with set/add/reset controls
- BillingPage: red exhaustion banner when creditsUsed >= creditsLimit
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feat(billing): complete billing system, push notifications, and tech debt fixes
CognxSafeTrack+1: Claude Sonnet 4.6
8280d7d
- Usage tracking: instrument pedagogy, audio transcription, AI Agent mode (was silently untracked)
- EmailHandler: implement templates 2 (password reset), 3 (quota alert), 4 (monthly report)
- Quota alert: auto-queue email + push at 85% threshold via maybeQueueQuotaAlert
- Push notifications: PushHandler + send-push BullMQ job; sendPushToUser scoped by organizationId to prevent cross-tenant reads
- BillingPage: add credit recharge modal with 3 packs, null guard for missing orgId
- i18n: add nav.billing key in fr/en/es/pt locales
- Tests: billing.test.ts (10 tests), payments.test.ts (13 tests)
- Tech debt: fix empty catch blocks in ai-pedagogy.ts, exclude usage tokens from CRM API response, pass organizationId to generateChat in AIAgentHandler
- Docs: add backlog and business model to docs/business/
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>