Skip to main content

Privacy and network traffic

note

Looking for the previous SDK? See the 6.x network privacy page.

Bugsee records the application's network activity: for each request, its URL, method, headers, status and, within limits, the request and response bodies. To keep personal data out of these records, Bugsee redacts well-known sensitive values on its own, and lets you install a filter that sees, changes or drops every event.

Disabling network capture​

Set BugseeOptionCaptureNetwork (BugseeOptions.monitorNetwork) to NO to record no network traffic, or BugseeOptionCaptureWebSocket (BugseeOptions.monitorWebSocket) to NO to leave out WebSocket traffic only. See Configuration.

Built-in redaction​

With BugseeOptionCaptureNetworkUseDefaultSanitizer (BugseeOptions.sanitizeNetworkData) on, which is the default, every captured event is redacted before it is recorded. The value of each sensitive key below is replaced with <redacted>:

  • URL query parameters, in the URL and in the URL it was redirected from: password, passwd, pass, secret, client_secret, token, app_token, access_token, refresh_token, id_token, auth_token, api_key, apikey, authorization, credit_card, creditcard, card_number, cardnumber, cvv, cvc, cvv2, ssn, social_security, pin, private_key, privatekey.
  • JSON bodies: the same keys, up to 64 levels of nesting. A body is parsed as JSON when its Content-Type contains json, or when the event has no Content-Type. Other bodies are left as they are.
  • HTTP headers: Authorization, Proxy-Authorization, Cookie, Set-Cookie, X-Api-Key, X-Auth-Token, X-Csrf-Token, X-Forwarded-For, X-Real-Ip.

Keys and header names are matched without regard to case.

A network filter turns this off

The built-in redaction runs only while no network filter is set. As soon as you install one — with setNetworkEventFilter: or the delegate method — your filter alone decides what is recorded. To keep the built-in redaction, run defaultNetworkSanitizer in your filter, as shown below.

Network filters​

A filter receives every network event before it is recorded, as a BugseeNetworkEvent. Change it and pass it to the decision block, or pass nil to drop the event.

[Bugsee setNetworkEventFilter:^(BugseeNetworkEvent *event,
BugseeNetworkFilterDecisionBlock decision) {
// Keep the built-in redaction
[Bugsee.defaultNetworkSanitizer sanitize:event];

// Drop the traffic of an internal host altogether
if ([event.url containsString:@"://telemetry.example.com"]) {
decision(nil);
return;
}

// Your own redaction
NSMutableDictionary *headers = [event.headers mutableCopy];
if (headers[@"X-Session-Id"]) {
headers[@"X-Session-Id"] = @"<redacted>";
event.headers = headers;
}

decision(event);
}];

// Remove the filter
[Bugsee setNetworkEventFilter:nil];

The same filter can be a BugseeDelegate method instead:

- (void)bugseeFilterNetworkEvent:(BugseeNetworkEvent *)event
completionHandler:(BugseeNetworkFilterDecisionBlock)decisionBlock {
[Bugsee.defaultNetworkSanitizer sanitize:event];
// ...your own redaction...
decisionBlock(event);
}

// ...somewhere within the class
[Bugsee sharedInstance].delegate = self;
  • If both are set, the block filter is used and the delegate method is not called.
  • Call the decision block once, within 10 seconds. Past that the event is dropped, and a later call is ignored. The filter may finish on any thread.
  • defaultNetworkSanitizer changes the event in place and returns once it is done, parsing a JSON body on the calling thread. It is safe to use from any thread, and works before launch and after stop.
  • Events your code records with addNetworkEvent: are recorded as they are, without the filter and without the built-in redaction. Record them with addNetworkEvent:requiresFiltering: and YES to run them through your filter, or through the built-in redaction when no filter is set. See Network events.

Network events​

The filter is called several times for one request: usually once for the request (BugseeNetworkEventBegin) and once when it ends (BugseeNetworkEventComplete, or BugseeNetworkEventCancel / BugseeNetworkEventError). WebSocket events carry the BugseeWebSocketEvent* types.

PropertyTypeNotes
bugseeNetworkEventTypeNSStringThe stage, one of the constants above. Read it to tell the events apart.
methodNSStringThe HTTP method: GET, POST…
responseCodeNSIntegerThe HTTP status; 0 for the request event.
urlNSStringThe request URL. Change it to redact.
redirectedFromURLNSStringThe URL the request was redirected from, if any.
headersNSDictionaryThe request or response headers. Assign a new dictionary to change them.
bodyNSDataThe raw request or response body, where it was captured.
noBodyReasonNSStringWhy there is no body: BugseeNetworkBodySizeTooLarge, BugseeNetworkBodyUnsupportedContentType, BugseeNetworkBodyNoContentType or BugseeNetworkBodyCantReadData.
errorNSDictionaryThe error of a failed request.

Limiting bodies​

Two options decide which bodies are kept. Both apply after your filter: the filter sees the body as it was captured.

OptionDefaultEffect
BugseeOptionCaptureNetworkBodySizeLimit (maxNetworkBodySize)20480Largest body kept, in bytes. A larger body is left out whole, not cut. 0 keeps no bodies.
BugseeOptionCaptureNetworkBodyWithoutTypeNOWhether to keep a body that has no Content-Type header. A filter that removes Content-Type therefore also removes the body. WebSocket frames are kept either way.
  • Breadcrumbs privacy: network filters do not reach the HTTP breadcrumbs. The built-in query parameter redaction does.
  • HTTP errors: with a network filter set, the URL in an HTTP-error report also loses its user info, and path segments that look like identifiers are replaced with placeholders.
Found an issue, typo, or wrong statement on this page? Report it now →