-
Notifications
You must be signed in to change notification settings - Fork 205
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
Enable automatic session tracking by default #314
Changes from 16 commits
461eebb
307270c
59a8164
1b14ae9
711ab74
6886111
84efa1e
e276037
8e38483
f89c322
145c45a
4dcf7ad
3334063
66ce062
397ac7f
b03b1d6
ceb8cfe
abbcc28
58baad8
6432b4c
0706d25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -312,21 +312,21 @@ static Configuration populateConfigFromManifest(@NonNull Configuration config, | |
config.setAppVersion(data.getString(MF_APP_VERSION)); | ||
config.setReleaseStage(data.getString(MF_RELEASE_STAGE)); | ||
|
||
String endpoint = data.getString(MF_ENDPOINT); | ||
|
||
if (endpoint != null) { | ||
config.setEndpoint(endpoint); | ||
} | ||
String sessionEndpoint = data.getString(MF_SESSIONS_ENDPOINT); | ||
|
||
if (sessionEndpoint != null) { | ||
config.setSessionEndpoint(sessionEndpoint); | ||
if (data.containsKey(MF_ENDPOINT)) { | ||
String endpoint = data.getString(MF_ENDPOINT); | ||
String sessionEndpoint = data.getString(MF_SESSIONS_ENDPOINT); | ||
//noinspection ConstantConditions (pass in null/empty as this function will warn) | ||
config.setEndpoints(endpoint, sessionEndpoint); | ||
} | ||
|
||
config.setSendThreads(data.getBoolean(MF_SEND_THREADS, true)); | ||
config.setPersistUserBetweenSessions( | ||
data.getBoolean(MF_PERSIST_USER_BETWEEN_SESSIONS, false)); | ||
config.setAutoCaptureSessions(data.getBoolean(MF_AUTO_CAPTURE_SESSIONS, false)); | ||
|
||
if (data.containsKey(MF_AUTO_CAPTURE_SESSIONS)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the advantage of this over the previous with the default set to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method no longer requires any knowledge of whether sessions should be automatically captured or not, and relies on |
||
config.setAutoCaptureSessions(data.getBoolean(MF_AUTO_CAPTURE_SESSIONS)); | ||
} | ||
|
||
config.setEnableExceptionHandler( | ||
data.getBoolean(MF_ENABLE_EXCEPTION_HANDLER, true)); | ||
return config; | ||
|
@@ -390,7 +390,10 @@ public void setContext(String context) { | |
* endpoint. | ||
* | ||
* @param endpoint the custom endpoint to send report to | ||
* @deprecated use {@link com.bugsnag.android.Configuration#setEndpoints(String, String)} | ||
* instead. | ||
*/ | ||
@Deprecated | ||
public void setEndpoint(String endpoint) { | ||
config.setEndpoint(endpoint); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import android.content.Context; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.text.TextUtils; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
@@ -30,8 +31,8 @@ public class Configuration extends Observable implements Observer { | |
private String buildUuid; | ||
private String appVersion; | ||
private String context; | ||
private String endpoint = "https://notify.bugsnag.com"; | ||
private String sessionEndpoint = "https://sessions.bugsnag.com"; | ||
private volatile String endpoint = "https://notify.bugsnag.com"; | ||
private volatile String sessionEndpoint = "https://sessions.bugsnag.com"; | ||
|
||
private String[] ignoreClasses; | ||
@Nullable | ||
|
@@ -42,7 +43,7 @@ public class Configuration extends Observable implements Observer { | |
private boolean enableExceptionHandler = true; | ||
private boolean persistUserBetweenSessions = false; | ||
private long launchCrashThresholdMs = 5 * 1000; | ||
private boolean autoCaptureSessions = false; | ||
private boolean autoCaptureSessions = true; | ||
private boolean automaticallyCollectBreadcrumbs = true; | ||
|
||
@NonNull | ||
|
@@ -134,11 +135,49 @@ public String getEndpoint() { | |
* endpoint. | ||
* | ||
* @param endpoint the custom endpoint to send report to | ||
* @deprecated use {@link com.bugsnag.android.Configuration#setEndpoints(String, String)} | ||
*/ | ||
@Deprecated | ||
public void setEndpoint(String endpoint) { | ||
this.endpoint = endpoint; | ||
} | ||
|
||
/** | ||
* Set the endpoints to send data to. By default we'll send error reports to | ||
* https://notify.bugsnag.com, and sessions to https://session.bugsnag.com, but you can | ||
* override this if you are using Bugsnag Enterprise to point to your own Bugsnag endpoint. | ||
* | ||
* Please note that it is recommended that you set both endpoints. If the notify endpoint is | ||
* missing, an exception will be thrown. If the session endpoint is missing, a warning will be | ||
* logged and sessions will not be sent automatically. | ||
* | ||
* @param notify the notify endpoint | ||
* @param sessions the sessions endpoint | ||
* | ||
* @throws IllegalArgumentException if the notify endpoint is empty or null | ||
*/ | ||
@SuppressWarnings("ConstantConditions") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be worth adding a comment on the reasoning behind suppressing specific warnings There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added an inline comment |
||
public void setEndpoints(@NonNull String notify, @NonNull String sessions) | ||
throws IllegalArgumentException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a big change in behavior? The other methods on configuration just accept whatever was set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC the design doc for this change states that we should throw an exception if |
||
|
||
if (TextUtils.isEmpty(notify)) { | ||
throw new IllegalArgumentException("Notify endpoint cannot be empty or null."); | ||
} else { | ||
this.endpoint = notify; | ||
} | ||
|
||
boolean invalidSessionsEndpoint = TextUtils.isEmpty(sessions); | ||
|
||
if (invalidSessionsEndpoint) { | ||
Logger.warn("The session tracking endpoint has not been set. " | ||
+ "Session tracking is disabled"); | ||
this.sessionEndpoint = null; | ||
this.autoCaptureSessions = false; | ||
} else { | ||
this.sessionEndpoint = sessions; | ||
} | ||
} | ||
|
||
/** | ||
* Gets the Session Tracking API endpoint | ||
* | ||
|
@@ -155,7 +194,9 @@ public String getSessionEndpoint() { | |
* endpoint. | ||
* | ||
* @param endpoint the custom endpoint to send session data to | ||
* @deprecated use {@link com.bugsnag.android.Configuration#setEndpoints(String, String)} | ||
*/ | ||
@Deprecated | ||
public void setSessionEndpoint(String endpoint) { | ||
this.sessionEndpoint = endpoint; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,11 @@ class SessionTracker implements Application.ActivityLifecycleCallbacks { | |
* @param user the session user (if any) | ||
*/ | ||
void startNewSession(@NonNull Date date, @Nullable User user, boolean autoCaptured) { | ||
if (configuration.getSessionEndpoint() == null) { | ||
Logger.warn("The session tracking endpoint has not been set. " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should have mentioned this earlier, sorry - Should this warning be a one-time thing? We could end up adding a lot of logger noise. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess that's ok, are there any similar cases already present in the notifier? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is somewhat similar. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean for the logging repeatedly when in debug mode? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Cawllec it's not particularly easy to test log messages in Android unfortunately |
||
+ "Session tracking is disabled"); | ||
return; | ||
} | ||
Session session = new Session(UUID.randomUUID().toString(), date, user, autoCaptured); | ||
currentSession.set(session); | ||
trackSessionIfNeeded(session); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm reusing this copy for the js changelog and noticed a little typo: