feat(platform): notification/inbox spans Phase 444 (v0.8.407)

Add markNotificationRead wrapper with notification.markRead span and
error logging. Use inbox.mark-read span for non-thread markChannelRead.
Extend notification.markAll span with guildId metadata.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-23 19:59:53 -04:00
co-authored by Cursor
parent 0fb9663362
commit 546aab0ce3
2 changed files with 27 additions and 3 deletions
+2
View File
@@ -147,6 +147,8 @@ Primary consumer: `apps/pearcord/index.js` sidecar reading pear-pipe JSON.
**v0.8.403:** `stageAttachment`/`readAttachmentPreview` log `attachment.*` spans and errors; `_queueLinkEmbed` logs `embed.resolve` span and `embed.resolve error` on failure.
**v0.8.407:** `markNotificationRead(notificationId)` wraps inbox `markRead` with `notification.markRead` span + `notification.markRead error`. `markAllNotificationsRead` span ends with `count` + `guildId`. `markChannelRead` logs `inbox.mark-read` span + error for non-thread channels (thread channels use `thread.read`). Smokes: `test:notification-platform-errors`, `test:inbox-platform-errors`. Bundle: `test:phase444-notifications-inbox`.
**v0.8.406:** `createThread`/`createForumPost`/`markChannelRead` (thread channels)/`archiveThread` log `thread.create`/`forum.post`/`thread.read`/`thread.archive` spans and errors; audit entries for `thread.create`, `forum.post.create`, `thread.archive`, and `thread.unarchive`. Smoke: `test:thread-platform-errors`.
**v0.8.401:** `createGuildCustomRole`/`updateGuildCustomRole`/`deleteGuildCustomRole`/`reorderGuildCustomRoles`/`setMemberCustomRoles` log `role.*` spans and errors; `upsertChannelPermissionOverwrite`/`deleteChannelPermissionOverwrite` log `permission.overwrite*` spans and errors.
+25 -3
View File
@@ -3607,7 +3607,7 @@ class PearcordPlatform extends EventEmitter {
const span = this.log.time('notification.markAll')
try {
const count = await this.notifications.markAllRead()
span.end({ count })
span.end({ count, guildId: this.guild?.guild?.id || null })
return count
} catch (err) {
this.log.error('notification.markAll error', {
@@ -3618,6 +3618,28 @@ class PearcordPlatform extends EventEmitter {
}
}
async markNotificationRead (notificationId) {
if (!this.notifications) return null
const span = this.log.time('notification.markRead', {
notificationId: notificationId || null
})
try {
const row = await this.notifications.markRead(notificationId)
span.end({
channelId: row?.channelId || null,
guildId: row?.guildId || null
})
return row
} catch (err) {
this.log.error('notification.markRead error', {
notificationId: notificationId || null,
err: err?.message || String(err)
})
span.fail(err)
throw err
}
}
async listAuditLog (limit = 50, opts = {}) {
const guildId = this.guild?.guild?.id
if (!guildId) return []
@@ -7287,7 +7309,7 @@ class PearcordPlatform extends EventEmitter {
}
const span = threadRead
? this.log.time('thread.read', { channelId, guildId })
: null
: this.log.time('inbox.mark-read', { channelId, guildId })
try {
const at = Date.now()
await this.db.insert(COLLECTIONS.READ_STATE, {
@@ -7313,7 +7335,7 @@ class PearcordPlatform extends EventEmitter {
if (this.notifications) {
await this.notifications.clearForChannel(guildId, channelId)
}
span?.end({ channelId })
span.end({ channelId })
} catch (err) {
if (threadRead) {
this.log.error('thread.read error', {