Skip to content

Commit

Permalink
Release 1.3.9
Browse files Browse the repository at this point in the history
1. 修复 NSDate 属性序列化的Bug
  • Loading branch information
Yuhan ZOU committed Apr 8, 2016
1 parent 3b7fcbc commit 7eeaa1c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/SensorsAnalyticsSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SensorsAnalyticsSDK"
s.version = "1.3.8"
s.version = "1.3.9"
s.summary = "The offical iOS SDK of Sensors Analytics."
s.homepage = "http://www.sensorsdata.cn"
s.source = { :git => 'https://github.com/sensorsdata/sa-sdk-ios.git', :tag => "v#{s.version}" }
Expand Down
30 changes: 20 additions & 10 deletions SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#import "SASwizzler.h"
#import "SensorsAnalyticsSDK.h"

#define VERSION @"1.3.8"
#define VERSION @"1.3.9"

@implementation SensorsAnalyticsDebugException

Expand Down Expand Up @@ -66,6 +66,7 @@ @implementation SensorsAnalyticsSDK {
SensorsAnalyticsDebugMode _debugMode;
UInt64 _flushInterval;
UInt64 _lastFlushTime;
NSDateFormatter *_dateFormatter;
}

static SensorsAnalyticsSDK *sharedInstance = nil;
Expand Down Expand Up @@ -182,6 +183,10 @@ - (instancetype)initWithServerURL:(NSString *)serverURL
_flushInterval = 60 * 100;
}


_dateFormatter = [[NSDateFormatter alloc] init];
[_dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm:ss.SSS"];

self.checkForEventBindingsOnActive = YES;
self.flushBeforeEnterBackground = NO;

Expand Down Expand Up @@ -375,10 +380,8 @@ - (void)enqueueWithType:(NSString *)type andEvent:(NSDictionary *)e {
[event setObject:properties forKey:@"properties"];
}

SADebug(@"%@ queueing event: %@", self, event);
[self.messageQueue addObejct:event];


if (_debugMode != SensorsAnalyticsDebugOff) {
// 在DEBUG模式下,同步发送所有事件
[self flush];
Expand Down Expand Up @@ -436,17 +439,24 @@ - (void)track:(NSString *)event withProperties:(NSDictionary *)propertieDict wit
// 这里注意下顺序,按照优先级从低到高,依次是automaticProperties, superProperties和propertieDict
[p addEntriesFromDictionary:self.automaticProperties];
[p addEntriesFromDictionary:_superProperties];
if (propertieDict) {
[p addEntriesFromDictionary:propertieDict];
}

// 是否WIFI是每次track的时候需要判断一次的
[p setObject:[self ifWifi] forKey:@"$wifi"];
} else {
// 对于profile类型的请求,则不需要这些property了
if (propertieDict) {
[p addEntriesFromDictionary:propertieDict];
}

if (propertieDict) {
for (id key in propertieDict) {
NSObject *obj = propertieDict[key];
if ([obj isKindOfClass:[NSDate class]]) {
// 序列化所有 NSDate 类型
NSString *dateStr = [_dateFormatter stringFromDate:(NSDate *)obj];
[p setObject:dateStr forKey:key];
} else {
[p setObject:obj forKey:key];
}
}
}

NSDictionary *e;
if ([type isEqualToString:@"track_signup"]) {
e = @{
Expand Down

0 comments on commit 7eeaa1c

Please sign in to comment.