Skip to content

Commit

Permalink
add network request response size
Browse files Browse the repository at this point in the history
  • Loading branch information
garredow committed Apr 20, 2024
1 parent 11c858f commit 7179753
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/lib/kaiware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ export class Kaiware {
lifecycleStatus: 'success',
responseStatus: this.status,
responseHeaders,
responseBody: this.responseText
responseBody: this.responseText,
responseSize: new Blob([this.responseText]).size
});
});

Expand Down
9 changes: 6 additions & 3 deletions src/types/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export type ClearLogsPayload = z.infer<typeof clearLogsPayloadSchema>;
export const clearLogsResPayloadSchema = z.null();
export type ClearLogsResPayload = z.infer<typeof clearLogsResPayloadSchema>;

// NetworkRequestUpdate
// NetworkRequest
export const networkRequestSchema = z.object({
requestId: z.string(),
url: z.string(),
Expand All @@ -135,10 +135,12 @@ export const networkRequestSchema = z.object({
endTime: z.number().optional(),
responseStatus: z.number().optional(),
responseHeaders: z.array(z.object({ key: z.string(), value: z.string() })).optional(),
responseBody: z.string().optional()
responseBody: z.string().optional(),
responseSize: z.number().optional()
});
export type NetworkRequest = z.infer<typeof networkRequestSchema>;

// NetworkRequestUpdateResPayload
export const networkRequestUpdateResPayload = z.object({
requestId: z.string(),
url: z.string().optional(),
Expand Down Expand Up @@ -166,7 +168,8 @@ export const networkRequestUpdateResPayload = z.object({
endTime: z.number().optional(),
responseStatus: z.number().optional(),
responseHeaders: z.array(z.object({ key: z.string(), value: z.string() })).optional(),
responseBody: z.string().optional()
responseBody: z.string().optional(),
responseSize: z.number().optional()
});
export type NetworkRequestUpdateResPayload = z.infer<typeof networkRequestUpdateResPayload>;

Expand Down

0 comments on commit 7179753

Please sign in to comment.