Skip to content

Define read-only Standard Event evidence - #4311

Open
Ji-One1 wants to merge 2 commits into
jb/storefront-e2e-v2-03-catalogfrom
jb/storefront-e2e-v2-04-standard-events
Open

Ji-One1 wants to merge 2 commits into
jb/storefront-e2e-v2-03-catalogfrom
jb/storefront-e2e-v2-04-standard-events

Conversation

@Ji-One1

@Ji-One1 Ji-One1 commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Selected Shopify Standard Events can explain an add attempt or rejection without treating an event's cart data as the current cart. This PR defines the read-only event script and its evidence format.

What this changes

  • Listen in the capture phase on document for an explicit selection from the supported-event list. Record document and element events once, including non-bubbling element events; ignore events dispatched directly on window. An empty selection records nothing.
  • Re-arm document listeners without duplicates, including after document.open() and same-origin popup document replacement in a reused JavaScript realm. Observe event.promise without dispatching events or changing storefront state.
  • Use focused Zod schemas and safeParse for event headers and retained phase fields. Parse input, settled, failed, and unsettled records; reject malformed messages and messages longer than 65,536 JavaScript string code units.
  • Save payload fields only for shopify:cart:lines-update input action, context, and line IDs, merchandise IDs, and quantities; its settled cart userErrors; and shopify:cart:error input code and error. Other supported events keep headers and phase metadata only. Failed promises retain error name/message; unsettled records retain their reason. Standard Event evidence saves no cart IDs or other cart fields.
  • Truncate retained strings and arrays rather than rejecting them only for length. Provide an unsettled record for an awaited event whose outcome was not received.
  • Add Chrome regression tests for document/element capture, direct-window exclusion, duplicate prevention, document.open(), and same-realm popup replacement.

Developer impact

Internal tooling only; no published Hydrogen exports change and no changeset is needed. Browser installation over CDP is separate from this script and parser.

Out of scope

No Hydrogen analytics capture, automatic capture of every event, cart reader, or verdict logic.

Risk

Truncated fields and omitted payloads can remove diagnostic detail. Saved line IDs, error messages, and other retained values remain private owner data; bounds and field selection are not secret redaction. Events on a reused document can be missed before its listeners are re-armed.

Stack: 04/15. Previous: #4310. Next: #4313.

@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-03-catalog branch from 2701341 to a2b35e6 Compare November 5, 2026 16:23
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-04-standard-events branch 2 times, most recently from 49c7b24 to 67d149e Compare November 5, 2026 18:42
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-03-catalog branch 2 times, most recently from 5a25aae to c23831a Compare November 6, 2026 00:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-04-standard-events branch 2 times, most recently from 5e33d61 to 3d68c1c Compare November 6, 2026 01:36
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-03-catalog branch from 0207c88 to c3a8c33 Compare November 6, 2026 01:45
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-04-standard-events branch from 3d68c1c to 9160988 Compare November 6, 2026 01:45
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-03-catalog branch from c3a8c33 to 7cfe512 Compare November 6, 2026 14:27
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-04-standard-events branch from 9160988 to 159401b Compare November 6, 2026 14:27
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-03-catalog branch from 7cfe512 to f995e73 Compare November 6, 2026 15:08
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-04-standard-events branch from 159401b to 2d1d3dc Compare November 6, 2026 15:08
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-03-catalog branch from f995e73 to cdc2c89 Compare November 6, 2026 16:20
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-04-standard-events branch from 2d1d3dc to 3cefe90 Compare November 6, 2026 16:20
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-03-catalog branch from cdc2c89 to 7f27156 Compare November 6, 2026 19:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-04-standard-events branch from 3cefe90 to 72f8e98 Compare November 6, 2026 19:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-03-catalog branch from 7f27156 to e7c0bcd Compare November 6, 2026 20:32
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-04-standard-events branch 2 times, most recently from 04de19b to 961f2fb Compare November 9, 2026 00:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-03-catalog branch 2 times, most recently from 5aaf2af to b205d96 Compare November 9, 2026 00:37
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-04-standard-events branch 2 times, most recently from 2c0dc91 to 949c6cb Compare November 9, 2026 04:23
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-04-standard-events branch from 949c6cb to d5aa3fe Compare November 9, 2026 06:55
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-03-catalog branch from 961a217 to bc2e072 Compare November 9, 2026 06:55
@Ji-One1
Ji-One1 marked this pull request as ready for review November 9, 2026 06:56
@Ji-One1
Ji-One1 requested a review from a team as a code owner November 9, 2026 06:56
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

We detected some changes in packages/*/package.json or packages/*/src, and there are no updates in the .changeset.
If the changes are user-facing and should cause a version bump, run pnpm run changeset add to track your changes and include them in the next release CHANGELOG.
If you are making simple updates to examples or documentation, you do not need to add a changeset.

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