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

Add projectPackages field to error payloads #1226

Merged
merged 1 commit into from
Apr 21, 2021
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### Bug fixes

* Add projectPackages field to error payloads
[#1226](https://github.com/bugsnag/bugsnag-android/pull/1226)

* Fix deserialization bug in persisted NDK errors
[#1220](https://github.com/bugsnag/bugsnag-android/pull/1220)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ internal class EventInternal @JvmOverloads internal constructor(

val metadata: Metadata = data.copy()
private val discardClasses: Set<String> = config.discardClasses.toSet()
private val projectPackages = config.projectPackages

@JvmField
internal var session: Session? = null
Expand Down Expand Up @@ -84,6 +85,12 @@ internal class EventInternal @JvmOverloads internal constructor(
errors.forEach { writer.value(it) }
writer.endArray()

// Write project packages
writer.name("projectPackages")
writer.beginArray()
projectPackages.forEach { writer.value(it) }
writer.endArray()

// Write user info
writer.name("user").value(_user)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;

Expand All @@ -21,6 +22,7 @@ static Configuration generateConfiguration() {
Configuration configuration = new Configuration("5d1ec5bd39a74caa1267142706a7fb21");
configuration.setDelivery(generateDelivery());
configuration.setLogger(NoopLogger.INSTANCE);
configuration.setProjectPackages(Collections.singleton("com.example.foo"));
try {
File dir = Files.createTempDirectory("test").toFile();
configuration.setPersistenceDirectory(dir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal class ImmutableConfigTest {
// release stages
assertTrue(discardClasses.isEmpty())
assertNull(enabledReleaseStages)
assertTrue(projectPackages.isEmpty())
assertEquals(setOf("com.example.foo"), projectPackages)
assertEquals(seed.releaseStage, releaseStage)

// identifiers
Expand Down
3 changes: 3 additions & 0 deletions bugsnag-android-core/src/test/resources/event_redaction.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
},
"unhandled": false,
"exceptions": [],
"projectPackages":[
"com.example.foo"
],
"user": {},
"app": {
"type": "android",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
},
"unhandled": false,
"exceptions": [],
"projectPackages":[
"com.example.foo"
],
"user": {},
"app": {
"type": "android",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
},
"unhandled": false,
"exceptions": [],
"projectPackages":[
"com.example.foo"
],
"user": {},
"app": {
"type": "android",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
},
"unhandled": false,
"exceptions": [],
"projectPackages":[
"com.example.foo"
],
"user": {},
"app": {
"type": "android",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
},
"unhandled": false,
"exceptions": [],
"projectPackages":[
"com.example.foo"
],
"user": {},
"app": {
"type": "android",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
},
"unhandled": false,
"exceptions": [],
"projectPackages":[
"com.example.foo"
],
"user": {},
"app": {
"type": "android",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
},
"unhandled": false,
"exceptions": [],
"projectPackages":[
"com.example.foo"
],
"user": {},
"app": {
"type": "android",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"stacktrace": []
}
],
"projectPackages":[
"com.example.foo"
],
"user": {
"name": "Jamie"
},
Expand Down
6 changes: 6 additions & 0 deletions features/smoke_tests/handled.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Scenario: Notify caught Java exception with default configuration
# R8 minification alters the lineNumber, see the mapping file/source code for the original value
And the event "exceptions.0.stacktrace.0.lineNumber" equals 8
And the event "exceptions.0.stacktrace.0.inProject" is true
And the error payload field "events.0.projectPackages" is a non-empty array
And the event "projectPackages.0" equals "com.bugsnag.android.mazerunner"

And the thread with name "main" contains the error reporting flag
And the "method" of stack frame 0 equals "com.bugsnag.android.mazerunner.scenarios.HandledJavaSmokeScenario.startScenario"
Expand Down Expand Up @@ -116,6 +118,8 @@ Scenario: Notify Kotlin exception with overwritten configuration
And the event "severity" equals "error"
And the event "severityReason.type" equals "userCallbackSetSeverity"
And the event "severityReason.unhandledOverridden" is false
And the error payload field "events.0.projectPackages" is a non-empty array
And the event "projectPackages.0" equals "com.bugsnag.android.mazerunner"

# Stacktrace validation
And the error payload field "events.0.exceptions.0.stacktrace" is a non-empty array
Expand Down Expand Up @@ -171,6 +175,8 @@ Scenario: Handled C functionality
And the event "severity" equals "error"
And the event "severityReason.type" equals "userCallbackSetSeverity"
And the event "severityReason.unhandledOverridden" is false
And the error payload field "events.0.projectPackages" is a non-empty array
And the event "projectPackages.0" equals "com.bugsnag.android.mazerunner"

# App data
And the event "app.buildUUID" is not null
Expand Down
2 changes: 2 additions & 0 deletions features/smoke_tests/unhandled.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Scenario: Unhandled Java Exception with loaded configuration
And the event "severity" equals "error"
And the event "severityReason.type" equals "unhandledException"
And the event "severityReason.unhandledOverridden" is false
And the error payload field "events.0.projectPackages" is a non-empty array
And the event "projectPackages.0" equals "com.bugsnag.android.mazerunner"

# Stacktrace validation
And the error payload field "events.0.exceptions.0.stacktrace" is a non-empty array
Expand Down