Skip to content

Commit

Permalink
fix: Support stopping/resuming sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
kattrali committed Mar 13, 2019
1 parent 61cbd7e commit 142354d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions sdk/src/main/java/com/bugsnag/android/NativeInterface.java
Expand Up @@ -399,11 +399,12 @@ public static void setNotifyReleaseStages(@Nullable String[] notifyReleaseStages
/**
* Update the current session with a given start time, ID, and event counts
*/
public static void registerSession(long startedAt, @NonNull String sessionId,
public static void registerSession(long startedAt, @Nullable String sessionId,
int unhandledCount, int handledCount) {
Client client = getClient();
User user = client.getUser();
client.getSessionTracker().registerExistingSession(new Date(startedAt), sessionId, user,
Date startDate = startedAt > 0 ? new Date(startedAt) : null;
client.getSessionTracker().registerExistingSession(startDate, sessionId, user,
unhandledCount, handledCount);
}

Expand Down
7 changes: 5 additions & 2 deletions sdk/src/main/java/com/bugsnag/android/SessionTracker.java
Expand Up @@ -89,10 +89,13 @@ class SessionTracker extends Observable implements Application.ActivityLifecycle
* @param handledCount the number of handled events which have occurred during the session
* @return the session
*/
@Nullable Session registerExistingSession(@NonNull Date date, @NonNull String sessionId,
@Nullable Session registerExistingSession(@Nullable Date date, @Nullable String sessionId,
@Nullable User user, int unhandledCount,
int handledCount) {
Session session = new Session(sessionId, date, user, unhandledCount, handledCount);
Session session = null;
if (date != null && sessionId != null) {
session = new Session(sessionId, date, user, unhandledCount, handledCount);
}
currentSession.set(session);
return session;
}
Expand Down

0 comments on commit 142354d

Please sign in to comment.