Commit 98e8d83e authored by 翟国钧's avatar 翟国钧

修改实时发送埋点之后的缓存数据处理的逻辑,实时发送数据成功之后,不清除缓存数据

parent eb165a7c
......@@ -219,7 +219,7 @@ static NSString *sdkVersion = @"110";
NSArray *array = [[WMCacheService sharedInstance] fetchObjectAtDiskWithkey:PhobosCacheKey];
//超过一定数量的话,统一发送一次
if (array.count > PhobosShardCount) {
[sharedClient sendArray:array];
[sharedClient sendArray:array cleanCacheRightNow:YES];
}
}
......@@ -227,7 +227,8 @@ static NSString *sdkVersion = @"110";
NSDictionary *dict = [sharedClient prepareDictionaryForEvent:eventId attributes:attributes];
if (sendNow) {
NSArray *array = @[dict];
[sharedClient sendArray:array];
// 实时发送的埋点,不能立即清楚缓存
[sharedClient sendArray:array cleanCacheRightNow:NO];
}else{
[sharedClient save:dict];
}
......@@ -364,18 +365,18 @@ static NSString *sdkVersion = @"110";
- (void)fetchDataAndSend{
NSArray *paramsArray = [[WMCacheService sharedInstance] fetchObjectAtDiskWithkey:PhobosCacheKey];
if (paramsArray.count>0) {
[self sendArray:paramsArray];
[self sendArray:paramsArray cleanCacheRightNow:YES];
}
}
/**
* @brief 发送数组
*
* @param array
*
* @since 0.0.1
向Mars发送埋点数据,如果是实时发送的,http请求成功之后,不清楚已有的缓存数据。
针对普通埋点数据,发送成功之后,立即删除本地的缓存。
@author zhaiguojun 16-10-17 in (null)
@param array 参数
@param now 是否立即清楚缓存
*/
- (void)sendArray:(NSArray *)array {
- (void)sendArray:(NSArray *)array cleanCacheRightNow:(BOOL)clean {
if (_logEnabled) {
phobosLog([NSString stringWithFormat:@"array prepare to fly --✈: %@",array]);
}
......@@ -385,7 +386,9 @@ static NSString *sdkVersion = @"110";
if (compressedData) {
[PhobosUtil sendData:compressedData success:^(NSInteger code) {
phobosLog(@"✈ ---------- ✈ data arrived Mars");
[[WMCacheService sharedInstance] removeObjectAtDiskWithkey:PhobosCacheKey];
if (clean) {
[[WMCacheService sharedInstance] removeObjectAtDiskWithkey:PhobosCacheKey];
}
}];
}
}
......@@ -460,5 +463,4 @@ static NSString *sdkVersion = @"110";
}
}
@end
@end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment