Gleap
Search…
🌎
Network logs
Gleap allows you to log all network requests, to get a better understanding of what went wrong. This usually works out of the box, but needs additional configuration, depending on the 3rd party libraries you are using within your applications.

Setting up network logs

Swift
Objective-C
1
Gleap.startNetworkRecording();
Copied!
1
[Gleap startNetworkRecording];
Copied!
In certain circumstances you might need to pass an NSURLSessionConfiguration in order for Gleap to be able to log the network requests.
Swift
Objective-C
1
Gleap.startNetworkRecording(for: sessionConfiguration)
Copied!
1
[Gleap startNetworkRecordingForSessionConfiguration: sessionConfiguration];
Copied!
​

AFNetworking

To enable network logging for AFNetworking, create and use the following class.
1
// GleapAFURLSessionManager.h
2
#import <AFNetworking/AFNetworking.h>
3
​
4
@interface GleapAFURLSessionManager : AFHTTPSessionManager
5
​
6
@end
7
​
8
// GleapAFURLSessionManager.m
9
#import "GleapAFURLSessionManager.h"
10
#import <Gleap/Gleap.h>
11
​
12
@implementation GleapAFURLSessionManager
13
​
14
- (instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)configuration {
15
[Gleap startNetworkRecordingForSessionConfiguration: configuration];
16
17
return [super initWithSessionConfiguration:configuration];
18
}
19
​
20
@end
Copied!
Example usage for the GleapAFURLSessionManager.
1
// Use the GleapAFURLSessionManager for all further requests
2
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
3
GleapAFURLSessionManager *manager = [[GleapAFURLSessionManager alloc] initWithSessionConfiguration: configuration];
4
​
5
[manager GET: @"https://www.example.org/get" parameters:nil headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
6
NSLog(@"JSON: %@", responseObject);
7
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
8
NSLog(@"Error: %@", error);
9
}];
Copied!

Alamofire

To enable network logging for Alamofire, create and use the following class.
1
import Alamofire
2
import Gleap
3
​
4
class GleapSessionManager: Alamofire.Session {
5
static let sharedManager: GleapSessionManager = {
6
let configuration = URLSessionConfiguration.default
7
Gleap.startNetworkRecording(for: configuration)
8
let manager = GleapSessionManager(configuration: configuration)
9
return manager
10
}()
11
}
Copied!
Example usage for the GleapSessionManager.
1
GleapSessionManager.sharedManager.request("https://www.sample.org/get").response { response in
2
debugPrint(response)
3
}
Copied!

​

Last modified 1mo ago