Commit 7b79a83e authored by 乔金柱's avatar 乔金柱

Merge branch 'jql/phobos' into 'master'

重构埋点库

See merge request !42
parents 3d867177 9adf3bfc
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>classNames</key>
<dict>
<key>GMPhobosUtilTest</key>
<dict>
<key>testDataCompressPerformance</key>
<dict>
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.000579</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</plist>
...@@ -35,6 +35,37 @@ ...@@ -35,6 +35,37 @@
<string>com.apple.platform.iphonesimulator</string> <string>com.apple.platform.iphonesimulator</string>
</dict> </dict>
</dict> </dict>
<key>D343427D-396A-4DA4-A74B-7C92AD89F7A7</key>
<dict>
<key>localComputer</key>
<dict>
<key>busSpeedInMHz</key>
<integer>100</integer>
<key>cpuCount</key>
<integer>1</integer>
<key>cpuKind</key>
<string>Intel Core i7</string>
<key>cpuSpeedInMHz</key>
<integer>2300</integer>
<key>logicalCPUCoresPerPackage</key>
<integer>8</integer>
<key>modelCode</key>
<string>MacBookPro11,2</string>
<key>physicalCPUCoresPerPackage</key>
<integer>4</integer>
<key>platformIdentifier</key>
<string>com.apple.platform.macosx</string>
</dict>
<key>targetArchitecture</key>
<string>x86_64</string>
<key>targetDevice</key>
<dict>
<key>modelCode</key>
<string>iPhone10,5</string>
<key>platformIdentifier</key>
<string>com.apple.platform.iphonesimulator</string>
</dict>
</dict>
</dict> </dict>
</dict> </dict>
</plist> </plist>
...@@ -36,12 +36,11 @@ NSString *const MockCityId = @"beijing"; ...@@ -36,12 +36,11 @@ NSString *const MockCityId = @"beijing";
NSString *url = @"http://log.test.gengmei.cc/log/collect"; NSString *url = @"http://log.test.gengmei.cc/log/collect";
#endif #endif
[GMCache removeObjectAtDocumentPathWithkey:PhobosCacheKey]; [GMCache removeObjectAtDocumentPathWithkey:PhobosCacheKey];
Phobos *phobos = [Phobos clientWithAppName:MockAppName channelId:MockChannelId]; [Phobos clientWithAppName:MockAppName channelId:MockChannelId];
phobos.serverAPI = url; Phobos.sharedClient.serverAPI = url;
[phobos setLogEnabled:NO]; // 调试打Log模式,看情况开启 [Phobos.sharedClient setLogEnabled:NO]; // 调试打Log模式,看情况开启
phobos.signingType = PhobosSigningTypeDebug; Phobos.sharedClient.signingType = PhobosSigningTypeDebug;
phobos.userId = @""; Phobos.sharedClient.userId = @"";
[Phobos setSharedClient:phobos];
NSString *inDate = [PhobosUtil currentTime]; NSString *inDate = [PhobosUtil currentTime];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
......
...@@ -35,9 +35,9 @@ PODS: ...@@ -35,9 +35,9 @@ PODS:
- GMKit/Protocol (1.1.3): - GMKit/Protocol (1.1.3):
- Masonry (= 1.1.0) - Masonry (= 1.1.0)
- SDWebImage (= 3.7.6) - SDWebImage (= 3.7.6)
- GMPhobos (1.2.9): - GMPhobos (1.3.0):
- GMCache (= 0.2.3) - GMCache
- GMKit (= 1.1.3) - GMKit
- Masonry (1.1.0) - Masonry (1.1.0)
- SDWebImage (3.7.6): - SDWebImage (3.7.6):
- SDWebImage/Core (= 3.7.6) - SDWebImage/Core (= 3.7.6)
...@@ -63,7 +63,7 @@ EXTERNAL SOURCES: ...@@ -63,7 +63,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
GMCache: 09a3029c96fe130e3a21faef70b3d9d2ce92d639 GMCache: 09a3029c96fe130e3a21faef70b3d9d2ce92d639
GMKit: 35f788243cceeddf3e13c5226b3ea0b5e08e2117 GMKit: 35f788243cceeddf3e13c5226b3ea0b5e08e2117
GMPhobos: 89d9654a951819abc9285b392e055278d10877f2 GMPhobos: c1dd33760f8d4243e6bf562a115899e66c6ec7d2
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
SDWebImage: c325cf02c30337336b95beff20a13df489ec0ec9 SDWebImage: c325cf02c30337336b95beff20a13df489ec0ec9
TMCache: 95ebcc9b3c7e90fb5fd8fc3036cba3aa781c9bed TMCache: 95ebcc9b3c7e90fb5fd8fc3036cba3aa781c9bed
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
// //
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
#import <GMPhobos/Phobos.h>
#import "PhobosUtil.h" #import "PhobosUtil.h"
@import GMPhobos;
@interface GMPhobosUtilTest : XCTestCase @interface GMPhobosUtilTest : XCTestCase
@property (nonatomic, retain) NSMutableArray *mockArray; @property (nonatomic, retain) NSMutableArray *mockArray;
...@@ -19,7 +19,7 @@ ...@@ -19,7 +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 setSharedClient:[Phobos clientWithAppName:@"gengmei_test" channelId:@"AppStore"]]; [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++) {
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "GMPhobos" s.name = "GMPhobos"
s.version = "1.3.0" s.version = "1.3.1"
s.summary = "GM statistic data sdk" s.summary = "GM statistic data sdk"
s.description = <<-DESC s.description = <<-DESC
......
...@@ -33,13 +33,14 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) { ...@@ -33,13 +33,14 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
*/ */
+ (Phobos *)clientWithAppName:(NSString *)appName channelId:(NSString *)channelId; + (Phobos *)clientWithAppName:(NSString *)appName channelId:(NSString *)channelId;
+ (instancetype)sharedClient; + (instancetype) alloc __attribute__((deprecated));
- (instancetype) init __attribute__((deprecated));
+ (void)setSharedClient:(Phobos *)client; + (instancetype) new __attribute__((deprecated));
#pragma mark - SDK配置 #pragma mark - SDK配置
@property (class, readonly, strong) Phobos *sharedClient;
// Phobos在处理业务端传递来的参数时会检查是否某个value为空,如果为空会调用这个block以通知业务层,业务层可以上报这个异常,以助解决问题 // Phobos在处理业务端传递来的参数时会检查是否某个value为空,如果为空会调用这个block以通知业务层,业务层可以上报这个异常,以助解决问题
@property(nonatomic, copy) void (^captureNullExpection) (NSString *eventId, NSDictionary *info); @property(nonatomic, copy) void (^captureNullExpection) (NSString *eventId, NSDictionary *info);
...@@ -133,12 +134,12 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) { ...@@ -133,12 +134,12 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
* *
* @since 0.0.1 * @since 0.0.1
*/ */
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes; + (void)track:(NSString *)eventName attributes:(NSDictionary *)attributes;
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow; + (void)track:(NSString *)eventName attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow;
+ (void)track:(NSString *)eventId; + (void)track:(NSString *)eventName;
/** /**
* @brief 自定义事件,数量统计 7730 精准曝光. * @brief 自定义事件,数量统计 7730 精准曝光/数据链路.
* *
* @param eventId 事件Id * @param eventId 事件Id
* @attributes 参数 * @attributes 参数
...@@ -146,9 +147,9 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) { ...@@ -146,9 +147,9 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
* @currentAPI 当前传过来的API * @currentAPI 当前传过来的API
* @ * @
*/ */
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes currentAPI:(NSString *)currentAPI; + (void)track:(NSString *)eventName attributes:(NSDictionary *)attributes currentAPI:(NSString *)currentAPI;
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow currentAPI:(NSString *)currentAPI; + (void)track:(NSString *)eventName attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow currentAPI:(NSString *)currentAPI;
+ (void)track:(NSString *)eventId currentAPI:(NSString *)currentAPI; + (void)track:(NSString *)eventName currentAPI:(NSString *)currentAPI;
/** /**
* @author 翟国钧, 16-02-03 16:02:30 * @author 翟国钧, 16-02-03 16:02:30
...@@ -183,5 +184,48 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) { ...@@ -183,5 +184,48 @@ 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 PhobosCacheKey @"PhobosCacheKey" //存放持久化埋点数据的key #define PhobosNormalCacheKey @"PhobosNormalCacheKey" //存放持久化埋点数据的key
#define PhobosTempCacheKey @"PhobosTempCacheKey" //临时存放待发送埋点数据的key #define PhobosImmediatelyCacheKey @"PhobosImmediatelyCacheKey" //存放持久化实时埋点数据的key
#define PhobosShardCount 50 //收集数据分段发送的个数 #define PhobosShardCount 50 //收集数据分段发送的个数
......
...@@ -127,6 +127,8 @@ ...@@ -127,6 +127,8 @@
//没有错误,返回正确; //没有错误,返回正确;
if (success) { if (success) {
success(200); success(200);
} else {
success(error.code);
} }
} }
}]; }];
...@@ -150,6 +152,8 @@ ...@@ -150,6 +152,8 @@
//没有错误,返回正确; //没有错误,返回正确;
if (success) { if (success) {
success(200); success(200);
} else {
success(error.code);
} }
} }
}]; }];
......
...@@ -25,5 +25,4 @@ ...@@ -25,5 +25,4 @@
*/ */
- (void)initReferrerTabName; - (void)initReferrerTabName;
@end @end
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