Skip to content

♻️ move endpointBuilder and its dependencies to @datadog/js-core - #4824

Merged
BenoitZugmeyer merged 6 commits into
mainfrom
benoit/move-globalobject-endpointbuilder-to-js-core
Jun 29, 2026
Merged

♻️ move endpointBuilder and its dependencies to @datadog/js-core#4824
BenoitZugmeyer merged 6 commits into
mainfrom
benoit/move-globalobject-endpointbuilder-to-js-core

Conversation

@BenoitZugmeyer

@BenoitZugmeyer BenoitZugmeyer commented Jun 26, 2026

Copy link
Copy Markdown
Member

Motivation

endpointBuilder is used by openfeature-js-client, which currently has to depend on @datadog/browser-core just to access it. Moving endpointBuilder, intakeSites, globalObject, and urlPolyfill to @datadog/js-core — the cross-environment package shared across SDK targets — is another step toward removing the browser-core dependency from openfeature-js-client.

Changes

  • move globalObject and urlPolyfill to @datadog/js-core/util: consolidate the GlobalObject type into js-core (including the browser API type definitions previously in browser.types.ts), make all browser-specific properties optional for cross-environment correctness, and update all consumers to import directly from @datadog/js-core/util
  • move endpointBuilder and intakeSites to @datadog/js-core/transport: move the endpoint building logic and intake site constants, update all consumers across the monorepo to import from @datadog/js-core/transport
  • clarify and document js-core transport public API: rename ambiguous types with their context prefix (ApiTypeTransportApiType, RetryInfoTransportRetryInfo, EffectiveTypeNetworkEffectiveType), convert EndpointBuilder to an explicit interface, and add JSDoc to all public exports in @datadog/js-core

Test instructions

These are internal refactoring changes with no user-visible behaviour change. Verify that the SDK initialises and sends events normally by opening the sandbox at http://localhost:8080 after running yarn dev.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@BenoitZugmeyer BenoitZugmeyer changed the title ♻️ move globalObject, urlPolyfill, endpointBuilder, and intakeSites to @datadog/js-core ♻️ move endpointBuilder and its dependencies to @datadog/js-core Jun 26, 2026
@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 172.75 KiB 172.61 KiB -141 B -0.08%
Rum Profiler 8.22 KiB 8.22 KiB 0 B 0.00%
Rum Recorder 21.14 KiB 21.14 KiB 0 B 0.00%
Logs 54.44 KiB 54.58 KiB +146 B +0.26%
Rum Slim 130.27 KiB 130.44 KiB +174 B +0.13%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Jun 26, 2026

Copy link
Copy Markdown

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

DataDog/browser-sdk | check-node-version   View in Datadog   GitLab

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 77.20% (+0.00%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 6ff7394 | Docs | Datadog PR Page | Give us feedback!

Both modules had no browser-specific dependencies, making them
good candidates for the cross-environment js-core package.
All consumers across the monorepo now import directly from
@datadog/js-core/transport instead of going through browser-core.
Rename ambiguous types with their context prefix (`ApiType` →
`TransportApiType`, `RetryInfo` → `TransportRetryInfo`, `EffectiveType`
→ `NetworkEffectiveType`), convert `EndpointBuilder` from an inferred
return type to an explicit interface, and add JSDoc to all public
exports in `@datadog/js-core`.
@BenoitZugmeyer
BenoitZugmeyer force-pushed the benoit/move-globalobject-endpointbuilder-to-js-core branch from 79ea456 to d18b1dc Compare June 26, 2026 13:43
@BenoitZugmeyer
BenoitZugmeyer marked this pull request as ready for review June 26, 2026 14:02
@BenoitZugmeyer
BenoitZugmeyer requested review from a team as code owners June 26, 2026 14:02

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

`dd-evp-origin-version=${encodeURIComponent(__BUILD_ENV__SDK_VERSION__)}`,

P2 Badge Pass the SDK version into the endpoint builder

Because browser packages now import this builder from the separately versioned @datadog/js-core package at runtime (for example packages/browser-logs/src/transport/startLogsBatch.ts:3), this build-time constant is fixed when js-core is published, not when each Browser SDK package is released. On any Browser SDK release where js-core is not republished, intake URLs will keep sending the previous dd-evp-origin-version, corrupting SDK-version attribution for logs/RUM/replay. Pass the Browser SDK version into the builder from the browser package instead of baking it in js-core.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"require": "./cjs/entries/util.js",
"types": "./cjs/entries/util.d.ts"
},
"./transport": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bump js-core before exporting transport

Adding this public subpath (and the new util exports used by the browser packages) while keeping @datadog/js-core at 0.0.4 leaves released Browser SDK packages depending on a js-core version that may already exist without those files. In the release workflow, scripts/deploy/publish-npm.ts:33 uses npm publish --tolerate-republish; Yarn help says that flag will warn and exit for an existing version, so js-core can be skipped while consumers get browser packages importing @datadog/js-core/transport/new util exports that are absent. Please bump @datadog/js-core and the dependent pins with this API move.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We'll bump on next release.

Comment on lines +29 to +30
/** Not available in workers or SSR environments. https://developer.mozilla.org/en-US/docs/Web/API/Window */
window?: Window

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid DOM-only names in js-core util types

For Node TypeScript consumers of @datadog/js-core/util that use @types/node without the DOM lib, this exported declaration makes the package fail to typecheck because names such as Window (and the event-listener DOM types below) are not defined. I reproduced this with a minimal lib: ["ES2020"], types: ["node"] project importing @datadog/js-core/util. Since js-core is documented as runtime-agnostic, use local structural types or avoid exporting DOM-only names from its public declarations.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Mmhmh, right. I'll see what I can do, but people should probably use skipLibCheck in any case.

@gogusarov

Copy link
Copy Markdown
Contributor

by the way do you plan to update AGENTS.md only when the full migration is done?

right now the paths in it are out of sync and refer to folders that do not exist anymore
image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sad that we lose the history :(

collectViewEntry(lastViewEntry)

// Add event handler case we overflow the buffer
// eslint-disable-next-line local-rules/disallow-zone-js-patched-values -- FIXME use the `addEventListener` helper

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💭 thought: ‏We could improve the types if the globalObject is reexported in browser-core with the right types. Similar to what happens in the getConnection

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This lint didn't trigger before because the addEventListener was defined in a random file and it wasn't considered as a "native function" because of this (only lib.dom.d.ts and globalObject.ts are considered native). Now that it's in a globalObject.ts file, the lint triggers correctly.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6ff7394969

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 75 to 77
export function createEndpointBuilder(
configuration: EndpointBuilderConfiguration,
trackType: TrackType,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Export the transport builder option types

The new public subpath exposes createEndpointBuilder, but its signature names EndpointBuilderConfiguration, which remains private to endpointBuilder.ts and is not re-exported from src/entries/transport.ts; the same pattern is used by createReplicaEndpointBuilder with ConfigurationWithReplica. This leaves the generated public API report referring to option types that consumers cannot import or inspect in the subpath docs, making the new js-core API hard to use directly. Please export and document these configuration interfaces, or use already-exported option types in the public signatures.

Useful? React with 👍 / 👎.

Comment on lines +27 to 31
"./transport": {
"import": "./esm/entries/transport.mjs",
"require": "./cjs/entries/transport.js",
"types": "./cjs/entries/transport.d.ts"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include the transport subpath in TypeDoc

Adding ./transport here makes @datadog/js-core/transport a public subpath, but packages/js-core/typedoc.json still lists only time, monitor, util, and assembly; the js-core AGENTS instructions require every new subpath entry file to be added there. As a result, the generated js-core documentation will omit createEndpointBuilder, buildEndpointUrl, and the related transport types even though they are now public APIs.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Too late for reviews. I am trying to make CI pass and merge. I'll tackle this in a follow-up

@BenoitZugmeyer
BenoitZugmeyer merged commit ec19de9 into main Jun 29, 2026
30 of 31 checks passed
@BenoitZugmeyer
BenoitZugmeyer deleted the benoit/move-globalobject-endpointbuilder-to-js-core branch June 29, 2026 15:14
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants