From 32a2a9b15c2179e30e2bb9e56ed894e263c816b5 Mon Sep 17 00:00:00 2001 From: Renato Alcara Date: Mon, 2 Mar 2026 14:18:17 -0300 Subject: [PATCH] feat: add connection and pair code presentation logs (#251) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Single-line logs showing how the lib presents to WhatsApp: - 📱/🖥️ Connection: phone number, platform, device, type - 🔗 Pair code: companion platform, android override status * fix: move connection log to CB:success and rename type to platformType Move the presentation log from pre-handshake (validateConnection) to CB:success where the connection is actually confirmed. Rename ambiguous 'type' label to 'platformType' matching DeviceProps.PlatformType. --- src/Socket/socket.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Socket/socket.ts b/src/Socket/socket.ts index 93e298b1..032b6ab4 100644 --- a/src/Socket/socket.ts +++ b/src/Socket/socket.ts @@ -634,8 +634,6 @@ export const makeSocket = (config: SocketConfig) => { } helloMsg = proto.HandshakeMessage.fromObject(helloMsg) - logger.info({ browser, helloMsg }, 'connected to WA') - const init = proto.HandshakeMessage.encode(helloMsg).finish() const result = await awaitNextMessage(init) @@ -1360,6 +1358,8 @@ export const makeSocket = (config: SocketConfig) => { const pairPlatformId = isAndroid ? getPlatformId('Chrome') : getPlatformId(browser[1]) const pairPlatformDisplay = isAndroid ? 'Chrome (Mac OS)' : `${browser[1]} (${browser[0]})` + logger.info(`\uD83D\uDD17 Pair code requested | companion: ${pairPlatformDisplay} | ${isAndroid ? 'android override \u2192 Chrome' : 'native platform'}`) + ev.emit('creds.update', authState.creds) await sendNode({ tag: 'iq', @@ -1527,7 +1527,9 @@ export const makeSocket = (config: SocketConfig) => { }) // login complete ws.on('CB:success', async (node: BinaryNode) => { - logger.info('opened connection to WA') + const isAndroid = isAndroidBrowser(browser) + const phoneId = authState.creds.me?.id?.split(':')[0]?.split('@')[0] || 'new session' + logger.info(`${isAndroid ? '\uD83D\uDCF1' : '\uD83D\uDDA5\uFE0F'} Connected to WA | ${phoneId} | platform: ${isAndroid ? 'SMB_ANDROID' : 'MACOS'} | device: ${isAndroid ? 'Android' : 'Desktop'} | platformType: ${isAndroid ? 'ANDROID_PHONE' : 'CHROME'}`) clearTimeout(qrTimer) // will never happen in all likelyhood -- but just in case WA sends success on first try ev.emit('creds.update', { me: { ...authState.creds.me!, lid: node.attrs.lid } })