Add compose.draft.save telemetry span for draft persistence.
Surfaces draft save duration and payload size in platform logs to support Phase 660 composer draft flush debounce verification. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -10306,6 +10306,7 @@ class PearcordPlatform extends EventEmitter {
|
||||
|
||||
async setComposeDraft (channelId, text) {
|
||||
if (!channelId) throw new Error('channelId required')
|
||||
const span = this.log.time('compose.draft.save', { channelId })
|
||||
const prefs = this.userSettings ? await this.userSettings.getPrefs() : {}
|
||||
const composeDrafts = { ...(prefs.composeDrafts || {}) }
|
||||
const trimmed = String(text || '').slice(0, 4000)
|
||||
@@ -10315,7 +10316,9 @@ class PearcordPlatform extends EventEmitter {
|
||||
composeDrafts[channelId] = { text: trimmed, updatedAt: now() }
|
||||
}
|
||||
this.log.trace('compose draft saved', { channelId, len: trimmed.length })
|
||||
return this.userSettings.setPrefs({ composeDrafts }, { localNotify: false })
|
||||
const out = await this.userSettings.setPrefs({ composeDrafts }, { localNotify: false })
|
||||
span.end({ len: trimmed.length, cleared: !trimmed })
|
||||
return out
|
||||
}
|
||||
|
||||
async getComposeDraftText (channelId) {
|
||||
|
||||
Reference in New Issue
Block a user