← Back to PRs

#23579: feat(whatsapp): add sender attribution to inbound message logs

by svan058 open 2026-02-22 13:17 View on GitHub →
channel: whatsapp-web size: XS
## Problem WhatsApp group messages are logged without sender attribution. The log entries include `from` (group JID), `to`, `body`, `mediaPath`, `mediaType`, `mediaFileName`, and `timestamp`, but not who within the group sent the message. The Baileys message object has `pushName` (display name) and `key.participant` (sender JID) available, but these weren't included in the log output. ## Solution Added `pushName` and `participant` fields to the inbound message log entry for WhatsApp messages. **Before:** ```json { "type": "inbound message", "from": "120363418116473253@g.us", "to": "61450067892:16@s.whatsapp.net", "body": "message text", "timestamp": 1740000000 } ``` **After:** ```json { "type": "inbound message", "from": "120363418116473253@g.us", "to": "61450067892:16@s.whatsapp.net", "participant": "447922832522@s.whatsapp.net", "pushName": "Daniel", "body": "message text", "timestamp": 1740000000 } ``` ## Use Case External tools (message loggers, analytics) that tail the gateway log need sender attribution to build useful chat histories. Without it, all group messages appear anonymous. ## Testing - ✅ Build passes (`pnpm build`) - ✅ Linter passes (`pnpm check`) - ✅ Unit tests pass (`pnpm test src/web/monitor-inbox.streams-inbound-messages.test.ts`) - ✅ No breaking changes to existing code ## Notes - The `WebInboundMessage` type already had `pushName` and `senderJid` fields - These fields were being populated in the message object passed to handlers - This PR only adds them to the log output for observability - Both fields are optional (undefined for direct messages or when unavailable) Made with [Cursor](https://cursor.com) <!-- greptile_comment --> <h3>Greptile Summary</h3> Added `participant` and `pushName` fields to WhatsApp inbound message log entries for better observability. These fields were already captured in the `WebInboundMessage` object (`senderJid` and `pushName`) and passed to handlers, but weren't included in the structured log output. This change addresses a gap where group message logs lacked sender attribution, making it difficult for external tools consuming the logs to identify who sent messages in group chats. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The change only adds two optional fields to the log output without modifying any logic. The fields (`participantJid` and `senderName`) are already defined and used in the same code path to populate the `WebInboundMessage` object. The PR includes passing unit tests and the implementation follows existing patterns in the codebase. - No files require special attention <sub>Last reviewed commit: 6ff2a94</sub> <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs