From 546aab0ce3c1253b21f635a2311905e9383f05d8 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Sat, 23 May 2026 19:59:53 -0400 Subject: [PATCH] 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 --- README.md | 2 ++ index.js | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d6ef08a..b58d1cd 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/index.js b/index.js index d415027..c6f9225 100644 --- a/index.js +++ b/index.js @@ -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', {