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 crash when enabling auto session capture #220

Merged
merged 1 commit into from
Jan 10, 2018
Merged
Show file tree
Hide file tree
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
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