Authored by John Tai

fix crash bug.reviewed by sunkai

... ... @@ -308,8 +308,7 @@
- (void)handleMemoryWarning
{
if (self.mode == YHEventReportStrategyInterval) {
@synchronized (self) {
//[self.eventCacheArray removeAllObjects];
@synchronized (self.performanceCacheArray) {
[self.performanceCacheArray removeAllObjects];
}
}
... ... @@ -317,26 +316,14 @@
- (void)handleDidFinishLaunch
{
if (self.mode == YHEventReportStrategyInterval) {
@synchronized (self.performanceCacheArray) {
NSMutableArray *data = [[NSMutableArray alloc]initWithCapacity:0];
[data setArray:self.performanceCacheArray];
[self.performanceCacheArray removeAllObjects];
[self.eventDataSession uploadPerformanceData:[self getPerformanceFormatData:data type:YHEventReportTrackDataTypeStart] tag:nil result:^(BOOL isSuc, id tag, NSError *error) {
}];
}
[self uploadPerformanceDataWithType:YHEventReportTrackDataTypeStart];
}
}
- (void)handleTerminate
{
if (self.mode == YHEventReportStrategyInterval) {
@synchronized (self.performanceCacheArray) {
NSMutableArray *data = [[NSMutableArray alloc]initWithCapacity:0];
[data setArray:self.performanceCacheArray];
[self.performanceCacheArray removeAllObjects];
[self.eventDataSession uploadPerformanceData:[self getPerformanceFormatData:data type:YHEventReportTrackDataTypeDestory] tag:nil result:^(BOOL isSuc, id tag, NSError *error) {
}];
}
[self uploadPerformanceDataWithType:YHEventReportTrackDataTypeDestory];
}
}
... ... @@ -344,28 +331,27 @@
{
[self.performanceAppInfo resetSessionID];
if (self.mode == YHEventReportStrategyInterval) {
@synchronized (self.performanceCacheArray) {
NSMutableArray *data = [[NSMutableArray alloc]initWithCapacity:0];
[data setArray:self.performanceCacheArray];
[self.performanceCacheArray removeAllObjects];
[self.eventDataSession uploadPerformanceData:[self getPerformanceFormatData:data type:YHEventReportTrackDataTypeStop] tag:nil result:^(BOOL isSuc, id tag, NSError *error) {
}];
}
[self uploadPerformanceDataWithType:YHEventReportTrackDataTypeStop];
}
}
#pragma mark - timer
- (void)timerAction
{
[self uploadPerformanceDataWithType:YHEventReportTrackDataTypeHeartbeat];
}
#pragma mark - upload performance data
-(void)uploadPerformanceDataWithType:(YHEventReportTrackDataType)type{
@synchronized (self.performanceCacheArray) {
[self.eventDataSession uploadPerformanceData:[self getPerformanceFormatData:[self.performanceCacheArray copy] type:type] tag:nil result:^(BOOL isSuc, id tag, NSError *error) {
}];
}
@synchronized (self.performanceCacheArray) {
NSMutableArray *data = [[NSMutableArray alloc]initWithCapacity:0];
[data setArray:self.performanceCacheArray];
[self.performanceCacheArray removeAllObjects];
//if ([data count] > 0) {
[self.eventDataSession uploadPerformanceData:[self getPerformanceFormatData:data type:YHEventReportTrackDataTypeHeartbeat] tag:nil result:^(BOOL isSuc, id tag, NSError *error) {
}];
//}
}
}
@end
... ...
... ... @@ -108,8 +108,11 @@
return nil;
}
NSError *error;
if (![NSJSONSerialization isValidJSONObject:param]) {
return nil;
}
NSError *error;
NSData *postData = [NSJSONSerialization dataWithJSONObject:param options:0 error:&error];
if (error) {
return nil;
... ...
... ... @@ -156,13 +156,8 @@
}
-(NSString *)ts{
long long now = [[NSDate date] timeIntervalSince1970];
long long int date = (long long int)now;
_ts = [NSString stringWithFormat:@"%lld", date];
if (!_ts) {
_ts = @"";
}
return _ts;
long long int date = (long long int)[[NSDate date] timeIntervalSince1970];
return [NSString stringWithFormat:@"%lld", date]?:@"";
}
@end
... ...