Authored by ZhangTonghai

修改上报错误上报到南京

review by xiaojun
... ... @@ -102,7 +102,6 @@
- (void)reportUploadError:(AFHTTPRequestOperation *)operation withResponse:(id)responseObject
{
#ifdef APPYOHO
if (operation.response.statusCode == 200) {
return;
}
... ... @@ -112,7 +111,7 @@
NSString *body = [[NSString alloc] initWithData:operation.request.HTTPBody encoding:NSUTF8StringEncoding];
id response = nil;
if (IsDictionaryClass(responseObject)) {
if (YAIsDictionaryClass(responseObject)) {
response = responseObject;
} else {
response = [responseObject description];
... ... @@ -126,32 +125,30 @@
parameters[JsonKeyErrorEC] = @(code);
}
if (!IsStrEmpty(url)) {
if (!YAIsStrEmpty(url)) {
parameters[JsonKeyErrorEI] = url;
}
if (!IsStrEmpty(method)) {
if (!YAIsStrEmpty(method)) {
parameters[JsonKeyErrorMethod] = method;
}
if (!IsStrEmpty(body)) {
if (!YAIsStrEmpty(body)) {
parameters[JsonKeyErrorBody] = body;
}
if (!IsNilOrNull(response)) {
if (!YAIsNilOrNull(response)) {
parameters[JsonKeyErrorResponse] = response;
}
[[YH_Analytics sharedInstance] logError:kErrorTypeREPORT parameters:parameters];
#endif
}
- (void)reportUplaodError:(AFHTTPRequestOperation *)operation withError:(NSError *)error
{
#ifdef APPYOHO
if (!error) {
return;
}
NSString *url = operation.request.URL.absoluteString;
NSString *method = [operation.request.HTTPMethod uppercaseString];
NSString *body = [[NSString alloc] initWithData:operation.request.HTTPBody encoding:NSUTF8StringEncoding];
NSString *response = (*error).localizedDescription;
NSString *response = error.localizedDescription;
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
//超时返回是0,但是为了和android的统一性,ios修改成-1。
if (operation.response.statusCode == 0) {
... ... @@ -160,20 +157,20 @@
parameters[JsonKeyErrorEC] = @(operation.response.statusCode);
}
if (!IsStrEmpty(url)) {
if (!YAIsStrEmpty(url)) {
parameters[JsonKeyErrorEI] = url;
}
if (!IsStrEmpty(method)) {
if (!YAIsStrEmpty(method)) {
parameters[JsonKeyErrorMethod] = method;
}
if (!IsStrEmpty(body)) {
if (!YAIsStrEmpty(body)) {
parameters[JsonKeyErrorBody] = body;
}
if (!IsStrEmpty(response)) {
if (!YAIsStrEmpty(response)) {
parameters[JsonKeyErrorResponse] = response;
}
[[YH_Analytics sharedInstance] logError:kErrorTypeREPORT parameters:parameters];
#endif
}
- (AFHTTPRequestOperation *)uploadLogcustomURL:(NSString *)url parameters:(NSDictionary *)parameters completionBlock:(void (^)(BOOL success, NSError *error))block
... ...
... ... @@ -27,6 +27,16 @@
#define kSafeValue(X) (!(X) ? [NSNull null] : (X))
#define YAIsNilOrNull(_ref) (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]))
#define YAIsDictionaryClass(_ref) (!YAIsNilOrNull(_ref) && ([(_ref) isKindOfClass:[NSDictionary class]]))
#define YAIsArrayClass(_ref) (!YAIsNilOrNull(_ref) && ([(_ref) isKindOfClass:[NSArray class]]))
#define YAIsStrEmpty(_ref) (YAIsNilOrNull(_ref) || (![(_ref) isKindOfClass:[NSString class]]) || ([(_ref) isEqualToString:@""]))
#define YAIsArrEmpty(_ref) (YAIsNilOrNull(_ref) || (![(_ref) isKindOfClass:[NSArray class]]) || ([(_ref) count] == 0))
/*********** App Configuration ************/
#define kYHAnalyticsSDKVersion @"1.2" // 数据分析库版本
... ...