-
Notifications
You must be signed in to change notification settings - Fork 121
Breadcrumbs not properly treating objects as metadata on android #36
Comments
When I allow the object to pass I get It seems related to this: #32 |
As I'm looking through this code, I see the function here: /**
* Convert an object into a structure with types suitable for serializing
* across to native code.
*/
const typedMap = function(map) {
const output = {};
for (const key in map) {
const value = map[key];
if (value instanceof Map || value instanceof Object) {
output[key] = {type: 'map', value: typedMap(value)};
} else {
const type = typeof value;
if (allowedMapObjectTypes.includes(type)) {
output[key] = {type: type, value: value};
}
}
}
return output;
}; And i can see it recursively move through the object and turns each object into a serializeable map. however, the check is for somethign that is an instance of Map, as in either a Map class, or Map prototype. I dont see how anything could ever pass that check, there is no Map constructor in this file (or anywhere), there is only the What I am saying is you are checking for instances of classes or prototypes that don't exist. I have questions:
|
@the-simian, indeed this should already be fixed by #33. The new version isn't published yet, but you can fork it for now or refer to the commit hash.
I'll let a BugSnag owner comment on the rest of your questions, as I don't want to mislead you by getting something wrong in terms of BugSnag's expectations. Seems like they don't have a lot of documentation or unit tests yet. |
Is Maybe I'm misunderstanding what's going on. The JSON you pass into the (JS) |
@the-simian I misunderstood which Feel free to submit a PR and fix this! |
I'd love to submit a Pr, but I was asking questions about what the (at least) Android Interface needs to be. Swapping that out with a plain-old check of an Object or something like:
causes the same error as PR #33 ostensibly fixes. I also noticed the 'Mapper' |
In the latest release v1.1.3, the breadcrumb can only be a string on Android. It can be any plain type on iOS (string, number, boolean, or object consisting of any of these types). PR #33 should have fixed Android, and as of that change you should be able to use at least numbers and booleans. I thought it also worked for objects, but as you point out it may not. With your suggested change above, it should then work for objects too. Does that help? |
Yeah that is helpful, let me make sure I got this right
Do I have the details correct? this is why you wrote the typedMap in the first place? I'll mess around with this and see if I can fix it. |
That's mostly right, but actually nested objects should also work -- they'll just be recursively flattened into a string before logging. But yes, this logic is separate from the object/map check in JS. |
Alright I'll try to fix it, thanks for that answer its exactly what I needed, right now as-is the typedMap does send something broken into android, but I think i know what to do |
Good luck! I'll be happy to review a PR if you end up fixing it. |
Thanks for the debugging, @cooperka, @the-simian - updated this in a patch just now, which will be published shortly. |
@kattrali (cc @cooperka) I'll check it out, but just be aware that even with
The type-checking in the method is easy enough, but I think the Android API is still not handling nested object correctly as-is. I'll see for sure in a short bit, when you publish! If my suspicion is correct I will open a separate issue for that. |
Ah, thanks for the clarification, @the-simian. I thought this was handled given #33 and 262b991. Let me know if there is a further issue. |
Using this line of code:
client.leaveBreadcrumb('foo', {bar: 'baz'});
results in the warning:
Breadcrumb metadata is not a Map or String
here:
as a result, the breadcrumbs are never left.
i can see that the incoming metadata is jsut a normal js object. it does not appear to be converted into
Map
, as-isThe text was updated successfully, but these errors were encountered: