Authored by ZhouRongjun

增加错误信息回调给app。Review by 朱小军。

@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 objects = { 7 objects = {
8 8
9 /* Begin PBXBuildFile section */ 9 /* Begin PBXBuildFile section */
  10 + 0928E56C1E8D3824008FD4F3 /* YHPatch.m in Sources */ = {isa = PBXBuildFile; fileRef = 0928E56B1E8D3824008FD4F3 /* YHPatch.m */; };
10 194EDC761A7F52D100421E6C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 194EDC751A7F52D100421E6C /* main.m */; }; 11 194EDC761A7F52D100421E6C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 194EDC751A7F52D100421E6C /* main.m */; };
11 194EDC791A7F52D100421E6C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 194EDC781A7F52D100421E6C /* AppDelegate.m */; }; 12 194EDC791A7F52D100421E6C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 194EDC781A7F52D100421E6C /* AppDelegate.m */; };
12 194EDC7C1A7F52D100421E6C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 194EDC7B1A7F52D100421E6C /* ViewController.m */; }; 13 194EDC7C1A7F52D100421E6C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 194EDC7B1A7F52D100421E6C /* ViewController.m */; };
@@ -101,6 +102,8 @@ @@ -101,6 +102,8 @@
101 /* End PBXCopyFilesBuildPhase section */ 102 /* End PBXCopyFilesBuildPhase section */
102 103
103 /* Begin PBXFileReference section */ 104 /* Begin PBXFileReference section */
  105 + 0928E56A1E8D3824008FD4F3 /* YHPatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YHPatch.h; sourceTree = "<group>"; };
  106 + 0928E56B1E8D3824008FD4F3 /* YHPatch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YHPatch.m; sourceTree = "<group>"; };
104 194EDC701A7F52D100421E6C /* YH_Analytics.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YH_Analytics.app; sourceTree = BUILT_PRODUCTS_DIR; }; 107 194EDC701A7F52D100421E6C /* YH_Analytics.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YH_Analytics.app; sourceTree = BUILT_PRODUCTS_DIR; };
105 194EDC741A7F52D100421E6C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 108 194EDC741A7F52D100421E6C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
106 194EDC751A7F52D100421E6C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; 109 194EDC751A7F52D100421E6C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
@@ -463,18 +466,20 @@ @@ -463,18 +466,20 @@
463 E7ADAE321AB946C100C9DD0B /* Model */ = { 466 E7ADAE321AB946C100C9DD0B /* Model */ = {
464 isa = PBXGroup; 467 isa = PBXGroup;
465 children = ( 468 children = (
  469 + E7ADAE441AB9487A00C9DD0B /* YHAnalyItemData.h */,
  470 + E7ADAE451AB9487A00C9DD0B /* YHAnalyItemData.m */,
466 E7ADAE331AB946C100C9DD0B /* YHDevice.h */, 471 E7ADAE331AB946C100C9DD0B /* YHDevice.h */,
467 E7ADAE341AB946C100C9DD0B /* YHDevice.m */, 472 E7ADAE341AB946C100C9DD0B /* YHDevice.m */,
468 E7ADAE351AB946C100C9DD0B /* YHError.h */, 473 E7ADAE351AB946C100C9DD0B /* YHError.h */,
469 E7ADAE361AB946C100C9DD0B /* YHError.m */, 474 E7ADAE361AB946C100C9DD0B /* YHError.m */,
470 E7ADAE371AB946C100C9DD0B /* YHEvent.h */, 475 E7ADAE371AB946C100C9DD0B /* YHEvent.h */,
471 E7ADAE381AB946C100C9DD0B /* YHEvent.m */, 476 E7ADAE381AB946C100C9DD0B /* YHEvent.m */,
472 - E7ADAE391AB946C100C9DD0B /* YHStatus.h */,  
473 - E7ADAE3A1AB946C100C9DD0B /* YHStatus.m */, 477 + 0928E56A1E8D3824008FD4F3 /* YHPatch.h */,
  478 + 0928E56B1E8D3824008FD4F3 /* YHPatch.m */,
474 E7A908711BB3C4B000E2EA39 /* YHPerformance.h */, 479 E7A908711BB3C4B000E2EA39 /* YHPerformance.h */,
475 E7A908721BB3C4B000E2EA39 /* YHPerformance.m */, 480 E7A908721BB3C4B000E2EA39 /* YHPerformance.m */,
476 - E7ADAE441AB9487A00C9DD0B /* YHAnalyItemData.h */,  
477 - E7ADAE451AB9487A00C9DD0B /* YHAnalyItemData.m */, 481 + E7ADAE391AB946C100C9DD0B /* YHStatus.h */,
  482 + E7ADAE3A1AB946C100C9DD0B /* YHStatus.m */,
478 ); 483 );
479 path = Model; 484 path = Model;
480 sourceTree = "<group>"; 485 sourceTree = "<group>";
@@ -693,6 +698,7 @@ @@ -693,6 +698,7 @@
693 E7A908731BB3C4B000E2EA39 /* YHPerformance.m in Sources */, 698 E7A908731BB3C4B000E2EA39 /* YHPerformance.m in Sources */,
694 E7ADAE3B1AB946C100C9DD0B /* YHDevice.m in Sources */, 699 E7ADAE3B1AB946C100C9DD0B /* YHDevice.m in Sources */,
695 E79828121AA6A5120035137C /* YH_KeychainStore.m in Sources */, 700 E79828121AA6A5120035137C /* YH_KeychainStore.m in Sources */,
  701 + 0928E56C1E8D3824008FD4F3 /* YHPatch.m in Sources */,
696 194EDC761A7F52D100421E6C /* main.m in Sources */, 702 194EDC761A7F52D100421E6C /* main.m in Sources */,
697 E7ADAE5B1AB95BC800C9DD0B /* YHAssemblyAssistant.m in Sources */, 703 E7ADAE5B1AB95BC800C9DD0B /* YHAssemblyAssistant.m in Sources */,
698 E7ADAE3C1AB946C100C9DD0B /* YHError.m in Sources */, 704 E7ADAE3C1AB946C100C9DD0B /* YHError.m in Sources */,
@@ -30,6 +30,10 @@ @@ -30,6 +30,10 @@
30 [[YH_Analytics sharedInstance] startWithAppId:@"appid"]; 30 [[YH_Analytics sharedInstance] startWithAppId:@"appid"];
31 31
32 [[YH_Analytics sharedInstance] setCid:@"test cid"]; 32 [[YH_Analytics sharedInstance] setCid:@"test cid"];
  33 +
  34 + [YH_Analytics sharedInstance].errorBlock = ^(NSDictionary *dict){
  35 + NSLog(@"%@", dict);
  36 + };
33 return YES; 37 return YES;
34 } 38 }
35 39
@@ -6,7 +6,8 @@ @@ -6,7 +6,8 @@
6 // 6 //
7 // 7 //
8 8
9 -#import <YH_Analytics/YH_Analytics.h> 9 +#import <Foundation/Foundation.h>
  10 +#import "YHAnalyItemData.h"
10 11
11 @interface YHPatch : YHAnalyItemData 12 @interface YHPatch : YHAnalyItemData
12 13
@@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
15 @class YHPerformance; 15 @class YHPerformance;
16 @interface YHAssemblyAssistant : NSObject 16 @interface YHAssemblyAssistant : NSObject
17 17
  18 +@property (copy, nonatomic) void(^errorBlock)(NSDictionary *dict);
  19 +
18 + (instancetype)sharedInstance; 20 + (instancetype)sharedInstance;
19 21
20 - (BOOL)canPersisting; 22 - (BOOL)canPersisting;
@@ -439,6 +439,11 @@ static dispatch_queue_t persisting_queue() { @@ -439,6 +439,11 @@ static dispatch_queue_t persisting_queue() {
439 [self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypePatch]; 439 [self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypePatch];
440 [self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:error.jsonDictionary, nil] forKey:JsonKeyDataTypeErrors]; 440 [self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:error.jsonDictionary, nil] forKey:JsonKeyDataTypeErrors];
441 441
  442 + //将错误信息回调给应用
  443 + if (self.errorBlock) {
  444 + self.errorBlock(self.immediUploadItemDic);
  445 + }
  446 +
442 [[YHNetworkService sharedInstance] uploadLogcustomURL:kURLAnalyticsService2 parameters:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) { 447 [[YHNetworkService sharedInstance] uploadLogcustomURL:kURLAnalyticsService2 parameters:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) {
443 if (success) { 448 if (success) {
444 YALog(@"upload immedialite error success."); 449 YALog(@"upload immedialite error success.");
@@ -165,5 +165,9 @@ typedef NS_ENUM(NSInteger, YHLogStrategy) { @@ -165,5 +165,9 @@ typedef NS_ENUM(NSInteger, YHLogStrategy) {
165 是否使用https 165 是否使用https
166 */ 166 */
167 @property (assign, nonatomic, readonly) BOOL httpsEnable; 167 @property (assign, nonatomic, readonly) BOOL httpsEnable;
  168 +/**
  169 + 返回图片和网络错误的信息
  170 + */
  171 +@property (copy, nonatomic) void(^errorBlock)(NSDictionary *dict);
168 172
169 @end 173 @end
@@ -398,4 +398,9 @@ @@ -398,4 +398,9 @@
398 _httpsEnable = enable; 398 _httpsEnable = enable;
399 } 399 }
400 400
  401 +- (void)setErrorBlock:(void (^)(NSDictionary *))errorBlock
  402 +{
  403 + [YHAssemblyAssistant sharedInstance].errorBlock = errorBlock;
  404 +}
  405 +
401 @end 406 @end