Skip to content

feat(amp-semantic): capture resource load failures - #2155

Open
jxiwang wants to merge 26 commits into
codex/semantic-keysfrom
codex/semantic-resource-errors
Open

jxiwang wants to merge 26 commits into
codex/semantic-keysfrom
codex/semantic-resource-errors

Conversation

@jxiwang

@jxiwang jxiwang commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add amp-semantic/resource-error for failed image, stylesheet, script, and font loads, grouped over 500 ms with a compact count.
  • Keep only sanitized paths and privacy-safe containers, rechecking masking and node attachment at emission. Flush pending groups on pagehide and hidden.
  • Add schema, docs, local inspector description, unit tests, and a real failed-image browser replay test. Supersedes the resource portion of older draft feat(session-replay): integrate semantic lifecycle capture #2080.

Stack

Base: #2154. Merge after #2128 and #2150–#2154.

Validation

  • pnpm --filter @amplitude/amp-semantic... build
  • pnpm --filter @amplitude/session-replay-browser... build
  • pnpm --filter @amplitude/amp-semantic test: 149 passed, 100% coverage
  • pnpm --filter @amplitude/session-replay-browser test: 1,183 passed, 100% coverage
  • pnpm --filter @amplitude/amp-semantic test:playwright: 13 passed
  • pnpm lint, pnpm lint:deps, pnpm test:examples

The full workspace build stalls in the unchanged Segment Session Replay Rollup step, and the full workspace test run has two existing analytics-react-native failures, as documented in earlier stack drafts.

Linear: SRAI-82.


Note

Medium Risk
Introduces new global DOM/font listeners and URL path templating at emission time; behavior is bounded and privacy-conscious but affects every opted-in replay session.

Overview
Adds a new amp-semantic/resource-error semantic family that records failed image, stylesheet, script, and font loads without patching the network or scanning the DOM.

A resourceErrorRecorder listens for capture-phase error on img/script/stylesheet link elements and document.fonts loadingerror, batches matching failures for 500 ms (with flush on pagehide / hidden), and emits compact payloads: resource type rt, count, and optional sanitized path (no origin/query) plus privacy-safe container when the element is still connected and not blocked. It is wired into defaultRecorders and SEMANTIC_CAPS (200/session), with families: { 'resource-error': false } to opt out.

Schema, README, local inspector copy, broad unit tests, and a Playwright failed-image replay test complete the surface; capture-gate e2e now includes resource-error in the disabled-families list.

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

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

size-limit report 📦

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

@jxiwang
jxiwang marked this pull request as ready for review November 11, 2026 21:16
@jxiwang
jxiwang requested review from a team as code owners November 11, 2026 21:16
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Session Replay Browser E2E Results

passed  179 passed
flaky  1 flaky

Details

stats  180 tests across 20 suites
duration  7 minutes, 3 seconds
commit  cca2b5b

Flaky tests

chromium › e2e/shadow-dom.spec.ts › captureAdoptedStyleSheets option › SDK initializes without error and captures shadow host with captureAdoptedStyleSheets=false

@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.

Stale Bugbot comment from a previous run.

Comment thread packages/amp-semantic/schema.json Resolved

@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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ 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 b0e7cc0. Configure here.

Comment thread packages/amp-semantic/schema.json Resolved

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