-
Notifications
You must be signed in to change notification settings - Fork 10
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
Navigator.pushAndRemoveUntil throws exception in Bugsnag #242
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b2a38e8
Navigator.pushAndRemoveUntil throws exception in Bugsnag #238
57b6d22
Updated changelog
c169dec
Extended the solution to other cases
509b746
Fixed an issue
b73f35b
Fixed an issue
e9ca14f
Fixed metadata handling on Android
239b997
Apply suggestions from code review
robert-smartbear 73907c6
Changes requested in code review
f1d146f
Added E2E tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -104,18 +104,18 @@ Void start(@Nullable JSONObject args) throws Exception { | |||||
? new Configuration(arguments.getString("apiKey")) | ||||||
: Configuration.load(context); | ||||||
|
||||||
configuration.setAppType(arguments.optString("appType", configuration.getAppType())); | ||||||
configuration.setAppVersion(arguments.optString("appVersion", configuration.getAppVersion())); | ||||||
configuration.setAppType(getString(arguments, "appType", configuration.getAppType())); | ||||||
configuration.setAppVersion(getString(arguments, "appVersion", configuration.getAppVersion())); | ||||||
configuration.setAutoTrackSessions(arguments.optBoolean("autoTrackSessions", configuration.getAutoTrackSessions())); | ||||||
configuration.setAutoDetectErrors(arguments.optBoolean("autoDetectErrors", configuration.getAutoDetectErrors())); | ||||||
configuration.setContext(arguments.optString("context", configuration.getContext())); | ||||||
configuration.setContext(getString(arguments, "context", configuration.getContext())); | ||||||
configuration.setLaunchDurationMillis(arguments.optLong("launchDurationMillis", configuration.getLaunchDurationMillis())); | ||||||
configuration.setSendLaunchCrashesSynchronously(arguments.optBoolean("sendLaunchCrashesSynchronously", configuration.getSendLaunchCrashesSynchronously())); | ||||||
configuration.setMaxBreadcrumbs(arguments.optInt("maxBreadcrumbs", configuration.getMaxBreadcrumbs())); | ||||||
configuration.setMaxPersistedEvents(arguments.optInt("maxPersistedEvents", configuration.getMaxPersistedEvents())); | ||||||
configuration.setMaxPersistedSessions(arguments.optInt("maxPersistedSessions", configuration.getMaxPersistedSessions())); | ||||||
configuration.setMaxStringValueLength(arguments.optInt("maxStringValueLength", configuration.getMaxStringValueLength())); | ||||||
configuration.setReleaseStage(arguments.optString("releaseStage", configuration.getReleaseStage())); | ||||||
configuration.setReleaseStage(getString(arguments, "releaseStage", configuration.getReleaseStage())); | ||||||
configuration.setPersistUser(arguments.optBoolean("persistUser", configuration.getPersistUser())); | ||||||
|
||||||
if (arguments.has("redactedKeys")) { | ||||||
|
@@ -133,9 +133,9 @@ Void start(@Nullable JSONObject args) throws Exception { | |||||
JSONObject user = arguments.optJSONObject("user"); | ||||||
if (user != null) { | ||||||
configuration.setUser( | ||||||
user.optString("id", null), | ||||||
user.optString("email", null), | ||||||
user.optString("name", null) | ||||||
getString(user, "id"), | ||||||
getString(user, "email"), | ||||||
getString(user, "name") | ||||||
); | ||||||
} | ||||||
|
||||||
|
@@ -228,9 +228,9 @@ JSONObject getUser(@Nullable JSONObject args) { | |||||
Void setUser(@Nullable JSONObject user) { | ||||||
if (user != null) { | ||||||
Bugsnag.setUser( | ||||||
(String) user.opt("id"), | ||||||
(String) user.opt("email"), | ||||||
(String) user.opt("name") | ||||||
getString(user, "id"), | ||||||
getString(user, "email"), | ||||||
getString(user, "name") | ||||||
); | ||||||
} else { | ||||||
Bugsnag.setUser(null, null, null); | ||||||
|
@@ -241,7 +241,7 @@ Void setUser(@Nullable JSONObject user) { | |||||
|
||||||
Void setContext(@Nullable JSONObject args) { | ||||||
if (args != null) { | ||||||
Bugsnag.setContext((String) args.opt("context")); | ||||||
Bugsnag.setContext(getString(args, "context")); | ||||||
} | ||||||
|
||||||
return null; | ||||||
|
@@ -253,9 +253,9 @@ String getContext(@Nullable JSONObject args) { | |||||
|
||||||
Void leaveBreadcrumb(@Nullable JSONObject args) throws Exception { | ||||||
if (args != null && | ||||||
args.has("name") && | ||||||
hasString(args, "name") && | ||||||
args.has("metaData") && | ||||||
args.has("type")) { | ||||||
hasString(args, "type")) { | ||||||
Bugsnag.leaveBreadcrumb(args.getString("name"), | ||||||
JsonHelper.unwrap(args.getJSONObject("metaData")), | ||||||
JsonHelper.unpackBreadcrumbType(args.getString("type"))); | ||||||
|
@@ -279,7 +279,7 @@ Void addFeatureFlags(@Nullable JSONArray args) { | |||||
} | ||||||
|
||||||
Void clearFeatureFlag(@Nullable JSONObject args) throws JSONException { | ||||||
if (args != null && args.has("name")) { | ||||||
if (args != null && hasString(args, "name")) { | ||||||
Bugsnag.clearFeatureFlag(args.getString("name")); | ||||||
} | ||||||
return null; | ||||||
|
@@ -291,7 +291,7 @@ Void clearFeatureFlags(@Nullable JSONObject args) { | |||||
} | ||||||
|
||||||
Void addMetadata(@Nullable JSONObject args) throws JSONException { | ||||||
if (args == null || !args.has("section") || !args.has("metadata")) { | ||||||
if (args == null || !hasString(args,"section") || args.has("metadata")) { | ||||||
return null; | ||||||
} | ||||||
|
||||||
|
@@ -303,11 +303,11 @@ Void addMetadata(@Nullable JSONObject args) throws JSONException { | |||||
} | ||||||
|
||||||
Void clearMetadata(@Nullable JSONObject args) throws JSONException { | ||||||
if (args == null || !args.has("section")) { | ||||||
if (args == null || !hasString(args,"section")) { | ||||||
robert-smartbear marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
return null; | ||||||
} | ||||||
|
||||||
if (args.has("key")) { | ||||||
if (hasString(args,"key")) { | ||||||
robert-smartbear marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
Bugsnag.clearMetadata(args.getString("section"), args.getString("key")); | ||||||
} else { | ||||||
Bugsnag.clearMetadata(args.getString("section")); | ||||||
|
@@ -317,7 +317,7 @@ Void clearMetadata(@Nullable JSONObject args) throws JSONException { | |||||
} | ||||||
|
||||||
JSONObject getMetadata(@Nullable JSONObject args) throws JSONException { | ||||||
if (args == null || !args.has("section")) { | ||||||
if (args == null || !hasString(args,"section")) { | ||||||
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. nit: formatting
Suggested change
|
||||||
return null; | ||||||
} | ||||||
|
||||||
|
@@ -403,4 +403,21 @@ JSONObject deliverEvent(@Nullable JSONObject eventJson) { | |||||
client.deliverEvent(event); | ||||||
return null; | ||||||
} | ||||||
|
||||||
@Nullable String getString(JSONObject args, String key) { | ||||||
if (!args.has(key)) { | ||||||
return null; | ||||||
} | ||||||
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 think this check is redundant, if |
||||||
Object value = args.opt(key); | ||||||
return value instanceof String ? (String) value : null; | ||||||
} | ||||||
|
||||||
@Nullable String getString(JSONObject args, String key, @Nullable String fallback) { | ||||||
String value = getString(args, key); | ||||||
return value != null ? value : fallback; | ||||||
} | ||||||
|
||||||
boolean hasString(JSONObject args, String key) { | ||||||
return getString(args, key) != null; | ||||||
} | ||||||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: formatting