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
a95c7555
Commit
a95c7555
authored
May 24, 2017
by
翟国钧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加一个专门负责发送数据的方法,修改边界情况下的bug:当cache中的数据满50条发送给服务器的时候,再有数据过来,会重复发送
parent
26d9c677
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
20 deletions
+44
-20
Podfile.lock
Example/Podfile.lock
+2
-2
GMPhobos.podspec.json
Example/Pods/Local Podspecs/GMPhobos.podspec.json
+2
-2
Manifest.lock
Example/Pods/Manifest.lock
+2
-2
Info.plist
Example/Pods/Target Support Files/GMPhobos/Info.plist
+1
-1
Phobos.m
Pod/Classes/Phobos.m
+35
-12
PhobosConfig.h
Pod/Classes/PhobosConfig.h
+2
-1
No files found.
Example/Podfile.lock
View file @
a95c7555
PODS:
- GMCache (0.1.1):
- TMCache (~> 2.1.0)
- GMPhobos (0.3.
6
):
- GMPhobos (0.3.
7
):
- GMCache (~> 0.1.1)
- TMCache (2.1.0)
...
...
@@ -14,7 +14,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
GMCache: 73855b613b9d7e34f4f37ad425e8b8153b760c04
GMPhobos:
a7e9b181f903becb1135b5f058f80353fe3dd784
GMPhobos:
57d155e2b1e64934b8507c275d6dbe53b1631457
TMCache: 95ebcc9b3c7e90fb5fd8fc3036cba3aa781c9bed
PODFILE CHECKSUM: 281ed5ce2f0e8e2e49cc13b1e4726e6686ac6095
...
...
Example/Pods/Local Podspecs/GMPhobos.podspec.json
View file @
a95c7555
{
"name"
:
"GMPhobos"
,
"version"
:
"0.3.
6
"
,
"version"
:
"0.3.
7
"
,
"summary"
:
"GM statistic data sdk"
,
"description"
:
"GM event track sdk."
,
"homepage"
:
"http://git.gengmei.cc/gengmeiios/GMPhobos"
,
...
...
@@ -10,7 +10,7 @@
},
"source"
:
{
"git"
:
"git@git.gengmei.cc:gengmeiios/GMPhobos.git"
,
"tag"
:
"0.3.
6
"
"tag"
:
"0.3.
7
"
},
"platforms"
:
{
"ios"
:
"8.0"
...
...
Example/Pods/Manifest.lock
View file @
a95c7555
PODS:
- GMCache (0.1.1):
- TMCache (~> 2.1.0)
- GMPhobos (0.3.
6
):
- GMPhobos (0.3.
7
):
- GMCache (~> 0.1.1)
- TMCache (2.1.0)
...
...
@@ -14,7 +14,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
GMCache: 73855b613b9d7e34f4f37ad425e8b8153b760c04
GMPhobos:
a7e9b181f903becb1135b5f058f80353fe3dd784
GMPhobos:
57d155e2b1e64934b8507c275d6dbe53b1631457
TMCache: 95ebcc9b3c7e90fb5fd8fc3036cba3aa781c9bed
PODFILE CHECKSUM: 281ed5ce2f0e8e2e49cc13b1e4726e6686ac6095
...
...
Example/Pods/Target Support Files/GMPhobos/Info.plist
View file @
a95c7555
...
...
@@ -15,7 +15,7 @@
<
k
e
y
>
CFBundlePackageType
<
/k
e
y
>
<
string
>
FMWK
<
/string
>
<
k
e
y
>
CFBundleShortVersionString
<
/k
e
y
>
<
string
>
0.3.
6
<
/string
>
<
string
>
0.3.
7
<
/string
>
<
k
e
y
>
CFBundleSignature
<
/k
e
y
>
<
string
>
????
<
/string
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
...
...
Pod/Classes/Phobos.m
View file @
a95c7555
...
...
@@ -404,26 +404,21 @@ static NSString *sdkVersion = @"110";
}
}
/**
向Mars发送埋点数据,如果是实时发送的,http请求成功之后,不清楚已有的缓存数据。
针对普通埋点数据,发送成功之后,立即删除本地的缓存。
@author zhaiguojun 16-10-17 in (null)
@param array 参数
@param now 是否立即清楚缓存
/*
从缓存区获取数据,发给服务器,请求成功的时候,把缓存区的数据删除掉
*/
-
(
void
)
sendArray
:
(
NSArray
*
)
array
cleanCacheRightNow
:
(
BOOL
)
clean
{
-
(
void
)
sendArray
{
NSMutableArray
*
dataArray
=
[[
WMCacheService
sharedInstance
]
fetchObjectAtDiskWithkey
:
PhobosTempCacheKey
];
if
(
_logEnabled
)
{
phobosLog
([
NSString
stringWithFormat
:
@"array prepare to fly --✈: %@"
,
a
rray
]);
phobosLog
([
NSString
stringWithFormat
:
@"array prepare to fly --✈: %@"
,
dataA
rray
]);
}
@try
{
NSData
*
JSON
=
[
PhobosUtil
encodeJSON
:
a
rray
];
NSData
*
JSON
=
[
PhobosUtil
encodeJSON
:
dataA
rray
];
NSData
*
compressedData
=
[
PhobosUtil
compressData
:
JSON
];
if
(
compressedData
)
{
[
PhobosUtil
sendData
:
compressedData
success
:
^
(
NSInteger
code
)
{
phobosLog
(
@"✈ ---------- ✈ data arrived Mars"
);
if
(
clean
)
{
[[
WMCacheService
sharedInstance
]
removeObjectAtDiskWithkey
:
PhobosCacheKey
];
}
[[
WMCacheService
sharedInstance
]
removeObjectAtDiskWithkey
:
PhobosTempCacheKey
];
}];
}
}
...
...
@@ -432,6 +427,34 @@ static NSString *sdkVersion = @"110";
}
}
/**
该方法有改动,现在的逻辑是:当前方法只接受发送的请求,然后把数据转存到另一个缓存区,
让sendArray方法负责发送,数据一旦转移到缓存区,就把原有的数据干掉。
@author zhaiguojun 16-10-17 in (null)
@param array 参数
@param now 是否立即清楚缓存
*/
-
(
void
)
sendArray
:
(
NSArray
*
)
array
cleanCacheRightNow
:
(
BOOL
)
clean
{
@try
{
//1.获取缓存区的数据,把新数据追加进去
WMCacheService
*
cache
=
[
WMCacheService
sharedInstance
];
NSMutableArray
*
dataArray
=
[
cache
fetchObjectAtDiskWithkey
:
PhobosTempCacheKey
];
if
(
dataArray
)
{
[
dataArray
addObjectsFromArray
:
array
];
}
else
{
dataArray
=
[
NSMutableArray
arrayWithArray
:
array
];
}
[
cache
storeObjectAtDiskWithkey
:
PhobosTempCacheKey
object
:
dataArray
];
//2.把缓存区的数据发送给服务器
[
self
sendArray
];
//3.把原有的数据删除
[
cache
removeObjectAtDiskWithkey
:
PhobosCacheKey
];
}
@catch
(
NSException
*
exception
)
{
phobosLog
(
exception
);
}
}
#pragma mark - helpers
-
(
void
)
catchNullForEvent
:
(
NSString
*
)
eventId
attributes
:
(
NSDictionary
*
)
attributes
{
dispatch_async
(
dispatch_get_global_queue
(
0
,
0
),
^
{
...
...
Pod/Classes/PhobosConfig.h
View file @
a95c7555
...
...
@@ -18,7 +18,8 @@
#define PhobosHaveOpenApp @"PhobosHaveOpenApp" //是否打开过APP
#define PhobosBeginTime @"PhobosBeginTime" //记录APP打开|从后台启动时的时间戳
#define PhobosEndTime @"PhobosEndTime" //记录APP退出|退到后台时的时间戳
#define PhobosCacheKey @"PhobosCacheKey"
#define PhobosCacheKey @"PhobosCacheKey" //存放持久化埋点数据的key
#define PhobosTempCacheKey @"PhobosTempCacheKey" //临时存放待发送埋点数据的key
#define PhobosShardCount 50 //收集数据分段发送的个数
#endif
/* PhobosConfig_h */
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