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
bfd0d80b
Commit
bfd0d80b
authored
Nov 23, 2018
by
朱璇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
7730精准曝光 增加新的API
parent
49ed583a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
2 deletions
+46
-2
Phobos.h
GMPhobos/Classes/Phobos.h
+18
-0
Phobos.m
GMPhobos/Classes/Phobos.m
+25
-1
PhobosUtil.m
GMPhobos/Classes/PhobosUtil.m
+3
-1
No files found.
GMPhobos/Classes/Phobos.h
View file @
bfd0d80b
...
...
@@ -77,6 +77,11 @@
*/
@property
(
copy
,
nonatomic
)
NSString
*
serverAPI
;
/**
数据接收的服务器API(新开的接口)7730精准曝光
*/
@property
(
copy
,
nonatomic
)
NSString
*
currentServerAPI
;
/**
从主项目获取当前显示的controller
*/
...
...
@@ -97,6 +102,19 @@
+
(
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
*
...
...
GMPhobos/Classes/Phobos.m
View file @
bfd0d80b
...
...
@@ -263,7 +263,6 @@ static NSString *sdkVersion = @"110";
[
sharedClient
sendArray
:
array
cleanCacheRightNow
:
YES
];
}
}
+
(
void
)
track
:
(
NSString
*
)
eventId
attributes
:
(
NSDictionary
*
)
attributes
sendNow
:
(
BOOL
)
sendNow
{
NSDictionary
*
dict
=
[
sharedClient
prepareDictionaryForEvent
:
eventId
attributes
:
attributes
];
if
(
sendNow
)
{
...
...
@@ -275,6 +274,31 @@ static NSString *sdkVersion = @"110";
}
}
+
(
void
)
track
:
(
NSString
*
)
eventId
attributes
:
(
NSDictionary
*
)
attributes
currentAPI
:
(
NSString
*
)
currentAPI
{
[
self
track
:
eventId
attributes
:
attributes
sendNow
:
NO
currentAPI
:
currentAPI
];
NSArray
*
array
=
[
GMCache
fetchObjectAtDocumentPathWithkey
:
PhobosCacheKey
];
//超过一定数量的话,统一发送一次
if
(
array
.
count
>
PhobosShardCount
)
{
[
sharedClient
sendArray
:
array
cleanCacheRightNow
:
YES
];
}
}
+
(
void
)
track
:
(
NSString
*
)
eventId
attributes
:
(
NSDictionary
*
)
attributes
sendNow
:
(
BOOL
)
sendNow
currentAPI
:
(
NSString
*
)
currentAPI
{
[
Phobos
sharedClient
].
currentServerAPI
=
currentAPI
;
NSDictionary
*
dict
=
[
sharedClient
prepareDictionaryForEvent
:
eventId
attributes
:
attributes
];
if
(
sendNow
)
{
NSArray
*
array
=
@[
dict
];
// 实时发送的埋点,不能立即清楚缓存
[
sharedClient
sendArray
:
array
cleanCacheRightNow
:
NO
];
}
else
{
[
sharedClient
save
:
dict
];
}
}
+
(
void
)
track
:
(
NSString
*
)
eventId
currentAPI
:
(
NSString
*
)
currentAPI
{
[
Phobos
track
:
eventId
attributes
:@{}
currentAPI
:
currentAPI
];
}
+
(
void
)
trackJsEvent
:
(
NSString
*
)
jsonString
{
@try
{
NSData
*
data
=
[
jsonString
dataUsingEncoding
:
NSUnicodeStringEncoding
];
...
...
GMPhobos/Classes/PhobosUtil.m
View file @
bfd0d80b
...
...
@@ -114,7 +114,9 @@
+
(
void
)
sendData
:(
NSData
*
)
data
success
:(
SendDataSuccessBlock
)
success
{
@try
{
NSMutableURLRequest
*
request
=
[[
NSMutableURLRequest
alloc
]
initWithURL
:[
NSURL
URLWithString
:[
Phobos
sharedClient
].
serverAPI
]];
NSString
*
url
=
[
Phobos
sharedClient
].
currentServerAPI
.
length
>
0
?
[
Phobos
sharedClient
].
currentServerAPI
:
[
Phobos
sharedClient
].
serverAPI
;
NSMutableURLRequest
*
request
=
[[
NSMutableURLRequest
alloc
]
initWithURL
:[
NSURL
URLWithString
:
url
]];
[
Phobos
sharedClient
].
currentServerAPI
=
@""
;
// 用完置为空 防止下次判断无效出现错误
[
request
setValue
:
@"gzip"
forHTTPHeaderField
:
@"Content-Encoding"
];
request
.
HTTPBody
=
data
;
request
.
HTTPMethod
=
@"POST"
;
...
...
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