...
|
...
|
@@ -16,6 +16,7 @@ |
|
|
#import <UserNotifications/UserNotifications.h>
|
|
|
#import "YH_AnalyticEventData.h"
|
|
|
#import "YHLog.h"
|
|
|
#import "YH_EventDataFactory.h"
|
|
|
|
|
|
@interface YH_EventCacheManager()
|
|
|
|
...
|
...
|
@@ -87,7 +88,6 @@ |
|
|
return self;
|
|
|
}
|
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
{
|
|
|
[self.timer invalidate];
|
...
|
...
|
@@ -150,14 +150,14 @@ |
|
|
|
|
|
- (void)pushEventData:(NSDictionary*)data
|
|
|
{
|
|
|
[self pushData:[[YH_AnalyticEventData sharedInstance] analyticEventParameters:data] dataType:YHEventReportDataTypeNormalEvent];
|
|
|
[self pushData:[[YH_AnalyticEventData sharedInstance] analyticEventParameters:data] dataType:YHEventReportDataTypeClickEvent];
|
|
|
}
|
|
|
|
|
|
- (void)pushPerformanceData:(NSDictionary*)data pointName:(YHEventReportPointName)name
|
|
|
{
|
|
|
NSMutableDictionary *performanceDic = [[NSMutableDictionary alloc]initWithCapacity:0];
|
|
|
[performanceDic setObject:@"PERFORMANCE" forKey:YOHOAppReportKeyPT];
|
|
|
[performanceDic setObject:[self getPointName:name] forKey:YOHOAppReportKeyPN];
|
|
|
[performanceDic setObject:[YH_EventDataFactory getPointName:name] forKey:YOHOAppReportKeyPN];
|
|
|
|
|
|
NSMutableDictionary *eventDic = [[YH_EventDataFactory factoryEventAppInfo:self.performanceAppInfo]mutableCopy];
|
|
|
|
...
|
...
|
@@ -174,10 +174,42 @@ |
|
|
[self pushData:eventDic dataType:YHEventReportDataTypePerformance];
|
|
|
}
|
|
|
|
|
|
- (void)pushCustomData:(NSDictionary*)data pointType:(YHPointType)type pointName:(YHEventReportPointName)name{
|
|
|
NSMutableDictionary *performanceDic = [NSMutableDictionary dictionary];
|
|
|
[performanceDic setObject:[YH_EventDataFactory getPointType:type] forKey:YOHOAppReportKeyPT];
|
|
|
[performanceDic setObject:[YH_EventDataFactory getPointName:name] forKey:YOHOAppReportKeyPN];
|
|
|
|
|
|
NSMutableDictionary *eventDic = [[YH_EventDataFactory factoryEventAppInfo:self.performanceAppInfo]mutableCopy];
|
|
|
|
|
|
if (!IsDictionaryClass(eventDic)) {
|
|
|
return;
|
|
|
}
|
|
|
if (IsDictionaryClass(performanceDic)) {
|
|
|
[eventDic addEntriesFromDictionary:performanceDic];
|
|
|
}
|
|
|
if (IsDictionaryClass(eventDic)) {
|
|
|
[eventDic setObject:data forKey:YOHOAppReportKeyPARAM];
|
|
|
}
|
|
|
|
|
|
[self pushData:eventDic dataType:YHEventReportDataTypeCustom];
|
|
|
}
|
|
|
|
|
|
- (void)pushCrashData:(NSDictionary*)data{
|
|
|
NSMutableDictionary *eventDic = [[YH_EventDataFactory factoryEventAppInfo:self.performanceAppInfo]mutableCopy];
|
|
|
|
|
|
if (!IsDictionaryClass(eventDic) ||!IsDictionaryClass(data)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
[eventDic addEntriesFromDictionary:data];
|
|
|
|
|
|
[self pushData:[eventDic copy] dataType:YHEventReportDataTypeCustom];
|
|
|
}
|
|
|
|
|
|
#pragma mark - private
|
|
|
- (void)pushData:(NSDictionary*)data dataType:(YHEventReportDataType)type
|
|
|
{
|
|
|
if (type == YHEventReportDataTypeNormalEvent) {
|
|
|
if (type == YHEventReportDataTypeClickEvent) {
|
|
|
[self.eventDataSession uploadEventData:data tag:nil result:^(BOOL isSuc, id tag, NSError *error) {
|
|
|
}];
|
|
|
}else {
|
...
|
...
|
@@ -195,9 +227,7 @@ |
|
|
- (void) startUploadMode:(YHEventReportStrategy)mode timeInterval:(long)timeIntervals;
|
|
|
{
|
|
|
_mode = mode;
|
|
|
|
|
|
self.timeInterval = timeIntervals;
|
|
|
|
|
|
if (mode == YHEventReportStrategyInterval) {
|
|
|
if (self.timer == nil) {
|
|
|
//定时上传
|
...
|
...
|
@@ -222,61 +252,11 @@ |
|
|
if (IsArrayClass(ary)) {
|
|
|
[performanceAryDic setObject:dataArray forKey:@"list"];
|
|
|
}
|
|
|
[performanceAryDic setObject:[self getDataType:type] forKey:@"type"];
|
|
|
[performanceAryDic setObject:[YH_EventDataFactory getDataType:type] forKey:@"type"];
|
|
|
|
|
|
return performanceAryDic;
|
|
|
}
|
|
|
|
|
|
-(NSString *)getPointName:(YHEventReportPointName)pointName{
|
|
|
NSString *str = @"";
|
|
|
switch (pointName) {
|
|
|
case YHPN_VIEWCONTROLLER:
|
|
|
str = @"PAGE";
|
|
|
break;
|
|
|
case YHPN_WEBVIEW:
|
|
|
str = @"WEBVIEW";
|
|
|
break;
|
|
|
case YHPN_IMAGEVIEW:
|
|
|
str = @"IMAGE";
|
|
|
break;
|
|
|
case YHPN_BUTTON:
|
|
|
str = @"BUTTON";
|
|
|
break;
|
|
|
case YHPN_GESTURERECOGNIZER:
|
|
|
str = @"GESTURERECOGNIZER";
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
-(NSString *)getDataType:(YHEventReportTrackDataType)type{
|
|
|
NSString *str = @"";
|
|
|
|
|
|
switch (type) {
|
|
|
case YHEventReportTrackDataTypeStart:
|
|
|
str = @"start";
|
|
|
break;
|
|
|
case YHEventReportTrackDataTypeDestory:
|
|
|
str = @"destory";
|
|
|
break;
|
|
|
case YHEventReportTrackDataTypeStop:
|
|
|
str = @"stop";
|
|
|
break;
|
|
|
case YHEventReportTrackDataTypeHeartbeat:
|
|
|
str = @"hb";
|
|
|
break;
|
|
|
case YHEventReportTrackDataTypeNONE:
|
|
|
str = @"realTime";
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
- (void)refreshPushStatus
|
|
|
{
|
...
|
...
|
@@ -308,8 +288,7 @@ |
|
|
- (void)handleMemoryWarning
|
|
|
{
|
|
|
if (self.mode == YHEventReportStrategyInterval) {
|
|
|
@synchronized (self) {
|
|
|
//[self.eventCacheArray removeAllObjects];
|
|
|
@synchronized (self.performanceCacheArray) {
|
|
|
[self.performanceCacheArray removeAllObjects];
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -317,26 +296,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,27 +311,25 @@ |
|
|
{
|
|
|
[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) {
|
|
|
}];
|
|
|
//}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|