Repository navigation
Conversation
Ji-One1
marked this pull request as ready for review
November 17, 2026 19:15
This was referenced Nov 17, 2026
Ji-One1
marked this pull request as draft
November 18, 2026 06:18
Ji-One1
force-pushed
the
jb/hydrogen-product-view-event
branch
from
November 18, 2026 16:21
51c0a2b to
bccc8da
Compare
Ji-One1
force-pushed
the
jb/hydrogen-collection-view-event
branch
4 times, most recently
from
November 19, 2026 20:53
7c4a388 to
3b6b749
Compare
Ji-One1
force-pushed
the
jb/hydrogen-product-view-event
branch
from
November 19, 2026 21:04
15d022f to
e41554b
Compare
Ji-One1
force-pushed
the
jb/hydrogen-collection-view-event
branch
from
November 19, 2026 21:04
3b6b749 to
818bcb5
Compare
Ji-One1
changed the base branch from
jb/hydrogen-product-view-event
to
jb/hydrogen-product-view-apps
November 19, 2026 22:26
Ji-One1
force-pushed
the
jb/hydrogen-collection-view-event
branch
from
November 19, 2026 22:27
818bcb5 to
449faec
Compare
This was referenced Nov 19, 2026
Ji-One1
marked this pull request as ready for review
November 20, 2026 05:41
CollectionView (React, Vue) renders the shopify-collection-view element, registered via defineViewEventElement(). The element sends shopify:collection:view from itself when the collection page connects, and again when collection.handle in view-event-payload changes. Filter, sort, pagination, and productsCount changes don't re-send it. The Storefront API has no product total for a collection, so the storefront passes productsCount (the number of products loaded on the page). collection.id is required (string | null) so queries missing id fail typechecking. ShopifyScripts and initializeShopifyScripts register the element. Frameworks without a binding use COLLECTION_VIEW_TAG_NAME and getCollectionViewAttributes.
Ji-One1
force-pushed
the
jb/hydrogen-product-view-apps
branch
from
November 20, 2026 06:24
d8bc01a to
d2fbef4
Compare
Ji-One1
force-pushed
the
jb/hydrogen-collection-view-event
branch
from
November 20, 2026 06:24
449faec to
1b06680
Compare
This branch has not been deployed
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.
Stacked on #4403. Refs Shopify/developer-tools-team#1285
Part 3 of 4. This PR adds the package API only. The template and examples use it in the next PR (#4404).
TL;DR: Adds
CollectionView, a component that sends theshopify:collection:viewStandard Event when a collection page shows. It works likeProductViewfrom #4376: it usescreateViewEventElementfrom the Standard Events module, and the storefront places it explicitly.Before
Hydrogen has no way to send a collection view event.
After
The element sends:
What this changes
CollectionView(React and Vue) renders ashopify-collection-viewelement, registered withdefineViewEventElement()from feat(hydrogen): add ProductView for the shopify:product:view event #4376. The element sends the event from itself when it appears, and the event bubbles todocument.createViewEventElement()class (the same helper as the product view element). It sends the event again when the collection handle inview-event-payloadchanges, for example on in-app navigation to another collection. The React and VueCollectionViewcomponents only render the element. Filter, sort, and "load more" changes don't send it. Those belong toshopify:collection:update, which is not in this PR.ShopifyScriptsandinitializeShopifyScripts()register the element, next to the product view element.collection.idis required (string | null), so a query that forgetsidfails typechecking. Passid: nullfor a page without a collection record, such as an all-products page.COLLECTION_VIEW_TAG_NAMEwith the attributes fromgetCollectionViewAttributes().CollectionViewmapsclassNameto the custom element'sclassattribute, so grid and block classes work in React 18 as well as React 19.CollectionView.Developer impact
Includes a minor changeset for
@shopify/hydrogen. New exports:@shopify/hydrogen/reactand@shopify/hydrogen/vue:CollectionView,CollectionViewProps.@shopify/hydrogen:COLLECTION_VIEW_TAG_NAME,getCollectionViewAttributes,defineCollectionView,CollectionViewOptions.Hydrogen doesn't send the event on its own. Storefronts add
CollectionViewto their collection page.productsCountis the number of products that the page loaded, not the collection total. The Storefront API has no direct product count onCollectionorcollection.products. The storefront passes the loaded count explicitly, so Hydrogen doesn't guess. We asked the Standard Events owners whetherproductsCountcan be optional, or what headless storefronts should send.Why we don't sum availability filter counts
We considered adding the in-stock and out-of-stock filter counts to get the collection total, but read-only Storefront API
2026-10queries onhydrogen-preview.myshopify.com, collectionbackcountry, disproved that approach:binding mount=NestedWe checked all product pages and both availability groups. Five products appeared in both groups, so adding the counts double-counted them. The other filter also changed the counts. Using an unfiltered query would not fix the overlap. The individual availability counts matched their query results; the sum was not a unique product total. So we don't recommend that shortcut and keep the loaded-product count instead.
Out of scope
CollectionViewto the React Router template and examples (feat(templates): send collection view events in the template and examples #4404).shopify:collection:update(filters, sort, pagination).Risk
productsCountis lower than the real total for any collection with more than one page.CollectionViewmapsclassNametoclassexplicitly so React 18 keeps CSS classes, but it was not run under a React 18 runtime.How to Test
This PR has no storefront wiring. To try it in a browser, check out the next PR (#4404) and follow its steps.