( baseFetch: typeof fetch = globalThis.fetch, )
| 103 | * mutating any global. |
| 104 | */ |
| 105 | export function createBillingFetch( |
| 106 | baseFetch: typeof fetch = globalThis.fetch, |
| 107 | ): typeof fetch { |
| 108 | return async (input, init) => { |
| 109 | const response = await baseFetch(input, init) |
| 110 | try { |
| 111 | recordBillableUnitsFromResponse(response) |
| 112 | } catch { |
| 113 | // Capturing usage must never break the underlying request. |
| 114 | } |
| 115 | return response |
| 116 | } |
| 117 | } |
no test coverage detected