Skip to content

[demo split #4449] 2/5 — Add @datadog/browser-debugger package#4533

Draft
allspain wants to merge 1 commit intoallspain/debug-5296-foundationfrom
allspain/debug-5296-package
Draft

[demo split #4449] 2/5 — Add @datadog/browser-debugger package#4533
allspain wants to merge 1 commit intoallspain/debug-5296-foundationfrom
allspain/debug-5296-package

Conversation

@allspain
Copy link
Copy Markdown
Collaborator

@allspain allspain commented Apr 28, 2026

DEMO — split of #4449. This is one of 5 stacked draft PRs that breaks
#4449 — Add Live Debugger package
into reviewable increments. Original PR is untouched. This stack is for
demonstrating tooling (jj split for the surgery, gh for the stack);
all of the underlying code is Thomas Watson's work and credited via
Co-authored-by: trailers.

Stack

  1. [demo split #4449] 1/5 — Foundation: expose core hooks for the live debugger package #4532 — Foundation — expose core hooks for the live debugger package (12 files / +56-10)
  2. [demo split #4449] 2/5 — Add @datadog/browser-debugger package #4533 — Package — add @datadog/browser-debugger (25 files / +6433) ← you are here
  3. [demo split #4449] 3/5 — Extend e2e framework for the debugger package #4534 — E2E framework — extend test framework for the debugger package (12 files / +129-8)
  4. [demo split #4449] 4/5 — Add debugger e2e scenarios #4535 — E2E scenarios — add debugger e2e scenarios (3 files / +318-2)
  5. [demo split #4449] 5/5 — Add instrumentation overhead benchmarks #4536 — Perf benchmarks — add instrumentation overhead benchmarks (12 files / +1222-9)

Each PR's base branch is the previous PR's head, so reviewing in order is
the intended path. Stack constructed with jj:
all 4 commits from #4449 were squashed into one change, then peeled into 5
with jj split <paths>, then pushed with jj git push.


What this PR contains (2/5 — Package)

The @datadog/browser-debugger package itself: the full probe execution
pipeline. Builds on the core changes from PR 1.

Changes

  • domain/api.ts — Core instrumentation hooks (onEntry, onReturn,
    onThrow) that execute probes when instrumented functions are called,
    including condition evaluation, snapshot capture, template message
    rendering, and rate limiting.
  • domain/activeEntries.ts — Tracks per-probe execution stacks for
    correlating entry/return/throw events.
  • domain/probes.ts — Probe lifecycle management (add, remove, clear)
    with per-probe and global snapshot rate limiting.
  • domain/capture.ts — Deep value capture for arguments, locals, return
    values, and thrown errors with configurable depth/size limits.
  • domain/expression.ts — Expression compiler that parses JSON
    expression trees into executable functions.
  • domain/condition.ts — Probe condition evaluator with caching.
  • domain/template.ts — Template segment compiler/evaluator for dynamic
    probe messages.
  • domain/stacktrace.ts — Stack trace capture from Error objects.
  • domain/deliveryApi.ts — Polling-based probe delivery client.
  • transport/startDebuggerBatch.ts — Reuses
    @datadog/browser-core's batch/flush infrastructure.
  • entries/main.ts — Public API surface (datadogDebugger.init()),
    exposes $dd_entry/$dd_return/$dd_throw/$dd_probes on globalThis.

Specs included for: api, capture, condition, deliveryApi,
expression, probes, stacktrace, template, entries/main.

25 files, +6433 / -0.

Tests

Unit tests run with yarn test:unit --spec "packages/debugger/src/**/*.spec.ts".

Original author: Thomas Watson <thomas.watson@datadoghq.com> (split of #4449)
Co-authored-by: Thomas Watson <thomas.watson@datadoghq.com>
@github-actions
Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


Rick Klein seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

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

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 71.76%
Overall Coverage: 76.68%

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

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.

1 participant