diff --git a/core/src/main/java/com/rudderstack/android/sdk/core/RudderClient.java b/core/src/main/java/com/rudderstack/android/sdk/core/RudderClient.java index a7a7ab4d1..f44d0622e 100644 --- a/core/src/main/java/com/rudderstack/android/sdk/core/RudderClient.java +++ b/core/src/main/java/com/rudderstack/android/sdk/core/RudderClient.java @@ -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; @@ -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); } @@ -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