[PREVIEW — DO NOT MERGE] Location matcher segmentation demo - #9
Closed
JonasJesus42 wants to merge 1 commit into
Closed
[PREVIEW — DO NOT MERGE] Location matcher segmentation demo#9JonasJesus42 wants to merge 1 commit into
JonasJesus42 wants to merge 1 commit into
Conversation
This branch exists ONLY to produce a Cloudflare Workers preview deploy for demoing the regional segmentation flow to merchants and the team. It is not safe to merge into main. What this adds (all should be reverted before any merge): * .deco/blocks/pages-home.json — Carousel section [2] wrapped in a website/flags/multivariate/section.ts flag with three Location-matcher variants: regionCode=RJ → "Olá, Rio de Janeiro!", regionCode=SP → "E aí, São Paulo!", fallback (always.ts) → original "Skate into Adventure!!" copy. Mimics exactly what admin.deco.cx writes when a merchant adds a region variant through the UI. * src/server/cms/blocks.gen.json — regenerated to pick up the variant. * src/matchers/location.ts — local copy of the fixed matcher from decocms/blocks#209 (deco-cx/apps parity + cubic review fixes). Necessary because the framework version pinned here ships a buggy built-in. Delete once we bump to the release with #209. * src/setup.ts — calls registerLocationMatcher() AFTER createSiteSetup so it overrides the buggy built-in (registerBuiltinMatchers runs inside createSiteSetup and would otherwise clobber it). * src/routes/geo-debug.tsx — /geo-debug QA route. Resolves geo source, evaluates 9 sample matcher rules, and renders a RegionGreeting banner that flips per region. Comes with ?simulate=SP|RJ|MG|SC|47 shortcuts for testing without a real CF visitor. * src/worker-entry.ts — adds a ?region= URL override wrapped around decoWorker. Lets QA preview any region from a single IP. Guarded by PREVIEW_REGION_OVERRIDE constant for clarity (still trivially bypassable — must NOT ship to production). Preview URLs once GH Actions deploys: https://pr-<N>-storefront-tanstack-template.deco-cx.workers.dev/ https://pr-<N>-storefront-tanstack-template.deco-cx.workers.dev/?region=SP https://pr-<N>-storefront-tanstack-template.deco-cx.workers.dev/?region=RJ https://pr-<N>-storefront-tanstack-template.deco-cx.workers.dev/geo-debug Refs decocms/blocks#209
Contributor
Preview deployed
|
3 tasks
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.
Caution
DO NOT MERGE. This branch exists only to produce a Cloudflare Workers preview deploy so we can demo the regional segmentation flow end-to-end. Every commit here is intentionally throwaway code: temporary matcher override, demo home variant, QA route, dev region override. None of it is safe for
main.What this previews
The full Location matcher segmentation flow:
/→ Carousel renders🌊 Olá, Rio de Janeiro! Frete grátis para todo o estado./→ Carousel renders🏙️ E aí, São Paulo! Retire na loja do Morumbi hoje.Cache keys are split via
regionIdinbuildSegment(already onmainfrom #8) so different regions get distinct cache entries.QA tools on this preview
/geo-debug— diagnostic page with the resolved geo source + a matrix of 9 sample matcher rules (SP / RJ /"47"raw /country=Brasil/ haversine SP / haversine Rio / empty entry / exclude) and a live RegionGreeting banner that swaps per region.?region=XXon any URL — dev override that rewritescf-region-codeon the inbound request. Lets QA / admins preview any region from a single IP. This is exactly why this branch can't go to main — anyone with the URL can bypass real geo./?region=SP/?region=RJ/?region=MG/geo-debug/geo-debug?simulate=SPWhy this branch needs the local matcher override
@decocms/start@5.2.1(pinned in this repo) ships a buggy built-inwebsite/matchers/location.tsthat drops Brazilian visitors entirely. The fix is in decocms/deco-start#209 but not yet released. Until then,src/matchers/location.tshere is a verbatim copy of the fixed matcher, registered viacustomMatchersso it overrides the framework's built-in.When #209 merges and we bump
@decocms/start, every file in this preview can be deleted.Followups (not this PR)
@decocms/start@5.x.x@decocms/starton Bagaggio / Miess / Granado, drop any local override copiesadmin.deco.cxUI (not by hand-editing JSON)🤖 Generated with Claude Code