Skip to content

Commit

Permalink
Release 1.5.3
Browse files Browse the repository at this point in the history
1. 修复 track_installation 时的异常情况
  • Loading branch information
Yuhan ZOU committed Jul 5, 2016
1 parent 4b05a0b commit e37ce21
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 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.2"
s.version = "1.5.3"
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
28 changes: 14 additions & 14 deletions SensorsAnalyticsSDK/SensorsAnalyticsSDK/MessageQueueBySqlite.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ - (void)addObejct:(id)obj withType:(NSString *)type {
SAError(@"touch MAX_MESSAGE_SIZE:%d, do not insert", MAX_MESSAGE_SIZE);
return;
}
NSData * jsonData = [_jsonUtil JSONSerializeObject:obj];
NSString * jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSString *query = @"INSERT INTO dataCache(type, content) values(?, ?)";
NSData* jsonData = [_jsonUtil JSONSerializeObject:obj];
NSString* jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSString* query = @"INSERT INTO dataCache(type, content) values(?, ?)";
sqlite3_stmt *insertStatement;
int rc ;
int rc;
rc = sqlite3_prepare_v2(_database, [query UTF8String],-1, &insertStatement, nil);
if (rc == SQLITE_OK) {
sqlite3_bind_text(insertStatement, 1, [type UTF8String], -1, SQLITE_TRANSIENT);
Expand All @@ -90,9 +90,9 @@ - (NSArray *) getFirstRecords:(NSUInteger)recordSize withType:(NSString *)type {
return @[];
}

NSMutableArray * contentArray = [[NSMutableArray alloc] init];
NSMutableArray* contentArray = [[NSMutableArray alloc] init];

NSString *query = [NSString stringWithFormat:@"SELECT content FROM dataCache WHERE type='%@' ORDER BY id ASC LIMIT %lu", type, (unsigned long)recordSize];
NSString* query = [NSString stringWithFormat:@"SELECT content FROM dataCache WHERE type='%@' ORDER BY id ASC LIMIT %lu", type, (unsigned long)recordSize];

sqlite3_stmt* stmt = NULL;
int rc = sqlite3_prepare_v2(_database, [query UTF8String], -1, &stmt, NULL);
Expand All @@ -112,9 +112,9 @@ - (NSArray *) getFirstRecords:(NSUInteger)recordSize withType:(NSString *)type {

- (BOOL) removeFirstRecords:(NSUInteger)recordSize withType:(NSString *)type {
NSUInteger removeSize = MIN(recordSize, _messageCount);
NSString *query = [NSString stringWithFormat:@"DELETE FROM dataCache WHERE id IN (SELECT id FROM dataCache WHERE type = '%@' ORDER BY id ASC LIMIT %lu);", type, (unsigned long)removeSize];
char * errMsg;
if (sqlite3_exec(_database, [query UTF8String] ,NULL,NULL,&errMsg) != SQLITE_OK) {
NSString* query = [NSString stringWithFormat:@"DELETE FROM dataCache WHERE id IN (SELECT id FROM dataCache WHERE type = '%@' ORDER BY id ASC LIMIT %lu);", type, (unsigned long)removeSize];
char* errMsg;
if (sqlite3_exec(_database, [query UTF8String], NULL, NULL, &errMsg) != SQLITE_OK) {
SAError(@"Failed to delete record msg=%s", errMsg);
return NO;
}
Expand All @@ -127,7 +127,7 @@ - (NSUInteger) count {
}

- (NSInteger) sqliteCount {
NSString *query = @"select count(*) from dataCache";
NSString* query = @"select count(*) from dataCache";
sqlite3_stmt* statement = NULL;
NSInteger count = -1;
int rc = sqlite3_prepare_v2(_database, [query UTF8String], -1, &statement, NULL);
Expand All @@ -144,10 +144,10 @@ - (NSInteger) sqliteCount {
}

- (BOOL) vacuum {
NSString *query = @"VACUUM";
char * errMsg;
if (sqlite3_exec(_database, [query UTF8String] ,NULL,NULL,&errMsg) != SQLITE_OK) {
NSLog(@"Failed to delete record msg=%s", errMsg);
NSString* query = @"VACUUM";
char* errMsg;
if (sqlite3_exec(_database, [query UTF8String], NULL, NULL, &errMsg) != SQLITE_OK) {
SAError(@"Failed to delete record msg=%s", errMsg);
return NO;
}
return YES;
Expand Down
12 changes: 7 additions & 5 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.2"
#define VERSION @"1.5.3"

#define PROPERTY_LENGTH_LIMITATION 8191

Expand Down Expand Up @@ -408,7 +408,11 @@ - (void)flush {

UIViewController *windowRootController = [[UIViewController alloc] init];

self.secondWindow = [[UIWindow alloc] initWithFrame:[[[[UIApplication sharedApplication] delegate] window] bounds]];
if (self.vtrackWindow == nil) {
self.secondWindow = [[UIWindow alloc] initWithFrame:[[[[UIApplication sharedApplication] delegate] window] bounds]];
} else {
self.secondWindow = [[UIWindow alloc] initWithFrame:[self.vtrackWindow bounds]];
}
self.secondWindow.rootViewController = windowRootController;
self.secondWindow.windowLevel = UIWindowLevelNormal - 1;
[self.secondWindow setHidden:NO];
Expand Down Expand Up @@ -450,9 +454,7 @@ - (void)flush {
[self flushByType:@"SFSafariViewController" withSize:(_debugMode == SensorsAnalyticsDebugOff ? 50 : 1) andFlushMethod:flushBySafariVC];

if (![self.messageQueue vacuum]) {
@throw [NSException exceptionWithName:@"SqliteException"
reason:@"vacuum in Message Queue in Sqlite fail"
userInfo:nil];
SAError(@"Failed to VACUUM SQLite.");
}
});
}
Expand Down

0 comments on commit e37ce21

Please sign in to comment.