Commit c9810285 authored by 王伟明's avatar 王伟明

Merge branch 'rmc/changeSendNow' into 'master'

埋点库修改实时上报

See merge request !76
parents bcb1602a 6d49a4cb
......@@ -38,6 +38,8 @@ NS_ASSUME_NONNULL_BEGIN
/** 用于Phobos库从old更新到new使用,在全量之后删除相关逻辑 */
@property (nonatomic, assign) BOOL isGray;
@property (nonatomic, assign) BOOL isGraySendNow;//控制实时上报
// Phobos在处理业务端传递来的参数时会检查是否某个value为空,如果为空会调用这个block以通知业务层,业务层可以上报这个异常,以助解决问题
@property(nonatomic, copy) void (^captureNullExpection) (NSString *eventId, NSDictionary *info);
......
......@@ -10,7 +10,7 @@
#import "NewPhobos.h"
static Phobos *sharedClient = nil;
static BOOL isGray = NO;
static BOOL isGray = YES;
@interface Phobos ()
......@@ -46,7 +46,12 @@ static BOOL isGray = NO;
- (instancetype)initWithAppName:(NSString *)appName channelId:(NSString *)channelId{
if (self = [super init]) {
//判断 PhobosGray 是否为空值
if ([[NSUserDefaults standardUserDefaults] objectForKey:PhobosGray] == nil) {
isGray = YES;
}else{
isGray = [[[NSUserDefaults standardUserDefaults] objectForKey:PhobosGray] boolValue];
}
// isGray在config接口获取,会保存在NSUserDefaults的PhobosGray中,当次不使用,在下一次冷启动通过该灰度,初始化埋点库
if (isGray) {
_rePhobos = [NewPhobos clientWithAppName:appName channelId:channelId];
......@@ -79,7 +84,16 @@ static BOOL isGray = NO;
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes {
if (isGray) {
[NewPhobos track:eventId attributes:attributes];
//埋点处如果没传sendNow 取灰度字段去控制
if ([NewPhobos sharedClient].isGraySendNow == nil) {
[NewPhobos track:eventId attributes:attributes sendNow:YES];
}else{
if ([NewPhobos sharedClient].isGraySendNow == YES) {
[NewPhobos track:eventId attributes:attributes sendNow:YES];
}else{
[NewPhobos track:eventId attributes:attributes sendNow:NO];
}
}
} else {
[OldPhobos track:eventId attributes:attributes];
}
......
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