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
fd789797
Commit
fd789797
authored
Feb 07, 2017
by
汪洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化captureNullExpection
parent
0e425556
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
13 deletions
+21
-13
GMPhotoTest.m
Example/Tests/GMPhotoTest.m
+7
-1
Phobos.h
Pod/Classes/Phobos.h
+1
-1
Phobos.m
Pod/Classes/Phobos.m
+13
-11
No files found.
Example/Tests/GMPhotoTest.m
View file @
fd789797
...
...
@@ -114,7 +114,7 @@ NSString *const MockCityId = @"beijing";
}
-
(
void
)
testCatchNullInAttributes
{
_client
.
captureNullExpection
=
^
(
NSDictionary
*
att
)
{
_client
.
captureNullExpection
=
^
(
NS
String
*
eventId
,
NS
Dictionary
*
att
)
{
NSCAssert
([
att
[
@"bussness_id"
]
integerValue
]
==
1244
,
@"testCatchNullInAttributes 没有捕获到有用信息"
);
};
NSDictionary
*
attributes
=
@{
@"key"
:
[
NSNull
null
],
...
...
@@ -142,6 +142,12 @@ NSString *const MockCityId = @"beijing";
[
controller
viewWillAppear
:
true
];
[
controller
viewWillDisappear
:
true
];
[
self
paramUnNilCheck
];
NSArray
*
array
=
[[
WMCacheService
sharedInstance
]
fetchObjectAtDiskWithkey
:
PhobosCacheKey
];
XCTAssertTrue
(
array
.
count
!=
0
,
@"PhobosCacheKey 下面应该有数据"
);
NSDictionary
*
dic
=
array
[
0
][
@"params"
];
XCTAssertTrue
([
dic
[
@"referrer_id"
]
isEqualToString
:
@"rreferrerIdTest"
],
@"referrerId至少使用默认的空字符串"
);
}
-
(
void
)
testSimulativePageViewEvent
{
...
...
Pod/Classes/Phobos.h
View file @
fd789797
...
...
@@ -32,7 +32,7 @@
#pragma mark - SDK配置
// Phobos在处理业务端传递来的参数时会检查是否某个value为空,如果为空会调用这个block以通知业务层,业务层可以上报这个异常,以助解决问题
@property
(
nonatomic
,
copy
)
void
(
^
captureNullExpection
)
(
NSDictionary
*
info
);
@property
(
nonatomic
,
copy
)
void
(
^
captureNullExpection
)
(
NS
String
*
eventId
,
NS
Dictionary
*
info
);
/**
网络状态 wifi=1, mobile=0, 不连通=-1
...
...
Pod/Classes/Phobos.m
View file @
fd789797
...
...
@@ -304,7 +304,7 @@ static NSString *sdkVersion = @"110";
* @since 0.0.1
*/
-
(
NSDictionary
*
)
prepareDictionaryForEvent
:
(
NSString
*
)
eventId
attributes
:
(
NSDictionary
*
)
attributes
{
[
self
performSelectorInBackground
:
@selector
(
catchNullInAttributes
:)
withObject
:
attributes
];
[
self
catchNullForEvent
:
eventId
attributes
:
attributes
];
NSMutableDictionary
*
dict
=
[[
NSMutableDictionary
alloc
]
init
];
@try
{
NSString
*
currentTime
=
[
PhobosUtil
currentTime
];
...
...
@@ -400,19 +400,21 @@ static NSString *sdkVersion = @"110";
}
#pragma mark - helpers
-
(
void
)
catchNullInAttributes
:
(
NSDictionary
*
)
attributes
{
@try
{
for
(
NSString
*
key
in
attributes
.
allKeys
)
{
if
([
attributes
[
key
]
isMemberOfClass
:[
NSNull
class
]])
{
if
(
self
.
captureNullExpection
)
{
self
.
captureNullExpection
(
attributes
);
-
(
void
)
catchNullForEvent
:
(
NSString
*
)
eventId
attributes
:
(
NSDictionary
*
)
attributes
{
dispatch_async
(
dispatch_get_global_queue
(
0
,
0
),
^
{
@try
{
for
(
NSString
*
key
in
attributes
.
allKeys
)
{
if
([
attributes
[
key
]
isMemberOfClass
:[
NSNull
class
]])
{
if
(
self
.
captureNullExpection
)
{
self
.
captureNullExpection
(
eventId
,
attributes
);
}
break
;
}
break
;
}
}
@catch
(
NSException
*
exception
)
{
}
}
@catch
(
NSException
*
exception
)
{
}
});
}
@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