Skip to content

feat(amp-semantic): add visibility recorder - #2128

Open
jxiwang wants to merge 34 commits into
mainfrom
codex/semantic-visibility-recorder
Open

jxiwang wants to merge 34 commits into
mainfrom
codex/semantic-visibility-recorder

Conversation

@jxiwang

@jxiwang jxiwang commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Add amp-semantic/visibility to the established capture runtime and Session Replay integration. The recorder emits deduplicated hidden/visible transitions, includes runtime-provided version and identity, and removes its listener on stop. Focus/blur alone do not emit events; context already supplies the initial visibility state.

Include the visibility payload/schema, default registration and budget, listener cleanup tests, playground description, and Chromium tests of visibility delivery and timestamp ordering. Native tab scheduling remains browser-dependent; browser tests use deterministic visibility notifications.

Capture uses the locally supplied semanticCapture.createCapture: createSemanticCapture callback introduced in #2127. The base Session Replay SDK has no production dependency on amp-semantic. Adding visibility leaves the base Session Replay bundle at 142.78 kB gzip within its limit.

Stack

Base: #2127 (codex/semantic-replay-integration). Merge runtime, context, and Session Replay integration first, then retarget this PR to main.

Validation

Node 24: install, full workspace build, docs, lint, dependency checks, typecheck, and tests across all 32 workspace projects passed. Seven Chromium transport tests and existing bundle-size limits passed. Session Replay is 142.78 kB gzip and unified is about 231 kB gzip; source maps contain no amp-semantic modules. Semantic and affected Session Replay packages retain 100% coverage.

Existing blocker retained with prior maintainer approval: pnpm test:examples cannot start because jest.setup.examples.js is absent on main.


Note

Low Risk
Additive recorder and schema behind existing opt-in semantic capture; changes are covered by unit, schema, and Playwright tests with no auth or sensitive data handling changes.

Overview
Adds a visibility semantic event family alongside context, wired through createSemanticCapture defaults, schema, and Session Replay transport.

The new visibilityRecorder listens for deduplicated document.visibilitychange transitions (hidden / visible), ignores focus/blur-only signals, tears down on stop, and emits runtime-stamped amp-semantic/visibility custom events with the same per-session budget as context. defaultRecorders, SEMANTIC_CAPS, and payload types now include visibility; schema.json validates the new tag and tracks visibility in caps_hit.

Playwright replay tests, unit tests, the local semantic harness, README, and joined-config coverage are updated so both families can be gated remotely/locally and visibility shows up in end-to-end delivery checks.

Reviewed by Cursor Bugbot for commit 823c6a8. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
packages/analytics-browser/lib/scripts/amplitude-min.js.gz 68.41 KB (0%)
packages/session-replay-browser/lib/scripts/session-replay-browser-min.js.gz 140.38 KB (0%)
packages/unified/lib/scripts/amplitude-min.umd.js.gz 226.82 KB (0%)
@amplitude/element-selector (gzipped esm) 3.48 KB (0%)
@amplitude/analytics-browser/lite (gzipped CDN bundle) 21.34 KB (0%)

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Session Replay Browser E2E Results

passed  158 passed
flaky  1 flaky

Details

stats  159 tests across 18 suites
duration  4 minutes, 10 seconds
commit  823c6a8

Flaky tests

chromium › e2e/shadow-dom.spec.ts › captureAdoptedStyleSheets option › SDK initializes without error and captures shadow host with default (true)

@jxiwang
jxiwang marked this pull request as ready for review November 10, 2026 17:15
@jxiwang
jxiwang requested review from a team as code owners November 10, 2026 17:15
@jxiwang

jxiwang commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 5b99f6f. Configure here.

@linear-code

linear-code Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

SRAI-129

Base automatically changed from codex/semantic-replay-integration to main November 10, 2026 21:00
…lity-recorder

# Conflicts:
#	packages/amp-semantic/README.md
#	packages/amp-semantic/e2e/replay.spec.ts
#	packages/session-replay-browser/test/config/joined-config.test.ts
#	test-server/session-replay-browser/sr-semantic-test.html
#	test-server/session-replay-browser/sr-semantic-test.js

This branch has not been deployed

No deployments
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