Skip to content

Commit

Permalink
fix: serialise breadcrumb message correctly (#306)
Browse files Browse the repository at this point in the history
the breadcrumb message should be serialised as part of the
metadata, not as the name attribute
  • Loading branch information
fractalwrench authored and kattrali committed May 2, 2018
1 parent a5f103a commit 8a24ac6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 20 additions & 0 deletions sdk/src/androidTest/java/com/bugsnag/android/BreadcrumbsTest.java
@@ -1,5 +1,7 @@
package com.bugsnag.android;

import static com.bugsnag.android.BreadcrumbType.MANUAL;
import static com.bugsnag.android.BugsnagTestUtils.generateClient;
import static com.bugsnag.android.BugsnagTestUtils.streamableToJsonArray;
import static org.junit.Assert.assertEquals;

Expand All @@ -16,6 +18,7 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Queue;


@RunWith(AndroidJUnit4.class)
Expand Down Expand Up @@ -172,4 +175,21 @@ public void testPayloadType() throws JSONException, IOException {
assertEquals("left", node.getJSONObject("metaData").get("direction"));
assertEquals(1, breadcrumbsJson.length());
}

@Test
public void testClientMethods() {
Client client = generateClient();
client.leaveBreadcrumb("Hello World");
Queue<Breadcrumb> store = client.breadcrumbs.store;
int count = 0;

for (Breadcrumb breadcrumb : store) {
if (MANUAL == breadcrumb.getType() && "manual".equals(breadcrumb.getName())) {
count++;
assertEquals("Hello World", breadcrumb.getMetadata().get("message"));
}
}
assertEquals(1, count);
}

}
3 changes: 1 addition & 2 deletions sdk/src/main/java/com/bugsnag/android/Client.java
Expand Up @@ -1172,8 +1172,7 @@ public void setMetaData(@NonNull MetaData metaData) {
* @param breadcrumb the log message to leave (max 140 chars)
*/
public void leaveBreadcrumb(@NonNull String breadcrumb) {
Map<String, String> metaData = Collections.emptyMap();
Breadcrumb crumb = new Breadcrumb(breadcrumb, BreadcrumbType.MANUAL, metaData);
Breadcrumb crumb = new Breadcrumb(breadcrumb);

if (runBeforeBreadcrumbTasks(crumb)) {
breadcrumbs.add(crumb);
Expand Down

0 comments on commit 8a24ac6

Please sign in to comment.