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:
@@ -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.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.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.
|
**v0.8.401:** `createGuildCustomRole`/`updateGuildCustomRole`/`deleteGuildCustomRole`/`reorderGuildCustomRoles`/`setMemberCustomRoles` log `role.*` spans and errors; `upsertChannelPermissionOverwrite`/`deleteChannelPermissionOverwrite` log `permission.overwrite*` spans and errors.
|
||||||
|
|||||||
@@ -3607,7 +3607,7 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
const span = this.log.time('notification.markAll')
|
const span = this.log.time('notification.markAll')
|
||||||
try {
|
try {
|
||||||
const count = await this.notifications.markAllRead()
|
const count = await this.notifications.markAllRead()
|
||||||
span.end({ count })
|
span.end({ count, guildId: this.guild?.guild?.id || null })
|
||||||
return count
|
return count
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.log.error('notification.markAll error', {
|
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 = {}) {
|
async listAuditLog (limit = 50, opts = {}) {
|
||||||
const guildId = this.guild?.guild?.id
|
const guildId = this.guild?.guild?.id
|
||||||
if (!guildId) return []
|
if (!guildId) return []
|
||||||
@@ -7287,7 +7309,7 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
}
|
}
|
||||||
const span = threadRead
|
const span = threadRead
|
||||||
? this.log.time('thread.read', { channelId, guildId })
|
? this.log.time('thread.read', { channelId, guildId })
|
||||||
: null
|
: this.log.time('inbox.mark-read', { channelId, guildId })
|
||||||
try {
|
try {
|
||||||
const at = Date.now()
|
const at = Date.now()
|
||||||
await this.db.insert(COLLECTIONS.READ_STATE, {
|
await this.db.insert(COLLECTIONS.READ_STATE, {
|
||||||
@@ -7313,7 +7335,7 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
if (this.notifications) {
|
if (this.notifications) {
|
||||||
await this.notifications.clearForChannel(guildId, channelId)
|
await this.notifications.clearForChannel(guildId, channelId)
|
||||||
}
|
}
|
||||||
span?.end({ channelId })
|
span.end({ channelId })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (threadRead) {
|
if (threadRead) {
|
||||||
this.log.error('thread.read error', {
|
this.log.error('thread.read error', {
|
||||||
|
|||||||
Reference in New Issue
Block a user