Repository navigation
fix(analytics): run heatmap view mode in a window Studio opened - #848
Merged
Merged
Conversation
Some commerce platforms fix a store's frame-ancestors to its own domain, so Studio can never frame those stores to draw their heatmap. View mode now also starts when the page has an opener, and the view chunk speaks to window.opener when it is not framed. The allow-list and origin pinning are unchanged. Mirrors decocms/analytics#77: both copies build to the same bytes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
4 tasks done
Mirrors decocms/analytics#77. Frames accept any *.decocms.com parent, sandbox previews included. A window skips the store's frame-ancestors and carries the visitor's cookies, so an opener must be studio.decocms.com, studio-stg.decocms.com or localhost. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
yuriassuncx
approved these changes
Nov 25, 2026
|
🎉 This PR is included in version 8.22.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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.
Why
This keeps the analytics copy in sync with decocms/analytics#77. Some commerce platforms fix a store's
frame-ancestorsto the store's own domain, so Studio's Heatmap tab can never frame those stores. Studio now opens the store in a window instead, and the view chunk has to talk to the window that opened it.What changes
runtime/src/index.ts: view mode starts when the URL hasdq_view=1and the page is framed or has an opener.runtime/view/view.ts: the parent iswindow.parentwhen framed, elsewindow.opener. A frame keeps the*.decocms.comallow-list. An opener must be Studio itself (studio.decocms.com,studio-stg.decocms.comor localhost): a window skips the store'sframe-ancestorsand carries the visitor's cookies, and the wildcard includes sandbox previews.Until decocms/analytics builds the tag from this package (task 3.7), its
runtime/is what production serves. That is why the change lands in both copies.Verification
node ops/build-tag.mjs --check --src <this repo>/packages/blocks/src/v8/analytics, run from decocms/analytics#77: "matches worker/tag.lock.json (10 bundles)".bun run typecheckpassed on every package.biome checkonsrc/v8/analytics/runtimeis clean.npx vitest run packages/blocks/src/v8/analytics: 48 passed.Summary by cubic
Fixes analytics heatmap view mode to work on stores that can't be framed by Studio. Some commerce platforms fix a store's
frame-ancestorsto its own domain, so Studio now opens those stores in a window, and the heatmap view chunk must talk to the window that opened it. View mode starts when the URL carriesdq_view=1and the page is framed or has an opener; the parent iswindow.parentwhen framed, elsewindow.opener. Because a window carries the visitor's cookies and skips the store'sframe-ancestors, windows accept only Studio itself (studio.decocms.com, studio-stg.decocms.com, localhost) as opener, while frames keep the existing*.decocms.comallow-list. Mirrors decocms/analytics#77 so both copies build to the same bytes.Written for commit 21fc38a. Summary will update on new commits.