Repository navigation
feat(shopping): show where AI sends shoppers, and flag resellers cheaper than the brand - #1460
Merged
Merged
Conversation
…h its source per market (#1278) - lib/shopping/markets: one country-to-market helper. US and US state codes map to the US; EU / EEA countries, the UK and Switzerland to Europe; anything else to none. Also the default market and each market's region codes. - getBrandMarketCountries reads the brand's domain countries and every prompt's location codes (paged past the 1,000-row cap). - The Shopping page opens on the US when the brand has US countries and on Europe when all of them are European. With no market it shows no switch and makes no source claim. The choice is remembered per brand in localStorage. - The switch shows where ChatGPT's products come from in each market and keeps ChatGPT Shopping cards to that market's regions in the card reads. Other platforms' cards are unaffected. A picked region already narrows every platform, so the switch then follows that region, and choosing a market clears the region.
…arket (#1278) - 00267 adds p_chatgpt_regions to shopping_overview. It narrows ChatGPT Shopping's results and cards only; null (the default) reads exactly what the function did before. The 6-argument version is dropped so PostgREST sees one candidate, and its grants are restored. Apply the migration before deploying the web. - loadShoppingOverview passes the market's regions only while the market filter applies (All regions picked), the same rule as the card reads. Reports call without it and are unchanged. Behaviour kept from the switch: - A brand opens on Europe only when every country is European; DE + TR gets no market, no switch and no claim. - Both markets are offered once a brand has one. - While a market applies, ChatGPT cards from other countries show only through the region filter. - The switch shows with shopping mode off, paused prompts count as the brand's countries, brands.region is not read, and a ChatGPT card with no region is left out under a market.
…per than the brand (#1277) Migration 00268 adds two reads over the brand's own-product cards, in the Overview tab's window and filters, ChatGPT Shopping's market included (p_chatgpt_regions, as shopping_overview has since 00267): - shopping_merchant_split counts the cards per destination (your store, Amazon, Walmart, eBay, other marketplaces, other resellers) and the unclassified ones apart. - shopping_own_product_offers returns each merchant's lowest price per listing, title and currency as one jsonb list. Both are security definer behind the same membership check as shopping_amazon_share_weekly; anon and public can't execute them. The Overview tab gets a "Where AI sends shoppers" card (split bar and legend with counts and percentages that add up to 100) and a "Resellers cheaper than you" list with both prices and both links. Both wait for the market like the rest of the Overview. The rule lives in detectResellerPriceAlerts: offers match by listing id or normalized title, and a reseller is flagged at 5% or more below the store's lowest price in the same currency.
7 of 12 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.
Summary
Parts 2–4 of #1277: where AI sends shoppers for the brand's own products, and resellers cheaper than the brand. Part 1, storing each card's destination, shipped in #1313 (00225).
Stacked on #1459 (the market switch); review that first.
00268_shopping_merchant_splitadds two reads over the brand's own-product cards. They use the Overview tab's window and filters, ChatGPT Shopping's market included (p_chatgpt_regions, asshopping_overviewhas since 00267):shopping_merchant_splitcounts cards per destination: your store, Amazon, Walmart, eBay, other marketplaces, other resellers. Unclassified cards are counted apart.shopping_own_product_offersreturns each merchant's lowest price per listing, title and currency, as one jsonb list (no 1,000-row cap).security definerbehind the same membership check asshopping_amazon_share_weekly, withsearch_pathset.anonandpubliccan't execute them.detectResellerPriceAlerts) matches offers by listing id, else by normalized title, within the brand's own products. It flags a reseller or marketplace at 5% or more below the store's lowest price in the same currency.product_brandisn't part of the match. On these cards it often holds the seller's name, so the store and the reseller would never pair.Prod dry run (rolled back), with 00267 then 00268:
shopping_overview's own cards.Not here yet: the split on Shelf and in the Products table, and the Readiness row. Those views don't exist yet.
Related issue
Closes #1277
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)🤖 Generated with Claude Code