feat(contact): add klaus@klz-cables.com to recipients and fix pino logging
Some checks failed
Build & Deploy / 🧪 QA (push) Has been cancelled
Build & Deploy / 🏗️ Build (push) Has been cancelled
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🔍 Prepare (push) Has been cancelled
Some checks failed
Build & Deploy / 🧪 QA (push) Has been cancelled
Build & Deploy / 🏗️ Build (push) Has been cancelled
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🔍 Prepare (push) Has been cancelled
This commit is contained in:
@@ -245,7 +245,7 @@ jobs:
|
|||||||
MAIL_USERNAME: ${{ secrets.SMTP_USER || vars.SMTP_USER }}
|
MAIL_USERNAME: ${{ secrets.SMTP_USER || vars.SMTP_USER }}
|
||||||
MAIL_PASSWORD: ${{ secrets.SMTP_PASS || vars.SMTP_PASS }}
|
MAIL_PASSWORD: ${{ secrets.SMTP_PASS || vars.SMTP_PASS }}
|
||||||
MAIL_FROM: ${{ secrets.SMTP_FROM || vars.SMTP_FROM || 'noreply@klz-cables.com' }}
|
MAIL_FROM: ${{ secrets.SMTP_FROM || vars.SMTP_FROM || 'noreply@klz-cables.com' }}
|
||||||
MAIL_RECIPIENTS: ${{ secrets.CONTACT_RECIPIENT || vars.CONTACT_RECIPIENT || 'info@klz-cables.com' }}
|
MAIL_RECIPIENTS: ${{ secrets.CONTACT_RECIPIENT || vars.CONTACT_RECIPIENT || 'info@klz-cables.com,klaus@klz-cables.com' }}
|
||||||
|
|
||||||
# Monitoring
|
# Monitoring
|
||||||
SENTRY_DSN: ${{ secrets.SENTRY_DSN || vars.SENTRY_DSN }}
|
SENTRY_DSN: ${{ secrets.SENTRY_DSN || vars.SENTRY_DSN }}
|
||||||
|
|||||||
@@ -32,18 +32,24 @@ export async function sendContactFormAction(formData: FormData) {
|
|||||||
const productName = formData.get('productName') as string | null;
|
const productName = formData.get('productName') as string | null;
|
||||||
|
|
||||||
if (!name || !email || !message) {
|
if (!name || !email || !message) {
|
||||||
logger.warn('Missing required fields in contact form', {
|
logger.warn(
|
||||||
name: !!name,
|
{
|
||||||
email: !!email,
|
name: !!name,
|
||||||
message: !!message,
|
email: !!email,
|
||||||
});
|
message: !!message,
|
||||||
|
},
|
||||||
|
'Missing required fields in contact form',
|
||||||
|
);
|
||||||
return { success: false, error: 'Missing required fields' };
|
return { success: false, error: 'Missing required fields' };
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info('Payload CMS saving skipped because it has been removed', {
|
logger.info(
|
||||||
type: productName ? 'product_quote' : 'contact',
|
{
|
||||||
email,
|
type: productName ? 'product_quote' : 'contact',
|
||||||
});
|
email,
|
||||||
|
},
|
||||||
|
'Payload CMS saving skipped because it has been removed',
|
||||||
|
);
|
||||||
|
|
||||||
// 1.5. Simple Fail-Safe Backup to Disk
|
// 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.
|
// To ensure leads are never lost if email fails or Gotify is down, we append them to a local JSON Lines file.
|
||||||
@@ -61,14 +67,14 @@ export async function sendContactFormAction(formData: FormData) {
|
|||||||
productName,
|
productName,
|
||||||
message,
|
message,
|
||||||
};
|
};
|
||||||
fs.appendFileSync(backupFile, JSON.stringify(leadData) + '\\n');
|
fs.appendFileSync(backupFile, JSON.stringify(leadData) + '\n');
|
||||||
logger.info('Successfully saved lead to local backup file', { backupFile });
|
logger.info({ backupFile }, 'Successfully saved lead to local backup file');
|
||||||
} catch (backupError) {
|
} catch (backupError) {
|
||||||
logger.error('Failed to write to local leads backup', { error: String(backupError) });
|
logger.error({ error: String(backupError) }, 'Failed to write to local leads backup');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Send Emails
|
// 2. Send Emails
|
||||||
logger.info('Sending branded emails', { email, productName });
|
logger.info({ email, productName }, 'Sending branded emails');
|
||||||
|
|
||||||
const notificationSubject = productName
|
const notificationSubject = productName
|
||||||
? `Product Inquiry: ${productName}`
|
? `Product Inquiry: ${productName}`
|
||||||
@@ -88,7 +94,7 @@ export async function sendContactFormAction(formData: FormData) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!isTestSubmission) {
|
if (!isTestSubmission) {
|
||||||
logger.info('Sending internal notification', { recipients: env.MAIL_RECIPIENTS });
|
logger.info({ recipients: env.MAIL_RECIPIENTS }, 'Sending internal notification');
|
||||||
const notificationResult = await sendEmail({
|
const notificationResult = await sendEmail({
|
||||||
replyTo: email,
|
replyTo: email,
|
||||||
subject: notificationSubject,
|
subject: notificationSubject,
|
||||||
@@ -96,15 +102,21 @@ export async function sendContactFormAction(formData: FormData) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (notificationResult.success) {
|
if (notificationResult.success) {
|
||||||
logger.info('Notification email sent successfully', {
|
logger.info(
|
||||||
messageId: notificationResult.messageId,
|
{
|
||||||
});
|
messageId: notificationResult.messageId,
|
||||||
|
},
|
||||||
|
'Notification email sent successfully',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
logger.error('Notification email DELIVERY FAILED', {
|
logger.error(
|
||||||
error: notificationResult.error,
|
{
|
||||||
subject: notificationSubject,
|
error: notificationResult.error,
|
||||||
recipients: env.MAIL_RECIPIENTS,
|
subject: notificationSubject,
|
||||||
});
|
recipients: env.MAIL_RECIPIENTS,
|
||||||
|
},
|
||||||
|
'Notification email DELIVERY FAILED',
|
||||||
|
);
|
||||||
services.errors.captureException(
|
services.errors.captureException(
|
||||||
new Error(`Notification email failed: ${notificationResult.error}`),
|
new Error(`Notification email failed: ${notificationResult.error}`),
|
||||||
{
|
{
|
||||||
@@ -115,7 +127,7 @@ export async function sendContactFormAction(formData: FormData) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.info('Skipping notification email for test submission', { email });
|
logger.info({ email }, 'Skipping notification email for test submission');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2b. Send confirmation to Customer (branded as KLZ Cables)
|
// 2b. Send confirmation to Customer (branded as KLZ Cables)
|
||||||
@@ -128,7 +140,7 @@ export async function sendContactFormAction(formData: FormData) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!isTestSubmission) {
|
if (!isTestSubmission) {
|
||||||
logger.info('Sending customer confirmation', { to: email });
|
logger.info({ to: email }, 'Sending customer confirmation');
|
||||||
const confirmationResult = await sendEmail({
|
const confirmationResult = await sendEmail({
|
||||||
to: email,
|
to: email,
|
||||||
subject: confirmationSubject,
|
subject: confirmationSubject,
|
||||||
@@ -136,27 +148,33 @@ export async function sendContactFormAction(formData: FormData) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (confirmationResult.success) {
|
if (confirmationResult.success) {
|
||||||
logger.info('Confirmation email sent successfully', {
|
logger.info(
|
||||||
messageId: confirmationResult.messageId,
|
{
|
||||||
});
|
messageId: confirmationResult.messageId,
|
||||||
|
},
|
||||||
|
'Confirmation email sent successfully',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
logger.error('Confirmation email DELIVERY FAILED', {
|
logger.error(
|
||||||
error: confirmationResult.error,
|
{
|
||||||
subject: confirmationSubject,
|
error: confirmationResult.error,
|
||||||
to: email,
|
subject: confirmationSubject,
|
||||||
});
|
to: email,
|
||||||
|
},
|
||||||
|
'Confirmation email DELIVERY FAILED',
|
||||||
|
);
|
||||||
services.errors.captureException(
|
services.errors.captureException(
|
||||||
new Error(`Confirmation email failed: ${confirmationResult.error}`),
|
new Error(`Confirmation email failed: ${confirmationResult.error}`),
|
||||||
{ action: 'sendContactFormAction_confirmation', email },
|
{ action: 'sendContactFormAction_confirmation', email },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.info('Skipping confirmation email for test submission', { email });
|
logger.info({ email }, 'Skipping confirmation email for test submission');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify via Gotify (Internal)
|
// Notify via Gotify (Internal)
|
||||||
await services.notifications.notify({
|
await services.notifications.notify({
|
||||||
title: `📩 ${notificationSubject}`,
|
title: `📩 [KLZ] ${notificationSubject}`,
|
||||||
message: `New message from ${name} (${email}):\n\n${message}`,
|
message: `New message from ${name} (${email}):\n\n${message}`,
|
||||||
priority: 5,
|
priority: 5,
|
||||||
});
|
});
|
||||||
@@ -169,10 +187,13 @@ export async function sendContactFormAction(formData: FormData) {
|
|||||||
return { success: true };
|
return { success: true };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMsg = error instanceof Error ? error.message : String(error);
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
||||||
logger.error('Failed to send branded emails', {
|
logger.error(
|
||||||
error: errorMsg,
|
{
|
||||||
stack: error instanceof Error ? error.stack : undefined,
|
error: errorMsg,
|
||||||
});
|
stack: error instanceof Error ? error.stack : undefined,
|
||||||
|
},
|
||||||
|
'Failed to send branded emails',
|
||||||
|
);
|
||||||
|
|
||||||
services.errors.captureException(error, { action: 'sendContactFormAction', email });
|
services.errors.captureException(error, { action: 'sendContactFormAction', email });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user