(
url: string,
teamId: number | null,
timeToSeeDataPayload: Omit<
TimeToSeeDataPayload,
'api_url' | 'time_to_see_data_ms' | 'status' | 'api_response_bytes'
>
)
| 40 | * This is not in api.ts to avoid circular dependencies, but the principle is the same. |
| 41 | */ |
| 42 | export async function apiGetWithTimeToSeeDataTracking<T extends any>( |
| 43 | url: string, |
| 44 | teamId: number | null, |
| 45 | timeToSeeDataPayload: Omit< |
| 46 | TimeToSeeDataPayload, |
| 47 | 'api_url' | 'time_to_see_data_ms' | 'status' | 'api_response_bytes' |
| 48 | > |
| 49 | ): Promise<T> { |
| 50 | let response: Response | undefined |
| 51 | let responseData: T | undefined |
| 52 | let error: any |
| 53 | const requestStartMs = performance.now() |
| 54 | try { |
| 55 | response = await api.getResponse(url) |
| 56 | responseData = await getJSONOrThrow(response) |
| 57 | } catch (e) { |
| 58 | error = e |
| 59 | } |
| 60 | const requestDurationMs = performance.now() - requestStartMs |
| 61 | captureTimeToSeeData(teamId, { |
| 62 | ...timeToSeeDataPayload, |
| 63 | api_url: url, |
| 64 | status: error ? 'failure' : 'success', |
| 65 | api_response_bytes: response && getResponseBytes(response), |
| 66 | time_to_see_data_ms: requestDurationMs, |
| 67 | }) |
| 68 | if (!responseData) { |
| 69 | throw error // If there's no response data, there must have been an error - rethrow it |
| 70 | } |
| 71 | return responseData |
| 72 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…