Skip to content

feat(shopping): classify where each product card sends shoppers: own store, marketplace or reseller #1186

Closed

Description

@gkhngyk

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 in dl_target_url, and goto.walmart.com with the destination in u.
  • 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 brandDomains or 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>.
  • 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 returns reseller with no listing id and doesn't throw.
  • cd server && npm test passes.

Activity

  1. added
    enhancement
    good first issue
    help wanted
    e-commerce
    agent-ready
    on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readye-commerceenhancementgood first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions