From d02ad1a2921e46afa06f671be367e0b1d6cc1a61 Mon Sep 17 00:00:00 2001
From: Abhishek Pandey <64667840+1abhishekpandey@users.noreply.github.com>
Date: Tue, 7 Nov 2023 16:44:09 +0530
Subject: [PATCH 1/6] refactor: change LastEventTimeStamp to
LastActiveTimestamp
---
.../RudderConfig/SampleRudderConfig.plist | 24 -------------------
.../Headers/Public/RSPreferenceManager.h | 8 +++----
.../Classes/Headers/Public/RSUserSession.h | 4 ++--
Sources/Classes/RSEventRepository.m | 2 +-
Sources/Classes/RSPreferenceManager.m | 18 +++++++-------
Sources/Classes/RSUserSession.m | 16 ++++++-------
Tests/ContextTests.swift | 2 +-
7 files changed, 25 insertions(+), 49 deletions(-)
delete mode 100644 Examples/RudderConfig/SampleRudderConfig.plist
diff --git a/Examples/RudderConfig/SampleRudderConfig.plist b/Examples/RudderConfig/SampleRudderConfig.plist
deleted file mode 100644
index 4e130dde..00000000
--- a/Examples/RudderConfig/SampleRudderConfig.plist
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
- WRITE_KEY
-
- PROD_DATA_PLANE_URL
-
- PROD_CONTROL_PLANE_URL
-
- LOCAL_DATA_PLANE_URL
-
- LOCAL_CONTROL_PLANE_URL
-
- DEV_DATA_PLANE_URL
-
- DEV_CONTROL_PLANE_URL
-
- STORAGE_LOCATION
-
- DOMAIN_IDENTIFIER
-
-
-
diff --git a/Sources/Classes/Headers/Public/RSPreferenceManager.h b/Sources/Classes/Headers/Public/RSPreferenceManager.h
index 78d83372..0c5d5312 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 *) lastEventTimeStamp;
+- (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..0f8fcce6 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];
}
}
diff --git a/Sources/Classes/RSPreferenceManager.m b/Sources/Classes/RSPreferenceManager.m
index e38455ae..ef2b76d0 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 *) lastEventTimeStamp {
+ [[NSUserDefaults standardUserDefaults] setValue:lastEventTimeStamp 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 00059322b2fb492d8e0a18ea0add98eb65b7e68d Mon Sep 17 00:00:00 2001
From: Abhishek Pandey <64667840+1abhishekpandey@users.noreply.github.com>
Date: Tue, 7 Nov 2023 16:49:09 +0530
Subject: [PATCH 2/6] chore: undo the deleted SampleRudderConfig.plist file
---
.../RudderConfig/SampleRudderConfig.plist | 24 +++++++++++++++++++
1 file changed, 24 insertions(+)
create mode 100644 Examples/RudderConfig/SampleRudderConfig.plist
diff --git a/Examples/RudderConfig/SampleRudderConfig.plist b/Examples/RudderConfig/SampleRudderConfig.plist
new file mode 100644
index 00000000..4e130dde
--- /dev/null
+++ b/Examples/RudderConfig/SampleRudderConfig.plist
@@ -0,0 +1,24 @@
+
+
+
+
+ WRITE_KEY
+
+ PROD_DATA_PLANE_URL
+
+ PROD_CONTROL_PLANE_URL
+
+ LOCAL_DATA_PLANE_URL
+
+ LOCAL_CONTROL_PLANE_URL
+
+ DEV_DATA_PLANE_URL
+
+ DEV_CONTROL_PLANE_URL
+
+ STORAGE_LOCATION
+
+ DOMAIN_IDENTIFIER
+
+
+
From 32d2f24ccb7265e41db21446b095fadbe161dc0d Mon Sep 17 00:00:00 2001
From: Abhishek Pandey <64667840+1abhishekpandey@users.noreply.github.com>
Date: Tue, 7 Nov 2023 16:59:08 +0530
Subject: [PATCH 3/6] refactor: change LastEventTimeStamp to
LastActiveTimestamp
---
Sources/Classes/Headers/Public/RSPreferenceManager.h | 2 +-
Sources/Classes/RSPreferenceManager.m | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Sources/Classes/Headers/Public/RSPreferenceManager.h b/Sources/Classes/Headers/Public/RSPreferenceManager.h
index 0c5d5312..24e9e596 100644
--- a/Sources/Classes/Headers/Public/RSPreferenceManager.h
+++ b/Sources/Classes/Headers/Public/RSPreferenceManager.h
@@ -73,7 +73,7 @@ extern NSString *const RSSessionAutoTrackStatus;
- (NSNumber * __nullable) getSessionId;
- (void) clearSessionId;
-- (void) saveLastActiveTimestamp: (NSNumber *) lastEventTimeStamp;
+- (void) saveLastActiveTimestamp: (NSNumber *) lastActiveTimestamp;
- (NSNumber * __nullable) getLastActiveTimestamp;
- (void) clearLastActiveTimestamp;
diff --git a/Sources/Classes/RSPreferenceManager.m b/Sources/Classes/RSPreferenceManager.m
index ef2b76d0..aa448d91 100644
--- a/Sources/Classes/RSPreferenceManager.m
+++ b/Sources/Classes/RSPreferenceManager.m
@@ -238,8 +238,8 @@ - (void) clearSessionId {
[[NSUserDefaults standardUserDefaults] synchronize];
}
-- (void) saveLastActiveTimestamp:(NSNumber *) lastEventTimeStamp {
- [[NSUserDefaults standardUserDefaults] setValue:lastEventTimeStamp forKey:RSLastActiveTimestamp];
+- (void) saveLastActiveTimestamp:(NSNumber *) lastActiveTimestamp {
+ [[NSUserDefaults standardUserDefaults] setValue:lastActiveTimestamp forKey:RSLastActiveTimestamp];
[[NSUserDefaults standardUserDefaults] synchronize];
}
From b86e086099b327ba54fc6e53fcefbe0a3b1a79d1 Mon Sep 17 00:00:00 2001
From: Abhishek Pandey <64667840+1abhishekpandey@users.noreply.github.com>
Date: Tue, 7 Nov 2023 17:02:59 +0530
Subject: [PATCH 4/6] fix: update last active timestamp when reset is made
This fix might change in future based on the discussion
---
Sources/Classes/RSEventRepository.m | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Sources/Classes/RSEventRepository.m b/Sources/Classes/RSEventRepository.m
index 0f8fcce6..d6f1b074 100644
--- a/Sources/Classes/RSEventRepository.m
+++ b/Sources/Classes/RSEventRepository.m
@@ -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"];
From 5f2eb76896ccfe2d3c5dd353beff182f31b94246 Mon Sep 17 00:00:00 2001
From: Abhishek Pandey <64667840+1abhishekpandey@users.noreply.github.com>
Date: Tue, 7 Nov 2023 17:04:04 +0530
Subject: [PATCH 5/6] chore: update podfile.lock
---
Podfile.lock | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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
From 3b5ee412e232dd37f46b9b2b69cdc8c466bcd0ac Mon Sep 17 00:00:00 2001
From: Abhishek Pandey <64667840+1abhishekpandey@users.noreply.github.com>
Date: Tue, 7 Nov 2023 17:05:24 +0530
Subject: [PATCH 6/6] chore: update the SDK init snippet in objc sample app
---
Examples/RudderSampleAppObjC/RudderSampleAppObjC/_AppDelegate.m | 1 -
1 file changed, 1 deletion(-)
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]];
}