Skip to content

Commit 25f724a

Browse files
authored
fix(ndk): breadcrumb data serialization (#1808)
1 parent fd19f35 commit 25f724a

4 files changed

Lines changed: 189 additions & 136 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
**Fixes**:
66

77
- Report on partial disk writes when streaming envelopes to file, which previously left truncated envelopes on disk and reported success. ([#1804](https://github.com/getsentry/sentry-native/pull/1804))
8+
- Android: breadcrumb `data` is now sent as a structured object instead of a raw JSON string. ([#1808](https://github.com/getsentry/sentry-native/pull/1808))
89

910
## 0.15.0
1011

ndk/lib/src/androidTest/java/io/sentry/ndk/SentryNdkTest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.sentry.ndk;
22

33
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertFalse;
45
import static org.junit.Assert.assertNotNull;
56
import static org.junit.Assert.assertTrue;
67

@@ -109,7 +110,12 @@ public void messageCaught() throws IOException {
109110
// when initialized
110111
SentryNdk.init(options);
111112

112-
// and a message is captured
113+
// and a breadcrumb whose data was serialized to a JSON object string is added
114+
new NativeScope()
115+
.addBreadcrumb(
116+
"info", "test crumb", "test", "default", null, "{\"some_key\":\"some_value\"}");
117+
118+
// and a message is captured (which merges the scope's breadcrumbs into it)
113119
NdkTestHelper.message();
114120

115121
// then the message should be stored on disk
@@ -120,6 +126,10 @@ public void messageCaught() throws IOException {
120126
String content = new String(Files.readAllBytes(firstFile.toPath()), StandardCharsets.UTF_8);
121127
assertTrue(content.contains("It works!")); // expected message content from
122128
// Java_io_sentry_ndk_NdkTestHelper_message(..) in ndk-test.cpp
129+
130+
// and the breadcrumb data is well formed.
131+
assertTrue(content.contains("\"some_key\":\"some_value\""));
132+
assertFalse(content.contains("\"data\":\"{"));
123133
}
124134

125135
@Test

0 commit comments

Comments
 (0)