Authored by 张文文

添加上报字段和内容

... ... @@ -144,6 +144,7 @@ typedef NS_ENUM(NSInteger, YHEventReportPointName) {
YHPN_BUSINESS_UFO_SELL,//BUSINESS_UFO_SELL
YHPN_BUSINESS_UFO_BUY,//BUSINESS_UFO_BUY
YHPN_BUSINESS_UFO_VIDEO_TRAFFIC,//BUSINESS_UFO_VIDEO_TRAFFIC
};
... ... @@ -171,7 +172,8 @@ typedef NS_ENUM(NSInteger, YHPointType) {
YHPT_BUSINESS,
YHPT_PERFORMANCE,
YHPT_AD,
YHPT_APPTARGET
YHPT_APPTARGET,
YHPT_UFOBUSINESS,
};
#define YHEventReportDebugModeEnableKey @"YHEventReportDebugModeEnableKey"
... ...
... ... @@ -289,6 +289,9 @@
case YHPN_APPFPS:
str = @"FPS";
break;
case YHPN_BUSINESS_UFO_VIDEO_TRAFFIC:
str = @"UFO_BUSINESS_VIDEO_TRAFFIC";
break;
default:
break;
}
... ... @@ -329,6 +332,9 @@
case YHPT_APPTARGET:
str = @"APPTARGET";
break;
case YHPT_UFOBUSINESS:
str = @"UFO_BUSINESS";
break;
default:
break;
}
... ...
... ... @@ -12,12 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface YH_VideoFlowMonitor : NSObject
+ (YH_VideoFlowMonitor *)sharedInstance;
- (void)startFlowMonitor;
- (void)stopFlowMonitor;
- (void)enterForegroundMonitor;
- (void)enterBackgroundMonitor;
@end
... ...
... ... @@ -7,6 +7,7 @@
//
#import "YH_VideoFlowMonitor.h"
#import "YHEventReport.h"
#import <mach/mach.h>
#include <ifaddrs.h>
#include <net/if.h>
... ... @@ -24,15 +25,6 @@
@implementation YH_VideoFlowMonitor
+ (YH_VideoFlowMonitor *)sharedInstance {
static YH_VideoFlowMonitor *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[YH_VideoFlowMonitor alloc] init];
});
return sharedInstance;
}
- (instancetype)init {
if ([super init]) {
if (self) {
... ... @@ -40,6 +32,9 @@
_finalValue = 0;
_backValue = 0;
_foreValue = 0;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidEnterBackGround) name:UIApplicationDidEnterBackgroundNotification object:nil];
}
}
... ... @@ -48,22 +43,29 @@
- (void)startFlowMonitor {
_originValue = [self transferNetFlow];
}
- (void)stopFlowMonitor {
_finalValue = [self transferNetFlow];
int64_t lastValue = _finalValue - _originValue - (_foreValue - _backValue);
NSLog(@"lastValue:%lld", lastValue);
NSString *trafficBytes = [NSString stringWithFormat:@"%lld", lastValue];
NSString *videoUrl = [[NSUserDefaults standardUserDefaults] objectForKey:@"UFO_VideoUrl"];
NSString *fromPage = [[NSUserDefaults standardUserDefaults] objectForKey:@"UFO_FromPage"];
NSDictionary *trafficDict = @{ @"url" : videoUrl?videoUrl:@"",
@"traffic" : trafficBytes?trafficBytes:@"",
@"fromPage" : fromPage?fromPage:@""
};
[[YHEventReport sharedInstance] reportWithPointType:YHPT_UFOBUSINESS pointName:YHPN_BUSINESS_UFO_VIDEO_TRAFFIC parameters:trafficDict];
}
- (void)enterBackgroundMonitor {
_backValue = [self transferNetFlow];
- (void)appBecomeActive {
_foreValue = [self transferNetFlow];
}
- (void)enterForegroundMonitor {
_foreValue = [self transferNetFlow];
- (void)appDidEnterBackGround {
_backValue = [self transferNetFlow];
}
- (int64_t)transferNetFlow {
... ... @@ -111,6 +113,5 @@
}
@end
... ...