Skip to main content

Privacy and Network traffic

Disabling network traffic collection

Network traffic collection can be disabled completely using BugseeMonitorNetworkKey launch option. See configuration for more info.

Sanitizing data

Bugsee captures network activity from the application and stores headers and in some cases body of the request and response. In order to allow you to hide user identifiable and other sensitive data from these network logs, we provide two methods for hooking your own filters, via a delegate or a block that we will call for every event about to be recorded.

Regardless of the method you chose, the principle is similar, for every event to be recorded, Bugsee will call your method and provide you with BugseeNetworkEvent object. It is your method's responsibility to clean up all user identifiable data from that structure and call decisionBlock() to pass it back to Bugsee.

Using delegate

Your class should implement BugseeDelegate protocol and it must set itself as the delegate for Bugsee.

-(void)bugseeFilterNetworkEvent:(BugseeNetworkEvent *)event completionHandler:(BugseeNetworkFilterDecisionBlock)decisionBlock{
NSError * error;
// Below is an example code that will remove access_token from all URLs going through the filter.
if (event.url){
NSError * error;
NSRegularExpression * regex = [NSRegularExpression regularExpressionWithPattern:@"access_token=[0-9a-z\\-]*" options:NSRegularExpressionCaseInsensitive error:&error];
event.url = [regex stringByReplacingMatchesInString:event.url
options:0
range:NSMakeRange(0, event.url.length)
withTemplate:@""];
}

// Send the event further, call with nil if you want to omit this event altogether.
decisionBlock(event);
}

// ..somewhere within the class
[Bugsee sharedInstance].delegate = self;

Using filter with block

Alternatively you can set up a filter by registering a block to be executed for every event.

[Bugsee setNetworkEventFilter:^(BugseeNetworkEvent *event, BugseeNetworkFilterDecisionBlock decisionBlock) {

// modify BugseeNetworkEvent as you wish here


// Send the event further, call with nil if you want to omit this event altogether.
decisionBlock(event);
}

// Unregister a block before de-allocating a class in which it was registered
[Bugsee removeNetworkEventFilter];

Network Events

The delegate or hook is going to be called several times for each network request, depending on its life-cycle. Usually for successful requests its going to be called twice, once with the request event (request headers and body) and once after completion and will contain headers and body of the response.

PropertyDescriptionTypeRead onlyNotes
bugseeNetworkEventTypeType of network eventNSStringYESCan be one of BugseeNetworkEventBegin, BugseeNetworkEventComplete, BugseeNetworkEventCancel or BugseeNetworkEventError
methodHTTP Request MethodNSStringYES'GET', 'POST', etc...
urlNetwork event URLNSStringNO
redirectedFromURLURL of Network event that we were redirected fromNSStringNO
bodyBodyNSDataNORaw body of the request or response where available.
headersHTTP HeadersNSDictionaryNOKey-value store of HTTP headers associated with the event.