...
|
...
|
@@ -132,7 +132,7 @@ |
|
|
- (void)yher_start
|
|
|
{
|
|
|
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].httpPerformanceTrackEnable) {
|
|
|
[[YH_EventCollector sharedInstance] timeEventStartWithRequest:self.currentRequest];
|
|
|
[[YH_EventCollector sharedInstance] timeEventStartWithRequestUrl:[self.currentRequest.URL absoluteString]];
|
|
|
}
|
|
|
[self yher_start];
|
|
|
}
|
...
|
...
|
@@ -140,13 +140,19 @@ |
|
|
+ (nullable NSData *)yher_sendSynchronousRequest:(NSURLRequest *)request returningResponse:(NSURLResponse * _Nullable * _Nullable)response error:(NSError **)error
|
|
|
{
|
|
|
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].httpPerformanceTrackEnable) {
|
|
|
[[YH_EventCollector sharedInstance] timeEventStartWithRequest:request];
|
|
|
[[YH_EventCollector sharedInstance] timeEventStartWithRequestUrl:[request.URL absoluteString]];
|
|
|
}
|
|
|
|
|
|
NSData *data = [self yher_sendSynchronousRequest:request returningResponse:response error:error];
|
|
|
|
|
|
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].httpPerformanceTrackEnable) {
|
|
|
[[YH_EventCollector sharedInstance] timeEventEndWithRequest:request response:*response];
|
|
|
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].httpPerformanceTrackEnable && !error && ![[request.URL absoluteString] isEqualToString:@"http://app.yoho.cn/collect/v2"]) {
|
|
|
NSURLResponse *res = *response;
|
|
|
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)res;
|
|
|
NSDictionary *httpResponseHeaderFields = [httpResponse allHeaderFields];
|
|
|
NSString *contentLength = [NSString stringWithFormat:@"%lld",[[httpResponseHeaderFields objectForKey:@"Content-Length"] longLongValue]];
|
|
|
NSString *statusCode = [NSString stringWithFormat:@"%lld",httpResponse.statusCode];
|
|
|
|
|
|
[[YH_EventCollector sharedInstance] timeEventEndWithRequestUrl:[request.URL absoluteString] HTTPMethod:request.HTTPMethod statusCode:statusCode contentLength:contentLength];
|
|
|
}
|
|
|
return data;
|
|
|
}
|
...
|
...
|
@@ -157,15 +163,22 @@ |
|
|
{
|
|
|
|
|
|
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].httpPerformanceTrackEnable) {
|
|
|
[[YH_EventCollector sharedInstance] timeEventStartWithRequest:request];
|
|
|
[[YH_EventCollector sharedInstance] timeEventStartWithRequestUrl:[request.URL absoluteString]];
|
|
|
}
|
|
|
[self yher_sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
|
|
|
|
|
|
if (handler) {
|
|
|
handler(response,data,connectionError);
|
|
|
}
|
|
|
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].httpPerformanceTrackEnable) {
|
|
|
[[YH_EventCollector sharedInstance] timeEventEndWithRequest:request response:response];
|
|
|
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].httpPerformanceTrackEnable && !connectionError && ![[request.URL absoluteString] isEqualToString:@"http://app.yoho.cn/collect/v2"]) {
|
|
|
|
|
|
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
|
|
|
NSDictionary *httpResponseHeaderFields = [httpResponse allHeaderFields];
|
|
|
NSString *contentLength = [NSString stringWithFormat:@"%lld",[[httpResponseHeaderFields objectForKey:@"Content-Length"] longLongValue]];
|
|
|
NSString *statusCode = [NSString stringWithFormat:@"%lld",httpResponse.statusCode];
|
|
|
|
|
|
[[YH_EventCollector sharedInstance] timeEventEndWithRequestUrl:[request.URL absoluteString] HTTPMethod:request.HTTPMethod statusCode:statusCode contentLength:contentLength];
|
|
|
|
|
|
}
|
|
|
}];
|
|
|
}
|
...
|
...
|
@@ -189,8 +202,13 @@ |
|
|
if (self.my_delegate && [self.my_delegate respondsToSelector:@selector(connectionDidFinishLoading:)]) {
|
|
|
[self.my_delegate connectionDidFinishLoading:connection];
|
|
|
}
|
|
|
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].httpPerformanceTrackEnable) {
|
|
|
[[YH_EventCollector sharedInstance] timeEventEndWithRequest:connection.currentRequest response:connection.my_response];
|
|
|
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].httpPerformanceTrackEnable && ![[connection.currentRequest.URL absoluteString] isEqualToString:@"http://app.yoho.cn/collect/v2"]) {
|
|
|
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)connection.my_response;
|
|
|
NSDictionary *httpResponseHeaderFields = [httpResponse allHeaderFields];
|
|
|
NSString *contentLength = [NSString stringWithFormat:@"%lld",[[httpResponseHeaderFields objectForKey:@"Content-Length"] longLongValue]];
|
|
|
NSString *statusCode = [NSString stringWithFormat:@"%lld",httpResponse.statusCode];
|
|
|
|
|
|
[[YH_EventCollector sharedInstance] timeEventEndWithRequestUrl:[connection.currentRequest.URL absoluteString] HTTPMethod:connection.currentRequest.HTTPMethod statusCode:statusCode contentLength:contentLength];
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -198,9 +216,6 @@ |
|
|
if (self.my_delegate && [self.my_delegate respondsToSelector:@selector(connection:didFailWithError:)]) {
|
|
|
[self.my_delegate connection:connection didFailWithError:error];
|
|
|
}
|
|
|
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].httpPerformanceTrackEnable) {
|
|
|
[[YH_EventCollector sharedInstance] timeEventEndWithRequest:connection.currentRequest response:nil];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|