Skip to content

Commit

Permalink
fix: add projectPackages to event payload
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Apr 21, 2021
1 parent f40a9ee commit d8e8e8a
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 1 deletion.
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

0 comments on commit d8e8e8a

Please sign in to comment.