fix(analytics): run heatmap view mode in a window Studio opened
Why
This keeps the analytics copy in sync with decocms/analytics#77. Some commerce platforms fix a store's frame-ancestors to 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-ancestors to 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 carries dq_view=1 and the page is framed or has an opener; the parent is window.parent when framed, else window.opener. Because a window carries the visitor's cookies and skips the store's frame-ancestors, windows accept only Studio itself (studio.decocms.com, studio-stg.decocms.com, localhost) as opener, while frames keep the existing *.decocms.com allow-list. Mirrors decocms/analytics#77 so both copies build to the same bytes.