Merge branch 'develop' of http://git.yoho.cn/mobile/YH_EventReport into develop
Showing
16 changed files
with
831 additions
and
154 deletions
@@ -18,6 +18,8 @@ | @@ -18,6 +18,8 @@ | ||
18 | 29D3B9761F739D2F00B07F47 /* YH_EventCollector+UIAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 29D3B9751F739D2F00B07F47 /* YH_EventCollector+UIAlertView.m */; }; | 18 | 29D3B9761F739D2F00B07F47 /* YH_EventCollector+UIAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 29D3B9751F739D2F00B07F47 /* YH_EventCollector+UIAlertView.m */; }; |
19 | 29D3B9791F739D8300B07F47 /* YH_EventCollector+PowerfulBannerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 29D3B9781F739D8300B07F47 /* YH_EventCollector+PowerfulBannerView.m */; }; | 19 | 29D3B9791F739D8300B07F47 /* YH_EventCollector+PowerfulBannerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 29D3B9781F739D8300B07F47 /* YH_EventCollector+PowerfulBannerView.m */; }; |
20 | 29D3B97C1F73A81E00B07F47 /* YH_EventCollector+UIActionSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = 29D3B97B1F73A81E00B07F47 /* YH_EventCollector+UIActionSheet.m */; }; | 20 | 29D3B97C1F73A81E00B07F47 /* YH_EventCollector+UIActionSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = 29D3B97B1F73A81E00B07F47 /* YH_EventCollector+UIActionSheet.m */; }; |
21 | + 52540FAD1F8F6BAD001907B3 /* YH_CrashReporter.m in Sources */ = {isa = PBXBuildFile; fileRef = 52540FA91F8F6BAD001907B3 /* YH_CrashReporter.m */; }; | ||
22 | + 52540FAE1F8F6BAD001907B3 /* YH_CrashDataManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 52540FAC1F8F6BAD001907B3 /* YH_CrashDataManager.m */; }; | ||
21 | 29FB39AA1F7C9D67000E3B27 /* UIImageView+GestureAutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = 29FB39A91F7C9D67000E3B27 /* UIImageView+GestureAutoTrack.m */; }; | 23 | 29FB39AA1F7C9D67000E3B27 /* UIImageView+GestureAutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = 29FB39A91F7C9D67000E3B27 /* UIImageView+GestureAutoTrack.m */; }; |
22 | 29FB39AD1F7C9D73000E3B27 /* UILabel+GestureAutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = 29FB39AC1F7C9D73000E3B27 /* UILabel+GestureAutoTrack.m */; }; | 24 | 29FB39AD1F7C9D73000E3B27 /* UILabel+GestureAutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = 29FB39AC1F7C9D73000E3B27 /* UILabel+GestureAutoTrack.m */; }; |
23 | 5255C2B91F5D25F400A8FC5F /* UICollectionView+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = 5255C2A61F5D25F400A8FC5F /* UICollectionView+AutoTrack.m */; }; | 25 | 5255C2B91F5D25F400A8FC5F /* UICollectionView+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = 5255C2A61F5D25F400A8FC5F /* UICollectionView+AutoTrack.m */; }; |
@@ -114,6 +116,10 @@ | @@ -114,6 +116,10 @@ | ||
114 | 29D3B9781F739D8300B07F47 /* YH_EventCollector+PowerfulBannerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "YH_EventCollector+PowerfulBannerView.m"; sourceTree = "<group>"; }; | 116 | 29D3B9781F739D8300B07F47 /* YH_EventCollector+PowerfulBannerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "YH_EventCollector+PowerfulBannerView.m"; sourceTree = "<group>"; }; |
115 | 29D3B97A1F73A81E00B07F47 /* YH_EventCollector+UIActionSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "YH_EventCollector+UIActionSheet.h"; sourceTree = "<group>"; }; | 117 | 29D3B97A1F73A81E00B07F47 /* YH_EventCollector+UIActionSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "YH_EventCollector+UIActionSheet.h"; sourceTree = "<group>"; }; |
116 | 29D3B97B1F73A81E00B07F47 /* YH_EventCollector+UIActionSheet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "YH_EventCollector+UIActionSheet.m"; sourceTree = "<group>"; }; | 118 | 29D3B97B1F73A81E00B07F47 /* YH_EventCollector+UIActionSheet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "YH_EventCollector+UIActionSheet.m"; sourceTree = "<group>"; }; |
119 | + 52540FA91F8F6BAD001907B3 /* YH_CrashReporter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YH_CrashReporter.m; sourceTree = "<group>"; }; | ||
120 | + 52540FAA1F8F6BAD001907B3 /* YH_CrashDataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YH_CrashDataManager.h; sourceTree = "<group>"; }; | ||
121 | + 52540FAB1F8F6BAD001907B3 /* YH_CrashReporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YH_CrashReporter.h; sourceTree = "<group>"; }; | ||
122 | + 52540FAC1F8F6BAD001907B3 /* YH_CrashDataManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YH_CrashDataManager.m; sourceTree = "<group>"; }; | ||
117 | 29FB39A81F7C9D67000E3B27 /* UIImageView+GestureAutoTrack.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImageView+GestureAutoTrack.h"; sourceTree = "<group>"; }; | 123 | 29FB39A81F7C9D67000E3B27 /* UIImageView+GestureAutoTrack.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImageView+GestureAutoTrack.h"; sourceTree = "<group>"; }; |
118 | 29FB39A91F7C9D67000E3B27 /* UIImageView+GestureAutoTrack.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+GestureAutoTrack.m"; sourceTree = "<group>"; }; | 124 | 29FB39A91F7C9D67000E3B27 /* UIImageView+GestureAutoTrack.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+GestureAutoTrack.m"; sourceTree = "<group>"; }; |
119 | 29FB39AB1F7C9D73000E3B27 /* UILabel+GestureAutoTrack.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UILabel+GestureAutoTrack.h"; sourceTree = "<group>"; }; | 125 | 29FB39AB1F7C9D73000E3B27 /* UILabel+GestureAutoTrack.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UILabel+GestureAutoTrack.h"; sourceTree = "<group>"; }; |
@@ -280,12 +286,24 @@ | @@ -280,12 +286,24 @@ | ||
280 | path = PowerfulBannerView; | 286 | path = PowerfulBannerView; |
281 | sourceTree = "<group>"; | 287 | sourceTree = "<group>"; |
282 | }; | 288 | }; |
289 | + 5223D9CE1F8F50FF00EB698F /* YH_CrashReporter */ = { | ||
290 | + isa = PBXGroup; | ||
291 | + children = ( | ||
292 | + 52540FAA1F8F6BAD001907B3 /* YH_CrashDataManager.h */, | ||
293 | + 52540FAC1F8F6BAD001907B3 /* YH_CrashDataManager.m */, | ||
294 | + 52540FAB1F8F6BAD001907B3 /* YH_CrashReporter.h */, | ||
295 | + 52540FA91F8F6BAD001907B3 /* YH_CrashReporter.m */, | ||
296 | + ); | ||
297 | + path = YH_CrashReporter; | ||
298 | + sourceTree = "<group>"; | ||
299 | + }; | ||
283 | 5255C2A31F5D25F400A8FC5F /* YHEventReport */ = { | 300 | 5255C2A31F5D25F400A8FC5F /* YHEventReport */ = { |
284 | isa = PBXGroup; | 301 | isa = PBXGroup; |
285 | children = ( | 302 | children = ( |
286 | 5255C2B71F5D25F400A8FC5F /* YHEventReport.h */, | 303 | 5255C2B71F5D25F400A8FC5F /* YHEventReport.h */, |
287 | 5255C2B81F5D25F400A8FC5F /* YHEventReport.m */, | 304 | 5255C2B81F5D25F400A8FC5F /* YHEventReport.m */, |
288 | 5255C2A41F5D25F400A8FC5F /* YH_AOP */, | 305 | 5255C2A41F5D25F400A8FC5F /* YH_AOP */, |
306 | + 5223D9CE1F8F50FF00EB698F /* YH_CrashReporter */, | ||
289 | 5255C2C21F5D265000A8FC5F /* YH_EventCollector */, | 307 | 5255C2C21F5D265000A8FC5F /* YH_EventCollector */, |
290 | 5255C2AB1F5D25F400A8FC5F /* YH_EventCache */, | 308 | 5255C2AB1F5D25F400A8FC5F /* YH_EventCache */, |
291 | 5255C2B21F5D25F400A8FC5F /* YH_EventDataSession */, | 309 | 5255C2B21F5D25F400A8FC5F /* YH_EventDataSession */, |
@@ -717,6 +735,7 @@ | @@ -717,6 +735,7 @@ | ||
717 | B1D774AE1F62A37E00BA89C3 /* UIImageView+HighlightedWebCache.m in Sources */, | 735 | B1D774AE1F62A37E00BA89C3 /* UIImageView+HighlightedWebCache.m in Sources */, |
718 | B14C0C991F8E2E9B00D963F3 /* UITapGestureRecognizer+AutoTrack.m in Sources */, | 736 | B14C0C991F8E2E9B00D963F3 /* UITapGestureRecognizer+AutoTrack.m in Sources */, |
719 | B1D774A91F62A37E00BA89C3 /* SDWebImagePrefetcher.m in Sources */, | 737 | B1D774A91F62A37E00BA89C3 /* SDWebImagePrefetcher.m in Sources */, |
738 | + 52540FAD1F8F6BAD001907B3 /* YH_CrashReporter.m in Sources */, | ||
720 | 29FB39AA1F7C9D67000E3B27 /* UIImageView+GestureAutoTrack.m in Sources */, | 739 | 29FB39AA1F7C9D67000E3B27 /* UIImageView+GestureAutoTrack.m in Sources */, |
721 | 29D3B9791F739D8300B07F47 /* YH_EventCollector+PowerfulBannerView.m in Sources */, | 740 | 29D3B9791F739D8300B07F47 /* YH_EventCollector+PowerfulBannerView.m in Sources */, |
722 | B1D774A71F62A37E00BA89C3 /* SDWebImageDownloaderOperation.m in Sources */, | 741 | B1D774A71F62A37E00BA89C3 /* SDWebImageDownloaderOperation.m in Sources */, |
@@ -742,6 +761,7 @@ | @@ -742,6 +761,7 @@ | ||
742 | B1D774AF1F62A37E00BA89C3 /* UIImageView+WebCache.m in Sources */, | 761 | B1D774AF1F62A37E00BA89C3 /* UIImageView+WebCache.m in Sources */, |
743 | B1D774A81F62A37E00BA89C3 /* SDWebImageManager.m in Sources */, | 762 | B1D774A81F62A37E00BA89C3 /* SDWebImageManager.m in Sources */, |
744 | B13B6C0C1F710BA600C18812 /* UITabBarItem+Yoho.m in Sources */, | 763 | B13B6C0C1F710BA600C18812 /* UITabBarItem+Yoho.m in Sources */, |
764 | + 52540FAE1F8F6BAD001907B3 /* YH_CrashDataManager.m in Sources */, | ||
745 | B1D774A21F62A37E00BA89C3 /* SDImageCache.m in Sources */, | 765 | B1D774A21F62A37E00BA89C3 /* SDImageCache.m in Sources */, |
746 | B1C418CD1F5FFBAA005E0729 /* YH_PerformanceAppInfo.m in Sources */, | 766 | B1C418CD1F5FFBAA005E0729 /* YH_PerformanceAppInfo.m in Sources */, |
747 | 5255C2BC1F5D25F400A8FC5F /* YH_EventCacheFile.m in Sources */, | 767 | 5255C2BC1F5D25F400A8FC5F /* YH_EventCacheFile.m in Sources */, |
@@ -14,27 +14,39 @@ | @@ -14,27 +14,39 @@ | ||
14 | 14 | ||
15 | 15 | ||
16 | /** | 16 | /** |
17 | - * @property | ||
18 | - * | ||
19 | * @abstract | 17 | * @abstract |
20 | - * 两次数据发送的时间间隔,单位毫秒 | 18 | + * 返回初始化好的单例 |
21 | * | 19 | * |
22 | - * @discussion | ||
23 | - * 默认值为 10 * 1000 毫秒. | 20 | + * @return 返回的单例 |
24 | */ | 21 | */ |
25 | -@property (atomic) UInt64 flushInterval; | 22 | ++ (YHEventReport *)sharedInstance; |
23 | + | ||
24 | + | ||
25 | +-(void)setup; | ||
26 | 26 | ||
27 | 27 | ||
28 | /** | 28 | /** |
29 | - * @property | 29 | + * @abstract |
30 | + * 开启点击事件上报 | ||
30 | * | 31 | * |
32 | + */ | ||
33 | +-(void)startClickEventTrack; | ||
34 | + | ||
35 | + | ||
36 | +/** | ||
31 | * @abstract | 37 | * @abstract |
32 | - * 本地缓存的最大事件数目,当累积日志量达到阈值时发送数据 | 38 | + * 开启性能数据上报 |
33 | * | 39 | * |
34 | - * @discussion | ||
35 | - * 默认值为 10. | ||
36 | */ | 40 | */ |
37 | -@property (atomic) UInt64 flushBulkSize; | 41 | +-(void)startPerformanceTrack; |
42 | + | ||
43 | + | ||
44 | +#pragma mark - 开关 | ||
45 | +/** | ||
46 | + * 上报埋点ID和参数 | ||
47 | + */ | ||
48 | +- (void)reportWithPointType:(YHPointType)type pointName:(YHEventReportPointName)name parameters:(NSDictionary *)param; | ||
49 | + | ||
38 | 50 | ||
39 | 51 | ||
40 | /** | 52 | /** |
@@ -82,59 +94,84 @@ | @@ -82,59 +94,84 @@ | ||
82 | @property (atomic,getter=isHttpPerformanceTrackEnable) BOOL httpPerformanceTrackEnable; | 94 | @property (atomic,getter=isHttpPerformanceTrackEnable) BOOL httpPerformanceTrackEnable; |
83 | 95 | ||
84 | 96 | ||
97 | + | ||
85 | /** | 98 | /** |
99 | + * @property | ||
100 | + * | ||
86 | * @abstract | 101 | * @abstract |
87 | - * 设置本地缓存最大空间 | 102 | + * 是否开启app埋点数据上报 |
88 | * | 103 | * |
89 | * @discussion | 104 | * @discussion |
90 | - * 默认为 50 * 1024 * 1024 | ||
91 | - * | ||
92 | - * @param maxCacheSize 本地缓存最大容量空间 | 105 | + * 默认值为 关. |
93 | */ | 106 | */ |
94 | -- (void)setMaxCacheSize:(UInt64)maxCacheSize; | ||
95 | - | 107 | +@property (atomic,getter=isAppReportEnable) BOOL appReportEnable; |
96 | 108 | ||
97 | /** | 109 | /** |
110 | + * @property | ||
111 | + * | ||
98 | * @abstract | 112 | * @abstract |
99 | - * 设置网络发送策略 | 113 | + * 是否开启app crash数据上报 |
100 | * | 114 | * |
101 | * @discussion | 115 | * @discussion |
102 | - * 默认联网状态下都会尝试上传 | ||
103 | - * | ||
104 | - * @param networkType YHEventReportNetworkType | 116 | + * 默认值为 关. |
105 | */ | 117 | */ |
106 | -- (void)setUploadNetworkPolicy:(YHEventReportNetworkType)networkType; | 118 | +@property (atomic,getter=isAppCrashReportEnable) BOOL appCrashReportEnable; |
107 | 119 | ||
120 | +#pragma mark - 配置 | ||
108 | /** | 121 | /** |
122 | + * @property | ||
123 | + * | ||
109 | * @abstract | 124 | * @abstract |
110 | - * 设置上传的时间间隔 | 125 | + * 两次数据发送的时间间隔,单位毫秒 |
111 | * | 126 | * |
127 | + * @discussion | ||
128 | + * 默认值为 10 * 1000 毫秒. | ||
112 | */ | 129 | */ |
113 | -- (void)setUploadInterval:(NSTimeInterval)timeInterval; | 130 | +@property (atomic) UInt64 flushInterval; |
131 | + | ||
114 | 132 | ||
115 | /** | 133 | /** |
134 | + * @property | ||
135 | + * | ||
116 | * @abstract | 136 | * @abstract |
117 | - * 返回初始化好的单例 | 137 | + * 本地缓存的最大事件数目,当累积日志量达到阈值时发送数据 |
118 | * | 138 | * |
119 | - * @return 返回的单例 | 139 | + * @discussion |
140 | + * 默认值为 10. | ||
120 | */ | 141 | */ |
121 | -+ (YHEventReport *)sharedInstance; | 142 | +@property (atomic) UInt64 flushBulkSize; |
122 | 143 | ||
123 | 144 | ||
124 | /** | 145 | /** |
125 | * @abstract | 146 | * @abstract |
126 | - * 开启点击事件上报 | 147 | + * 设置本地缓存最大空间 |
127 | * | 148 | * |
149 | + * @discussion | ||
150 | + * 默认为 50 * 1024 * 1024 | ||
151 | + * | ||
152 | + * @param maxCacheSize 本地缓存最大容量空间 | ||
128 | */ | 153 | */ |
129 | --(void)startClickEventTrack; | 154 | +- (void)setMaxCacheSize:(UInt64)maxCacheSize; |
130 | 155 | ||
131 | 156 | ||
132 | /** | 157 | /** |
133 | * @abstract | 158 | * @abstract |
134 | - * 开启性能数据上报 | 159 | + * 设置网络发送策略 |
135 | * | 160 | * |
161 | + * @discussion | ||
162 | + * 默认联网状态下都会尝试上传 | ||
163 | + * | ||
164 | + * @param networkType YHEventReportNetworkType | ||
136 | */ | 165 | */ |
137 | --(void)startPerformanceTrack; | 166 | +- (void)setUploadNetworkPolicy:(YHEventReportNetworkType)networkType; |
167 | + | ||
168 | +/** | ||
169 | + * @abstract | ||
170 | + * 设置上传的时间间隔 | ||
171 | + * | ||
172 | + */ | ||
173 | +- (void)setUploadInterval:(NSTimeInterval)timeInterval; | ||
174 | + | ||
138 | 175 | ||
139 | /** | 176 | /** |
140 | * @abstract | 177 | * @abstract |
@@ -168,6 +205,29 @@ | @@ -168,6 +205,29 @@ | ||
168 | 205 | ||
169 | /** | 206 | /** |
170 | * @abstract | 207 | * @abstract |
208 | + * 是否开启debug模式,默认关闭 | ||
209 | + * | ||
210 | + */ | ||
211 | +-(void)setDebugMode:(BOOL)debugMode; | ||
212 | + | ||
213 | +/** | ||
214 | + * @abstract | ||
215 | + * 获取用户的UD | ||
216 | + * @return 用户id | ||
217 | + */ | ||
218 | +- (NSString *)uid; | ||
219 | + | ||
220 | +/** | ||
221 | + * @abstract | ||
222 | + * 获取渠道号 | ||
223 | + * @return 渠道号 | ||
224 | + */ | ||
225 | +- (NSString *)channelId; | ||
226 | + | ||
227 | + | ||
228 | +#pragma mark - Getter | ||
229 | +/** | ||
230 | + * @abstract | ||
171 | * 是否忽略该类View的track | 231 | * 是否忽略该类View的track |
172 | * | 232 | * |
173 | */ | 233 | */ |
@@ -214,26 +274,5 @@ | @@ -214,26 +274,5 @@ | ||
214 | - (BOOL)isPerformanceTrackEnabled; | 274 | - (BOOL)isPerformanceTrackEnabled; |
215 | 275 | ||
216 | 276 | ||
217 | -/** | ||
218 | - * @abstract | ||
219 | - * 获取用户的UD | ||
220 | - * @return 用户id | ||
221 | - */ | ||
222 | -- (NSString *)uid; | ||
223 | - | ||
224 | -/** | ||
225 | - * @abstract | ||
226 | - * 获取渠道号 | ||
227 | - * @return 渠道号 | ||
228 | - */ | ||
229 | -- (NSString *)channelId; | ||
230 | - | ||
231 | - | ||
232 | -/** | ||
233 | - * @abstract | ||
234 | - * 是否开启debug模式,默认关闭 | ||
235 | - * | ||
236 | - */ | ||
237 | --(void)setDebugMode:(BOOL)debugMode; | ||
238 | 277 | ||
239 | @end | 278 | @end |
@@ -22,6 +22,10 @@ | @@ -22,6 +22,10 @@ | ||
22 | #import "UIControl+AutoTrack.h" | 22 | #import "UIControl+AutoTrack.h" |
23 | #import "UITapGestureRecognizer+AutoTrack.h" | 23 | #import "UITapGestureRecognizer+AutoTrack.h" |
24 | #import "NSURLConnection+AutoTrack.h" | 24 | #import "NSURLConnection+AutoTrack.h" |
25 | +#import "YH_EventCacheManager.h" | ||
26 | +#import "YH_CrashDataManager.h" | ||
27 | +#import "YH_EventDataFactory.h" | ||
28 | +#import "YH_CrashReporter.h" | ||
25 | 29 | ||
26 | #define kYHEventReportIgnoredViewController @"YHEventReportQueue" | 30 | #define kYHEventReportIgnoredViewController @"YHEventReportQueue" |
27 | 31 | ||
@@ -35,6 +39,7 @@ | @@ -35,6 +39,7 @@ | ||
35 | @property(nonatomic,strong)NSArray *ignorePerformanceViewControllerArray; | 39 | @property(nonatomic,strong)NSArray *ignorePerformanceViewControllerArray; |
36 | @property(nonatomic,strong)NSArray *ignoreClickViewControllerArray; | 40 | @property(nonatomic,strong)NSArray *ignoreClickViewControllerArray; |
37 | 41 | ||
42 | +@property (nonatomic,strong)YH_CrashDataManager *crashDataMgr; | ||
38 | 43 | ||
39 | @end | 44 | @end |
40 | 45 | ||
@@ -103,6 +108,13 @@ static NSArray *kYHEventReportIgnoredViewControllerArray; | @@ -103,6 +108,13 @@ static NSArray *kYHEventReportIgnoredViewControllerArray; | ||
103 | return self; | 108 | return self; |
104 | } | 109 | } |
105 | 110 | ||
111 | +-(void)setup{ | ||
112 | + if (self.isAppReportEnable && self.isAppCrashReportEnable) { | ||
113 | + [self uploadLocalErrorData]; | ||
114 | + [YH_CrashReporter sharedInstance]; | ||
115 | + } | ||
116 | +} | ||
117 | + | ||
106 | - (void)dealloc | 118 | - (void)dealloc |
107 | { | 119 | { |
108 | [[NSNotificationCenter defaultCenter] removeObserver:self]; | 120 | [[NSNotificationCenter defaultCenter] removeObserver:self]; |
@@ -142,7 +154,6 @@ static NSArray *kYHEventReportIgnoredViewControllerArray; | @@ -142,7 +154,6 @@ static NSArray *kYHEventReportIgnoredViewControllerArray; | ||
142 | /** | 154 | /** |
143 | * @abstract | 155 | * @abstract |
144 | * 开启性能数据上报 | 156 | * 开启性能数据上报 |
145 | - * | ||
146 | */ | 157 | */ |
147 | -(void)startPerformanceTrack{ | 158 | -(void)startPerformanceTrack{ |
148 | self.performanceTrackEnabled = YES; | 159 | self.performanceTrackEnabled = YES; |
@@ -150,11 +161,68 @@ static NSArray *kYHEventReportIgnoredViewControllerArray; | @@ -150,11 +161,68 @@ static NSArray *kYHEventReportIgnoredViewControllerArray; | ||
150 | [UITabBar startTrack]; | 161 | [UITabBar startTrack]; |
151 | [UIControl startTrack]; | 162 | [UIControl startTrack]; |
152 | [UITapGestureRecognizer startTrack]; | 163 | [UITapGestureRecognizer startTrack]; |
153 | - [NSURLConnection startTrack]; | 164 | + //[NSURLConnection startTrack]; |
154 | 165 | ||
155 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ | 166 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
156 | [UIWebView startTrack]; | 167 | [UIWebView startTrack]; |
157 | - //[SDWebImageManager startTrack]; | 168 | + [SDWebImageManager startTrack]; |
169 | + }); | ||
170 | +} | ||
171 | + | ||
172 | +- (void)reportWithPointType:(YHPointType)type pointName:(YHEventReportPointName)name parameters:(NSDictionary *)param{ | ||
173 | + //如果是exception类型,先保存,待下次启动后,上传;其他事件,则直接上传. | ||
174 | + if (!self.isAppReportEnable) { | ||
175 | + return; | ||
176 | + } | ||
177 | + | ||
178 | + if (type == YHPT_EXCEPTION) { | ||
179 | + if (!self.isAppCrashReportEnable) { | ||
180 | + return; | ||
181 | + } | ||
182 | + | ||
183 | + NSMutableDictionary *postMDict = [NSMutableDictionary dictionary]; | ||
184 | + [postMDict setObject:[YH_EventDataFactory getPointType:type] forKey:YOHOAppReportKeyPT]; | ||
185 | + [postMDict setObject:[YH_EventDataFactory getPointName:name] forKey:YOHOAppReportKeyPN]; | ||
186 | + [postMDict setObject:param forKey:YOHOAppReportKeyPARAM]; | ||
187 | + | ||
188 | + if (![self.crashDataMgr saveData:postMDict]) { | ||
189 | + YHLog(@"save error data to file failed."); | ||
190 | + } | ||
191 | + }else{ | ||
192 | + [[YH_EventCacheManager sharedInstance] pushCustomData:IsNilOrNull(param)?@{}:param pointType:type pointName:name]; | ||
193 | + } | ||
194 | +} | ||
195 | + | ||
196 | +#pragma mark - Exception handle methods | ||
197 | +// 发送本地存储的Exception数据 | ||
198 | +- (void)uploadLocalErrorData | ||
199 | +{ | ||
200 | + @synchronized(self){ | ||
201 | + NSArray *errorDataArray = [self.crashDataMgr getLocalErrorData]; | ||
202 | + if (!IsNilOrNull(errorDataArray)) { | ||
203 | + [self postErrorWithParametersArray:errorDataArray]; | ||
204 | + } | ||
205 | + } | ||
206 | +} | ||
207 | + | ||
208 | +- (void)postErrorWithParametersArray:(NSArray *)parametersArray | ||
209 | +{ | ||
210 | + if (IsArrEmpty(parametersArray)) { | ||
211 | + return; | ||
212 | + } | ||
213 | + | ||
214 | + WS(weakSelf); | ||
215 | + dispatch_async(dispatch_get_global_queue(0, 0), ^{ | ||
216 | + for (NSDictionary *param in parametersArray) { | ||
217 | + if (IsDictionaryClass(param)) { | ||
218 | + return; | ||
219 | + } | ||
220 | + [[YH_EventCacheManager sharedInstance] pushCrashData:param]; | ||
221 | + } | ||
222 | + dispatch_async(dispatch_get_main_queue(), ^{ | ||
223 | + [weakSelf.crashDataMgr removeLocalFile]; | ||
224 | + }); | ||
225 | + | ||
158 | }); | 226 | }); |
159 | } | 227 | } |
160 | 228 |
@@ -42,7 +42,7 @@ static const void *yher_actionHandlerBlock = &yher_actionHandlerBlock; | @@ -42,7 +42,7 @@ static const void *yher_actionHandlerBlock = &yher_actionHandlerBlock; | ||
42 | return objc_getAssociatedObject(self, @selector(yh_webImageId)); | 42 | return objc_getAssociatedObject(self, @selector(yh_webImageId)); |
43 | } | 43 | } |
44 | 44 | ||
45 | -+(void)load | 45 | ++(void)startTrack |
46 | { | 46 | { |
47 | static dispatch_once_t onceToken; | 47 | static dispatch_once_t onceToken; |
48 | dispatch_once(&onceToken, ^{ | 48 | dispatch_once(&onceToken, ^{ |
1 | +// | ||
2 | +// YH_CrashDataManager.h | ||
3 | +// YH_Mall | ||
4 | +// | ||
5 | +// Created by John Tai on 12/8/2017. | ||
6 | +// Copyright © 2017 YOHO. All rights reserved. | ||
7 | +// | ||
8 | + | ||
9 | +#import <Foundation/Foundation.h> | ||
10 | + | ||
11 | +@interface YH_CrashDataManager : NSObject | ||
12 | + | ||
13 | +//获取本地存储的Exception数据 | ||
14 | +-(NSArray *)getLocalErrorData; | ||
15 | + | ||
16 | +//将错误信息持久化到本地 | ||
17 | +-(BOOL)saveData:(NSDictionary*)data; | ||
18 | + | ||
19 | +// 删除本地持久化文件 | ||
20 | +- (void)removeLocalFile; | ||
21 | + | ||
22 | +@end |
1 | +// | ||
2 | +// YH_CrashDataManager.m | ||
3 | +// YH_Mall | ||
4 | +// | ||
5 | +// Created by John Tai on 12/8/2017. | ||
6 | +// Copyright © 2017 YOHO. All rights reserved. | ||
7 | +// | ||
8 | + | ||
9 | +#import "YH_CrashDataManager.h" | ||
10 | +#import "YHEventReportMacros.h" | ||
11 | + | ||
12 | +@interface YH_CrashDataManager() | ||
13 | + | ||
14 | +/** | ||
15 | + * 日志文件存储路径 | ||
16 | + */ | ||
17 | +@property (strong, nonatomic) NSString *eventFilePath; | ||
18 | +/** | ||
19 | + * 日志文件名称 | ||
20 | + */ | ||
21 | +@property (strong, nonatomic) NSString *eventFileName; | ||
22 | +/** | ||
23 | + * 文件管理服务 | ||
24 | + */ | ||
25 | +@property (strong, nonatomic) NSFileManager *fileManager; | ||
26 | + | ||
27 | +@end | ||
28 | + | ||
29 | +@implementation YH_CrashDataManager | ||
30 | +-(instancetype)init{ | ||
31 | + self = [super init]; | ||
32 | + if (self) { | ||
33 | + | ||
34 | + } | ||
35 | + return self; | ||
36 | +} | ||
37 | + | ||
38 | +//保存错误信息 | ||
39 | +-(BOOL)saveData:(NSDictionary*)data{ | ||
40 | + if (![self canPersisting] ||!data) { | ||
41 | + return FALSE; | ||
42 | + } | ||
43 | + | ||
44 | + NSMutableArray *localErrorDataArray = [NSMutableArray arrayWithArray:[self getLocalErrorData]]; | ||
45 | + [localErrorDataArray addObject:data]; | ||
46 | + | ||
47 | + return [localErrorDataArray writeToFile:self.eventFileName atomically:YES]; | ||
48 | +} | ||
49 | + | ||
50 | +- (BOOL)canPersisting | ||
51 | +{ | ||
52 | + if (![self.fileManager fileExistsAtPath:self.eventFilePath]) { | ||
53 | + return [self.fileManager createDirectoryAtPath:self.eventFilePath withIntermediateDirectories:YES attributes:nil error:nil]; | ||
54 | + } | ||
55 | + | ||
56 | + return YES; | ||
57 | +} | ||
58 | + | ||
59 | +//获取本地存储的Exception数据 | ||
60 | +-(NSArray *)getLocalErrorData{ | ||
61 | + return [NSArray arrayWithContentsOfFile:self.eventFileName]; | ||
62 | +} | ||
63 | + | ||
64 | + | ||
65 | +// 删除本地持久化文件 | ||
66 | +- (void)removeLocalFile | ||
67 | +{ | ||
68 | + if ([self.fileManager fileExistsAtPath:self.eventFileName]) { | ||
69 | + NSError *error; | ||
70 | + if ([self.fileManager removeItemAtPath:self.eventFileName error:&error]) { | ||
71 | + NSLog(@"成功删除本地日志文件。"); | ||
72 | + } else { | ||
73 | + NSLog(@"删除本地日志文件失败:%@", error.localizedDescription); | ||
74 | + } | ||
75 | + } | ||
76 | +} | ||
77 | + | ||
78 | + | ||
79 | +#pragma mark - Getters | ||
80 | +- (NSFileManager *)fileManager | ||
81 | +{ | ||
82 | + if (!_fileManager) { | ||
83 | + _fileManager = [NSFileManager defaultManager]; | ||
84 | + } | ||
85 | + return _fileManager; | ||
86 | +} | ||
87 | + | ||
88 | +- (NSString *)eventFilePath | ||
89 | +{ | ||
90 | + if (!_eventFilePath || [_eventFilePath isEqualToString:@""]) { | ||
91 | + _eventFilePath = YOHOPathLogSystem; | ||
92 | + } | ||
93 | + return _eventFilePath; | ||
94 | + | ||
95 | +} | ||
96 | + | ||
97 | +- (NSString *)eventFileName | ||
98 | +{ | ||
99 | + if (!_eventFileName || [_eventFileName isEqualToString:@""]) { | ||
100 | + _eventFileName = [self.eventFilePath stringByAppendingPathComponent:YOHOAppReportLogSystemName]; | ||
101 | + } | ||
102 | + return _eventFileName; | ||
103 | +} | ||
104 | +@end |
1 | +// | ||
2 | +// YH_CrashReporter.h | ||
3 | +// YH_Mall | ||
4 | +// | ||
5 | +// Created by John Tai on 11/8/2017. | ||
6 | +// Copyright © 2017 YOHO. All rights reserved. | ||
7 | +// | ||
8 | + | ||
9 | +#import <Foundation/Foundation.h> | ||
10 | + | ||
11 | +@interface YH_CrashReporter : NSObject | ||
12 | + | ||
13 | ++ (YH_CrashReporter *)sharedInstance; | ||
14 | + | ||
15 | +- (NSString *)callstackString; | ||
16 | + | ||
17 | +- (void)handleSignal:(NSDictionary *)userInfo; | ||
18 | + | ||
19 | +- (void)handleNSException:(NSDictionary *)userInfo; | ||
20 | + | ||
21 | +-(NSString *)getStringFromArray:(NSArray *)array; | ||
22 | + | ||
23 | +@end |
1 | +// | ||
2 | +// YH_CrashReporter.m | ||
3 | +// YH_Mall | ||
4 | +// | ||
5 | +// Created by John Tai on 11/8/2017. | ||
6 | +// Copyright © 2017 YOHO. All rights reserved. | ||
7 | +// | ||
8 | + | ||
9 | +#import "YH_CrashReporter.h" | ||
10 | +//#import "YHError.h" | ||
11 | +#include <signal.h> | ||
12 | +#include <execinfo.h> | ||
13 | +#import "YHEventReportMacros.h" | ||
14 | +#import "YHLog.h" | ||
15 | +#import "YHEventReport.h" | ||
16 | + | ||
17 | +#pragma mark - C Fuctions | ||
18 | + | ||
19 | +void yh_sighandler(int signal) | ||
20 | +{ | ||
21 | + const char* names[NSIG]; | ||
22 | + names[SIGABRT] = "SIGABRT"; | ||
23 | + names[SIGBUS] = "SIGBUS"; | ||
24 | + names[SIGFPE] = "SIGFPE"; | ||
25 | + names[SIGILL] = "SIGILL"; | ||
26 | + names[SIGPIPE] = "SIGPIPE"; | ||
27 | + names[SIGSEGV] = "SIGSEGV"; | ||
28 | + | ||
29 | + YH_CrashReporter *crash = [[YH_CrashReporter alloc] init]; | ||
30 | + | ||
31 | + NSString *str = [crash callstackString]; | ||
32 | + NSDictionary *userInfo = @{ | ||
33 | + YOHOAppReportCrashCallstack : str, | ||
34 | + YOHOAppReportCrashSignal : @(signal), | ||
35 | + YOHOAppReportCrashSignalName : [NSString stringWithUTF8String:names[signal]], | ||
36 | + }; | ||
37 | + [crash performSelectorOnMainThread:@selector(handleSignal:) withObject:userInfo waitUntilDone:YES]; | ||
38 | +} | ||
39 | + | ||
40 | +void yh_uncaughtCrashExceptionHandler(NSException *exception) | ||
41 | +{ | ||
42 | + YH_CrashReporter *crash = [[YH_CrashReporter alloc] init]; | ||
43 | + | ||
44 | + NSArray *arr = [exception callStackSymbols]; | ||
45 | + NSString *str = [crash getStringFromArray:arr]; | ||
46 | + NSDictionary *userInfo = @{ | ||
47 | + YOHOAppReportCrashCallstack : str, | ||
48 | + YOHOAppReportCrashExceptionName : exception.name, | ||
49 | + YOHOAppReportCrashExceptionReason : exception.reason, | ||
50 | + }; | ||
51 | + [crash performSelectorOnMainThread:@selector(handleNSException:) withObject:userInfo waitUntilDone:YES]; | ||
52 | +} | ||
53 | + | ||
54 | +@implementation YH_CrashReporter | ||
55 | + | ||
56 | ++ (YH_CrashReporter *)sharedInstance | ||
57 | +{ | ||
58 | + static YH_CrashReporter *sharedInstance = nil; | ||
59 | + | ||
60 | + static dispatch_once_t onceToken; | ||
61 | + dispatch_once(&onceToken, ^{ | ||
62 | + sharedInstance = [[YH_CrashReporter alloc] init]; | ||
63 | + }); | ||
64 | + return sharedInstance; | ||
65 | +} | ||
66 | + | ||
67 | +#pragma mark - Lifetime methods | ||
68 | + | ||
69 | +- (id)init | ||
70 | +{ | ||
71 | + self = [super init]; | ||
72 | + if (self) { | ||
73 | + signal(SIGABRT, yh_sighandler); | ||
74 | + signal(SIGBUS, yh_sighandler); | ||
75 | + signal(SIGFPE, yh_sighandler); | ||
76 | + signal(SIGILL, yh_sighandler); | ||
77 | + signal(SIGPIPE, yh_sighandler); | ||
78 | + signal(SIGSEGV, yh_sighandler); | ||
79 | + | ||
80 | + NSSetUncaughtExceptionHandler(&yh_uncaughtCrashExceptionHandler); | ||
81 | + } | ||
82 | + | ||
83 | + return self; | ||
84 | +} | ||
85 | + | ||
86 | +#pragma mark - methods | ||
87 | + | ||
88 | +- (NSString *)callstackString | ||
89 | +{ | ||
90 | + void *callstack[128]; | ||
91 | + const int numFrams = backtrace(callstack, 128); | ||
92 | + char **symbols = backtrace_symbols(callstack, numFrams); | ||
93 | + | ||
94 | + NSString *callStackString = @""; | ||
95 | + for (int i = 0; i < numFrams; i++) { | ||
96 | + NSString *symbolStr = [NSString stringWithUTF8String:symbols[i]]; | ||
97 | + callStackString = [callStackString stringByAppendingString:symbolStr]; | ||
98 | + callStackString = [callStackString stringByAppendingString:@" \n"]; | ||
99 | + } | ||
100 | + | ||
101 | + free(symbols); | ||
102 | + | ||
103 | + return callStackString; | ||
104 | +} | ||
105 | + | ||
106 | +- (void)handleSignal:(NSDictionary*)userInfo | ||
107 | +{ | ||
108 | + YHLog(@"crash============:\n%@", userInfo); | ||
109 | + if (!userInfo || ![userInfo isKindOfClass:[NSDictionary class]]) { | ||
110 | + return; | ||
111 | + } | ||
112 | + | ||
113 | + [[YHEventReport sharedInstance] reportWithPointType:YHPT_EXCEPTION pointName:YHPN_CRASH parameters:userInfo]; | ||
114 | + | ||
115 | + [self killApp]; | ||
116 | +} | ||
117 | + | ||
118 | +- (void)handleNSException:(NSDictionary*)userInfo | ||
119 | +{ | ||
120 | + YHLog(@"crash============:\n%@", userInfo); | ||
121 | + if (!userInfo || ![userInfo isKindOfClass:[NSDictionary class]]) { | ||
122 | + return; | ||
123 | + } | ||
124 | + | ||
125 | + [[YHEventReport sharedInstance] reportWithPointType:YHPT_EXCEPTION pointName:YHPN_CRASH parameters:userInfo]; | ||
126 | + | ||
127 | + [self killApp]; | ||
128 | +} | ||
129 | + | ||
130 | +- (void)killApp | ||
131 | +{ | ||
132 | + NSSetUncaughtExceptionHandler(NULL); | ||
133 | + | ||
134 | + signal(SIGABRT, SIG_DFL); | ||
135 | + signal(SIGILL, SIG_DFL); | ||
136 | + signal(SIGSEGV, SIG_DFL); | ||
137 | + signal(SIGFPE, SIG_DFL); | ||
138 | + signal(SIGBUS, SIG_DFL); | ||
139 | + signal(SIGPIPE, SIG_DFL); | ||
140 | + | ||
141 | + kill(getpid(), SIGKILL); | ||
142 | + | ||
143 | +} | ||
144 | + | ||
145 | +#pragma mark - tools | ||
146 | +-(NSString *)getStringFromArray:(NSArray *)array{ | ||
147 | + NSString * result = @""; | ||
148 | + if (!array) { | ||
149 | + return result; | ||
150 | + } | ||
151 | + | ||
152 | + result = [[array valueForKey:@"description"] componentsJoinedByString:@""]; | ||
153 | + return result; | ||
154 | +} | ||
155 | + | ||
156 | + | ||
157 | +@end |
@@ -34,6 +34,19 @@ | @@ -34,6 +34,19 @@ | ||
34 | */ | 34 | */ |
35 | - (void)pushPerformanceData:(NSDictionary*)data pointName:(YHEventReportPointName)name; | 35 | - (void)pushPerformanceData:(NSDictionary*)data pointName:(YHEventReportPointName)name; |
36 | 36 | ||
37 | +/** | ||
38 | + * @abstract | ||
39 | + * 上传原AppReport数据,即手动添加的埋点数据 | ||
40 | + * | ||
41 | + */ | ||
42 | +- (void)pushCustomData:(NSDictionary*)data pointType:(YHPointType)type pointName:(YHEventReportPointName)name; | ||
43 | + | ||
44 | +/** | ||
45 | + * @abstract | ||
46 | + * 上传crash数据 | ||
47 | + */ | ||
48 | +- (void)pushCrashData:(NSDictionary*)data; | ||
49 | + | ||
37 | - (void) startUploadMode:(YHEventReportStrategy)mode timeInterval:(long)timeIntervals; | 50 | - (void) startUploadMode:(YHEventReportStrategy)mode timeInterval:(long)timeIntervals; |
38 | 51 | ||
39 | @end | 52 | @end |
@@ -16,6 +16,7 @@ | @@ -16,6 +16,7 @@ | ||
16 | #import <UserNotifications/UserNotifications.h> | 16 | #import <UserNotifications/UserNotifications.h> |
17 | #import "YH_AnalyticEventData.h" | 17 | #import "YH_AnalyticEventData.h" |
18 | #import "YHLog.h" | 18 | #import "YHLog.h" |
19 | +#import "YH_EventDataFactory.h" | ||
19 | 20 | ||
20 | @interface YH_EventCacheManager() | 21 | @interface YH_EventCacheManager() |
21 | 22 | ||
@@ -87,7 +88,6 @@ | @@ -87,7 +88,6 @@ | ||
87 | return self; | 88 | return self; |
88 | } | 89 | } |
89 | 90 | ||
90 | - | ||
91 | - (void)dealloc | 91 | - (void)dealloc |
92 | { | 92 | { |
93 | [self.timer invalidate]; | 93 | [self.timer invalidate]; |
@@ -150,14 +150,14 @@ | @@ -150,14 +150,14 @@ | ||
150 | 150 | ||
151 | - (void)pushEventData:(NSDictionary*)data | 151 | - (void)pushEventData:(NSDictionary*)data |
152 | { | 152 | { |
153 | - [self pushData:[[YH_AnalyticEventData sharedInstance] analyticEventParameters:data] dataType:YHEventReportDataTypeNormalEvent]; | 153 | + [self pushData:[[YH_AnalyticEventData sharedInstance] analyticEventParameters:data] dataType:YHEventReportDataTypeClickEvent]; |
154 | } | 154 | } |
155 | 155 | ||
156 | - (void)pushPerformanceData:(NSDictionary*)data pointName:(YHEventReportPointName)name | 156 | - (void)pushPerformanceData:(NSDictionary*)data pointName:(YHEventReportPointName)name |
157 | { | 157 | { |
158 | NSMutableDictionary *performanceDic = [[NSMutableDictionary alloc]initWithCapacity:0]; | 158 | NSMutableDictionary *performanceDic = [[NSMutableDictionary alloc]initWithCapacity:0]; |
159 | [performanceDic setObject:@"PERFORMANCE" forKey:YOHOAppReportKeyPT]; | 159 | [performanceDic setObject:@"PERFORMANCE" forKey:YOHOAppReportKeyPT]; |
160 | - [performanceDic setObject:[self getPointName:name] forKey:YOHOAppReportKeyPN]; | 160 | + [performanceDic setObject:[YH_EventDataFactory getPointName:name] forKey:YOHOAppReportKeyPN]; |
161 | 161 | ||
162 | NSMutableDictionary *eventDic = [[YH_EventDataFactory factoryEventAppInfo:self.performanceAppInfo]mutableCopy]; | 162 | NSMutableDictionary *eventDic = [[YH_EventDataFactory factoryEventAppInfo:self.performanceAppInfo]mutableCopy]; |
163 | 163 | ||
@@ -174,10 +174,42 @@ | @@ -174,10 +174,42 @@ | ||
174 | [self pushData:eventDic dataType:YHEventReportDataTypePerformance]; | 174 | [self pushData:eventDic dataType:YHEventReportDataTypePerformance]; |
175 | } | 175 | } |
176 | 176 | ||
177 | +- (void)pushCustomData:(NSDictionary*)data pointType:(YHPointType)type pointName:(YHEventReportPointName)name{ | ||
178 | + NSMutableDictionary *performanceDic = [NSMutableDictionary dictionary]; | ||
179 | + [performanceDic setObject:[YH_EventDataFactory getPointType:type] forKey:YOHOAppReportKeyPT]; | ||
180 | + [performanceDic setObject:[YH_EventDataFactory getPointName:name] forKey:YOHOAppReportKeyPN]; | ||
181 | + | ||
182 | + NSMutableDictionary *eventDic = [[YH_EventDataFactory factoryEventAppInfo:self.performanceAppInfo]mutableCopy]; | ||
183 | + | ||
184 | + if (!IsDictionaryClass(eventDic)) { | ||
185 | + return; | ||
186 | + } | ||
187 | + if (IsDictionaryClass(performanceDic)) { | ||
188 | + [eventDic addEntriesFromDictionary:performanceDic]; | ||
189 | + } | ||
190 | + if (IsDictionaryClass(eventDic)) { | ||
191 | + [eventDic setObject:data forKey:YOHOAppReportKeyPARAM]; | ||
192 | + } | ||
193 | + | ||
194 | + [self pushData:eventDic dataType:YHEventReportDataTypeCustom]; | ||
195 | +} | ||
196 | + | ||
197 | +- (void)pushCrashData:(NSDictionary*)data{ | ||
198 | + NSMutableDictionary *eventDic = [[YH_EventDataFactory factoryEventAppInfo:self.performanceAppInfo]mutableCopy]; | ||
199 | + | ||
200 | + if (!IsDictionaryClass(eventDic) ||!IsDictionaryClass(data)) { | ||
201 | + return; | ||
202 | + } | ||
203 | + | ||
204 | + [eventDic addEntriesFromDictionary:data]; | ||
205 | + | ||
206 | + [self pushData:[eventDic copy] dataType:YHEventReportDataTypeCustom]; | ||
207 | +} | ||
208 | + | ||
177 | #pragma mark - private | 209 | #pragma mark - private |
178 | - (void)pushData:(NSDictionary*)data dataType:(YHEventReportDataType)type | 210 | - (void)pushData:(NSDictionary*)data dataType:(YHEventReportDataType)type |
179 | { | 211 | { |
180 | - if (type == YHEventReportDataTypeNormalEvent) { | 212 | + if (type == YHEventReportDataTypeClickEvent) { |
181 | [self.eventDataSession uploadEventData:data tag:nil result:^(BOOL isSuc, id tag, NSError *error) { | 213 | [self.eventDataSession uploadEventData:data tag:nil result:^(BOOL isSuc, id tag, NSError *error) { |
182 | }]; | 214 | }]; |
183 | }else { | 215 | }else { |
@@ -195,9 +227,7 @@ | @@ -195,9 +227,7 @@ | ||
195 | - (void) startUploadMode:(YHEventReportStrategy)mode timeInterval:(long)timeIntervals; | 227 | - (void) startUploadMode:(YHEventReportStrategy)mode timeInterval:(long)timeIntervals; |
196 | { | 228 | { |
197 | _mode = mode; | 229 | _mode = mode; |
198 | - | ||
199 | self.timeInterval = timeIntervals; | 230 | self.timeInterval = timeIntervals; |
200 | - | ||
201 | if (mode == YHEventReportStrategyInterval) { | 231 | if (mode == YHEventReportStrategyInterval) { |
202 | if (self.timer == nil) { | 232 | if (self.timer == nil) { |
203 | //定时上传 | 233 | //定时上传 |
@@ -222,61 +252,11 @@ | @@ -222,61 +252,11 @@ | ||
222 | if (IsArrayClass(ary)) { | 252 | if (IsArrayClass(ary)) { |
223 | [performanceAryDic setObject:dataArray forKey:@"list"]; | 253 | [performanceAryDic setObject:dataArray forKey:@"list"]; |
224 | } | 254 | } |
225 | - [performanceAryDic setObject:[self getDataType:type] forKey:@"type"]; | 255 | + [performanceAryDic setObject:[YH_EventDataFactory getDataType:type] forKey:@"type"]; |
226 | 256 | ||
227 | return performanceAryDic; | 257 | return performanceAryDic; |
228 | } | 258 | } |
229 | 259 | ||
230 | --(NSString *)getPointName:(YHEventReportPointName)pointName{ | ||
231 | - NSString *str = @""; | ||
232 | - switch (pointName) { | ||
233 | - case YHPN_VIEWCONTROLLER: | ||
234 | - str = @"PAGE"; | ||
235 | - break; | ||
236 | - case YHPN_WEBVIEW: | ||
237 | - str = @"WEBVIEW"; | ||
238 | - break; | ||
239 | - case YHPN_IMAGEVIEW: | ||
240 | - str = @"IMAGE"; | ||
241 | - break; | ||
242 | - case YHPN_BUTTON: | ||
243 | - str = @"BUTTON"; | ||
244 | - break; | ||
245 | - case YHPN_GESTURERECOGNIZER: | ||
246 | - str = @"GESTURERECOGNIZER"; | ||
247 | - break; | ||
248 | - default: | ||
249 | - break; | ||
250 | - } | ||
251 | - | ||
252 | - return str; | ||
253 | -} | ||
254 | - | ||
255 | --(NSString *)getDataType:(YHEventReportTrackDataType)type{ | ||
256 | - NSString *str = @""; | ||
257 | - | ||
258 | - switch (type) { | ||
259 | - case YHEventReportTrackDataTypeStart: | ||
260 | - str = @"start"; | ||
261 | - break; | ||
262 | - case YHEventReportTrackDataTypeDestory: | ||
263 | - str = @"destory"; | ||
264 | - break; | ||
265 | - case YHEventReportTrackDataTypeStop: | ||
266 | - str = @"stop"; | ||
267 | - break; | ||
268 | - case YHEventReportTrackDataTypeHeartbeat: | ||
269 | - str = @"hb"; | ||
270 | - break; | ||
271 | - case YHEventReportTrackDataTypeNONE: | ||
272 | - str = @"realTime"; | ||
273 | - break; | ||
274 | - default: | ||
275 | - break; | ||
276 | - } | ||
277 | - | ||
278 | - return str; | ||
279 | -} | ||
280 | 260 | ||
281 | - (void)refreshPushStatus | 261 | - (void)refreshPushStatus |
282 | { | 262 | { |
@@ -308,8 +288,7 @@ | @@ -308,8 +288,7 @@ | ||
308 | - (void)handleMemoryWarning | 288 | - (void)handleMemoryWarning |
309 | { | 289 | { |
310 | if (self.mode == YHEventReportStrategyInterval) { | 290 | if (self.mode == YHEventReportStrategyInterval) { |
311 | - @synchronized (self) { | ||
312 | - //[self.eventCacheArray removeAllObjects]; | 291 | + @synchronized (self.performanceCacheArray) { |
313 | [self.performanceCacheArray removeAllObjects]; | 292 | [self.performanceCacheArray removeAllObjects]; |
314 | } | 293 | } |
315 | } | 294 | } |
@@ -317,26 +296,14 @@ | @@ -317,26 +296,14 @@ | ||
317 | - (void)handleDidFinishLaunch | 296 | - (void)handleDidFinishLaunch |
318 | { | 297 | { |
319 | if (self.mode == YHEventReportStrategyInterval) { | 298 | if (self.mode == YHEventReportStrategyInterval) { |
320 | - @synchronized (self.performanceCacheArray) { | ||
321 | - NSMutableArray *data = [[NSMutableArray alloc]initWithCapacity:0]; | ||
322 | - [data setArray:self.performanceCacheArray]; | ||
323 | - [self.performanceCacheArray removeAllObjects]; | ||
324 | - [self.eventDataSession uploadPerformanceData:[self getPerformanceFormatData:data type:YHEventReportTrackDataTypeStart] tag:nil result:^(BOOL isSuc, id tag, NSError *error) { | ||
325 | - }]; | ||
326 | - } | 299 | + [self uploadPerformanceDataWithType:YHEventReportTrackDataTypeStart]; |
327 | } | 300 | } |
328 | } | 301 | } |
329 | 302 | ||
330 | - (void)handleTerminate | 303 | - (void)handleTerminate |
331 | { | 304 | { |
332 | if (self.mode == YHEventReportStrategyInterval) { | 305 | if (self.mode == YHEventReportStrategyInterval) { |
333 | - @synchronized (self.performanceCacheArray) { | ||
334 | - NSMutableArray *data = [[NSMutableArray alloc]initWithCapacity:0]; | ||
335 | - [data setArray:self.performanceCacheArray]; | ||
336 | - [self.performanceCacheArray removeAllObjects]; | ||
337 | - [self.eventDataSession uploadPerformanceData:[self getPerformanceFormatData:data type:YHEventReportTrackDataTypeDestory] tag:nil result:^(BOOL isSuc, id tag, NSError *error) { | ||
338 | - }]; | ||
339 | - } | 306 | + [self uploadPerformanceDataWithType:YHEventReportTrackDataTypeDestory]; |
340 | } | 307 | } |
341 | } | 308 | } |
342 | 309 | ||
@@ -344,27 +311,25 @@ | @@ -344,27 +311,25 @@ | ||
344 | { | 311 | { |
345 | [self.performanceAppInfo resetSessionID]; | 312 | [self.performanceAppInfo resetSessionID]; |
346 | if (self.mode == YHEventReportStrategyInterval) { | 313 | if (self.mode == YHEventReportStrategyInterval) { |
347 | - @synchronized (self.performanceCacheArray) { | ||
348 | - NSMutableArray *data = [[NSMutableArray alloc]initWithCapacity:0]; | ||
349 | - [data setArray:self.performanceCacheArray]; | ||
350 | - [self.performanceCacheArray removeAllObjects]; | ||
351 | - [self.eventDataSession uploadPerformanceData:[self getPerformanceFormatData:data type:YHEventReportTrackDataTypeStop] tag:nil result:^(BOOL isSuc, id tag, NSError *error) { | ||
352 | - }]; | ||
353 | - } | 314 | + [self uploadPerformanceDataWithType:YHEventReportTrackDataTypeStop]; |
354 | } | 315 | } |
355 | } | 316 | } |
356 | 317 | ||
357 | #pragma mark - timer | 318 | #pragma mark - timer |
358 | - (void)timerAction | 319 | - (void)timerAction |
359 | { | 320 | { |
321 | + [self uploadPerformanceDataWithType:YHEventReportTrackDataTypeHeartbeat]; | ||
322 | +} | ||
323 | + | ||
324 | +#pragma mark - upload performance data | ||
325 | +-(void)uploadPerformanceDataWithType:(YHEventReportTrackDataType)type{ | ||
326 | + @synchronized (self.performanceCacheArray) { | ||
327 | + [self.eventDataSession uploadPerformanceData:[self getPerformanceFormatData:[self.performanceCacheArray copy] type:type] tag:nil result:^(BOOL isSuc, id tag, NSError *error) { | ||
328 | + }]; | ||
329 | + } | ||
330 | + | ||
360 | @synchronized (self.performanceCacheArray) { | 331 | @synchronized (self.performanceCacheArray) { |
361 | - NSMutableArray *data = [[NSMutableArray alloc]initWithCapacity:0]; | ||
362 | - [data setArray:self.performanceCacheArray]; | ||
363 | [self.performanceCacheArray removeAllObjects]; | 332 | [self.performanceCacheArray removeAllObjects]; |
364 | - //if ([data count] > 0) { | ||
365 | - [self.eventDataSession uploadPerformanceData:[self getPerformanceFormatData:data type:YHEventReportTrackDataTypeHeartbeat] tag:nil result:^(BOOL isSuc, id tag, NSError *error) { | ||
366 | - }]; | ||
367 | - //} | ||
368 | } | 333 | } |
369 | } | 334 | } |
370 | 335 |
@@ -12,6 +12,7 @@ | @@ -12,6 +12,7 @@ | ||
12 | #import "YHLog.h" | 12 | #import "YHLog.h" |
13 | #import "NSData+YHERGZip.h" | 13 | #import "NSData+YHERGZip.h" |
14 | #import "NSString+ER_URL.h" | 14 | #import "NSString+ER_URL.h" |
15 | +#import "YHEventReport.h" | ||
15 | 16 | ||
16 | #define kYOHOEventReportURL @"http://analysis.yohobuy.com/yas_mobile"//@"http://172.16.10.128:8081/eventreport" | 17 | #define kYOHOEventReportURL @"http://analysis.yohobuy.com/yas_mobile"//@"http://172.16.10.128:8081/eventreport" |
17 | 18 | ||
@@ -50,6 +51,11 @@ | @@ -50,6 +51,11 @@ | ||
50 | 51 | ||
51 | - (void)uploadEventData:(id)parameters tag:(id)tag result:(void (^)(BOOL isSuc,id tag, NSError *error))result | 52 | - (void)uploadEventData:(id)parameters tag:(id)tag result:(void (^)(BOOL isSuc,id tag, NSError *error))result |
52 | { | 53 | { |
54 | +#if !TARGET_IPHONE_SIMULATOR | ||
55 | + if (![YHEventReport sharedInstance].isClickEventTrackEnabled) { | ||
56 | + return; | ||
57 | + } | ||
58 | + | ||
53 | if (!self.canUpload) { | 59 | if (!self.canUpload) { |
54 | return; | 60 | return; |
55 | } | 61 | } |
@@ -73,10 +79,16 @@ | @@ -73,10 +79,16 @@ | ||
73 | }]; | 79 | }]; |
74 | 80 | ||
75 | [task resume]; | 81 | [task resume]; |
82 | +#endif | ||
76 | } | 83 | } |
77 | 84 | ||
78 | - (void)uploadPerformanceData:(id)parameters tag:(id)tag result:(void (^)(BOOL isSuc,id tag, NSError *error))result | 85 | - (void)uploadPerformanceData:(id)parameters tag:(id)tag result:(void (^)(BOOL isSuc,id tag, NSError *error))result |
79 | { | 86 | { |
87 | +#if !TARGET_IPHONE_SIMULATOR | ||
88 | + if (![YHEventReport sharedInstance].isPerformanceTrackEnabled) { | ||
89 | + return; | ||
90 | + } | ||
91 | + | ||
80 | if (!self.canUpload) { | 92 | if (!self.canUpload) { |
81 | return; | 93 | return; |
82 | } | 94 | } |
@@ -99,6 +111,7 @@ | @@ -99,6 +111,7 @@ | ||
99 | }]; | 111 | }]; |
100 | 112 | ||
101 | [task resume]; | 113 | [task resume]; |
114 | +#endif | ||
102 | } | 115 | } |
103 | 116 | ||
104 | #pragma mark - private | 117 | #pragma mark - private |
@@ -108,8 +121,11 @@ | @@ -108,8 +121,11 @@ | ||
108 | return nil; | 121 | return nil; |
109 | } | 122 | } |
110 | 123 | ||
111 | - NSError *error; | 124 | + if (![NSJSONSerialization isValidJSONObject:param]) { |
125 | + return nil; | ||
126 | + } | ||
112 | 127 | ||
128 | + NSError *error; | ||
113 | NSData *postData = [NSJSONSerialization dataWithJSONObject:param options:0 error:&error]; | 129 | NSData *postData = [NSJSONSerialization dataWithJSONObject:param options:0 error:&error]; |
114 | if (error) { | 130 | if (error) { |
115 | return nil; | 131 | return nil; |
@@ -30,12 +30,14 @@ typedef NS_ENUM(NSInteger, YHEventReportStrategy) { | @@ -30,12 +30,14 @@ typedef NS_ENUM(NSInteger, YHEventReportStrategy) { | ||
30 | * @abstract | 30 | * @abstract |
31 | * YHEventReportDataType 上报数据类型。 | 31 | * YHEventReportDataType 上报数据类型。 |
32 | 32 | ||
33 | - * YHEventReportDataTypeNormalEvent - 点击数据 | 33 | + * YHEventReportDataTypeClickEvent - 点击数据 |
34 | * YHEventReportDataTypePerformance - 性能数据 | 34 | * YHEventReportDataTypePerformance - 性能数据 |
35 | + * YHEventReportDataTypeCustom - 业务数据(手动添加的埋点,统计前后台切换、cdn切换、双中心切换、业务数据等) | ||
35 | */ | 36 | */ |
36 | typedef NS_ENUM(NSInteger, YHEventReportDataType) { | 37 | typedef NS_ENUM(NSInteger, YHEventReportDataType) { |
37 | - YHEventReportDataTypeNormalEvent, | 38 | + YHEventReportDataTypeClickEvent, |
38 | YHEventReportDataTypePerformance, | 39 | YHEventReportDataTypePerformance, |
40 | + YHEventReportDataTypeCustom, | ||
39 | }; | 41 | }; |
40 | 42 | ||
41 | /** | 43 | /** |
@@ -91,6 +93,31 @@ typedef NS_ENUM(NSInteger, YHEventReportPointName) { | @@ -91,6 +93,31 @@ typedef NS_ENUM(NSInteger, YHEventReportPointName) { | ||
91 | YHPN_WEBVIEW,//UIWebView 加载时间 // @"WEBVIEW" | 93 | YHPN_WEBVIEW,//UIWebView 加载时间 // @"WEBVIEW" |
92 | YHPN_IMAGEVIEW,//Image (SDWebImage) 加载时间 // @"IMAGE" | 94 | YHPN_IMAGEVIEW,//Image (SDWebImage) 加载时间 // @"IMAGE" |
93 | YHPN_BUTTON,//Button 响应时间 // @"BUTTON" | 95 | YHPN_BUTTON,//Button 响应时间 // @"BUTTON" |
96 | + YHPN_TIMEOUT, //网络事件 -网络超时 | ||
97 | + YHPN_CODE_ERR , //网络事件- 有错误码返回的错误 | ||
98 | + YHPN_H5_FEATURE_META_FAILED, //feature.yoho.cn的H5页面meta校验失败 | ||
99 | + YHPN_RN_EXCEPTION, //App异常- RN自定义错误 | ||
100 | + YHPN_CRASH , //App异常- App崩溃 | ||
101 | + YHPN_CUSTOM_EXCEPTION, //App异常- 自定义异常 | ||
102 | + YHPN_CDN_CHOOSE, //CDN- cdn选择,启动时上报当前的CDN, 发生CDN切换时再上报切换的CDN | ||
103 | + YHPN_CENTER_CHOOSE, //CENTER- 中心选择,启动时上报当前的中心, 发生中心切换时再上报切换的中心 | ||
104 | + YHPN_APP_PATCHLOAD, //APP补丁- 如果当前客户端在运行过程中使用了某个补丁则上报该事件 | ||
105 | + YHPN_RN_PATCHLOAD, //RN补丁- 如果当前客户端在运行过程中使用了某个补丁则上报该事件 | ||
106 | + YHPN_START, //启动 | ||
107 | + YHPN_RESUME, //进入 | ||
108 | + YHPN_STOP,//不可见状态 | ||
109 | + YHPN_DESTROY, //被杀掉 | ||
110 | + YHPN_PUSH_ACTIVE,//被PUSH拉起, 此状态不影响RESUME的上报 | ||
111 | + YHPN_T3_ACTIVE,//被3D TOUCH拉起, 此状态不影响RESUME的上报 | ||
112 | + YHPN_UL_ACTIVE,//被universal link拉起,此状态不影响RESUME的上报 | ||
113 | + YHPN_APP_ACTIVE,//被第三方APP拉起, 此状态不影响RESUME的上报 | ||
114 | + YHPN_BUSINESS_USER_LOGIN,//用户登录相关业务错误 | ||
115 | + YHPN_BUSINESS_USER_REGIST,//用户注册相关业务错误 | ||
116 | + YHPN_BUSINESS_USER_REPASSWORD,//用户找回密码相关业务错误 | ||
117 | + YHPN_BUSINESS_ORDER_ADDSHOPPINGCARD,//加入购物车相关业务错误 | ||
118 | + YHPN_BUSINESS_ORDER_ACCOUNT,//结算订单相关业务错误 | ||
119 | + YHPN_BUSINESS_ORDER_CONFIRM,//确认订单相关业务错误 | ||
120 | + YHPN_BUSINESS_ORDER_PAY,//支付相关业务错误 | ||
94 | YHPN_GESTURERECOGNIZER //UITapGestureRecognizer响应时间// @"GESTURERECOGNIZER" | 121 | YHPN_GESTURERECOGNIZER //UITapGestureRecognizer响应时间// @"GESTURERECOGNIZER" |
95 | }; | 122 | }; |
96 | 123 | ||
@@ -104,6 +131,21 @@ typedef NS_ENUM(NSInteger, YHEventLoadStatus) { | @@ -104,6 +131,21 @@ typedef NS_ENUM(NSInteger, YHEventLoadStatus) { | ||
104 | YHEventLoadStatusFailed, //加载失败 | 131 | YHEventLoadStatusFailed, //加载失败 |
105 | }; | 132 | }; |
106 | 133 | ||
134 | +typedef NS_ENUM(NSInteger,YHAPPKey){ | ||
135 | + YOHOBUY, | ||
136 | +}; | ||
137 | + | ||
138 | +typedef NS_ENUM(NSInteger, YHPointType) { | ||
139 | + YHPT_NETWORK, | ||
140 | + YHPT_EXCEPTION, | ||
141 | + YHPT_CDN, | ||
142 | + YHPT_CENTER, | ||
143 | + YHPT_PATCH, | ||
144 | + YHPT_LIFECYCLE, | ||
145 | + YHPT_BUSINESS, | ||
146 | + YHPT_PERFORMANCE, | ||
147 | +}; | ||
148 | + | ||
107 | #define YHEventReportDebugModeEnableKey @"YHEventReportDebugModeEnableKey" | 149 | #define YHEventReportDebugModeEnableKey @"YHEventReportDebugModeEnableKey" |
108 | 150 | ||
109 | 151 | ||
@@ -239,4 +281,52 @@ typedef NS_ENUM(NSInteger, YHEventLoadStatus) { | @@ -239,4 +281,52 @@ typedef NS_ENUM(NSInteger, YHEventLoadStatus) { | ||
239 | 281 | ||
240 | #define YOHOAppReportKeyStyle_C @"YB_AUTO_TRACK" | 282 | #define YOHOAppReportKeyStyle_C @"YB_AUTO_TRACK" |
241 | 283 | ||
284 | + | ||
285 | +#define YOHOAppReportErrors @"errors" //错误 | ||
286 | +#define YOHOAppReportParam @"param" //参数 | ||
287 | +// 中断和异常参数 | ||
288 | +#define YOHOAppReportCrashCallstack @"st" // 异常堆栈 | ||
289 | +#define YOHOAppReportCrashSignal @"sig" // 中断信号量 | ||
290 | +#define YOHOAppReportCrashSignalName @"sign" // 中断信号名称 | ||
291 | +#define YOHOAppReportCrashExceptionName @"exn" // 异常名称 | ||
292 | +#define YOHOAppReportCrashExceptionReason @"exr" // 异常原因 | ||
293 | + | ||
294 | + | ||
295 | + | ||
296 | +#define YOHOAppReportLogSystemName @"AppReportLogSystem" // 日志文件名称 | ||
297 | +#define kPathCaches [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] | ||
298 | +#define YOHOPathLogSystem [kPathCaches stringByAppendingPathComponent:@"YHLogSystem"] // 日志保存路径 | ||
299 | + | ||
300 | +// 运营商 | ||
301 | +#define kCarrierCodeChinaUnknown @"0" // 未知 | ||
302 | +#define kCarrierCodeChinaMobile @"1" // 中国移动 | ||
303 | +#define kCarrierCodeChinaTelecom @"2" // 中国电信 | ||
304 | +#define kCarrierCodeChinaUnicom @"3" // 中国联通 | ||
305 | +#define kCarrierCodeChinaTietong @"4" // 中国铁通 | ||
306 | + | ||
307 | +//上报参数的key | ||
308 | +#define YOHOAppReportKeyAK @"ak" | ||
309 | +#define YOHOAppReportKeyUDID @"udid" | ||
310 | +#define YOHOAppReportKeyCH @"ch" | ||
311 | +#define YOHOAppReportKeyOS @"os" | ||
312 | +#define YOHOAppReportKeyOSV @"osv" | ||
313 | +#define YOHOAppReportKeyDM @"dm" | ||
314 | +#define YOHOAppReportKeyPS @"ps" | ||
315 | +#define YOHOAppReportKeyAV @"av" | ||
316 | +#define YOHOAppReportKeyAB @"ab" | ||
317 | +#define YOHOAppReportKeyCA @"ca" | ||
318 | +#define YOHOAppReportKeyNET @"net" | ||
319 | +#define YOHOAppReportKeyTS @"ts" | ||
320 | +#define YOHOAppReportKeyUID @"uid" | ||
321 | +#define YOHOAppReportKeySID @"sid" | ||
322 | +#define YOHOAppReportKeyPT @"pt" | ||
323 | +#define YOHOAppReportKeyPN @"pn" | ||
324 | +#define YOHOAppReportKeyPARAM @"param" | ||
325 | + | ||
326 | + | ||
327 | +#define YOHOAppReportDefaultAPPKey @"yohobuy_ios" | ||
328 | + | ||
329 | +#define WS(weakSelf) __weak __typeof(&*self)weakSelf = self | ||
330 | + | ||
331 | + | ||
242 | #endif /* YHEventReportMacros_h */ | 332 | #endif /* YHEventReportMacros_h */ |
@@ -23,6 +23,12 @@ | @@ -23,6 +23,12 @@ | ||
23 | 23 | ||
24 | +(NSDictionary *)factoryTimeEventDataWithUIGestureRecognizer:(UITapGestureRecognizer *)gestureRecognizer ElapsedTime:(NSTimeInterval)elapsedTime; | 24 | +(NSDictionary *)factoryTimeEventDataWithUIGestureRecognizer:(UITapGestureRecognizer *)gestureRecognizer ElapsedTime:(NSTimeInterval)elapsedTime; |
25 | 25 | ||
26 | -+ (NSDictionary *)factoryEventAppInfo:(YH_PerformanceAppInfo*)appInfo; | 26 | ++(NSDictionary *)factoryEventAppInfo:(YH_PerformanceAppInfo*)appInfo; |
27 | + | ||
28 | ++(NSString *)getPointName:(YHEventReportPointName)pointName; | ||
29 | + | ||
30 | ++(NSString *)getPointType:(YHPointType)pointType; | ||
31 | + | ||
32 | ++(NSString *)getDataType:(YHEventReportTrackDataType)type; | ||
27 | 33 | ||
28 | @end | 34 | @end |
@@ -104,4 +104,163 @@ | @@ -104,4 +104,163 @@ | ||
104 | return commonInfo; | 104 | return commonInfo; |
105 | } | 105 | } |
106 | 106 | ||
107 | ++(NSString *)getPointName:(YHEventReportPointName)pointName{ | ||
108 | + NSString *str = @""; | ||
109 | + switch (pointName) { | ||
110 | + case YHPN_VIEWCONTROLLER: | ||
111 | + str = @"PAGE"; | ||
112 | + break; | ||
113 | + case YHPN_WEBVIEW: | ||
114 | + str = @"WEBVIEW"; | ||
115 | + break; | ||
116 | + case YHPN_IMAGEVIEW: | ||
117 | + str = @"IMAGE"; | ||
118 | + break; | ||
119 | + case YHPN_BUTTON: | ||
120 | + str = @"BUTTON"; | ||
121 | + break; | ||
122 | + case YHPN_GESTURERECOGNIZER: | ||
123 | + str = @"GESTURERECOGNIZER"; | ||
124 | + break; | ||
125 | + case YHPN_TIMEOUT: | ||
126 | + str = @"TIMEOUT"; | ||
127 | + break; | ||
128 | + case YHPN_CODE_ERR: | ||
129 | + str = @"CODE_ERR"; | ||
130 | + break; | ||
131 | + case YHPN_H5_FEATURE_META_FAILED: | ||
132 | + str = @"NO_WEBMETA"; | ||
133 | + break; | ||
134 | + case YHPN_RN_EXCEPTION: | ||
135 | + str = @"RN_EXCEPTION"; | ||
136 | + break; | ||
137 | + case YHPN_CRASH: | ||
138 | + str = @"CRASH"; | ||
139 | + break; | ||
140 | + case YHPN_CUSTOM_EXCEPTION: | ||
141 | + str = @"CUSTOM_EXCEPTION"; | ||
142 | + break; | ||
143 | + case YHPN_CDN_CHOOSE: | ||
144 | + str = @"CDN_CHOOSE"; | ||
145 | + break; | ||
146 | + case YHPN_CENTER_CHOOSE: | ||
147 | + str = @"CENTER_CHOOSE"; | ||
148 | + break; | ||
149 | + case YHPN_APP_PATCHLOAD: | ||
150 | + str = @"APP_PATCHLOAD"; | ||
151 | + break; | ||
152 | + case YHPN_RN_PATCHLOAD: | ||
153 | + str = @"RN_PATCHLOAD"; | ||
154 | + break; | ||
155 | + case YHPN_START: | ||
156 | + str = @"START"; | ||
157 | + break; | ||
158 | + case YHPN_RESUME: | ||
159 | + str = @"RESUME"; | ||
160 | + break; | ||
161 | + case YHPN_STOP: | ||
162 | + str = @"STOP"; | ||
163 | + break; | ||
164 | + case YHPN_DESTROY: | ||
165 | + str = @"DESTROY"; | ||
166 | + break; | ||
167 | + case YHPN_PUSH_ACTIVE: | ||
168 | + str = @"PUSH_ACTIVE"; | ||
169 | + break; | ||
170 | + case YHPN_T3_ACTIVE: | ||
171 | + str = @"T3_ACTIVE"; | ||
172 | + break; | ||
173 | + case YHPN_UL_ACTIVE: | ||
174 | + str = @"UL_ACTIVE"; | ||
175 | + break; | ||
176 | + case YHPN_APP_ACTIVE: | ||
177 | + str = @"APP_ACTIVE"; | ||
178 | + break; | ||
179 | + case YHPN_BUSINESS_USER_LOGIN: | ||
180 | + str = @"BUSINESS_USER_LOGIN"; | ||
181 | + break; | ||
182 | + case YHPN_BUSINESS_USER_REGIST: | ||
183 | + str = @"BUSINESS_USER_REGIST"; | ||
184 | + break; | ||
185 | + case YHPN_BUSINESS_USER_REPASSWORD: | ||
186 | + str = @"BUSINESS_USER_REPASSWORD"; | ||
187 | + break; | ||
188 | + case YHPN_BUSINESS_ORDER_ADDSHOPPINGCARD: | ||
189 | + str = @"BUSINESS_ORDER_ADDSHOPPINGCARD"; | ||
190 | + break; | ||
191 | + case YHPN_BUSINESS_ORDER_ACCOUNT: | ||
192 | + str = @"BUSINESS_ORDER_ACCOUNT"; | ||
193 | + break; | ||
194 | + case YHPN_BUSINESS_ORDER_CONFIRM: | ||
195 | + str = @"BUSINESS_ORDER_CONFIRM"; | ||
196 | + break; | ||
197 | + case YHPN_BUSINESS_ORDER_PAY: | ||
198 | + str = @"BUSINESS_ORDER_PAY"; | ||
199 | + break; | ||
200 | + default: | ||
201 | + break; | ||
202 | + } | ||
203 | + | ||
204 | + return str; | ||
205 | +} | ||
206 | + | ||
207 | ++(NSString *)getPointType:(YHPointType)pointType{ | ||
208 | + NSString *str = @""; | ||
209 | + switch (pointType) { | ||
210 | + case YHPT_NETWORK: | ||
211 | + str = @"NETWORK"; | ||
212 | + break; | ||
213 | + case YHPT_EXCEPTION: | ||
214 | + str = @"EXCEPTION"; | ||
215 | + break; | ||
216 | + case YHPT_CDN: | ||
217 | + str = @"CDN"; | ||
218 | + break; | ||
219 | + case YHPT_CENTER: | ||
220 | + str = @"CENTER"; | ||
221 | + break; | ||
222 | + case YHPT_PATCH: | ||
223 | + str = @"PATCH"; | ||
224 | + break; | ||
225 | + case YHPT_LIFECYCLE: | ||
226 | + str = @"LIFECYCLE"; | ||
227 | + break; | ||
228 | + case YHPT_BUSINESS: | ||
229 | + str = @"BUSINESS"; | ||
230 | + break; | ||
231 | + case YHPT_PERFORMANCE: | ||
232 | + str = @"PERFORMANCE"; | ||
233 | + break; | ||
234 | + default: | ||
235 | + break; | ||
236 | + } | ||
237 | + return str; | ||
238 | +} | ||
239 | + | ||
240 | ++(NSString *)getDataType:(YHEventReportTrackDataType)type{ | ||
241 | + NSString *str = @""; | ||
242 | + | ||
243 | + switch (type) { | ||
244 | + case YHEventReportTrackDataTypeStart: | ||
245 | + str = @"start"; | ||
246 | + break; | ||
247 | + case YHEventReportTrackDataTypeDestory: | ||
248 | + str = @"destory"; | ||
249 | + break; | ||
250 | + case YHEventReportTrackDataTypeStop: | ||
251 | + str = @"stop"; | ||
252 | + break; | ||
253 | + case YHEventReportTrackDataTypeHeartbeat: | ||
254 | + str = @"hb"; | ||
255 | + break; | ||
256 | + case YHEventReportTrackDataTypeNONE: | ||
257 | + str = @"realTime"; | ||
258 | + break; | ||
259 | + default: | ||
260 | + break; | ||
261 | + } | ||
262 | + | ||
263 | + return str; | ||
264 | +} | ||
265 | + | ||
107 | @end | 266 | @end |
@@ -156,13 +156,8 @@ | @@ -156,13 +156,8 @@ | ||
156 | } | 156 | } |
157 | 157 | ||
158 | -(NSString *)ts{ | 158 | -(NSString *)ts{ |
159 | - long long now = [[NSDate date] timeIntervalSince1970]; | ||
160 | - long long int date = (long long int)now; | ||
161 | - _ts = [NSString stringWithFormat:@"%lld", date]; | ||
162 | - if (!_ts) { | ||
163 | - _ts = @""; | ||
164 | - } | ||
165 | - return _ts; | 159 | + long long int date = (long long int)[[NSDate date] timeIntervalSince1970]; |
160 | + return [NSString stringWithFormat:@"%lld", date]?:@""; | ||
166 | } | 161 | } |
167 | 162 | ||
168 | @end | 163 | @end |
-
Please register or login to post a comment