Commit e56ff462 authored by 乔金柱's avatar 乔金柱

Merge branch 'revert-e58799c9' into 'master'

Revert "Merge branch 'jql/newPhobos' into 'master'"

See merge request !40
parents e58799c9 954e3150
...@@ -41,7 +41,7 @@ NSString *const MockCityId = @"beijing"; ...@@ -41,7 +41,7 @@ NSString *const MockCityId = @"beijing";
[phobos setLogEnabled:NO]; // 调试打Log模式,看情况开启 [phobos setLogEnabled:NO]; // 调试打Log模式,看情况开启
phobos.signingType = PhobosSigningTypeDebug; phobos.signingType = PhobosSigningTypeDebug;
phobos.userId = @""; phobos.userId = @"";
// [Phobos setSharedClient:phobos]; [Phobos setSharedClient:phobos];
NSString *inDate = [PhobosUtil currentTime]; NSString *inDate = [PhobosUtil currentTime];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
- (void)setUp { - (void)setUp {
[super setUp]; [super setUp];
NSString *url = @"http://log.test.gengmei.cc/log/collect"; NSString *url = @"http://log.test.gengmei.cc/log/collect";
[Phobos clientWithAppName:@"gengmei_test" channelId:@"AppStore"]; [Phobos setSharedClient:[Phobos clientWithAppName:@"gengmei_test" channelId:@"AppStore"]];
// [Phobos setSharedClient:[Phobos clientWithAppName:@"gengmei_test" channelId:@"AppStore"]];
[Phobos sharedClient].serverAPI = url; [Phobos sharedClient].serverAPI = url;
_mockArray = [[NSMutableArray alloc] init]; _mockArray = [[NSMutableArray alloc] init];
for (int i=0; i<50; i++) { for (int i=0; i<50; i++) {
...@@ -64,9 +63,9 @@ ...@@ -64,9 +63,9 @@
XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method Works!"]; XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method Works!"];
NSData *mockData = [self encodeAndCompressArray:_mockArray]; NSData *mockData = [self encodeAndCompressArray:_mockArray];
[PhobosUtil sendData:mockData success:^(BOOL success) { [PhobosUtil sendData:mockData success:^(NSInteger code) {
[expectation fulfill]; [expectation fulfill];
XCTAssertEqual(success, YES); XCTAssertEqual(code, 200);
}]; }];
//如果超时,则认为发送失败 //如果超时,则认为发送失败
......
This diff is collapsed.
...@@ -31,13 +31,12 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) { ...@@ -31,13 +31,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);
...@@ -132,12 +131,12 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) { ...@@ -132,12 +131,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 参数
...@@ -145,9 +144,9 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) { ...@@ -145,9 +144,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
...@@ -182,41 +181,4 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) { ...@@ -182,41 +181,4 @@ 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;
/** 获取url的非立即发送埋点数据 */
+ (NSArray *)normalPhobosDataForURL:(NSString *)url;
/** 获取所有立即发送埋点数据 */
+ (NSDictionary *)immediatelyPhobosData;
/** 获取url的立即发送埋点数据 */
+ (NSArray *)immediatelyPhobosDataForURL:(NSString *)url;
/** 获取url的立即发送埋点数量 */
+ (NSUInteger)immediatelyPhobosCountForURL:(NSString *)url;
/** 清除非立即发送埋点数据缓存 */
+ (void)removeAllNormalPhobosData;
/** 清除立即发送埋点数据缓存 */
+ (void)removeAllImmediatelyPhobosData;
/** 获取将要发送的数据 */
@property (nonatomic, copy) void (^phobosSendDataBlock)(NSArray *datas);
@end @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 //收集数据分段发送的个数
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
typedef void (^SendDataSuccessBlock)(BOOL success); typedef void (^SendDataSuccessBlock)(NSInteger code);
@interface PhobosUtil : NSObject @interface PhobosUtil : NSObject
......
...@@ -123,8 +123,11 @@ ...@@ -123,8 +123,11 @@
// sendAsynchronousRequest 在iOS9以后y被废除了 // sendAsynchronousRequest 在iOS9以后y被废除了
NSURLSession *session = [NSURLSession sharedSession]; NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (success) { if (!error) {
success(!error ? YES : NO); //没有错误,返回正确;
if (success) {
success(200);
}
} }
}]; }];
[dataTask resume]; [dataTask resume];
......
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