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 @@
<string>com.apple.platform.iphonesimulator</string>
</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>
</plist>
......@@ -36,12 +36,11 @@ NSString *const MockCityId = @"beijing";
NSString *url = @"http://log.test.gengmei.cc/log/collect";
#endif
[GMCache removeObjectAtDocumentPathWithkey:PhobosCacheKey];
Phobos *phobos = [Phobos clientWithAppName:MockAppName channelId:MockChannelId];
phobos.serverAPI = url;
[phobos setLogEnabled:NO]; // 调试打Log模式,看情况开启
phobos.signingType = PhobosSigningTypeDebug;
phobos.userId = @"";
[Phobos setSharedClient:phobos];
[Phobos clientWithAppName:MockAppName channelId:MockChannelId];
Phobos.sharedClient.serverAPI = url;
[Phobos.sharedClient setLogEnabled:NO]; // 调试打Log模式,看情况开启
Phobos.sharedClient.signingType = PhobosSigningTypeDebug;
Phobos.sharedClient.userId = @"";
NSString *inDate = [PhobosUtil currentTime];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
......
......@@ -35,9 +35,9 @@ PODS:
- GMKit/Protocol (1.1.3):
- Masonry (= 1.1.0)
- SDWebImage (= 3.7.6)
- GMPhobos (1.2.9):
- GMCache (= 0.2.3)
- GMKit (= 1.1.3)
- GMPhobos (1.3.0):
- GMCache
- GMKit
- Masonry (1.1.0)
- SDWebImage (3.7.6):
- SDWebImage/Core (= 3.7.6)
......@@ -63,7 +63,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
GMCache: 09a3029c96fe130e3a21faef70b3d9d2ce92d639
GMKit: 35f788243cceeddf3e13c5226b3ea0b5e08e2117
GMPhobos: 89d9654a951819abc9285b392e055278d10877f2
GMPhobos: c1dd33760f8d4243e6bf562a115899e66c6ec7d2
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
SDWebImage: c325cf02c30337336b95beff20a13df489ec0ec9
TMCache: 95ebcc9b3c7e90fb5fd8fc3036cba3aa781c9bed
......
......@@ -7,8 +7,8 @@
//
#import <XCTest/XCTest.h>
#import <GMPhobos/Phobos.h>
#import "PhobosUtil.h"
@import GMPhobos;
@interface GMPhobosUtilTest : XCTestCase
@property (nonatomic, retain) NSMutableArray *mockArray;
......@@ -19,7 +19,7 @@
- (void)setUp {
[super setUp];
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;
_mockArray = [[NSMutableArray alloc] init];
for (int i=0; i<50; i++) {
......
This diff is collapsed.
......@@ -8,7 +8,7 @@
Pod::Spec.new do |s|
s.name = "GMPhobos"
s.version = "1.3.0"
s.version = "1.3.1"
s.summary = "GM statistic data sdk"
s.description = <<-DESC
......
......@@ -33,13 +33,14 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
*/
+ (Phobos *)clientWithAppName:(NSString *)appName channelId:(NSString *)channelId;
+ (instancetype)sharedClient;
+ (void)setSharedClient:(Phobos *)client;
+ (instancetype) alloc __attribute__((deprecated));
- (instancetype) init __attribute__((deprecated));
+ (instancetype) new __attribute__((deprecated));
#pragma mark - SDK配置
@property (class, readonly, strong) Phobos *sharedClient;
// Phobos在处理业务端传递来的参数时会检查是否某个value为空,如果为空会调用这个block以通知业务层,业务层可以上报这个异常,以助解决问题
@property(nonatomic, copy) void (^captureNullExpection) (NSString *eventId, NSDictionary *info);
......@@ -133,12 +134,12 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
*
* @since 0.0.1
*/
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes;
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow;
+ (void)track:(NSString *)eventId;
+ (void)track:(NSString *)eventName attributes:(NSDictionary *)attributes;
+ (void)track:(NSString *)eventName attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow;
+ (void)track:(NSString *)eventName;
/**
* @brief 自定义事件,数量统计 7730 精准曝光.
* @brief 自定义事件,数量统计 7730 精准曝光/数据链路.
*
* @param eventId 事件Id
* @attributes 参数
......@@ -146,9 +147,9 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
* @currentAPI 当前传过来的API
* @
*/
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes currentAPI:(NSString *)currentAPI;
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow currentAPI:(NSString *)currentAPI;
+ (void)track:(NSString *)eventId currentAPI:(NSString *)currentAPI;
+ (void)track:(NSString *)eventName attributes:(NSDictionary *)attributes currentAPI:(NSString *)currentAPI;
+ (void)track:(NSString *)eventName attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow currentAPI:(NSString *)currentAPI;
+ (void)track:(NSString *)eventName currentAPI:(NSString *)currentAPI;
/**
* @author 翟国钧, 16-02-03 16:02:30
......@@ -183,5 +184,48 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
*/
- (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
NS_ASSUME_NONNULL_END
This diff is collapsed.
......@@ -18,8 +18,8 @@
#define PhobosHaveOpenApp @"PhobosHaveOpenApp" //是否打开过APP
#define PhobosBeginTime @"PhobosBeginTime" //记录APP打开|从后台启动时的时间戳
#define PhobosEndTime @"PhobosEndTime" //记录APP退出|退到后台时的时间戳
#define PhobosCacheKey @"PhobosCacheKey" //存放持久化埋点数据的key
#define PhobosTempCacheKey @"PhobosTempCacheKey" //临时存放待发送埋点数据的key
#define PhobosNormalCacheKey @"PhobosNormalCacheKey" //存放持久化埋点数据的key
#define PhobosImmediatelyCacheKey @"PhobosImmediatelyCacheKey" //存放持久化实时埋点数据的key
#define PhobosShardCount 50 //收集数据分段发送的个数
......
......@@ -127,6 +127,8 @@
//没有错误,返回正确;
if (success) {
success(200);
} else {
success(error.code);
}
}
}];
......@@ -150,6 +152,8 @@
//没有错误,返回正确;
if (success) {
success(200);
} else {
success(error.code);
}
}
}];
......
......@@ -25,5 +25,4 @@
*/
- (void)initReferrerTabName;
@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