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
31344624
Commit
31344624
authored
Mar 25, 2020
by
井庆林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge
parent
049fe1cc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
22 deletions
+99
-22
NewPhobos.m
GMPhobos/Classes/NewPhobos.m
+33
-11
OldPhobos.m
GMPhobos/Classes/OldPhobos.m
+29
-10
PhobosPVProtocol.h
GMPhobos/Classes/PhobosPVProtocol.h
+9
-0
PhobosUtil.m
GMPhobos/Classes/PhobosUtil.m
+1
-1
UIResponder+PhobosPV.m
GMPhobos/Classes/UIResponder+PhobosPV.m
+27
-0
No files found.
GMPhobos/Classes/NewPhobos.m
View file @
31344624
...
...
@@ -119,12 +119,15 @@ static NSString *sdkVersion = @"1.4.0";
}
-
(
UIViewController
*
)
visibleController
{
id
target
=
self
.
getTopController
();
if
(
self
.
getTopController
)
{
id
target
=
self
.
getTopController
();
if
([
target
conformsToProtocol
:
NSProtocolFromString
(
@"PhobosCustomVisibleController"
)])
{
target
=
[
target
performSelector
:
@selector
(
phobosVisibleController
)];
if
([
target
conformsToProtocol
:
NSProtocolFromString
(
@"PhobosCustomVisibleController"
)])
{
target
=
[
target
performSelector
:
@selector
(
phobosVisibleController
)];
}
return
target
;
}
return
target
;
return
nil
;
}
#pragma mark - notification handler
...
...
@@ -247,6 +250,12 @@ static NSString *sdkVersion = @"1.4.0";
[
page
initReferrerIdIfNil
];
[
page
initReferrerTabName
];
page
.
inTime
=
[
PhobosUtil
currentTime
];
page
.
inTimeMillis
=
[
PhobosUtil
currentMMTime
];
// 业务层更新
if
(
page
.
updatePVStartBlock
)
{
page
.
updatePVStartBlock
();
}
}
-
(
void
)
onPVEnd
:
(
UIResponder
<
PhobosPVProtocol
>
*
)
page
{
...
...
@@ -261,12 +270,18 @@ static NSString *sdkVersion = @"1.4.0";
[
dict
setObject
:
page
.
pageName
forKey
:
@"page_name"
];
[
dict
setObject
:
page
.
businessId
?:
@""
forKey
:
@"business_id"
];
[
dict
setObject
:
page
.
referer
?:
@""
forKey
:
@"referrer"
];
[
dict
setObject
:
page
.
referrerLink
?
:
@[]
forKey
:
@"referrer_link"
];
if
([
page
.
referrerLink
isKindOfClass
:[
NSArray
class
]]
&&
page
.
referrerLink
.
count
)
{
[
dict
setObject
:
page
.
referrerLink
forKey
:
@"referrer_link"
];
}
else
{
[
dict
setObject
:@[]
forKey
:
@"referrer_link"
];
}
[
dict
setObject
:
@
(
0
)
forKey
:
@"fake"
];
[
dict
setObject
:
page
.
referrerId
?
:
@""
forKey
:
@"referrer_id"
];
[
dict
setObject
:
page
.
extraParam
?
:
@""
forKey
:
@"extra_param"
];
[
dict
setObject
:
page
.
referrerTabName
?
:
@""
forKey
:
@"referrer_tab_name"
];
[
dict
setObject
:
page
.
isPush
.
intValue
?
@
(
page
.
isPush
.
intValue
)
:
@
(
0
)
forKey
:
@"is_push"
];
[
dict
setObject
:
page
.
inTimeMillis
?:
@""
forKey
:
@"in_time_millis"
];
[
dict
setObject
:[
PhobosUtil
currentMMTime
]
forKey
:
@"out_time_millis"
];
if
(
page
.
inTime
.
length
>
0
)
{
// 页面显示时间为空时不记录页面pv事件
...
...
@@ -283,11 +298,16 @@ static NSString *sdkVersion = @"1.4.0";
*
* @since 0.0.1
*/
-
(
NSDictionary
*
)
prepareDictionaryForEvent
:
(
NSString
*
)
eventName
attributes
:
(
NSDictionary
*
)
attributes
{
-
(
NSDictionary
*
)
prepareDictionaryForEvent
:
(
NSString
*
)
eventName
attributes
:
(
NSDictionary
*
)
attributes
{
NSArray
*
referrerLink
=
_sharedClient
.
visibleController
.
referrerLink
;
if
(
!
[
eventName
isEqualToString
:
@"page_view"
])
{
// 对于埋点没有referrer_link的情况,在这里进行统一添加
if
(
!
[
attributes
.
allKeys
containsObject
:
@"referrer_link"
])
{
NSMutableDictionary
*
attributesParams
=
[
NSMutableDictionary
dictionaryWithDictionary
:
attributes
];
[
attributesParams
setValue
:
referrerLink
?
:
@[]
forKey
:
@"referrer_link"
];
if
([
referrerLink
isKindOfClass
:[
NSArray
class
]]
&&
referrerLink
.
count
)
{
[
attributesParams
setValue
:
referrerLink
forKey
:
@"referrer_link"
];
}
else
{
[
attributesParams
setValue
:@[]
forKey
:
@"referrer_link"
];
}
attributes
=
attributesParams
;
}
[
self
catchNullForEvent
:
eventName
attributes
:
attributes
];
...
...
@@ -322,14 +342,16 @@ static NSString *sdkVersion = @"1.4.0";
if
(
_signingType
==
PhobosSigningTypeDebug
||
_signingType
==
PhobosSigningTypeRelease
)
{
[
dict
setObject
:
@
(
0
)
forKey
:
@"is_release"
];
}
NSString
*
nano_time
=
[
NSString
stringWithFormat
:
@"%lld"
,[[
NSProcessInfo
processInfo
]
systemUptime
]];
[
dict
setObject
:
eventName
forKey
:
@"type"
];
[
dict
setObject
:
appParams
forKey
:
@"app"
];
[
dict
setObject
:
sdkVersion
forKey
:
@"version"
];
[
dict
setObject
:
deviceParams
forKey
:
@"device"
];
[
dict
setObject
:
_userId
forKey
:
@"user_id"
];
[
dict
setObject
:
currentTime
forKey
:
@"create_at"
];
[
dict
setObject
:
@
([[
NSProcessInfo
processInfo
]
systemUptime
])
forKey
:
@"nano_time"
];
[
dict
setObject
:
@
(
mach_absolute_time
())
forKey
:
@"absolute_time"
];
[
dict
setObject
:
currentTime
forKey
:
@"create_at"
];
// 1584513842 当前时间(秒)
[
dict
setObject
:
nano_time
?:
@""
forKey
:
@"nano_time"
];
// 1657008897 系统启动后时长(秒)
[
dict
setObject
:
@
(
mach_absolute_time
())
forKey
:
@"absolute_time"
];
// 148237263697318 系统启动后的 CPU 嘀嗒数(纳秒)
[
dict
setObject
:[
PhobosUtil
currentMMTime
]
forKey
:
@"create_at_millis"
];
// 1584513842753 当前时间戳(毫秒)
[
dict
setObject
:
attributes
forKey
:
@"params"
];
[
dict
setObject
:
_sessionId
forKey
:
@"app_session_id"
];
}
...
...
GMPhobos/Classes/OldPhobos.m
View file @
31344624
...
...
@@ -112,12 +112,15 @@ static NSString *sdkVersion = @"110";
}
-
(
UIViewController
*
)
visibleController
{
id
target
=
self
.
getTopController
();
if
(
self
.
getTopController
)
{
id
target
=
self
.
getTopController
();
if
([
target
conformsToProtocol
:
NSProtocolFromString
(
@"PhobosCustomVisibleController"
)])
{
target
=
[
target
performSelector
:
@selector
(
phobosVisibleController
)];
if
([
target
conformsToProtocol
:
NSProtocolFromString
(
@"PhobosCustomVisibleController"
)])
{
target
=
[
target
performSelector
:
@selector
(
phobosVisibleController
)];
}
return
target
;
}
return
target
;
return
nil
;
}
#pragma mark - notification handler
...
...
@@ -329,6 +332,11 @@ static NSString *sdkVersion = @"110";
[
page
initReferrerIdIfNil
];
[
page
initReferrerTabName
];
page
.
inTime
=
[
PhobosUtil
currentTime
];
page
.
inTimeMillis
=
[
PhobosUtil
currentMMTime
];
// 业务层更新
if
(
page
.
updatePVStartBlock
)
{
page
.
updatePVStartBlock
();
}
}
-
(
void
)
onPVEnd
:
(
UIResponder
<
PhobosPVProtocol
>
*
)
page
{
...
...
@@ -343,7 +351,11 @@ static NSString *sdkVersion = @"110";
[
dict
setObject
:
page
.
pageName
forKey
:
@"page_name"
];
[
dict
setObject
:
page
.
businessId
?:
@""
forKey
:
@"business_id"
];
[
dict
setObject
:
page
.
referer
?:
@""
forKey
:
@"referrer"
];
[
dict
setObject
:
page
.
referrerLink
?
:
@[]
forKey
:
@"referrer_link"
];
if
([
page
.
referrerLink
isKindOfClass
:[
NSArray
class
]]
&&
page
.
referrerLink
.
count
)
{
[
dict
setObject
:
page
.
referrerLink
forKey
:
@"referrer_link"
];
}
else
{
[
dict
setObject
:@[]
forKey
:
@"referrer_link"
];
}
[
dict
setObject
:
@
(
0
)
forKey
:
@"fake"
];
[
dict
setObject
:
page
.
referrerId
?
:
@""
forKey
:
@"referrer_id"
];
[
dict
setObject
:
page
.
extraParam
?
:
@""
forKey
:
@"extra_param"
];
...
...
@@ -387,9 +399,14 @@ static NSString *sdkVersion = @"110";
*/
-
(
NSDictionary
*
)
prepareDictionaryForEvent
:
(
NSString
*
)
eventId
attributes
:
(
NSDictionary
*
)
attributes
{
NSArray
*
referrerLink
=
sharedClient
.
visibleController
.
referrerLink
;
if
(
!
[
eventId
isEqualToString
:
@"page_view"
])
{
// 对于埋点没有referrer_link的情况,在这里进行统一添加
if
(
!
[
attributes
.
allKeys
containsObject
:
@"referrer_link"
])
{
NSMutableDictionary
*
attributesParams
=
[
NSMutableDictionary
dictionaryWithDictionary
:
attributes
];
[
attributesParams
setValue
:
referrerLink
?
:
@[]
forKey
:
@"referrer_link"
];
if
([
referrerLink
isKindOfClass
:[
NSArray
class
]]
&&
referrerLink
.
count
)
{
[
attributesParams
setValue
:
referrerLink
forKey
:
@"referrer_link"
];
}
else
{
[
attributesParams
setValue
:@[]
forKey
:
@"referrer_link"
];
}
attributes
=
attributesParams
;
}
[
self
catchNullForEvent
:
eventId
attributes
:
attributes
];
...
...
@@ -421,14 +438,16 @@ static NSString *sdkVersion = @"110";
if
(
_signingType
==
PhobosSigningTypeDebug
||
_signingType
==
PhobosSigningTypeRelease
)
{
[
dict
setObject
:
@
(
0
)
forKey
:
@"is_release"
];
}
NSString
*
nano_time
=
[
NSString
stringWithFormat
:
@"%lld"
,[[
NSProcessInfo
processInfo
]
systemUptime
]];
[
dict
setObject
:
eventId
forKey
:
@"type"
];
[
dict
setObject
:
appParams
forKey
:
@"app"
];
[
dict
setObject
:
sdkVersion
forKey
:
@"version"
];
[
dict
setObject
:
deviceParams
forKey
:
@"device"
];
[
dict
setObject
:
_userId
forKey
:
@"user_id"
];
[
dict
setObject
:
currentTime
forKey
:
@"create_at"
];
[
dict
setObject
:
@
([[
NSProcessInfo
processInfo
]
systemUptime
])
forKey
:
@"nano_time"
];
[
dict
setObject
:
@
(
mach_absolute_time
())
forKey
:
@"absolute_time"
];
[
dict
setObject
:
currentTime
forKey
:
@"create_at"
];
// 1584513842 当前时间(秒)
[
dict
setObject
:
nano_time
?:
@""
forKey
:
@"nano_time"
];
// 1657008897 系统启动后时长(秒)
[
dict
setObject
:
@
(
mach_absolute_time
())
forKey
:
@"absolute_time"
];
// 148237263697318 系统启动后的 CPU 嘀嗒数(纳秒)
[
dict
setObject
:[
PhobosUtil
currentMMTime
]
forKey
:
@"create_at_millis"
];
// 1584513842753 当前时间戳(毫秒)
[
dict
setObject
:
attributes
forKey
:
@"params"
];
[
dict
setObject
:
_sessionId
forKey
:
@"app_session_id"
];
}
...
...
GMPhobos/Classes/PhobosPVProtocol.h
View file @
31344624
...
...
@@ -10,6 +10,8 @@
NS_ASSUME_NONNULL_BEGIN
@protocol
PhobosPVProtocol
<
NSObject
>
typedef
void
(
^
PhobosUpdatePVBlock
)(
void
);
/**
* @author 翟国钧, 16-02-24 17:02:22
*
...
...
@@ -42,6 +44,9 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property
(
nonatomic
,
copy
,
nonnull
)
NSString
*
inTime
;
/// 当前VC.view 显示的时候的时间戳(精确到毫秒)
@property
(
nonatomic
,
copy
,
nonnull
)
NSString
*
inTimeMillis
;
/**
前一个页面的businessId。该属性有可能为空字符串
*/
...
...
@@ -80,6 +85,10 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property
(
nonatomic
,
copy
)
NSArray
*
referrerLink
;
/// 业务层更新PVStart信息
@property
(
nonatomic
,
copy
)
PhobosUpdatePVBlock
updatePVStartBlock
;
/// 业务层更新PVEnd信息
@property
(
nonatomic
,
copy
)
PhobosUpdatePVBlock
updatePVEndBlock
;
@end
NS_ASSUME_NONNULL_END
GMPhobos/Classes/PhobosUtil.m
View file @
31344624
...
...
@@ -436,7 +436,7 @@
}
/**
* 获取手机运行时间,从开机到现在
* 获取手机运行时间,从开机到现在
(秒)
*/
+
(
NSString
*
)
deviceRunTime
{
struct
timeval
boottime
;
...
...
GMPhobos/Classes/UIResponder+PhobosPV.m
View file @
31344624
...
...
@@ -161,6 +161,15 @@
return
inTime
;
}
-
(
void
)
setInTimeMillis
:
(
NSString
*
)
inTimeMillis
{
objc_setAssociatedObject
(
self
,
@selector
(
inTimeMillis
),
inTimeMillis
,
OBJC_ASSOCIATION_COPY
);
}
-
(
NSString
*
)
inTimeMillis
{
NSString
*
inTimeMillis
=
objc_getAssociatedObject
(
self
,
@selector
(
inTimeMillis
));
return
inTimeMillis
;
}
-
(
void
)
initReferrerIdIfNil
{
// 只有不为空,且是controller的情况下才自动获取
if
([
self
.
referrerId
isEqualToString
:
@""
]
&&
[
self
isKindOfClass
:[
UIViewController
class
]])
{
...
...
@@ -236,4 +245,22 @@
return
isPush
==
nil
?
@""
:
isPush
;
}
-
(
void
)
setUpdatePVStartBlock
:
(
PhobosUpdatePVBlock
)
updatePVStartBlock
{
objc_setAssociatedObject
(
self
,
@selector
(
updatePVStartBlock
),
updatePVStartBlock
,
OBJC_ASSOCIATION_COPY
);
}
-
(
PhobosUpdatePVBlock
)
updatePVStartBlock
{
PhobosUpdatePVBlock
updatePVBlock
=
objc_getAssociatedObject
(
self
,
@selector
(
updatePVStartBlock
));
return
updatePVBlock
;
}
-
(
void
)
setUpdatePVEndBlock
:
(
PhobosUpdatePVBlock
)
updatePVEndBlock
{
objc_setAssociatedObject
(
self
,
@selector
(
updatePVEndBlock
),
updatePVEndBlock
,
OBJC_ASSOCIATION_COPY
);
}
-
(
PhobosUpdatePVBlock
)
updatePVEndBlock
{
PhobosUpdatePVBlock
updatePVBlock
=
objc_getAssociatedObject
(
self
,
@selector
(
updatePVEndBlock
));
return
updatePVBlock
;
}
@end
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