Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sessionId not getting cleared issue #300

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,31 @@ public void startSessionTracking() {
// 8. clear session if automatic session tracking was enabled previously
// but disabled presently or vice versa.
boolean previousAutoSessionTrackingStatus = preferenceManager.getAutoSessionTrackingStatus();
if (previousAutoSessionTrackingStatus != config.isTrackAutoSession()) {
boolean currentAutomaticSessionTrackingStatus = isAutomaticSessionTrackingEnabled();
if (previousAutoSessionTrackingStatus != currentAutomaticSessionTrackingStatus) {
userSession.clearSession();
}
preferenceManager.saveAutoSessionTrackingStatus(config.isTrackAutoSession());
preferenceManager.saveAutoSessionTrackingStatus(currentAutomaticSessionTrackingStatus);
// starting automatic session tracking if enabled.
if (config.isTrackLifecycleEvents() && config.isTrackAutoSession()) {
if (currentAutomaticSessionTrackingStatus) {
userSession.startSessionIfNeeded();
}
}

private boolean isAutomaticSessionTrackingEnabled() {
return config.isTrackAutoSession() && isAutomaticLifeCycleEnabled();
}

private boolean isAutomaticLifeCycleEnabled() {
return config.isTrackLifecycleEvents() || config.isNewLifeCycleEvents();
}

void applySessionTracking(RudderMessage message) {
// Session Tracking
if (userSession.getSessionId() != null) {
message.setSession(userSession);
}
if (config.isTrackLifecycleEvents() && config.isTrackAutoSession()) {
if (isAutomaticSessionTrackingEnabled()) {
userSession.updateLastEventTimeStamp();
}
}
Expand Down