Skip to content

✨ Add @datadog/browser-sdk-endpoint package and CDN bundle generator CLI#4241

Closed
mormubis wants to merge 1 commit into
adlrb/ssi-remote-configfrom
adlrb/ssi-endpoint-pkg
Closed

✨ Add @datadog/browser-sdk-endpoint package and CDN bundle generator CLI#4241
mormubis wants to merge 1 commit into
adlrb/ssi-remote-configfrom
adlrb/ssi-endpoint-pkg

Conversation

@mormubis
Copy link
Copy Markdown
Contributor

Motivation

Build tools (webpack, Vite, Node.js scripts) need a programmatic API to generate CDN bundles with embedded remote configuration. This PR adds that API as a published Node.js package, plus a CLI wrapper.

Changes

New package: @datadog/browser-sdk-endpoint

  • generateBundle(options) — high-level async function with full input validation
  • fetchConfig(options) — fetches remote config (delegates to @datadog/browser-remote-config)
  • downloadSDK(options) — downloads SDK from Datadog CDN with in-memory caching (keyed by variant+datacenter; avoids re-fetching during watch mode)
  • generateCombinedBundle(options) — low-level combinator: wraps SDK + config in an IIFE
  • clearSdkCache() — test utility

CLI: scripts/build/generate-cdn-bundle.ts

generate-cdn-bundle --applicationId <id> --configId <id> --variant rum|rum-slim [--output file]

Infrastructure

  • Excluded from Karma browser test runner (Node.js-only package)
  • ESLint configured to disable browser-specific rules for Node.js files
  • tsconfig.base.json path alias for @datadog/browser-sdk-endpoint

Testing

yarn test:script
yarn typecheck

Part of SSI Phase 6 stacked PRs. Stacks on: ✨ @datadog/browser-remote-config (#4239). Next: E2E tests.

@cit-pr-commenter-54b7da
Copy link
Copy Markdown

cit-pr-commenter-54b7da Bot commented Feb 25, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum N/A 172.30 KiB N/A N/A N/A
Rum Profiler N/A 4.71 KiB N/A N/A N/A
Rum Recorder N/A 24.88 KiB N/A N/A N/A
Logs N/A 56.30 KiB N/A N/A N/A
Flagging N/A 944 B N/A N/A N/A
Rum Slim N/A 128.07 KiB N/A N/A N/A
Worker N/A 23.63 KiB N/A N/A N/A
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
addglobalcontext N/A 0.0041 N/A
addaction N/A 0.0177 N/A
adderror N/A 0.0148 N/A
addtiming N/A 0.0033 N/A
startview N/A 0.0159 N/A
startstopsessionreplayrecording N/A 0.0007 N/A
logmessage N/A 0.0164 N/A
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
addglobalcontext N/A 26.20 KiB N/A
addaction N/A 113.50 KiB N/A
addtiming N/A 26.27 KiB N/A
adderror N/A 119.99 KiB N/A
startstopsessionreplayrecording N/A 25.85 KiB N/A
startview N/A 503.16 KiB N/A
logmessage N/A 45.41 KiB N/A

🔗 RealWorld

@datadog-datadog-prod-us1-2
Copy link
Copy Markdown

datadog-datadog-prod-us1-2 Bot commented Feb 25, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

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

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 5e90dd5 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

Introduces two artifacts for build-time SDK bundle generation:

### @datadog/browser-sdk-endpoint (Node.js package)
- generateBundle(options) — high-level orchestrator: fetch config → download SDK → combine
- fetchConfig(options) — wraps fetchRemoteConfiguration with 30s AbortSignal timeout
- downloadSDK(options) — downloads SDK from Datadog CDN; in-memory cache keyed by
  variant+datacenter for watch mode (<5ms cache hit vs ~500ms network)
- generateCombinedBundle(options) — low-level: combine SDK text + config into IIFE bundle
- clearSdkCache() — test utility to reset the cache

### CLI: scripts/build/generate-cdn-bundle.ts
Entry point for the generate-cdn-bundle script. Accepts --applicationId,
--configId, --variant flags; outputs bundle to file or stdout.
@mormubis mormubis force-pushed the adlrb/ssi-endpoint-pkg branch from ae5fb37 to 5e90dd5 Compare March 3, 2026 16:45
@mormubis mormubis closed this Mar 13, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 13, 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.

1 participant