Skip to content

Commit

Permalink
fix(metadata): fix notifications for metadata sections populated usin…
Browse files Browse the repository at this point in the history
…g a `Map`
  • Loading branch information
lemnik committed Oct 25, 2021
1 parent 3c88066 commit e201bd8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
* Prevent events being attached to phantom sessions when they are blocked by an `OnSessionCallback`
[#1434](https://github.com/bugsnag/bugsnag-android/pull/1434)

* Plugins will correctly mirror metadata added using `addMetadata(String, Map)`
[#1454](https://github.com/bugsnag/bugsnag-android/pull/1454)

## 5.14.0 (2021-09-29)

### Enhancements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal data class MetadataState(val metadata: Metadata = Metadata()) :

private fun notifyMetadataAdded(section: String, value: Map<String, Any?>) {
value.entries.forEach {
updateState { AddMetadata(section, it.key, metadata.getMetadata(it.key)) }
updateState { AddMetadata(section, it.key, metadata.getMetadata(section, it.key)) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,19 @@ internal class MetadataStateTest {
assertEquals(setOf("foo"), sections)
assertEquals(setOf("key1", "key2", "key3"), keys)
}

@Test
fun observableMessageWithMap() {
val events = mutableListOf<StateEvent.AddMetadata>()
state.addObserver(
StateObserver {
events.add(it as StateEvent.AddMetadata)
}
)

state.addMetadata("fruit", mapOf<String, Any?>("apple" to "gala"))
assertEquals("fruit", events[0].section)
assertEquals("apple", events[0].key)
assertEquals("gala", events[0].value)
}
}

0 comments on commit e201bd8

Please sign in to comment.