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
e58799c9
Commit
e58799c9
authored
Aug 01, 2019
by
乔金柱
1
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'jql/newPhobos' into 'master'
埋点库重构 See merge request
!39
parents
2e1dbac1
2814756f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
59 additions
and
23 deletions
+59
-23
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
+49
-11
Phobos.m
GMPhobos/Classes/Phobos.m
+0
-0
PhobosConfig.h
GMPhobos/Classes/PhobosConfig.h
+2
-2
PhobosUtil.h
GMPhobos/Classes/PhobosUtil.h
+1
-1
PhobosUtil.m
GMPhobos/Classes/PhobosUtil.m
+2
-5
No files found.
Example/GMPhobos/GMViewController.m
View file @
e58799c9
...
@@ -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
];
...
...
Example/Tests/GMPhobosUtilTest.m
View file @
e58799c9
...
@@ -19,7 +19,8 @@
...
@@ -19,7 +19,8 @@
-
(
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 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
++
)
{
...
@@ -63,9 +64,9 @@
...
@@ -63,9 +64,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
:
^
(
NSInteger
code
)
{
[
PhobosUtil
sendData
:
mockData
success
:
^
(
BOOL
success
)
{
[
expectation
fulfill
];
[
expectation
fulfill
];
XCTAssertEqual
(
code
,
200
);
XCTAssertEqual
(
success
,
YES
);
}];
}];
//如果超时,则认为发送失败
//如果超时,则认为发送失败
...
...
Example/Tests/GMPhotoTest.m
View file @
e58799c9
This diff is collapsed.
Click to expand it.
GMPhobos/Classes/Phobos.h
View file @
e58799c9
...
@@ -31,13 +31,14 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
...
@@ -31,13 +31,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
);
...
@@ -131,12 +132,12 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
...
@@ -131,12 +132,12 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
*
*
* @since 0.0.1
* @since 0.0.1
*/
*/
+
(
void
)
track
:(
NSString
*
)
event
Id
attributes
:(
NSDictionary
*
)
attributes
;
+
(
void
)
track
:(
NSString
*
)
event
Name
attributes
:(
NSDictionary
*
)
attributes
;
+
(
void
)
track
:(
NSString
*
)
event
Id
attributes
:(
NSDictionary
*
)
attributes
sendNow
:(
BOOL
)
sendNow
;
+
(
void
)
track
:(
NSString
*
)
event
Name
attributes
:(
NSDictionary
*
)
attributes
sendNow
:(
BOOL
)
sendNow
;
+
(
void
)
track
:(
NSString
*
)
event
Id
;
+
(
void
)
track
:(
NSString
*
)
event
Name
;
/**
/**
* @brief 自定义事件,数量统计 7730 精准曝光.
* @brief 自定义事件,数量统计 7730 精准曝光
/数据链路
.
*
*
* @param eventId 事件Id
* @param eventId 事件Id
* @attributes 参数
* @attributes 参数
...
@@ -144,9 +145,9 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
...
@@ -144,9 +145,9 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
* @currentAPI 当前传过来的API
* @currentAPI 当前传过来的API
* @
* @
*/
*/
+
(
void
)
track
:(
NSString
*
)
event
Id
attributes
:(
NSDictionary
*
)
attributes
currentAPI
:(
NSString
*
)
currentAPI
;
+
(
void
)
track
:(
NSString
*
)
event
Name
attributes
:(
NSDictionary
*
)
attributes
currentAPI
:(
NSString
*
)
currentAPI
;
+
(
void
)
track
:(
NSString
*
)
event
Id
attributes
:(
NSDictionary
*
)
attributes
sendNow
:(
BOOL
)
sendNow
currentAPI
:(
NSString
*
)
currentAPI
;
+
(
void
)
track
:(
NSString
*
)
event
Name
attributes
:(
NSDictionary
*
)
attributes
sendNow
:(
BOOL
)
sendNow
currentAPI
:(
NSString
*
)
currentAPI
;
+
(
void
)
track
:(
NSString
*
)
event
Id
currentAPI
:(
NSString
*
)
currentAPI
;
+
(
void
)
track
:(
NSString
*
)
event
Name
currentAPI
:(
NSString
*
)
currentAPI
;
/**
/**
* @author 翟国钧, 16-02-03 16:02:30
* @author 翟国钧, 16-02-03 16:02:30
...
@@ -181,4 +182,41 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
...
@@ -181,4 +182,41 @@ 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
GMPhobos/Classes/Phobos.m
View file @
e58799c9
This diff is collapsed.
Click to expand it.
GMPhobos/Classes/PhobosConfig.h
View file @
e58799c9
...
@@ -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 Phobos
CacheKey @"PhobosCacheKey"
//存放持久化埋点数据的key
#define Phobos
NormalCacheKey @"PhobosNormalCacheKey"
//存放持久化埋点数据的key
#define Phobos
TempCacheKey @"PhobosTempCacheKey" //临时存放待发送
埋点数据的key
#define Phobos
ImmediatelyCacheKey @"PhobosImmediatelyCacheKey" //存放持久化实时
埋点数据的key
#define PhobosShardCount 50 //收集数据分段发送的个数
#define PhobosShardCount 50 //收集数据分段发送的个数
...
...
GMPhobos/Classes/PhobosUtil.h
View file @
e58799c9
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
typedef
void
(
^
SendDataSuccessBlock
)(
NSInteger
code
);
typedef
void
(
^
SendDataSuccessBlock
)(
BOOL
success
);
@interface
PhobosUtil
:
NSObject
@interface
PhobosUtil
:
NSObject
...
...
GMPhobos/Classes/PhobosUtil.m
View file @
e58799c9
...
@@ -123,11 +123,8 @@
...
@@ -123,11 +123,8 @@
// 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
(
!
error
)
{
if
(
success
)
{
//没有错误,返回正确;
success
(
!
error
?
YES
:
NO
);
if
(
success
)
{
success
(
200
);
}
}
}
}];
}];
[
dataTask
resume
];
[
dataTask
resume
];
...
...
乔金柱
@qiaojinzhu
mentioned in commit
e56ff462
·
Aug 08, 2019
mentioned in commit
e56ff462
mentioned in commit e56ff4621c14f175bc8f2d2e1cdb91f3aa2665aa
Toggle commit list
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