Skip to content

feat(core): add isObjectLike guard and consolidate non-null-object checks#22155

Merged
logaretm merged 8 commits into
developfrom
feat/consolidate-is-object
Jul 9, 2026
Merged

feat(core): add isObjectLike guard and consolidate non-null-object checks#22155
logaretm merged 8 commits into
developfrom
feat/consolidate-is-object

Conversation

@logaretm

@logaretm logaretm commented Jul 9, 2026

Copy link
Copy Markdown
Member

Adds an isObjectLike type guard to @sentry/core (typeof x === 'object' && x !== null) and routes the duplicated and inline non-null-object checks across the SDK through it.

Named isObjectLike rather than isObject on purpose. This guard only rules out null, primitives, and functions (arrays and class instances pass). I took a look at some examples in the ecosystem and GraphQL and Lodash do use this name for this exact type of check, so I'm sticking with that.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.6 kB +0.06% +15 B 🔺
@sentry/browser - with treeshaking flags 26.04 kB +0.07% +17 B 🔺
@sentry/browser (incl. Tracing) 46.35 kB +0.03% +12 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.14 kB +0.03% +13 B 🔺
@sentry/browser (incl. Tracing, Profiling) 51.13 kB +0.04% +17 B 🔺
@sentry/browser (incl. Tracing, Replay) 85.62 kB +0.01% +1 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.25 kB -0.02% -14 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 90.33 kB +0.01% +7 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 102.99 kB +0.03% +22 B 🔺
@sentry/browser (incl. Feedback) 44.78 kB +0.04% +16 B 🔺
@sentry/browser (incl. sendFeedback) 32.4 kB +0.07% +21 B 🔺
@sentry/browser (incl. FeedbackAsync) 37.53 kB +0.05% +17 B 🔺
@sentry/browser (incl. Metrics) 28.68 kB +0.04% +11 B 🔺
@sentry/browser (incl. Logs) 28.93 kB +0.07% +18 B 🔺
@sentry/browser (incl. Metrics & Logs) 29.61 kB +0.06% +17 B 🔺
@sentry/react 29.39 kB +0.04% +11 B 🔺
@sentry/react (incl. Tracing) 48.62 kB +0.03% +10 B 🔺
@sentry/vue 33.03 kB +0.03% +8 B 🔺
@sentry/vue (incl. Tracing) 48.33 kB +0.04% +19 B 🔺
@sentry/svelte 27.63 kB +0.04% +10 B 🔺
CDN Bundle 30 kB +0.01% +2 B 🔺
CDN Bundle (incl. Tracing) 48.33 kB +0.03% +11 B 🔺
CDN Bundle (incl. Logs, Metrics) 31.58 kB +0.05% +14 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 49.65 kB +0.01% +4 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 70.81 kB -0.01% -2 B 🔽
CDN Bundle (incl. Tracing, Replay) 85.83 kB -0.02% -10 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.15 kB +0.02% +12 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 91.64 kB -0.01% -6 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.91 kB -0.01% -8 B 🔽
CDN Bundle - uncompressed 89.33 kB -0.03% -25 B 🔽
CDN Bundle (incl. Tracing) - uncompressed 146.07 kB -0.02% -27 B 🔽
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.03 kB -0.03% -24 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.05 kB -0.02% -26 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.71 kB -0.04% -76 B 🔽
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.23 kB -0.03% -78 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.18 kB -0.03% -78 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.93 kB -0.03% -78 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.88 kB -0.03% -78 B 🔽
@sentry/nextjs (client) 51.17 kB +0.03% +11 B 🔺
@sentry/sveltekit (client) 46.8 kB +0.05% +22 B 🔺
@sentry/core/server 78.42 kB -0.02% -15 B 🔽
@sentry/core/browser 64.77 kB +0.02% +12 B 🔺
@sentry/node-core 62.73 kB +0.01% +5 B 🔺
@sentry/node 125.33 kB -0.04% -47 B 🔽
@sentry/node (incl. diagnostics channel injection) 138.5 kB -0.04% -50 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB - -
@sentry/node/light 50.73 kB +0.03% +12 B 🔺
@sentry/node - without tracing 74.04 kB -0.03% -18 B 🔽
@sentry/aws-serverless 83.26 kB +0.02% +11 B 🔺
@sentry/cloudflare (withSentry) - minified 181.47 kB -0.14% -243 B 🔽
@sentry/cloudflare (withSentry) 448.98 kB -0.05% -182 B 🔽

View base workflow run

@logaretm logaretm changed the title feat(core): add isObject guard and consolidate call sites feat(core): add isObjectLike guard and consolidate non-null-object checks Jul 9, 2026
@logaretm logaretm marked this pull request as ready for review July 9, 2026 20:10
@logaretm logaretm requested review from a team as code owners July 9, 2026 20:10
@logaretm logaretm requested review from JPeer264, Lms24, andreiborza, chargome, mydea and s1gr1d and removed request for a team July 9, 2026 20:10

@nicohrubec nicohrubec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice

@logaretm logaretm merged commit 88e3b32 into develop Jul 9, 2026
306 checks passed
@logaretm logaretm deleted the feat/consolidate-is-object branch July 9, 2026 23:46
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