From 8af4397803394b8460685c5be2454720a3c833b2 Mon Sep 17 00:00:00 2001 From: "khalid@traclabs.com" Date: Tue, 5 May 2026 12:50:55 -0500 Subject: [PATCH] Add logging --- server/src/routes/webhook-sms.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/src/routes/webhook-sms.ts b/server/src/routes/webhook-sms.ts index 3a4e718..2161cee 100644 --- a/server/src/routes/webhook-sms.ts +++ b/server/src/routes/webhook-sms.ts @@ -54,6 +54,24 @@ export function createWebhookSmsRouter(deps: WebhookSmsRouterDeps): Router { // Respond quickly — Vonage expects a 200 within a few seconds res.status(200).json({ status: 'received' }); + const body = (req.body ?? {}) as Record; + const rawText = typeof body.text === 'string' ? body.text : ''; + logger.info( + { + event: 'sms.webhook_inbound_payload', + contentType: req.headers['content-type'], + bodyKeys: Object.keys(body), + bodyRedacted: { + ...body, + from: typeof body.from === 'string' ? maskPhone(body.from) : body.from, + to: typeof body.to === 'string' ? maskPhone(body.to) : body.to, + msisdn: typeof body.msisdn === 'string' ? maskPhone(body.msisdn) : body.msisdn, + text: rawText ? `${rawText.slice(0, 80)}${rawText.length > 80 ? '…' : ''}` : body.text, + }, + }, + 'Inbound webhook payload (redacted)' + ); + // Process async handleInbound(req.body, deps).catch(err => { logger.error({ event: 'sms.handler_error', error: (err as Error).message }, 'SMS handler error');