@mantiq/heartbeat 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantiq/heartbeat",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Observability, APM & queue monitoring for MantiqJS",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -7,17 +7,20 @@ export async function renderMailPage(store: HeartbeatStore, basePath: string): P
7
7
  const entries = await store.getEntries('mail', 50)
8
8
 
9
9
  const rows = entries.map((e) => {
10
- const c = JSON.parse(e.content) as MailEntryContent
11
- const to = c.to.length > 2
12
- ? `${escapeHtml(c.to.slice(0, 2).join(', '))} +${c.to.length - 2}`
13
- : escapeHtml(c.to.join(', '))
10
+ let c: MailEntryContent
11
+ try { c = JSON.parse(e.content) } catch { return '' }
12
+ if (!c?.to) return ''
13
+ const recipients = Array.isArray(c.to) ? c.to : []
14
+ const to = recipients.length > 2
15
+ ? `${escapeHtml(recipients.slice(0, 2).join(', '))} +${recipients.length - 2}`
16
+ : escapeHtml(recipients.join(', '))
14
17
 
15
18
  return `<tr>
16
19
  <td style="padding:10px 14px">
17
20
  <a href="${basePath}/mail/${e.uuid}" style="color:var(--fg-0);text-decoration:none;font-weight:500">${escapeHtml(c.subject || '(no subject)')}</a>
18
21
  </td>
19
- <td class="mono sm" style="padding:10px 14px;color:var(--fg-2)">${to}</td>
20
- <td style="padding:10px 14px">${badge(c.mailer, 'mute')}</td>
22
+ <td class="mono sm" style="padding:10px 14px;color:var(--fg-2)">${to || '—'}</td>
23
+ <td style="padding:10px 14px">${badge(c.mailer ?? 'unknown', 'mute')}</td>
21
24
  <td style="padding:10px 14px">${c.queued ? badge('queued', 'amber') : badge('sent', 'green')}</td>
22
25
  <td style="padding:10px 14px">${durationBadge(c.duration)}</td>
23
26
  <td class="sm dim" style="padding:10px 14px;text-align:right">${timeAgo(e.created_at)}</td>