/** * `analyzeNetworkActivity`: parses xctrace's network-connections schema * from a `.trace` recorded with the Network Profile template. v1.14 item A. * * "The network is slow" / "my SDK is chatty" / "slow launch because of * one API call" are top-3 iOS perf complaints. Pre-v1.14 we had zero * coverage of the network family. XcodeTraceMCP's regex map listed it * as one of their five instrument families. This analyzer closes the * gap with the same shape as analyzeHangs / analyzeAnimationHitches: * * - Bytes-in/out, duration, status-code, and URL/host extracted per * connection. * - Aggregates: total bytes, slowest response, average response, count * per HTTP status bucket. * - Top-N by duration (the "which calls blocked the user?" view) and * top-N by bytes (the "which calls are bloating my budget?" view). * - Per-host aggregates surfacing chatty SDKs without manually grouping. * * Resilient to column-name drift across xctrace versions: each field * is looked up under multiple plausible mnemonics, falling back to the * one that yields data. */ import { z } from "zod"; import type { AnalyzeTraceOptions, DataStatus, SupportStatus } from "../types.js"; export declare const analyzeNetworkActivitySchema: z.ZodObject<{ tracePath: z.ZodString; topN: z.ZodDefault; minBytes: z.ZodDefault; outputFormat: z.ZodOptional>; }, "strip", z.ZodTypeAny, { tracePath: string; topN: number; minBytes: number; outputFormat?: "markdown" | "json" | "both" | "verify-fix-table" | undefined; }, { tracePath: string; outputFormat?: "markdown" | "json" | "both" | "verify-fix-table" | undefined; topN?: number | undefined; minBytes?: number | undefined; }>; export type AnalyzeNetworkActivityInput = z.infer; export interface NetworkConnectionEntry { /** Start timestamp in nanoseconds since recording start. */ startNs: number; startFmt?: string; /** Response/transaction duration in nanoseconds when available. */ durationNs?: number; durationMs?: number; durationFmt?: string; /** URL or hostname (whichever the trace exposed). */ url?: string; /** Host portion of the URL, when parseable. */ host?: string; /** HTTP method (GET, POST, etc.) when present. */ method?: string; /** HTTP response status code. */ statusCode?: number; /** Bytes received from the server (response body + headers). */ bytesIn?: number; /** Bytes sent to the server (request body + headers). */ bytesOut?: number; } export interface NetworkHostAggregate { host: string; count: number; bytesIn: number; bytesOut: number; longestMs: number; } export interface AnalyzeNetworkActivityResult { ok: boolean; tracePath: string; totals: { rows: number; totalBytesIn: number; totalBytesOut: number; longestMs: number; averageMs: number; /** Status-code bucket counts. Example: `{ "2xx": 47, "4xx": 3, "5xx": 1, "n/a": 12 }`. */ statusBuckets: Record; }; /** Top N connections ranked by `durationMs` desc. */ topByDuration: NetworkConnectionEntry[]; /** Top N connections ranked by `bytesIn + bytesOut` desc. */ topByBytes: NetworkConnectionEntry[]; /** Per-host aggregates, ranked by request count desc. */ byHost: NetworkHostAggregate[]; diagnosis: string; /** @deprecated v1.14 item I. Use `supportStatus[]` instead. */ status: DataStatus; /** v1.14+. Unified per-area status. See {@link SupportStatus}. */ supportStatus: SupportStatus[]; } /** Extract a host string from a URL-or-host value. Falls back to the * raw input when it does not look like a URL (already a host). * * Handles IPv4, IPv6 (with `[::1]:port/path` bracket form), and bare * hostnames. v1.17 fixed the IPv6 edge case where bracket-form was * yielding `[` because the colon-from-start search hit the IPv6 * delimiter before the port colon. */ export declare function extractHost(urlOrHost: string | undefined): string | undefined; /** Pure: turn the network-connections XML into the analyzed result. */ export declare function analyzeNetworkActivityFromXml(xml: string, tracePath: string, topN?: number, minBytes?: number): AnalyzeNetworkActivityResult; export declare function analyzeNetworkActivity(input: AnalyzeNetworkActivityInput, options?: AnalyzeTraceOptions): Promise;