Skip to content

Commit

Permalink
Release 1.4.7
Browse files Browse the repository at this point in the history
1. 修复可视化埋点的Bug
  • Loading branch information
Yuhan ZOU committed May 17, 2016
1 parent 7ed96fd commit 910613e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 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.4.6"
s.version = "1.4.7"
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 @@ -150,7 +150,7 @@ - (void)sendMessage:(id<SADesignerMessage>)message {
if (_connected) {

NSString *jsonString = [[NSString alloc] initWithData:[message JSONData:_useGzip] encoding:NSUTF8StringEncoding];
SADebug(@"%@ VTrack sending message: %@", self, [message description]);
// SADebug(@"%@ VTrack sending message: %@", self, [message description]);
[_webSocket send:jsonString];
} else {
SALog(@"Not sending message as we are not connected: %@", [message debugDescription]);
Expand All @@ -163,7 +163,7 @@ - (void)sendMessage:(id<SADesignerMessage>)message {
id <SADesignerMessage> designerMessage = nil;

NSData *jsonData = [message isKindOfClass:[NSString class]] ? [(NSString *)message dataUsingEncoding:NSUTF8StringEncoding] : message;
SADebug(@"%@ VTrack received message: %@", self, [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]);
// SADebug(@"%@ VTrack received message: %@", self, [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]);

NSError *error = nil;
id jsonObject = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ typedef NS_ENUM(NSInteger, SensorsAnalyticsDebugMode) {
*
* @discussion
* 若需要统计某个事件的持续时间,先在事件开始时调用 trackTimer:"Event" 记录事件开始时间,该方法并不会真正发
* 送事件;随后在时间结束时,调用 track:"Event" withProperties:properties,SDK 会追踪 "Event" 事件,并自动将事件持续时
* 送事件;随后在事件结束时,调用 track:"Event" withProperties:properties,SDK 会追踪 "Event" 事件,并自动将事件持续时
* 间记录在事件属性 "event_duration" 中。
*
* 多次调用 trackTimer:"Event" 时,事件 "Event" 的开始时间以最后一次调用时为准。
Expand Down
22 changes: 9 additions & 13 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.4.6"
#define VERSION @"1.4.7"

#define PROPERTY_LENGTH_LIMITATION 255

Expand Down Expand Up @@ -76,7 +76,6 @@ @implementation SensorsAnalyticsSDK {
SensorsAnalyticsDebugMode _debugMode;
UInt64 _flushBulkSize;
UInt64 _flushInterval;
UInt64 _lastFlushTime;
UInt32 _vtrackWindowIndex;
NSDateFormatter *_dateFormatter;
}
Expand Down Expand Up @@ -238,8 +237,7 @@ - (instancetype)initWithServerURL:(NSString *)serverURL
[self executeEventBindings:self.eventBindings];

[self checkForConfigure];

_lastFlushTime = [[self class] getCurrentTime];

[self startFlushTimer];
}

Expand Down Expand Up @@ -450,7 +448,7 @@ - (void)flush {
#endif
return YES;
};

dispatch_async(self.serialQueue, ^{
[self flushByType:@"Post" withSize:(_debugMode == SensorsAnalyticsDebugOff ? 50 : 1) andFlushMethod:flushByPost];
[self flushByType:@"SFSafariViewController" withSize:(_debugMode == SensorsAnalyticsDebugOff ? 50 : 1) andFlushMethod:flushBySafariVC];
Expand All @@ -460,9 +458,6 @@ - (void)flush {
reason:@"vacuum in Message Queue in Sqlite fail"
userInfo:nil];
}


_lastFlushTime = [[self class] getCurrentTime];
});
}

Expand Down Expand Up @@ -508,7 +503,7 @@ - (void)enqueueWithType:(NSString *)type andEvent:(NSDictionary *)e {
if ([properties objectForKey:@"$ios_install_source"]) {
flushMethod = @"SFSafariViewController";
}

[self.messageQueue addObejct:event withType:flushMethod];

if (_debugMode != SensorsAnalyticsDebugOff) {
Expand Down Expand Up @@ -591,7 +586,7 @@ - (void)track:(NSString *)event withProperties:(NSDictionary *)propertieDict wit
[libProperties setValue:detail forKey:@"$lib_detail"];
}
}

dispatch_async(self.serialQueue, ^{
NSMutableDictionary *p = [NSMutableDictionary dictionary];
if ([type isEqualToString:@"track"] || [type isEqualToString:@"track_signup"]) {
Expand Down Expand Up @@ -1102,8 +1097,9 @@ - (void)setFlushInterval:(UInt64)interval {
- (void)startFlushTimer {
[self stopFlushTimer];
dispatch_async(dispatch_get_main_queue(), ^{
if (self.flushInterval > 0) {
self.timer = [NSTimer scheduledTimerWithTimeInterval:(double)self.flushInterval / 1000.0
double interval = _flushInterval > 100 ? (double)_flushInterval / 1000.0 : 0.1f;
if (self.flushInterval > 100) {
self.timer = [NSTimer scheduledTimerWithTimeInterval:interval
target:self
selector:@selector(flush)
userInfo:nil
Expand Down Expand Up @@ -1306,7 +1302,7 @@ - (void)connectToVTrackDesigner:(BOOL)reconnect {
void (^connectCallback)(void) = ^{
__strong SensorsAnalyticsSDK *strongSelf = weakSelf;
oldInterval = strongSelf.flushInterval;
strongSelf.flushInterval = 1;
strongSelf.flushInterval = 1000;
[UIApplication sharedApplication].idleTimerDisabled = YES;
if (strongSelf) {
NSMutableSet *eventBindings = [strongSelf.eventBindings mutableCopy];
Expand Down

0 comments on commit 910613e

Please sign in to comment.