* Formats an issue and its latest event into a single plain-text document covering the * title, culprit, counts, the latest event's message/exception, and event tags.
(issue: SentryIssue, event: SentryEvent | null)
| 297 | * title, culprit, counts, the latest event's message/exception, and event tags. |
| 298 | */ |
| 299 | function formatIssueContent(issue: SentryIssue, event: SentryEvent | null): string { |
| 300 | const parts: string[] = [] |
| 301 | |
| 302 | parts.push(`Issue: ${buildTitle(issue)}`) |
| 303 | if (issue.shortId) parts.push(`Short ID: ${issue.shortId}`) |
| 304 | if (issue.culprit) parts.push(`Culprit: ${issue.culprit}`) |
| 305 | if (issue.level) parts.push(`Level: ${issue.level}`) |
| 306 | if (issue.status) parts.push(`Status: ${issue.status}`) |
| 307 | if (issue.platform) parts.push(`Platform: ${issue.platform}`) |
| 308 | if (issue.count) parts.push(`Events: ${issue.count}`) |
| 309 | if (issue.userCount != null) parts.push(`Users affected: ${issue.userCount}`) |
| 310 | if (issue.firstSeen) parts.push(`First seen: ${issue.firstSeen}`) |
| 311 | if (issue.lastSeen) parts.push(`Last seen: ${issue.lastSeen}`) |
| 312 | |
| 313 | if (event) { |
| 314 | const message = event.message?.trim() || event.title?.trim() |
| 315 | if (message) { |
| 316 | parts.push('') |
| 317 | parts.push('--- Latest Event ---') |
| 318 | if (event.dateCreated) parts.push(`Occurred: ${event.dateCreated}`) |
| 319 | parts.push(message) |
| 320 | } |
| 321 | |
| 322 | const exceptionEntry = event.entries?.find((entry) => entry.type === 'exception') |
| 323 | if (exceptionEntry?.data) { |
| 324 | const exceptionLines = formatException(exceptionEntry.data as SentryExceptionData) |
| 325 | if (exceptionLines.length > 0) { |
| 326 | parts.push('') |
| 327 | parts.push('--- Exception ---') |
| 328 | parts.push(...exceptionLines) |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | const tagLines = (event.tags ?? []) |
| 333 | .map((tag) => (tag.key && tag.value ? `${tag.key}: ${tag.value}` : undefined)) |
| 334 | .filter((line): line is string => Boolean(line)) |
| 335 | if (tagLines.length > 0) { |
| 336 | parts.push('') |
| 337 | parts.push('--- Tags ---') |
| 338 | parts.push(...tagLines) |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | return parts.join('\n').trim() |
| 343 | } |
| 344 | |
| 345 | /** |
| 346 | * Fetches the latest event for an issue. Returns null when the issue has no events or the |
no test coverage detected