-
Notifications
You must be signed in to change notification settings - Fork 120
Conventionalize to fix sneaky breadcrumb logging bugs #56
Conversation
console.warn('Breadcrumb name must be a String'); | ||
leaveBreadcrumb(name, metadata) { | ||
if (typeof name !== 'string') { | ||
console.warn(`Breadcrumb name must be a string, got '${name}'. Discarding.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably you should put type of name
? That would be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be happy to change this if I can make the message more helpful, but I think the variable itself is more useful than just the type of the variable. You can intuit the type from the content, but not vice versa.
One example of how this could be confusing is if name
is null
, then typeof name
is 'object'
.
@kattrali is there anything I can do to help this get merged? It fixes multiple important bugs. Let me know :) |
Thanks for the bump, @cooperka. It's a little hard to bring all of this in at once, since it doesn't seem to all be breadcrumb related. I just have a few questions.
Makes sense. Though it seems a bit odd to add the logged error message as metadata. A console warning could suffice, similar to the other errors which could be encountered.
What behavior does this fix?
This change was introduced in #17, since requiring something like |
@kattrali thanks for the feedback. My apologies for the confusion, my intent here really is to conventionalize the code in order to fix a few sneaky bugs, rather than fixing them more directly with workarounds. I've updated the title to make it more clear. If you'd like me to split it into separate PRs I would be happy to. I didn't realize the closures were added intentionally; I've rebased to exclude that commit. It does make sense why users were confused by the behavior you mentioned.
Finally, there are a few answers on this SO question that explain why I prefer Also, in one case |
Fixes a bug; see PR.
Fixes a couple hidden bugs; see PR description.
Gotcha! Thanks for the clarifications, its much clearer now what is going on. I'll look it over again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm 🦉
Thanks! |
This PR makes the code follow more standard JS conventions, fixing several major bugs related to breadcrumb logging. It also tackles a few other cleanup items related to the changes.
null
, andundefined
in breadcrumbstypeof
in several places instead of various alternativesUse regular functions instead of closures(previously 22aac3a)hasOwnProperty
before adding to typedMap output.idea
directory created by IntelliJ IDEsPlease see the individual commits for more information and to understand each change as a unit.
Obsolete:
Note: None of these changes should be breaking, except in the following case. The use of regular functions instead of closures means thatthis
can refer to the wrapper object in rare cases, for example if you do the following: