Skip to content

Commit

Permalink
Release 1.5.5
Browse files Browse the repository at this point in the history
1. 修复无网络时死锁问题
2. 调整默认 flushInterval 为 15 秒
  • Loading branch information
Yuhan ZOU committed Jul 15, 2016
1 parent d13a46d commit c31c564
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 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.5.4"
s.version = "1.5.5"
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ typedef NS_ENUM(NSInteger, SensorsAnalyticsDebugMode) {
* 两次数据发送的最小时间间隔,单位毫秒
*
* @discussion
* 默认值为 60 * 1000 毫秒, 在每次调用track、trackSignUp以及profileSet等接口的时候,
* 默认值为 15 * 1000 毫秒, 在每次调用track、trackSignUp以及profileSet等接口的时候,
* 都会检查如下条件,以判断是否向服务器上传数据:
* 1. 是否WIFI/3G/4G网络
* 2. 是否满足以下数据发送条件之一:
Expand Down
15 changes: 9 additions & 6 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.5.4"
#define VERSION @"1.5.5"

#define PROPERTY_LENGTH_LIMITATION 8191

Expand Down Expand Up @@ -202,7 +202,7 @@ - (instancetype)initWithServerURL:(NSString *)serverURL
self.vtrackServerURL = vtrackServerURL;
_debugMode = debugMode;

_flushInterval = 60 * 1000;
_flushInterval = 15 * 1000;
_flushBulkSize = 100;
_vtrackWindow = nil;

Expand Down Expand Up @@ -300,11 +300,13 @@ - (void)_flush {
NSString *errMsg = [NSString stringWithFormat:@"%@ network failure: %@", self, error];
SAError(@"%@", errMsg);
flushSucc = NO;
dispatch_semaphore_signal(flushSem);
return;
}

if (![response isKindOfClass:[NSHTTPURLResponse class]]) {
flushSucc = NO;
dispatch_semaphore_signal(flushSem);
return;
}

Expand All @@ -326,6 +328,7 @@ - (void)_flush {
} else {
SAError(@"%@", errMsg);
flushSucc = NO;
dispatch_semaphore_signal(flushSem);
return;
}
} else {
Expand Down Expand Up @@ -440,7 +443,7 @@ - (void)_flush {
#endif
return YES;
};

[self flushByType:@"Post" withSize:(_debugMode == SensorsAnalyticsDebugOff ? 50 : 1) andFlushMethod:flushByPost];
[self flushByType:@"SFSafariViewController" withSize:50 andFlushMethod:flushBySafariVC];

Expand Down Expand Up @@ -1079,7 +1082,7 @@ - (void)setFlushInterval:(UInt64)interval {
@synchronized(self) {
_flushInterval = interval;
}
[self flush];
[self _flush];
[self startFlushTimer];
}

Expand All @@ -1090,7 +1093,7 @@ - (void)startFlushTimer {
double interval = _flushInterval > 100 ? (double)_flushInterval / 1000.0 : 0.1f;
self.timer = [NSTimer scheduledTimerWithTimeInterval:interval
target:self
selector:@selector(flush)
selector:@selector(_flush)
userInfo:nil
repeats:YES];
}
Expand Down Expand Up @@ -1194,7 +1197,7 @@ - (void)applicationDidEnterBackground:(NSNotification *)notification {
SADebug(@"%@ application did enter background", self);

if (self.flushBeforeEnterBackground) {
[self flush];
[self _flush];
}

if ([self.abtestDesignerConnection isKindOfClass:[SADesignerConnection class]]
Expand Down

0 comments on commit c31c564

Please sign in to comment.