feat(contact): add local jsonl backup for fail-safe lead retention
All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 10s
Build & Deploy / 🧪 QA (push) Successful in 52s
Build & Deploy / 🏗️ Build (push) Successful in 1m48s
Build & Deploy / 🚀 Deploy (push) Successful in 12s
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s

This commit is contained in:
2026-05-06 12:50:07 +02:00
parent 1fee592ee7
commit e263e7f25c

View File

@@ -45,6 +45,28 @@ export async function sendContactFormAction(formData: FormData) {
email,
});
// 1.5. Simple Fail-Safe Backup to Disk
// To ensure leads are never lost if email fails or Gotify is down, we append them to a local JSON Lines file.
try {
const fs = await import('fs');
const path = await import('path');
const backupDir = path.join(process.cwd(), '.data');
if (!fs.existsSync(backupDir)) fs.mkdirSync(backupDir, { recursive: true });
const backupFile = path.join(backupDir, 'leads-backup.jsonl');
const leadData = {
timestamp: new Date().toISOString(),
name,
email,
productName,
message,
};
fs.appendFileSync(backupFile, JSON.stringify(leadData) + '\\n');
logger.info('Successfully saved lead to local backup file', { backupFile });
} catch (backupError) {
logger.error('Failed to write to local leads backup', { error: String(backupError) });
}
// 2. Send Emails
logger.info('Sending branded emails', { email, productName });