Authored by John Tai

Merge branch 'develop' of http://git.yoho.cn/mobile/YH_EventReport into develop

@@ -51,11 +51,9 @@ @@ -51,11 +51,9 @@
51 self.timedEvents = [NSMutableDictionary dictionary]; 51 self.timedEvents = [NSMutableDictionary dictionary];
52 52
53 53
54 - NSArray *tabAry= @[@"YH_CategoryContainerVC",  
55 - @"YH_GuangMainVC", 54 + NSArray *tabAry= @[@"YH_GuangMainVC",
56 @"YH_ShowMainVC", 55 @"YH_ShowMainVC",
57 @"YH_CmtMainVC", 56 @"YH_CmtMainVC",
58 - @"YH_GuangContainerVC",  
59 @"YH_ShoppingCartViewController", 57 @"YH_ShoppingCartViewController",
60 @"UIPageViewController", 58 @"UIPageViewController",
61 @"YH_MyViewController", 59 @"YH_MyViewController",
@@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
11 #import "YH_Reachability.h" 11 #import "YH_Reachability.h"
12 #import "YHLog.h" 12 #import "YHLog.h"
13 #import "NSData+YHERGZip.h" 13 #import "NSData+YHERGZip.h"
  14 +#import "NSString+ER_URL.h"
14 15
15 #define kYOHOEventReportURL @"http://analysis.yohobuy.com/yas_mobile"//@"http://172.16.10.128:8081/eventreport" 16 #define kYOHOEventReportURL @"http://analysis.yohobuy.com/yas_mobile"//@"http://172.16.10.128:8081/eventreport"
16 17
@@ -52,12 +53,13 @@ @@ -52,12 +53,13 @@
52 if (!self.canUpload) { 53 if (!self.canUpload) {
53 return; 54 return;
54 } 55 }
55 - NSData *postData = [self getBodyData:parameters];  
56 - if (!postData) {  
57 - NSError *nullError = [[NSError alloc] initWithDomain:@"YoHoErrorDomain" code:-11111 userInfo:@{NSLocalizedDescriptionKey:@"data 不能为空!"}];  
58 - result(NO,nil,nullError);  
59 - return;  
60 - } 56 +
  57 + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
  58 +
  59 + NSString *parsJsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  60 + NSString *parsStr = [[NSString stringWithFormat:@"_mlogs=%@",erSafeValue(parsJsonStr)]er_encodedString];
  61 + NSData* xmlData = [parsStr dataUsingEncoding:NSUTF8StringEncoding];
  62 + NSData *postData = [xmlData YHERgzippedData];
61 63
62 [self.uploadEventRequest setHTTPBody:postData]; 64 [self.uploadEventRequest setHTTPBody:postData];
63 [self.uploadEventRequest setValue:(@(self.uploadEventRequest.HTTPBody.length)).description forHTTPHeaderField:@"Content-Length"]; 65 [self.uploadEventRequest setValue:(@(self.uploadEventRequest.HTTPBody.length)).description forHTTPHeaderField:@"Content-Length"];
@@ -109,7 +111,6 @@ @@ -109,7 +111,6 @@
109 NSError *error; 111 NSError *error;
110 112
111 NSData *postData = [NSJSONSerialization dataWithJSONObject:param options:0 error:&error]; 113 NSData *postData = [NSJSONSerialization dataWithJSONObject:param options:0 error:&error];
112 -  
113 if (error) { 114 if (error) {
114 return nil; 115 return nil;
115 } 116 }
@@ -131,7 +132,7 @@ @@ -131,7 +132,7 @@
131 if (!_uploadEventRequest) { 132 if (!_uploadEventRequest) {
132 NSURL *url = [NSURL URLWithString:kYOHOEventReportURL]; 133 NSURL *url = [NSURL URLWithString:kYOHOEventReportURL];
133 _uploadEventRequest =[NSMutableURLRequest requestWithURL:url]; 134 _uploadEventRequest =[NSMutableURLRequest requestWithURL:url];
134 - [_uploadEventRequest setValue:@"application/json" forHTTPHeaderField:@"content-type"]; 135 + [_uploadEventRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
135 _uploadEventRequest.HTTPMethod = @"POST"; 136 _uploadEventRequest.HTTPMethod = @"POST";
136 [_uploadEventRequest setValue:@"gzip" forHTTPHeaderField:@"Content-Encoding"]; 137 [_uploadEventRequest setValue:@"gzip" forHTTPHeaderField:@"Content-Encoding"];
137 } 138 }
@@ -172,6 +172,7 @@ typedef NS_ENUM(NSInteger, YHEventLoadStatus) { @@ -172,6 +172,7 @@ typedef NS_ENUM(NSInteger, YHEventLoadStatus) {
172 172
173 #define IOS10 ([[[UIDevice currentDevice] systemVersion] doubleValue] >=10.0 ? YES : NO) 173 #define IOS10 ([[[UIDevice currentDevice] systemVersion] doubleValue] >=10.0 ? YES : NO)
174 174
  175 +#define erSafeValue(X) (!(X) ? [NSNull null] : (X))
175 176
176 177
177 //////////////////////大数据 业务数据上报参数/////////////////////////////// 178 //////////////////////大数据 业务数据上报参数///////////////////////////////
@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 return nil; 36 return nil;
37 } 37 }
38 38
39 - NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[currentUrl er_encodedString],kYHEventReportTimeURL,[NSString stringWithFormat:@"%.0f",elapsedTime*1000],kYHEventReportTimeElapsed,nil]; 39 + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[currentUrl er_encodedString],kYHEventReportTimeURL,[NSString stringWithFormat:@"%.0f",elapsedTime*1000],kYHEventReportTimeElapsed,@"",kYHEventReportTimeTitle,nil];
40 40
41 return dict; 41 return dict;
42 } 42 }
@@ -48,7 +48,7 @@ @@ -48,7 +48,7 @@
48 currentUrl=@""; 48 currentUrl=@"";
49 } 49 }
50 50
51 - NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[currentUrl er_encodedString],kYHEventReportTimeURL,[NSString stringWithFormat:@"%.0f",elapsedTime*1000],kYHEventReportTimeElapsed,nil]; 51 + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[currentUrl er_encodedString],kYHEventReportTimeURL,[NSString stringWithFormat:@"%.0f",elapsedTime*1000],kYHEventReportTimeElapsed,@"",kYHEventReportTimeTitle,nil];
52 52
53 return dict; 53 return dict;
54 } 54 }