Skip to content

Commit

Permalink
[Improvement] Changed data type of session timeout from int to long
Browse files Browse the repository at this point in the history
  • Loading branch information
1abhishekpandey committed Sep 21, 2022
1 parent b3fe089 commit dbbdda4
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
IDEWorkspaceChecks.plist
IDEWorkspaceChecks.plist
*.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
.withTrackLifecycleEvens(false)
.withRecordScreenViews(false)
.withSleepTimeOut(4)
.withSessionDuration(10)
.withSessionTimeoutMillis(30000)
RSClient.getInstance("1wvsoF3Kx2SczQNlx1dvcqW9ODW", config: builder.build())


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extension SessionViewController: UITableViewDataSource, UITableViewDelegate {
case 1:
RSClient.sharedInstance()?.endSession()
case 2:
RSClient.sharedInstance()?.startSession(UUID().uuidString.lowercased())
RSClient.sharedInstance()?.startSession(1234567890)
case 3:
RSClient.sharedInstance()?.reset()
case 4:
Expand Down Expand Up @@ -128,7 +128,7 @@ extension SessionViewController: UITableViewDataSource, UITableViewDelegate {
} else if index % 9 == 5 {
RSClient.sharedInstance()?.startSession()
} else if index % 9 == 6 {
RSClient.sharedInstance()?.startSession("session_id_\(index)")
RSClient.sharedInstance()?.startSession(Int(Date().timeIntervalSince1970))
} else if index % 9 == 7 {
RSClient.sharedInstance()?.endSession()
} else if index % 9 == 8 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Classes/Public/RSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) int sleepTimeout;
@property (nonatomic) int logLevel;
@property (nonatomic) int configRefreshInterval;
@property (nonatomic) int sessionInActivityTimeOut;
@property (nonatomic) long sessionInActivityTimeOut;
@property (nonatomic) bool trackLifecycleEvents;
@property (nonatomic) bool recordScreenViews;
@property (nonatomic) bool enableBackgroundMode;
Expand Down
2 changes: 1 addition & 1 deletion Sources/Classes/Public/RSConfigBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)withLoglevel:(int)logLevel;
- (instancetype)withDBCountThreshold:(int)dbCountThreshold;
- (instancetype)withSleepTimeOut:(int)sleepTimeOut;
- (instancetype)withSessionTimeoutMillis:(int)sessionTimeout;
- (instancetype)withSessionTimeoutMillis:(long)sessionTimeout;
- (instancetype)withConfigRefreshInteval:(int)configRefreshInterval;
- (instancetype)withTrackLifecycleEvens:(BOOL)trackLifecycleEvents;
- (instancetype)withRecordScreenViews:(BOOL)recordScreenViews;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Classes/Public/RSConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ extern int const RSDBCountThreshold;
// events will be flushed to server after sleepTimeOut seconds
extern int const RSSleepTimeout;
// Minimum value for the In Activity timeout after which the current session expires.
extern int const RSSessionInActivityMinTimeOut;
extern long const RSSessionInActivityMinTimeOut;
// Default value for the In Activity timeout after which the current session expires.
extern int const RSSessionInActivityDefaultTimeOut;
extern long const RSSessionInActivityDefaultTimeOut;
// config-plane url to get the config for the writeKey
extern NSString *const RSControlPlaneUrl;
// whether we should trackLifecycle events
Expand Down
4 changes: 2 additions & 2 deletions Sources/Classes/Public/RSUserSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
NS_ASSUME_NONNULL_BEGIN

@interface RSUserSession : NSObject {
int sessionInActivityTimeOut;
long sessionInActivityTimeOut;
long sessionId;
BOOL sessionStart;
long lastEventTimeStamp;
RSPreferenceManager* preferenceManager;
}

+ (instancetype) initiate:(int)sessionInActivityTimeOut with:(RSPreferenceManager *) preferenceManager;
+ (instancetype) initiate:(long)sessionInActivityTimeOut with:(RSPreferenceManager *) preferenceManager;

- (void) startSession;
- (void)startSession:(long)sessionId;
Expand Down
2 changes: 1 addition & 1 deletion Sources/Classes/RSConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ - (instancetype)init:(NSString *) dataPlaneUrl
dbCountThreshold: (int) dbCountThreshold
sleepTimeOut: (int) sleepTimeout
logLevel: (int) logLevel
sessionInActivityTimeOut: (int) sessionInActivityTimeOut
sessionInActivityTimeOut: (long) sessionInActivityTimeOut
configRefreshInterval: (int) configRefreshInteval
trackLifecycleEvents: (BOOL) trackLifecycleEvents
enableBackgroundMode: (BOOL) enableBackgroundMode
Expand Down
2 changes: 1 addition & 1 deletion Sources/Classes/RSConfigBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ - (instancetype)withAutoSessionTracking:(BOOL)autoSessionTracking {
return self;
}

- (instancetype)withSessionTimeoutMillis:(int)sessionTimeout {
- (instancetype)withSessionTimeoutMillis:(long)sessionTimeout {
if (config == nil) {
config = [[RSConfig alloc] init];
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Classes/RSConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ @implementation RSConstants
int const RSFlushQueueSize = 30;
int const RSDBCountThreshold = 10000;
int const RSSleepTimeout = 10;
int const RSSessionInActivityMinTimeOut = 0;
int const RSSessionInActivityDefaultTimeOut = 300000;
long const RSSessionInActivityMinTimeOut = 0;
long const RSSessionInActivityDefaultTimeOut = 300000;
NSString *const RSControlPlaneUrl = @"https://api.rudderlabs.com/";
bool const RSTrackLifeCycleEvents = YES;
bool const RSRecordScreenViews = NO;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Classes/RSUserSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ @implementation RSUserSession
static RSUserSession* _instance;
static dispatch_queue_t queue;

+ (instancetype) initiate:(int)sessionInActivityTimeOut with:(RSPreferenceManager *) preferenceManager {
+ (instancetype) initiate:(long)sessionInActivityTimeOut with:(RSPreferenceManager *) preferenceManager {
if (_instance == nil) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Expand All @@ -24,7 +24,7 @@ + (instancetype) initiate:(int)sessionInActivityTimeOut with:(RSPreferenceManage
return _instance;
}

- (instancetype) init:(int)sessionInActivityTimeOut with:(RSPreferenceManager *) preferenceManager {
- (instancetype) init:(long)sessionInActivityTimeOut with:(RSPreferenceManager *) preferenceManager {
self = [super init];
if (self) {
if (queue == nil) {
Expand Down

0 comments on commit dbbdda4

Please sign in to comment.