`shopify:page:view` fires when `history.replaceState` changes only the query, as a variant selection does
I maintainer di solito rispondono entro 3 giorni
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 53/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- react, typescript
Direzione di ricerca
Start with packages/hydrogen/src/core/shopify-scripts/page-view.test.ts and compare its existing navigation tests with the provided query-only replaceState reproduction. Then read packages/hydrogen/src/core/shopify-scripts/page-view.ts and utils/navigation.ts to trace both observer paths. First determine the intended behavior from the conflicting docs and recipes; done means the behavior is documented and covered by tests for the relevant navigation cases.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What is the location of your example repository?
None. The test below reproduces it in page-view.test.ts.
Which package or tool is having this issue?
Hydrogen
What version of that package or tool are you using?
2026.10.3
What version of React Router 7 are you using?
Not applicable: the core entry's initializeShopifyScripts.
Steps to Reproduce
- On a page that has called
initializeShopifyScripts(), listen for the standard event:document.addEventListener('shopify:page:view', (event) => console.log(event.page.url)); - Write a selected option into the URL in place, as a product form does for a variant selection:
history.replaceState(history.state, '', '?Size=m');
As a test beside the others in packages/hydrogen/src/core/shopify-scripts/page-view.test.ts:
it("ignores a query replaced in place", async () => {
initialize();
await flushPageViews();
pageViews.length = 0;
window.history.replaceState({}, "", "/?Size=m");
await flushPageViews();
expect(pageViews).toHaveLength(0);
});
Expected Behavior
No page view, since the buyer is still on the same page. #3917 describes one shopify:page:view for the initial page and one for each SPA navigation, and #4376 notes that variant changes belong to shopify:product:select.
Actual Behavior
A shopify:page:view for ?Size=m on the next animation frame, in both of the observer's paths:
- With the Navigation API, the observer listens to
currententrychange, whichhistory.replaceStatefires too (navigation.tsL17–L22). - Without it, the observer patches
history.replaceState(L24–L25).
Either way, page-view.ts counts any change of the path or the query (L48–L60). The existing tests cover a push, a currententrychange, and changes to the state or the hash only. None covers a query replaced in place.
So a product page that writes its selected variant into a bare URL after initializeShopifyScripts has run sends two page views for one visit, and one more for each selection after that. Tools that read Standard Events, such as PerfKit (#4376), see each of them as a new page.
Hydrogen's skills count a selection the same way in their React Router and Next.js recipes. There, PAGE_VIEWED is keyed by the path and the query, and the variant form writes the selection with a router replace. But the analytics skill's framework-neutral rule publishes PAGE_VIEWED "on each page transition".
This may be intended: the initializeShopifyScripts docs say it "sends a page view event on load and after each navigation that changes the path or query", and the Navigation API reports history.replaceState as a replace navigation. Possible directions, depending on the intended semantics:
- Skip a replacement that keeps the path, which is how storefronts write UI state into the URL, and key the recipes'
PAGE_VIEWEDthe same way. Keep counting pushes, traversals and replacements to another path, such as a redirect. - Let the storefront decide: an option to
initializeShopifyScriptsthat turns off the automatic event, and a function that dispatches it from the same route boundary that publishesPAGE_VIEWED. - If every change of the path or the query should count, say so in the docs and in the analytics skill's framework-neutral rule.
- Lingua principale
- TypeScript
- Stelle
- 2.2k
- Fork
- 466
- Merge medio
- 3g 18h
- PR unite (30g)
- 59
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Shopify/hydrogen
-
ShopifyPrivacyBanner.showBanner()/showPreferences() types declare zero args, but headless stores require storefrontAccessToken (and domains) at runtimeForse già presa @minwookshin l’ha presa 53 giorni fa. Apertainactive
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
Shopify/hydrogen#4069 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
Remix 3: running Hydrogen 2026-10's core without a bindingForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
I maintainer di solito rispondono entro 3 giorni
-
`runWithCache` starts a background refresh for every stale hit, where 2025.7 started one per keyForse già presa @debojyoti10CC l’ha presa 6 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 3 giorni
-
`gql check` and the TS plugin still fail on Windows when schema paths are absoluteForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Shopify/hydrogen#4371 · 2 commenti ·
I maintainer di solito rispondono entro 3 giorni
-
`hydrogen gql check` fails on Windows: absolute schema path is parsed as a URL by gql.tadaForse già presa @Roshan931 l’ha presa 12 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 30/100
Shopify/hydrogen#4359 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di Shopify/hydrogen
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
lidofinance/validator-ejector#233 ·
I maintainer di solito rispondono entro 1 giorno
-
desktop: app-version.v1 in drafts.sqlite is never refreshed — reports 1.19.4 while running 2.3.2Apertaarea/desktop platform/windows type/feature version/v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
anomalyco/opencode#66079 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
ai-driven-qa bug claude Major
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
linagora/twake-mail-admin#742 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
OpenSlides/openslides-client#6728 ·
I maintainer di solito rispondono entro 1 giorno