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

feat: add getSessionId #220

Closed
wants to merge 1 commit into from
Closed
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 @@ -31,6 +31,7 @@ public class RudderClient {
private static RudderOption defaultOptions;
private static String deviceToken;
private static String authToken;
private static Long currentSessionId= Long.valueOf(-1);

private static final int NUMBER_OF_FLUSH_CALLS_IN_QUEUE = 1;

Expand Down Expand Up @@ -866,6 +867,7 @@ public void startSession(@NonNull Long sessionId) {
RudderLogger.logError("RudderClient: startSession: Length of the session Id supplied should be atleast 10, hence ignoring it");
return;
}
currentSessionId=sessionId;
repository.startSession(sessionId);
}

Expand All @@ -876,8 +878,19 @@ public void endSession() {
if (repository == null) {
return;
}
currentSessionId= Long.valueOf(-1);
repository.endSession();
}

/**
* Public method for getting an active session id.
*/
public String getSessionId() {
if (currentSessionId == -1) {
return "";
}
return String.valueOf(currentSessionId);
}

/*
* RudderClient.Builder for building RudderClient with context, writeKey, endPointUrl
Expand Down