Repository navigation
Closed
Labels
agent-readyScoped well enough for a coding agent to take; a person reviews the PRe-commerceShopping, product catalog, store and marketplace connectorsenhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is needed
Description
Problem
Every product card AI shows links somewhere. prompt_result_shopping_cards keeps the link (merchant_url) and its host (merchant_domain, from extractDomain). Nothing says whether that host is the brand's own store, a marketplace or another reseller.
That answer feeds two things:
- "Where AI sends shoppers", a split of a brand's product cards by destination: your store, Amazon, Walmart, eBay, others.
- Matching marketplace listings to the brand's catalog.
The hosts aren't clean. In 30 days of Copilot cards there are 286 merchant hosts, including:
- Affiliate redirects:
s.click.aliexpress.com(570 cards) with the destination indl_target_url, andgoto.walmart.comwith the destination inu. - Other subdomains:
business.walmart.com. - Country domains:
amazon.de,amazon.nl,amazon.in,ebay.co.uk,ebay.it. - Tracking parameters on every link.
Proposal
Add a pure function, server/src/lib/merchant-detection.js:
classifyMerchant(merchantUrl, { brandDomains })
// → { kind: 'own' | 'marketplace' | 'reseller',
// marketplace: 'amazon' | 'ebay' | 'walmart' | 'etsy' | 'aliexpress' | 'temu' | 'trendyol' | 'hepsiburada' | null,
// listingId: string | null }- Marketplace hosts live in a JSON file, like
ai-sources.json, keyed by marketplace and listing its country domains and redirect hosts. A host matches when it equals a listed host or is a subdomain of one. - Redirects: when a redirect link carries its destination in a parameter, classify the destination.
- Own store: the host is one of
brandDomainsor a subdomain of one. - Listing IDs:
- Amazon ASIN from
/dp/<ASIN>or/gp/product/<ASIN>. An ASIN is 10 letters or digits; book ASINs are all digits. - eBay item id from
/itm/<id>. - Walmart item id from
/ip/<slug>/<id>. - Etsy listing id from
/listing/<id>.
- Amazon ASIN from
- Anything else is
reseller. - Tests in
merchant-detection.test.js, with a fixture list of made-up URLs in each of the shapes above.
Storing the result on each card and drawing the split come in a follow-up.
Acceptance criteria
- Every fixture URL classifies correctly, including the redirect, subdomain and country-domain shapes.
- An unknown host returns
reseller. A malformed URL returnsresellerwith no listing id and doesn't throw. cd server && npm testpasses.
Metadata
Metadata
Assignees
Labels
agent-readyScoped well enough for a coding agent to take; a person reviews the PRe-commerceShopping, product catalog, store and marketplace connectorsenhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is needed
Activity