Files
stack/packages/template/src
mantrakp04 e6038897ae feat(analytics): dual-mode ambient parenting (exact/best-effort) + span handle kit
Browser withSpan frames can mix across concurrently interleaved async flows
(no async-context primitive exists there — the reason for TC39 AsyncContext).
Support BOTH policies via analytics.ambientParenting:

- "exact" (default): a frame is ambient only when provably from the current
  flow — an exact primitive (ALS on servers/edge; AsyncContext in browsers
  once shipped), or the callback's SYNCHRONOUS window on the browser fallback
  (single-threaded sync execution cannot interleave, so prologue-open frames
  are exact by construction). Never wrong; can only under-attach.
- "best-effort": frames also stay ambient across browser awaits (zero-glue),
  accepting the documented cross-flow caveat.

Handle kit on every Span (browser, server, inert) — exact everywhere, both
modes: span.withSpan (nested child), span.run (re-bind for callbacks/timers),
span.getPropagationHeaders (non-fetch transports), span.fetch (pinned
cross-tier header, same origin policy as the auto wrapper, explicit wins).

Internals: sync-stack frames carry a prologueOpen flag (set false the moment
the callback returns its promise); context entry runs synchronously once the
ALS probe settles so sync nesting composes; getAmbientSpanRefs gains an
includeSuspendedSyncFrames read policy; servers fail closed when ALS is
missing. Design validated by Codex (gpt-5.5 xhigh) + a 3-lens design panel.
2026-07-03 13:38:17 -07:00
..
2026-06-05 16:42:11 -07:00
2026-06-26 13:50:48 -07:00
2025-02-08 02:31:03 +01:00
2026-06-05 16:42:11 -07:00