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

@logaretmlogaretm 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-actionsBot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser27.6 kB+0.06%+15 B 🔺
@sentry/browser - with treeshaking flags26.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 flags75.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/react29.39 kB+0.04%+11 B 🔺
@sentry/react (incl. Tracing)48.62 kB+0.03%+10 B 🔺
@sentry/vue33.03 kB+0.03%+8 B 🔺
@sentry/vue (incl. Tracing)48.33 kB+0.04%+19 B 🔺
@sentry/svelte27.63 kB+0.04%+10 B 🔺
CDN Bundle30 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 - uncompressed89.33 kB-0.03%-25 B 🔽
CDN Bundle (incl. Tracing) - uncompressed146.07 kB-0.02%-27 B 🔽
CDN Bundle (incl. Logs, Metrics) - uncompressed94.03 kB-0.03%-24 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed150.05 kB-0.02%-26 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed218.71 kB-0.04%-76 B 🔽
CDN Bundle (incl. Tracing, Replay) - uncompressed265.23 kB-0.03%-78 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed269.18 kB-0.03%-78 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed278.93 kB-0.03%-78 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed282.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/server78.42 kB-0.02%-15 B 🔽
@sentry/core/browser64.77 kB+0.02%+12 B 🔺
@sentry/node-core62.73 kB+0.01%+5 B 🔺
@sentry/node125.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/light50.73 kB+0.03%+12 B 🔺
@sentry/node - without tracing74.04 kB-0.03%-18 B 🔽
@sentry/aws-serverless83.26 kB+0.02%+11 B 🔺
@sentry/cloudflare (withSentry) - minified181.47 kB-0.14%-243 B 🔽
@sentry/cloudflare (withSentry)448.98 kB-0.05%-182 B 🔽

View base workflow run

@logaretmlogaretm changed the title feat(core): add isObject guard and consolidate call sitesfeat(core): add isObjectLike guard and consolidate non-null-object checksJul 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 ownersJuly 9, 2026 20:10
@logaretm
logaretm requested review from JPeer264, Lms24, andreiborza, chargome, mydea and s1gr1d and removed request for a teamJuly 9, 2026 20:10

@nicohrubecnicohrubec 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 developJul 9, 2026
306 checks passed
@logaretm
logaretm deleted the feat/consolidate-is-object branch July 9, 2026 23:46
logaretm added a commit that referenced this pull request Jul 17, 2026
…22370)
Adds a item to `AGENTS.md` (`CLAUDE.md` symlinks to it) telling agents
to search for an existing util before writing a new one, pointing at
where shared helpers actually live (`packages/core/src/utils/`,
`packages/browser-utils/`).
Motivation: LLM-assisted changes have a habit of introducing
near-duplicate helpers instead of reusing what's already there. This is
a passive nudge rather than an enforced check.
I did a quick check spawned a couple of agents on bogus tasks that
needed a couple of utils, and watched its reasoning and it picked up on
this, so while it doesn't enforce it, it may help us curb the util soup
we get.
This is a follow up to my previous util cleanup PRs #22155#22163#22154
Sign up for freeto 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

@logaretm@nicohrubec