diff --git a/SensorsAnalyticsSDK/SensorsAnalyticsSDK.podspec b/SensorsAnalyticsSDK/SensorsAnalyticsSDK.podspec index cc26834f..3b9f12d8 100644 --- a/SensorsAnalyticsSDK/SensorsAnalyticsSDK.podspec +++ b/SensorsAnalyticsSDK/SensorsAnalyticsSDK.podspec @@ -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}" } diff --git a/SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.h b/SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.h index 777cdefb..484a3357 100755 --- a/SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.h +++ b/SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.h @@ -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. 是否满足以下数据发送条件之一: diff --git a/SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.m b/SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.m index 48f65389..7b70d50c 100755 --- a/SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.m +++ b/SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.m @@ -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 @@ -202,7 +202,7 @@ - (instancetype)initWithServerURL:(NSString *)serverURL self.vtrackServerURL = vtrackServerURL; _debugMode = debugMode; - _flushInterval = 60 * 1000; + _flushInterval = 15 * 1000; _flushBulkSize = 100; _vtrackWindow = nil; @@ -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; } @@ -326,6 +328,7 @@ - (void)_flush { } else { SAError(@"%@", errMsg); flushSucc = NO; + dispatch_semaphore_signal(flushSem); return; } } else { @@ -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]; @@ -1079,7 +1082,7 @@ - (void)setFlushInterval:(UInt64)interval { @synchronized(self) { _flushInterval = interval; } - [self flush]; + [self _flush]; [self startFlushTimer]; } @@ -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]; } @@ -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]]