Skip to content

Commit

Permalink
fix: 同步 v3.8.3 上的修改内容 (#324)
Browse files Browse the repository at this point in the history
* fix: ANLSPI-20126 do not send autotrack event when session state is not active

* fix: ANLSPI-20159 remove NSLog on release mode

* fix: modify variable in block

* fix(mobiledebugger): large json crash
  • Loading branch information
YoloMao authored Jul 26, 2024
1 parent 76da54a commit c82c206
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 59 deletions.
12 changes: 10 additions & 2 deletions Modules/Flutter/GrowingFlutterPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#import "GrowingTrackerCore/Event/Autotrack/GrowingPageEvent.h"
#import "GrowingTrackerCore/Event/Autotrack/GrowingViewElementEvent.h"
#import "GrowingTrackerCore/Event/GrowingEventManager.h"
#import "GrowingTrackerCore/Manager/GrowingSession.h"
#import "GrowingTrackerCore/Public/GrowingAttributesBuilder.h"
#import "GrowingTrackerCore/Thread/GrowingDispatchManager.h"

Expand Down Expand Up @@ -108,8 +109,15 @@ - (void)trackViewElementEvent:(NSDictionary *)arguments
}

- (void)trackAutotrackEventWithBuilder:(GrowingBaseBuilder *)builder {
builder = builder.setScene(GrowingEventSceneFlutter);
[[GrowingEventManager sharedInstance] postEventBuilder:builder];
[GrowingDispatchManager dispatchInGrowingThread:^{
if ([GrowingSession currentSession].state != GrowingSessionStateActive) {
// 避免在session正在切换的时机之前,flutter侧因用户业务逻辑在后台状态下触发PAGE,回到前台后生成,造成上一个session的访问时长过长
// 另外,flutter sdk的逻辑中,会在返回前台时补发一个当前页面的PAGE,可覆盖上述场景的PAGE生成
return;
}
GrowingBaseBuilder *b = builder.setScene(GrowingEventSceneFlutter);
[[GrowingEventManager sharedInstance] postEventBuilder:b];
}];
}

@end
1 change: 0 additions & 1 deletion Modules/MobileDebugger/GrowingMobileDebugger.m
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ - (BOOL)isRunning {
}

- (void)sendJson:(id)json {
NSLog(@"sendJson : %@", json);
if (self.webSocket.readyState == Growing_WS_OPEN &&
([json isKindOfClass:[NSDictionary class]] || [json isKindOfClass:[NSArray class]])) {
NSString *jsonString = [json growingHelper_jsonString];
Expand Down
80 changes: 40 additions & 40 deletions Services/Database/FMDB/GrowingFMDatabase.m
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ - (BOOL)open {

int err = sqlite3_open([self sqlitePath], &_db );
if(err != SQLITE_OK) {
NSLog(@"error opening!: %d", err);
// NSLog(@"error opening!: %d", err);
return NO;
}

Expand All @@ -200,7 +200,7 @@ - (BOOL)openWithFlags:(int)flags vfs:(NSString *)vfsName {

int err = sqlite3_open_v2([self sqlitePath], &_db, flags, [vfsName UTF8String]);
if(err != SQLITE_OK) {
NSLog(@"error opening!: %d", err);
// NSLog(@"error opening!: %d", err);
return NO;
}

Expand Down Expand Up @@ -235,14 +235,14 @@ - (BOOL)close {
triedFinalizingOpenStatements = YES;
sqlite3_stmt *pStmt;
while ((pStmt = sqlite3_next_stmt(_db, nil)) !=0) {
NSLog(@"Closing leaked statement");
// NSLog(@"Closing leaked statement");
sqlite3_finalize(pStmt);
retry = YES;
}
}
}
else if (SQLITE_OK != rc) {
NSLog(@"error closing!: %d", rc);
// NSLog(@"error closing!: %d", rc);
}
}
while (retry);
Expand Down Expand Up @@ -277,7 +277,7 @@ static int FMG3DBDatabaseBusyHandler(void *f, int count) {
int requestedSleepInMillseconds = (int) arc4random_uniform(50) + 50;
int actualSleepInMilliseconds = sqlite3_sleep(requestedSleepInMillseconds);
if (actualSleepInMilliseconds != requestedSleepInMillseconds) {
NSLog(@"WARNING: Requested sleep of %i milliseconds, but SQLite returned %i. Maybe SQLite wasn't built with HAVE_USLEEP=1?", requestedSleepInMillseconds, actualSleepInMilliseconds);
// NSLog(@"WARNING: Requested sleep of %i milliseconds, but SQLite returned %i. Maybe SQLite wasn't built with HAVE_USLEEP=1?", requestedSleepInMillseconds, actualSleepInMilliseconds);
}
return 1;
}
Expand Down Expand Up @@ -311,15 +311,15 @@ - (NSTimeInterval)maxBusyRetryTimeInterval {
// but for folks who don't bother noticing that the interface to FMG3Database changed,
// we'll still implement the method so they don't get suprise crashes
- (int)busyRetryTimeout {
NSLog(@"%s:%d", __FUNCTION__, __LINE__);
NSLog(@"FMG3DB: busyRetryTimeout no longer works, please use maxBusyRetryTimeInterval");
// NSLog(@"%s:%d", __FUNCTION__, __LINE__);
// NSLog(@"FMG3DB: busyRetryTimeout no longer works, please use maxBusyRetryTimeInterval");
return -1;
}

- (void)setBusyRetryTimeout:(int)i {
#pragma unused(i)
NSLog(@"%s:%d", __FUNCTION__, __LINE__);
NSLog(@"FMG3DB: setBusyRetryTimeout does nothing, please use setMaxBusyRetryTimeInterval:");
// NSLog(@"%s:%d", __FUNCTION__, __LINE__);
// NSLog(@"FMG3DB: setBusyRetryTimeout does nothing, please use setMaxBusyRetryTimeInterval:");
}

#pragma mark Result set functions
Expand Down Expand Up @@ -406,8 +406,8 @@ - (BOOL)rekeyWithData:(NSData *)keyData {
int rc = sqlite3_rekey(_db, [keyData bytes], (int)[keyData length]);

if (rc != SQLITE_OK) {
NSLog(@"error on rekey: %d", rc);
NSLog(@"%@", [self lastErrorMessage]);
// NSLog(@"error on rekey: %d", rc);
// NSLog(@"%@", [self lastErrorMessage]);
}

return (rc == SQLITE_OK);
Expand Down Expand Up @@ -486,7 +486,7 @@ - (BOOL)goodConnection {
}

- (void)warnInUse {
NSLog(@"The FMG3Database %@ is currently in use.", self);
// NSLog(@"The FMG3Database %@ is currently in use.", self);

#ifndef NS_BLOCK_ASSERTIONS
if (_crashOnErrors) {
Expand All @@ -500,7 +500,7 @@ - (BOOL)databaseExists {

if (!_db) {

NSLog(@"The FMG3Database %@ is not open.", self);
// NSLog(@"The FMG3Database %@ is not open.", self);

#ifndef NS_BLOCK_ASSERTIONS
if (_crashOnErrors) {
Expand Down Expand Up @@ -793,7 +793,7 @@ - (GrowingFMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArr
GrowingFMResultSet *rs = 0x00;

if (_traceExecution && sql) {
NSLog(@"%@ executeQuery: %@", self, sql);
// NSLog(@"%@ executeQuery: %@", self, sql);
}

if (_shouldCacheStatements) {
Expand All @@ -808,9 +808,9 @@ - (GrowingFMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArr

if (SQLITE_OK != rc) {
if (_logsErrors) {
NSLog(@"DB Error: %d \"%@\"", [self lastErrorCode], [self lastErrorMessage]);
NSLog(@"DB Query: %@", sql);
NSLog(@"DB Path: %@", _databasePath);
// NSLog(@"DB Error: %d \"%@\"", [self lastErrorCode], [self lastErrorMessage]);
// NSLog(@"DB Query: %@", sql);
// NSLog(@"DB Path: %@", _databasePath);
}

if (_crashOnErrors) {
Expand All @@ -837,7 +837,7 @@ - (GrowingFMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArr
NSString *parameterName = [[NSString alloc] initWithFormat:@":%@", dictionaryKey];

if (_traceExecution) {
NSLog(@"%@ = %@", parameterName, [dictionaryArgs objectForKey:dictionaryKey]);
// NSLog(@"%@ = %@", parameterName, [dictionaryArgs objectForKey:dictionaryKey]);
}

// Get the index for the parameter name.
Expand All @@ -852,7 +852,7 @@ - (GrowingFMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArr
idx++;
}
else {
NSLog(@"Could not find index for %@", dictionaryKey);
// NSLog(@"Could not find index for %@", dictionaryKey);
}
}
}
Expand All @@ -873,10 +873,10 @@ - (GrowingFMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArr

if (_traceExecution) {
if ([obj isKindOfClass:[NSData class]]) {
NSLog(@"data: %ld bytes", (unsigned long)[(NSData*)obj length]);
// NSLog(@"data: %ld bytes", (unsigned long)[(NSData*)obj length]);
}
else {
NSLog(@"obj: %@", obj);
// NSLog(@"obj: %@", obj);
}
}

Expand All @@ -887,7 +887,7 @@ - (GrowingFMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArr
}

if (idx != queryCount) {
NSLog(@"Error: the bind count is not correct for the # of variables (executeQuery)");
// NSLog(@"Error: the bind count is not correct for the # of variables (executeQuery)");
sqlite3_finalize(pStmt);
_isExecutingStatement = NO;
return nil;
Expand Down Expand Up @@ -979,7 +979,7 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra
GrowingFMStatement *cachedStmt = 0x00;

if (_traceExecution && sql) {
NSLog(@"%@ executeUpdate: %@", self, sql);
// NSLog(@"%@ executeUpdate: %@", self, sql);
}

if (_shouldCacheStatements) {
Expand All @@ -993,9 +993,9 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra

if (SQLITE_OK != rc) {
if (_logsErrors) {
NSLog(@"DB Error: %d \"%@\"", [self lastErrorCode], [self lastErrorMessage]);
NSLog(@"DB Query: %@", sql);
NSLog(@"DB Path: %@", _databasePath);
// NSLog(@"DB Error: %d \"%@\"", [self lastErrorCode], [self lastErrorMessage]);
// NSLog(@"DB Query: %@", sql);
// NSLog(@"DB Path: %@", _databasePath);
}

if (_crashOnErrors) {
Expand Down Expand Up @@ -1027,7 +1027,7 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra
NSString *parameterName = [[NSString alloc] initWithFormat:@":%@", dictionaryKey];

if (_traceExecution) {
NSLog(@"%@ = %@", parameterName, [dictionaryArgs objectForKey:dictionaryKey]);
// NSLog(@"%@ = %@", parameterName, [dictionaryArgs objectForKey:dictionaryKey]);
}
// Get the index for the parameter name.
int namedIdx = sqlite3_bind_parameter_index(pStmt, [parameterName UTF8String]);
Expand All @@ -1042,7 +1042,7 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra
idx++;
}
else {
NSLog(@"Could not find index for %@", dictionaryKey);
// NSLog(@"Could not find index for %@", dictionaryKey);
}
}
}
Expand All @@ -1063,10 +1063,10 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra

if (_traceExecution) {
if ([obj isKindOfClass:[NSData class]]) {
NSLog(@"data: %ld bytes", (unsigned long)[(NSData*)obj length]);
// NSLog(@"data: %ld bytes", (unsigned long)[(NSData*)obj length]);
}
else {
NSLog(@"obj: %@", obj);
// NSLog(@"obj: %@", obj);
}
}

Expand All @@ -1078,7 +1078,7 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra


if (idx != queryCount) {
NSLog(@"Error: the bind count (%d) is not correct for the # of variables in the query (%d) (%@) (executeUpdate)", idx, queryCount, sql);
// NSLog(@"Error: the bind count (%d) is not correct for the # of variables in the query (%d) (%@) (executeUpdate)", idx, queryCount, sql);
sqlite3_finalize(pStmt);
_isExecutingStatement = NO;
return NO;
Expand All @@ -1095,22 +1095,22 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra
}
else if (SQLITE_ERROR == rc) {
if (_logsErrors) {
NSLog(@"Error calling sqlite3_step (%d: %s) SQLITE_ERROR", rc, sqlite3_errmsg(_db));
NSLog(@"DB Query: %@", sql);
// NSLog(@"Error calling sqlite3_step (%d: %s) SQLITE_ERROR", rc, sqlite3_errmsg(_db));
// NSLog(@"DB Query: %@", sql);
}
}
else if (SQLITE_MISUSE == rc) {
// uh oh.
if (_logsErrors) {
NSLog(@"Error calling sqlite3_step (%d: %s) SQLITE_MISUSE", rc, sqlite3_errmsg(_db));
NSLog(@"DB Query: %@", sql);
// NSLog(@"Error calling sqlite3_step (%d: %s) SQLITE_MISUSE", rc, sqlite3_errmsg(_db));
// NSLog(@"DB Query: %@", sql);
}
}
else {
// wtf?
if (_logsErrors) {
NSLog(@"Unknown error calling sqlite3_step (%d: %s) eu", rc, sqlite3_errmsg(_db));
NSLog(@"DB Query: %@", sql);
// NSLog(@"Unknown error calling sqlite3_step (%d: %s) eu", rc, sqlite3_errmsg(_db));
// NSLog(@"DB Query: %@", sql);
}
}

Expand Down Expand Up @@ -1143,8 +1143,8 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra

if (closeErrorCode != SQLITE_OK) {
if (_logsErrors) {
NSLog(@"Unknown error finalizing or resetting statement (%d: %s)", closeErrorCode, sqlite3_errmsg(_db));
NSLog(@"DB Query: %@", sql);
// NSLog(@"Unknown error finalizing or resetting statement (%d: %s)", closeErrorCode, sqlite3_errmsg(_db));
// NSLog(@"DB Query: %@", sql);
}
}

Expand Down Expand Up @@ -1226,7 +1226,7 @@ - (BOOL)executeStatements:(NSString *)sql withResultBlock:(FMG3DBExecuteStatemen
rc = sqlite3_exec([self sqliteHandle], [sql UTF8String], block ? FMG3DBExecuteBulkSQLCallback : nil, (__bridge void *)(block), &errmsg);

if (errmsg && [self logsErrors]) {
NSLog(@"Error inserting batch: %s", errmsg);
// NSLog(@"Error inserting batch: %s", errmsg);
sqlite3_free(errmsg);
}

Expand Down
2 changes: 1 addition & 1 deletion Services/Database/FMDB/GrowingFMDatabaseAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ - (NSString*)applicationIDString {
- (void)setApplicationIDString:(NSString*)s {

if ([s length] != 4) {
NSLog(@"setApplicationIDString: string passed is not exactly 4 chars long. (was %ld)", [s length]);
// NSLog(@"setApplicationIDString: string passed is not exactly 4 chars long. (was %ld)", [s length]);
}

[self setApplicationID:NSHFSTypeCodeFromFileType([NSString stringWithFormat:@"'%@'", s])];
Expand Down
4 changes: 2 additions & 2 deletions Services/Database/FMDB/GrowingFMDatabasePool.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ - (GrowingFMDatabase*)db {
NSUInteger currentCount = [self->_databaseOutPool count] + [self->_databaseInPool count];

if (currentCount >= self->_maximumNumberOfDatabasesToCreate) {
NSLog(@"Maximum number of databases (%ld) has already been reached!", (long)currentCount);
// NSLog(@"Maximum number of databases (%ld) has already been reached!", (long)currentCount);
return;
}
}
Expand Down Expand Up @@ -179,7 +179,7 @@ - (GrowingFMDatabase*)db {
}
}
else {
NSLog(@"Could not open up the database at path %@", self->_path);
// NSLog(@"Could not open up the database at path %@", self->_path);
db = 0x00;
}
}];
Expand Down
8 changes: 4 additions & 4 deletions Services/Database/FMDB/GrowingFMDatabaseQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ - (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags vfs:(NSString
BOOL success = [_db open];
#endif
if (!success) {
NSLog(@"Could not create database queue for path %@", aPath);
// NSLog(@"Could not create database queue for path %@", aPath);
FMG3DBRelease(self);
return 0x00;
}
Expand Down Expand Up @@ -160,7 +160,7 @@ - (GrowingFMDatabase*)database {
BOOL success = [_db open];
#endif
if (!success) {
NSLog(@"GrowingFMDatabaseQueue could not reopen database for path %@", _path);
// NSLog(@"GrowingFMDatabaseQueue could not reopen database for path %@", _path);
FMG3DBRelease(_db);
_db = 0x00;
return 0x00;
Expand All @@ -184,13 +184,13 @@ - (void)inDatabase:(void (^)(GrowingFMDatabase *db))block {
block(db);

if ([db hasOpenResultSets]) {
NSLog(@"Warning: there is at least one open result set around after performing [GrowingFMDatabaseQueue inDatabase:]");
// NSLog(@"Warning: there is at least one open result set around after performing [GrowingFMDatabaseQueue inDatabase:]");

#if defined(DEBUG) && DEBUG
NSSet *openSetCopy = FMG3DBReturnAutoreleased([[db valueForKey:@"_openResultSets"] copy]);
for (NSValue *rsInWrappedInATastyValueMeal in openSetCopy) {
GrowingFMResultSet *rs = (GrowingFMResultSet *)[rsInWrappedInATastyValueMeal pointerValue];
NSLog(@"query: '%@'", [rs query]);
// NSLog(@"query: '%@'", [rs query]);
}
#endif
}
Expand Down
Loading

0 comments on commit c82c206

Please sign in to comment.