Skip to content

✨ add @datadog/js-core/sample sub-path with performDraw#4844

Open
thomas-lebeau wants to merge 2 commits into
mainfrom
worktree-js-core-sample-entry
Open

✨ add @datadog/js-core/sample sub-path with performDraw#4844
thomas-lebeau wants to merge 2 commits into
mainfrom
worktree-js-core-sample-entry

Conversation

@thomas-lebeau

Copy link
Copy Markdown
Collaborator

Motivation

Per the @datadog/js-core RFC, electron-sdk needs performDraw (used for telemetry sampling decisions), which requires a new @datadog/js-core/sample sub-path — previously there was no sample entry at all.

Changes

  • New sub-path @datadog/js-core/sample, exporting performDraw, ported verbatim from browser-core/tools/utils/numberUtils.ts (the round/isNumber/isPercentage helpers in that same file were left out — not in scope).
  • Wired up per packages/js-core/AGENTS.md's "adding a new sub-path" checklist:
    • package.json exports field + physical sample/package.json fallback (legacy resolvers)
    • tsconfig.base.json path mapping
    • typedoc.json entry point
    • api/sample.api.md API Extractor golden file (auto-generated by yarn api:check --update)

Pure additive change (brand new sub-path), no existing behavior changes.

Test instructions

  • yarn workspace @datadog/js-core build && yarn api:check passes.
  • yarn typecheck passes.
  • yarn test:unit --spec 'packages/js-core/src/**/*.spec.ts' passes (61/61), including a new sample.spec.ts mirroring browser-core's performDraw test coverage.

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

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.
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jul 3, 2026

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 172.76 KiB 172.59 KiB -176 B -0.10%
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 55.44 KiB 55.44 KiB +6 B +0.01%
Rum Slim 130.87 KiB 130.88 KiB +6 B +0.00%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jul 3, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

This comment will be updated automatically if new data arrives.
🔗 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.
@thomas-lebeau thomas-lebeau marked this pull request as ready for review July 8, 2026 12:27
@thomas-lebeau thomas-lebeau requested a review from a team as a code owner July 8, 2026 12:27
@sbarrio sbarrio requested a review from amortemousque July 9, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants