Extend webhook and slash platform spans with guildId metadata.
Phase 448 adds guildId to webhook.create/delete/execute and slash.register/delete span start/end/error logs for tighter diagnostics alignment. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -144,6 +144,8 @@ Primary consumer: `apps/pearcord/index.js` sidecar reading pear-pipe JSON.
|
||||
|
||||
**v0.8.400:** `createChannelWebhook`/`deleteChannelWebhook`/`executeChannelWebhook` log `webhook.*` spans and errors; `registerSlashCommands`/`deleteSlashCommand`/`executeSlashCommand` log `slash.*` spans and errors.
|
||||
|
||||
**v0.8.411 (Phase 448):** Webhook and slash spans/errors include `guildId` metadata; `webhook.execute` span end includes `channelId`. Dev-log **webhook-errors** filter: `webhook.create|delete|execute`; **slash-errors**: `slash.register|delete|invoke`. Integrations UI permission toasts; webhook token modal autofocus. Bundle: `npm run test:phase448-webhooks-integrations`.
|
||||
|
||||
**v0.8.402:** `sendMessage`/`editMessage`/`deleteMessage` log `message.*` spans and errors; `toggleReaction` logs `reaction.toggle` span and `reaction.toggle error` on failure.
|
||||
|
||||
**v0.8.403:** `stageAttachment`/`readAttachmentPreview` log `attachment.*` spans and errors; `_queueLinkEmbed` logs `embed.resolve` span and `embed.resolve error` on failure.
|
||||
|
||||
@@ -7648,7 +7648,11 @@ class PearcordPlatform extends EventEmitter {
|
||||
}
|
||||
|
||||
async registerSlashCommands (commands = []) {
|
||||
const span = this.log.time('slash.register', { count: (commands || []).length })
|
||||
const guildId = this.guild?.guild?.id || null
|
||||
const span = this.log.time('slash.register', {
|
||||
count: (commands || []).length,
|
||||
guildId
|
||||
})
|
||||
try {
|
||||
if (!this.guild?.guild) throw new Error('no guild')
|
||||
const roles = await this._memberRoles()
|
||||
@@ -7677,11 +7681,12 @@ class PearcordPlatform extends EventEmitter {
|
||||
})
|
||||
}
|
||||
this.emit('slash-command')
|
||||
span.end({ registered: rows.length })
|
||||
span.end({ registered: rows.length, guildId })
|
||||
return rows
|
||||
} catch (err) {
|
||||
this.log.error('slash.register error', {
|
||||
count: (commands || []).length,
|
||||
guildId,
|
||||
error: err?.message || String(err)
|
||||
})
|
||||
span.fail(err)
|
||||
@@ -7690,7 +7695,8 @@ class PearcordPlatform extends EventEmitter {
|
||||
}
|
||||
|
||||
async deleteSlashCommand (name) {
|
||||
const span = this.log.time('slash.delete', { name })
|
||||
const guildId = this.guild?.guild?.id || null
|
||||
const span = this.log.time('slash.delete', { name, guildId })
|
||||
try {
|
||||
if (!this.guild?.guild) throw new Error('no guild')
|
||||
const roles = await this._memberRoles()
|
||||
@@ -7710,11 +7716,12 @@ class PearcordPlatform extends EventEmitter {
|
||||
meta: { name: removed.name }
|
||||
})
|
||||
this.emit('slash-command')
|
||||
span.end({ name: removed.name })
|
||||
span.end({ name: removed.name, guildId })
|
||||
return removed
|
||||
} catch (err) {
|
||||
this.log.error('slash.delete error', {
|
||||
name,
|
||||
guildId,
|
||||
error: err?.message || String(err)
|
||||
})
|
||||
span.fail(err)
|
||||
@@ -9660,7 +9667,8 @@ class PearcordPlatform extends EventEmitter {
|
||||
}
|
||||
|
||||
async createChannelWebhook ({ channelId, name, avatarUrl } = {}) {
|
||||
const span = this.log.time('webhook.create', { channelId })
|
||||
const guildId = this.guild?.guild?.id || null
|
||||
const span = this.log.time('webhook.create', { channelId, guildId })
|
||||
try {
|
||||
if (!this.guild?.guild) throw new Error('no guild')
|
||||
const user = this.identity.user
|
||||
@@ -9694,11 +9702,12 @@ class PearcordPlatform extends EventEmitter {
|
||||
})
|
||||
this.guild.gossipWebhookUpsert(webhook)
|
||||
this.emit('webhook', webhook)
|
||||
span.end({ webhookId: webhook.id })
|
||||
span.end({ webhookId: webhook.id, guildId })
|
||||
return { webhook, token }
|
||||
} catch (err) {
|
||||
this.log.error('webhook.create error', {
|
||||
channelId,
|
||||
guildId,
|
||||
error: err?.message || String(err)
|
||||
})
|
||||
span.fail(err)
|
||||
@@ -9707,7 +9716,8 @@ class PearcordPlatform extends EventEmitter {
|
||||
}
|
||||
|
||||
async deleteChannelWebhook (webhookId) {
|
||||
const span = this.log.time('webhook.delete', { webhookId })
|
||||
const guildId = this.guild?.guild?.id || null
|
||||
const span = this.log.time('webhook.delete', { webhookId, guildId })
|
||||
try {
|
||||
if (!this.guild?.guild) throw new Error('no guild')
|
||||
const roles = await this._memberRoles()
|
||||
@@ -9728,11 +9738,12 @@ class PearcordPlatform extends EventEmitter {
|
||||
})
|
||||
this.guild.gossipWebhookDelete({ id: webhookId, guildId: this.guild.guild.id })
|
||||
this.emit('webhook-delete', { id: webhookId, guildId: this.guild.guild.id })
|
||||
span.end({ webhookId })
|
||||
span.end({ webhookId, guildId })
|
||||
return removed
|
||||
} catch (err) {
|
||||
this.log.error('webhook.delete error', {
|
||||
webhookId,
|
||||
guildId,
|
||||
error: err?.message || String(err)
|
||||
})
|
||||
span.fail(err)
|
||||
@@ -9741,7 +9752,11 @@ class PearcordPlatform extends EventEmitter {
|
||||
}
|
||||
|
||||
async executeChannelWebhook ({ token, content, username } = {}) {
|
||||
const span = this.log.time('webhook.execute', { username: username || null })
|
||||
const guildId = this.guild?.guild?.id || null
|
||||
const span = this.log.time('webhook.execute', {
|
||||
username: username || null,
|
||||
guildId
|
||||
})
|
||||
try {
|
||||
if (!this.guild?.guild) throw new Error('no guild')
|
||||
await this._ensureGuildModules()
|
||||
@@ -9769,10 +9784,12 @@ class PearcordPlatform extends EventEmitter {
|
||||
detail: String(username || row.name).slice(0, 80)
|
||||
})
|
||||
this.emit('message', msg)
|
||||
span.end({ webhookId: row.id, messageId: msg?.id })
|
||||
span.end({ webhookId: row.id, messageId: msg?.id, guildId, channelId: row.channelId })
|
||||
return msg
|
||||
} catch (err) {
|
||||
this.log.error('webhook.execute error', {
|
||||
guildId,
|
||||
username: username || null,
|
||||
error: err?.message || String(err)
|
||||
})
|
||||
span.fail(err)
|
||||
|
||||
Reference in New Issue
Block a user