Repository navigation
feat(amp-semantic): add composable capture runtime - #2120
Merged
Merged
Conversation
1 task done
Session Replay Browser E2E ResultsDetails
Flaky testschromium › e2e/shadow-dom.spec.ts › captureAdoptedStyleSheets option › SDK initializes without error and captures shadow host with captureAdoptedStyleSheets=false |
size-limit report 📦
|
jxiwang
marked this pull request as ready for review
November 4, 2026 21:59
Collaborator
Author
|
bugbot run |
Register rollback cleanup before recorder setup so reentrant stop, reset, or config updates can tear down listeners registered during setup.
bravecod
approved these changes
Nov 5, 2026
Track attach generations so a nested resetSession or updateConfig during recorder setup does not leave the outer attach loop installing recorders again after the nested attach completes.
Skip registering the setup return cleanup when detach already ran during reentrant stop or reset, so the same function is not torn down twice.
When setup reenters resetSession or updateConfig and then throws, abort the stale outer attach loop so recorders are not installed twice.
Collaborator
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
2 issues from previous reviews remain unresolved.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit c1d9fe0. Configure here.
This was referenced Nov 11, 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.

Summary
Add the shared capture runtime on top of the merged package scaffold (#2113). No production event recorders are installed by default, and no SDK depends on this package yet.
The runtime provides typed recorder registration, opt-in sampling, per-session event caps, start/stop and reset, event identity/version/timestamp stamping, host snapshot signals, error isolation, and cleanup rollback. Its lazy identity fallback uses document-scoped memory only. Recorders explicitly acknowledge delivered dropped-event diagnostics. Failed transport releases its reserved cap slot, and each registered teardown runs once. The runtime has no context-specific behavior.
The recorder contract includes only capabilities used by the planned context and visibility recorders. Removed unused event subscriptions, snapshot-state inspection, and redundant capacity/enabled checks.
Stack
codex/semantic-context-recorder).codex/semantic-replay-integration).codex/semantic-visibility-recorder).The former combined implementation is preserved in commit ae9b929 (also retained on the local backup branch
codex/semantic-context-visibility-preserved). This branch incorporates current main, including the merged scaffold, without rewriting existing history.Validation
pnpm test:examplescannot start becausejest.setup.examples.jsis missing on main.Note
Medium Risk
The runtime adds non-trivial lifecycle, sampling, and reentrancy behavior that future recorders will rely on, but nothing in the monorepo consumes it yet and transport/consent stay with the host.
Overview
Replaces the envelope-only
@amplitude/amp-semanticscaffold with a composable browser capture runtime exposed ascreateSemanticCapture, while still shipping no default recorders and no Session Replay wiring.The host provides
document,window, and anemittransport; optional typed recorder factories register listeners only when enabled families pass session sampling and per-family caps (default 200). The runtime centralizes start/stop, config updates, session reset (new sample + counters),snapshothost signals, lazyv/timestamp/tab_id/document_idstamping (withgetDocumentIdentityfallback in memory),canEmit/dropped/clearDropped, and error-isolated teardown including rollback when setup or transport fails reentrantly.Public types grow to cover
SemanticHost,SemanticRecorder, andRecorderContext; README and Jest switch to jsdom-backed lifecycle tests (~23 cases). Follow-up PRs are expected to add concrete recorders and replay integration.Reviewed by Cursor Bugbot for commit c1d9fe0. Bugbot is set up for automated code reviews on this repo. Configure here.