Network Capture
Capture sanitized HTTP request and response evidence from .NET, Android, iOS, React Native, Flutter, and Cordova or Capacitor apps.
Ansight records completed HTTP requests as ansight.network-request.v1
evidence alongside screenshots, logs, and application events. Capture is
available across every SDK, but interception and opt-in behavior vary by
platform.
| SDK | Automatic integration | Manual recording |
|---|---|---|
| .NET / MAUI | Process-wide HttpClient diagnostics; Apple targets also use the native URL Loading System interceptor | Runtime.RecordNetworkRequest(...) or AnsightHttpMessageHandler |
| Android | Integrate with the app’s HTTP client | AnsightRuntime.recordNetworkRequest(...) |
| iOS / Swift | URL Loading System interceptor | AnsightRuntime.shared.recordNetworkRequest(...) |
| React Native | Opt-in fetch and XMLHttpRequest instrumentation | recordNetworkRequest(...) |
| Flutter | AnsightHttpClient wrapper | Ansight.instance.recordNetworkRequest(...) |
| Cordova / Capacitor | Opt-in fetch and XMLHttpRequest instrumentation | recordNetworkRequest(...) |
Defaults and Privacy
Network evidence can contain URLs, headers, error messages, and request or response bodies. Treat it as sensitive.
- Simulator and emulator native capture defaults may enable the platform integration; use the explicit enable/disable API when policy must be fixed.
- Text bodies are bounded to 64 KiB per body by default in body-aware capture integrations. Request and response bodies can be disabled independently.
- Binary bodies require an explicit opt-in and are represented as Base64.
- Standard credential headers, cookies, URL user information, cloud signed-URL fields, and sensitive text assignments are redacted before transport.
- Apps can add sensitive header and query-parameter names, rewrite URLs or records, or suppress a record entirely.
- The host applies its own sanitization before persisting
network/requests/.
Disabling redaction is suitable only for a deliberately isolated local test with non-sensitive data. Do not capture production credentials or personal data.
.NET / MAUI
Enable process-wide capture through the normal options builder:
using Ansight;
var options = Options.CreateBuilder()
.WithNetworkCapture(network =>
{
network.WithMaximumBodyBytes(64 * 1024);
network.WithRequestBodies();
network.WithResponseBodies();
})
.Build();
WithoutNetworkCapture() disables process-wide automatic capture. Explicit
AnsightHttpMessageHandler instances remain active. Automatic HttpClient
diagnostics are metadata-only because observers do not consume application
bodies; use the explicit handler when bounded body capture is required.
An explicit handler can also apply app-specific sensitive names and a final record filter:
var handler = new AnsightHttpMessageHandler(
new NetworkRequestSanitizationOptions
{
AdditionalSensitiveHeaderNames = ["x-tenant-secret"],
AdditionalSensitiveQueryParameterNames = ["session"],
RequestSanitizer = request =>
request.Url.Contains("/health", StringComparison.Ordinal)
? null
: request,
});
var client = new HttpClient(handler);
Android
Android core accepts sanitized typed records from the app’s existing OkHttp, Retrofit, or other client integration:
AnsightRuntime.recordNetworkRequest(
AnsightNetworkRequest(
id = requestId,
source = "okhttp",
startedAtUtc = startedAt,
completedAtUtc = completedAt,
durationMilliseconds = durationMs,
method = request.method,
url = request.url.toString(),
statusCode = response.code,
)
)
AnsightNetworkRequestSanitizer is always applied inside the native runtime,
including records received from framework bridges.
iOS / Swift
Enable or disable native URL Loading System interception in the options builder:
let options = try AnsightOptions.createBuilder()
.withNetworkCapture(AnsightNetworkCaptureOptions(
enabled: true,
maximumBodyBytes: 64 * 1_024,
captureBinaryBodies: false
))
.build()
Use .withoutNetworkCapture() to disable the interceptor. Custom clients can
submit an AnsightNetworkRequest directly with
AnsightRuntime.shared.recordNetworkRequest(...).
React Native
await Ansight.initializeAndActivate(
Ansight.createOptionsBuilder()
.withAnsightDefaults()
.withNetworkCapture({
maximumBodyBytes: 64 * 1024,
additionalSensitiveHeaderNames: ["x-tenant-secret"],
additionalSensitiveQueryParameterNames: ["session"],
requestSanitizer: request =>
request.url.includes("/health") ? null : request,
})
.build(),
);
Use installNetworkCapture(...) and uninstallNetworkCapture() when the hooks
need an independent lifecycle. sanitizeNetworkRequest(...) exposes the same
app-side policy for tests and custom integrations.
Flutter
Wrap the package:http client used by the app:
final client = AnsightHttpClient(
inner: http.Client(),
sanitizationOptions: AnsightNetworkSanitizationOptions(
maximumBodyBytes: 64 * 1024,
additionalSensitiveHeaderNames: <String>['x-tenant-secret'],
additionalSensitiveQueryParameterNames: <String>['session'],
requestSanitizer: (request) =>
request.url.contains('/health') ? null : request,
),
);
Use Ansight.instance.recordNetworkRequest(...) for a different HTTP stack.
Cordova / Capacitor
The Capacitor builder uses the same opt-in fetch and XMLHttpRequest capture
model as React Native:
await Ansight.initializeAndActivate(
Ansight.createOptionsBuilder()
.withAnsightDefaults()
.withNetworkCapture({ maximumBodyBytes: 64 * 1024 })
.withoutNetworkResponseBodies() // optional
.build(),
);
Use installNetworkCapture(...), uninstallNetworkCapture(), and
recordNetworkRequest(...) for explicit lifecycle and custom-client control.