-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): Allow to specify depth to dropUndefinedKeys
#15783
base: develop
Are you sure you want to change the base?
Conversation
size-limit report 📦
|
origin: attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined, | ||
links: convertSpanLinksForEnvelope(links), | ||
}); | ||
return dropUndefinedKeys( |
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.
Do we even need to call dropUndefinedKeys
here?
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.
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 extracted this out here: #15792 - I think you are right 🤔
9e7b55d
to
f9e2f48
Compare
Actually, after some more thought - maybe we can completely remove this and just rewrite the few places we actually need this 🤔 |
Today,
dropUndefinedKeys()
will iterate through all objects and arrays and make sure to drop undefined keys everywhere.In reality, we do not need this behavior in most/many cases - often, just removing undefined values one level deep should be more than good enough (apart from cases like #15781 where we maybe do not need it at all!)
So this PR introduces an optional second argument to
dropUndefinedKeys()
which is a depth, which defaults toInfinity
. It will drop undefined keys recursively until it reaches this depth.By specifying e.g.
1
there, only the top level of the passed in object will be checked for undefined values.