feat(contacts): add pending/accepted counts to contact span metadata

Phase 530 platform diagnostics for contacts.request/accept/decline.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-24 11:52:46 -04:00
co-authored by Cursor
parent e6797e9309
commit e41336feb8
+15 -3
View File
@@ -1266,11 +1266,15 @@ class PearcordPlatform extends EventEmitter {
if (!this.contacts) await this._joinContactsMesh() if (!this.contacts) await this._joinContactsMesh()
if (!this.contacts) throw new Error('contacts unavailable') if (!this.contacts) throw new Error('contacts unavailable')
const row = await this.contacts.sendRequest({ peerUserId, peerDisplayName }) const row = await this.contacts.sendRequest({ peerUserId, peerDisplayName })
const pendingOut = await this.contacts.listPendingOutgoing()
const accepted = await this.contacts.listAccepted()
span.end({ span.end({
spanKind: 'contacts.request', spanKind: 'contacts.request',
status: row?.status || null, status: row?.status || null,
peerUserId: peerUserId || null, peerUserId: peerUserId || null,
peerDisplayNameLen: String(peerDisplayName || '').trim().length peerDisplayNameLen: String(peerDisplayName || '').trim().length,
pendingOutCount: pendingOut.length,
acceptedCount: accepted.length
}) })
return row return row
} catch (err) { } catch (err) {
@@ -1291,11 +1295,15 @@ class PearcordPlatform extends EventEmitter {
try { try {
if (!this.contacts) throw new Error('contacts unavailable') if (!this.contacts) throw new Error('contacts unavailable')
const row = await this.contacts.acceptRequest(peerUserId) const row = await this.contacts.acceptRequest(peerUserId)
const accepted = await this.contacts.listAccepted()
const pendingIn = await this.contacts.listPendingIncoming()
span.end({ span.end({
spanKind: 'contacts.accept', spanKind: 'contacts.accept',
status: row?.status || null, status: row?.status || null,
peerUserId: peerUserId || null, peerUserId: peerUserId || null,
accepted: row?.status === 'accepted' || row?.status === 'friend' accepted: row?.status === 'accepted' || row?.status === 'friend',
acceptedCount: accepted.length,
pendingInCount: pendingIn.length
}) })
return row return row
} catch (err) { } catch (err) {
@@ -1316,10 +1324,14 @@ class PearcordPlatform extends EventEmitter {
try { try {
if (!this.contacts) throw new Error('contacts unavailable') if (!this.contacts) throw new Error('contacts unavailable')
const row = await this.contacts.declineRequest(peerUserId) const row = await this.contacts.declineRequest(peerUserId)
const pendingIn = await this.contacts.listPendingIncoming()
const pendingOut = await this.contacts.listPendingOutgoing()
span.end({ span.end({
spanKind: 'contacts.decline', spanKind: 'contacts.decline',
peerUserId: peerUserId || null, peerUserId: peerUserId || null,
declined: true declined: true,
pendingInCount: pendingIn.length,
pendingOutCount: pendingOut.length
}) })
return row return row
} catch (err) { } catch (err) {