Authored by 王钱钧

为performance数据类型添加net字段。 code review by 小熊

... ... @@ -16,7 +16,7 @@
@property (copy, nonatomic) NSString *sid; // 会话id(由设备标识和启动时间戳md5)
@property (copy, nonatomic) NSString *ts; // 时间戳
@property (copy, nonatomic) NSString *type; // 统计类型, IMG_LOAD,API_CALL,WEBVIEW_LOAD
//@property (copy, nonatomic) NSString *index; // 操作顺序
@property (copy, nonatomic) NSString *net; // 网络
@property (copy, nonatomic) NSDictionary *param; // 操作参数
... ...
... ... @@ -26,7 +26,8 @@
JsonKeyPerformanceTS : self.ts ? self.ts : @"",
JsonKeyPerformanceSID : self.sid ? self.sid : @"",
JsonKeyPerformanceTYPE : self.type ? self.type : @"",
JsonKeyPerformancePARAM : self.param ? self.param : @""
JsonKeyPerformancePARAM : self.param ? self.param : @"",
JsonKeyPerformanceEvtNet : self.net ? self.net : @""
// JsonKeyEventINDEX : self.index ? self.index : @""
};
}
... ...
... ... @@ -293,6 +293,8 @@ static dispatch_queue_t persisting_queue() {
} else if (itemData.dataType == YHItemDataTypePerformance) {
YHPerformance *performance = (YHPerformance *)itemData;
performance.net = self.currentStatus.net;
dispatch_async(persisting_queue(), ^{
if ([self writePerformanceToFile:performance]) {
... ... @@ -354,6 +356,20 @@ static dispatch_queue_t persisting_queue() {
}
}];
}
} else if (itemData.dataType == YHItemDataTypePerformance) {
YHPerformance *perfms = (YHPerformance *)itemData;
perfms.net = self.currentStatus.net;
if (perfms) {
[self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:perfms.jsonDictionary, nil] forKey:JsonKeyDataTypePerfor];
[[YHNetworkService sharedInstance] uploadLogData:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) {
if (success) {
YALog(@"upload immedialite event success.");
} else {
YALog(@"uploadImmedilyWithEvent error = %@", error.localizedDescription);
}
}];
}
} else if(itemData.dataType == YHItemDataTypeError) {
YHError *error = (YHError *)itemData;
if (error) {
... ... @@ -604,6 +620,7 @@ static dispatch_queue_t persisting_queue() {
- (BOOL)writePerformanceToFile:(YHPerformance *)performanceData
{
performanceData.net = self.currentStatus.net;
if (performanceData == nil || ![performanceData isKindOfClass:[YHPerformance class]]) {
NSException *exception = [NSException exceptionWithName:NSInvalidArgumentException
reason:@"The input parameter is nil or an unexpected value."
... ...
... ... @@ -124,6 +124,8 @@
#define JsonKeyPerformanceEvt @"evt" //事件类型, begin(开始加载h5页面),end(加载完成)
#define JsonKeyPerformanceEvtBegin @"begin"
#define JsonKeyPerformanceEvtEnd @"end"
#define JsonKeyPerformanceEvtNet @"net"
... ...