♻️ move batching transport stack to @datadog/js-core - #4856
Draft
BenoitZugmeyer wants to merge 13 commits into
Draft
♻️ move batching transport stack to @datadog/js-core#4856BenoitZugmeyer wants to merge 13 commits into
BenoitZugmeyer wants to merge 13 commits into
Conversation
|
BenoitZugmeyer
force-pushed
the
benoit/move-transport
branch
from
July 8, 2026 15:17
fa999e3 to
db9e0f1
Compare
Bundles Sizes Evolution
|
Move byteUtils, context types, jsonStringify, objectValues and isServerError to js-core — they have no browser-specific dependencies and are needed by the transport modules that will follow in subsequent commits. Browser-core files become thin re-exports so all existing relative imports keep working without touching every consumer.
… public API These were exported as stepping stones during the migration but have no legitimate external consumers: - sendWithRetryStrategy, newRetryState, RetryState, and the bandwidth / retry constants are internal machinery of createHttpRequest; remove them from @datadog/js-core/transport - FlushController is the internal return type of createFlushController; callers that needed the type can use ReturnType<typeof createFlushController> - browser-core's dead sendWithRetryStrategy.ts re-export shim is deleted (nothing ever imported from it) - sendWithRetryStrategy.spec.ts moves from browser-core to js-core so it can use internal imports; a minimal test/ helper (registerCleanupTask, mockClock, mockNavigator) is added to js-core for this
BenoitZugmeyer
force-pushed
the
benoit/move-transport
branch
from
August 26, 2026 10:39
db9e0f1 to
4e48c7a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The
@datadog/js-corepackage is meant to hold runtime-agnostic SDK utilitiesshared across all Datadog JS SDKs. However, the entire batching transport stack
(
createBatch,createHttpRequest,createFlushController, and all theirdependencies) lived exclusively in
@datadog/browser-core, making itunavailable to non-browser consumers such as the Worker or future server-side
SDK targets.
This PR moves the complete transport stack into
@datadog/js-core, withbrowser-specific concerns (fetch, sendBeacon, DOM events) remaining in
browser-coreas injectable strategies.Changes
byteUtils,jsonStringify,context,objectValues,isServerError) moved to@datadog/js-core/util; browser-core re-exports.mockablemoved to@datadog/js-core/util.Observable,BufferedObservable,mergeObservables,queueMicrotaskmoved to
@datadog/js-core/util;queueMicrotaskdrops themonitor()wrapper (callers handle error wrapping at their own layer).
Encoder/createIdentityEncodermoved to@datadog/js-core/transport.timer/getZoneJsOriginalValuemoved to@datadog/js-core/util;js-core timer has no
monitor()wrapping; browser-core keeps monitored wrappers.sendWithRetryStrategyandPayloadtypes moved to@datadog/js-core/transport;navigator.onLineaccess goes throughglobalObject.flushControllermoved to@datadog/js-core/transport;PageExitReasonand
PageMayExitEventmove with it as pure types;pageMayExitObservableis injected as a parameter.
createHttpRequestmoved to@datadog/js-core/transportwith injectablesendStrategy/sendOnExitStrategy; browser-core keepsfetchStrategyandsendBeaconStrategyand wraps the js-core factory.createBatchmoved to@datadog/js-core/transport;requestandpageMayExitObservableare injected parameters;display.warnbecomes aninjected
warnfunction; browser-core wrapper preserves the existing callsignature for all current callers.
sendWithRetryStrategy,newRetryState,RetryState,internal constants,
createFlushController, andFlushControllerareremoved from js-core's public transport entry — they are internal details.
Their specs move to js-core alongside the implementation.
Test instructions
This is a pure refactor with no observable behaviour change. All existing unit
tests cover the moved code. To sanity-check the SDK still initialises and
sends data correctly:
yarn devand openhttp://localhost:8080.intake endpoints on the configured interval.
beforeunload/visibilitychange.Checklist