Commit 3746b2e9 authored by jz's avatar jz

还原 phobos 1.3.0 代码

parent 2a751ef1
...@@ -33,13 +33,12 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) { ...@@ -33,13 +33,12 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
*/ */
+ (Phobos *)clientWithAppName:(NSString *)appName channelId:(NSString *)channelId; + (Phobos *)clientWithAppName:(NSString *)appName channelId:(NSString *)channelId;
+ (instancetype) alloc __attribute__((deprecated)); + (instancetype)sharedClient;
- (instancetype) init __attribute__((deprecated));
+ (instancetype) new __attribute__((deprecated)); + (void)setSharedClient:(Phobos *)client;
#pragma mark - SDK配置
@property (class, readonly, strong) Phobos *sharedClient; #pragma mark - SDK配置
// Phobos在处理业务端传递来的参数时会检查是否某个value为空,如果为空会调用这个block以通知业务层,业务层可以上报这个异常,以助解决问题 // Phobos在处理业务端传递来的参数时会检查是否某个value为空,如果为空会调用这个block以通知业务层,业务层可以上报这个异常,以助解决问题
@property(nonatomic, copy) void (^captureNullExpection) (NSString *eventId, NSDictionary *info); @property(nonatomic, copy) void (^captureNullExpection) (NSString *eventId, NSDictionary *info);
...@@ -134,12 +133,12 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) { ...@@ -134,12 +133,12 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
* *
* @since 0.0.1 * @since 0.0.1
*/ */
+ (void)track:(NSString *)eventName attributes:(NSDictionary *)attributes; + (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes;
+ (void)track:(NSString *)eventName attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow; + (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow;
+ (void)track:(NSString *)eventName; + (void)track:(NSString *)eventId;
/** /**
* @brief 自定义事件,数量统计 7730 精准曝光/数据链路. * @brief 自定义事件,数量统计 7730 精准曝光.
* *
* @param eventId 事件Id * @param eventId 事件Id
* @attributes 参数 * @attributes 参数
...@@ -147,9 +146,9 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) { ...@@ -147,9 +146,9 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
* @currentAPI 当前传过来的API * @currentAPI 当前传过来的API
* @ * @
*/ */
+ (void)track:(NSString *)eventName attributes:(NSDictionary *)attributes currentAPI:(NSString *)currentAPI; + (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes currentAPI:(NSString *)currentAPI;
+ (void)track:(NSString *)eventName attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow currentAPI:(NSString *)currentAPI; + (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow currentAPI:(NSString *)currentAPI;
+ (void)track:(NSString *)eventName currentAPI:(NSString *)currentAPI; + (void)track:(NSString *)eventId currentAPI:(NSString *)currentAPI;
/** /**
* @author 翟国钧, 16-02-03 16:02:30 * @author 翟国钧, 16-02-03 16:02:30
...@@ -184,48 +183,5 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) { ...@@ -184,48 +183,5 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
*/ */
- (void)simulativePV:(NSString *)pageName businessId:(NSString *)bid referer:(NSString *)referer; - (void)simulativePV:(NSString *)pageName businessId:(NSString *)bid referer:(NSString *)referer;
@end
@interface Phobos (UtilTest)
/** 获取所有非立即发送埋点数量 */
+ (NSInteger)normalPhobosCount;
/** 获取所有非立即发送埋点数据 */
+ (NSDictionary *)normalPhobosData;
/** 获取url的非立即发送埋点数量 */
+ (NSInteger)normalPhobosCountForURL:(NSString *)url;
/** 获取serverAPI的非立即发送埋点数据 */
+ (NSArray *)normalPhobosDataForServerAPI;
/** 获取url的非立即发送埋点数据 */
+ (NSArray *)normalPhobosDataForURL:(NSString *)url;
/** 获取所有立即发送埋点数据 */
+ (NSDictionary *)immediatelyPhobosData;
/** 获取serverAPI的立即发送埋点数据 */
+ (NSArray *)immediatelyPhobosForServerAPI;
/** 获取url的立即发送埋点数据 */
+ (NSArray *)immediatelyPhobosDataForURL:(NSString *)url;
/** 获取url的立即发送埋点数量 */
+ (NSUInteger)immediatelyPhobosCountForURL:(NSString *)url;
/** 清除非立即发送埋点数据缓存 */
+ (void)removeAllNormalPhobosData;
/** 清除立即发送埋点数据缓存 */
+ (void)removeAllImmediatelyPhobosData;
/** 获取将要发送的数据 */
@property (nonatomic, copy) void (^phobosSendDataBlock)(NSArray *datas);
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
This diff is collapsed.
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#define PhobosHaveOpenApp @"PhobosHaveOpenApp" //是否打开过APP #define PhobosHaveOpenApp @"PhobosHaveOpenApp" //是否打开过APP
#define PhobosBeginTime @"PhobosBeginTime" //记录APP打开|从后台启动时的时间戳 #define PhobosBeginTime @"PhobosBeginTime" //记录APP打开|从后台启动时的时间戳
#define PhobosEndTime @"PhobosEndTime" //记录APP退出|退到后台时的时间戳 #define PhobosEndTime @"PhobosEndTime" //记录APP退出|退到后台时的时间戳
#define PhobosNormalCacheKey @"PhobosNormalCacheKey" //存放持久化埋点数据的key #define PhobosCacheKey @"PhobosCacheKey" //存放持久化埋点数据的key
#define PhobosImmediatelyCacheKey @"PhobosImmediatelyCacheKey" //存放持久化实时埋点数据的key #define PhobosTempCacheKey @"PhobosTempCacheKey" //临时存放待发送埋点数据的key
#define PhobosShardCount 50 //收集数据分段发送的个数 #define PhobosShardCount 50 //收集数据分段发送的个数
......
...@@ -75,5 +75,11 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -75,5 +75,11 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
@property (nonatomic, copy) NSString *isPush; @property (nonatomic, copy) NSString *isPush;
/**
获取上一个页面链路的page_name link by 7.20.0 如果有此页面有page_name则添加 , 没有添加""
*/
@property (nonatomic, copy) NSArray *referrerLink;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -127,8 +127,6 @@ ...@@ -127,8 +127,6 @@
//没有错误,返回正确; //没有错误,返回正确;
if (success) { if (success) {
success(200); success(200);
} else {
success(error.code);
} }
} }
}]; }];
...@@ -152,8 +150,6 @@ ...@@ -152,8 +150,6 @@
//没有错误,返回正确; //没有错误,返回正确;
if (success) { if (success) {
success(200); success(200);
} else {
success(error.code);
} }
} }
}]; }];
......
...@@ -15,6 +15,11 @@ ...@@ -15,6 +15,11 @@
*/ */
- (void)initReferer; - (void)initReferer;
/**
// // 适用于链路中页面浏览事件的统计 添加 refererLink 参数
*/
- (void)initRefererLink;
/** /**
此方法在onPvStart时调用,如果发现已经有值了,不会给referrerId再次赋值 此方法在onPvStart时调用,如果发现已经有值了,不会给referrerId再次赋值
*/ */
...@@ -25,4 +30,5 @@ ...@@ -25,4 +30,5 @@
*/ */
- (void)initReferrerTabName; - (void)initReferrerTabName;
@end @end
...@@ -45,6 +45,52 @@ ...@@ -45,6 +45,52 @@
} }
} }
// 适用于链路中页面浏览事件的统计 添加 refererLink 参数
- (void)initRefererLink {
if ([self isKindOfClass:[UIViewController class]]) {
// 分present与navigation两种情况
UIViewController *me = (UIViewController *)self;
if (me.isPush.intValue) { // 如果是推送进来的,结果页面的referrerLink 为空数组, 此处添加过滤。
objc_setAssociatedObject(self, @selector(referrerLink), @[], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
return;
}
if (me.presentingViewController != nil) {
// app全局只有一个navigation,发现此时用navigation.topViewController presentViewController时,最终使用的是navigation弹出的
// 所以此处要判断,如果是navigation弹出,最后还是要定位到topViewController
if ([me.presentingViewController isKindOfClass:[UINavigationController class]]) {
UIViewController *top = ((UINavigationController *)me.presentingViewController).topViewController;
NSMutableArray *tempLink = [NSMutableArray arrayWithArray:top.referrerLink];
[tempLink addObject:top.pageName];
objc_setAssociatedObject(self, @selector(referrerLink), tempLink, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
} else {
NSMutableArray *tempLink = [NSMutableArray arrayWithArray:me.presentingViewController.referrerLink];
[tempLink addObject:me.presentingViewController.pageName];
objc_setAssociatedObject(self, @selector(referrerLink), tempLink, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
} else {
NSArray *navigationPool = ((UIViewController *)self).navigationController.viewControllers;
NSInteger refererIndex = navigationPool.count - 2;
if (refererIndex < 0 ) {
return ;
}
UIViewController *controller = navigationPool[refererIndex];
NSMutableArray *tempLink = [NSMutableArray arrayWithArray:controller.referrerLink];
[tempLink addObject:controller.pageName];
objc_setAssociatedObject(self, @selector(referrerLink), tempLink, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
}
}
- (void)setReferrerLink:(NSArray *)referrerLink {
objc_setAssociatedObject(self, @selector(referrerLink), referrerLink, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
-(NSArray *)referrerLink {
NSArray *referrerLink = objc_getAssociatedObject(self, @selector(referrerLink));
return referrerLink;
}
/** /**
此方法在onPvStart时调用,给referrerTabName赋值 此方法在onPvStart时调用,给referrerTabName赋值
*/ */
......
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