Commit 78f3bbd1 authored by 井庆林's avatar 井庆林

埋点库优化

parent b2272108
...@@ -409,8 +409,9 @@ static NewPhobos *_sharedClient; ...@@ -409,8 +409,9 @@ static NewPhobos *_sharedClient;
NSDictionary *dataDict = [_sharedClient prepareDictionaryForEvent:eventName attributes:attributes]; NSDictionary *dataDict = [_sharedClient prepareDictionaryForEvent:eventName attributes:attributes];
@try { @try {
NSData *JSON = [PhobosUtil encodeJSON:dataDict]; NSData *JSON = [PhobosUtil encodeJSON:dataDict];
[PhobosDataManager insertData:dataDict sendAPI:currentAPI]; [PhobosDataManager insertData:dataDict sendAPI:currentAPI completion:^(BOOL contextDidSave, NSError * _Nullable error) {
[self disposeSendDataWithImmediately:sendNow]; [self disposeSendDataWithImmediately:sendNow];
}];
} @catch (NSException *exception) { } @catch (NSException *exception) {
NSAssert(NO, @"哎呀呀,VALUE不能为NSObject "); NSAssert(NO, @"哎呀呀,VALUE不能为NSObject ");
} }
...@@ -425,8 +426,9 @@ static NewPhobos *_sharedClient; ...@@ -425,8 +426,9 @@ static NewPhobos *_sharedClient;
[PhobosDataManager updateDataEntities:entities sendStatus:PhobosDataSendStatusSending]; [PhobosDataManager updateDataEntities:entities sendStatus:PhobosDataSendStatusSending];
[PhobosSendManager sendDataWithEntities:entities completion:^(NSArray<PhobosSendDataEntity *> * _Nonnull finishEntities, NSInteger code) { [PhobosSendManager sendDataWithEntities:entities completion:^(NSArray<PhobosSendDataEntity *> * _Nonnull finishEntities, NSInteger code) {
if (code == 200) { if (code == 200) {
[PhobosDataManager updateDataEntities:finishEntities sendStatus:PhobosDataSendStatusFinish]; [PhobosDataManager updateDataEntities:finishEntities sendStatus:PhobosDataSendStatusFinish completion:^(BOOL contextDidSave, NSError * _Nullable error) {
[PhobosDataManager deleteDataEntities:finishEntities]; [PhobosDataManager deleteDataEntities:finishEntities];
}];
} else { } else {
[PhobosDataManager updateDataEntities:finishEntities sendStatus:PhobosDataSendStatusError]; [PhobosDataManager updateDataEntities:finishEntities sendStatus:PhobosDataSendStatusError];
} }
......
...@@ -115,7 +115,9 @@ static NSManagedObjectContext *Phobos_defaultContext; ...@@ -115,7 +115,9 @@ static NSManagedObjectContext *Phobos_defaultContext;
* 在保存完成后调用的完成块。如果发生错误,块将以“BOOL”和“NSError”实例的形式传递成功状态。总是在主队列上调用。 * 在保存完成后调用的完成块。如果发生错误,块将以“BOOL”和“NSError”实例的形式传递成功状态。总是在主队列上调用。
*/ */
+ (void)saveWithCompletion:(MRSaveCompletionHandler)completion { + (void)saveWithCompletion:(MRSaveCompletionHandler)completion {
[Phobos_defaultContext MR_saveOnlySelfWithCompletion:completion]; dispatch_async(dispatch_get_main_queue(), ^{
[Phobos_defaultContext MR_saveWithOptions:MRSaveSynchronously completion:completion];
});
} }
@end @end
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