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:
@@ -1266,11 +1266,15 @@ class PearcordPlatform extends EventEmitter {
|
||||
if (!this.contacts) await this._joinContactsMesh()
|
||||
if (!this.contacts) throw new Error('contacts unavailable')
|
||||
const row = await this.contacts.sendRequest({ peerUserId, peerDisplayName })
|
||||
const pendingOut = await this.contacts.listPendingOutgoing()
|
||||
const accepted = await this.contacts.listAccepted()
|
||||
span.end({
|
||||
spanKind: 'contacts.request',
|
||||
status: row?.status || null,
|
||||
peerUserId: peerUserId || null,
|
||||
peerDisplayNameLen: String(peerDisplayName || '').trim().length
|
||||
peerDisplayNameLen: String(peerDisplayName || '').trim().length,
|
||||
pendingOutCount: pendingOut.length,
|
||||
acceptedCount: accepted.length
|
||||
})
|
||||
return row
|
||||
} catch (err) {
|
||||
@@ -1291,11 +1295,15 @@ class PearcordPlatform extends EventEmitter {
|
||||
try {
|
||||
if (!this.contacts) throw new Error('contacts unavailable')
|
||||
const row = await this.contacts.acceptRequest(peerUserId)
|
||||
const accepted = await this.contacts.listAccepted()
|
||||
const pendingIn = await this.contacts.listPendingIncoming()
|
||||
span.end({
|
||||
spanKind: 'contacts.accept',
|
||||
status: row?.status || 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
|
||||
} catch (err) {
|
||||
@@ -1316,10 +1324,14 @@ class PearcordPlatform extends EventEmitter {
|
||||
try {
|
||||
if (!this.contacts) throw new Error('contacts unavailable')
|
||||
const row = await this.contacts.declineRequest(peerUserId)
|
||||
const pendingIn = await this.contacts.listPendingIncoming()
|
||||
const pendingOut = await this.contacts.listPendingOutgoing()
|
||||
span.end({
|
||||
spanKind: 'contacts.decline',
|
||||
peerUserId: peerUserId || null,
|
||||
declined: true
|
||||
declined: true,
|
||||
pendingInCount: pendingIn.length,
|
||||
pendingOutCount: pendingOut.length
|
||||
})
|
||||
return row
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user