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
642258fa
Commit
642258fa
authored
Dec 12, 2019
by
井庆林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
灰度策略
parent
0fac0e39
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
284 additions
and
108 deletions
+284
-108
GMPhotoTest.m
Example/Tests/GMPhotoTest.m
+0
-6
Phobos.h
GMPhobos/Classes/Phobos.h
+5
-32
Phobos.m
GMPhobos/Classes/Phobos.m
+88
-69
PhobosConfig.h
GMPhobos/Classes/PhobosConfig.h
+11
-1
OldPhobos.h
OldPhobos.h
+180
-0
OldPhobos.m
OldPhobos.m
+0
-0
No files found.
Example/Tests/GMPhotoTest.m
View file @
642258fa
...
@@ -326,12 +326,6 @@ NSString *const MockCityId = @"beijing";
...
@@ -326,12 +326,6 @@ NSString *const MockCityId = @"beijing";
}
}
-
(
void
)
testSimulativePageViewEvent
{
[
NSThread
sleepForTimeInterval
:
0
.
2
];
[
Phobos
.
sharedClient
simulativePV
:
nil
businessId
:
nil
referer
:
nil
];
[
self
paramUnNilCheck
];
}
-
(
void
)
paramUnNilCheck
{
-
(
void
)
paramUnNilCheck
{
[
NSThread
sleepForTimeInterval
:
0
.
2
];
[
NSThread
sleepForTimeInterval
:
0
.
2
];
NSArray
*
array
=
[
Phobos
normalPhobosDataForServerAPI
];
NSArray
*
array
=
[
Phobos
normalPhobosDataForServerAPI
];
...
...
GMPhobos/Classes/Phobos.h
View file @
642258fa
...
@@ -8,17 +8,11 @@
...
@@ -8,17 +8,11 @@
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
#import "PhobosPVProtocol.h"
#import "PhobosPVProtocol.h"
#import "PhobosConfig.h"
#import <CoreLocation/CLLocation.h>
#import <CoreLocation/CLLocation.h>
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
typedef
NS_ENUM
(
NSInteger
,
PhobosSigningType
)
{
PhobosSigningTypeUndefined
=
0
,
PhobosSigningTypeAppStore
,
PhobosSigningTypeRelease
,
PhobosSigningTypeDebug
};
@interface
Phobos
:
NSObject
@interface
Phobos
:
NSObject
/**
/**
...
@@ -31,7 +25,7 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
...
@@ -31,7 +25,7 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
*
*
* @since 0.0.1
* @since 0.0.1
*/
*/
+
(
Phobos
*
)
clientWithAppName
:(
NSString
*
)
appName
channelId
:(
NSString
*
)
channelId
;
+
(
void
)
clientWithAppName
:(
NSString
*
)
appName
channelId
:(
NSString
*
)
channelId
;
+
(
instancetype
)
alloc
__attribute__
((
deprecated
));
+
(
instancetype
)
alloc
__attribute__
((
deprecated
));
-
(
instancetype
)
init
__attribute__
((
deprecated
));
-
(
instancetype
)
init
__attribute__
((
deprecated
));
...
@@ -41,6 +35,9 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
...
@@ -41,6 +35,9 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
@property
(
class
,
readonly
,
strong
)
Phobos
*
sharedClient
;
@property
(
class
,
readonly
,
strong
)
Phobos
*
sharedClient
;
/** 用于Phobos库从old更新到new使用,在全量之后删除相关逻辑 */
@property
(
nonatomic
,
assign
)
BOOL
isGray
;
// Phobos在处理业务端传递来的参数时会检查是否某个value为空,如果为空会调用这个block以通知业务层,业务层可以上报这个异常,以助解决问题
// Phobos在处理业务端传递来的参数时会检查是否某个value为空,如果为空会调用这个block以通知业务层,业务层可以上报这个异常,以助解决问题
@property
(
nonatomic
,
copy
)
void
(
^
captureNullExpection
)
(
NSString
*
eventId
,
NSDictionary
*
info
);
@property
(
nonatomic
,
copy
)
void
(
^
captureNullExpection
)
(
NSString
*
eventId
,
NSDictionary
*
info
);
...
@@ -151,17 +148,6 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
...
@@ -151,17 +148,6 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
+
(
void
)
track
:(
NSString
*
)
eventName
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
*
)
eventName
currentAPI
:(
NSString
*
)
currentAPI
;
+
(
void
)
track
:(
NSString
*
)
eventName
currentAPI
:(
NSString
*
)
currentAPI
;
/**
* @author 翟国钧, 16-02-03 16:02:30
*
* @brief H5调用的埋点方法
*
* @param jsonString h5传过来的参数
*
* @since 0.0.1
*/
+
(
void
)
trackJsEvent
:(
NSString
*
)
jsonString
;
/**
/**
* @brief PV事件开始。当controller viewWillAppear时调用
* @brief PV事件开始。当controller viewWillAppear时调用
*/
*/
...
@@ -171,19 +157,6 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
...
@@ -171,19 +157,6 @@ typedef NS_ENUM (NSInteger, PhobosSigningType) {
*/
*/
-
(
void
)
onPVEnd
:(
UIResponder
<
PhobosPVProtocol
>
*
)
page
;
-
(
void
)
onPVEnd
:(
UIResponder
<
PhobosPVProtocol
>
*
)
page
;
/**
* @author 翟国钧, 16-03-08 11:03:45
*
* @brief 有些事件需要模拟pv事件,统一用该方法处理,in out 时间相同.点击一次即触发
*
* @param pageName 控件所在VC的pageName
* @param bid 业务id
* @param referer 上个月面的pagename
*
* @since 5.9.1
*/
-
(
void
)
simulativePV
:(
NSString
*
)
pageName
businessId
:(
NSString
*
)
bid
referer
:(
NSString
*
)
referer
;
@end
@end
@interface
Phobos
(
UtilTest
)
@interface
Phobos
(
UtilTest
)
...
...
GMPhobos/Classes/Phobos.m
View file @
642258fa
...
@@ -7,9 +7,9 @@
...
@@ -7,9 +7,9 @@
//
//
#import "Phobos.h"
#import "Phobos.h"
#import "OldPhobos.h"
#import <AdSupport/AdSupport.h>
#import <AdSupport/AdSupport.h>
#import "PhobosUtil.h"
#import "PhobosUtil.h"
#import "PhobosConfig.h"
#import "UIResponder+PhobosPV.h"
#import "UIResponder+PhobosPV.h"
#import "PhobosUtil.h"
#import "PhobosUtil.h"
#import "PhobosCustomVisibleController.h"
#import "PhobosCustomVisibleController.h"
...
@@ -33,6 +33,8 @@ static NSString *sdkVersion = @"1.3.1";
...
@@ -33,6 +33,8 @@ static NSString *sdkVersion = @"1.3.1";
//@property (nonatomic, weak) dispatch_semaphore_t normalSemaphore;// 保障普通埋点数据安全
//@property (nonatomic, weak) dispatch_semaphore_t normalSemaphore;// 保障普通埋点数据安全
@property
(
nonatomic
,
assign
)
NSInteger
normalCount
;
// 记录普通埋点数量
@property
(
nonatomic
,
assign
)
NSInteger
normalCount
;
// 记录普通埋点数量
@property
(
nonatomic
,
strong
)
OldPhobos
*
oldPhobos
;
@end
@end
@implementation
Phobos
@implementation
Phobos
...
@@ -45,6 +47,8 @@ static dispatch_queue_t _normalQueue;
...
@@ -45,6 +47,8 @@ static dispatch_queue_t _normalQueue;
+
(
Phobos
*
)
clientWithAppName
:(
NSString
*
)
appName
channelId
:(
NSString
*
)
channelId
{
+
(
Phobos
*
)
clientWithAppName
:(
NSString
*
)
appName
channelId
:(
NSString
*
)
channelId
{
Phobos
.
sharedClient
.
appName
=
appName
;
Phobos
.
sharedClient
.
appName
=
appName
;
Phobos
.
sharedClient
.
channelId
=
channelId
;
Phobos
.
sharedClient
.
channelId
=
channelId
;
Phobos
.
sharedClient
.
oldPhobos
=
[
OldPhobos
clientWithAppName
:
appName
channelId
:
channelId
];
[
OldPhobos
setSharedClient
:
Phobos
.
sharedClient
.
oldPhobos
];
return
Phobos
.
sharedClient
;
return
Phobos
.
sharedClient
;
}
}
...
@@ -81,7 +85,6 @@ static dispatch_queue_t _normalQueue;
...
@@ -81,7 +85,6 @@ static dispatch_queue_t _normalQueue;
[
self
setupNotification
];
[
self
setupNotification
];
[
self
handleSessionStart
];
[
self
handleSessionStart
];
[
self
synchronizePhobosKey
];
}
}
return
self
;
return
self
;
}
}
...
@@ -102,23 +105,6 @@ static dispatch_queue_t _normalQueue;
...
@@ -102,23 +105,6 @@ static dispatch_queue_t _normalQueue;
return
_sharedClient
;
return
_sharedClient
;
}
}
-
(
void
)
setAppName
:
(
NSString
*
)
appName
channelId
:
(
NSString
*
)
channelId
{
self
.
appName
=
appName
;
self
.
channelId
=
channelId
;
}
/**
* disk下的PhobosHaveOpenApp只要存在,就把他取出来放到document下(注:当不支持7.6.16版本的时候,干掉这个方法)
*/
-
(
void
)
synchronizePhobosKey
{
if
([
GMCache
fetchObjectAtDiskWithkey
:
PhobosHaveOpenApp
])
{
NSString
*
prefePath
=
[
NSSearchPathForDirectoriesInDomains
(
NSDocumentDirectory
,
NSUserDomainMask
,
YES
)
objectAtIndex
:
0
];
prefePath
=
[
NSString
stringWithFormat
:
@"%@/com.tumblr.TMDiskCache.WMCacheShared/%@"
,
prefePath
,
PhobosHaveOpenApp
];
NSURL
*
fileUrl
=
[
NSURL
fileURLWithPathComponents
:@[
prefePath
]];
BOOL
written
=
[
NSKeyedArchiver
archiveRootObject
:
PhobosHaveOpenApp
toFile
:[
fileUrl
path
]];
}
}
-
(
void
)
dealloc
{
-
(
void
)
dealloc
{
if
(
self
)
{
if
(
self
)
{
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
];
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
];
...
@@ -142,6 +128,57 @@ static dispatch_queue_t _normalQueue;
...
@@ -142,6 +128,57 @@ static dispatch_queue_t _normalQueue;
[
_userType
setObject
:[
userType
objectForKey
:
newKey
]
forKey
:
newKey
];
[
_userType
setObject
:[
userType
objectForKey
:
newKey
]
forKey
:
newKey
];
}
}
}
}
_oldPhobos
.
userType
=
userType
;
}
-
(
void
)
setServerAPI
:
(
NSString
*
)
serverAPI
{
_serverAPI
=
serverAPI
;
_oldPhobos
.
serverAPI
=
serverAPI
;
}
-
(
void
)
setUserId
:
(
NSString
*
)
userId
{
_userId
=
userId
;
_oldPhobos
.
userId
=
userId
;
}
-
(
void
)
setNetStatus
:
(
NSString
*
)
netStatus
{
_netStatus
=
netStatus
;
_oldPhobos
.
netStatus
=
netStatus
;
}
-
(
void
)
setNetworkStatus
:
(
NSString
*
)
networkStatus
{
_networkStatus
=
networkStatus
;
_oldPhobos
.
networkStatus
=
networkStatus
;
}
-
(
void
)
setCookie
:
(
NSString
*
)
cookie
{
_cookie
=
cookie
;
_oldPhobos
.
cookie
=
cookie
;
}
-
(
void
)
setGps
:
(
CLLocation
*
)
gps
{
_gps
=
gps
;
_oldPhobos
.
gps
=
gps
;
}
-
(
void
)
setGetTopController
:
(
UIViewController
*
_Nonnull
(
^
)(
void
))
getTopController
{
_getTopController
=
getTopController
;
_oldPhobos
.
getTopController
=
getTopController
;
}
-
(
void
)
setCurrentCityId
:
(
NSString
*
)
currentCityId
{
_currentCityId
=
currentCityId
;
_oldPhobos
.
currentCityId
=
currentCityId
;
}
-
(
void
)
setGreyType
:
(
NSString
*
)
greyType
{
_greyType
=
greyType
;
_oldPhobos
.
greyType
=
greyType
;
}
-
(
void
)
setCaptureNullExpection
:
(
void
(
^
)(
NSString
*
_Nonnull
,
NSDictionary
*
_Nonnull
))
captureNullExpection
{
_captureNullExpection
=
captureNullExpection
;
_oldPhobos
.
captureNullExpection
=
captureNullExpection
;
}
}
/**
/**
...
@@ -161,14 +198,6 @@ static dispatch_queue_t _normalQueue;
...
@@ -161,14 +198,6 @@ static dispatch_queue_t _normalQueue;
@"build_model"
:
[
UIDevice
deviceVersion
],
@"build_model"
:
[
UIDevice
deviceVersion
],
};
};
[
Phobos
track
:
@"device_opened"
attributes
:
dict
sendNow
:
YES
];
[
Phobos
track
:
@"device_opened"
attributes
:
dict
sendNow
:
YES
];
/** 第一次打开APP埋点 **/
// 当不再支持7.6.15版本时,只保留
if
(
!
[
GMCache
fetchObjectAtDocumentPathWithkey
:
PhobosHaveOpenApp
])
{
[
Phobos
track
:
@"device_activated"
attributes
:@{}
sendNow
:
YES
];
[
Phobos
track
:
@"device_activated"
attributes
:@{}
sendNow
:
NO
];
[
GMCache
storeObjectAtDocumentPathWithkey
:
PhobosHaveOpenApp
object
:
PhobosHaveOpenApp
];
}
}
}
-
(
UIViewController
*
)
visibleController
{
-
(
UIViewController
*
)
visibleController
{
...
@@ -295,6 +324,10 @@ static dispatch_queue_t _normalQueue;
...
@@ -295,6 +324,10 @@ static dispatch_queue_t _normalQueue;
#pragma mark - PV
#pragma mark - PV
-
(
void
)
onPVStart
:
(
UIResponder
<
PhobosPVProtocol
>
*
)
page
{
-
(
void
)
onPVStart
:
(
UIResponder
<
PhobosPVProtocol
>
*
)
page
{
if
(
!
_isGray
)
{
[
_oldPhobos
onPVStart
:
page
];
return
;
}
// 必须在此处调用一下referer,因为onControllerStart
// 必须在此处调用一下referer,因为onControllerStart
[
page
initReferer
];
[
page
initReferer
];
[
page
initReferrerIdIfNil
];
[
page
initReferrerIdIfNil
];
...
@@ -303,6 +336,10 @@ static dispatch_queue_t _normalQueue;
...
@@ -303,6 +336,10 @@ static dispatch_queue_t _normalQueue;
}
}
-
(
void
)
onPVEnd
:
(
UIResponder
<
PhobosPVProtocol
>
*
)
page
{
-
(
void
)
onPVEnd
:
(
UIResponder
<
PhobosPVProtocol
>
*
)
page
{
if
(
!
_isGray
)
{
[
_oldPhobos
onPVEnd
:
page
];
return
;
}
if
(
!
[
PhobosUtil
isNonEmpty
:
page
.
pageName
]
||
!
page
.
needLogPV
)
{
if
(
!
[
PhobosUtil
isNonEmpty
:
page
.
pageName
]
||
!
page
.
needLogPV
)
{
return
;
return
;
}
}
...
@@ -329,24 +366,6 @@ static dispatch_queue_t _normalQueue;
...
@@ -329,24 +366,6 @@ static dispatch_queue_t _normalQueue;
}
}
}
}
-
(
void
)
simulativePV
:
(
NSString
*
)
pageName
businessId
:
(
NSString
*
)
bid
referer
:
(
NSString
*
)
referer
{
NSMutableDictionary
*
dict
=
[[
NSMutableDictionary
alloc
]
init
];
@try
{
// fake(模拟)的事件,所以in与out一样,就是这么规定的
[
dict
setObject
:[
PhobosUtil
currentTime
]
forKey
:
@"in"
];
[
dict
setObject
:[
PhobosUtil
currentTime
]
forKey
:
@"out"
];
[
dict
setObject
:
pageName
?:
@""
forKey
:
@"page_name"
];
[
dict
setObject
:
bid
?:
@""
forKey
:
@"business_id"
];
[
dict
setObject
:
referer
?:
@""
forKey
:
@"referrer"
];
[
dict
setObject
:
@
(
1
)
forKey
:
@"fake"
];
[
Phobos
track
:
@"page_view"
attributes
:
dict
];
}
@catch
(
NSException
*
exception
)
{
phobosLog
(
exception
);
}
}
/**
/**
* @brief 将埋点时间封装成词典数据
* @brief 将埋点时间封装成词典数据
*
*
...
@@ -417,51 +436,51 @@ static dispatch_queue_t _normalQueue;
...
@@ -417,51 +436,51 @@ static dispatch_queue_t _normalQueue;
});
});
}
}
#pragma mark - track event handler
+
(
void
)
trackJsEvent
:
(
NSString
*
)
jsonString
{
@try
{
NSData
*
data
=
[
jsonString
dataUsingEncoding
:
NSUnicodeStringEncoding
];
NSMutableDictionary
*
dict
=
[
NSJSONSerialization
JSONObjectWithData
:
data
options
:
NSJSONReadingAllowFragments
error
:
nil
];
id
pa
=
dict
[
@"params"
];
NSDictionary
*
json
;
if
([
pa
isKindOfClass
:[
NSString
class
]])
{
NSError
*
jsonError
;
NSData
*
objectData
=
[
pa
dataUsingEncoding
:
NSUTF8StringEncoding
];
json
=
[
NSJSONSerialization
JSONObjectWithData
:
objectData
options
:
NSJSONReadingMutableContainers
error
:&
jsonError
];
[
Phobos
track
:
dict
[
@"type"
]
attributes
:
json
];
}
else
{
[
Phobos
track
:
dict
[
@"type"
]];
}
}
@catch
(
NSException
*
exception
)
{
phobosLog
(
exception
);
}
}
+
(
void
)
track
:
(
NSString
*
)
eventName
{
+
(
void
)
track
:
(
NSString
*
)
eventName
{
if
(
!
Phobos
.
sharedClient
.
isGray
)
{
[
OldPhobos
track
:
eventName
];
return
;
}
[
self
track
:
eventName
attributes
:@{}
sendNow
:
NO
currentAPI
:
_sharedClient
.
serverAPI
];
[
self
track
:
eventName
attributes
:@{}
sendNow
:
NO
currentAPI
:
_sharedClient
.
serverAPI
];
}
}
+
(
void
)
track
:
(
NSString
*
)
eventName
attributes
:
(
NSDictionary
*
)
attributes
{
+
(
void
)
track
:
(
NSString
*
)
eventName
attributes
:
(
NSDictionary
*
)
attributes
{
if
(
!
Phobos
.
sharedClient
.
isGray
)
{
[
Phobos
track
:
eventName
attributes
:
attributes
];
return
;
}
[
self
track
:
eventName
attributes
:
attributes
sendNow
:
NO
currentAPI
:
_sharedClient
.
serverAPI
];
[
self
track
:
eventName
attributes
:
attributes
sendNow
:
NO
currentAPI
:
_sharedClient
.
serverAPI
];
}
}
+
(
void
)
track
:
(
NSString
*
)
eventName
attributes
:
(
NSDictionary
*
)
attributes
sendNow
:
(
BOOL
)
sendNow
{
+
(
void
)
track
:
(
NSString
*
)
eventName
attributes
:
(
NSDictionary
*
)
attributes
sendNow
:
(
BOOL
)
sendNow
{
if
(
!
Phobos
.
sharedClient
.
isGray
)
{
[
OldPhobos
track
:
eventName
attributes
:
attributes
sendNow
:
sendNow
];
return
;
}
[
self
track
:
eventName
attributes
:
attributes
sendNow
:
sendNow
currentAPI
:
_sharedClient
.
serverAPI
];
[
self
track
:
eventName
attributes
:
attributes
sendNow
:
sendNow
currentAPI
:
_sharedClient
.
serverAPI
];
}
}
+
(
void
)
track
:
(
NSString
*
)
eventName
currentAPI
:
(
NSString
*
)
currentAPI
{
+
(
void
)
track
:
(
NSString
*
)
eventName
currentAPI
:
(
NSString
*
)
currentAPI
{
if
(
!
Phobos
.
sharedClient
.
isGray
)
{
[
OldPhobos
track
:
eventName
currentAPI
:
currentAPI
];
return
;
}
[
self
track
:
eventName
attributes
:@{}
sendNow
:
NO
currentAPI
:
currentAPI
];
[
self
track
:
eventName
attributes
:@{}
sendNow
:
NO
currentAPI
:
currentAPI
];
}
}
+
(
void
)
track
:
(
NSString
*
)
eventName
attributes
:
(
NSDictionary
*
)
attributes
currentAPI
:
(
NSString
*
)
currentAPI
{
+
(
void
)
track
:
(
NSString
*
)
eventName
attributes
:
(
NSDictionary
*
)
attributes
currentAPI
:
(
NSString
*
)
currentAPI
{
if
(
!
Phobos
.
sharedClient
.
isGray
)
{
[
OldPhobos
track
:
eventName
attributes
:
attributes
sendNow
:
sendNow
currentAPI
:
currentAPI
];
return
;
}
[
self
track
:
eventName
attributes
:
attributes
sendNow
:
NO
currentAPI
:
currentAPI
];
[
self
track
:
eventName
attributes
:
attributes
sendNow
:
NO
currentAPI
:
currentAPI
];
}
}
+
(
void
)
track
:
(
NSString
*
)
eventName
attributes
:
(
NSDictionary
*
)
attributes
sendNow
:
(
BOOL
)
sendNow
currentAPI
:
(
NSString
*
)
currentAPI
{
+
(
void
)
track
:
(
NSString
*
)
eventName
attributes
:
(
NSDictionary
*
)
attributes
sendNow
:
(
BOOL
)
sendNow
currentAPI
:
(
NSString
*
)
currentAPI
{
if
(
!
Phobos
.
sharedClient
.
isGray
)
{
[
OldPhobos
track
:
eventName
attributes
:
attributes
sendNow
:
sendNow
currentAPI
:
currentAPI
];
return
;
}
NSDictionary
*
dataDict
=
[
_sharedClient
prepareDictionaryForEvent
:
eventName
attributes
:
attributes
];
NSDictionary
*
dataDict
=
[
_sharedClient
prepareDictionaryForEvent
:
eventName
attributes
:
attributes
];
@try
{
@try
{
NSData
*
JSON
=
[
PhobosUtil
encodeJSON
:
dataDict
];
NSData
*
JSON
=
[
PhobosUtil
encodeJSON
:
dataDict
];
...
...
GMPhobos/Classes/PhobosConfig.h
View file @
642258fa
...
@@ -9,18 +9,28 @@
...
@@ -9,18 +9,28 @@
#ifndef PhobosConfig_h
#ifndef PhobosConfig_h
#define PhobosConfig_h
#define PhobosConfig_h
typedef
NS_ENUM
(
NSInteger
,
PhobosSigningType
)
{
PhobosSigningTypeUndefined
=
0
,
PhobosSigningTypeAppStore
,
PhobosSigningTypeRelease
,
PhobosSigningTypeDebug
};
#ifdef DEBUG
#ifdef DEBUG
#define phobosLog(...) NSLog(@"[Phobos] %@",__VA_ARGS__)
#define phobosLog(...) NSLog(@"[Phobos] %@",__VA_ARGS__)
#else
#else
#define phobosLog(...)
#define phobosLog(...)
#endif
#endif
#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 PhobosNormalCacheKey @"PhobosNormalCacheKey" //存放持久化埋点数据的key
#define PhobosImmediatelyCacheKey @"PhobosImmediatelyCacheKey" //存放持久化实时埋点数据的key
#define PhobosImmediatelyCacheKey @"PhobosImmediatelyCacheKey" //存放持久化实时埋点数据的key
#define PhobosCacheKey @"PhobosCacheKey" //old 存放持久化埋点数据的key
#define PhobosTempCacheKey @"PhobosTempCacheKey" //old 临时存放待发送埋点数据的key
#define PhobosShardCount 50 //收集数据分段发送的个数
#define PhobosShardCount 50 //收集数据分段发送的个数
#endif
/* PhobosConfig_h */
#endif
/* PhobosConfig_h */
OldPhobos.h
0 → 100644
View file @
642258fa
//
// Phobos.h
// GengmeiDoctor
// Data Statistic Client For Mars
// Created by Thierry on 16/1/26.
// Copyright © 2016年 wanmeizhensuo. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "PhobosPVProtocol.h"
#import <CoreLocation/CLLocation.h>
#import "PhobosConfig.h"
NS_ASSUME_NONNULL_BEGIN
@interface
OldPhobos
:
NSObject
/**
* @brief 开启Phobos统计,默认以BATCH方式发送log.
*
* @param appName 通常由数据端与客户端一起确认的区分不同app的名字
* @param channelId 发布渠道
*
* @return Phobos实例
*
* @since 0.0.1
*/
+
(
OldPhobos
*
)
clientWithAppName
:(
NSString
*
)
appName
channelId
:(
NSString
*
)
channelId
;
+
(
instancetype
)
sharedClient
;
+
(
void
)
setSharedClient
:(
OldPhobos
*
)
client
;
#pragma mark - SDK配置
// Phobos在处理业务端传递来的参数时会检查是否某个value为空,如果为空会调用这个block以通知业务层,业务层可以上报这个异常,以助解决问题
@property
(
nonatomic
,
copy
)
void
(
^
captureNullExpection
)
(
NSString
*
eventId
,
NSDictionary
*
info
);
/**
网络状态 wifi=1, mobile=0, 不连通=-1
*/
@property
(
nonatomic
,
copy
)
NSString
*
netStatus
;
/**
//没有网络连接
public static final String NETWORN_NONE = "none";
//wifi连接
public static final String NETWORN_WIFI = "wifi";
//手机网络数据连接类型
public static final String NETWORN_2G = "2G";
public static final String NETWORN_3G = "3G";
public static final String NETWORN_4G = "4G";
public static final String NETWORN_MOBILE = "other";
*/
@property
(
nonatomic
,
copy
)
NSString
*
networkStatus
;
/**
* @brief 设置是否打印sdk的log信息,默认不开启
*
* @since 0.0.1
*/
@property
(
assign
,
nonatomic
)
BOOL
logEnabled
;
/**
* @brief 设置当前登录用户的ID,如果没有默认为@""
*
*
* @since 0.0.2
*/
@property
(
strong
,
nonatomic
)
NSString
*
userId
;
/*!
* @author zhaiguojun, 16-05-31
*
* @brief 用户当前的城市id
*
*
* @since 0.2.7
*/
@property
(
strong
,
nonatomic
)
NSString
*
currentCityId
;
@property
(
strong
,
nonatomic
)
CLLocation
*
gps
;
/**
* 记录用户类型
*/
@property
(
strong
,
nonatomic
)
NSMutableDictionary
*
userType
;
/**
数据接收的服务器API
*/
@property
(
copy
,
nonatomic
)
NSString
*
serverAPI
;
/**
当前APP请求接口的 APIHOST(GMServerDomains.apiHost 主要用于flutter AppDelegate 中初始化需要传值
*/
@property
(
nonatomic
,
copy
)
NSString
*
apiHost
;
/**
当前APP请求接口的 cookie(主要用于flutter) 获取到cookie 的时候穿过来 或者cookie 有变化的时候传过来
*/
@property
(
nonatomic
,
copy
)
NSString
*
cookie
;
/**
灰度组, since 7.7.65
*/
@property
(
nonatomic
,
copy
)
NSString
*
greyType
;
/**
包的类型:APPSTORE、RELEASE、DEBUG
*/
@property
(
nonatomic
,
assign
)
PhobosSigningType
signingType
;
/**
从主项目获取当前显示的controller
*/
@property
(
nonatomic
,
copy
)
UIViewController
*
(
^
getTopController
)
(
void
);
#pragma mark - 事件采集
/**
* @brief 自定义事件,数量统计.
*
* @param eventId 事件Id
* @attributes 参数
* @sendNow 是否实时发送,默认为NO
*
* @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
;
/**
* @brief 自定义事件,数量统计 7730 精准曝光.
*
* @param eventId 事件Id
* @attributes 参数
* @sendNow 是否实时发送,默认为NO
* @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
;
/**
* @author 翟国钧, 16-02-03 16:02:30
*
* @brief H5调用的埋点方法
*
* @param jsonString h5传过来的参数
*
* @since 0.0.1
*/
+
(
void
)
trackJsEvent
:(
NSString
*
)
jsonString
;
/**
* @brief PV事件开始。当controller viewWillAppear时调用
*/
-
(
void
)
onPVStart
:(
UIResponder
<
PhobosPVProtocol
>
*
)
page
;
/**
* @brief PV事件结束。当controller viewWillDisAppear时调用
*/
-
(
void
)
onPVEnd
:(
UIResponder
<
PhobosPVProtocol
>
*
)
page
;
/**
* @author 翟国钧, 16-03-08 11:03:45
*
* @brief 有些事件需要模拟pv事件,统一用该方法处理,in out 时间相同.点击一次即触发
*
* @param pageName 控件所在VC的pageName
* @param bid 业务id
* @param referer 上个月面的pagename
*
* @since 5.9.1
*/
-
(
void
)
simulativePV
:(
NSString
*
)
pageName
businessId
:(
NSString
*
)
bid
referer
:(
NSString
*
)
referer
;
@end
NS_ASSUME_NONNULL_END
OldPhobos.m
0 → 100644
View file @
642258fa
This diff is collapsed.
Click to expand it.
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