Authored by 朱小军

接口错误类型可通过自定义的url接口上报 review by 小熊

... ... @@ -16,7 +16,7 @@
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{
NSError *serializationError = nil;
NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError];
NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"POST" URLString:URLString parameters:parameters error:&serializationError];
if (serializationError) {
if (failure) {
#pragma clang diagnostic push
... ...
... ... @@ -411,7 +411,7 @@ static dispatch_queue_t persisting_queue() {
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypePerfor];
[self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:error.jsonDictionary, nil] forKey:JsonKeyDataTypeErrors];
[[YHNetworkService sharedInstance] uploadLogData:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) {
[[YHNetworkService sharedInstance] uploadLogcustomURL:kURLAnalyticsService2 parameters:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) {
if (success) {
YALog(@"upload immedialite error success.");
} else {
... ...
... ... @@ -19,7 +19,7 @@ typedef void (^YHNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus sta
- (void)setReachabilityStatusChangeBlock:(YHNetworkReachabilityStatusBlock)block;
- (AFHTTPRequestOperation *)uploadLogData:(NSDictionary *)parameters completionBlock:(void (^)(BOOL success, NSError *error))block;
- (AFHTTPRequestOperation *)uploadLogcustomURL:(NSString *)url parameters:(NSDictionary *)parameters completionBlock:(void (^)(BOOL success, NSError *error))block;
- (AFHTTPRequestOperation *)getNewLogStrategy:(NSDictionary *)parameters completionBlock:(void (^)(NSDictionary *strategy, NSError *error))block;
+ (void)uploadFirstLaunchApp:(NSDictionary *)parameters completionBlock:(void (^)(BOOL flag, NSError *error))block;
... ...
... ... @@ -33,7 +33,7 @@
{
self = [super init];
if (self) {
self.httpClient = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:kURLAnalyticsService]];
self.httpClient = [AFHTTPRequestOperationManager manager];
self.httpClient.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
self.httpClient.securityPolicy.allowInvalidCertificates = YES;
self.httpClient.operationQueue.maxConcurrentOperationCount = 6;
... ... @@ -78,7 +78,37 @@
NSString *parsJsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSDictionary *newParameters = @{@"_mlogs": kSafeValue(parsJsonStr)};
return [self.httpClient POST:kYASApiMethodUploadData priority:NSOperationQueuePriorityLow parameters:newParameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
return [self.httpClient POST:kURLAnalyticsService priority:NSOperationQueuePriorityLow parameters:newParameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
if (block) {
block(YES, nil);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if (block) {
block(NO, error);
}
}];
}
- (AFHTTPRequestOperation *)uploadLogcustomURL:(NSString *)url parameters:(NSDictionary *)parameters completionBlock:(void (^)(BOOL success, NSError *error))block
{
NSError *error = nil;
NSMutableDictionary *actualParameters = [NSMutableDictionary dictionaryWithDictionary:parameters];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:actualParameters options:0 error:&error];
if (error) {
YALog(@"json parsing, connot convert to json for: %@\n code: %ld\n reason: %@", actualParameters, (long)[error code], [error localizedDescription]);
if (block) {
block(NO, error);
}
return nil;
}
NSString *parsJsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSDictionary *newParameters = @{@"_mlogs": kSafeValue(parsJsonStr)};
return [self.httpClient POST:url priority:NSOperationQueuePriorityLow parameters:newParameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
if (block) {
block(YES, nil);
... ...
... ... @@ -44,9 +44,10 @@
/********* Service and Interface *********/
#define kURLAnalyticsService @"http://analytics.yhurl.com/" // 数据分析服务器
#define kURLAnalyticsService @"http://analytics.yhurl.com/yas_mobile" // 数据分析服务器
#define kURLAnalyticsService2 @"http://error-report.yoho.cn/ios_report.do" //接口错误上报服务器
#define kYASApiMethodUploadData @"yas_mobile" // 上传监测数据接口
#define kYASApiMethodGetNewStrategy @"" // 获取新发送策略,接口名未定
#if defined TESTENV
... ...