Skip to content

Commit

Permalink
Fix crash when enabling auto session capture, remove encapsulation br…
Browse files Browse the repository at this point in the history
…eaking from Configuration
  • Loading branch information
loopj authored and kattrali committed Jan 10, 2018
1 parent e2da1b9 commit 555deb7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
12 changes: 12 additions & 0 deletions sdk/src/main/java/com/bugsnag/android/Bugsnag.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,18 @@ public static void setSendThreads(final boolean sendThreads) {
getClient().setSendThreads(sendThreads);
}

/**
* Sets whether or not Bugsnag should automatically capture and report User sessions whenever
* the app enters the foreground.
* <p>
* By default this behavior is disabled.
*
* @param autoCapture whether sessions should be captured automatically
*/
public static void setAutoCaptureSessions(boolean autoCapture) {
getClient().setAutoCaptureSessions(autoCapture);
}

/**
* Set details of the user currently using your application.
* You can search for this information in your Bugsnag dashboard.
Expand Down
20 changes: 20 additions & 0 deletions sdk/src/main/java/com/bugsnag/android/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,26 @@ public void setSendThreads(boolean sendThreads) {
config.setSendThreads(sendThreads);
}


/**
* Sets whether or not Bugsnag should automatically capture and report User sessions whenever
* the app enters the foreground.
* <p>
* By default this behavior is disabled.
*
* @param autoCapture whether sessions should be captured automatically
*/
public void setAutoCaptureSessions(boolean autoCapture) {
config.setAutoCaptureSessions(autoCapture);

if (autoCapture) { // track any existing sessions
//noinspection ConstantConditions
if (sessionTracker != null) {
sessionTracker.onAutoCaptureEnabled();
}
}
}

/**
* Set details of the user currently using your application.
* You can search for this information in your Bugsnag dashboard.
Expand Down
9 changes: 0 additions & 9 deletions sdk/src/main/java/com/bugsnag/android/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,6 @@ public boolean shouldAutoCaptureSessions() {
*/
public void setAutoCaptureSessions(boolean autoCapture) {
this.autoCaptureSessions = autoCapture;

if (autoCapture) { // track any existing sessions
Client client = Bugsnag.getClient();

//noinspection ConstantConditions
if (client != null && client.sessionTracker != null) {
client.sessionTracker.onAutoCaptureEnabled();
}
}
}

/**
Expand Down

0 comments on commit 555deb7

Please sign in to comment.