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
0495bdd9
Commit
0495bdd9
authored
Mar 25, 2020
by
乔金柱
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ajp/7.24.0_addParam' into 'master'
Ajp/7.24.0 add param See merge request
!47
parents
fe46540b
d215d30e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
14 deletions
+77
-14
Podfile.lock
Example/Podfile.lock
+1
-1
GMPhotoTest.m
Example/Tests/GMPhotoTest.m
+0
-0
Phobos.m
GMPhobos/Classes/Phobos.m
+38
-11
PhobosPVProtocol.h
GMPhobos/Classes/PhobosPVProtocol.h
+9
-0
PhobosUtil.m
GMPhobos/Classes/PhobosUtil.m
+1
-1
UIResponder+PhobosPV.m
GMPhobos/Classes/UIResponder+PhobosPV.m
+28
-1
No files found.
Example/Podfile.lock
View file @
0495bdd9
...
...
@@ -70,4 +70,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: ea0fac2144ac80baf8f21576cde49526c19991ad
COCOAPODS: 1.
8.4
COCOAPODS: 1.
9.0
Example/Tests/GMPhotoTest.m
View file @
0495bdd9
This diff is collapsed.
Click to expand it.
GMPhobos/Classes/Phobos.m
View file @
0495bdd9
...
...
@@ -136,12 +136,16 @@ 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
...
...
@@ -354,12 +358,21 @@ 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
{
if
(
!
[
PhobosUtil
isNonEmpty
:
page
.
pageName
]
||
!
page
.
needLogPV
)
{
return
;
}
// 业务层更新
if
(
page
.
updatePVEndBlock
)
{
page
.
updatePVEndBlock
();
}
NSMutableDictionary
*
dict
=
[[
NSMutableDictionary
alloc
]
init
];
@try
{
[
dict
setObject
:[
PhobosUtil
currentTime
]
forKey
:
@"out"
];
...
...
@@ -367,12 +380,18 @@ 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"
];
[
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事件
...
...
@@ -410,11 +429,17 @@ static NSString *sdkVersion = @"110";
*
* @since 0.0.1
*/
-
(
NSDictionary
*
)
prepareDictionaryForEvent
:
(
NSString
*
)
eventId
attributes
:
(
NSDictionary
*
)
attributes
{
-
(
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
];
...
...
@@ -446,14 +471,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 @
0495bdd9
...
...
@@ -8,6 +8,8 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef
void
(
^
PhobosUpdatePVBlock
)(
void
);
@protocol
PhobosPVProtocol
<
NSObject
>
/**
...
...
@@ -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 @
0495bdd9
...
...
@@ -426,7 +426,7 @@
}
/**
* 获取手机运行时间,从开机到现在
* 获取手机运行时间,从开机到现在
(秒)
*/
+
(
NSString
*
)
deviceRunTime
{
struct
timeval
boottime
;
...
...
GMPhobos/Classes/UIResponder+PhobosPV.m
View file @
0495bdd9
...
...
@@ -152,7 +152,6 @@
objc_setAssociatedObject
(
self
,
@selector
(
inTime
),
inTime
,
OBJC_ASSOCIATION_COPY
);
}
/**
这个地方inTime的值为nil的情况不做考虑,因为Phobos不会发送。inTime必须在controller viewWillAppear时赋值
*/
...
...
@@ -161,6 +160,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 +244,23 @@
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