Render {% pixels %} in the base layout, recover from a consumed cart id; release 1.3.0 - #55
Merged
Conversation
The platform injects every app's storefront event tracker (GA4, GTM,
Klaviyo, Taboola) as hidden iframes through the builtin {% pixels %} tag.
Intro Bootstrap reaches it indirectly through {% core_js %}; Spark replaced
core_js with spark-platform.js and never re-added pixels, so no tracker
iframe rendered, window.customerEventManager never existed, and no app
received any storefront event on Spark-based stores.
Add a `pixels` block before the theme script stack so the tag's fetch hook
is installed before spark-cart and friends make requests. Document the
block in the load-order contract, CLAUDE.md, and the changelog.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
next-devin
marked this pull request as ready for review
September 3, 2026 04:10
Bump the version markers in manifest.json, README.md, and CLAUDE.md, and promote the Unreleased changelog section to a dated 1.3.0 heading. Adds entries for the merged-but-unlogged changes since 1.2.0: the filter-argument escape check (#52), the scoped Tailwind content scan (#53), and the __pycache__ ignore (#54). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Reproduced on aptest.29next.store on 2026-09-03 right after an order
completed: every addCartLines afterwards returned HTTP 200 with
{"addCartLines":{"success":false,"errors":{"nonFieldErrors":
[[{"message":"Cart not found.","code":"cart_not_found"}]]},"cart":null}}
and the shopper could not add anything until browser storage was cleared.
Two things combined. The consumed cart id stays in sessionStorage and the
storefront_cart_id cookie because the order-confirmation page is rendered by
the platform, not the theme, so nothing on the theme side ever ran to forget
it. And addToCart only recovered when the request *rejected* and the message
matched isCartExpiredError; this payload resolves, so the .then branch handed
back success:false and the create-and-retry path never ran.
- isCartNotFoundResult() recognises the resolved shape (code cart_not_found,
or a message matching the existing expired-cart heuristic, at any depth of
the errors object).
- addToCart settles the request into an outcome first, then recovers exactly
once for either a rejection or a resolved cart_not_found: clear the stored
id, createCart, retry with recover=false. A failure inside the retry cannot
re-enter the recovery branch.
- getCart clears the stored id when the platform returns cart:null or a
not-found error. Badge hydration calls this on the first storefront page
after confirmation, so the stale id is gone before the shopper's next add.
- updateCartLines, removeCartLines, addVoucher, removeVoucher clear the id on
cart_not_found without recreating (the caller is editing a cart it believes
exists), so a stale id cannot leak into the next add.
- clearCartId() removes the sessionStorage key and expires the cookie.
Tests: the exact aptest payload on the first add asserts createCart and a
second addCartLines follow with the new id stored; a second miss returns the
platform answer without looping; getCart null/reject and each explicit-id
mutation clear the stored id and dispatch nothing.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (8 files)
Fix these issues in Kilo Cloud Previous Review Summary (commit 1df9121)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 1df9121)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (8 files)
Reviewed by minimax-m3 · Input: 23.2K · Output: 1.9K · Cached: 239.4K |
…resolved result Review finding on #55: isCartNotFoundResult fell back to isCartExpiredError, whose substring match on "invalid" would have flagged ordinary resolved validation errors ("Invalid quantity", "Invalid voucher code") as a missing cart and wiped a live cart id. Resolved results now count only the cart_not_found code or a message naming the cart as not found; the broad matcher stays on the rejection path where it started. Regression test covers an add, a voucher, and a line update that each fail validation with "invalid" in the message and assert no recreate and the id kept. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Two Spark bugs found on aptest.29next.store on 2026-09-03, plus the 1.3.0 release bump. Three commits, one per concern.
1. App event trackers never load
Spark-based stores send no storefront events to any installed app. The platform injects each app's event tracker (Google Analytics 4, Google Tag Manager, Klaviyo, Taboola) as a hidden iframe through the builtin
{% pixels %}template tag. In Intro Bootstrap that tag is rendered indirectly by{% core_js %}at the end oflayouts/base.html. Spark deliberately droppedcore_js(jQuery-free design, replaced byassets/js/spark-platform.js) and never re-added{% pixels %}.Verification. Checked in a browser on aptest.29next.store:
iframe[name=customer_event_iframe]elements in the DOMwindow.customerEventManagerpage_viewed,product_viewed,product_added_to_cart, orcheckout_*The developer docs (
content/docs/storefront/themes/templates/tags.mdin developer-docs) saycore_jsis required in every base layout; this is the part of it Spark still needs.Platform chain (traced in the platform source).
core_js→pixels→customer_event_manager(loadspixels/js/dist/pixels.min.js, createswindow.customerEventManager, hookswindow.fetchandhtmx:afterRequestto read theAnalytic-Eventsresponse header) +customer_event_iframes(one hidden iframe per active tracker, plus a script that publishes the page's server-side events to each frame on load). Guarded by{% if not disable_pixel %}. All three tags are platform builtins, so no{% load %}is needed, and none of it depends on jQuery.Points checked against Intro Bootstrap and the platform templates:
core_jsis the only place Intro Bootstrap touches tracking; the rest of that tag is jQuery plumbing Spark already replaced.object/object_listforproduct_viewedand category events, not template variables, so Spark templates need nothing extra.Analytic-Eventsto every response and the manager wrapswindow.fetch.spark-cart.jscalls barefetch()at call time, so it picks up the patched global; the wrapper preserves the abort-signal init.{% pixels %}themselves and do not extend the theme layout, so there is no double render.Change.
layouts/base.htmlgets{% block pixels %}{% pixels %}{% endblock %}immediately before{% block scripts %}.docs/performance-load-order.mdandCLAUDE.mddocument the block.2. Add-to-cart is dead after a purchase until browser storage is cleared
Reproduced right after an order completed on aptest.29next.store: every add afterwards returned HTTP 200 with
{"addCartLines":{"success":false,"errors":{"nonFieldErrors":[[{"message":"Cart not found.","code":"cart_not_found"}]]},"cart":null}}Cause. Checkout consumes the cart, but its id stays in
sessionStorageand thestorefront_cart_idcookie: the order-confirmation page is rendered by the platform, not the theme, so nothing theme-side runs to forget it.SparkCartClient.addToCartonly recovered when the request rejected and the message matchedisCartExpiredError. This payload resolves, so the.thenbranch handed backsuccess: falseand the create-and-retry path never ran.Change (
assets/js/spark-cart.js).isCartNotFoundResult()recognises the resolved shape (codecart_not_found, or a message matching the existing expired-cart heuristic, at any depth oferrors).addToCartsettles the request into an outcome first, then recovers exactly once for either a rejection or a resolvedcart_not_found: clear the stored id,createCart, retry with recovery off. A failure inside the retry cannot re-enter the recovery branch.getCartclears the stored id when the platform returnscart: nullor a not-found error. Badge hydration calls this on the first storefront page after confirmation, so the stale id is gone before the shopper's next add.updateCartLines,removeCartLines,addVoucher,removeVoucherclear the id oncart_not_foundwithout recreating (the caller is editing a cart it believes exists), so a stale id cannot leak into the next add.Tests (
tests/js/spark-cart-client.test.js, 14 → 17). The exact aptest payload on the first add assertscreateCartand a secondaddCartLinesfollow with the new id stored; a second miss returns the platform answer without looping;getCartnull/reject and each explicit-id mutation clear the stored id and dispatch nothing.3. Release 1.3.0
Bumps
manifest.json,README.md, andCLAUDE.mdto 1.3.0 and promotes the Unreleased changelog section to a dated1.3.0heading, with entries for both fixes above and for the changes merged since 1.2.0 that had none (#52, #53, #54). Tag / GitHub release to follow after merge.Checks
python3 -m unittest discover -s tests: 61 tests OK (the Tailwind source-guard tests need thetailwindcssbinary in the checkout).for f in tests/js/*.test.js; do node "$f"; done: all pass.scripts/check-templates.py: template integrity gate passed (62 templates).make css-check: rebuiltassets/main.cssis byte-identical to the committed file, Sass-compat OK.Related
Velin (Sellmore-Co/velin-theme, a Spark derivative) has the same gaps and received the same fixes separately.
🤖 Generated with Claude Code