(body: NonNullable<RequestInit['body']>)
| 618 | } |
| 619 | |
| 620 | function parseBodyForReport(body: NonNullable<RequestInit['body']>): unknown { |
| 621 | if (typeof body === 'string') { |
| 622 | try { |
| 623 | return JSON.parse(body) as unknown; |
| 624 | } catch { |
| 625 | return body; |
| 626 | } |
| 627 | } |
| 628 | if (body instanceof URLSearchParams) { |
| 629 | return body.toString(); |
| 630 | } |
| 631 | if (body instanceof FormData) { |
| 632 | return '[FormData]'; |
| 633 | } |
| 634 | if (body instanceof Blob) { |
| 635 | return `[Blob ${body.type || 'application/octet-stream'} ${body.size} bytes]`; |
| 636 | } |
| 637 | if (body instanceof ArrayBuffer) { |
| 638 | return `[ArrayBuffer ${body.byteLength} bytes]`; |
| 639 | } |
| 640 | if (ArrayBuffer.isView(body)) { |
| 641 | return `[${body.constructor.name} ${body.byteLength} bytes]`; |
| 642 | } |
| 643 | return '[ReadableStream]'; |
| 644 | } |
| 645 | |
| 646 | function responseForReport(text: string): { envelope?: unknown; raw?: string } { |
| 647 | try { |
no test coverage detected