Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
GMPhobos
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
GMPhobos
Commits
2814756f
Commit
2814756f
authored
Jul 31, 2019
by
井庆林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
埋点库重构、重写单元测试
parent
eea2869b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
11 deletions
+49
-11
GMViewController.m
Example/GMPhobos/GMViewController.m
+1
-1
GMPhobosUtilTest.m
Example/Tests/GMPhobosUtilTest.m
+4
-3
GMPhotoTest.m
Example/Tests/GMPhotoTest.m
+0
-0
Phobos.h
GMPhobos/Classes/Phobos.h
+42
-4
Phobos.m
GMPhobos/Classes/Phobos.m
+0
-0
PhobosConfig.h
GMPhobos/Classes/PhobosConfig.h
+2
-3
No files found.
Example/GMPhobos/GMViewController.m
View file @
2814756f
...
...
@@ -41,7 +41,7 @@ NSString *const MockCityId = @"beijing";
[
phobos
setLogEnabled
:
NO
];
// 调试打Log模式,看情况开启
phobos
.
signingType
=
PhobosSigningTypeDebug
;
phobos
.
userId
=
@""
;
[
Phobos
setSharedClient
:
phobos
];
//
[Phobos setSharedClient:phobos];
NSString
*
inDate
=
[
PhobosUtil
currentTime
];
NSMutableDictionary
*
dict
=
[[
NSMutableDictionary
alloc
]
init
];
...
...
Example/Tests/GMPhobosUtilTest.m
View file @
2814756f
...
...
@@ -19,7 +19,8 @@
-
(
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 setSharedClient:[Phobos clientWithAppName:@"gengmei_test" channelId:@"AppStore"]];
[
Phobos
sharedClient
].
serverAPI
=
url
;
_mockArray
=
[[
NSMutableArray
alloc
]
init
];
for
(
int
i
=
0
;
i
<
50
;
i
++
)
{
...
...
@@ -63,9 +64,9 @@
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
@"Testing Async Method Works!"
];
NSData
*
mockData
=
[
self
encodeAndCompressArray
:
_mockArray
];
[
PhobosUtil
sendData
:
mockData
success
:
^
(
NSInteger
code
)
{
[
PhobosUtil
sendData
:
mockData
success
:
^
(
BOOL
success
)
{
[
expectation
fulfill
];
XCTAssertEqual
(
code
,
200
);
XCTAssertEqual
(
success
,
YES
);
}];
//如果超时,则认为发送失败
...
...
Example/Tests/GMPhotoTest.m
View file @
2814756f
This diff is collapsed.
Click to expand it.
GMPhobos/Classes/Phobos.h
View file @
2814756f
...
...
@@ -31,13 +31,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
);
...
...
@@ -181,4 +182,41 @@ 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
;
/** 获取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
GMPhobos/Classes/Phobos.m
View file @
2814756f
This diff is collapsed.
Click to expand it.
GMPhobos/Classes/PhobosConfig.h
View file @
2814756f
...
...
@@ -18,9 +18,8 @@
#define PhobosHaveOpenApp @"PhobosHaveOpenApp" //是否打开过APP
#define PhobosBeginTime @"PhobosBeginTime" //记录APP打开|从后台启动时的时间戳
#define PhobosEndTime @"PhobosEndTime" //记录APP退出|退到后台时的时间戳
#define PhobosNormalCacheKey @"PhobosNormalCacheKey" //存放持久化埋点数据的key
#define PhobosRealTimeCacheKeys @"PhobosRealTimeCacheKey" //存放持久化实时埋点数据的key
#define PhobosTempCacheKey @"PhobosTempCacheKey" //临时存放待发送埋点数据的key
#define PhobosNormalCacheKey @"PhobosNormalCacheKey" //存放持久化埋点数据的key
#define PhobosImmediatelyCacheKey @"PhobosImmediatelyCacheKey" //存放持久化实时埋点数据的key
#define PhobosShardCount 50 //收集数据分段发送的个数
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment