Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/github_actions/SonarSource/son…
Browse files Browse the repository at this point in the history
…arcloud-github-c-cpp-3
  • Loading branch information
SKannaniOS authored Nov 11, 2024
2 parents 6f52a21 + e74cc1b commit d227731
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 97 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.30.0](https://github.com/rudderlabs/rudder-sdk-ios/compare/v1.29.1...v1.30.0) (2024-11-11)


### Features

* upgrade the maximum event size limit ([#548](https://github.com/rudderlabs/rudder-sdk-ios/issues/548)) ([892892d](https://github.com/rudderlabs/rudder-sdk-ios/commit/892892ddf234b7d76abc4fa9ad2f629bb08517f7))


### Bug Fixes

* memory issue crash happening on CloudModeProcessor ([#544](https://github.com/rudderlabs/rudder-sdk-ios/issues/544)) ([a71ac44](https://github.com/rudderlabs/rudder-sdk-ios/commit/a71ac444393b750a9dcbe5dd094924e72f60799f))

### [1.29.1](https://github.com/rudderlabs/rudder-sdk-ios/compare/v1.29.0...v1.29.1) (2024-10-07)


Expand Down
4 changes: 2 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PODS:
- RSCrashReporter (= 1.0.1)
- RudderKit (= 1.4.0)
- RSCrashReporter (1.0.1)
- Rudder (1.28.1):
- Rudder (1.29.1):
- MetricsReporter (= 2.0.0)
- RudderKit (1.4.0)
- SQLCipher (4.5.4):
Expand Down Expand Up @@ -33,7 +33,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
MetricsReporter: 364b98791e868b10e9d512eb50af28d8c11e5cdb
RSCrashReporter: 6b8376ac729b0289ebe0908553e5f56d8171f313
Rudder: 07c2c7f8f02a91a3c8343d7284d3b3b49f8da969
Rudder: 731095848aee39d27ff5d0e78233aa5ad8febb0b
RudderKit: d9d6997696e1642b753d8bdf94e57af643a68f03
SQLCipher: 905b145f65f349f26da9e60a19901ad24adcd381

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<p align="center">
<a href="https://cocoapods.org/pods/Rudder">
<img src="https://img.shields.io/static/v1?label=pod&message=v1.29.1&color=blue&style=flat">
<img src="https://img.shields.io/static/v1?label=pod&message=v1.30.0&color=blue&style=flat">
</a>
</p>

Expand Down Expand Up @@ -39,15 +39,15 @@ The iOS SDK is available through [**CocoaPods**](https://cocoapods.org), [**Cart
To install the SDK, simply add the following line to your Podfile:

```xcode
pod 'Rudder', '1.29.1'
pod 'Rudder', '1.30.0'
```

### Carthage

For Carthage support, add the following line to your `Cartfile`:

```xcode
github "rudderlabs/rudder-sdk-ios" "v1.29.1"
github "rudderlabs/rudder-sdk-ios" "v1.30.0"
```

> Remember to include the following code in all `.m` and `.h` files where you want to refer to or use the RudderStack SDK classes, as shown:
Expand All @@ -71,7 +71,7 @@ You can also add the RudderStack iOS SDK via Swift Package Mangaer, via one of t

* Enter the package repository (`[email protected]:rudderlabs/rudder-sdk-ios.git`) in the search bar.

* In **Dependency Rule**, select **Up to Next Major Version** and enter `1.29.1` as the value, as shown:
* In **Dependency Rule**, select **Up to Next Major Version** and enter `1.30.0` as the value, as shown:

![Setting dependency](https://user-images.githubusercontent.com/59817155/145574696-8c849749-13e0-40d5-aacb-3fccb5c8e67d.png)

Expand Down Expand Up @@ -99,7 +99,7 @@ let package = Package(
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "[email protected]:rudderlabs/rudder-sdk-ios.git", from: "1.29.1")
.package(url: "[email protected]:rudderlabs/rudder-sdk-ios.git", from: "1.30.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Classes/Headers/RSVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
#ifndef RSVersion_h
#define RSVersion_h

NSString *const SDK_VERSION = @"1.29.1";
NSString *const SDK_VERSION = @"1.30.0";

#endif /* RSVersion_h */
85 changes: 39 additions & 46 deletions Sources/Classes/RSCloudModeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,55 +39,48 @@ - (void) startCloudModeProcessor {
[RSLogger logDebug:@"RSCloudModeManager: CloudModeProcessor: Starting the Cloud Mode Processor"];
int sleepCount = 0;
while (YES) {
@try {
[strongSelf->lock lock];
RSNetworkResponse* response = nil;
[strongSelf->dbPersistentManager clearOldEventsWithThreshold: strongSelf->config.dbCountThreshold];
[RSLogger logDebug:@"RSCloudModeManager: CloudModeProcessor: Fetching events to flush to server"];
RSDBMessage* dbMessage = [strongSelf->dbPersistentManager fetchEventsFromDB:(strongSelf->config.flushQueueSize) ForMode:CLOUDMODE];
if ((dbMessage.messages.count >= strongSelf->config.flushQueueSize) || (dbMessage.messages.count > 0 && (sleepCount >= strongSelf->config.sleepTimeout))) {
NSString* payload = [RSCloudModeManager getPayloadFromMessages:dbMessage];
[RSLogger logDebug:[[NSString alloc] initWithFormat:@"RSCloudModeManager: CloudModeProcessor: Payload: %@", payload]];
[RSLogger logInfo:[[NSString alloc] initWithFormat:@"RSCloudModeManager: CloudModeProcessor: EventCount: %lu", (unsigned long)dbMessage.messageIds.count]];
[RSMetricsReporter report:SDKMETRICS_CM_EVENT forMetricType:COUNT withProperties:@{SDKMETRICS_TYPE: SDKMETRICS_MESSAGES} andValue:(float)dbMessage.messages.count];
if (payload != nil) {
response = [strongSelf->networkManager sendNetworkRequest:payload toEndpoint:BATCH_ENDPOINT withRequestMethod:POST];
if (response.state == NETWORK_SUCCESS) {
[RSLogger logDebug:[[NSString alloc] initWithFormat:@"RSCloudModeManager: CloudModeProcessor: Updating status as CLOUDMODEPROCESSING DONE for events (%@)",[RSUtils getCSVStringFromArray:dbMessage.messageIds]]];
[RSMetricsReporter report:SDKMETRICS_CM_ATTEMPT_SUCCESS forMetricType:COUNT withProperties:nil andValue:(float)dbMessage.messages.count];
[strongSelf->dbPersistentManager updateEventsWithIds:dbMessage.messageIds withStatus:CLOUD_MODE_PROCESSING_DONE];
[strongSelf->dbPersistentManager clearProcessedEventsFromDB];
sleepCount = 0;
[self->backOff reset];
}
[strongSelf->lock lock];
RSNetworkResponse* response = nil;
[strongSelf->dbPersistentManager clearOldEventsWithThreshold: strongSelf->config.dbCountThreshold];
[RSLogger logDebug:@"RSCloudModeManager: CloudModeProcessor: Fetching events to flush to server"];
RSDBMessage* dbMessage = [strongSelf->dbPersistentManager fetchEventsFromDB:(strongSelf->config.flushQueueSize) ForMode:CLOUDMODE];
if ((dbMessage.messages.count >= strongSelf->config.flushQueueSize) || (dbMessage.messages.count > 0 && (sleepCount >= strongSelf->config.sleepTimeout))) {
NSString* payload = [RSCloudModeManager getPayloadFromMessages:dbMessage];
[RSLogger logDebug:[[NSString alloc] initWithFormat:@"RSCloudModeManager: CloudModeProcessor: Payload: %@", payload]];
[RSLogger logInfo:[[NSString alloc] initWithFormat:@"RSCloudModeManager: CloudModeProcessor: EventCount: %lu", (unsigned long)dbMessage.messageIds.count]];
[RSMetricsReporter report:SDKMETRICS_CM_EVENT forMetricType:COUNT withProperties:@{SDKMETRICS_TYPE: SDKMETRICS_MESSAGES} andValue:(float)dbMessage.messages.count];
if (payload != nil) {
response = [strongSelf->networkManager sendNetworkRequest:payload toEndpoint:BATCH_ENDPOINT withRequestMethod:POST];
if (response.state == NETWORK_SUCCESS) {
[RSLogger logDebug:[[NSString alloc] initWithFormat:@"RSCloudModeManager: CloudModeProcessor: Updating status as CLOUDMODEPROCESSING DONE for events (%@)",[RSUtils getCSVStringFromArray:dbMessage.messageIds]]];
[RSMetricsReporter report:SDKMETRICS_CM_ATTEMPT_SUCCESS forMetricType:COUNT withProperties:nil andValue:(float)dbMessage.messages.count];
[strongSelf->dbPersistentManager updateEventsWithIds:dbMessage.messageIds withStatus:CLOUD_MODE_PROCESSING_DONE];
[strongSelf->dbPersistentManager clearProcessedEventsFromDB];
sleepCount = 0;
[self->backOff reset];
}
}
[strongSelf->lock unlock];
[RSLogger logDebug:[[NSString alloc] initWithFormat:@"RSCloudModeManager: CloudModeProcessor: cloudModeSleepCount: %d", sleepCount]];
sleepCount += 1;

if(response == nil) {
sleep(1);
} else if (response.state == WRONG_WRITE_KEY) {
[RSLogger logError:@"RSCloudModeManager: CloudModeProcessor: Wrong WriteKey. Aborting the Cloud Mode Processor"];
break;
} else if (response.state == INVALID_URL) {
[RSLogger logError:@"RSCloudModeManager: CloudModeProcessor: Invalid Data Plane URL. Aborting the Cloud Mode Processor"];
[RSMetricsReporter report:SDKMETRICS_CM_ATTEMPT_ABORT forMetricType:COUNT withProperties:@{SDKMETRICS_TYPE: SDKMETRICS_DATA_PLANE_URL_INVALID} andValue:1];
break;
} else if (response.state == NETWORK_ERROR) {
int delay = [self->backOff nextDelay];
[RSLogger logDebug:[[NSString alloc] initWithFormat:@"RSCloudModeManager: CloudModeProcessor: Retrying in: %@", [RSUtils secondsToString:delay]]];
[RSMetricsReporter report:SDKMETRICS_CM_ATTEMPT_RETRY forMetricType:COUNT withProperties:nil andValue:1];
sleep(delay);
} else { // To handle the status code RESOURCE_NOT_FOUND(404) & BAD_REQUEST(400)
[RSLogger logDebug:[[NSString alloc] initWithFormat:@"RSCloudModeManager: CloudModeProcessor: Retrying in: 1s"]];
sleep(1);
}
}
@catch (NSException *exception) {
[strongSelf->lock unlock];
[RSLogger logError:[NSString stringWithFormat:@"RSCloudModeManager: CloudModeProcessor: Failed to flush current batch, reason: %@", exception.reason]];
[strongSelf->lock unlock];
[RSLogger logDebug:[[NSString alloc] initWithFormat:@"RSCloudModeManager: CloudModeProcessor: cloudModeSleepCount: %d", sleepCount]];
sleepCount += 1;

if(response == nil) {
sleep(1);
} else if (response.state == WRONG_WRITE_KEY) {
[RSLogger logError:@"RSCloudModeManager: CloudModeProcessor: Wrong WriteKey. Aborting the Cloud Mode Processor"];
break;
} else if (response.state == INVALID_URL) {
[RSLogger logError:@"RSCloudModeManager: CloudModeProcessor: Invalid Data Plane URL. Aborting the Cloud Mode Processor"];
[RSMetricsReporter report:SDKMETRICS_CM_ATTEMPT_ABORT forMetricType:COUNT withProperties:@{SDKMETRICS_TYPE: SDKMETRICS_DATA_PLANE_URL_INVALID} andValue:1];
break;
} else if (response.state == NETWORK_ERROR) {
int delay = [self->backOff nextDelay];
[RSLogger logDebug:[[NSString alloc] initWithFormat:@"RSCloudModeManager: CloudModeProcessor: Retrying in: %@", [RSUtils secondsToString:delay]]];
[RSMetricsReporter report:SDKMETRICS_CM_ATTEMPT_RETRY forMetricType:COUNT withProperties:nil andValue:1];
sleep(delay);
} else { // To handle the status code RESOURCE_NOT_FOUND(404) & BAD_REQUEST(400)
[RSLogger logDebug:[[NSString alloc] initWithFormat:@"RSCloudModeManager: CloudModeProcessor: Retrying in: 1s"]];
sleep(1);
}
}
Expand Down
80 changes: 43 additions & 37 deletions Sources/Classes/RSDBPersistentManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -490,48 +490,54 @@ -(RSDBMessage*) fetchAllEventsFromDBForMode:(MODES) mode {
}

- (RSDBMessage *) getEventsFromDB :(NSString*) querySQLString {
[RSLogger logDebug:[[NSString alloc] initWithFormat:@"RSDBPersistentManager: getEventsFromDB: fetchEventSql: %@", querySQLString]];

const char* querySQL = [querySQLString UTF8String];
NSMutableArray<NSString *> *messageIds = [NSMutableArray array];
NSMutableArray<NSString *> *messages = [NSMutableArray array];
NSMutableArray<NSNumber *> *statusList = [NSMutableArray array];
NSMutableArray<NSNumber *> *dmProcessedList = [NSMutableArray array];

@synchronized (self) {
sqlite3_stmt *queryStmt = nil;
if ([database prepare_v2:querySQL nBytes:-1 ppStmt:&queryStmt pzTail:NULL] == SQLITE_OK) {
[RSLogger logDebug:@"RSDBPersistentManager: getEventsFromDB: Successfully fetched events from DB"];
while ([database step:queryStmt] == SQLITE_ROW) {
@autoreleasepool {
int messageId = [database column_int:queryStmt i:0];
const unsigned char* queryResultCol1 = [database column_text:queryStmt i:1];
NSString *message = [[NSString alloc] initWithUTF8String:(char *)queryResultCol1];
int status = [database column_int:queryStmt i:3];
int dmProcessed = [database column_int:queryStmt i:4];

[messageIds addObject:[[NSString alloc] initWithFormat:@"%d", messageId]];
[messages addObject:message];
[statusList addObject:[NSNumber numberWithInt:status]];
[dmProcessedList addObject:[NSNumber numberWithInt:dmProcessed]];
@try {
[RSLogger logDebug:[[NSString alloc] initWithFormat:@"RSDBPersistentManager: getEventsFromDB: fetchEventSql: %@", querySQLString]];

const char* querySQL = [querySQLString UTF8String];
NSMutableArray<NSString *> *messageIds = [NSMutableArray array];
NSMutableArray<NSString *> *messages = [NSMutableArray array];
NSMutableArray<NSNumber *> *statusList = [NSMutableArray array];
NSMutableArray<NSNumber *> *dmProcessedList = [NSMutableArray array];

@synchronized (self) {
sqlite3_stmt *queryStmt = nil;
if ([database prepare_v2:querySQL nBytes:-1 ppStmt:&queryStmt pzTail:NULL] == SQLITE_OK) {
[RSLogger logDebug:@"RSDBPersistentManager: getEventsFromDB: Successfully fetched events from DB"];
while ([database step:queryStmt] == SQLITE_ROW) {
@autoreleasepool {
int messageId = [database column_int:queryStmt i:0];
const unsigned char* queryResultCol1 = [database column_text:queryStmt i:1];
NSString *message = [[NSString alloc] initWithUTF8String:(char *)queryResultCol1];
int status = [database column_int:queryStmt i:3];
int dmProcessed = [database column_int:queryStmt i:4];

[messageIds addObject:[[NSString alloc] initWithFormat:@"%d", messageId]];
[messages addObject:message];
[statusList addObject:[NSNumber numberWithInt:status]];
[dmProcessedList addObject:[NSNumber numberWithInt:dmProcessed]];
}
}
} else {
[RSLogger logError:@"RSDBPersistentManager: getEventsFromDB: Failed to fetch events from DB"];
}

// Finalize the SQL statement to free resources
if (queryStmt != nil) {
[database finalize:queryStmt];
}
} else {
[RSLogger logError:@"RSDBPersistentManager: getEventsFromDB: Failed to fetch events from DB"];
}

// Finalize the SQL statement to free resources
if (queryStmt != nil) {
[database finalize:queryStmt];
}
RSDBMessage *dbMessage = [[RSDBMessage alloc] init];
dbMessage.messageIds = messageIds;
dbMessage.messages = messages;
dbMessage.statusList = statusList;
dbMessage.dmProcessed = dmProcessedList;
return dbMessage;

} @catch (NSException *exception) {
[RSLogger logError:[NSString stringWithFormat:@"RSDBPersistentManager: getEventsFromDB: Failed to fetch events from DB, reason: %@", exception.reason]];
return nil;
}

RSDBMessage *dbMessage = [[RSDBMessage alloc] init];
dbMessage.messageIds = messageIds;
dbMessage.messages = messages;
dbMessage.statusList = statusList;
dbMessage.dmProcessed = dmProcessedList;
return dbMessage;
}

// If mode is passed as DEVICEMODE, this function would return the total number of events which were waiting for the Device Mode Processing to be done
Expand Down
2 changes: 1 addition & 1 deletion Sources/Classes/RSUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ +(NSArray*) extractParamFromURL: (NSURL*) deepLinkURL{
}
return queryItems != nil ? queryItems : [NSArray array];
}
unsigned int MAX_EVENT_SIZE = 32 * 1024; // 32 KB
unsigned int MAX_EVENT_SIZE = 64 * 1024; // 64 KB
unsigned int MAX_BATCH_SIZE = 500 * 1024; // 500 KB

+ (NSString *)secondsToString:(int) delay {
Expand Down
7 changes: 4 additions & 3 deletions Tests/ContextTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,13 @@ class ContextTests: XCTestCase {
}

func test_putAdvertisementId() {
context.putAdvertisementId("00000000-0000-0000-0000-000000000000")
XCTAssertEqual(context.device.advertisingId, "");
XCTAssertFalse(context.device.adTrackingEnabled)
context.putAdvertisementId("some-random-uuid");
XCTAssertEqual(context.device.advertisingId, "some-random-uuid");
XCTAssertTrue(context.device.adTrackingEnabled)

context.putAdvertisementId("00000000-0000-0000-0000-000000000000")
XCTAssertEqual(context.device.advertisingId, "some-random-uuid");
XCTAssertTrue(context.device.adTrackingEnabled)
}

func test_updateExternalIds() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.29.1",
"version": "1.30.0",
"description": "Rudder is a platform for collecting, storing and routing customer event data to dozens of tools"
}
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sonar.qualitygate.wait=false
sonar.projectKey=rudderlabs_rudder-sdk-ios
sonar.organization=rudderlabs
sonar.projectName=RudderStack iOS SDK
sonar.projectVersion=1.29.1
sonar.projectVersion=1.30.0

# C/C++/Objective-C related details
# sonar.cfamily.compile-commands=compile_commands.json
Expand Down

0 comments on commit d227731

Please sign in to comment.