From 6f229adb89c9a2f347c99cbc99324f07d241d2ae Mon Sep 17 00:00:00 2001 From: Abhishek Pandey <64667840+1abhishekpandey@users.noreply.github.com> Date: Thu, 9 Nov 2023 12:52:06 +0530 Subject: [PATCH 1/2] fix: update lastActiveTimestamp value when reset call is made (#412) * refactor: change LastEventTimeStamp to LastActiveTimestamp * chore: undo the deleted SampleRudderConfig.plist file * refactor: change LastEventTimeStamp to LastActiveTimestamp * fix: update last active timestamp when reset is made This fix might change in future based on the discussion * chore: update podfile.lock * chore: update the SDK init snippet in objc sample app --- .../RudderSampleAppObjC/_AppDelegate.m | 1 - Podfile.lock | 6 +++--- .../Headers/Public/RSPreferenceManager.h | 8 ++++---- Sources/Classes/Headers/Public/RSUserSession.h | 4 ++-- Sources/Classes/RSEventRepository.m | 5 ++++- Sources/Classes/RSPreferenceManager.m | 18 +++++++++--------- Sources/Classes/RSUserSession.m | 16 ++++++++-------- Tests/ContextTests.swift | 2 +- 8 files changed, 31 insertions(+), 29 deletions(-) diff --git a/Examples/RudderSampleAppObjC/RudderSampleAppObjC/_AppDelegate.m b/Examples/RudderSampleAppObjC/RudderSampleAppObjC/_AppDelegate.m index 6310f7f0..a5459a3e 100644 --- a/Examples/RudderSampleAppObjC/RudderSampleAppObjC/_AppDelegate.m +++ b/Examples/RudderSampleAppObjC/RudderSampleAppObjC/_AppDelegate.m @@ -36,7 +36,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( [builder withRecordScreenViews:YES]; [builder withDataPlaneUrl:rudderConfig.DEV_DATA_PLANE_URL]; [builder withControlPlaneUrl:rudderConfig.DEV_CONTROL_PLANE_URL]; - [builder withSleepTimeOut:3000]; [builder withDBEncryption:[[RSDBEncryption alloc] initWithKey:@"test1234" enable:NO databaseProvider:[EncryptedDatabaseProvider new]]]; [RSClient getInstance:rudderConfig.WRITE_KEY config:[builder build]]; } diff --git a/Podfile.lock b/Podfile.lock index c788d8e4..81b35311 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -3,7 +3,7 @@ PODS: - RSCrashReporter (= 1.0.0) - RudderKit (= 1.4.0) - RSCrashReporter (1.0.0) - - Rudder (1.20.0): + - Rudder (1.23.0): - MetricsReporter (= 1.1.1) - RudderKit (1.4.0) - SQLCipher (4.5.4): @@ -33,10 +33,10 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: MetricsReporter: d4265e0ac833e2c0078bbe044b3f9dbe29f53a48 RSCrashReporter: 7e26b51ac816e967acb58fa458040946a93a9e65 - Rudder: d9e8730c891325da05ac4c454db09bc449d3b9ff + Rudder: 125d9dc03e178b35b0f74487aa694afe1a8e6f4f RudderKit: d9d6997696e1642b753d8bdf94e57af643a68f03 SQLCipher: 905b145f65f349f26da9e60a19901ad24adcd381 PODFILE CHECKSUM: b6937cee06e0633464427ff0d975d40e17419e9f -COCOAPODS: 1.13.0 +COCOAPODS: 1.11.3 diff --git a/Sources/Classes/Headers/Public/RSPreferenceManager.h b/Sources/Classes/Headers/Public/RSPreferenceManager.h index 78d83372..24e9e596 100644 --- a/Sources/Classes/Headers/Public/RSPreferenceManager.h +++ b/Sources/Classes/Headers/Public/RSPreferenceManager.h @@ -21,7 +21,7 @@ extern NSString *const RSOptStatus; extern NSString *const RSOptInTimeKey; extern NSString *const RSOptOutTimeKey; extern NSString *const RSSessionIdKey; -extern NSString *const RSLastEventTimeStamp; +extern NSString *const RSLastActiveTimestamp; extern NSString *const RSSessionAutoTrackStatus; + (instancetype) getInstance; @@ -73,9 +73,9 @@ extern NSString *const RSSessionAutoTrackStatus; - (NSNumber * __nullable) getSessionId; - (void) clearSessionId; -- (void) saveLastEventTimeStamp: (NSNumber *) lastEventTimeStamp; -- (NSNumber * __nullable) getLastEventTimeStamp; -- (void) clearLastEventTimeStamp; +- (void) saveLastActiveTimestamp: (NSNumber *) lastActiveTimestamp; +- (NSNumber * __nullable) getLastActiveTimestamp; +- (void) clearLastActiveTimestamp; - (void) saveAutoTrackingStatus: (BOOL) autoTrackingStatus; - (BOOL) getAutoTrackingStatus; diff --git a/Sources/Classes/Headers/Public/RSUserSession.h b/Sources/Classes/Headers/Public/RSUserSession.h index c71636f4..e573fd4d 100644 --- a/Sources/Classes/Headers/Public/RSUserSession.h +++ b/Sources/Classes/Headers/Public/RSUserSession.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN long sessionInActivityTimeOut; NSNumber *sessionId; BOOL sessionStart; - NSNumber *lastEventTimeStamp; + NSNumber *lastActiveTimestamp; RSPreferenceManager* preferenceManager; } @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)startSessionIfExpired; - (void)refreshSession; - (void)clearSession; -- (void)updateLastEventTimeStamp; +- (void)updateLastActiveTimestamp; - (NSNumber * __nullable)getSessionId; - (BOOL)getSessionStart; diff --git a/Sources/Classes/RSEventRepository.m b/Sources/Classes/RSEventRepository.m index 6c551354..d6f1b074 100644 --- a/Sources/Classes/RSEventRepository.m +++ b/Sources/Classes/RSEventRepository.m @@ -273,7 +273,7 @@ - (void)applySession:(RSMessage *)message withUserSession:(RSUserSession *)_user [message setSessionData: _userSession]; } if(rudderConfig.trackLifecycleEvents && rudderConfig.automaticSessionTracking) { - [_userSession updateLastEventTimeStamp]; + [_userSession updateLastActiveTimestamp]; } } @@ -281,6 +281,9 @@ -(void) reset { if([self->userSession getSessionId] != nil) { [RSLogger logDebug: @"EventRepository: reset: Refreshing the session as the reset is triggered"]; [self->userSession refreshSession]; + if(self->config.trackLifecycleEvents && self->config.automaticSessionTracking) { + [self->userSession updateLastActiveTimestamp]; + } } [RSLogger logDebug: @"EventRepository: reset: clearing the CTS Auth token as the reset is triggered"]; diff --git a/Sources/Classes/RSPreferenceManager.m b/Sources/Classes/RSPreferenceManager.m index e38455ae..aa448d91 100644 --- a/Sources/Classes/RSPreferenceManager.m +++ b/Sources/Classes/RSPreferenceManager.m @@ -28,7 +28,7 @@ @implementation RSPreferenceManager NSString *const RSOptInTimeKey = @"rl_opt_in_time"; NSString *const RSOptOutTimeKey = @"rl_opt_out_time"; NSString *const RSSessionIdKey = @"rl_session_id"; -NSString *const RSLastEventTimeStamp = @"rl_last_event_time_stamp"; +NSString *const RSLastActiveTimestamp = @"rl_last_event_time_stamp"; NSString *const RSSessionAutoTrackStatus = @"rl_session_auto_track_status"; NSString *const RSEventDeletionStatus = @"rl_event_deletion_status"; @@ -238,21 +238,21 @@ - (void) clearSessionId { [[NSUserDefaults standardUserDefaults] synchronize]; } -- (void) saveLastEventTimeStamp:(NSNumber *) lastEventTimeStamp { - [[NSUserDefaults standardUserDefaults] setValue:lastEventTimeStamp forKey:RSLastEventTimeStamp]; +- (void) saveLastActiveTimestamp:(NSNumber *) lastActiveTimestamp { + [[NSUserDefaults standardUserDefaults] setValue:lastActiveTimestamp forKey:RSLastActiveTimestamp]; [[NSUserDefaults standardUserDefaults] synchronize]; } -- (NSNumber * __nullable) getLastEventTimeStamp { - NSNumber *lastEventTimeStamp = [[NSUserDefaults standardUserDefaults] valueForKey:RSLastEventTimeStamp]; - if(lastEventTimeStamp == nil) { +- (NSNumber * __nullable) getLastActiveTimestamp { + NSNumber *lastActiveTimestamp = [[NSUserDefaults standardUserDefaults] valueForKey:RSLastActiveTimestamp]; + if(lastActiveTimestamp == nil) { return nil; } - return lastEventTimeStamp; + return lastActiveTimestamp; } -- (void) clearLastEventTimeStamp { - [[NSUserDefaults standardUserDefaults] setValue:nil forKey:RSLastEventTimeStamp]; +- (void) clearLastActiveTimestamp { + [[NSUserDefaults standardUserDefaults] setValue:nil forKey:RSLastActiveTimestamp]; [[NSUserDefaults standardUserDefaults] synchronize]; } diff --git a/Sources/Classes/RSUserSession.m b/Sources/Classes/RSUserSession.m index 0c73a53c..f0b1730b 100644 --- a/Sources/Classes/RSUserSession.m +++ b/Sources/Classes/RSUserSession.m @@ -33,7 +33,7 @@ - (instancetype) init:(long)sessionInActivityTimeOut with:(RSPreferenceManager * self->sessionInActivityTimeOut = sessionInActivityTimeOut; self->preferenceManager = preferenceManager; self->sessionId = [self->preferenceManager getSessionId]; - self->lastEventTimeStamp = [self->preferenceManager getLastEventTimeStamp]; + self->lastActiveTimestamp = [self->preferenceManager getLastActiveTimestamp]; } return self; } @@ -61,11 +61,11 @@ - (void) startSessionIfExpired { } - (BOOL) isSessionExpired { - if(self->lastEventTimeStamp == nil) + if(self->lastActiveTimestamp == nil) return YES; __block NSTimeInterval timeDifference; dispatch_sync(queue, ^{ - timeDifference = labs([RSUtils getTimeStampLong] - [self->lastEventTimeStamp longValue]); + timeDifference = labs([RSUtils getTimeStampLong] - [self->lastActiveTimestamp longValue]); }); if (timeDifference > (self->sessionInActivityTimeOut / 1000)) { return YES; @@ -83,9 +83,9 @@ - (void) clearSession { dispatch_sync(queue, ^{ self->sessionId = nil; self->sessionStart = NO; - self->lastEventTimeStamp = nil; + self->lastActiveTimestamp = nil; [self->preferenceManager clearSessionId]; - [self->preferenceManager clearLastEventTimeStamp]; + [self->preferenceManager clearLastActiveTimestamp]; }); } @@ -113,10 +113,10 @@ - (void) setSessionStart:(BOOL)sessionStart { }); } -- (void) updateLastEventTimeStamp { +- (void) updateLastActiveTimestamp { dispatch_sync(queue, ^{ - self->lastEventTimeStamp = [[NSNumber alloc] initWithLong:[RSUtils getTimeStampLong]]; - [self->preferenceManager saveLastEventTimeStamp:lastEventTimeStamp]; + self->lastActiveTimestamp = [[NSNumber alloc] initWithLong:[RSUtils getTimeStampLong]]; + [self->preferenceManager saveLastActiveTimestamp:lastActiveTimestamp]; }); } @end diff --git a/Tests/ContextTests.swift b/Tests/ContextTests.swift index 0ec3b5f7..90f5b631 100644 --- a/Tests/ContextTests.swift +++ b/Tests/ContextTests.swift @@ -59,7 +59,7 @@ class ContextTests: XCTestCase { preferenceManager.clearTraits() preferenceManager.clearExternalIds() preferenceManager.clearSessionId() - preferenceManager.clearLastEventTimeStamp() + preferenceManager.clearLastActiveTimestamp() preferenceManager.saveAnonymousId("testAnonymousId") context = RSContext(config: RSConfig()) testUtils = TestUtils() From 383a515d144c36a5e173147b26be721a5c9d39f3 Mon Sep 17 00:00:00 2001 From: GitHub actions Date: Tue, 14 Nov 2023 05:59:02 +0000 Subject: [PATCH 2/2] chore(release): 1.23.1 --- CHANGELOG.md | 7 +++++++ README.md | 10 +++++----- Sources/Classes/Headers/RSVersion.h | 2 +- package.json | 2 +- sonar-project.properties | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c42e29..f3d616e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ 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.23.1](https://github.com/rudderlabs/rudder-sdk-ios/compare/v1.23.0...v1.23.1) (2023-11-14) + + +### Bug Fixes + +* update lastActiveTimestamp value when reset call is made ([#412](https://github.com/rudderlabs/rudder-sdk-ios/issues/412)) ([6f229ad](https://github.com/rudderlabs/rudder-sdk-ios/commit/6f229adb89c9a2f347c99cbc99324f07d241d2ae)) + ## [1.23.0](https://github.com/rudderlabs/rudder-sdk-ios/compare/v1.22.0...v1.23.0) (2023-10-09) diff --git a/README.md b/README.md index ba95f421..17de6eba 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@

- +

@@ -39,7 +39,7 @@ 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.23.0' +pod 'Rudder', '1.23.1' ``` ### Carthage @@ -47,7 +47,7 @@ pod 'Rudder', '1.23.0' For Carthage support, add the following line to your `Cartfile`: ```xcode -github "rudderlabs/rudder-sdk-ios" "v1.23.0" +github "rudderlabs/rudder-sdk-ios" "v1.23.1" ``` > 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: @@ -71,7 +71,7 @@ You can also add the RudderStack iOS SDK via Swift Package Mangaer, via one of t * Enter the package repository (`git@github.com:rudderlabs/rudder-sdk-ios.git`) in the search bar. -* In **Dependency Rule**, select **Up to Next Major Version** and enter `1.23.0` as the value, as shown: +* In **Dependency Rule**, select **Up to Next Major Version** and enter `1.23.1` as the value, as shown: ![Setting dependency](https://user-images.githubusercontent.com/59817155/145574696-8c849749-13e0-40d5-aacb-3fccb5c8e67d.png) @@ -99,7 +99,7 @@ let package = Package( ], dependencies: [ // Dependencies declare other packages that this package depends on. - .package(url: "git@github.com:rudderlabs/rudder-sdk-ios.git", from: "1.23.0") + .package(url: "git@github.com:rudderlabs/rudder-sdk-ios.git", from: "1.23.1") ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/Sources/Classes/Headers/RSVersion.h b/Sources/Classes/Headers/RSVersion.h index 0bbd1018..c322082a 100644 --- a/Sources/Classes/Headers/RSVersion.h +++ b/Sources/Classes/Headers/RSVersion.h @@ -8,6 +8,6 @@ #ifndef RSVersion_h #define RSVersion_h -NSString *const SDK_VERSION = @"1.23.0"; +NSString *const SDK_VERSION = @"1.23.1"; #endif /* RSVersion_h */ diff --git a/package.json b/package.json index 5ff9be3a..41d55a8d 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,4 @@ { - "version": "1.23.0", + "version": "1.23.1", "description": "Rudder is a platform for collecting, storing and routing customer event data to dozens of tools" } diff --git a/sonar-project.properties b/sonar-project.properties index 1c880d96..0803937a 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -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.23.0 +sonar.projectVersion=1.23.1 # C/C++/Objective-C related details # sonar.cfamily.compile-commands=compile_commands.json