Skip to content

Commit 4a7396c

Browse files
committed
fix(android): Fix breadcrumb data for non-string types
1 parent 6fb6ad8 commit 4a7396c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/nssentry.android.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,21 @@ export namespace NSSentry {
179179
try {
180180
if (breadcrumb.data) {
181181
Object.keys(breadcrumb.data).forEach((k) => {
182-
const value = breadcrumb.data[k];
182+
let value = breadcrumb.data[k];
183183
// in case a `status_code` entry got accidentally stringified as a float
184-
if (k === 'status_code') {
185-
nBreadcumb.setData(k, value && value.endsWith('.0') ? value.replace('.0', '') : value);
186-
} else {
187-
nBreadcumb.setData(k, value);
184+
if (k === 'status_code' && typeof value === 'string' && value.endsWith('.0')) {
185+
value = value.replace('.0', '');
186+
} else if (typeof value === 'boolean') {
187+
value = new java.lang.Boolean(value);
188+
} else if (typeof value === 'number') {
189+
value = value.toString();
190+
} else if (Array.isArray(value)) {
191+
value = new org.json.JSONArray(JSON.stringify(value));
192+
} else if (value && typeof value === 'object') {
193+
value = new org.json.JSONObject(JSON.stringify(value));
188194
}
195+
196+
nBreadcumb.setData(k, value);
189197
});
190198
}
191199
} catch (e) {

0 commit comments

Comments
 (0)