Repository navigation
ref(core): Drop unused internal exports and rename log/metric capture helpers - #26744
Conversation
Remove _INTERNAL_captureSerializedLog, _INTERNAL_captureSerializedMetric, _INTERNAL_captureMetric, INTERNAL_getSegmentSpan, _INTERNAL_getTunnelPaths, _INTERNAL_FLAG_BUFFER_SIZE and _INTERNAL_MAX_FLAGS_PER_SPAN from the public entry points. Nothing outside core uses them; the integration tests now inline the two feature flag constants. Co-Authored-By: Francesco Gringl-Novy <[email protected]>
size-limit report 📦Compared: 16ed3f6 (PR test merge using develop at cee40e6) Against: cee40e6 (develop) · base run #67873 ✅ Baseline matches: this diff contains only this PR's changes.
|
Optional E2E testsSome optional checks were not successful. They do not block the merge. 2 not successful, 81 successful. See the run.
Successful checks
|
|
|
damn, great finding. let's keep these as deprecated variants them and add the non-internal variant here, then we can eventually remove them in a follow up. |
## What Drops the `_INTERNAL_` prefix from the managed tunnel helpers in `@sentry/core`, `@sentry/core/server` and `@sentry/server-utils`, and from the tunnel setters that framework build plugins inject (`setTunnelDefaults` on `@sentry/astro/middleware`, `setTunnelBasePath` on `@sentry/react-router`, `setTunnelRoute` on `@sentry/tanstackstart-react`). Removes `_INTERNAL_installTunnelHooks` from `@sentry/node` and `_INTERNAL_getTunnelPaths` from `@sentry/core/server`. ## Why `@sentry/core` and `@sentry/server-utils` are internal packages, so their exports don't need a prefix to warn users off. The framework tunnel setters aren't brittle enough to warrant one either. - `_INTERNAL_installTunnelHooks` was a thin wrapper around server-utils' `instrumentTunnelServers`. It also leaked into every SDK that re-exports `@sentry/node`. Next.js and TanStack Start already depend on `@sentry/server-utils`, so they now call it directly. - `_INTERNAL_getTunnelPaths` had no users outside core. #26744 removes it as well, so the two PRs make the same change to that line. - Nothing else could move or be removed: - `applyBrowserTunnelDefaults` stays on the main `@sentry/core` entry, not `/browser`, because the frameworks' shared `common/tunnel.ts` modules also run at build time and on the server. - The Node handler (`handleServedNodeTunnelRequest`, `setNodeTunnelHandler`, `httpServerHandlesTunnel`) stays in core. It shares the request/response conversion with `handleTunnelRequestIfMatched`, and core's HTTP server instrumentation reads it from the shared tunnel store. - `resetTunnelDefaults` is only used by tests, but tests in five packages need it to reset shared state. <!-- junior-request-attribution:start --> via @mydea. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0C22CSDV6X%3A1795423564.677139 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AC0C22CSDV6X%3A1795423564.677139) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0C22CSDV6X%3A1795423564.677139/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Francesco Gringl-Novy <[email protected]>
The Electron SDK still uses _INTERNAL_captureSerializedLog, _INTERNAL_captureSerializedMetric and _INTERNAL_captureMetric. Export them as captureSerializedLog, captureSerializedMetric and captureMetric, and keep the old names as deprecated aliases until Electron moves over. Co-Authored-By: Francesco Gringl-Novy <[email protected]>
|
Done in 0a6ff37. |
…sed-internal-exports Co-Authored-By: Francesco Gringl-Novy <[email protected]> # Conflicts: # packages/core/src/server.ts
captureMetric becomes captureMetricEvent, so it no longer reads like a sibling of captureEvent and doesn't clash with the local captureMetric helpers in core and Electron. captureSerializedLog and captureSerializedMetric become bufferSerializedLog and bufferSerializedMetric: they only add an already processed item to the client's buffer. The deprecated _INTERNAL_ aliases point at the new names. Co-Authored-By: Francesco Gringl-Novy <[email protected]>
Rename _INTERNAL_captureLog to captureLogEvent, to match captureMetricEvent, and drop the _INTERNAL_ prefix from the flush and get buffer helpers for logs and metrics. Electron uses _INTERNAL_captureLog and React Native uses _INTERNAL_flushLogsBuffer, so the exported ones keep deprecated aliases. The get buffer helpers are not exported from the package, so they are renamed outright. Co-Authored-By: Francesco Gringl-Novy <[email protected]>
antonis
left a comment
There was a problem hiding this comment.
LGTM!
Thanks for the heads-up @mydea 🙇
We checked the React Native SDK and the only INTERNAL export we use is _INTERNAL_flushLogsBuffer (in our client, plus a few test spies).
Since we are still on JS v10 I've opened a follow up issue to remove that too in our next major getsentry/sentry-react-native#7108
What
Cleans up
_INTERNAL_-prefixed exports from@sentry/core:INTERNAL_getSegmentSpan, which no other package uses._INTERNAL_FLAG_BUFFER_SIZEand_INTERNAL_MAX_FLAGS_PER_SPAN, which only the browser and node feature flag integration tests imported. Each test package now defines the limits once._INTERNAL_captureLog→captureLogEvent_INTERNAL_captureMetric→captureMetricEvent_INTERNAL_captureSerializedLog→bufferSerializedLog_INTERNAL_captureSerializedMetric→bufferSerializedMetric_INTERNAL_flushLogsBuffer→flushLogsBuffer_INTERNAL_flushMetricsBuffer→flushMetricsBuffer_INTERNAL_getLogBufferand_INTERNAL_getMetricBuffertogetLogBufferandgetMetricBuffer. They aren't exported from the package, so they get no alias.Why
This is the first step in cleaning up
_INTERNAL_-prefixed exports, which only add surface area. Removed symbols are still exported from their own modules, so core keeps using them internally.Electron uses the capture helpers and React Native uses
_INTERNAL_flushLogsBuffer, so the old names can't go yet. A follow-up can drop the aliases once those SDKs use the new names.The new names avoid two problems with plain
captureLog/captureMetricandcaptureSerialized*:capture*Eventruns the full pipeline: enrichment,beforeSendLog/beforeSendMetric, serialization, then a sink that defaults to the buffer. A barecaptureMetricwould read like a sibling ofcaptureEvent/captureException, which return an event id and send their own envelope. It would also clash with the localcaptureMetrichelpers in core'smetrics/public-api.tsand in Electron.bufferSerialized*does no processing. It only adds an already processed item to the client's buffer, which is how Electron's main process ingests items from the renderer._INTERNAL_getTunnelPathswas dropped by #26746._INTERNAL_resetTunnelDefaultsis test-only, but tests in several packages call it, so it stays.via @mydea.
--
View Session [Sentry]