Content-Length: 283944 | pFad | http://github.com/getsentry/sentry-javascript/pull/15783

58 feat(core): Allow to specify depth to `dropUndefinedKeys` by mydea · Pull Request #15783 · getsentry/sentry-javascript · GitHub
Skip to content
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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

mydea
Copy link
Member

@mydea mydea commented Mar 21, 2025

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 to Infinity. 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.

@mydea mydea requested review from AbhiPrasad and chargome March 21, 2025 11:52
@mydea mydea self-assigned this Mar 21, 2025
@mydea mydea requested a review from a team as a code owner March 21, 2025 11:52
Copy link
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.29 KB +0.07% +15 B 🔺
@sentry/browser - with treeshaking flags 23.1 KB +0.07% +16 B 🔺
@sentry/browser (incl. Tracing) 36.62 KB +0.05% +15 B 🔺
@sentry/browser (incl. Tracing, Replay) 73.81 KB +0.03% +19 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 67.16 KB +0.04% +23 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 78.44 KB +0.03% +19 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 91.01 KB +0.02% +16 B 🔺
@sentry/browser (incl. Feedback) 40.42 KB +0.04% +16 B 🔺
@sentry/browser (incl. sendFeedback) 27.93 KB +0.06% +16 B 🔺
@sentry/browser (incl. FeedbackAsync) 32.72 KB +0.05% +15 B 🔺
@sentry/react 25.09 KB +0.07% +16 B 🔺
@sentry/react (incl. Tracing) 38.55 KB +0.05% +18 B 🔺
@sentry/vue 27.52 KB +0.07% +18 B 🔺
@sentry/vue (incl. Tracing) 38.32 KB +0.04% +15 B 🔺
@sentry/svelte 23.32 KB +0.07% +16 B 🔺
CDN Bundle 24.51 KB +0.06% +15 B 🔺
CDN Bundle (incl. Tracing) 36.63 KB +0.06% +21 B 🔺
CDN Bundle (incl. Tracing, Replay) 71.65 KB +0.04% +28 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 76.84 KB +0.04% +24 B 🔺
CDN Bundle - uncompressed 71.66 KB +0.05% +35 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 108.7 KB +0.04% +39 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 219.96 KB +0.02% +41 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 232.53 KB +0.02% +41 B 🔺
@sentry/nextjs (client) 39.83 KB +0.06% +23 B 🔺
@sentry/sveltekit (client) 37.04 KB +0.06% +20 B 🔺
@sentry/node 142.64 KB +0.02% +17 B 🔺
@sentry/node - without tracing 96.03 KB +0.02% +15 B 🔺
@sentry/aws-serverless 120.4 KB +0.02% +18 B 🔺

View base workflow run

origen: attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,
links: convertSpanLinksForEnvelope(links),
});
return dropUndefinedKeys(
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/getsentry/sentry-javascript/pull/15783

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy