Repository navigation
feat(amp-semantic): add context recorder - #2126
Merged
Merged
Conversation
…context-visibility-events
This was referenced Nov 4, 2026
size-limit report 📦
|
Base automatically changed from
codex/semantic-context-visibility-events
to
main
November 5, 2026 21:51
jxiwang
marked this pull request as ready for review
November 6, 2026 01:13
Collaborator
Author
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0fbe740. Configure here.
bravecod
approved these changes
Nov 6, 2026
Resolve conflict in packages/amp-semantic/package.json: keep main 0.2.0 description and merge PR additions (schema.json in files, ajv, session-replay-dom-privacy dependency).
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
amp-semantic/contexton top of the capture runtime in #2120. The recorder emits after a host-provided accepted full-snapshot signal, and reads SDK/privacy configuration, the effective mask level for the snapshot URL (including URL overrides), stylesheet counts, viewport, device heuristic, language, user agent, visibility/focus snapshots, analytics configuration, and dropped-event diagnostics.This PR includes the context payload, wire schema, recorder tests, and documentation. It does not add Session Replay configuration, transport, or visibility listeners. The host must supply privacy settings and snapshot notifications. Context skips payload reads after its event budget and acknowledges dropped counts only after successful delivery. The shared runtime releases cap slots after failed transport, deduplicates cleanup callbacks, and preserves the reentrant setup fix merged in #2120.
Stack
Base:
mainafter #2120 merged. Session Replay wiring follows in #2127, then visibility in #2128.Validation
Node 24: install, full workspace build, package typecheck, docs, lint, dependency checks, and workspace tests passed. The semantic package has 39 passing tests with 100% coverage in all four metrics. A regression test covers matching URL mask overrides and fallback to the default level.
Existing blocker retained with prior maintainer approval:
pnpm test:examplescannot start becausejest.setup.examples.jsis absent on main.Note
Medium Risk
Expands what the runtime reads from the page (stylesheets, UA, privacy-derived mask) and breaks host typings by requiring new fields; privacy-adjacent but no transport/auth changes.
Overview
createSemanticCapturenow wires the context family by default viadefaultRecordersand fixed per-family caps (SEMANTIC_CAPS), so snapshot notifications produceamp-semantic/contextunless callers pass a different recorder list. Low-levelcreateCapturestays explicit for tests and extensions.Hosts must supply
sdk,getPrivacy, and optionalgetAnalyticsContext/inlineStylesheet. Types and fixtures reflect that. The newcontextRecorderlistens forsnapshot, respects caps (canEmit), aggregates stylesheet stats (with cross-origin handling), effective mask from@amplitude/session-replay-dom-privacy, viewport, device heuristic, visibility/focus, UA, analytics SDK metadata, and optionalcaps_hit; it clears dropped diagnostics only after a successful emit.Published artifacts include
schema.json(rrweb custom-event shape for context),ajv-backed tests validate wired payloads, and README documents behavior and budgets. Lockfile andpackage.jsonadd the privacy workspace dep and devajv.Reviewed by Cursor Bugbot for commit 63198de. Bugbot is set up for automated code reviews on this repo. Configure here.