✨ add @datadog/js-core/sample sub-path with performDraw#4844
Open
thomas-lebeau wants to merge 2 commits into
Open
✨ add @datadog/js-core/sample sub-path with performDraw#4844thomas-lebeau wants to merge 2 commits into
thomas-lebeau wants to merge 2 commits into
Conversation
Introduces a new sample sub-path per the js-core RFC, containing performDraw, ported from browser-core's tools/utils/numberUtils.ts. Used by electron-sdk for telemetry sampling decisions. Wires up the new sub-path: package.json exports + physical sample/package.json fallback, tsconfig.base.json path mapping, and typedoc.json entry point, per packages/js-core/AGENTS.md.
Bundles Sizes Evolution
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: c2dd3f1 | Docs | Datadog PR Page | Give us feedback! |
Deletes performDraw from tools/utils/numberUtils.ts (round/isPercentage/ isNumber stay, they're not migrated) and points telemetry.ts and browser-core's own public re-export in index.ts at @datadog/js-core/sample instead. Adds '@datadog/js-core/sample' to the disallow-side-effects lint rule's allowlist, alongside the other side-effect-free js-core sub-paths. Removes the now-redundant performDraw test from numberUtils.spec.ts since it has identical coverage in js-core's own sample.spec.ts. Downstream packages are unaffected: performDraw was only consumed internally by browser-core; the public re-export keeps '@datadog/browser-core' backward compatible regardless.
gogusarov
approved these changes
Jul 9, 2026
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
Per the
@datadog/js-coreRFC,electron-sdkneedsperformDraw(used for telemetry sampling decisions), which requires a new@datadog/js-core/samplesub-path — previously there was nosampleentry at all.Changes
@datadog/js-core/sample, exportingperformDraw, ported verbatim frombrowser-core/tools/utils/numberUtils.ts(theround/isNumber/isPercentagehelpers in that same file were left out — not in scope).packages/js-core/AGENTS.md's "adding a new sub-path" checklist:package.jsonexportsfield + physicalsample/package.jsonfallback (legacy resolvers)tsconfig.base.jsonpath mappingtypedoc.jsonentry pointapi/sample.api.mdAPI Extractor golden file (auto-generated byyarn api:check --update)Pure additive change (brand new sub-path), no existing behavior changes.
Test instructions
yarn workspace @datadog/js-core build && yarn api:checkpasses.yarn typecheckpasses.yarn test:unit --spec 'packages/js-core/src/**/*.spec.ts'passes (61/61), including a newsample.spec.tsmirroring browser-core'sperformDrawtest coverage.Checklist